documentation.d.ts 3.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704
  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. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  31780. * @returns an array of particle systems in the scene that use the mesh as an emitter
  31781. */
  31782. getConnectedParticleSystems(): IParticleSystem[];
  31783. }
  31784. }
  31785. declare module BABYLON {
  31786. /**
  31787. * Interface used to define ActionEvent
  31788. */
  31789. export interface IActionEvent {
  31790. /** The mesh or sprite that triggered the action */
  31791. source: any;
  31792. /** The X mouse cursor position at the time of the event */
  31793. pointerX: number;
  31794. /** The Y mouse cursor position at the time of the event */
  31795. pointerY: number;
  31796. /** The mesh that is currently pointed at (can be null) */
  31797. meshUnderPointer: Nullable<AbstractMesh>;
  31798. /** the original (browser) event that triggered the ActionEvent */
  31799. sourceEvent?: any;
  31800. /** additional data for the event */
  31801. additionalData?: any;
  31802. }
  31803. /**
  31804. * ActionEvent is the event being sent when an action is triggered.
  31805. */
  31806. export class ActionEvent implements IActionEvent {
  31807. /** The mesh or sprite that triggered the action */
  31808. source: any;
  31809. /** The X mouse cursor position at the time of the event */
  31810. pointerX: number;
  31811. /** The Y mouse cursor position at the time of the event */
  31812. pointerY: number;
  31813. /** The mesh that is currently pointed at (can be null) */
  31814. meshUnderPointer: Nullable<AbstractMesh>;
  31815. /** the original (browser) event that triggered the ActionEvent */
  31816. sourceEvent?: any;
  31817. /** additional data for the event */
  31818. additionalData?: any;
  31819. /**
  31820. * Creates a new ActionEvent
  31821. * @param source The mesh or sprite that triggered the action
  31822. * @param pointerX The X mouse cursor position at the time of the event
  31823. * @param pointerY The Y mouse cursor position at the time of the event
  31824. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31825. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31826. * @param additionalData additional data for the event
  31827. */
  31828. constructor(
  31829. /** The mesh or sprite that triggered the action */
  31830. source: any,
  31831. /** The X mouse cursor position at the time of the event */
  31832. pointerX: number,
  31833. /** The Y mouse cursor position at the time of the event */
  31834. pointerY: number,
  31835. /** The mesh that is currently pointed at (can be null) */
  31836. meshUnderPointer: Nullable<AbstractMesh>,
  31837. /** the original (browser) event that triggered the ActionEvent */
  31838. sourceEvent?: any,
  31839. /** additional data for the event */
  31840. additionalData?: any);
  31841. /**
  31842. * Helper function to auto-create an ActionEvent from a source mesh.
  31843. * @param source The source mesh that triggered the event
  31844. * @param evt The original (browser) event
  31845. * @param additionalData additional data for the event
  31846. * @returns the new ActionEvent
  31847. */
  31848. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31849. /**
  31850. * Helper function to auto-create an ActionEvent from a source sprite
  31851. * @param source The source sprite that triggered the event
  31852. * @param scene Scene associated with the sprite
  31853. * @param evt The original (browser) event
  31854. * @param additionalData additional data for the event
  31855. * @returns the new ActionEvent
  31856. */
  31857. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31858. /**
  31859. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31860. * @param scene the scene where the event occurred
  31861. * @param evt The original (browser) event
  31862. * @returns the new ActionEvent
  31863. */
  31864. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31865. /**
  31866. * Helper function to auto-create an ActionEvent from a primitive
  31867. * @param prim defines the target primitive
  31868. * @param pointerPos defines the pointer position
  31869. * @param evt The original (browser) event
  31870. * @param additionalData additional data for the event
  31871. * @returns the new ActionEvent
  31872. */
  31873. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31874. }
  31875. }
  31876. declare module BABYLON {
  31877. /**
  31878. * Abstract class used to decouple action Manager from scene and meshes.
  31879. * Do not instantiate.
  31880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31881. */
  31882. export abstract class AbstractActionManager implements IDisposable {
  31883. /** Gets the list of active triggers */
  31884. static Triggers: {
  31885. [key: string]: number;
  31886. };
  31887. /** Gets the cursor to use when hovering items */
  31888. hoverCursor: string;
  31889. /** Gets the list of actions */
  31890. actions: IAction[];
  31891. /**
  31892. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31893. */
  31894. isRecursive: boolean;
  31895. /**
  31896. * Releases all associated resources
  31897. */
  31898. abstract dispose(): void;
  31899. /**
  31900. * Does this action manager has pointer triggers
  31901. */
  31902. abstract get hasPointerTriggers(): boolean;
  31903. /**
  31904. * Does this action manager has pick triggers
  31905. */
  31906. abstract get hasPickTriggers(): boolean;
  31907. /**
  31908. * Process a specific trigger
  31909. * @param trigger defines the trigger to process
  31910. * @param evt defines the event details to be processed
  31911. */
  31912. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31913. /**
  31914. * Does this action manager handles actions of any of the given triggers
  31915. * @param triggers defines the triggers to be tested
  31916. * @return a boolean indicating whether one (or more) of the triggers is handled
  31917. */
  31918. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31919. /**
  31920. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31921. * speed.
  31922. * @param triggerA defines the trigger to be tested
  31923. * @param triggerB defines the trigger to be tested
  31924. * @return a boolean indicating whether one (or more) of the triggers is handled
  31925. */
  31926. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31927. /**
  31928. * Does this action manager handles actions of a given trigger
  31929. * @param trigger defines the trigger to be tested
  31930. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31931. * @return whether the trigger is handled
  31932. */
  31933. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31934. /**
  31935. * Serialize this manager to a JSON object
  31936. * @param name defines the property name to store this manager
  31937. * @returns a JSON representation of this manager
  31938. */
  31939. abstract serialize(name: string): any;
  31940. /**
  31941. * Registers an action to this action manager
  31942. * @param action defines the action to be registered
  31943. * @return the action amended (prepared) after registration
  31944. */
  31945. abstract registerAction(action: IAction): Nullable<IAction>;
  31946. /**
  31947. * Unregisters an action to this action manager
  31948. * @param action defines the action to be unregistered
  31949. * @return a boolean indicating whether the action has been unregistered
  31950. */
  31951. abstract unregisterAction(action: IAction): Boolean;
  31952. /**
  31953. * Does exist one action manager with at least one trigger
  31954. **/
  31955. static get HasTriggers(): boolean;
  31956. /**
  31957. * Does exist one action manager with at least one pick trigger
  31958. **/
  31959. static get HasPickTriggers(): boolean;
  31960. /**
  31961. * Does exist one action manager that handles actions of a given trigger
  31962. * @param trigger defines the trigger to be tested
  31963. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31964. **/
  31965. static HasSpecificTrigger(trigger: number): boolean;
  31966. }
  31967. }
  31968. declare module BABYLON {
  31969. /**
  31970. * Defines how a node can be built from a string name.
  31971. */
  31972. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31973. /**
  31974. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31975. */
  31976. export class Node implements IBehaviorAware<Node> {
  31977. /** @hidden */
  31978. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31979. private static _NodeConstructors;
  31980. /**
  31981. * Add a new node constructor
  31982. * @param type defines the type name of the node to construct
  31983. * @param constructorFunc defines the constructor function
  31984. */
  31985. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31986. /**
  31987. * Returns a node constructor based on type name
  31988. * @param type defines the type name
  31989. * @param name defines the new node name
  31990. * @param scene defines the hosting scene
  31991. * @param options defines optional options to transmit to constructors
  31992. * @returns the new constructor or null
  31993. */
  31994. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31995. /**
  31996. * Gets or sets the name of the node
  31997. */
  31998. name: string;
  31999. /**
  32000. * Gets or sets the id of the node
  32001. */
  32002. id: string;
  32003. /**
  32004. * Gets or sets the unique id of the node
  32005. */
  32006. uniqueId: number;
  32007. /**
  32008. * Gets or sets a string used to store user defined state for the node
  32009. */
  32010. state: string;
  32011. /**
  32012. * Gets or sets an object used to store user defined information for the node
  32013. */
  32014. metadata: any;
  32015. /**
  32016. * For internal use only. Please do not use.
  32017. */
  32018. reservedDataStore: any;
  32019. /**
  32020. * List of inspectable custom properties (used by the Inspector)
  32021. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32022. */
  32023. inspectableCustomProperties: IInspectable[];
  32024. private _doNotSerialize;
  32025. /**
  32026. * Gets or sets a boolean used to define if the node must be serialized
  32027. */
  32028. get doNotSerialize(): boolean;
  32029. set doNotSerialize(value: boolean);
  32030. /** @hidden */
  32031. _isDisposed: boolean;
  32032. /**
  32033. * Gets a list of Animations associated with the node
  32034. */
  32035. animations: Animation[];
  32036. protected _ranges: {
  32037. [name: string]: Nullable<AnimationRange>;
  32038. };
  32039. /**
  32040. * Callback raised when the node is ready to be used
  32041. */
  32042. onReady: Nullable<(node: Node) => void>;
  32043. private _isEnabled;
  32044. private _isParentEnabled;
  32045. private _isReady;
  32046. /** @hidden */
  32047. _currentRenderId: number;
  32048. private _parentUpdateId;
  32049. /** @hidden */
  32050. _childUpdateId: number;
  32051. /** @hidden */
  32052. _waitingParentId: Nullable<string>;
  32053. /** @hidden */
  32054. _scene: Scene;
  32055. /** @hidden */
  32056. _cache: any;
  32057. private _parentNode;
  32058. private _children;
  32059. /** @hidden */
  32060. _worldMatrix: Matrix;
  32061. /** @hidden */
  32062. _worldMatrixDeterminant: number;
  32063. /** @hidden */
  32064. _worldMatrixDeterminantIsDirty: boolean;
  32065. /** @hidden */
  32066. private _sceneRootNodesIndex;
  32067. /**
  32068. * Gets a boolean indicating if the node has been disposed
  32069. * @returns true if the node was disposed
  32070. */
  32071. isDisposed(): boolean;
  32072. /**
  32073. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32074. * @see https://doc.babylonjs.com/how_to/parenting
  32075. */
  32076. set parent(parent: Nullable<Node>);
  32077. get parent(): Nullable<Node>;
  32078. /** @hidden */
  32079. _addToSceneRootNodes(): void;
  32080. /** @hidden */
  32081. _removeFromSceneRootNodes(): void;
  32082. private _animationPropertiesOverride;
  32083. /**
  32084. * Gets or sets the animation properties override
  32085. */
  32086. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32087. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32088. /**
  32089. * Gets a string idenfifying the name of the class
  32090. * @returns "Node" string
  32091. */
  32092. getClassName(): string;
  32093. /** @hidden */
  32094. readonly _isNode: boolean;
  32095. /**
  32096. * An event triggered when the mesh is disposed
  32097. */
  32098. onDisposeObservable: Observable<Node>;
  32099. private _onDisposeObserver;
  32100. /**
  32101. * Sets a callback that will be raised when the node will be disposed
  32102. */
  32103. set onDispose(callback: () => void);
  32104. /**
  32105. * Creates a new Node
  32106. * @param name the name and id to be given to this node
  32107. * @param scene the scene this node will be added to
  32108. */
  32109. constructor(name: string, scene?: Nullable<Scene>);
  32110. /**
  32111. * Gets the scene of the node
  32112. * @returns a scene
  32113. */
  32114. getScene(): Scene;
  32115. /**
  32116. * Gets the engine of the node
  32117. * @returns a Engine
  32118. */
  32119. getEngine(): Engine;
  32120. private _behaviors;
  32121. /**
  32122. * Attach a behavior to the node
  32123. * @see http://doc.babylonjs.com/features/behaviour
  32124. * @param behavior defines the behavior to attach
  32125. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32126. * @returns the current Node
  32127. */
  32128. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32129. /**
  32130. * Remove an attached behavior
  32131. * @see http://doc.babylonjs.com/features/behaviour
  32132. * @param behavior defines the behavior to attach
  32133. * @returns the current Node
  32134. */
  32135. removeBehavior(behavior: Behavior<Node>): Node;
  32136. /**
  32137. * Gets the list of attached behaviors
  32138. * @see http://doc.babylonjs.com/features/behaviour
  32139. */
  32140. get behaviors(): Behavior<Node>[];
  32141. /**
  32142. * Gets an attached behavior by name
  32143. * @param name defines the name of the behavior to look for
  32144. * @see http://doc.babylonjs.com/features/behaviour
  32145. * @returns null if behavior was not found else the requested behavior
  32146. */
  32147. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32148. /**
  32149. * Returns the latest update of the World matrix
  32150. * @returns a Matrix
  32151. */
  32152. getWorldMatrix(): Matrix;
  32153. /** @hidden */
  32154. _getWorldMatrixDeterminant(): number;
  32155. /**
  32156. * Returns directly the latest state of the mesh World matrix.
  32157. * A Matrix is returned.
  32158. */
  32159. get worldMatrixFromCache(): Matrix;
  32160. /** @hidden */
  32161. _initCache(): void;
  32162. /** @hidden */
  32163. updateCache(force?: boolean): void;
  32164. /** @hidden */
  32165. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32166. /** @hidden */
  32167. _updateCache(ignoreParentClass?: boolean): void;
  32168. /** @hidden */
  32169. _isSynchronized(): boolean;
  32170. /** @hidden */
  32171. _markSyncedWithParent(): void;
  32172. /** @hidden */
  32173. isSynchronizedWithParent(): boolean;
  32174. /** @hidden */
  32175. isSynchronized(): boolean;
  32176. /**
  32177. * Is this node ready to be used/rendered
  32178. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32179. * @return true if the node is ready
  32180. */
  32181. isReady(completeCheck?: boolean): boolean;
  32182. /**
  32183. * Is this node enabled?
  32184. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  32185. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  32186. * @return whether this node (and its parent) is enabled
  32187. */
  32188. isEnabled(checkAncestors?: boolean): boolean;
  32189. /** @hidden */
  32190. protected _syncParentEnabledState(): void;
  32191. /**
  32192. * Set the enabled state of this node
  32193. * @param value defines the new enabled state
  32194. */
  32195. setEnabled(value: boolean): void;
  32196. /**
  32197. * Is this node a descendant of the given node?
  32198. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32199. * @param ancestor defines the parent node to inspect
  32200. * @returns a boolean indicating if this node is a descendant of the given node
  32201. */
  32202. isDescendantOf(ancestor: Node): boolean;
  32203. /** @hidden */
  32204. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32205. /**
  32206. * Will return all nodes that have this node as ascendant
  32207. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  32208. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  32209. * @return all children nodes of all types
  32210. */
  32211. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32212. /**
  32213. * Get all child-meshes of this node
  32214. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  32215. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  32216. * @returns an array of AbstractMesh
  32217. */
  32218. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32219. /**
  32220. * Get all direct children of this node
  32221. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  32222. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  32223. * @returns an array of Node
  32224. */
  32225. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32226. /** @hidden */
  32227. _setReady(state: boolean): void;
  32228. /**
  32229. * Get an animation by name
  32230. * @param name defines the name of the animation to look for
  32231. * @returns null if not found else the requested animation
  32232. */
  32233. getAnimationByName(name: string): Nullable<Animation>;
  32234. /**
  32235. * Creates an animation range for this node
  32236. * @param name defines the name of the range
  32237. * @param from defines the starting key
  32238. * @param to defines the end key
  32239. */
  32240. createAnimationRange(name: string, from: number, to: number): void;
  32241. /**
  32242. * Delete a specific animation range
  32243. * @param name defines the name of the range to delete
  32244. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32245. */
  32246. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32247. /**
  32248. * Get an animation range by name
  32249. * @param name defines the name of the animation range to look for
  32250. * @returns null if not found else the requested animation range
  32251. */
  32252. getAnimationRange(name: string): Nullable<AnimationRange>;
  32253. /**
  32254. * Gets the list of all animation ranges defined on this node
  32255. * @returns an array
  32256. */
  32257. getAnimationRanges(): Nullable<AnimationRange>[];
  32258. /**
  32259. * Will start the animation sequence
  32260. * @param name defines the range frames for animation sequence
  32261. * @param loop defines if the animation should loop (false by default)
  32262. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32263. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32264. * @returns the object created for this animation. If range does not exist, it will return null
  32265. */
  32266. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32267. /**
  32268. * Serialize animation ranges into a JSON compatible object
  32269. * @returns serialization object
  32270. */
  32271. serializeAnimationRanges(): any;
  32272. /**
  32273. * Computes the world matrix of the node
  32274. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32275. * @returns the world matrix
  32276. */
  32277. computeWorldMatrix(force?: boolean): Matrix;
  32278. /**
  32279. * Releases resources associated with this node.
  32280. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32281. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32282. */
  32283. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32284. /**
  32285. * Parse animation range data from a serialization object and store them into a given node
  32286. * @param node defines where to store the animation ranges
  32287. * @param parsedNode defines the serialization object to read data from
  32288. * @param scene defines the hosting scene
  32289. */
  32290. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32291. /**
  32292. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32293. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32294. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  32295. * @returns the new bounding vectors
  32296. */
  32297. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32298. min: Vector3;
  32299. max: Vector3;
  32300. };
  32301. }
  32302. }
  32303. declare module BABYLON {
  32304. /**
  32305. * @hidden
  32306. */
  32307. export class _IAnimationState {
  32308. key: number;
  32309. repeatCount: number;
  32310. workValue?: any;
  32311. loopMode?: number;
  32312. offsetValue?: any;
  32313. highLimitValue?: any;
  32314. }
  32315. /**
  32316. * Class used to store any kind of animation
  32317. */
  32318. export class Animation {
  32319. /**Name of the animation */
  32320. name: string;
  32321. /**Property to animate */
  32322. targetProperty: string;
  32323. /**The frames per second of the animation */
  32324. framePerSecond: number;
  32325. /**The data type of the animation */
  32326. dataType: number;
  32327. /**The loop mode of the animation */
  32328. loopMode?: number | undefined;
  32329. /**Specifies if blending should be enabled */
  32330. enableBlending?: boolean | undefined;
  32331. /**
  32332. * Use matrix interpolation instead of using direct key value when animating matrices
  32333. */
  32334. static AllowMatricesInterpolation: boolean;
  32335. /**
  32336. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32337. */
  32338. static AllowMatrixDecomposeForInterpolation: boolean;
  32339. /** Define the Url to load snippets */
  32340. static SnippetUrl: string;
  32341. /** Snippet ID if the animation was created from the snippet server */
  32342. snippetId: string;
  32343. /**
  32344. * Stores the key frames of the animation
  32345. */
  32346. private _keys;
  32347. /**
  32348. * Stores the easing function of the animation
  32349. */
  32350. private _easingFunction;
  32351. /**
  32352. * @hidden Internal use only
  32353. */
  32354. _runtimeAnimations: RuntimeAnimation[];
  32355. /**
  32356. * The set of event that will be linked to this animation
  32357. */
  32358. private _events;
  32359. /**
  32360. * Stores an array of target property paths
  32361. */
  32362. targetPropertyPath: string[];
  32363. /**
  32364. * Stores the blending speed of the animation
  32365. */
  32366. blendingSpeed: number;
  32367. /**
  32368. * Stores the animation ranges for the animation
  32369. */
  32370. private _ranges;
  32371. /**
  32372. * @hidden Internal use
  32373. */
  32374. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32375. /**
  32376. * Sets up an animation
  32377. * @param property The property to animate
  32378. * @param animationType The animation type to apply
  32379. * @param framePerSecond The frames per second of the animation
  32380. * @param easingFunction The easing function used in the animation
  32381. * @returns The created animation
  32382. */
  32383. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32384. /**
  32385. * Create and start an animation on a node
  32386. * @param name defines the name of the global animation that will be run on all nodes
  32387. * @param node defines the root node where the animation will take place
  32388. * @param targetProperty defines property to animate
  32389. * @param framePerSecond defines the number of frame per second yo use
  32390. * @param totalFrame defines the number of frames in total
  32391. * @param from defines the initial value
  32392. * @param to defines the final value
  32393. * @param loopMode defines which loop mode you want to use (off by default)
  32394. * @param easingFunction defines the easing function to use (linear by default)
  32395. * @param onAnimationEnd defines the callback to call when animation end
  32396. * @returns the animatable created for this animation
  32397. */
  32398. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32399. /**
  32400. * Create and start an animation on a node and its descendants
  32401. * @param name defines the name of the global animation that will be run on all nodes
  32402. * @param node defines the root node where the animation will take place
  32403. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  32404. * @param targetProperty defines property to animate
  32405. * @param framePerSecond defines the number of frame per second to use
  32406. * @param totalFrame defines the number of frames in total
  32407. * @param from defines the initial value
  32408. * @param to defines the final value
  32409. * @param loopMode defines which loop mode you want to use (off by default)
  32410. * @param easingFunction defines the easing function to use (linear by default)
  32411. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32412. * @returns the list of animatables created for all nodes
  32413. * @example https://www.babylonjs-playground.com/#MH0VLI
  32414. */
  32415. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  32416. /**
  32417. * Creates a new animation, merges it with the existing animations and starts it
  32418. * @param name Name of the animation
  32419. * @param node Node which contains the scene that begins the animations
  32420. * @param targetProperty Specifies which property to animate
  32421. * @param framePerSecond The frames per second of the animation
  32422. * @param totalFrame The total number of frames
  32423. * @param from The frame at the beginning of the animation
  32424. * @param to The frame at the end of the animation
  32425. * @param loopMode Specifies the loop mode of the animation
  32426. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32427. * @param onAnimationEnd Callback to run once the animation is complete
  32428. * @returns Nullable animation
  32429. */
  32430. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32431. /**
  32432. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32433. * @param sourceAnimation defines the Animation containing keyframes to convert
  32434. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32435. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32436. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32437. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32438. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32439. */
  32440. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32441. /**
  32442. * Transition property of an host to the target Value
  32443. * @param property The property to transition
  32444. * @param targetValue The target Value of the property
  32445. * @param host The object where the property to animate belongs
  32446. * @param scene Scene used to run the animation
  32447. * @param frameRate Framerate (in frame/s) to use
  32448. * @param transition The transition type we want to use
  32449. * @param duration The duration of the animation, in milliseconds
  32450. * @param onAnimationEnd Callback trigger at the end of the animation
  32451. * @returns Nullable animation
  32452. */
  32453. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32454. /**
  32455. * Return the array of runtime animations currently using this animation
  32456. */
  32457. get runtimeAnimations(): RuntimeAnimation[];
  32458. /**
  32459. * Specifies if any of the runtime animations are currently running
  32460. */
  32461. get hasRunningRuntimeAnimations(): boolean;
  32462. /**
  32463. * Initializes the animation
  32464. * @param name Name of the animation
  32465. * @param targetProperty Property to animate
  32466. * @param framePerSecond The frames per second of the animation
  32467. * @param dataType The data type of the animation
  32468. * @param loopMode The loop mode of the animation
  32469. * @param enableBlending Specifies if blending should be enabled
  32470. */
  32471. constructor(
  32472. /**Name of the animation */
  32473. name: string,
  32474. /**Property to animate */
  32475. targetProperty: string,
  32476. /**The frames per second of the animation */
  32477. framePerSecond: number,
  32478. /**The data type of the animation */
  32479. dataType: number,
  32480. /**The loop mode of the animation */
  32481. loopMode?: number | undefined,
  32482. /**Specifies if blending should be enabled */
  32483. enableBlending?: boolean | undefined);
  32484. /**
  32485. * Converts the animation to a string
  32486. * @param fullDetails support for multiple levels of logging within scene loading
  32487. * @returns String form of the animation
  32488. */
  32489. toString(fullDetails?: boolean): string;
  32490. /**
  32491. * Add an event to this animation
  32492. * @param event Event to add
  32493. */
  32494. addEvent(event: AnimationEvent): void;
  32495. /**
  32496. * Remove all events found at the given frame
  32497. * @param frame The frame to remove events from
  32498. */
  32499. removeEvents(frame: number): void;
  32500. /**
  32501. * Retrieves all the events from the animation
  32502. * @returns Events from the animation
  32503. */
  32504. getEvents(): AnimationEvent[];
  32505. /**
  32506. * Creates an animation range
  32507. * @param name Name of the animation range
  32508. * @param from Starting frame of the animation range
  32509. * @param to Ending frame of the animation
  32510. */
  32511. createRange(name: string, from: number, to: number): void;
  32512. /**
  32513. * Deletes an animation range by name
  32514. * @param name Name of the animation range to delete
  32515. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32516. */
  32517. deleteRange(name: string, deleteFrames?: boolean): void;
  32518. /**
  32519. * Gets the animation range by name, or null if not defined
  32520. * @param name Name of the animation range
  32521. * @returns Nullable animation range
  32522. */
  32523. getRange(name: string): Nullable<AnimationRange>;
  32524. /**
  32525. * Gets the key frames from the animation
  32526. * @returns The key frames of the animation
  32527. */
  32528. getKeys(): Array<IAnimationKey>;
  32529. /**
  32530. * Gets the highest frame rate of the animation
  32531. * @returns Highest frame rate of the animation
  32532. */
  32533. getHighestFrame(): number;
  32534. /**
  32535. * Gets the easing function of the animation
  32536. * @returns Easing function of the animation
  32537. */
  32538. getEasingFunction(): IEasingFunction;
  32539. /**
  32540. * Sets the easing function of the animation
  32541. * @param easingFunction A custom mathematical formula for animation
  32542. */
  32543. setEasingFunction(easingFunction: EasingFunction): void;
  32544. /**
  32545. * Interpolates a scalar linearly
  32546. * @param startValue Start value of the animation curve
  32547. * @param endValue End value of the animation curve
  32548. * @param gradient Scalar amount to interpolate
  32549. * @returns Interpolated scalar value
  32550. */
  32551. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32552. /**
  32553. * Interpolates a scalar cubically
  32554. * @param startValue Start value of the animation curve
  32555. * @param outTangent End tangent of the animation
  32556. * @param endValue End value of the animation curve
  32557. * @param inTangent Start tangent of the animation curve
  32558. * @param gradient Scalar amount to interpolate
  32559. * @returns Interpolated scalar value
  32560. */
  32561. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32562. /**
  32563. * Interpolates a quaternion using a spherical linear interpolation
  32564. * @param startValue Start value of the animation curve
  32565. * @param endValue End value of the animation curve
  32566. * @param gradient Scalar amount to interpolate
  32567. * @returns Interpolated quaternion value
  32568. */
  32569. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32570. /**
  32571. * Interpolates a quaternion cubically
  32572. * @param startValue Start value of the animation curve
  32573. * @param outTangent End tangent of the animation curve
  32574. * @param endValue End value of the animation curve
  32575. * @param inTangent Start tangent of the animation curve
  32576. * @param gradient Scalar amount to interpolate
  32577. * @returns Interpolated quaternion value
  32578. */
  32579. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32580. /**
  32581. * Interpolates a Vector3 linearl
  32582. * @param startValue Start value of the animation curve
  32583. * @param endValue End value of the animation curve
  32584. * @param gradient Scalar amount to interpolate
  32585. * @returns Interpolated scalar value
  32586. */
  32587. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32588. /**
  32589. * Interpolates a Vector3 cubically
  32590. * @param startValue Start value of the animation curve
  32591. * @param outTangent End tangent of the animation
  32592. * @param endValue End value of the animation curve
  32593. * @param inTangent Start tangent of the animation curve
  32594. * @param gradient Scalar amount to interpolate
  32595. * @returns InterpolatedVector3 value
  32596. */
  32597. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32598. /**
  32599. * Interpolates a Vector2 linearly
  32600. * @param startValue Start value of the animation curve
  32601. * @param endValue End value of the animation curve
  32602. * @param gradient Scalar amount to interpolate
  32603. * @returns Interpolated Vector2 value
  32604. */
  32605. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32606. /**
  32607. * Interpolates a Vector2 cubically
  32608. * @param startValue Start value of the animation curve
  32609. * @param outTangent End tangent of the animation
  32610. * @param endValue End value of the animation curve
  32611. * @param inTangent Start tangent of the animation curve
  32612. * @param gradient Scalar amount to interpolate
  32613. * @returns Interpolated Vector2 value
  32614. */
  32615. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32616. /**
  32617. * Interpolates a size linearly
  32618. * @param startValue Start value of the animation curve
  32619. * @param endValue End value of the animation curve
  32620. * @param gradient Scalar amount to interpolate
  32621. * @returns Interpolated Size value
  32622. */
  32623. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32624. /**
  32625. * Interpolates a Color3 linearly
  32626. * @param startValue Start value of the animation curve
  32627. * @param endValue End value of the animation curve
  32628. * @param gradient Scalar amount to interpolate
  32629. * @returns Interpolated Color3 value
  32630. */
  32631. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32632. /**
  32633. * Interpolates a Color4 linearly
  32634. * @param startValue Start value of the animation curve
  32635. * @param endValue End value of the animation curve
  32636. * @param gradient Scalar amount to interpolate
  32637. * @returns Interpolated Color3 value
  32638. */
  32639. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32640. /**
  32641. * @hidden Internal use only
  32642. */
  32643. _getKeyValue(value: any): any;
  32644. /**
  32645. * @hidden Internal use only
  32646. */
  32647. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32648. /**
  32649. * Defines the function to use to interpolate matrices
  32650. * @param startValue defines the start matrix
  32651. * @param endValue defines the end matrix
  32652. * @param gradient defines the gradient between both matrices
  32653. * @param result defines an optional target matrix where to store the interpolation
  32654. * @returns the interpolated matrix
  32655. */
  32656. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32657. /**
  32658. * Makes a copy of the animation
  32659. * @returns Cloned animation
  32660. */
  32661. clone(): Animation;
  32662. /**
  32663. * Sets the key frames of the animation
  32664. * @param values The animation key frames to set
  32665. */
  32666. setKeys(values: Array<IAnimationKey>): void;
  32667. /**
  32668. * Serializes the animation to an object
  32669. * @returns Serialized object
  32670. */
  32671. serialize(): any;
  32672. /**
  32673. * Float animation type
  32674. */
  32675. static readonly ANIMATIONTYPE_FLOAT: number;
  32676. /**
  32677. * Vector3 animation type
  32678. */
  32679. static readonly ANIMATIONTYPE_VECTOR3: number;
  32680. /**
  32681. * Quaternion animation type
  32682. */
  32683. static readonly ANIMATIONTYPE_QUATERNION: number;
  32684. /**
  32685. * Matrix animation type
  32686. */
  32687. static readonly ANIMATIONTYPE_MATRIX: number;
  32688. /**
  32689. * Color3 animation type
  32690. */
  32691. static readonly ANIMATIONTYPE_COLOR3: number;
  32692. /**
  32693. * Color3 animation type
  32694. */
  32695. static readonly ANIMATIONTYPE_COLOR4: number;
  32696. /**
  32697. * Vector2 animation type
  32698. */
  32699. static readonly ANIMATIONTYPE_VECTOR2: number;
  32700. /**
  32701. * Size animation type
  32702. */
  32703. static readonly ANIMATIONTYPE_SIZE: number;
  32704. /**
  32705. * Relative Loop Mode
  32706. */
  32707. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32708. /**
  32709. * Cycle Loop Mode
  32710. */
  32711. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32712. /**
  32713. * Constant Loop Mode
  32714. */
  32715. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32716. /** @hidden */
  32717. static _UniversalLerp(left: any, right: any, amount: number): any;
  32718. /**
  32719. * Parses an animation object and creates an animation
  32720. * @param parsedAnimation Parsed animation object
  32721. * @returns Animation object
  32722. */
  32723. static Parse(parsedAnimation: any): Animation;
  32724. /**
  32725. * Appends the serialized animations from the source animations
  32726. * @param source Source containing the animations
  32727. * @param destination Target to store the animations
  32728. */
  32729. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32730. /**
  32731. * Creates a new animation or an array of animations from a snippet saved in a remote file
  32732. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  32733. * @param url defines the url to load from
  32734. * @returns a promise that will resolve to the new animation or an array of animations
  32735. */
  32736. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  32737. /**
  32738. * Creates an animation or an array of animations from a snippet saved by the Inspector
  32739. * @param snippetId defines the snippet to load
  32740. * @returns a promise that will resolve to the new animation or a new array of animations
  32741. */
  32742. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  32743. }
  32744. }
  32745. declare module BABYLON {
  32746. /**
  32747. * Interface containing an array of animations
  32748. */
  32749. export interface IAnimatable {
  32750. /**
  32751. * Array of animations
  32752. */
  32753. animations: Nullable<Array<Animation>>;
  32754. }
  32755. }
  32756. declare module BABYLON {
  32757. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32758. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32759. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32760. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32761. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32762. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32763. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32764. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32765. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32766. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32767. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32768. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32769. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32770. /**
  32771. * Decorator used to define property that can be serialized as reference to a camera
  32772. * @param sourceName defines the name of the property to decorate
  32773. */
  32774. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32775. /**
  32776. * Class used to help serialization objects
  32777. */
  32778. export class SerializationHelper {
  32779. /** @hidden */
  32780. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32781. /** @hidden */
  32782. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32783. /** @hidden */
  32784. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32785. /** @hidden */
  32786. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32787. /**
  32788. * Appends the serialized animations from the source animations
  32789. * @param source Source containing the animations
  32790. * @param destination Target to store the animations
  32791. */
  32792. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32793. /**
  32794. * Static function used to serialized a specific entity
  32795. * @param entity defines the entity to serialize
  32796. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32797. * @returns a JSON compatible object representing the serialization of the entity
  32798. */
  32799. static Serialize<T>(entity: T, serializationObject?: any): any;
  32800. /**
  32801. * Creates a new entity from a serialization data object
  32802. * @param creationFunction defines a function used to instanciated the new entity
  32803. * @param source defines the source serialization data
  32804. * @param scene defines the hosting scene
  32805. * @param rootUrl defines the root url for resources
  32806. * @returns a new entity
  32807. */
  32808. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32809. /**
  32810. * Clones an object
  32811. * @param creationFunction defines the function used to instanciate the new object
  32812. * @param source defines the source object
  32813. * @returns the cloned object
  32814. */
  32815. static Clone<T>(creationFunction: () => T, source: T): T;
  32816. /**
  32817. * Instanciates a new object based on a source one (some data will be shared between both object)
  32818. * @param creationFunction defines the function used to instanciate the new object
  32819. * @param source defines the source object
  32820. * @returns the new object
  32821. */
  32822. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32823. }
  32824. }
  32825. declare module BABYLON {
  32826. /**
  32827. * Base class of all the textures in babylon.
  32828. * It groups all the common properties the materials, post process, lights... might need
  32829. * in order to make a correct use of the texture.
  32830. */
  32831. export class BaseTexture implements IAnimatable {
  32832. /**
  32833. * Default anisotropic filtering level for the application.
  32834. * It is set to 4 as a good tradeoff between perf and quality.
  32835. */
  32836. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32837. /**
  32838. * Gets or sets the unique id of the texture
  32839. */
  32840. uniqueId: number;
  32841. /**
  32842. * Define the name of the texture.
  32843. */
  32844. name: string;
  32845. /**
  32846. * Gets or sets an object used to store user defined information.
  32847. */
  32848. metadata: any;
  32849. /**
  32850. * For internal use only. Please do not use.
  32851. */
  32852. reservedDataStore: any;
  32853. private _hasAlpha;
  32854. /**
  32855. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32856. */
  32857. set hasAlpha(value: boolean);
  32858. get hasAlpha(): boolean;
  32859. /**
  32860. * Defines if the alpha value should be determined via the rgb values.
  32861. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32862. */
  32863. getAlphaFromRGB: boolean;
  32864. /**
  32865. * Intensity or strength of the texture.
  32866. * It is commonly used by materials to fine tune the intensity of the texture
  32867. */
  32868. level: number;
  32869. /**
  32870. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32871. * This is part of the texture as textures usually maps to one uv set.
  32872. */
  32873. coordinatesIndex: number;
  32874. private _coordinatesMode;
  32875. /**
  32876. * How a texture is mapped.
  32877. *
  32878. * | Value | Type | Description |
  32879. * | ----- | ----------------------------------- | ----------- |
  32880. * | 0 | EXPLICIT_MODE | |
  32881. * | 1 | SPHERICAL_MODE | |
  32882. * | 2 | PLANAR_MODE | |
  32883. * | 3 | CUBIC_MODE | |
  32884. * | 4 | PROJECTION_MODE | |
  32885. * | 5 | SKYBOX_MODE | |
  32886. * | 6 | INVCUBIC_MODE | |
  32887. * | 7 | EQUIRECTANGULAR_MODE | |
  32888. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32889. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32890. */
  32891. set coordinatesMode(value: number);
  32892. get coordinatesMode(): number;
  32893. /**
  32894. * | Value | Type | Description |
  32895. * | ----- | ------------------ | ----------- |
  32896. * | 0 | CLAMP_ADDRESSMODE | |
  32897. * | 1 | WRAP_ADDRESSMODE | |
  32898. * | 2 | MIRROR_ADDRESSMODE | |
  32899. */
  32900. wrapU: number;
  32901. /**
  32902. * | Value | Type | Description |
  32903. * | ----- | ------------------ | ----------- |
  32904. * | 0 | CLAMP_ADDRESSMODE | |
  32905. * | 1 | WRAP_ADDRESSMODE | |
  32906. * | 2 | MIRROR_ADDRESSMODE | |
  32907. */
  32908. wrapV: number;
  32909. /**
  32910. * | Value | Type | Description |
  32911. * | ----- | ------------------ | ----------- |
  32912. * | 0 | CLAMP_ADDRESSMODE | |
  32913. * | 1 | WRAP_ADDRESSMODE | |
  32914. * | 2 | MIRROR_ADDRESSMODE | |
  32915. */
  32916. wrapR: number;
  32917. /**
  32918. * With compliant hardware and browser (supporting anisotropic filtering)
  32919. * this defines the level of anisotropic filtering in the texture.
  32920. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32921. */
  32922. anisotropicFilteringLevel: number;
  32923. /**
  32924. * Define if the texture is a cube texture or if false a 2d texture.
  32925. */
  32926. get isCube(): boolean;
  32927. set isCube(value: boolean);
  32928. /**
  32929. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32930. */
  32931. get is3D(): boolean;
  32932. set is3D(value: boolean);
  32933. /**
  32934. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32935. */
  32936. get is2DArray(): boolean;
  32937. set is2DArray(value: boolean);
  32938. /**
  32939. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32940. * HDR texture are usually stored in linear space.
  32941. * This only impacts the PBR and Background materials
  32942. */
  32943. gammaSpace: boolean;
  32944. /**
  32945. * Gets or sets whether or not the texture contains RGBD data.
  32946. */
  32947. get isRGBD(): boolean;
  32948. set isRGBD(value: boolean);
  32949. /**
  32950. * Is Z inverted in the texture (useful in a cube texture).
  32951. */
  32952. invertZ: boolean;
  32953. /**
  32954. * Are mip maps generated for this texture or not.
  32955. */
  32956. get noMipmap(): boolean;
  32957. /**
  32958. * @hidden
  32959. */
  32960. lodLevelInAlpha: boolean;
  32961. /**
  32962. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32963. */
  32964. get lodGenerationOffset(): number;
  32965. set lodGenerationOffset(value: number);
  32966. /**
  32967. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32968. */
  32969. get lodGenerationScale(): number;
  32970. set lodGenerationScale(value: number);
  32971. /**
  32972. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32973. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32974. * average roughness values.
  32975. */
  32976. get linearSpecularLOD(): boolean;
  32977. set linearSpecularLOD(value: boolean);
  32978. /**
  32979. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32980. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32981. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32982. */
  32983. get irradianceTexture(): Nullable<BaseTexture>;
  32984. set irradianceTexture(value: Nullable<BaseTexture>);
  32985. /**
  32986. * Define if the texture is a render target.
  32987. */
  32988. isRenderTarget: boolean;
  32989. /**
  32990. * Define the unique id of the texture in the scene.
  32991. */
  32992. get uid(): string;
  32993. /** @hidden */
  32994. _prefiltered: boolean;
  32995. /**
  32996. * Return a string representation of the texture.
  32997. * @returns the texture as a string
  32998. */
  32999. toString(): string;
  33000. /**
  33001. * Get the class name of the texture.
  33002. * @returns "BaseTexture"
  33003. */
  33004. getClassName(): string;
  33005. /**
  33006. * Define the list of animation attached to the texture.
  33007. */
  33008. animations: Animation[];
  33009. /**
  33010. * An event triggered when the texture is disposed.
  33011. */
  33012. onDisposeObservable: Observable<BaseTexture>;
  33013. private _onDisposeObserver;
  33014. /**
  33015. * Callback triggered when the texture has been disposed.
  33016. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33017. */
  33018. set onDispose(callback: () => void);
  33019. /**
  33020. * Define the current state of the loading sequence when in delayed load mode.
  33021. */
  33022. delayLoadState: number;
  33023. private _scene;
  33024. private _engine;
  33025. /** @hidden */
  33026. _texture: Nullable<InternalTexture>;
  33027. private _uid;
  33028. /**
  33029. * Define if the texture is preventinga material to render or not.
  33030. * If not and the texture is not ready, the engine will use a default black texture instead.
  33031. */
  33032. get isBlocking(): boolean;
  33033. /**
  33034. * Instantiates a new BaseTexture.
  33035. * Base class of all the textures in babylon.
  33036. * It groups all the common properties the materials, post process, lights... might need
  33037. * in order to make a correct use of the texture.
  33038. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33039. */
  33040. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33041. /**
  33042. * Get the scene the texture belongs to.
  33043. * @returns the scene or null if undefined
  33044. */
  33045. getScene(): Nullable<Scene>;
  33046. /** @hidden */
  33047. protected _getEngine(): Nullable<ThinEngine>;
  33048. /**
  33049. * Get the texture transform matrix used to offset tile the texture for istance.
  33050. * @returns the transformation matrix
  33051. */
  33052. getTextureMatrix(): Matrix;
  33053. /**
  33054. * Get the texture reflection matrix used to rotate/transform the reflection.
  33055. * @returns the reflection matrix
  33056. */
  33057. getReflectionTextureMatrix(): Matrix;
  33058. /**
  33059. * Get the underlying lower level texture from Babylon.
  33060. * @returns the insternal texture
  33061. */
  33062. getInternalTexture(): Nullable<InternalTexture>;
  33063. /**
  33064. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33065. * @returns true if ready or not blocking
  33066. */
  33067. isReadyOrNotBlocking(): boolean;
  33068. /**
  33069. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33070. * @returns true if fully ready
  33071. */
  33072. isReady(): boolean;
  33073. private _cachedSize;
  33074. /**
  33075. * Get the size of the texture.
  33076. * @returns the texture size.
  33077. */
  33078. getSize(): ISize;
  33079. /**
  33080. * Get the base size of the texture.
  33081. * It can be different from the size if the texture has been resized for POT for instance
  33082. * @returns the base size
  33083. */
  33084. getBaseSize(): ISize;
  33085. /**
  33086. * Update the sampling mode of the texture.
  33087. * Default is Trilinear mode.
  33088. *
  33089. * | Value | Type | Description |
  33090. * | ----- | ------------------ | ----------- |
  33091. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33092. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33093. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33094. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33095. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33096. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33097. * | 7 | NEAREST_LINEAR | |
  33098. * | 8 | NEAREST_NEAREST | |
  33099. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33100. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33101. * | 11 | LINEAR_LINEAR | |
  33102. * | 12 | LINEAR_NEAREST | |
  33103. *
  33104. * > _mag_: magnification filter (close to the viewer)
  33105. * > _min_: minification filter (far from the viewer)
  33106. * > _mip_: filter used between mip map levels
  33107. *@param samplingMode Define the new sampling mode of the texture
  33108. */
  33109. updateSamplingMode(samplingMode: number): void;
  33110. /**
  33111. * Scales the texture if is `canRescale()`
  33112. * @param ratio the resize factor we want to use to rescale
  33113. */
  33114. scale(ratio: number): void;
  33115. /**
  33116. * Get if the texture can rescale.
  33117. */
  33118. get canRescale(): boolean;
  33119. /** @hidden */
  33120. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33121. /** @hidden */
  33122. _rebuild(): void;
  33123. /**
  33124. * Triggers the load sequence in delayed load mode.
  33125. */
  33126. delayLoad(): void;
  33127. /**
  33128. * Clones the texture.
  33129. * @returns the cloned texture
  33130. */
  33131. clone(): Nullable<BaseTexture>;
  33132. /**
  33133. * Get the texture underlying type (INT, FLOAT...)
  33134. */
  33135. get textureType(): number;
  33136. /**
  33137. * Get the texture underlying format (RGB, RGBA...)
  33138. */
  33139. get textureFormat(): number;
  33140. /**
  33141. * Indicates that textures need to be re-calculated for all materials
  33142. */
  33143. protected _markAllSubMeshesAsTexturesDirty(): void;
  33144. /**
  33145. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33146. * This will returns an RGBA array buffer containing either in values (0-255) or
  33147. * float values (0-1) depending of the underlying buffer type.
  33148. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33149. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33150. * @param buffer defines a user defined buffer to fill with data (can be null)
  33151. * @returns The Array buffer containing the pixels data.
  33152. */
  33153. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33154. /**
  33155. * Release and destroy the underlying lower level texture aka internalTexture.
  33156. */
  33157. releaseInternalTexture(): void;
  33158. /** @hidden */
  33159. get _lodTextureHigh(): Nullable<BaseTexture>;
  33160. /** @hidden */
  33161. get _lodTextureMid(): Nullable<BaseTexture>;
  33162. /** @hidden */
  33163. get _lodTextureLow(): Nullable<BaseTexture>;
  33164. /**
  33165. * Dispose the texture and release its associated resources.
  33166. */
  33167. dispose(): void;
  33168. /**
  33169. * Serialize the texture into a JSON representation that can be parsed later on.
  33170. * @returns the JSON representation of the texture
  33171. */
  33172. serialize(): any;
  33173. /**
  33174. * Helper function to be called back once a list of texture contains only ready textures.
  33175. * @param textures Define the list of textures to wait for
  33176. * @param callback Define the callback triggered once the entire list will be ready
  33177. */
  33178. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33179. private static _isScene;
  33180. }
  33181. }
  33182. declare module BABYLON {
  33183. /**
  33184. * Options to be used when creating an effect.
  33185. */
  33186. export interface IEffectCreationOptions {
  33187. /**
  33188. * Atrributes that will be used in the shader.
  33189. */
  33190. attributes: string[];
  33191. /**
  33192. * Uniform varible names that will be set in the shader.
  33193. */
  33194. uniformsNames: string[];
  33195. /**
  33196. * Uniform buffer variable names that will be set in the shader.
  33197. */
  33198. uniformBuffersNames: string[];
  33199. /**
  33200. * Sampler texture variable names that will be set in the shader.
  33201. */
  33202. samplers: string[];
  33203. /**
  33204. * Define statements that will be set in the shader.
  33205. */
  33206. defines: any;
  33207. /**
  33208. * Possible fallbacks for this effect to improve performance when needed.
  33209. */
  33210. fallbacks: Nullable<IEffectFallbacks>;
  33211. /**
  33212. * Callback that will be called when the shader is compiled.
  33213. */
  33214. onCompiled: Nullable<(effect: Effect) => void>;
  33215. /**
  33216. * Callback that will be called if an error occurs during shader compilation.
  33217. */
  33218. onError: Nullable<(effect: Effect, errors: string) => void>;
  33219. /**
  33220. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33221. */
  33222. indexParameters?: any;
  33223. /**
  33224. * Max number of lights that can be used in the shader.
  33225. */
  33226. maxSimultaneousLights?: number;
  33227. /**
  33228. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33229. */
  33230. transformFeedbackVaryings?: Nullable<string[]>;
  33231. /**
  33232. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  33233. */
  33234. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33235. }
  33236. /**
  33237. * Effect containing vertex and fragment shader that can be executed on an object.
  33238. */
  33239. export class Effect implements IDisposable {
  33240. /**
  33241. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33242. */
  33243. static ShadersRepository: string;
  33244. /**
  33245. * Enable logging of the shader code when a compilation error occurs
  33246. */
  33247. static LogShaderCodeOnCompilationError: boolean;
  33248. /**
  33249. * Name of the effect.
  33250. */
  33251. name: any;
  33252. /**
  33253. * String container all the define statements that should be set on the shader.
  33254. */
  33255. defines: string;
  33256. /**
  33257. * Callback that will be called when the shader is compiled.
  33258. */
  33259. onCompiled: Nullable<(effect: Effect) => void>;
  33260. /**
  33261. * Callback that will be called if an error occurs during shader compilation.
  33262. */
  33263. onError: Nullable<(effect: Effect, errors: string) => void>;
  33264. /**
  33265. * Callback that will be called when effect is bound.
  33266. */
  33267. onBind: Nullable<(effect: Effect) => void>;
  33268. /**
  33269. * Unique ID of the effect.
  33270. */
  33271. uniqueId: number;
  33272. /**
  33273. * Observable that will be called when the shader is compiled.
  33274. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33275. */
  33276. onCompileObservable: Observable<Effect>;
  33277. /**
  33278. * Observable that will be called if an error occurs during shader compilation.
  33279. */
  33280. onErrorObservable: Observable<Effect>;
  33281. /** @hidden */
  33282. _onBindObservable: Nullable<Observable<Effect>>;
  33283. /**
  33284. * @hidden
  33285. * Specifies if the effect was previously ready
  33286. */
  33287. _wasPreviouslyReady: boolean;
  33288. /**
  33289. * Observable that will be called when effect is bound.
  33290. */
  33291. get onBindObservable(): Observable<Effect>;
  33292. /** @hidden */
  33293. _bonesComputationForcedToCPU: boolean;
  33294. private static _uniqueIdSeed;
  33295. private _engine;
  33296. private _uniformBuffersNames;
  33297. private _uniformBuffersNamesList;
  33298. private _uniformsNames;
  33299. private _samplerList;
  33300. private _samplers;
  33301. private _isReady;
  33302. private _compilationError;
  33303. private _allFallbacksProcessed;
  33304. private _attributesNames;
  33305. private _attributes;
  33306. private _attributeLocationByName;
  33307. private _uniforms;
  33308. /**
  33309. * Key for the effect.
  33310. * @hidden
  33311. */
  33312. _key: string;
  33313. private _indexParameters;
  33314. private _fallbacks;
  33315. private _vertexSourceCode;
  33316. private _fragmentSourceCode;
  33317. private _vertexSourceCodeOverride;
  33318. private _fragmentSourceCodeOverride;
  33319. private _transformFeedbackVaryings;
  33320. /**
  33321. * Compiled shader to webGL program.
  33322. * @hidden
  33323. */
  33324. _pipelineContext: Nullable<IPipelineContext>;
  33325. private _valueCache;
  33326. private static _baseCache;
  33327. /**
  33328. * Instantiates an effect.
  33329. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33330. * @param baseName Name of the effect.
  33331. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33332. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33333. * @param samplers List of sampler variables that will be passed to the shader.
  33334. * @param engine Engine to be used to render the effect
  33335. * @param defines Define statements to be added to the shader.
  33336. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33337. * @param onCompiled Callback that will be called when the shader is compiled.
  33338. * @param onError Callback that will be called if an error occurs during shader compilation.
  33339. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33340. */
  33341. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  33342. private _useFinalCode;
  33343. /**
  33344. * Unique key for this effect
  33345. */
  33346. get key(): string;
  33347. /**
  33348. * If the effect has been compiled and prepared.
  33349. * @returns if the effect is compiled and prepared.
  33350. */
  33351. isReady(): boolean;
  33352. private _isReadyInternal;
  33353. /**
  33354. * The engine the effect was initialized with.
  33355. * @returns the engine.
  33356. */
  33357. getEngine(): Engine;
  33358. /**
  33359. * The pipeline context for this effect
  33360. * @returns the associated pipeline context
  33361. */
  33362. getPipelineContext(): Nullable<IPipelineContext>;
  33363. /**
  33364. * The set of names of attribute variables for the shader.
  33365. * @returns An array of attribute names.
  33366. */
  33367. getAttributesNames(): string[];
  33368. /**
  33369. * Returns the attribute at the given index.
  33370. * @param index The index of the attribute.
  33371. * @returns The location of the attribute.
  33372. */
  33373. getAttributeLocation(index: number): number;
  33374. /**
  33375. * Returns the attribute based on the name of the variable.
  33376. * @param name of the attribute to look up.
  33377. * @returns the attribute location.
  33378. */
  33379. getAttributeLocationByName(name: string): number;
  33380. /**
  33381. * The number of attributes.
  33382. * @returns the numnber of attributes.
  33383. */
  33384. getAttributesCount(): number;
  33385. /**
  33386. * Gets the index of a uniform variable.
  33387. * @param uniformName of the uniform to look up.
  33388. * @returns the index.
  33389. */
  33390. getUniformIndex(uniformName: string): number;
  33391. /**
  33392. * Returns the attribute based on the name of the variable.
  33393. * @param uniformName of the uniform to look up.
  33394. * @returns the location of the uniform.
  33395. */
  33396. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33397. /**
  33398. * Returns an array of sampler variable names
  33399. * @returns The array of sampler variable names.
  33400. */
  33401. getSamplers(): string[];
  33402. /**
  33403. * Returns an array of uniform variable names
  33404. * @returns The array of uniform variable names.
  33405. */
  33406. getUniformNames(): string[];
  33407. /**
  33408. * Returns an array of uniform buffer variable names
  33409. * @returns The array of uniform buffer variable names.
  33410. */
  33411. getUniformBuffersNames(): string[];
  33412. /**
  33413. * Returns the index parameters used to create the effect
  33414. * @returns The index parameters object
  33415. */
  33416. getIndexParameters(): any;
  33417. /**
  33418. * The error from the last compilation.
  33419. * @returns the error string.
  33420. */
  33421. getCompilationError(): string;
  33422. /**
  33423. * Gets a boolean indicating that all fallbacks were used during compilation
  33424. * @returns true if all fallbacks were used
  33425. */
  33426. allFallbacksProcessed(): boolean;
  33427. /**
  33428. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33429. * @param func The callback to be used.
  33430. */
  33431. executeWhenCompiled(func: (effect: Effect) => void): void;
  33432. private _checkIsReady;
  33433. private _loadShader;
  33434. /**
  33435. * Gets the vertex shader source code of this effect
  33436. */
  33437. get vertexSourceCode(): string;
  33438. /**
  33439. * Gets the fragment shader source code of this effect
  33440. */
  33441. get fragmentSourceCode(): string;
  33442. /**
  33443. * Recompiles the webGL program
  33444. * @param vertexSourceCode The source code for the vertex shader.
  33445. * @param fragmentSourceCode The source code for the fragment shader.
  33446. * @param onCompiled Callback called when completed.
  33447. * @param onError Callback called on error.
  33448. * @hidden
  33449. */
  33450. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33451. /**
  33452. * Prepares the effect
  33453. * @hidden
  33454. */
  33455. _prepareEffect(): void;
  33456. private _getShaderCodeAndErrorLine;
  33457. private _processCompilationErrors;
  33458. /**
  33459. * Checks if the effect is supported. (Must be called after compilation)
  33460. */
  33461. get isSupported(): boolean;
  33462. /**
  33463. * Binds a texture to the engine to be used as output of the shader.
  33464. * @param channel Name of the output variable.
  33465. * @param texture Texture to bind.
  33466. * @hidden
  33467. */
  33468. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33469. /**
  33470. * Sets a texture on the engine to be used in the shader.
  33471. * @param channel Name of the sampler variable.
  33472. * @param texture Texture to set.
  33473. */
  33474. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33475. /**
  33476. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33477. * @param channel Name of the sampler variable.
  33478. * @param texture Texture to set.
  33479. */
  33480. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33481. /**
  33482. * Sets an array of textures on the engine to be used in the shader.
  33483. * @param channel Name of the variable.
  33484. * @param textures Textures to set.
  33485. */
  33486. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33487. /**
  33488. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  33489. * @param channel Name of the sampler variable.
  33490. * @param postProcess Post process to get the input texture from.
  33491. */
  33492. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33493. /**
  33494. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33495. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  33496. * @param channel Name of the sampler variable.
  33497. * @param postProcess Post process to get the output texture from.
  33498. */
  33499. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33500. /** @hidden */
  33501. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33502. /** @hidden */
  33503. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33504. /** @hidden */
  33505. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33506. /** @hidden */
  33507. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33508. /**
  33509. * Binds a buffer to a uniform.
  33510. * @param buffer Buffer to bind.
  33511. * @param name Name of the uniform variable to bind to.
  33512. */
  33513. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33514. /**
  33515. * Binds block to a uniform.
  33516. * @param blockName Name of the block to bind.
  33517. * @param index Index to bind.
  33518. */
  33519. bindUniformBlock(blockName: string, index: number): void;
  33520. /**
  33521. * Sets an interger value on a uniform variable.
  33522. * @param uniformName Name of the variable.
  33523. * @param value Value to be set.
  33524. * @returns this effect.
  33525. */
  33526. setInt(uniformName: string, value: number): Effect;
  33527. /**
  33528. * Sets an int array on a uniform variable.
  33529. * @param uniformName Name of the variable.
  33530. * @param array array to be set.
  33531. * @returns this effect.
  33532. */
  33533. setIntArray(uniformName: string, array: Int32Array): Effect;
  33534. /**
  33535. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  33536. * @param uniformName Name of the variable.
  33537. * @param array array to be set.
  33538. * @returns this effect.
  33539. */
  33540. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33541. /**
  33542. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  33543. * @param uniformName Name of the variable.
  33544. * @param array array to be set.
  33545. * @returns this effect.
  33546. */
  33547. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33548. /**
  33549. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  33550. * @param uniformName Name of the variable.
  33551. * @param array array to be set.
  33552. * @returns this effect.
  33553. */
  33554. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33555. /**
  33556. * Sets an float array on a uniform variable.
  33557. * @param uniformName Name of the variable.
  33558. * @param array array to be set.
  33559. * @returns this effect.
  33560. */
  33561. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33562. /**
  33563. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  33564. * @param uniformName Name of the variable.
  33565. * @param array array to be set.
  33566. * @returns this effect.
  33567. */
  33568. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33569. /**
  33570. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  33571. * @param uniformName Name of the variable.
  33572. * @param array array to be set.
  33573. * @returns this effect.
  33574. */
  33575. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33576. /**
  33577. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  33578. * @param uniformName Name of the variable.
  33579. * @param array array to be set.
  33580. * @returns this effect.
  33581. */
  33582. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33583. /**
  33584. * Sets an array on a uniform variable.
  33585. * @param uniformName Name of the variable.
  33586. * @param array array to be set.
  33587. * @returns this effect.
  33588. */
  33589. setArray(uniformName: string, array: number[]): Effect;
  33590. /**
  33591. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  33592. * @param uniformName Name of the variable.
  33593. * @param array array to be set.
  33594. * @returns this effect.
  33595. */
  33596. setArray2(uniformName: string, array: number[]): Effect;
  33597. /**
  33598. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  33599. * @param uniformName Name of the variable.
  33600. * @param array array to be set.
  33601. * @returns this effect.
  33602. */
  33603. setArray3(uniformName: string, array: number[]): Effect;
  33604. /**
  33605. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  33606. * @param uniformName Name of the variable.
  33607. * @param array array to be set.
  33608. * @returns this effect.
  33609. */
  33610. setArray4(uniformName: string, array: number[]): Effect;
  33611. /**
  33612. * Sets matrices on a uniform variable.
  33613. * @param uniformName Name of the variable.
  33614. * @param matrices matrices to be set.
  33615. * @returns this effect.
  33616. */
  33617. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33618. /**
  33619. * Sets matrix on a uniform variable.
  33620. * @param uniformName Name of the variable.
  33621. * @param matrix matrix to be set.
  33622. * @returns this effect.
  33623. */
  33624. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33625. /**
  33626. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  33627. * @param uniformName Name of the variable.
  33628. * @param matrix matrix to be set.
  33629. * @returns this effect.
  33630. */
  33631. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33632. /**
  33633. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33634. * @param uniformName Name of the variable.
  33635. * @param matrix matrix to be set.
  33636. * @returns this effect.
  33637. */
  33638. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33639. /**
  33640. * Sets a float on a uniform variable.
  33641. * @param uniformName Name of the variable.
  33642. * @param value value to be set.
  33643. * @returns this effect.
  33644. */
  33645. setFloat(uniformName: string, value: number): Effect;
  33646. /**
  33647. * Sets a boolean on a uniform variable.
  33648. * @param uniformName Name of the variable.
  33649. * @param bool value to be set.
  33650. * @returns this effect.
  33651. */
  33652. setBool(uniformName: string, bool: boolean): Effect;
  33653. /**
  33654. * Sets a Vector2 on a uniform variable.
  33655. * @param uniformName Name of the variable.
  33656. * @param vector2 vector2 to be set.
  33657. * @returns this effect.
  33658. */
  33659. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33660. /**
  33661. * Sets a float2 on a uniform variable.
  33662. * @param uniformName Name of the variable.
  33663. * @param x First float in float2.
  33664. * @param y Second float in float2.
  33665. * @returns this effect.
  33666. */
  33667. setFloat2(uniformName: string, x: number, y: number): Effect;
  33668. /**
  33669. * Sets a Vector3 on a uniform variable.
  33670. * @param uniformName Name of the variable.
  33671. * @param vector3 Value to be set.
  33672. * @returns this effect.
  33673. */
  33674. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33675. /**
  33676. * Sets a float3 on a uniform variable.
  33677. * @param uniformName Name of the variable.
  33678. * @param x First float in float3.
  33679. * @param y Second float in float3.
  33680. * @param z Third float in float3.
  33681. * @returns this effect.
  33682. */
  33683. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33684. /**
  33685. * Sets a Vector4 on a uniform variable.
  33686. * @param uniformName Name of the variable.
  33687. * @param vector4 Value to be set.
  33688. * @returns this effect.
  33689. */
  33690. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33691. /**
  33692. * Sets a float4 on a uniform variable.
  33693. * @param uniformName Name of the variable.
  33694. * @param x First float in float4.
  33695. * @param y Second float in float4.
  33696. * @param z Third float in float4.
  33697. * @param w Fourth float in float4.
  33698. * @returns this effect.
  33699. */
  33700. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33701. /**
  33702. * Sets a Color3 on a uniform variable.
  33703. * @param uniformName Name of the variable.
  33704. * @param color3 Value to be set.
  33705. * @returns this effect.
  33706. */
  33707. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33708. /**
  33709. * Sets a Color4 on a uniform variable.
  33710. * @param uniformName Name of the variable.
  33711. * @param color3 Value to be set.
  33712. * @param alpha Alpha value to be set.
  33713. * @returns this effect.
  33714. */
  33715. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33716. /**
  33717. * Sets a Color4 on a uniform variable
  33718. * @param uniformName defines the name of the variable
  33719. * @param color4 defines the value to be set
  33720. * @returns this effect.
  33721. */
  33722. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33723. /** Release all associated resources */
  33724. dispose(): void;
  33725. /**
  33726. * This function will add a new shader to the shader store
  33727. * @param name the name of the shader
  33728. * @param pixelShader optional pixel shader content
  33729. * @param vertexShader optional vertex shader content
  33730. */
  33731. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33732. /**
  33733. * Store of each shader (The can be looked up using effect.key)
  33734. */
  33735. static ShadersStore: {
  33736. [key: string]: string;
  33737. };
  33738. /**
  33739. * Store of each included file for a shader (The can be looked up using effect.key)
  33740. */
  33741. static IncludesShadersStore: {
  33742. [key: string]: string;
  33743. };
  33744. /**
  33745. * Resets the cache of effects.
  33746. */
  33747. static ResetCache(): void;
  33748. }
  33749. }
  33750. declare module BABYLON {
  33751. /**
  33752. * Interface used to describe the capabilities of the engine relatively to the current browser
  33753. */
  33754. export interface EngineCapabilities {
  33755. /** Maximum textures units per fragment shader */
  33756. maxTexturesImageUnits: number;
  33757. /** Maximum texture units per vertex shader */
  33758. maxVertexTextureImageUnits: number;
  33759. /** Maximum textures units in the entire pipeline */
  33760. maxCombinedTexturesImageUnits: number;
  33761. /** Maximum texture size */
  33762. maxTextureSize: number;
  33763. /** Maximum texture samples */
  33764. maxSamples?: number;
  33765. /** Maximum cube texture size */
  33766. maxCubemapTextureSize: number;
  33767. /** Maximum render texture size */
  33768. maxRenderTextureSize: number;
  33769. /** Maximum number of vertex attributes */
  33770. maxVertexAttribs: number;
  33771. /** Maximum number of varyings */
  33772. maxVaryingVectors: number;
  33773. /** Maximum number of uniforms per vertex shader */
  33774. maxVertexUniformVectors: number;
  33775. /** Maximum number of uniforms per fragment shader */
  33776. maxFragmentUniformVectors: number;
  33777. /** Defines if standard derivates (dx/dy) are supported */
  33778. standardDerivatives: boolean;
  33779. /** Defines if s3tc texture compression is supported */
  33780. s3tc?: WEBGL_compressed_texture_s3tc;
  33781. /** Defines if pvrtc texture compression is supported */
  33782. pvrtc: any;
  33783. /** Defines if etc1 texture compression is supported */
  33784. etc1: any;
  33785. /** Defines if etc2 texture compression is supported */
  33786. etc2: any;
  33787. /** Defines if astc texture compression is supported */
  33788. astc: any;
  33789. /** Defines if float textures are supported */
  33790. textureFloat: boolean;
  33791. /** Defines if vertex array objects are supported */
  33792. vertexArrayObject: boolean;
  33793. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33794. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33795. /** Gets the maximum level of anisotropy supported */
  33796. maxAnisotropy: number;
  33797. /** Defines if instancing is supported */
  33798. instancedArrays: boolean;
  33799. /** Defines if 32 bits indices are supported */
  33800. uintIndices: boolean;
  33801. /** Defines if high precision shaders are supported */
  33802. highPrecisionShaderSupported: boolean;
  33803. /** Defines if depth reading in the fragment shader is supported */
  33804. fragmentDepthSupported: boolean;
  33805. /** Defines if float texture linear filtering is supported*/
  33806. textureFloatLinearFiltering: boolean;
  33807. /** Defines if rendering to float textures is supported */
  33808. textureFloatRender: boolean;
  33809. /** Defines if half float textures are supported*/
  33810. textureHalfFloat: boolean;
  33811. /** Defines if half float texture linear filtering is supported*/
  33812. textureHalfFloatLinearFiltering: boolean;
  33813. /** Defines if rendering to half float textures is supported */
  33814. textureHalfFloatRender: boolean;
  33815. /** Defines if textureLOD shader command is supported */
  33816. textureLOD: boolean;
  33817. /** Defines if draw buffers extension is supported */
  33818. drawBuffersExtension: boolean;
  33819. /** Defines if depth textures are supported */
  33820. depthTextureExtension: boolean;
  33821. /** Defines if float color buffer are supported */
  33822. colorBufferFloat: boolean;
  33823. /** Gets disjoint timer query extension (null if not supported) */
  33824. timerQuery?: EXT_disjoint_timer_query;
  33825. /** Defines if timestamp can be used with timer query */
  33826. canUseTimestampForTimerQuery: boolean;
  33827. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33828. multiview?: any;
  33829. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33830. oculusMultiview?: any;
  33831. /** Function used to let the system compiles shaders in background */
  33832. parallelShaderCompile?: {
  33833. COMPLETION_STATUS_KHR: number;
  33834. };
  33835. /** Max number of texture samples for MSAA */
  33836. maxMSAASamples: number;
  33837. /** Defines if the blend min max extension is supported */
  33838. blendMinMax: boolean;
  33839. }
  33840. }
  33841. declare module BABYLON {
  33842. /**
  33843. * @hidden
  33844. **/
  33845. export class DepthCullingState {
  33846. private _isDepthTestDirty;
  33847. private _isDepthMaskDirty;
  33848. private _isDepthFuncDirty;
  33849. private _isCullFaceDirty;
  33850. private _isCullDirty;
  33851. private _isZOffsetDirty;
  33852. private _isFrontFaceDirty;
  33853. private _depthTest;
  33854. private _depthMask;
  33855. private _depthFunc;
  33856. private _cull;
  33857. private _cullFace;
  33858. private _zOffset;
  33859. private _frontFace;
  33860. /**
  33861. * Initializes the state.
  33862. */
  33863. constructor();
  33864. get isDirty(): boolean;
  33865. get zOffset(): number;
  33866. set zOffset(value: number);
  33867. get cullFace(): Nullable<number>;
  33868. set cullFace(value: Nullable<number>);
  33869. get cull(): Nullable<boolean>;
  33870. set cull(value: Nullable<boolean>);
  33871. get depthFunc(): Nullable<number>;
  33872. set depthFunc(value: Nullable<number>);
  33873. get depthMask(): boolean;
  33874. set depthMask(value: boolean);
  33875. get depthTest(): boolean;
  33876. set depthTest(value: boolean);
  33877. get frontFace(): Nullable<number>;
  33878. set frontFace(value: Nullable<number>);
  33879. reset(): void;
  33880. apply(gl: WebGLRenderingContext): void;
  33881. }
  33882. }
  33883. declare module BABYLON {
  33884. /**
  33885. * @hidden
  33886. **/
  33887. export class StencilState {
  33888. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  33889. static readonly ALWAYS: number;
  33890. /** Passed to stencilOperation to specify that stencil value must be kept */
  33891. static readonly KEEP: number;
  33892. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33893. static readonly REPLACE: number;
  33894. private _isStencilTestDirty;
  33895. private _isStencilMaskDirty;
  33896. private _isStencilFuncDirty;
  33897. private _isStencilOpDirty;
  33898. private _stencilTest;
  33899. private _stencilMask;
  33900. private _stencilFunc;
  33901. private _stencilFuncRef;
  33902. private _stencilFuncMask;
  33903. private _stencilOpStencilFail;
  33904. private _stencilOpDepthFail;
  33905. private _stencilOpStencilDepthPass;
  33906. get isDirty(): boolean;
  33907. get stencilFunc(): number;
  33908. set stencilFunc(value: number);
  33909. get stencilFuncRef(): number;
  33910. set stencilFuncRef(value: number);
  33911. get stencilFuncMask(): number;
  33912. set stencilFuncMask(value: number);
  33913. get stencilOpStencilFail(): number;
  33914. set stencilOpStencilFail(value: number);
  33915. get stencilOpDepthFail(): number;
  33916. set stencilOpDepthFail(value: number);
  33917. get stencilOpStencilDepthPass(): number;
  33918. set stencilOpStencilDepthPass(value: number);
  33919. get stencilMask(): number;
  33920. set stencilMask(value: number);
  33921. get stencilTest(): boolean;
  33922. set stencilTest(value: boolean);
  33923. constructor();
  33924. reset(): void;
  33925. apply(gl: WebGLRenderingContext): void;
  33926. }
  33927. }
  33928. declare module BABYLON {
  33929. /**
  33930. * @hidden
  33931. **/
  33932. export class AlphaState {
  33933. private _isAlphaBlendDirty;
  33934. private _isBlendFunctionParametersDirty;
  33935. private _isBlendEquationParametersDirty;
  33936. private _isBlendConstantsDirty;
  33937. private _alphaBlend;
  33938. private _blendFunctionParameters;
  33939. private _blendEquationParameters;
  33940. private _blendConstants;
  33941. /**
  33942. * Initializes the state.
  33943. */
  33944. constructor();
  33945. get isDirty(): boolean;
  33946. get alphaBlend(): boolean;
  33947. set alphaBlend(value: boolean);
  33948. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33949. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33950. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33951. reset(): void;
  33952. apply(gl: WebGLRenderingContext): void;
  33953. }
  33954. }
  33955. declare module BABYLON {
  33956. /** @hidden */
  33957. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33958. attributeProcessor(attribute: string): string;
  33959. varyingProcessor(varying: string, isFragment: boolean): string;
  33960. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33961. }
  33962. }
  33963. declare module BABYLON {
  33964. /**
  33965. * Interface for attribute information associated with buffer instanciation
  33966. */
  33967. export interface InstancingAttributeInfo {
  33968. /**
  33969. * Name of the GLSL attribute
  33970. * if attribute index is not specified, this is used to retrieve the index from the effect
  33971. */
  33972. attributeName: string;
  33973. /**
  33974. * Index/offset of the attribute in the vertex shader
  33975. * if not specified, this will be computes from the name.
  33976. */
  33977. index?: number;
  33978. /**
  33979. * size of the attribute, 1, 2, 3 or 4
  33980. */
  33981. attributeSize: number;
  33982. /**
  33983. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33984. */
  33985. offset: number;
  33986. /**
  33987. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33988. * default to 1
  33989. */
  33990. divisor?: number;
  33991. /**
  33992. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33993. * default is FLOAT
  33994. */
  33995. attributeType?: number;
  33996. /**
  33997. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33998. */
  33999. normalized?: boolean;
  34000. }
  34001. }
  34002. declare module BABYLON {
  34003. interface ThinEngine {
  34004. /**
  34005. * Update a video texture
  34006. * @param texture defines the texture to update
  34007. * @param video defines the video element to use
  34008. * @param invertY defines if data must be stored with Y axis inverted
  34009. */
  34010. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34011. }
  34012. }
  34013. declare module BABYLON {
  34014. interface ThinEngine {
  34015. /**
  34016. * Creates a dynamic texture
  34017. * @param width defines the width of the texture
  34018. * @param height defines the height of the texture
  34019. * @param generateMipMaps defines if the engine should generate the mip levels
  34020. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34021. * @returns the dynamic texture inside an InternalTexture
  34022. */
  34023. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34024. /**
  34025. * Update the content of a dynamic texture
  34026. * @param texture defines the texture to update
  34027. * @param canvas defines the canvas containing the source
  34028. * @param invertY defines if data must be stored with Y axis inverted
  34029. * @param premulAlpha defines if alpha is stored as premultiplied
  34030. * @param format defines the format of the data
  34031. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34032. */
  34033. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34034. }
  34035. }
  34036. declare module BABYLON {
  34037. /**
  34038. * Settings for finer control over video usage
  34039. */
  34040. export interface VideoTextureSettings {
  34041. /**
  34042. * Applies `autoplay` to video, if specified
  34043. */
  34044. autoPlay?: boolean;
  34045. /**
  34046. * Applies `loop` to video, if specified
  34047. */
  34048. loop?: boolean;
  34049. /**
  34050. * Automatically updates internal texture from video at every frame in the render loop
  34051. */
  34052. autoUpdateTexture: boolean;
  34053. /**
  34054. * Image src displayed during the video loading or until the user interacts with the video.
  34055. */
  34056. poster?: string;
  34057. }
  34058. /**
  34059. * If you want to display a video in your scene, this is the special texture for that.
  34060. * This special texture works similar to other textures, with the exception of a few parameters.
  34061. * @see https://doc.babylonjs.com/how_to/video_texture
  34062. */
  34063. export class VideoTexture extends Texture {
  34064. /**
  34065. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34066. */
  34067. readonly autoUpdateTexture: boolean;
  34068. /**
  34069. * The video instance used by the texture internally
  34070. */
  34071. readonly video: HTMLVideoElement;
  34072. private _onUserActionRequestedObservable;
  34073. /**
  34074. * Event triggerd when a dom action is required by the user to play the video.
  34075. * This happens due to recent changes in browser policies preventing video to auto start.
  34076. */
  34077. get onUserActionRequestedObservable(): Observable<Texture>;
  34078. private _generateMipMaps;
  34079. private _stillImageCaptured;
  34080. private _displayingPosterTexture;
  34081. private _settings;
  34082. private _createInternalTextureOnEvent;
  34083. private _frameId;
  34084. private _currentSrc;
  34085. /**
  34086. * Creates a video texture.
  34087. * If you want to display a video in your scene, this is the special texture for that.
  34088. * This special texture works similar to other textures, with the exception of a few parameters.
  34089. * @see https://doc.babylonjs.com/how_to/video_texture
  34090. * @param name optional name, will detect from video source, if not defined
  34091. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34092. * @param scene is obviously the current scene.
  34093. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34094. * @param invertY is false by default but can be used to invert video on Y axis
  34095. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34096. * @param settings allows finer control over video usage
  34097. */
  34098. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34099. private _getName;
  34100. private _getVideo;
  34101. private _createInternalTexture;
  34102. private reset;
  34103. /**
  34104. * @hidden Internal method to initiate `update`.
  34105. */
  34106. _rebuild(): void;
  34107. /**
  34108. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34109. */
  34110. update(): void;
  34111. /**
  34112. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34113. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34114. */
  34115. updateTexture(isVisible: boolean): void;
  34116. protected _updateInternalTexture: () => void;
  34117. /**
  34118. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34119. * @param url New url.
  34120. */
  34121. updateURL(url: string): void;
  34122. /**
  34123. * Clones the texture.
  34124. * @returns the cloned texture
  34125. */
  34126. clone(): VideoTexture;
  34127. /**
  34128. * Dispose the texture and release its associated resources.
  34129. */
  34130. dispose(): void;
  34131. /**
  34132. * Creates a video texture straight from a stream.
  34133. * @param scene Define the scene the texture should be created in
  34134. * @param stream Define the stream the texture should be created from
  34135. * @returns The created video texture as a promise
  34136. */
  34137. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34138. /**
  34139. * Creates a video texture straight from your WebCam video feed.
  34140. * @param scene Define the scene the texture should be created in
  34141. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34142. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34143. * @returns The created video texture as a promise
  34144. */
  34145. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34146. minWidth: number;
  34147. maxWidth: number;
  34148. minHeight: number;
  34149. maxHeight: number;
  34150. deviceId: string;
  34151. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34152. /**
  34153. * Creates a video texture straight from your WebCam video feed.
  34154. * @param scene Define the scene the texture should be created in
  34155. * @param onReady Define a callback to triggered once the texture will be ready
  34156. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34157. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34158. */
  34159. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34160. minWidth: number;
  34161. maxWidth: number;
  34162. minHeight: number;
  34163. maxHeight: number;
  34164. deviceId: string;
  34165. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34166. }
  34167. }
  34168. declare module BABYLON {
  34169. /**
  34170. * Defines the interface used by objects working like Scene
  34171. * @hidden
  34172. */
  34173. export interface ISceneLike {
  34174. _addPendingData(data: any): void;
  34175. _removePendingData(data: any): void;
  34176. offlineProvider: IOfflineProvider;
  34177. }
  34178. /** Interface defining initialization parameters for Engine class */
  34179. export interface EngineOptions extends WebGLContextAttributes {
  34180. /**
  34181. * Defines if the engine should no exceed a specified device ratio
  34182. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34183. */
  34184. limitDeviceRatio?: number;
  34185. /**
  34186. * Defines if webvr should be enabled automatically
  34187. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34188. */
  34189. autoEnableWebVR?: boolean;
  34190. /**
  34191. * Defines if webgl2 should be turned off even if supported
  34192. * @see http://doc.babylonjs.com/features/webgl2
  34193. */
  34194. disableWebGL2Support?: boolean;
  34195. /**
  34196. * Defines if webaudio should be initialized as well
  34197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34198. */
  34199. audioEngine?: boolean;
  34200. /**
  34201. * Defines if animations should run using a deterministic lock step
  34202. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34203. */
  34204. deterministicLockstep?: boolean;
  34205. /** Defines the maximum steps to use with deterministic lock step mode */
  34206. lockstepMaxSteps?: number;
  34207. /** Defines the seconds between each deterministic lock step */
  34208. timeStep?: number;
  34209. /**
  34210. * Defines that engine should ignore context lost events
  34211. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34212. */
  34213. doNotHandleContextLost?: boolean;
  34214. /**
  34215. * Defines that engine should ignore modifying touch action attribute and style
  34216. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34217. */
  34218. doNotHandleTouchAction?: boolean;
  34219. /**
  34220. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34221. */
  34222. useHighPrecisionFloats?: boolean;
  34223. /**
  34224. * Make the canvas XR Compatible for XR sessions
  34225. */
  34226. xrCompatible?: boolean;
  34227. }
  34228. /**
  34229. * The base engine class (root of all engines)
  34230. */
  34231. export class ThinEngine {
  34232. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34233. static ExceptionList: ({
  34234. key: string;
  34235. capture: string;
  34236. captureConstraint: number;
  34237. targets: string[];
  34238. } | {
  34239. key: string;
  34240. capture: null;
  34241. captureConstraint: null;
  34242. targets: string[];
  34243. })[];
  34244. /** @hidden */
  34245. static _TextureLoaders: IInternalTextureLoader[];
  34246. /**
  34247. * Returns the current npm package of the sdk
  34248. */
  34249. static get NpmPackage(): string;
  34250. /**
  34251. * Returns the current version of the framework
  34252. */
  34253. static get Version(): string;
  34254. /**
  34255. * Returns a string describing the current engine
  34256. */
  34257. get description(): string;
  34258. /**
  34259. * Gets or sets the epsilon value used by collision engine
  34260. */
  34261. static CollisionsEpsilon: number;
  34262. /**
  34263. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34264. */
  34265. static get ShadersRepository(): string;
  34266. static set ShadersRepository(value: string);
  34267. /** @hidden */
  34268. _shaderProcessor: IShaderProcessor;
  34269. /**
  34270. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34271. */
  34272. forcePOTTextures: boolean;
  34273. /**
  34274. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34275. */
  34276. isFullscreen: boolean;
  34277. /**
  34278. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34279. */
  34280. cullBackFaces: boolean;
  34281. /**
  34282. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34283. */
  34284. renderEvenInBackground: boolean;
  34285. /**
  34286. * Gets or sets a boolean indicating that cache can be kept between frames
  34287. */
  34288. preventCacheWipeBetweenFrames: boolean;
  34289. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34290. validateShaderPrograms: boolean;
  34291. /**
  34292. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34293. * This can provide greater z depth for distant objects.
  34294. */
  34295. useReverseDepthBuffer: boolean;
  34296. /**
  34297. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34298. */
  34299. disableUniformBuffers: boolean;
  34300. /** @hidden */
  34301. _uniformBuffers: UniformBuffer[];
  34302. /**
  34303. * Gets a boolean indicating that the engine supports uniform buffers
  34304. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34305. */
  34306. get supportsUniformBuffers(): boolean;
  34307. /** @hidden */
  34308. _gl: WebGLRenderingContext;
  34309. /** @hidden */
  34310. _webGLVersion: number;
  34311. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34312. protected _windowIsBackground: boolean;
  34313. protected _creationOptions: EngineOptions;
  34314. protected _highPrecisionShadersAllowed: boolean;
  34315. /** @hidden */
  34316. get _shouldUseHighPrecisionShader(): boolean;
  34317. /**
  34318. * Gets a boolean indicating that only power of 2 textures are supported
  34319. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34320. */
  34321. get needPOTTextures(): boolean;
  34322. /** @hidden */
  34323. _badOS: boolean;
  34324. /** @hidden */
  34325. _badDesktopOS: boolean;
  34326. private _hardwareScalingLevel;
  34327. /** @hidden */
  34328. _caps: EngineCapabilities;
  34329. private _isStencilEnable;
  34330. private _glVersion;
  34331. private _glRenderer;
  34332. private _glVendor;
  34333. /** @hidden */
  34334. _videoTextureSupported: boolean;
  34335. protected _renderingQueueLaunched: boolean;
  34336. protected _activeRenderLoops: (() => void)[];
  34337. /**
  34338. * Observable signaled when a context lost event is raised
  34339. */
  34340. onContextLostObservable: Observable<ThinEngine>;
  34341. /**
  34342. * Observable signaled when a context restored event is raised
  34343. */
  34344. onContextRestoredObservable: Observable<ThinEngine>;
  34345. private _onContextLost;
  34346. private _onContextRestored;
  34347. protected _contextWasLost: boolean;
  34348. /** @hidden */
  34349. _doNotHandleContextLost: boolean;
  34350. /**
  34351. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34352. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34353. */
  34354. get doNotHandleContextLost(): boolean;
  34355. set doNotHandleContextLost(value: boolean);
  34356. /**
  34357. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34358. */
  34359. disableVertexArrayObjects: boolean;
  34360. /** @hidden */
  34361. protected _colorWrite: boolean;
  34362. /** @hidden */
  34363. protected _colorWriteChanged: boolean;
  34364. /** @hidden */
  34365. protected _depthCullingState: DepthCullingState;
  34366. /** @hidden */
  34367. protected _stencilState: StencilState;
  34368. /** @hidden */
  34369. _alphaState: AlphaState;
  34370. /** @hidden */
  34371. _alphaMode: number;
  34372. /** @hidden */
  34373. _alphaEquation: number;
  34374. /** @hidden */
  34375. _internalTexturesCache: InternalTexture[];
  34376. /** @hidden */
  34377. protected _activeChannel: number;
  34378. private _currentTextureChannel;
  34379. /** @hidden */
  34380. protected _boundTexturesCache: {
  34381. [key: string]: Nullable<InternalTexture>;
  34382. };
  34383. /** @hidden */
  34384. protected _currentEffect: Nullable<Effect>;
  34385. /** @hidden */
  34386. protected _currentProgram: Nullable<WebGLProgram>;
  34387. private _compiledEffects;
  34388. private _vertexAttribArraysEnabled;
  34389. /** @hidden */
  34390. protected _cachedViewport: Nullable<IViewportLike>;
  34391. private _cachedVertexArrayObject;
  34392. /** @hidden */
  34393. protected _cachedVertexBuffers: any;
  34394. /** @hidden */
  34395. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34396. /** @hidden */
  34397. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34398. /** @hidden */
  34399. _currentRenderTarget: Nullable<InternalTexture>;
  34400. private _uintIndicesCurrentlySet;
  34401. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34402. /** @hidden */
  34403. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34404. /** @hidden */
  34405. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34406. private _currentBufferPointers;
  34407. private _currentInstanceLocations;
  34408. private _currentInstanceBuffers;
  34409. private _textureUnits;
  34410. /** @hidden */
  34411. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34412. /** @hidden */
  34413. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34414. /** @hidden */
  34415. _boundRenderFunction: any;
  34416. private _vaoRecordInProgress;
  34417. private _mustWipeVertexAttributes;
  34418. private _emptyTexture;
  34419. private _emptyCubeTexture;
  34420. private _emptyTexture3D;
  34421. private _emptyTexture2DArray;
  34422. /** @hidden */
  34423. _frameHandler: number;
  34424. private _nextFreeTextureSlots;
  34425. private _maxSimultaneousTextures;
  34426. private _activeRequests;
  34427. /** @hidden */
  34428. _transformTextureUrl: Nullable<(url: string) => string>;
  34429. protected get _supportsHardwareTextureRescaling(): boolean;
  34430. private _framebufferDimensionsObject;
  34431. /**
  34432. * sets the object from which width and height will be taken from when getting render width and height
  34433. * Will fallback to the gl object
  34434. * @param dimensions the framebuffer width and height that will be used.
  34435. */
  34436. set framebufferDimensionsObject(dimensions: Nullable<{
  34437. framebufferWidth: number;
  34438. framebufferHeight: number;
  34439. }>);
  34440. /**
  34441. * Gets the current viewport
  34442. */
  34443. get currentViewport(): Nullable<IViewportLike>;
  34444. /**
  34445. * Gets the default empty texture
  34446. */
  34447. get emptyTexture(): InternalTexture;
  34448. /**
  34449. * Gets the default empty 3D texture
  34450. */
  34451. get emptyTexture3D(): InternalTexture;
  34452. /**
  34453. * Gets the default empty 2D array texture
  34454. */
  34455. get emptyTexture2DArray(): InternalTexture;
  34456. /**
  34457. * Gets the default empty cube texture
  34458. */
  34459. get emptyCubeTexture(): InternalTexture;
  34460. /**
  34461. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34462. */
  34463. readonly premultipliedAlpha: boolean;
  34464. /**
  34465. * Observable event triggered before each texture is initialized
  34466. */
  34467. onBeforeTextureInitObservable: Observable<Texture>;
  34468. /**
  34469. * Creates a new engine
  34470. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  34471. * @param antialias defines enable antialiasing (default: false)
  34472. * @param options defines further options to be sent to the getContext() function
  34473. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34474. */
  34475. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34476. private _rebuildInternalTextures;
  34477. private _rebuildEffects;
  34478. /**
  34479. * Gets a boolean indicating if all created effects are ready
  34480. * @returns true if all effects are ready
  34481. */
  34482. areAllEffectsReady(): boolean;
  34483. protected _rebuildBuffers(): void;
  34484. protected _initGLContext(): void;
  34485. /**
  34486. * Gets version of the current webGL context
  34487. */
  34488. get webGLVersion(): number;
  34489. /**
  34490. * Gets a string idenfifying the name of the class
  34491. * @returns "Engine" string
  34492. */
  34493. getClassName(): string;
  34494. /**
  34495. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34496. */
  34497. get isStencilEnable(): boolean;
  34498. /** @hidden */
  34499. _prepareWorkingCanvas(): void;
  34500. /**
  34501. * Reset the texture cache to empty state
  34502. */
  34503. resetTextureCache(): void;
  34504. /**
  34505. * Gets an object containing information about the current webGL context
  34506. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34507. */
  34508. getGlInfo(): {
  34509. vendor: string;
  34510. renderer: string;
  34511. version: string;
  34512. };
  34513. /**
  34514. * Defines the hardware scaling level.
  34515. * By default the hardware scaling level is computed from the window device ratio.
  34516. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  34517. * @param level defines the level to use
  34518. */
  34519. setHardwareScalingLevel(level: number): void;
  34520. /**
  34521. * Gets the current hardware scaling level.
  34522. * By default the hardware scaling level is computed from the window device ratio.
  34523. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  34524. * @returns a number indicating the current hardware scaling level
  34525. */
  34526. getHardwareScalingLevel(): number;
  34527. /**
  34528. * Gets the list of loaded textures
  34529. * @returns an array containing all loaded textures
  34530. */
  34531. getLoadedTexturesCache(): InternalTexture[];
  34532. /**
  34533. * Gets the object containing all engine capabilities
  34534. * @returns the EngineCapabilities object
  34535. */
  34536. getCaps(): EngineCapabilities;
  34537. /**
  34538. * stop executing a render loop function and remove it from the execution array
  34539. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34540. */
  34541. stopRenderLoop(renderFunction?: () => void): void;
  34542. /** @hidden */
  34543. _renderLoop(): void;
  34544. /**
  34545. * Gets the HTML canvas attached with the current webGL context
  34546. * @returns a HTML canvas
  34547. */
  34548. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34549. /**
  34550. * Gets host window
  34551. * @returns the host window object
  34552. */
  34553. getHostWindow(): Nullable<Window>;
  34554. /**
  34555. * Gets the current render width
  34556. * @param useScreen defines if screen size must be used (or the current render target if any)
  34557. * @returns a number defining the current render width
  34558. */
  34559. getRenderWidth(useScreen?: boolean): number;
  34560. /**
  34561. * Gets the current render height
  34562. * @param useScreen defines if screen size must be used (or the current render target if any)
  34563. * @returns a number defining the current render height
  34564. */
  34565. getRenderHeight(useScreen?: boolean): number;
  34566. /**
  34567. * Can be used to override the current requestAnimationFrame requester.
  34568. * @hidden
  34569. */
  34570. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34571. /**
  34572. * Register and execute a render loop. The engine can have more than one render function
  34573. * @param renderFunction defines the function to continuously execute
  34574. */
  34575. runRenderLoop(renderFunction: () => void): void;
  34576. /**
  34577. * Clear the current render buffer or the current render target (if any is set up)
  34578. * @param color defines the color to use
  34579. * @param backBuffer defines if the back buffer must be cleared
  34580. * @param depth defines if the depth buffer must be cleared
  34581. * @param stencil defines if the stencil buffer must be cleared
  34582. */
  34583. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34584. private _viewportCached;
  34585. /** @hidden */
  34586. _viewport(x: number, y: number, width: number, height: number): void;
  34587. /**
  34588. * Set the WebGL's viewport
  34589. * @param viewport defines the viewport element to be used
  34590. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34591. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34592. */
  34593. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34594. /**
  34595. * Begin a new frame
  34596. */
  34597. beginFrame(): void;
  34598. /**
  34599. * Enf the current frame
  34600. */
  34601. endFrame(): void;
  34602. /**
  34603. * Resize the view according to the canvas' size
  34604. */
  34605. resize(): void;
  34606. /**
  34607. * Force a specific size of the canvas
  34608. * @param width defines the new canvas' width
  34609. * @param height defines the new canvas' height
  34610. * @returns true if the size was changed
  34611. */
  34612. setSize(width: number, height: number): boolean;
  34613. /**
  34614. * Binds the frame buffer to the specified texture.
  34615. * @param texture The texture to render to or null for the default canvas
  34616. * @param faceIndex The face of the texture to render to in case of cube texture
  34617. * @param requiredWidth The width of the target to render to
  34618. * @param requiredHeight The height of the target to render to
  34619. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34620. * @param lodLevel defines the lod level to bind to the frame buffer
  34621. * @param layer defines the 2d array index to bind to frame buffer to
  34622. */
  34623. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34624. /** @hidden */
  34625. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34626. /**
  34627. * Unbind the current render target texture from the webGL context
  34628. * @param texture defines the render target texture to unbind
  34629. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34630. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34631. */
  34632. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34633. /**
  34634. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34635. */
  34636. flushFramebuffer(): void;
  34637. /**
  34638. * Unbind the current render target and bind the default framebuffer
  34639. */
  34640. restoreDefaultFramebuffer(): void;
  34641. /** @hidden */
  34642. protected _resetVertexBufferBinding(): void;
  34643. /**
  34644. * Creates a vertex buffer
  34645. * @param data the data for the vertex buffer
  34646. * @returns the new WebGL static buffer
  34647. */
  34648. createVertexBuffer(data: DataArray): DataBuffer;
  34649. private _createVertexBuffer;
  34650. /**
  34651. * Creates a dynamic vertex buffer
  34652. * @param data the data for the dynamic vertex buffer
  34653. * @returns the new WebGL dynamic buffer
  34654. */
  34655. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34656. protected _resetIndexBufferBinding(): void;
  34657. /**
  34658. * Creates a new index buffer
  34659. * @param indices defines the content of the index buffer
  34660. * @param updatable defines if the index buffer must be updatable
  34661. * @returns a new webGL buffer
  34662. */
  34663. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34664. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34665. /**
  34666. * Bind a webGL buffer to the webGL context
  34667. * @param buffer defines the buffer to bind
  34668. */
  34669. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34670. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34671. private bindBuffer;
  34672. /**
  34673. * update the bound buffer with the given data
  34674. * @param data defines the data to update
  34675. */
  34676. updateArrayBuffer(data: Float32Array): void;
  34677. private _vertexAttribPointer;
  34678. /** @hidden */
  34679. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34680. private _bindVertexBuffersAttributes;
  34681. /**
  34682. * Records a vertex array object
  34683. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34684. * @param vertexBuffers defines the list of vertex buffers to store
  34685. * @param indexBuffer defines the index buffer to store
  34686. * @param effect defines the effect to store
  34687. * @returns the new vertex array object
  34688. */
  34689. recordVertexArrayObject(vertexBuffers: {
  34690. [key: string]: VertexBuffer;
  34691. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34692. /**
  34693. * Bind a specific vertex array object
  34694. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34695. * @param vertexArrayObject defines the vertex array object to bind
  34696. * @param indexBuffer defines the index buffer to bind
  34697. */
  34698. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34699. /**
  34700. * Bind webGl buffers directly to the webGL context
  34701. * @param vertexBuffer defines the vertex buffer to bind
  34702. * @param indexBuffer defines the index buffer to bind
  34703. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34704. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34705. * @param effect defines the effect associated with the vertex buffer
  34706. */
  34707. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34708. private _unbindVertexArrayObject;
  34709. /**
  34710. * Bind a list of vertex buffers to the webGL context
  34711. * @param vertexBuffers defines the list of vertex buffers to bind
  34712. * @param indexBuffer defines the index buffer to bind
  34713. * @param effect defines the effect associated with the vertex buffers
  34714. */
  34715. bindBuffers(vertexBuffers: {
  34716. [key: string]: Nullable<VertexBuffer>;
  34717. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34718. /**
  34719. * Unbind all instance attributes
  34720. */
  34721. unbindInstanceAttributes(): void;
  34722. /**
  34723. * Release and free the memory of a vertex array object
  34724. * @param vao defines the vertex array object to delete
  34725. */
  34726. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34727. /** @hidden */
  34728. _releaseBuffer(buffer: DataBuffer): boolean;
  34729. protected _deleteBuffer(buffer: DataBuffer): void;
  34730. /**
  34731. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34732. * @param instancesBuffer defines the webGL buffer to update and bind
  34733. * @param data defines the data to store in the buffer
  34734. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34735. */
  34736. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34737. /**
  34738. * Bind the content of a webGL buffer used with instantiation
  34739. * @param instancesBuffer defines the webGL buffer to bind
  34740. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34741. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34742. */
  34743. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34744. /**
  34745. * Disable the instance attribute corresponding to the name in parameter
  34746. * @param name defines the name of the attribute to disable
  34747. */
  34748. disableInstanceAttributeByName(name: string): void;
  34749. /**
  34750. * Disable the instance attribute corresponding to the location in parameter
  34751. * @param attributeLocation defines the attribute location of the attribute to disable
  34752. */
  34753. disableInstanceAttribute(attributeLocation: number): void;
  34754. /**
  34755. * Disable the attribute corresponding to the location in parameter
  34756. * @param attributeLocation defines the attribute location of the attribute to disable
  34757. */
  34758. disableAttributeByIndex(attributeLocation: number): void;
  34759. /**
  34760. * Send a draw order
  34761. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34762. * @param indexStart defines the starting index
  34763. * @param indexCount defines the number of index to draw
  34764. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34765. */
  34766. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34767. /**
  34768. * Draw a list of points
  34769. * @param verticesStart defines the index of first vertex to draw
  34770. * @param verticesCount defines the count of vertices to draw
  34771. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34772. */
  34773. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34774. /**
  34775. * Draw a list of unindexed primitives
  34776. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34777. * @param verticesStart defines the index of first vertex to draw
  34778. * @param verticesCount defines the count of vertices to draw
  34779. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34780. */
  34781. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34782. /**
  34783. * Draw a list of indexed primitives
  34784. * @param fillMode defines the primitive to use
  34785. * @param indexStart defines the starting index
  34786. * @param indexCount defines the number of index to draw
  34787. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34788. */
  34789. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34790. /**
  34791. * Draw a list of unindexed primitives
  34792. * @param fillMode defines the primitive to use
  34793. * @param verticesStart defines the index of first vertex to draw
  34794. * @param verticesCount defines the count of vertices to draw
  34795. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34796. */
  34797. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34798. private _drawMode;
  34799. /** @hidden */
  34800. protected _reportDrawCall(): void;
  34801. /** @hidden */
  34802. _releaseEffect(effect: Effect): void;
  34803. /** @hidden */
  34804. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34805. /**
  34806. * Create a new effect (used to store vertex/fragment shaders)
  34807. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34808. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34809. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34810. * @param samplers defines an array of string used to represent textures
  34811. * @param defines defines the string containing the defines to use to compile the shaders
  34812. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34813. * @param onCompiled defines a function to call when the effect creation is successful
  34814. * @param onError defines a function to call when the effect creation has failed
  34815. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34816. * @returns the new Effect
  34817. */
  34818. 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;
  34819. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34820. private _compileShader;
  34821. private _compileRawShader;
  34822. /** @hidden */
  34823. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34824. /**
  34825. * Directly creates a webGL program
  34826. * @param pipelineContext defines the pipeline context to attach to
  34827. * @param vertexCode defines the vertex shader code to use
  34828. * @param fragmentCode defines the fragment shader code to use
  34829. * @param context defines the webGL context to use (if not set, the current one will be used)
  34830. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34831. * @returns the new webGL program
  34832. */
  34833. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34834. /**
  34835. * Creates a webGL program
  34836. * @param pipelineContext defines the pipeline context to attach to
  34837. * @param vertexCode defines the vertex shader code to use
  34838. * @param fragmentCode defines the fragment shader code to use
  34839. * @param defines defines the string containing the defines to use to compile the shaders
  34840. * @param context defines the webGL context to use (if not set, the current one will be used)
  34841. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34842. * @returns the new webGL program
  34843. */
  34844. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34845. /**
  34846. * Creates a new pipeline context
  34847. * @returns the new pipeline
  34848. */
  34849. createPipelineContext(): IPipelineContext;
  34850. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34851. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34852. /** @hidden */
  34853. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34854. /** @hidden */
  34855. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34856. /** @hidden */
  34857. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34858. /**
  34859. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34860. * @param pipelineContext defines the pipeline context to use
  34861. * @param uniformsNames defines the list of uniform names
  34862. * @returns an array of webGL uniform locations
  34863. */
  34864. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34865. /**
  34866. * Gets the lsit of active attributes for a given webGL program
  34867. * @param pipelineContext defines the pipeline context to use
  34868. * @param attributesNames defines the list of attribute names to get
  34869. * @returns an array of indices indicating the offset of each attribute
  34870. */
  34871. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34872. /**
  34873. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34874. * @param effect defines the effect to activate
  34875. */
  34876. enableEffect(effect: Nullable<Effect>): void;
  34877. /**
  34878. * Set the value of an uniform to a number (int)
  34879. * @param uniform defines the webGL uniform location where to store the value
  34880. * @param value defines the int number to store
  34881. */
  34882. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34883. /**
  34884. * Set the value of an uniform to an array of int32
  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. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34889. /**
  34890. * Set the value of an uniform to an array of int32 (stored as vec2)
  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. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34895. /**
  34896. * Set the value of an uniform to an array of int32 (stored as vec3)
  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. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34901. /**
  34902. * Set the value of an uniform to an array of int32 (stored as vec4)
  34903. * @param uniform defines the webGL uniform location where to store the value
  34904. * @param array defines the array of int32 to store
  34905. */
  34906. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34907. /**
  34908. * Set the value of an uniform to an array of number
  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. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34913. /**
  34914. * Set the value of an uniform to an array of number (stored as vec2)
  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. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34919. /**
  34920. * Set the value of an uniform to an array of number (stored as vec3)
  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. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34925. /**
  34926. * Set the value of an uniform to an array of number (stored as vec4)
  34927. * @param uniform defines the webGL uniform location where to store the value
  34928. * @param array defines the array of number to store
  34929. */
  34930. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34931. /**
  34932. * Set the value of an uniform to an array of float32 (stored as matrices)
  34933. * @param uniform defines the webGL uniform location where to store the value
  34934. * @param matrices defines the array of float32 to store
  34935. */
  34936. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34937. /**
  34938. * Set the value of an uniform to a matrix (3x3)
  34939. * @param uniform defines the webGL uniform location where to store the value
  34940. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34941. */
  34942. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34943. /**
  34944. * Set the value of an uniform to a matrix (2x2)
  34945. * @param uniform defines the webGL uniform location where to store the value
  34946. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34947. */
  34948. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34949. /**
  34950. * Set the value of an uniform to a number (float)
  34951. * @param uniform defines the webGL uniform location where to store the value
  34952. * @param value defines the float number to store
  34953. */
  34954. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34955. /**
  34956. * Set the value of an uniform to a vec2
  34957. * @param uniform defines the webGL uniform location where to store the value
  34958. * @param x defines the 1st component of the value
  34959. * @param y defines the 2nd component of the value
  34960. */
  34961. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34962. /**
  34963. * Set the value of an uniform to a vec3
  34964. * @param uniform defines the webGL uniform location where to store the value
  34965. * @param x defines the 1st component of the value
  34966. * @param y defines the 2nd component of the value
  34967. * @param z defines the 3rd component of the value
  34968. */
  34969. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34970. /**
  34971. * Set the value of an uniform to a vec4
  34972. * @param uniform defines the webGL uniform location where to store the value
  34973. * @param x defines the 1st component of the value
  34974. * @param y defines the 2nd component of the value
  34975. * @param z defines the 3rd component of the value
  34976. * @param w defines the 4th component of the value
  34977. */
  34978. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34979. /**
  34980. * Apply all cached states (depth, culling, stencil and alpha)
  34981. */
  34982. applyStates(): void;
  34983. /**
  34984. * Enable or disable color writing
  34985. * @param enable defines the state to set
  34986. */
  34987. setColorWrite(enable: boolean): void;
  34988. /**
  34989. * Gets a boolean indicating if color writing is enabled
  34990. * @returns the current color writing state
  34991. */
  34992. getColorWrite(): boolean;
  34993. /**
  34994. * Gets the depth culling state manager
  34995. */
  34996. get depthCullingState(): DepthCullingState;
  34997. /**
  34998. * Gets the alpha state manager
  34999. */
  35000. get alphaState(): AlphaState;
  35001. /**
  35002. * Gets the stencil state manager
  35003. */
  35004. get stencilState(): StencilState;
  35005. /**
  35006. * Clears the list of texture accessible through engine.
  35007. * This can help preventing texture load conflict due to name collision.
  35008. */
  35009. clearInternalTexturesCache(): void;
  35010. /**
  35011. * Force the entire cache to be cleared
  35012. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35013. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35014. */
  35015. wipeCaches(bruteForce?: boolean): void;
  35016. /** @hidden */
  35017. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35018. min: number;
  35019. mag: number;
  35020. };
  35021. /** @hidden */
  35022. _createTexture(): WebGLTexture;
  35023. /**
  35024. * Usually called from Texture.ts.
  35025. * Passed information to create a WebGLTexture
  35026. * @param url defines a value which contains one of the following:
  35027. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35028. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35029. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35030. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35031. * @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)
  35032. * @param scene needed for loading to the correct scene
  35033. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35034. * @param onLoad optional callback to be called upon successful completion
  35035. * @param onError optional callback to be called upon failure
  35036. * @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
  35037. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35038. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35039. * @param forcedExtension defines the extension to use to pick the right loader
  35040. * @param mimeType defines an optional mime type
  35041. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35042. */
  35043. 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;
  35044. /**
  35045. * Loads an image as an HTMLImageElement.
  35046. * @param input url string, ArrayBuffer, or Blob to load
  35047. * @param onLoad callback called when the image successfully loads
  35048. * @param onError callback called when the image fails to load
  35049. * @param offlineProvider offline provider for caching
  35050. * @param mimeType optional mime type
  35051. * @returns the HTMLImageElement of the loaded image
  35052. * @hidden
  35053. */
  35054. 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>;
  35055. /**
  35056. * @hidden
  35057. */
  35058. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35059. private _unpackFlipYCached;
  35060. /**
  35061. * In case you are sharing the context with other applications, it might
  35062. * be interested to not cache the unpack flip y state to ensure a consistent
  35063. * value would be set.
  35064. */
  35065. enableUnpackFlipYCached: boolean;
  35066. /** @hidden */
  35067. _unpackFlipY(value: boolean): void;
  35068. /** @hidden */
  35069. _getUnpackAlignement(): number;
  35070. private _getTextureTarget;
  35071. /**
  35072. * Update the sampling mode of a given texture
  35073. * @param samplingMode defines the required sampling mode
  35074. * @param texture defines the texture to update
  35075. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35076. */
  35077. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35078. /**
  35079. * Update the sampling mode of a given texture
  35080. * @param texture defines the texture to update
  35081. * @param wrapU defines the texture wrap mode of the u coordinates
  35082. * @param wrapV defines the texture wrap mode of the v coordinates
  35083. * @param wrapR defines the texture wrap mode of the r coordinates
  35084. */
  35085. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35086. /** @hidden */
  35087. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35088. width: number;
  35089. height: number;
  35090. layers?: number;
  35091. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35092. /** @hidden */
  35093. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35094. /** @hidden */
  35095. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35096. /**
  35097. * Update a portion of an internal texture
  35098. * @param texture defines the texture to update
  35099. * @param imageData defines the data to store into the texture
  35100. * @param xOffset defines the x coordinates of the update rectangle
  35101. * @param yOffset defines the y coordinates of the update rectangle
  35102. * @param width defines the width of the update rectangle
  35103. * @param height defines the height of the update rectangle
  35104. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35105. * @param lod defines the lod level to update (0 by default)
  35106. */
  35107. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35108. /** @hidden */
  35109. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35110. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35111. private _prepareWebGLTexture;
  35112. /** @hidden */
  35113. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35114. private _getDepthStencilBuffer;
  35115. /** @hidden */
  35116. _releaseFramebufferObjects(texture: InternalTexture): void;
  35117. /** @hidden */
  35118. _releaseTexture(texture: InternalTexture): void;
  35119. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35120. protected _setProgram(program: WebGLProgram): void;
  35121. protected _boundUniforms: {
  35122. [key: number]: WebGLUniformLocation;
  35123. };
  35124. /**
  35125. * Binds an effect to the webGL context
  35126. * @param effect defines the effect to bind
  35127. */
  35128. bindSamplers(effect: Effect): void;
  35129. private _activateCurrentTexture;
  35130. /** @hidden */
  35131. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35132. /** @hidden */
  35133. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35134. /**
  35135. * Unbind all textures from the webGL context
  35136. */
  35137. unbindAllTextures(): void;
  35138. /**
  35139. * Sets a texture to the according uniform.
  35140. * @param channel The texture channel
  35141. * @param uniform The uniform to set
  35142. * @param texture The texture to apply
  35143. */
  35144. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35145. private _bindSamplerUniformToChannel;
  35146. private _getTextureWrapMode;
  35147. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35148. /**
  35149. * Sets an array of texture to the webGL context
  35150. * @param channel defines the channel where the texture array must be set
  35151. * @param uniform defines the associated uniform location
  35152. * @param textures defines the array of textures to bind
  35153. */
  35154. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35155. /** @hidden */
  35156. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35157. private _setTextureParameterFloat;
  35158. private _setTextureParameterInteger;
  35159. /**
  35160. * Unbind all vertex attributes from the webGL context
  35161. */
  35162. unbindAllAttributes(): void;
  35163. /**
  35164. * 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
  35165. */
  35166. releaseEffects(): void;
  35167. /**
  35168. * Dispose and release all associated resources
  35169. */
  35170. dispose(): void;
  35171. /**
  35172. * Attach a new callback raised when context lost event is fired
  35173. * @param callback defines the callback to call
  35174. */
  35175. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35176. /**
  35177. * Attach a new callback raised when context restored event is fired
  35178. * @param callback defines the callback to call
  35179. */
  35180. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35181. /**
  35182. * Get the current error code of the webGL context
  35183. * @returns the error code
  35184. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35185. */
  35186. getError(): number;
  35187. private _canRenderToFloatFramebuffer;
  35188. private _canRenderToHalfFloatFramebuffer;
  35189. private _canRenderToFramebuffer;
  35190. /** @hidden */
  35191. _getWebGLTextureType(type: number): number;
  35192. /** @hidden */
  35193. _getInternalFormat(format: number): number;
  35194. /** @hidden */
  35195. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35196. /** @hidden */
  35197. _getRGBAMultiSampleBufferFormat(type: number): number;
  35198. /** @hidden */
  35199. _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;
  35200. /**
  35201. * Loads a file from a url
  35202. * @param url url to load
  35203. * @param onSuccess callback called when the file successfully loads
  35204. * @param onProgress callback called while file is loading (if the server supports this mode)
  35205. * @param offlineProvider defines the offline provider for caching
  35206. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35207. * @param onError callback called when the file fails to load
  35208. * @returns a file request object
  35209. * @hidden
  35210. */
  35211. 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;
  35212. /**
  35213. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35214. * @param x defines the x coordinate of the rectangle where pixels must be read
  35215. * @param y defines the y coordinate of the rectangle where pixels must be read
  35216. * @param width defines the width of the rectangle where pixels must be read
  35217. * @param height defines the height of the rectangle where pixels must be read
  35218. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35219. * @returns a Uint8Array containing RGBA colors
  35220. */
  35221. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35222. private static _isSupported;
  35223. /**
  35224. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35225. * @returns true if the engine can be created
  35226. * @ignorenaming
  35227. */
  35228. static isSupported(): boolean;
  35229. /**
  35230. * Find the next highest power of two.
  35231. * @param x Number to start search from.
  35232. * @return Next highest power of two.
  35233. */
  35234. static CeilingPOT(x: number): number;
  35235. /**
  35236. * Find the next lowest power of two.
  35237. * @param x Number to start search from.
  35238. * @return Next lowest power of two.
  35239. */
  35240. static FloorPOT(x: number): number;
  35241. /**
  35242. * Find the nearest power of two.
  35243. * @param x Number to start search from.
  35244. * @return Next nearest power of two.
  35245. */
  35246. static NearestPOT(x: number): number;
  35247. /**
  35248. * Get the closest exponent of two
  35249. * @param value defines the value to approximate
  35250. * @param max defines the maximum value to return
  35251. * @param mode defines how to define the closest value
  35252. * @returns closest exponent of two of the given value
  35253. */
  35254. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35255. /**
  35256. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35257. * @param func - the function to be called
  35258. * @param requester - the object that will request the next frame. Falls back to window.
  35259. * @returns frame number
  35260. */
  35261. static QueueNewFrame(func: () => void, requester?: any): number;
  35262. /**
  35263. * Gets host document
  35264. * @returns the host document object
  35265. */
  35266. getHostDocument(): Nullable<Document>;
  35267. }
  35268. }
  35269. declare module BABYLON {
  35270. /**
  35271. * Class representing spherical harmonics coefficients to the 3rd degree
  35272. */
  35273. export class SphericalHarmonics {
  35274. /**
  35275. * Defines whether or not the harmonics have been prescaled for rendering.
  35276. */
  35277. preScaled: boolean;
  35278. /**
  35279. * The l0,0 coefficients of the spherical harmonics
  35280. */
  35281. l00: Vector3;
  35282. /**
  35283. * The l1,-1 coefficients of the spherical harmonics
  35284. */
  35285. l1_1: Vector3;
  35286. /**
  35287. * The l1,0 coefficients of the spherical harmonics
  35288. */
  35289. l10: Vector3;
  35290. /**
  35291. * The l1,1 coefficients of the spherical harmonics
  35292. */
  35293. l11: Vector3;
  35294. /**
  35295. * The l2,-2 coefficients of the spherical harmonics
  35296. */
  35297. l2_2: Vector3;
  35298. /**
  35299. * The l2,-1 coefficients of the spherical harmonics
  35300. */
  35301. l2_1: Vector3;
  35302. /**
  35303. * The l2,0 coefficients of the spherical harmonics
  35304. */
  35305. l20: Vector3;
  35306. /**
  35307. * The l2,1 coefficients of the spherical harmonics
  35308. */
  35309. l21: Vector3;
  35310. /**
  35311. * The l2,2 coefficients of the spherical harmonics
  35312. */
  35313. l22: Vector3;
  35314. /**
  35315. * Adds a light to the spherical harmonics
  35316. * @param direction the direction of the light
  35317. * @param color the color of the light
  35318. * @param deltaSolidAngle the delta solid angle of the light
  35319. */
  35320. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35321. /**
  35322. * Scales the spherical harmonics by the given amount
  35323. * @param scale the amount to scale
  35324. */
  35325. scaleInPlace(scale: number): void;
  35326. /**
  35327. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35328. *
  35329. * ```
  35330. * E_lm = A_l * L_lm
  35331. * ```
  35332. *
  35333. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35334. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35335. * the scaling factors are given in equation 9.
  35336. */
  35337. convertIncidentRadianceToIrradiance(): void;
  35338. /**
  35339. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35340. *
  35341. * ```
  35342. * L = (1/pi) * E * rho
  35343. * ```
  35344. *
  35345. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35346. */
  35347. convertIrradianceToLambertianRadiance(): void;
  35348. /**
  35349. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35350. * required operations at run time.
  35351. *
  35352. * This is simply done by scaling back the SH with Ylm constants parameter.
  35353. * The trigonometric part being applied by the shader at run time.
  35354. */
  35355. preScaleForRendering(): void;
  35356. /**
  35357. * Constructs a spherical harmonics from an array.
  35358. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35359. * @returns the spherical harmonics
  35360. */
  35361. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35362. /**
  35363. * Gets the spherical harmonics from polynomial
  35364. * @param polynomial the spherical polynomial
  35365. * @returns the spherical harmonics
  35366. */
  35367. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35368. }
  35369. /**
  35370. * Class representing spherical polynomial coefficients to the 3rd degree
  35371. */
  35372. export class SphericalPolynomial {
  35373. private _harmonics;
  35374. /**
  35375. * The spherical harmonics used to create the polynomials.
  35376. */
  35377. get preScaledHarmonics(): SphericalHarmonics;
  35378. /**
  35379. * The x coefficients of the spherical polynomial
  35380. */
  35381. x: Vector3;
  35382. /**
  35383. * The y coefficients of the spherical polynomial
  35384. */
  35385. y: Vector3;
  35386. /**
  35387. * The z coefficients of the spherical polynomial
  35388. */
  35389. z: Vector3;
  35390. /**
  35391. * The xx coefficients of the spherical polynomial
  35392. */
  35393. xx: Vector3;
  35394. /**
  35395. * The yy coefficients of the spherical polynomial
  35396. */
  35397. yy: Vector3;
  35398. /**
  35399. * The zz coefficients of the spherical polynomial
  35400. */
  35401. zz: Vector3;
  35402. /**
  35403. * The xy coefficients of the spherical polynomial
  35404. */
  35405. xy: Vector3;
  35406. /**
  35407. * The yz coefficients of the spherical polynomial
  35408. */
  35409. yz: Vector3;
  35410. /**
  35411. * The zx coefficients of the spherical polynomial
  35412. */
  35413. zx: Vector3;
  35414. /**
  35415. * Adds an ambient color to the spherical polynomial
  35416. * @param color the color to add
  35417. */
  35418. addAmbient(color: Color3): void;
  35419. /**
  35420. * Scales the spherical polynomial by the given amount
  35421. * @param scale the amount to scale
  35422. */
  35423. scaleInPlace(scale: number): void;
  35424. /**
  35425. * Gets the spherical polynomial from harmonics
  35426. * @param harmonics the spherical harmonics
  35427. * @returns the spherical polynomial
  35428. */
  35429. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35430. /**
  35431. * Constructs a spherical polynomial from an array.
  35432. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35433. * @returns the spherical polynomial
  35434. */
  35435. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35436. }
  35437. }
  35438. declare module BABYLON {
  35439. /**
  35440. * Defines the source of the internal texture
  35441. */
  35442. export enum InternalTextureSource {
  35443. /**
  35444. * The source of the texture data is unknown
  35445. */
  35446. Unknown = 0,
  35447. /**
  35448. * Texture data comes from an URL
  35449. */
  35450. Url = 1,
  35451. /**
  35452. * Texture data is only used for temporary storage
  35453. */
  35454. Temp = 2,
  35455. /**
  35456. * Texture data comes from raw data (ArrayBuffer)
  35457. */
  35458. Raw = 3,
  35459. /**
  35460. * Texture content is dynamic (video or dynamic texture)
  35461. */
  35462. Dynamic = 4,
  35463. /**
  35464. * Texture content is generated by rendering to it
  35465. */
  35466. RenderTarget = 5,
  35467. /**
  35468. * Texture content is part of a multi render target process
  35469. */
  35470. MultiRenderTarget = 6,
  35471. /**
  35472. * Texture data comes from a cube data file
  35473. */
  35474. Cube = 7,
  35475. /**
  35476. * Texture data comes from a raw cube data
  35477. */
  35478. CubeRaw = 8,
  35479. /**
  35480. * Texture data come from a prefiltered cube data file
  35481. */
  35482. CubePrefiltered = 9,
  35483. /**
  35484. * Texture content is raw 3D data
  35485. */
  35486. Raw3D = 10,
  35487. /**
  35488. * Texture content is raw 2D array data
  35489. */
  35490. Raw2DArray = 11,
  35491. /**
  35492. * Texture content is a depth texture
  35493. */
  35494. Depth = 12,
  35495. /**
  35496. * Texture data comes from a raw cube data encoded with RGBD
  35497. */
  35498. CubeRawRGBD = 13
  35499. }
  35500. /**
  35501. * Class used to store data associated with WebGL texture data for the engine
  35502. * This class should not be used directly
  35503. */
  35504. export class InternalTexture {
  35505. /** @hidden */
  35506. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35507. /**
  35508. * Defines if the texture is ready
  35509. */
  35510. isReady: boolean;
  35511. /**
  35512. * Defines if the texture is a cube texture
  35513. */
  35514. isCube: boolean;
  35515. /**
  35516. * Defines if the texture contains 3D data
  35517. */
  35518. is3D: boolean;
  35519. /**
  35520. * Defines if the texture contains 2D array data
  35521. */
  35522. is2DArray: boolean;
  35523. /**
  35524. * Defines if the texture contains multiview data
  35525. */
  35526. isMultiview: boolean;
  35527. /**
  35528. * Gets the URL used to load this texture
  35529. */
  35530. url: string;
  35531. /**
  35532. * Gets the sampling mode of the texture
  35533. */
  35534. samplingMode: number;
  35535. /**
  35536. * Gets a boolean indicating if the texture needs mipmaps generation
  35537. */
  35538. generateMipMaps: boolean;
  35539. /**
  35540. * Gets the number of samples used by the texture (WebGL2+ only)
  35541. */
  35542. samples: number;
  35543. /**
  35544. * Gets the type of the texture (int, float...)
  35545. */
  35546. type: number;
  35547. /**
  35548. * Gets the format of the texture (RGB, RGBA...)
  35549. */
  35550. format: number;
  35551. /**
  35552. * Observable called when the texture is loaded
  35553. */
  35554. onLoadedObservable: Observable<InternalTexture>;
  35555. /**
  35556. * Gets the width of the texture
  35557. */
  35558. width: number;
  35559. /**
  35560. * Gets the height of the texture
  35561. */
  35562. height: number;
  35563. /**
  35564. * Gets the depth of the texture
  35565. */
  35566. depth: number;
  35567. /**
  35568. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35569. */
  35570. baseWidth: number;
  35571. /**
  35572. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35573. */
  35574. baseHeight: number;
  35575. /**
  35576. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35577. */
  35578. baseDepth: number;
  35579. /**
  35580. * Gets a boolean indicating if the texture is inverted on Y axis
  35581. */
  35582. invertY: boolean;
  35583. /** @hidden */
  35584. _invertVScale: boolean;
  35585. /** @hidden */
  35586. _associatedChannel: number;
  35587. /** @hidden */
  35588. _source: InternalTextureSource;
  35589. /** @hidden */
  35590. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35591. /** @hidden */
  35592. _bufferView: Nullable<ArrayBufferView>;
  35593. /** @hidden */
  35594. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35595. /** @hidden */
  35596. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35597. /** @hidden */
  35598. _size: number;
  35599. /** @hidden */
  35600. _extension: string;
  35601. /** @hidden */
  35602. _files: Nullable<string[]>;
  35603. /** @hidden */
  35604. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35605. /** @hidden */
  35606. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35607. /** @hidden */
  35608. _framebuffer: Nullable<WebGLFramebuffer>;
  35609. /** @hidden */
  35610. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35611. /** @hidden */
  35612. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35613. /** @hidden */
  35614. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35615. /** @hidden */
  35616. _attachments: Nullable<number[]>;
  35617. /** @hidden */
  35618. _cachedCoordinatesMode: Nullable<number>;
  35619. /** @hidden */
  35620. _cachedWrapU: Nullable<number>;
  35621. /** @hidden */
  35622. _cachedWrapV: Nullable<number>;
  35623. /** @hidden */
  35624. _cachedWrapR: Nullable<number>;
  35625. /** @hidden */
  35626. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35627. /** @hidden */
  35628. _isDisabled: boolean;
  35629. /** @hidden */
  35630. _compression: Nullable<string>;
  35631. /** @hidden */
  35632. _generateStencilBuffer: boolean;
  35633. /** @hidden */
  35634. _generateDepthBuffer: boolean;
  35635. /** @hidden */
  35636. _comparisonFunction: number;
  35637. /** @hidden */
  35638. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35639. /** @hidden */
  35640. _lodGenerationScale: number;
  35641. /** @hidden */
  35642. _lodGenerationOffset: number;
  35643. /** @hidden */
  35644. _depthStencilTexture: Nullable<InternalTexture>;
  35645. /** @hidden */
  35646. _colorTextureArray: Nullable<WebGLTexture>;
  35647. /** @hidden */
  35648. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35649. /** @hidden */
  35650. _lodTextureHigh: Nullable<BaseTexture>;
  35651. /** @hidden */
  35652. _lodTextureMid: Nullable<BaseTexture>;
  35653. /** @hidden */
  35654. _lodTextureLow: Nullable<BaseTexture>;
  35655. /** @hidden */
  35656. _isRGBD: boolean;
  35657. /** @hidden */
  35658. _linearSpecularLOD: boolean;
  35659. /** @hidden */
  35660. _irradianceTexture: Nullable<BaseTexture>;
  35661. /** @hidden */
  35662. _webGLTexture: Nullable<WebGLTexture>;
  35663. /** @hidden */
  35664. _references: number;
  35665. private _engine;
  35666. /**
  35667. * Gets the Engine the texture belongs to.
  35668. * @returns The babylon engine
  35669. */
  35670. getEngine(): ThinEngine;
  35671. /**
  35672. * Gets the data source type of the texture
  35673. */
  35674. get source(): InternalTextureSource;
  35675. /**
  35676. * Creates a new InternalTexture
  35677. * @param engine defines the engine to use
  35678. * @param source defines the type of data that will be used
  35679. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35680. */
  35681. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35682. /**
  35683. * Increments the number of references (ie. the number of Texture that point to it)
  35684. */
  35685. incrementReferences(): void;
  35686. /**
  35687. * Change the size of the texture (not the size of the content)
  35688. * @param width defines the new width
  35689. * @param height defines the new height
  35690. * @param depth defines the new depth (1 by default)
  35691. */
  35692. updateSize(width: int, height: int, depth?: int): void;
  35693. /** @hidden */
  35694. _rebuild(): void;
  35695. /** @hidden */
  35696. _swapAndDie(target: InternalTexture): void;
  35697. /**
  35698. * Dispose the current allocated resources
  35699. */
  35700. dispose(): void;
  35701. }
  35702. }
  35703. declare module BABYLON {
  35704. /**
  35705. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35707. */
  35708. export class Analyser {
  35709. /**
  35710. * Gets or sets the smoothing
  35711. * @ignorenaming
  35712. */
  35713. SMOOTHING: number;
  35714. /**
  35715. * Gets or sets the FFT table size
  35716. * @ignorenaming
  35717. */
  35718. FFT_SIZE: number;
  35719. /**
  35720. * Gets or sets the bar graph amplitude
  35721. * @ignorenaming
  35722. */
  35723. BARGRAPHAMPLITUDE: number;
  35724. /**
  35725. * Gets or sets the position of the debug canvas
  35726. * @ignorenaming
  35727. */
  35728. DEBUGCANVASPOS: {
  35729. x: number;
  35730. y: number;
  35731. };
  35732. /**
  35733. * Gets or sets the debug canvas size
  35734. * @ignorenaming
  35735. */
  35736. DEBUGCANVASSIZE: {
  35737. width: number;
  35738. height: number;
  35739. };
  35740. private _byteFreqs;
  35741. private _byteTime;
  35742. private _floatFreqs;
  35743. private _webAudioAnalyser;
  35744. private _debugCanvas;
  35745. private _debugCanvasContext;
  35746. private _scene;
  35747. private _registerFunc;
  35748. private _audioEngine;
  35749. /**
  35750. * Creates a new analyser
  35751. * @param scene defines hosting scene
  35752. */
  35753. constructor(scene: Scene);
  35754. /**
  35755. * Get the number of data values you will have to play with for the visualization
  35756. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35757. * @returns a number
  35758. */
  35759. getFrequencyBinCount(): number;
  35760. /**
  35761. * Gets the current frequency data as a byte array
  35762. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35763. * @returns a Uint8Array
  35764. */
  35765. getByteFrequencyData(): Uint8Array;
  35766. /**
  35767. * Gets the current waveform as a byte array
  35768. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35769. * @returns a Uint8Array
  35770. */
  35771. getByteTimeDomainData(): Uint8Array;
  35772. /**
  35773. * Gets the current frequency data as a float array
  35774. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35775. * @returns a Float32Array
  35776. */
  35777. getFloatFrequencyData(): Float32Array;
  35778. /**
  35779. * Renders the debug canvas
  35780. */
  35781. drawDebugCanvas(): void;
  35782. /**
  35783. * Stops rendering the debug canvas and removes it
  35784. */
  35785. stopDebugCanvas(): void;
  35786. /**
  35787. * Connects two audio nodes
  35788. * @param inputAudioNode defines first node to connect
  35789. * @param outputAudioNode defines second node to connect
  35790. */
  35791. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35792. /**
  35793. * Releases all associated resources
  35794. */
  35795. dispose(): void;
  35796. }
  35797. }
  35798. declare module BABYLON {
  35799. /**
  35800. * This represents an audio engine and it is responsible
  35801. * to play, synchronize and analyse sounds throughout the application.
  35802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35803. */
  35804. export interface IAudioEngine extends IDisposable {
  35805. /**
  35806. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35807. */
  35808. readonly canUseWebAudio: boolean;
  35809. /**
  35810. * Gets the current AudioContext if available.
  35811. */
  35812. readonly audioContext: Nullable<AudioContext>;
  35813. /**
  35814. * The master gain node defines the global audio volume of your audio engine.
  35815. */
  35816. readonly masterGain: GainNode;
  35817. /**
  35818. * Gets whether or not mp3 are supported by your browser.
  35819. */
  35820. readonly isMP3supported: boolean;
  35821. /**
  35822. * Gets whether or not ogg are supported by your browser.
  35823. */
  35824. readonly isOGGsupported: boolean;
  35825. /**
  35826. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35827. * @ignoreNaming
  35828. */
  35829. WarnedWebAudioUnsupported: boolean;
  35830. /**
  35831. * Defines if the audio engine relies on a custom unlocked button.
  35832. * In this case, the embedded button will not be displayed.
  35833. */
  35834. useCustomUnlockedButton: boolean;
  35835. /**
  35836. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35837. */
  35838. readonly unlocked: boolean;
  35839. /**
  35840. * Event raised when audio has been unlocked on the browser.
  35841. */
  35842. onAudioUnlockedObservable: Observable<AudioEngine>;
  35843. /**
  35844. * Event raised when audio has been locked on the browser.
  35845. */
  35846. onAudioLockedObservable: Observable<AudioEngine>;
  35847. /**
  35848. * Flags the audio engine in Locked state.
  35849. * This happens due to new browser policies preventing audio to autoplay.
  35850. */
  35851. lock(): void;
  35852. /**
  35853. * Unlocks the audio engine once a user action has been done on the dom.
  35854. * This is helpful to resume play once browser policies have been satisfied.
  35855. */
  35856. unlock(): void;
  35857. /**
  35858. * Gets the global volume sets on the master gain.
  35859. * @returns the global volume if set or -1 otherwise
  35860. */
  35861. getGlobalVolume(): number;
  35862. /**
  35863. * Sets the global volume of your experience (sets on the master gain).
  35864. * @param newVolume Defines the new global volume of the application
  35865. */
  35866. setGlobalVolume(newVolume: number): void;
  35867. /**
  35868. * Connect the audio engine to an audio analyser allowing some amazing
  35869. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35871. * @param analyser The analyser to connect to the engine
  35872. */
  35873. connectToAnalyser(analyser: Analyser): void;
  35874. }
  35875. /**
  35876. * This represents the default audio engine used in babylon.
  35877. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35879. */
  35880. export class AudioEngine implements IAudioEngine {
  35881. private _audioContext;
  35882. private _audioContextInitialized;
  35883. private _muteButton;
  35884. private _hostElement;
  35885. /**
  35886. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35887. */
  35888. canUseWebAudio: boolean;
  35889. /**
  35890. * The master gain node defines the global audio volume of your audio engine.
  35891. */
  35892. masterGain: GainNode;
  35893. /**
  35894. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35895. * @ignoreNaming
  35896. */
  35897. WarnedWebAudioUnsupported: boolean;
  35898. /**
  35899. * Gets whether or not mp3 are supported by your browser.
  35900. */
  35901. isMP3supported: boolean;
  35902. /**
  35903. * Gets whether or not ogg are supported by your browser.
  35904. */
  35905. isOGGsupported: boolean;
  35906. /**
  35907. * Gets whether audio has been unlocked on the device.
  35908. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35909. * a user interaction has happened.
  35910. */
  35911. unlocked: boolean;
  35912. /**
  35913. * Defines if the audio engine relies on a custom unlocked button.
  35914. * In this case, the embedded button will not be displayed.
  35915. */
  35916. useCustomUnlockedButton: boolean;
  35917. /**
  35918. * Event raised when audio has been unlocked on the browser.
  35919. */
  35920. onAudioUnlockedObservable: Observable<AudioEngine>;
  35921. /**
  35922. * Event raised when audio has been locked on the browser.
  35923. */
  35924. onAudioLockedObservable: Observable<AudioEngine>;
  35925. /**
  35926. * Gets the current AudioContext if available.
  35927. */
  35928. get audioContext(): Nullable<AudioContext>;
  35929. private _connectedAnalyser;
  35930. /**
  35931. * Instantiates a new audio engine.
  35932. *
  35933. * There should be only one per page as some browsers restrict the number
  35934. * of audio contexts you can create.
  35935. * @param hostElement defines the host element where to display the mute icon if necessary
  35936. */
  35937. constructor(hostElement?: Nullable<HTMLElement>);
  35938. /**
  35939. * Flags the audio engine in Locked state.
  35940. * This happens due to new browser policies preventing audio to autoplay.
  35941. */
  35942. lock(): void;
  35943. /**
  35944. * Unlocks the audio engine once a user action has been done on the dom.
  35945. * This is helpful to resume play once browser policies have been satisfied.
  35946. */
  35947. unlock(): void;
  35948. private _resumeAudioContext;
  35949. private _initializeAudioContext;
  35950. private _tryToRun;
  35951. private _triggerRunningState;
  35952. private _triggerSuspendedState;
  35953. private _displayMuteButton;
  35954. private _moveButtonToTopLeft;
  35955. private _onResize;
  35956. private _hideMuteButton;
  35957. /**
  35958. * Destroy and release the resources associated with the audio ccontext.
  35959. */
  35960. dispose(): void;
  35961. /**
  35962. * Gets the global volume sets on the master gain.
  35963. * @returns the global volume if set or -1 otherwise
  35964. */
  35965. getGlobalVolume(): number;
  35966. /**
  35967. * Sets the global volume of your experience (sets on the master gain).
  35968. * @param newVolume Defines the new global volume of the application
  35969. */
  35970. setGlobalVolume(newVolume: number): void;
  35971. /**
  35972. * Connect the audio engine to an audio analyser allowing some amazing
  35973. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35975. * @param analyser The analyser to connect to the engine
  35976. */
  35977. connectToAnalyser(analyser: Analyser): void;
  35978. }
  35979. }
  35980. declare module BABYLON {
  35981. /**
  35982. * Interface used to present a loading screen while loading a scene
  35983. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35984. */
  35985. export interface ILoadingScreen {
  35986. /**
  35987. * Function called to display the loading screen
  35988. */
  35989. displayLoadingUI: () => void;
  35990. /**
  35991. * Function called to hide the loading screen
  35992. */
  35993. hideLoadingUI: () => void;
  35994. /**
  35995. * Gets or sets the color to use for the background
  35996. */
  35997. loadingUIBackgroundColor: string;
  35998. /**
  35999. * Gets or sets the text to display while loading
  36000. */
  36001. loadingUIText: string;
  36002. }
  36003. /**
  36004. * Class used for the default loading screen
  36005. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36006. */
  36007. export class DefaultLoadingScreen implements ILoadingScreen {
  36008. private _renderingCanvas;
  36009. private _loadingText;
  36010. private _loadingDivBackgroundColor;
  36011. private _loadingDiv;
  36012. private _loadingTextDiv;
  36013. /** Gets or sets the logo url to use for the default loading screen */
  36014. static DefaultLogoUrl: string;
  36015. /** Gets or sets the spinner url to use for the default loading screen */
  36016. static DefaultSpinnerUrl: string;
  36017. /**
  36018. * Creates a new default loading screen
  36019. * @param _renderingCanvas defines the canvas used to render the scene
  36020. * @param _loadingText defines the default text to display
  36021. * @param _loadingDivBackgroundColor defines the default background color
  36022. */
  36023. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36024. /**
  36025. * Function called to display the loading screen
  36026. */
  36027. displayLoadingUI(): void;
  36028. /**
  36029. * Function called to hide the loading screen
  36030. */
  36031. hideLoadingUI(): void;
  36032. /**
  36033. * Gets or sets the text to display while loading
  36034. */
  36035. set loadingUIText(text: string);
  36036. get loadingUIText(): string;
  36037. /**
  36038. * Gets or sets the color to use for the background
  36039. */
  36040. get loadingUIBackgroundColor(): string;
  36041. set loadingUIBackgroundColor(color: string);
  36042. private _resizeLoadingUI;
  36043. }
  36044. }
  36045. declare module BABYLON {
  36046. /**
  36047. * Interface for any object that can request an animation frame
  36048. */
  36049. export interface ICustomAnimationFrameRequester {
  36050. /**
  36051. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36052. */
  36053. renderFunction?: Function;
  36054. /**
  36055. * Called to request the next frame to render to
  36056. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36057. */
  36058. requestAnimationFrame: Function;
  36059. /**
  36060. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36061. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36062. */
  36063. requestID?: number;
  36064. }
  36065. }
  36066. declare module BABYLON {
  36067. /**
  36068. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36069. */
  36070. export class PerformanceMonitor {
  36071. private _enabled;
  36072. private _rollingFrameTime;
  36073. private _lastFrameTimeMs;
  36074. /**
  36075. * constructor
  36076. * @param frameSampleSize The number of samples required to saturate the sliding window
  36077. */
  36078. constructor(frameSampleSize?: number);
  36079. /**
  36080. * Samples current frame
  36081. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36082. */
  36083. sampleFrame(timeMs?: number): void;
  36084. /**
  36085. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36086. */
  36087. get averageFrameTime(): number;
  36088. /**
  36089. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36090. */
  36091. get averageFrameTimeVariance(): number;
  36092. /**
  36093. * Returns the frame time of the most recent frame
  36094. */
  36095. get instantaneousFrameTime(): number;
  36096. /**
  36097. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36098. */
  36099. get averageFPS(): number;
  36100. /**
  36101. * Returns the average framerate in frames per second using the most recent frame time
  36102. */
  36103. get instantaneousFPS(): number;
  36104. /**
  36105. * Returns true if enough samples have been taken to completely fill the sliding window
  36106. */
  36107. get isSaturated(): boolean;
  36108. /**
  36109. * Enables contributions to the sliding window sample set
  36110. */
  36111. enable(): void;
  36112. /**
  36113. * Disables contributions to the sliding window sample set
  36114. * Samples will not be interpolated over the disabled period
  36115. */
  36116. disable(): void;
  36117. /**
  36118. * Returns true if sampling is enabled
  36119. */
  36120. get isEnabled(): boolean;
  36121. /**
  36122. * Resets performance monitor
  36123. */
  36124. reset(): void;
  36125. }
  36126. /**
  36127. * RollingAverage
  36128. *
  36129. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36130. */
  36131. export class RollingAverage {
  36132. /**
  36133. * Current average
  36134. */
  36135. average: number;
  36136. /**
  36137. * Current variance
  36138. */
  36139. variance: number;
  36140. protected _samples: Array<number>;
  36141. protected _sampleCount: number;
  36142. protected _pos: number;
  36143. protected _m2: number;
  36144. /**
  36145. * constructor
  36146. * @param length The number of samples required to saturate the sliding window
  36147. */
  36148. constructor(length: number);
  36149. /**
  36150. * Adds a sample to the sample set
  36151. * @param v The sample value
  36152. */
  36153. add(v: number): void;
  36154. /**
  36155. * Returns previously added values or null if outside of history or outside the sliding window domain
  36156. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36157. * @return Value previously recorded with add() or null if outside of range
  36158. */
  36159. history(i: number): number;
  36160. /**
  36161. * Returns true if enough samples have been taken to completely fill the sliding window
  36162. * @return true if sample-set saturated
  36163. */
  36164. isSaturated(): boolean;
  36165. /**
  36166. * Resets the rolling average (equivalent to 0 samples taken so far)
  36167. */
  36168. reset(): void;
  36169. /**
  36170. * Wraps a value around the sample range boundaries
  36171. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36172. * @return Wrapped position in sample range
  36173. */
  36174. protected _wrapPosition(i: number): number;
  36175. }
  36176. }
  36177. declare module BABYLON {
  36178. /**
  36179. * This class is used to track a performance counter which is number based.
  36180. * The user has access to many properties which give statistics of different nature.
  36181. *
  36182. * The implementer can track two kinds of Performance Counter: time and count.
  36183. * 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.
  36184. * 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.
  36185. */
  36186. export class PerfCounter {
  36187. /**
  36188. * Gets or sets a global boolean to turn on and off all the counters
  36189. */
  36190. static Enabled: boolean;
  36191. /**
  36192. * Returns the smallest value ever
  36193. */
  36194. get min(): number;
  36195. /**
  36196. * Returns the biggest value ever
  36197. */
  36198. get max(): number;
  36199. /**
  36200. * Returns the average value since the performance counter is running
  36201. */
  36202. get average(): number;
  36203. /**
  36204. * Returns the average value of the last second the counter was monitored
  36205. */
  36206. get lastSecAverage(): number;
  36207. /**
  36208. * Returns the current value
  36209. */
  36210. get current(): number;
  36211. /**
  36212. * Gets the accumulated total
  36213. */
  36214. get total(): number;
  36215. /**
  36216. * Gets the total value count
  36217. */
  36218. get count(): number;
  36219. /**
  36220. * Creates a new counter
  36221. */
  36222. constructor();
  36223. /**
  36224. * Call this method to start monitoring a new frame.
  36225. * 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.
  36226. */
  36227. fetchNewFrame(): void;
  36228. /**
  36229. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36230. * @param newCount the count value to add to the monitored count
  36231. * @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.
  36232. */
  36233. addCount(newCount: number, fetchResult: boolean): void;
  36234. /**
  36235. * Start monitoring this performance counter
  36236. */
  36237. beginMonitoring(): void;
  36238. /**
  36239. * Compute the time lapsed since the previous beginMonitoring() call.
  36240. * @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
  36241. */
  36242. endMonitoring(newFrame?: boolean): void;
  36243. private _fetchResult;
  36244. private _startMonitoringTime;
  36245. private _min;
  36246. private _max;
  36247. private _average;
  36248. private _current;
  36249. private _totalValueCount;
  36250. private _totalAccumulated;
  36251. private _lastSecAverage;
  36252. private _lastSecAccumulated;
  36253. private _lastSecTime;
  36254. private _lastSecValueCount;
  36255. }
  36256. }
  36257. declare module BABYLON {
  36258. interface ThinEngine {
  36259. /**
  36260. * Sets alpha constants used by some alpha blending modes
  36261. * @param r defines the red component
  36262. * @param g defines the green component
  36263. * @param b defines the blue component
  36264. * @param a defines the alpha component
  36265. */
  36266. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36267. /**
  36268. * Sets the current alpha mode
  36269. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36270. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36271. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36272. */
  36273. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36274. /**
  36275. * Gets the current alpha mode
  36276. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36277. * @returns the current alpha mode
  36278. */
  36279. getAlphaMode(): number;
  36280. /**
  36281. * Sets the current alpha equation
  36282. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36283. */
  36284. setAlphaEquation(equation: number): void;
  36285. /**
  36286. * Gets the current alpha equation.
  36287. * @returns the current alpha equation
  36288. */
  36289. getAlphaEquation(): number;
  36290. }
  36291. }
  36292. declare module BABYLON {
  36293. interface ThinEngine {
  36294. /** @hidden */
  36295. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36296. }
  36297. }
  36298. declare module BABYLON {
  36299. /**
  36300. * Defines the interface used by display changed events
  36301. */
  36302. export interface IDisplayChangedEventArgs {
  36303. /** Gets the vrDisplay object (if any) */
  36304. vrDisplay: Nullable<any>;
  36305. /** Gets a boolean indicating if webVR is supported */
  36306. vrSupported: boolean;
  36307. }
  36308. /**
  36309. * Defines the interface used by objects containing a viewport (like a camera)
  36310. */
  36311. interface IViewportOwnerLike {
  36312. /**
  36313. * Gets or sets the viewport
  36314. */
  36315. viewport: IViewportLike;
  36316. }
  36317. /**
  36318. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36319. */
  36320. export class Engine extends ThinEngine {
  36321. /** Defines that alpha blending is disabled */
  36322. static readonly ALPHA_DISABLE: number;
  36323. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36324. static readonly ALPHA_ADD: number;
  36325. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36326. static readonly ALPHA_COMBINE: number;
  36327. /** Defines that alpha blending to DEST - SRC * DEST */
  36328. static readonly ALPHA_SUBTRACT: number;
  36329. /** Defines that alpha blending to SRC * DEST */
  36330. static readonly ALPHA_MULTIPLY: number;
  36331. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36332. static readonly ALPHA_MAXIMIZED: number;
  36333. /** Defines that alpha blending to SRC + DEST */
  36334. static readonly ALPHA_ONEONE: number;
  36335. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36336. static readonly ALPHA_PREMULTIPLIED: number;
  36337. /**
  36338. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36339. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36340. */
  36341. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36342. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36343. static readonly ALPHA_INTERPOLATE: number;
  36344. /**
  36345. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36346. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36347. */
  36348. static readonly ALPHA_SCREENMODE: number;
  36349. /** Defines that the ressource is not delayed*/
  36350. static readonly DELAYLOADSTATE_NONE: number;
  36351. /** Defines that the ressource was successfully delay loaded */
  36352. static readonly DELAYLOADSTATE_LOADED: number;
  36353. /** Defines that the ressource is currently delay loading */
  36354. static readonly DELAYLOADSTATE_LOADING: number;
  36355. /** Defines that the ressource is delayed and has not started loading */
  36356. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36357. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36358. static readonly NEVER: number;
  36359. /** 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 */
  36360. static readonly ALWAYS: number;
  36361. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36362. static readonly LESS: number;
  36363. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36364. static readonly EQUAL: number;
  36365. /** 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 */
  36366. static readonly LEQUAL: number;
  36367. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36368. static readonly GREATER: number;
  36369. /** 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 */
  36370. static readonly GEQUAL: number;
  36371. /** 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 */
  36372. static readonly NOTEQUAL: number;
  36373. /** Passed to stencilOperation to specify that stencil value must be kept */
  36374. static readonly KEEP: number;
  36375. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36376. static readonly REPLACE: number;
  36377. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36378. static readonly INCR: number;
  36379. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36380. static readonly DECR: number;
  36381. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36382. static readonly INVERT: number;
  36383. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36384. static readonly INCR_WRAP: number;
  36385. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36386. static readonly DECR_WRAP: number;
  36387. /** Texture is not repeating outside of 0..1 UVs */
  36388. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36389. /** Texture is repeating outside of 0..1 UVs */
  36390. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36391. /** Texture is repeating and mirrored */
  36392. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36393. /** ALPHA */
  36394. static readonly TEXTUREFORMAT_ALPHA: number;
  36395. /** LUMINANCE */
  36396. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36397. /** LUMINANCE_ALPHA */
  36398. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36399. /** RGB */
  36400. static readonly TEXTUREFORMAT_RGB: number;
  36401. /** RGBA */
  36402. static readonly TEXTUREFORMAT_RGBA: number;
  36403. /** RED */
  36404. static readonly TEXTUREFORMAT_RED: number;
  36405. /** RED (2nd reference) */
  36406. static readonly TEXTUREFORMAT_R: number;
  36407. /** RG */
  36408. static readonly TEXTUREFORMAT_RG: number;
  36409. /** RED_INTEGER */
  36410. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36411. /** RED_INTEGER (2nd reference) */
  36412. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36413. /** RG_INTEGER */
  36414. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36415. /** RGB_INTEGER */
  36416. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36417. /** RGBA_INTEGER */
  36418. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36419. /** UNSIGNED_BYTE */
  36420. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36421. /** UNSIGNED_BYTE (2nd reference) */
  36422. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36423. /** FLOAT */
  36424. static readonly TEXTURETYPE_FLOAT: number;
  36425. /** HALF_FLOAT */
  36426. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36427. /** BYTE */
  36428. static readonly TEXTURETYPE_BYTE: number;
  36429. /** SHORT */
  36430. static readonly TEXTURETYPE_SHORT: number;
  36431. /** UNSIGNED_SHORT */
  36432. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36433. /** INT */
  36434. static readonly TEXTURETYPE_INT: number;
  36435. /** UNSIGNED_INT */
  36436. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36437. /** UNSIGNED_SHORT_4_4_4_4 */
  36438. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36439. /** UNSIGNED_SHORT_5_5_5_1 */
  36440. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36441. /** UNSIGNED_SHORT_5_6_5 */
  36442. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36443. /** UNSIGNED_INT_2_10_10_10_REV */
  36444. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36445. /** UNSIGNED_INT_24_8 */
  36446. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36447. /** UNSIGNED_INT_10F_11F_11F_REV */
  36448. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36449. /** UNSIGNED_INT_5_9_9_9_REV */
  36450. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36451. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36452. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36453. /** nearest is mag = nearest and min = nearest and mip = linear */
  36454. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36455. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36456. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36457. /** Trilinear is mag = linear and min = linear and mip = linear */
  36458. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36459. /** nearest is mag = nearest and min = nearest and mip = linear */
  36460. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36461. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36462. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36463. /** Trilinear is mag = linear and min = linear and mip = linear */
  36464. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36465. /** mag = nearest and min = nearest and mip = nearest */
  36466. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36467. /** mag = nearest and min = linear and mip = nearest */
  36468. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36469. /** mag = nearest and min = linear and mip = linear */
  36470. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36471. /** mag = nearest and min = linear and mip = none */
  36472. static readonly TEXTURE_NEAREST_LINEAR: number;
  36473. /** mag = nearest and min = nearest and mip = none */
  36474. static readonly TEXTURE_NEAREST_NEAREST: number;
  36475. /** mag = linear and min = nearest and mip = nearest */
  36476. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36477. /** mag = linear and min = nearest and mip = linear */
  36478. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36479. /** mag = linear and min = linear and mip = none */
  36480. static readonly TEXTURE_LINEAR_LINEAR: number;
  36481. /** mag = linear and min = nearest and mip = none */
  36482. static readonly TEXTURE_LINEAR_NEAREST: number;
  36483. /** Explicit coordinates mode */
  36484. static readonly TEXTURE_EXPLICIT_MODE: number;
  36485. /** Spherical coordinates mode */
  36486. static readonly TEXTURE_SPHERICAL_MODE: number;
  36487. /** Planar coordinates mode */
  36488. static readonly TEXTURE_PLANAR_MODE: number;
  36489. /** Cubic coordinates mode */
  36490. static readonly TEXTURE_CUBIC_MODE: number;
  36491. /** Projection coordinates mode */
  36492. static readonly TEXTURE_PROJECTION_MODE: number;
  36493. /** Skybox coordinates mode */
  36494. static readonly TEXTURE_SKYBOX_MODE: number;
  36495. /** Inverse Cubic coordinates mode */
  36496. static readonly TEXTURE_INVCUBIC_MODE: number;
  36497. /** Equirectangular coordinates mode */
  36498. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36499. /** Equirectangular Fixed coordinates mode */
  36500. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36501. /** Equirectangular Fixed Mirrored coordinates mode */
  36502. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36503. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36504. static readonly SCALEMODE_FLOOR: number;
  36505. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36506. static readonly SCALEMODE_NEAREST: number;
  36507. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36508. static readonly SCALEMODE_CEILING: number;
  36509. /**
  36510. * Returns the current npm package of the sdk
  36511. */
  36512. static get NpmPackage(): string;
  36513. /**
  36514. * Returns the current version of the framework
  36515. */
  36516. static get Version(): string;
  36517. /** Gets the list of created engines */
  36518. static get Instances(): Engine[];
  36519. /**
  36520. * Gets the latest created engine
  36521. */
  36522. static get LastCreatedEngine(): Nullable<Engine>;
  36523. /**
  36524. * Gets the latest created scene
  36525. */
  36526. static get LastCreatedScene(): Nullable<Scene>;
  36527. /**
  36528. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36529. * @param flag defines which part of the materials must be marked as dirty
  36530. * @param predicate defines a predicate used to filter which materials should be affected
  36531. */
  36532. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36533. /**
  36534. * Method called to create the default loading screen.
  36535. * This can be overriden in your own app.
  36536. * @param canvas The rendering canvas element
  36537. * @returns The loading screen
  36538. */
  36539. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36540. /**
  36541. * Method called to create the default rescale post process on each engine.
  36542. */
  36543. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36544. /**
  36545. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36546. **/
  36547. enableOfflineSupport: boolean;
  36548. /**
  36549. * 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)
  36550. **/
  36551. disableManifestCheck: boolean;
  36552. /**
  36553. * Gets the list of created scenes
  36554. */
  36555. scenes: Scene[];
  36556. /**
  36557. * Event raised when a new scene is created
  36558. */
  36559. onNewSceneAddedObservable: Observable<Scene>;
  36560. /**
  36561. * Gets the list of created postprocesses
  36562. */
  36563. postProcesses: PostProcess[];
  36564. /**
  36565. * Gets a boolean indicating if the pointer is currently locked
  36566. */
  36567. isPointerLock: boolean;
  36568. /**
  36569. * Observable event triggered each time the rendering canvas is resized
  36570. */
  36571. onResizeObservable: Observable<Engine>;
  36572. /**
  36573. * Observable event triggered each time the canvas loses focus
  36574. */
  36575. onCanvasBlurObservable: Observable<Engine>;
  36576. /**
  36577. * Observable event triggered each time the canvas gains focus
  36578. */
  36579. onCanvasFocusObservable: Observable<Engine>;
  36580. /**
  36581. * Observable event triggered each time the canvas receives pointerout event
  36582. */
  36583. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36584. /**
  36585. * Observable raised when the engine begins a new frame
  36586. */
  36587. onBeginFrameObservable: Observable<Engine>;
  36588. /**
  36589. * If set, will be used to request the next animation frame for the render loop
  36590. */
  36591. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36592. /**
  36593. * Observable raised when the engine ends the current frame
  36594. */
  36595. onEndFrameObservable: Observable<Engine>;
  36596. /**
  36597. * Observable raised when the engine is about to compile a shader
  36598. */
  36599. onBeforeShaderCompilationObservable: Observable<Engine>;
  36600. /**
  36601. * Observable raised when the engine has jsut compiled a shader
  36602. */
  36603. onAfterShaderCompilationObservable: Observable<Engine>;
  36604. /**
  36605. * Gets the audio engine
  36606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36607. * @ignorenaming
  36608. */
  36609. static audioEngine: IAudioEngine;
  36610. /**
  36611. * Default AudioEngine factory responsible of creating the Audio Engine.
  36612. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36613. */
  36614. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36615. /**
  36616. * Default offline support factory responsible of creating a tool used to store data locally.
  36617. * By default, this will create a Database object if the workload has been embedded.
  36618. */
  36619. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36620. private _loadingScreen;
  36621. private _pointerLockRequested;
  36622. private _rescalePostProcess;
  36623. private _deterministicLockstep;
  36624. private _lockstepMaxSteps;
  36625. private _timeStep;
  36626. protected get _supportsHardwareTextureRescaling(): boolean;
  36627. private _fps;
  36628. private _deltaTime;
  36629. /** @hidden */
  36630. _drawCalls: PerfCounter;
  36631. /** 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 */
  36632. canvasTabIndex: number;
  36633. /**
  36634. * Turn this value on if you want to pause FPS computation when in background
  36635. */
  36636. disablePerformanceMonitorInBackground: boolean;
  36637. private _performanceMonitor;
  36638. /**
  36639. * Gets the performance monitor attached to this engine
  36640. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36641. */
  36642. get performanceMonitor(): PerformanceMonitor;
  36643. private _onFocus;
  36644. private _onBlur;
  36645. private _onCanvasPointerOut;
  36646. private _onCanvasBlur;
  36647. private _onCanvasFocus;
  36648. private _onFullscreenChange;
  36649. private _onPointerLockChange;
  36650. /**
  36651. * Gets the HTML element used to attach event listeners
  36652. * @returns a HTML element
  36653. */
  36654. getInputElement(): Nullable<HTMLElement>;
  36655. /**
  36656. * Creates a new engine
  36657. * @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
  36658. * @param antialias defines enable antialiasing (default: false)
  36659. * @param options defines further options to be sent to the getContext() function
  36660. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36661. */
  36662. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36663. /**
  36664. * Gets current aspect ratio
  36665. * @param viewportOwner defines the camera to use to get the aspect ratio
  36666. * @param useScreen defines if screen size must be used (or the current render target if any)
  36667. * @returns a number defining the aspect ratio
  36668. */
  36669. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36670. /**
  36671. * Gets current screen aspect ratio
  36672. * @returns a number defining the aspect ratio
  36673. */
  36674. getScreenAspectRatio(): number;
  36675. /**
  36676. * Gets the client rect of the HTML canvas attached with the current webGL context
  36677. * @returns a client rectanglee
  36678. */
  36679. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36680. /**
  36681. * Gets the client rect of the HTML element used for events
  36682. * @returns a client rectanglee
  36683. */
  36684. getInputElementClientRect(): Nullable<ClientRect>;
  36685. /**
  36686. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36687. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36688. * @returns true if engine is in deterministic lock step mode
  36689. */
  36690. isDeterministicLockStep(): boolean;
  36691. /**
  36692. * Gets the max steps when engine is running in deterministic lock step
  36693. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36694. * @returns the max steps
  36695. */
  36696. getLockstepMaxSteps(): number;
  36697. /**
  36698. * Returns the time in ms between steps when using deterministic lock step.
  36699. * @returns time step in (ms)
  36700. */
  36701. getTimeStep(): number;
  36702. /**
  36703. * Force the mipmap generation for the given render target texture
  36704. * @param texture defines the render target texture to use
  36705. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36706. */
  36707. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36708. /** States */
  36709. /**
  36710. * Set various states to the webGL context
  36711. * @param culling defines backface culling state
  36712. * @param zOffset defines the value to apply to zOffset (0 by default)
  36713. * @param force defines if states must be applied even if cache is up to date
  36714. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36715. */
  36716. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36717. /**
  36718. * Set the z offset to apply to current rendering
  36719. * @param value defines the offset to apply
  36720. */
  36721. setZOffset(value: number): void;
  36722. /**
  36723. * Gets the current value of the zOffset
  36724. * @returns the current zOffset state
  36725. */
  36726. getZOffset(): number;
  36727. /**
  36728. * Enable or disable depth buffering
  36729. * @param enable defines the state to set
  36730. */
  36731. setDepthBuffer(enable: boolean): void;
  36732. /**
  36733. * Gets a boolean indicating if depth writing is enabled
  36734. * @returns the current depth writing state
  36735. */
  36736. getDepthWrite(): boolean;
  36737. /**
  36738. * Enable or disable depth writing
  36739. * @param enable defines the state to set
  36740. */
  36741. setDepthWrite(enable: boolean): void;
  36742. /**
  36743. * Gets a boolean indicating if stencil buffer is enabled
  36744. * @returns the current stencil buffer state
  36745. */
  36746. getStencilBuffer(): boolean;
  36747. /**
  36748. * Enable or disable the stencil buffer
  36749. * @param enable defines if the stencil buffer must be enabled or disabled
  36750. */
  36751. setStencilBuffer(enable: boolean): void;
  36752. /**
  36753. * Gets the current stencil mask
  36754. * @returns a number defining the new stencil mask to use
  36755. */
  36756. getStencilMask(): number;
  36757. /**
  36758. * Sets the current stencil mask
  36759. * @param mask defines the new stencil mask to use
  36760. */
  36761. setStencilMask(mask: number): void;
  36762. /**
  36763. * Gets the current stencil function
  36764. * @returns a number defining the stencil function to use
  36765. */
  36766. getStencilFunction(): number;
  36767. /**
  36768. * Gets the current stencil reference value
  36769. * @returns a number defining the stencil reference value to use
  36770. */
  36771. getStencilFunctionReference(): number;
  36772. /**
  36773. * Gets the current stencil mask
  36774. * @returns a number defining the stencil mask to use
  36775. */
  36776. getStencilFunctionMask(): number;
  36777. /**
  36778. * Sets the current stencil function
  36779. * @param stencilFunc defines the new stencil function to use
  36780. */
  36781. setStencilFunction(stencilFunc: number): void;
  36782. /**
  36783. * Sets the current stencil reference
  36784. * @param reference defines the new stencil reference to use
  36785. */
  36786. setStencilFunctionReference(reference: number): void;
  36787. /**
  36788. * Sets the current stencil mask
  36789. * @param mask defines the new stencil mask to use
  36790. */
  36791. setStencilFunctionMask(mask: number): void;
  36792. /**
  36793. * Gets the current stencil operation when stencil fails
  36794. * @returns a number defining stencil operation to use when stencil fails
  36795. */
  36796. getStencilOperationFail(): number;
  36797. /**
  36798. * Gets the current stencil operation when depth fails
  36799. * @returns a number defining stencil operation to use when depth fails
  36800. */
  36801. getStencilOperationDepthFail(): number;
  36802. /**
  36803. * Gets the current stencil operation when stencil passes
  36804. * @returns a number defining stencil operation to use when stencil passes
  36805. */
  36806. getStencilOperationPass(): number;
  36807. /**
  36808. * Sets the stencil operation to use when stencil fails
  36809. * @param operation defines the stencil operation to use when stencil fails
  36810. */
  36811. setStencilOperationFail(operation: number): void;
  36812. /**
  36813. * Sets the stencil operation to use when depth fails
  36814. * @param operation defines the stencil operation to use when depth fails
  36815. */
  36816. setStencilOperationDepthFail(operation: number): void;
  36817. /**
  36818. * Sets the stencil operation to use when stencil passes
  36819. * @param operation defines the stencil operation to use when stencil passes
  36820. */
  36821. setStencilOperationPass(operation: number): void;
  36822. /**
  36823. * Sets a boolean indicating if the dithering state is enabled or disabled
  36824. * @param value defines the dithering state
  36825. */
  36826. setDitheringState(value: boolean): void;
  36827. /**
  36828. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36829. * @param value defines the rasterizer state
  36830. */
  36831. setRasterizerState(value: boolean): void;
  36832. /**
  36833. * Gets the current depth function
  36834. * @returns a number defining the depth function
  36835. */
  36836. getDepthFunction(): Nullable<number>;
  36837. /**
  36838. * Sets the current depth function
  36839. * @param depthFunc defines the function to use
  36840. */
  36841. setDepthFunction(depthFunc: number): void;
  36842. /**
  36843. * Sets the current depth function to GREATER
  36844. */
  36845. setDepthFunctionToGreater(): void;
  36846. /**
  36847. * Sets the current depth function to GEQUAL
  36848. */
  36849. setDepthFunctionToGreaterOrEqual(): void;
  36850. /**
  36851. * Sets the current depth function to LESS
  36852. */
  36853. setDepthFunctionToLess(): void;
  36854. /**
  36855. * Sets the current depth function to LEQUAL
  36856. */
  36857. setDepthFunctionToLessOrEqual(): void;
  36858. private _cachedStencilBuffer;
  36859. private _cachedStencilFunction;
  36860. private _cachedStencilMask;
  36861. private _cachedStencilOperationPass;
  36862. private _cachedStencilOperationFail;
  36863. private _cachedStencilOperationDepthFail;
  36864. private _cachedStencilReference;
  36865. /**
  36866. * Caches the the state of the stencil buffer
  36867. */
  36868. cacheStencilState(): void;
  36869. /**
  36870. * Restores the state of the stencil buffer
  36871. */
  36872. restoreStencilState(): void;
  36873. /**
  36874. * Directly set the WebGL Viewport
  36875. * @param x defines the x coordinate of the viewport (in screen space)
  36876. * @param y defines the y coordinate of the viewport (in screen space)
  36877. * @param width defines the width of the viewport (in screen space)
  36878. * @param height defines the height of the viewport (in screen space)
  36879. * @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
  36880. */
  36881. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36882. /**
  36883. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36884. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36885. * @param y defines the y-coordinate of the corner of the clear rectangle
  36886. * @param width defines the width of the clear rectangle
  36887. * @param height defines the height of the clear rectangle
  36888. * @param clearColor defines the clear color
  36889. */
  36890. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36891. /**
  36892. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36893. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36894. * @param y defines the y-coordinate of the corner of the clear rectangle
  36895. * @param width defines the width of the clear rectangle
  36896. * @param height defines the height of the clear rectangle
  36897. */
  36898. enableScissor(x: number, y: number, width: number, height: number): void;
  36899. /**
  36900. * Disable previously set scissor test rectangle
  36901. */
  36902. disableScissor(): void;
  36903. protected _reportDrawCall(): void;
  36904. /**
  36905. * Initializes a webVR display and starts listening to display change events
  36906. * The onVRDisplayChangedObservable will be notified upon these changes
  36907. * @returns The onVRDisplayChangedObservable
  36908. */
  36909. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36910. /** @hidden */
  36911. _prepareVRComponent(): void;
  36912. /** @hidden */
  36913. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36914. /** @hidden */
  36915. _submitVRFrame(): void;
  36916. /**
  36917. * Call this function to leave webVR mode
  36918. * Will do nothing if webVR is not supported or if there is no webVR device
  36919. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36920. */
  36921. disableVR(): void;
  36922. /**
  36923. * Gets a boolean indicating that the system is in VR mode and is presenting
  36924. * @returns true if VR mode is engaged
  36925. */
  36926. isVRPresenting(): boolean;
  36927. /** @hidden */
  36928. _requestVRFrame(): void;
  36929. /** @hidden */
  36930. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36931. /**
  36932. * Gets the source code of the vertex 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 vertex shader associated with the program
  36935. */
  36936. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36937. /**
  36938. * Gets the source code of the fragment shader associated with a specific webGL program
  36939. * @param program defines the program to use
  36940. * @returns a string containing the source code of the fragment shader associated with the program
  36941. */
  36942. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36943. /**
  36944. * Sets a depth stencil texture from a render target to the according uniform.
  36945. * @param channel The texture channel
  36946. * @param uniform The uniform to set
  36947. * @param texture The render target texture containing the depth stencil texture to apply
  36948. */
  36949. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36950. /**
  36951. * Sets a texture to the webGL context from a postprocess
  36952. * @param channel defines the channel to use
  36953. * @param postProcess defines the source postprocess
  36954. */
  36955. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36956. /**
  36957. * Binds the output of the passed in post process to the texture channel specified
  36958. * @param channel The channel the texture should be bound to
  36959. * @param postProcess The post process which's output should be bound
  36960. */
  36961. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36962. protected _rebuildBuffers(): void;
  36963. /** @hidden */
  36964. _renderFrame(): void;
  36965. _renderLoop(): void;
  36966. /** @hidden */
  36967. _renderViews(): boolean;
  36968. /**
  36969. * Toggle full screen mode
  36970. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36971. */
  36972. switchFullscreen(requestPointerLock: boolean): void;
  36973. /**
  36974. * Enters full screen mode
  36975. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36976. */
  36977. enterFullscreen(requestPointerLock: boolean): void;
  36978. /**
  36979. * Exits full screen mode
  36980. */
  36981. exitFullscreen(): void;
  36982. /**
  36983. * Enters Pointerlock mode
  36984. */
  36985. enterPointerlock(): void;
  36986. /**
  36987. * Exits Pointerlock mode
  36988. */
  36989. exitPointerlock(): void;
  36990. /**
  36991. * Begin a new frame
  36992. */
  36993. beginFrame(): void;
  36994. /**
  36995. * Enf the current frame
  36996. */
  36997. endFrame(): void;
  36998. resize(): void;
  36999. /**
  37000. * Force a specific size of the canvas
  37001. * @param width defines the new canvas' width
  37002. * @param height defines the new canvas' height
  37003. * @returns true if the size was changed
  37004. */
  37005. setSize(width: number, height: number): boolean;
  37006. /**
  37007. * Updates a dynamic vertex buffer.
  37008. * @param vertexBuffer the vertex buffer to update
  37009. * @param data the data used to update the vertex buffer
  37010. * @param byteOffset the byte offset of the data
  37011. * @param byteLength the byte length of the data
  37012. */
  37013. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37014. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37015. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37016. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37017. _releaseTexture(texture: InternalTexture): void;
  37018. /**
  37019. * @hidden
  37020. * Rescales a texture
  37021. * @param source input texutre
  37022. * @param destination destination texture
  37023. * @param scene scene to use to render the resize
  37024. * @param internalFormat format to use when resizing
  37025. * @param onComplete callback to be called when resize has completed
  37026. */
  37027. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37028. /**
  37029. * Gets the current framerate
  37030. * @returns a number representing the framerate
  37031. */
  37032. getFps(): number;
  37033. /**
  37034. * Gets the time spent between current and previous frame
  37035. * @returns a number representing the delta time in ms
  37036. */
  37037. getDeltaTime(): number;
  37038. private _measureFps;
  37039. /** @hidden */
  37040. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37041. /**
  37042. * Update a dynamic index buffer
  37043. * @param indexBuffer defines the target index buffer
  37044. * @param indices defines the data to update
  37045. * @param offset defines the offset in the target index buffer where update should start
  37046. */
  37047. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37048. /**
  37049. * Updates the sample count of a render target texture
  37050. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37051. * @param texture defines the texture to update
  37052. * @param samples defines the sample count to set
  37053. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37054. */
  37055. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37056. /**
  37057. * Updates a depth texture Comparison Mode and Function.
  37058. * If the comparison Function is equal to 0, the mode will be set to none.
  37059. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37060. * @param texture The texture to set the comparison function for
  37061. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37062. */
  37063. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37064. /**
  37065. * Creates a webGL buffer to use with instanciation
  37066. * @param capacity defines the size of the buffer
  37067. * @returns the webGL buffer
  37068. */
  37069. createInstancesBuffer(capacity: number): DataBuffer;
  37070. /**
  37071. * Delete a webGL buffer used with instanciation
  37072. * @param buffer defines the webGL buffer to delete
  37073. */
  37074. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37075. private _clientWaitAsync;
  37076. /** @hidden */
  37077. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37078. dispose(): void;
  37079. private _disableTouchAction;
  37080. /**
  37081. * Display the loading screen
  37082. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37083. */
  37084. displayLoadingUI(): void;
  37085. /**
  37086. * Hide the loading screen
  37087. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37088. */
  37089. hideLoadingUI(): void;
  37090. /**
  37091. * Gets the current loading screen object
  37092. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37093. */
  37094. get loadingScreen(): ILoadingScreen;
  37095. /**
  37096. * Sets the current loading screen object
  37097. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37098. */
  37099. set loadingScreen(loadingScreen: ILoadingScreen);
  37100. /**
  37101. * Sets the current loading screen text
  37102. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37103. */
  37104. set loadingUIText(text: string);
  37105. /**
  37106. * Sets the current loading screen background color
  37107. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37108. */
  37109. set loadingUIBackgroundColor(color: string);
  37110. /** Pointerlock and fullscreen */
  37111. /**
  37112. * Ask the browser to promote the current element to pointerlock mode
  37113. * @param element defines the DOM element to promote
  37114. */
  37115. static _RequestPointerlock(element: HTMLElement): void;
  37116. /**
  37117. * Asks the browser to exit pointerlock mode
  37118. */
  37119. static _ExitPointerlock(): void;
  37120. /**
  37121. * Ask the browser to promote the current element to fullscreen rendering mode
  37122. * @param element defines the DOM element to promote
  37123. */
  37124. static _RequestFullscreen(element: HTMLElement): void;
  37125. /**
  37126. * Asks the browser to exit fullscreen mode
  37127. */
  37128. static _ExitFullscreen(): void;
  37129. }
  37130. }
  37131. declare module BABYLON {
  37132. /**
  37133. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37134. * during the life time of the application.
  37135. */
  37136. export class EngineStore {
  37137. /** Gets the list of created engines */
  37138. static Instances: Engine[];
  37139. /** @hidden */
  37140. static _LastCreatedScene: Nullable<Scene>;
  37141. /**
  37142. * Gets the latest created engine
  37143. */
  37144. static get LastCreatedEngine(): Nullable<Engine>;
  37145. /**
  37146. * Gets the latest created scene
  37147. */
  37148. static get LastCreatedScene(): Nullable<Scene>;
  37149. /**
  37150. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37151. * @ignorenaming
  37152. */
  37153. static UseFallbackTexture: boolean;
  37154. /**
  37155. * Texture content used if a texture cannot loaded
  37156. * @ignorenaming
  37157. */
  37158. static FallbackTexture: string;
  37159. }
  37160. }
  37161. declare module BABYLON {
  37162. /**
  37163. * Helper class that provides a small promise polyfill
  37164. */
  37165. export class PromisePolyfill {
  37166. /**
  37167. * Static function used to check if the polyfill is required
  37168. * If this is the case then the function will inject the polyfill to window.Promise
  37169. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37170. */
  37171. static Apply(force?: boolean): void;
  37172. }
  37173. }
  37174. declare module BABYLON {
  37175. /**
  37176. * Interface for screenshot methods with describe argument called `size` as object with options
  37177. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37178. */
  37179. export interface IScreenshotSize {
  37180. /**
  37181. * number in pixels for canvas height
  37182. */
  37183. height?: number;
  37184. /**
  37185. * multiplier allowing render at a higher or lower resolution
  37186. * If value is defined then height and width will be ignored and taken from camera
  37187. */
  37188. precision?: number;
  37189. /**
  37190. * number in pixels for canvas width
  37191. */
  37192. width?: number;
  37193. }
  37194. }
  37195. declare module BABYLON {
  37196. interface IColor4Like {
  37197. r: float;
  37198. g: float;
  37199. b: float;
  37200. a: float;
  37201. }
  37202. /**
  37203. * Class containing a set of static utilities functions
  37204. */
  37205. export class Tools {
  37206. /**
  37207. * Gets or sets the base URL to use to load assets
  37208. */
  37209. static get BaseUrl(): string;
  37210. static set BaseUrl(value: string);
  37211. /**
  37212. * Enable/Disable Custom HTTP Request Headers globally.
  37213. * default = false
  37214. * @see CustomRequestHeaders
  37215. */
  37216. static UseCustomRequestHeaders: boolean;
  37217. /**
  37218. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37219. * i.e. when loading files, where the server/service expects an Authorization header
  37220. */
  37221. static CustomRequestHeaders: {
  37222. [key: string]: string;
  37223. };
  37224. /**
  37225. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37226. */
  37227. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37228. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37229. /**
  37230. * Default behaviour for cors in the application.
  37231. * It can be a string if the expected behavior is identical in the entire app.
  37232. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37233. */
  37234. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37235. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37236. /**
  37237. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37238. * @ignorenaming
  37239. */
  37240. static get UseFallbackTexture(): boolean;
  37241. static set UseFallbackTexture(value: boolean);
  37242. /**
  37243. * Use this object to register external classes like custom textures or material
  37244. * to allow the laoders to instantiate them
  37245. */
  37246. static get RegisteredExternalClasses(): {
  37247. [key: string]: Object;
  37248. };
  37249. static set RegisteredExternalClasses(classes: {
  37250. [key: string]: Object;
  37251. });
  37252. /**
  37253. * Texture content used if a texture cannot loaded
  37254. * @ignorenaming
  37255. */
  37256. static get fallbackTexture(): string;
  37257. static set fallbackTexture(value: string);
  37258. /**
  37259. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37260. * @param u defines the coordinate on X axis
  37261. * @param v defines the coordinate on Y axis
  37262. * @param width defines the width of the source data
  37263. * @param height defines the height of the source data
  37264. * @param pixels defines the source byte array
  37265. * @param color defines the output color
  37266. */
  37267. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37268. /**
  37269. * Interpolates between a and b via alpha
  37270. * @param a The lower value (returned when alpha = 0)
  37271. * @param b The upper value (returned when alpha = 1)
  37272. * @param alpha The interpolation-factor
  37273. * @return The mixed value
  37274. */
  37275. static Mix(a: number, b: number, alpha: number): number;
  37276. /**
  37277. * Tries to instantiate a new object from a given class name
  37278. * @param className defines the class name to instantiate
  37279. * @returns the new object or null if the system was not able to do the instantiation
  37280. */
  37281. static Instantiate(className: string): any;
  37282. /**
  37283. * Provides a slice function that will work even on IE
  37284. * @param data defines the array to slice
  37285. * @param start defines the start of the data (optional)
  37286. * @param end defines the end of the data (optional)
  37287. * @returns the new sliced array
  37288. */
  37289. static Slice<T>(data: T, start?: number, end?: number): T;
  37290. /**
  37291. * Polyfill for setImmediate
  37292. * @param action defines the action to execute after the current execution block
  37293. */
  37294. static SetImmediate(action: () => void): void;
  37295. /**
  37296. * Function indicating if a number is an exponent of 2
  37297. * @param value defines the value to test
  37298. * @returns true if the value is an exponent of 2
  37299. */
  37300. static IsExponentOfTwo(value: number): boolean;
  37301. private static _tmpFloatArray;
  37302. /**
  37303. * Returns the nearest 32-bit single precision float representation of a Number
  37304. * @param value A Number. If the parameter is of a different type, it will get converted
  37305. * to a number or to NaN if it cannot be converted
  37306. * @returns number
  37307. */
  37308. static FloatRound(value: number): number;
  37309. /**
  37310. * Extracts the filename from a path
  37311. * @param path defines the path to use
  37312. * @returns the filename
  37313. */
  37314. static GetFilename(path: string): string;
  37315. /**
  37316. * Extracts the "folder" part of a path (everything before the filename).
  37317. * @param uri The URI to extract the info from
  37318. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37319. * @returns The "folder" part of the path
  37320. */
  37321. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37322. /**
  37323. * Extracts text content from a DOM element hierarchy
  37324. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37325. */
  37326. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37327. /**
  37328. * Convert an angle in radians to degrees
  37329. * @param angle defines the angle to convert
  37330. * @returns the angle in degrees
  37331. */
  37332. static ToDegrees(angle: number): number;
  37333. /**
  37334. * Convert an angle in degrees to radians
  37335. * @param angle defines the angle to convert
  37336. * @returns the angle in radians
  37337. */
  37338. static ToRadians(angle: number): number;
  37339. /**
  37340. * Returns an array if obj is not an array
  37341. * @param obj defines the object to evaluate as an array
  37342. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37343. * @returns either obj directly if obj is an array or a new array containing obj
  37344. */
  37345. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37346. /**
  37347. * Gets the pointer prefix to use
  37348. * @param engine defines the engine we are finding the prefix for
  37349. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37350. */
  37351. static GetPointerPrefix(engine: Engine): string;
  37352. /**
  37353. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37354. * @param url define the url we are trying
  37355. * @param element define the dom element where to configure the cors policy
  37356. */
  37357. static SetCorsBehavior(url: string | string[], element: {
  37358. crossOrigin: string | null;
  37359. }): void;
  37360. /**
  37361. * Removes unwanted characters from an url
  37362. * @param url defines the url to clean
  37363. * @returns the cleaned url
  37364. */
  37365. static CleanUrl(url: string): string;
  37366. /**
  37367. * Gets or sets a function used to pre-process url before using them to load assets
  37368. */
  37369. static get PreprocessUrl(): (url: string) => string;
  37370. static set PreprocessUrl(processor: (url: string) => string);
  37371. /**
  37372. * Loads an image as an HTMLImageElement.
  37373. * @param input url string, ArrayBuffer, or Blob to load
  37374. * @param onLoad callback called when the image successfully loads
  37375. * @param onError callback called when the image fails to load
  37376. * @param offlineProvider offline provider for caching
  37377. * @param mimeType optional mime type
  37378. * @returns the HTMLImageElement of the loaded image
  37379. */
  37380. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37381. /**
  37382. * Loads a file from a url
  37383. * @param url url string, ArrayBuffer, or Blob to load
  37384. * @param onSuccess callback called when the file successfully loads
  37385. * @param onProgress callback called while file is loading (if the server supports this mode)
  37386. * @param offlineProvider defines the offline provider for caching
  37387. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37388. * @param onError callback called when the file fails to load
  37389. * @returns a file request object
  37390. */
  37391. 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;
  37392. /**
  37393. * Loads a file from a url
  37394. * @param url the file url to load
  37395. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37396. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37397. */
  37398. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37399. /**
  37400. * Load a script (identified by an url). When the url returns, the
  37401. * content of this file is added into a new script element, attached to the DOM (body element)
  37402. * @param scriptUrl defines the url of the script to laod
  37403. * @param onSuccess defines the callback called when the script is loaded
  37404. * @param onError defines the callback to call if an error occurs
  37405. * @param scriptId defines the id of the script element
  37406. */
  37407. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37408. /**
  37409. * Load an asynchronous script (identified by an url). When the url returns, the
  37410. * content of this file is added into a new script element, attached to the DOM (body element)
  37411. * @param scriptUrl defines the url of the script to laod
  37412. * @param scriptId defines the id of the script element
  37413. * @returns a promise request object
  37414. */
  37415. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37416. /**
  37417. * Loads a file from a blob
  37418. * @param fileToLoad defines the blob to use
  37419. * @param callback defines the callback to call when data is loaded
  37420. * @param progressCallback defines the callback to call during loading process
  37421. * @returns a file request object
  37422. */
  37423. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37424. /**
  37425. * Reads a file from a File object
  37426. * @param file defines the file to load
  37427. * @param onSuccess defines the callback to call when data is loaded
  37428. * @param onProgress defines the callback to call during loading process
  37429. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37430. * @param onError defines the callback to call when an error occurs
  37431. * @returns a file request object
  37432. */
  37433. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37434. /**
  37435. * Creates a data url from a given string content
  37436. * @param content defines the content to convert
  37437. * @returns the new data url link
  37438. */
  37439. static FileAsURL(content: string): string;
  37440. /**
  37441. * Format the given number to a specific decimal format
  37442. * @param value defines the number to format
  37443. * @param decimals defines the number of decimals to use
  37444. * @returns the formatted string
  37445. */
  37446. static Format(value: number, decimals?: number): string;
  37447. /**
  37448. * Tries to copy an object by duplicating every property
  37449. * @param source defines the source object
  37450. * @param destination defines the target object
  37451. * @param doNotCopyList defines a list of properties to avoid
  37452. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37453. */
  37454. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37455. /**
  37456. * Gets a boolean indicating if the given object has no own property
  37457. * @param obj defines the object to test
  37458. * @returns true if object has no own property
  37459. */
  37460. static IsEmpty(obj: any): boolean;
  37461. /**
  37462. * Function used to register events at window level
  37463. * @param windowElement defines the Window object to use
  37464. * @param events defines the events to register
  37465. */
  37466. static RegisterTopRootEvents(windowElement: Window, events: {
  37467. name: string;
  37468. handler: Nullable<(e: FocusEvent) => any>;
  37469. }[]): void;
  37470. /**
  37471. * Function used to unregister events from window level
  37472. * @param windowElement defines the Window object to use
  37473. * @param events defines the events to unregister
  37474. */
  37475. static UnregisterTopRootEvents(windowElement: Window, events: {
  37476. name: string;
  37477. handler: Nullable<(e: FocusEvent) => any>;
  37478. }[]): void;
  37479. /**
  37480. * @ignore
  37481. */
  37482. static _ScreenshotCanvas: HTMLCanvasElement;
  37483. /**
  37484. * Dumps the current bound framebuffer
  37485. * @param width defines the rendering width
  37486. * @param height defines the rendering height
  37487. * @param engine defines the hosting engine
  37488. * @param successCallback defines the callback triggered once the data are available
  37489. * @param mimeType defines the mime type of the result
  37490. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37491. */
  37492. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37493. /**
  37494. * Converts the canvas data to blob.
  37495. * This acts as a polyfill for browsers not supporting the to blob function.
  37496. * @param canvas Defines the canvas to extract the data from
  37497. * @param successCallback Defines the callback triggered once the data are available
  37498. * @param mimeType Defines the mime type of the result
  37499. */
  37500. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37501. /**
  37502. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37503. * @param successCallback defines the callback triggered once the data are available
  37504. * @param mimeType defines the mime type of the result
  37505. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37506. */
  37507. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37508. /**
  37509. * Downloads a blob in the browser
  37510. * @param blob defines the blob to download
  37511. * @param fileName defines the name of the downloaded file
  37512. */
  37513. static Download(blob: Blob, fileName: string): void;
  37514. /**
  37515. * Captures a screenshot of the current rendering
  37516. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37517. * @param engine defines the rendering engine
  37518. * @param camera defines the source camera
  37519. * @param size This parameter can be set to a single number or to an object with the
  37520. * following (optional) properties: precision, width, height. If a single number is passed,
  37521. * it will be used for both width and height. If an object is passed, the screenshot size
  37522. * will be derived from the parameters. The precision property is a multiplier allowing
  37523. * rendering at a higher or lower resolution
  37524. * @param successCallback defines the callback receives a single parameter which contains the
  37525. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37526. * src parameter of an <img> to display it
  37527. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37528. * Check your browser for supported MIME types
  37529. */
  37530. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37531. /**
  37532. * Captures a screenshot of the current rendering
  37533. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37534. * @param engine defines the rendering engine
  37535. * @param camera defines the source camera
  37536. * @param size This parameter can be set to a single number or to an object with the
  37537. * following (optional) properties: precision, width, height. If a single number is passed,
  37538. * it will be used for both width and height. If an object is passed, the screenshot size
  37539. * will be derived from the parameters. The precision property is a multiplier allowing
  37540. * rendering at a higher or lower resolution
  37541. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37542. * Check your browser for supported MIME types
  37543. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37544. * to the src parameter of an <img> to display it
  37545. */
  37546. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37547. /**
  37548. * Generates an image screenshot from the specified camera.
  37549. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37550. * @param engine The engine to use for rendering
  37551. * @param camera The camera to use for rendering
  37552. * @param size This parameter can be set to a single number or to an object with the
  37553. * following (optional) properties: precision, width, height. If a single number is passed,
  37554. * it will be used for both width and height. If an object is passed, the screenshot size
  37555. * will be derived from the parameters. The precision property is a multiplier allowing
  37556. * rendering at a higher or lower resolution
  37557. * @param successCallback The callback receives a single parameter which contains the
  37558. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37559. * src parameter of an <img> to display it
  37560. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37561. * Check your browser for supported MIME types
  37562. * @param samples Texture samples (default: 1)
  37563. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37564. * @param fileName A name for for the downloaded file.
  37565. */
  37566. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37567. /**
  37568. * Generates an image screenshot from the specified camera.
  37569. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37570. * @param engine The engine to use for rendering
  37571. * @param camera The camera to use for rendering
  37572. * @param size This parameter can be set to a single number or to an object with the
  37573. * following (optional) properties: precision, width, height. If a single number is passed,
  37574. * it will be used for both width and height. If an object is passed, the screenshot size
  37575. * will be derived from the parameters. The precision property is a multiplier allowing
  37576. * rendering at a higher or lower resolution
  37577. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37578. * Check your browser for supported MIME types
  37579. * @param samples Texture samples (default: 1)
  37580. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37581. * @param fileName A name for for the downloaded file.
  37582. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37583. * to the src parameter of an <img> to display it
  37584. */
  37585. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37586. /**
  37587. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37588. * Be aware Math.random() could cause collisions, but:
  37589. * "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"
  37590. * @returns a pseudo random id
  37591. */
  37592. static RandomId(): string;
  37593. /**
  37594. * Test if the given uri is a base64 string
  37595. * @param uri The uri to test
  37596. * @return True if the uri is a base64 string or false otherwise
  37597. */
  37598. static IsBase64(uri: string): boolean;
  37599. /**
  37600. * Decode the given base64 uri.
  37601. * @param uri The uri to decode
  37602. * @return The decoded base64 data.
  37603. */
  37604. static DecodeBase64(uri: string): ArrayBuffer;
  37605. /**
  37606. * Gets the absolute url.
  37607. * @param url the input url
  37608. * @return the absolute url
  37609. */
  37610. static GetAbsoluteUrl(url: string): string;
  37611. /**
  37612. * No log
  37613. */
  37614. static readonly NoneLogLevel: number;
  37615. /**
  37616. * Only message logs
  37617. */
  37618. static readonly MessageLogLevel: number;
  37619. /**
  37620. * Only warning logs
  37621. */
  37622. static readonly WarningLogLevel: number;
  37623. /**
  37624. * Only error logs
  37625. */
  37626. static readonly ErrorLogLevel: number;
  37627. /**
  37628. * All logs
  37629. */
  37630. static readonly AllLogLevel: number;
  37631. /**
  37632. * Gets a value indicating the number of loading errors
  37633. * @ignorenaming
  37634. */
  37635. static get errorsCount(): number;
  37636. /**
  37637. * Callback called when a new log is added
  37638. */
  37639. static OnNewCacheEntry: (entry: string) => void;
  37640. /**
  37641. * Log a message to the console
  37642. * @param message defines the message to log
  37643. */
  37644. static Log(message: string): void;
  37645. /**
  37646. * Write a warning message to the console
  37647. * @param message defines the message to log
  37648. */
  37649. static Warn(message: string): void;
  37650. /**
  37651. * Write an error message to the console
  37652. * @param message defines the message to log
  37653. */
  37654. static Error(message: string): void;
  37655. /**
  37656. * Gets current log cache (list of logs)
  37657. */
  37658. static get LogCache(): string;
  37659. /**
  37660. * Clears the log cache
  37661. */
  37662. static ClearLogCache(): void;
  37663. /**
  37664. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37665. */
  37666. static set LogLevels(level: number);
  37667. /**
  37668. * Checks if the window object exists
  37669. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37670. */
  37671. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37672. /**
  37673. * No performance log
  37674. */
  37675. static readonly PerformanceNoneLogLevel: number;
  37676. /**
  37677. * Use user marks to log performance
  37678. */
  37679. static readonly PerformanceUserMarkLogLevel: number;
  37680. /**
  37681. * Log performance to the console
  37682. */
  37683. static readonly PerformanceConsoleLogLevel: number;
  37684. private static _performance;
  37685. /**
  37686. * Sets the current performance log level
  37687. */
  37688. static set PerformanceLogLevel(level: number);
  37689. private static _StartPerformanceCounterDisabled;
  37690. private static _EndPerformanceCounterDisabled;
  37691. private static _StartUserMark;
  37692. private static _EndUserMark;
  37693. private static _StartPerformanceConsole;
  37694. private static _EndPerformanceConsole;
  37695. /**
  37696. * Starts a performance counter
  37697. */
  37698. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37699. /**
  37700. * Ends a specific performance coutner
  37701. */
  37702. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37703. /**
  37704. * Gets either window.performance.now() if supported or Date.now() else
  37705. */
  37706. static get Now(): number;
  37707. /**
  37708. * This method will return the name of the class used to create the instance of the given object.
  37709. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37710. * @param object the object to get the class name from
  37711. * @param isType defines if the object is actually a type
  37712. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37713. */
  37714. static GetClassName(object: any, isType?: boolean): string;
  37715. /**
  37716. * Gets the first element of an array satisfying a given predicate
  37717. * @param array defines the array to browse
  37718. * @param predicate defines the predicate to use
  37719. * @returns null if not found or the element
  37720. */
  37721. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37722. /**
  37723. * This method will return the name of the full name of the class, including its owning module (if any).
  37724. * 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).
  37725. * @param object the object to get the class name from
  37726. * @param isType defines if the object is actually a type
  37727. * @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.
  37728. * @ignorenaming
  37729. */
  37730. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37731. /**
  37732. * Returns a promise that resolves after the given amount of time.
  37733. * @param delay Number of milliseconds to delay
  37734. * @returns Promise that resolves after the given amount of time
  37735. */
  37736. static DelayAsync(delay: number): Promise<void>;
  37737. /**
  37738. * Utility function to detect if the current user agent is Safari
  37739. * @returns whether or not the current user agent is safari
  37740. */
  37741. static IsSafari(): boolean;
  37742. }
  37743. /**
  37744. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37745. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37746. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37747. * @param name The name of the class, case should be preserved
  37748. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37749. */
  37750. export function className(name: string, module?: string): (target: Object) => void;
  37751. /**
  37752. * An implementation of a loop for asynchronous functions.
  37753. */
  37754. export class AsyncLoop {
  37755. /**
  37756. * Defines the number of iterations for the loop
  37757. */
  37758. iterations: number;
  37759. /**
  37760. * Defines the current index of the loop.
  37761. */
  37762. index: number;
  37763. private _done;
  37764. private _fn;
  37765. private _successCallback;
  37766. /**
  37767. * Constructor.
  37768. * @param iterations the number of iterations.
  37769. * @param func the function to run each iteration
  37770. * @param successCallback the callback that will be called upon succesful execution
  37771. * @param offset starting offset.
  37772. */
  37773. constructor(
  37774. /**
  37775. * Defines the number of iterations for the loop
  37776. */
  37777. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37778. /**
  37779. * Execute the next iteration. Must be called after the last iteration was finished.
  37780. */
  37781. executeNext(): void;
  37782. /**
  37783. * Break the loop and run the success callback.
  37784. */
  37785. breakLoop(): void;
  37786. /**
  37787. * Create and run an async loop.
  37788. * @param iterations the number of iterations.
  37789. * @param fn the function to run each iteration
  37790. * @param successCallback the callback that will be called upon succesful execution
  37791. * @param offset starting offset.
  37792. * @returns the created async loop object
  37793. */
  37794. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37795. /**
  37796. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37797. * @param iterations total number of iterations
  37798. * @param syncedIterations number of synchronous iterations in each async iteration.
  37799. * @param fn the function to call each iteration.
  37800. * @param callback a success call back that will be called when iterating stops.
  37801. * @param breakFunction a break condition (optional)
  37802. * @param timeout timeout settings for the setTimeout function. default - 0.
  37803. * @returns the created async loop object
  37804. */
  37805. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37806. }
  37807. }
  37808. declare module BABYLON {
  37809. /**
  37810. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37811. * The underlying implementation relies on an associative array to ensure the best performances.
  37812. * The value can be anything including 'null' but except 'undefined'
  37813. */
  37814. export class StringDictionary<T> {
  37815. /**
  37816. * This will clear this dictionary and copy the content from the 'source' one.
  37817. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37818. * @param source the dictionary to take the content from and copy to this dictionary
  37819. */
  37820. copyFrom(source: StringDictionary<T>): void;
  37821. /**
  37822. * Get a value based from its key
  37823. * @param key the given key to get the matching value from
  37824. * @return the value if found, otherwise undefined is returned
  37825. */
  37826. get(key: string): T | undefined;
  37827. /**
  37828. * Get a value from its key or add it if it doesn't exist.
  37829. * This method will ensure you that a given key/data will be present in the dictionary.
  37830. * @param key the given key to get the matching value from
  37831. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37832. * The factory will only be invoked if there's no data for the given key.
  37833. * @return the value corresponding to the key.
  37834. */
  37835. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37836. /**
  37837. * Get a value from its key if present in the dictionary otherwise add it
  37838. * @param key the key to get the value from
  37839. * @param val if there's no such key/value pair in the dictionary add it with this value
  37840. * @return the value corresponding to the key
  37841. */
  37842. getOrAdd(key: string, val: T): T;
  37843. /**
  37844. * Check if there's a given key in the dictionary
  37845. * @param key the key to check for
  37846. * @return true if the key is present, false otherwise
  37847. */
  37848. contains(key: string): boolean;
  37849. /**
  37850. * Add a new key and its corresponding value
  37851. * @param key the key to add
  37852. * @param value the value corresponding to the key
  37853. * @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
  37854. */
  37855. add(key: string, value: T): boolean;
  37856. /**
  37857. * Update a specific value associated to a key
  37858. * @param key defines the key to use
  37859. * @param value defines the value to store
  37860. * @returns true if the value was updated (or false if the key was not found)
  37861. */
  37862. set(key: string, value: T): boolean;
  37863. /**
  37864. * Get the element of the given key and remove it from the dictionary
  37865. * @param key defines the key to search
  37866. * @returns the value associated with the key or null if not found
  37867. */
  37868. getAndRemove(key: string): Nullable<T>;
  37869. /**
  37870. * Remove a key/value from the dictionary.
  37871. * @param key the key to remove
  37872. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37873. */
  37874. remove(key: string): boolean;
  37875. /**
  37876. * Clear the whole content of the dictionary
  37877. */
  37878. clear(): void;
  37879. /**
  37880. * Gets the current count
  37881. */
  37882. get count(): number;
  37883. /**
  37884. * Execute a callback on each key/val of the dictionary.
  37885. * Note that you can remove any element in this dictionary in the callback implementation
  37886. * @param callback the callback to execute on a given key/value pair
  37887. */
  37888. forEach(callback: (key: string, val: T) => void): void;
  37889. /**
  37890. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37891. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37892. * Note that you can remove any element in this dictionary in the callback implementation
  37893. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37894. * @returns the first item
  37895. */
  37896. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37897. private _count;
  37898. private _data;
  37899. }
  37900. }
  37901. declare module BABYLON {
  37902. /** @hidden */
  37903. export interface ICollisionCoordinator {
  37904. createCollider(): Collider;
  37905. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37906. init(scene: Scene): void;
  37907. }
  37908. /** @hidden */
  37909. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37910. private _scene;
  37911. private _scaledPosition;
  37912. private _scaledVelocity;
  37913. private _finalPosition;
  37914. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37915. createCollider(): Collider;
  37916. init(scene: Scene): void;
  37917. private _collideWithWorld;
  37918. }
  37919. }
  37920. declare module BABYLON {
  37921. /**
  37922. * Class used to manage all inputs for the scene.
  37923. */
  37924. export class InputManager {
  37925. /** The distance in pixel that you have to move to prevent some events */
  37926. static DragMovementThreshold: number;
  37927. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37928. static LongPressDelay: number;
  37929. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37930. static DoubleClickDelay: number;
  37931. /** If you need to check double click without raising a single click at first click, enable this flag */
  37932. static ExclusiveDoubleClickMode: boolean;
  37933. private _wheelEventName;
  37934. private _onPointerMove;
  37935. private _onPointerDown;
  37936. private _onPointerUp;
  37937. private _initClickEvent;
  37938. private _initActionManager;
  37939. private _delayedSimpleClick;
  37940. private _delayedSimpleClickTimeout;
  37941. private _previousDelayedSimpleClickTimeout;
  37942. private _meshPickProceed;
  37943. private _previousButtonPressed;
  37944. private _currentPickResult;
  37945. private _previousPickResult;
  37946. private _totalPointersPressed;
  37947. private _doubleClickOccured;
  37948. private _pointerOverMesh;
  37949. private _pickedDownMesh;
  37950. private _pickedUpMesh;
  37951. private _pointerX;
  37952. private _pointerY;
  37953. private _unTranslatedPointerX;
  37954. private _unTranslatedPointerY;
  37955. private _startingPointerPosition;
  37956. private _previousStartingPointerPosition;
  37957. private _startingPointerTime;
  37958. private _previousStartingPointerTime;
  37959. private _pointerCaptures;
  37960. private _onKeyDown;
  37961. private _onKeyUp;
  37962. private _onCanvasFocusObserver;
  37963. private _onCanvasBlurObserver;
  37964. private _scene;
  37965. /**
  37966. * Creates a new InputManager
  37967. * @param scene defines the hosting scene
  37968. */
  37969. constructor(scene: Scene);
  37970. /**
  37971. * Gets the mesh that is currently under the pointer
  37972. */
  37973. get meshUnderPointer(): Nullable<AbstractMesh>;
  37974. /**
  37975. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37976. */
  37977. get unTranslatedPointer(): Vector2;
  37978. /**
  37979. * Gets or sets the current on-screen X position of the pointer
  37980. */
  37981. get pointerX(): number;
  37982. set pointerX(value: number);
  37983. /**
  37984. * Gets or sets the current on-screen Y position of the pointer
  37985. */
  37986. get pointerY(): number;
  37987. set pointerY(value: number);
  37988. private _updatePointerPosition;
  37989. private _processPointerMove;
  37990. private _setRayOnPointerInfo;
  37991. private _checkPrePointerObservable;
  37992. /**
  37993. * Use this method to simulate a pointer move 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. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37999. /**
  38000. * Use this method to simulate a pointer down on a mesh
  38001. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38002. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38003. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38004. */
  38005. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38006. private _processPointerDown;
  38007. /** @hidden */
  38008. _isPointerSwiping(): boolean;
  38009. /**
  38010. * Use this method to simulate a pointer up on a mesh
  38011. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38012. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38013. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38014. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38015. */
  38016. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38017. private _processPointerUp;
  38018. /**
  38019. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38020. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38021. * @returns true if the pointer was captured
  38022. */
  38023. isPointerCaptured(pointerId?: number): boolean;
  38024. /**
  38025. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38026. * @param attachUp defines if you want to attach events to pointerup
  38027. * @param attachDown defines if you want to attach events to pointerdown
  38028. * @param attachMove defines if you want to attach events to pointermove
  38029. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38030. */
  38031. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38032. /**
  38033. * Detaches all event handlers
  38034. */
  38035. detachControl(): void;
  38036. /**
  38037. * Force the value of meshUnderPointer
  38038. * @param mesh defines the mesh to use
  38039. */
  38040. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38041. /**
  38042. * Gets the mesh under the pointer
  38043. * @returns a Mesh or null if no mesh is under the pointer
  38044. */
  38045. getPointerOverMesh(): Nullable<AbstractMesh>;
  38046. }
  38047. }
  38048. declare module BABYLON {
  38049. /**
  38050. * This class defines the direct association between an animation and a target
  38051. */
  38052. export class TargetedAnimation {
  38053. /**
  38054. * Animation to perform
  38055. */
  38056. animation: Animation;
  38057. /**
  38058. * Target to animate
  38059. */
  38060. target: any;
  38061. /**
  38062. * Returns the string "TargetedAnimation"
  38063. * @returns "TargetedAnimation"
  38064. */
  38065. getClassName(): string;
  38066. /**
  38067. * Serialize the object
  38068. * @returns the JSON object representing the current entity
  38069. */
  38070. serialize(): any;
  38071. }
  38072. /**
  38073. * Use this class to create coordinated animations on multiple targets
  38074. */
  38075. export class AnimationGroup implements IDisposable {
  38076. /** The name of the animation group */
  38077. name: string;
  38078. private _scene;
  38079. private _targetedAnimations;
  38080. private _animatables;
  38081. private _from;
  38082. private _to;
  38083. private _isStarted;
  38084. private _isPaused;
  38085. private _speedRatio;
  38086. private _loopAnimation;
  38087. private _isAdditive;
  38088. /**
  38089. * Gets or sets the unique id of the node
  38090. */
  38091. uniqueId: number;
  38092. /**
  38093. * This observable will notify when one animation have ended
  38094. */
  38095. onAnimationEndObservable: Observable<TargetedAnimation>;
  38096. /**
  38097. * Observer raised when one animation loops
  38098. */
  38099. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38100. /**
  38101. * Observer raised when all animations have looped
  38102. */
  38103. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38104. /**
  38105. * This observable will notify when all animations have ended.
  38106. */
  38107. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38108. /**
  38109. * This observable will notify when all animations have paused.
  38110. */
  38111. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38112. /**
  38113. * This observable will notify when all animations are playing.
  38114. */
  38115. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38116. /**
  38117. * Gets the first frame
  38118. */
  38119. get from(): number;
  38120. /**
  38121. * Gets the last frame
  38122. */
  38123. get to(): number;
  38124. /**
  38125. * Define if the animations are started
  38126. */
  38127. get isStarted(): boolean;
  38128. /**
  38129. * Gets a value indicating that the current group is playing
  38130. */
  38131. get isPlaying(): boolean;
  38132. /**
  38133. * Gets or sets the speed ratio to use for all animations
  38134. */
  38135. get speedRatio(): number;
  38136. /**
  38137. * Gets or sets the speed ratio to use for all animations
  38138. */
  38139. set speedRatio(value: number);
  38140. /**
  38141. * Gets or sets if all animations should loop or not
  38142. */
  38143. get loopAnimation(): boolean;
  38144. set loopAnimation(value: boolean);
  38145. /**
  38146. * Gets or sets if all animations should be evaluated additively
  38147. */
  38148. get isAdditive(): boolean;
  38149. set isAdditive(value: boolean);
  38150. /**
  38151. * Gets the targeted animations for this animation group
  38152. */
  38153. get targetedAnimations(): Array<TargetedAnimation>;
  38154. /**
  38155. * returning the list of animatables controlled by this animation group.
  38156. */
  38157. get animatables(): Array<Animatable>;
  38158. /**
  38159. * Gets the list of target animations
  38160. */
  38161. get children(): TargetedAnimation[];
  38162. /**
  38163. * Instantiates a new Animation Group.
  38164. * This helps managing several animations at once.
  38165. * @see http://doc.babylonjs.com/how_to/group
  38166. * @param name Defines the name of the group
  38167. * @param scene Defines the scene the group belongs to
  38168. */
  38169. constructor(
  38170. /** The name of the animation group */
  38171. name: string, scene?: Nullable<Scene>);
  38172. /**
  38173. * Add an animation (with its target) in the group
  38174. * @param animation defines the animation we want to add
  38175. * @param target defines the target of the animation
  38176. * @returns the TargetedAnimation object
  38177. */
  38178. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38179. /**
  38180. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38181. * It can add constant keys at begin or end
  38182. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38183. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38184. * @returns the animation group
  38185. */
  38186. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38187. private _animationLoopCount;
  38188. private _animationLoopFlags;
  38189. private _processLoop;
  38190. /**
  38191. * Start all animations on given targets
  38192. * @param loop defines if animations must loop
  38193. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38194. * @param from defines the from key (optional)
  38195. * @param to defines the to key (optional)
  38196. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38197. * @returns the current animation group
  38198. */
  38199. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38200. /**
  38201. * Pause all animations
  38202. * @returns the animation group
  38203. */
  38204. pause(): AnimationGroup;
  38205. /**
  38206. * Play all animations to initial state
  38207. * This function will start() the animations if they were not started or will restart() them if they were paused
  38208. * @param loop defines if animations must loop
  38209. * @returns the animation group
  38210. */
  38211. play(loop?: boolean): AnimationGroup;
  38212. /**
  38213. * Reset all animations to initial state
  38214. * @returns the animation group
  38215. */
  38216. reset(): AnimationGroup;
  38217. /**
  38218. * Restart animations from key 0
  38219. * @returns the animation group
  38220. */
  38221. restart(): AnimationGroup;
  38222. /**
  38223. * Stop all animations
  38224. * @returns the animation group
  38225. */
  38226. stop(): AnimationGroup;
  38227. /**
  38228. * Set animation weight for all animatables
  38229. * @param weight defines the weight to use
  38230. * @return the animationGroup
  38231. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38232. */
  38233. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38234. /**
  38235. * Synchronize and normalize all animatables with a source animatable
  38236. * @param root defines the root animatable to synchronize with
  38237. * @return the animationGroup
  38238. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38239. */
  38240. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38241. /**
  38242. * Goes to a specific frame in this animation group
  38243. * @param frame the frame number to go to
  38244. * @return the animationGroup
  38245. */
  38246. goToFrame(frame: number): AnimationGroup;
  38247. /**
  38248. * Dispose all associated resources
  38249. */
  38250. dispose(): void;
  38251. private _checkAnimationGroupEnded;
  38252. /**
  38253. * Clone the current animation group and returns a copy
  38254. * @param newName defines the name of the new group
  38255. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38256. * @returns the new aniamtion group
  38257. */
  38258. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38259. /**
  38260. * Serializes the animationGroup to an object
  38261. * @returns Serialized object
  38262. */
  38263. serialize(): any;
  38264. /**
  38265. * Returns a new AnimationGroup object parsed from the source provided.
  38266. * @param parsedAnimationGroup defines the source
  38267. * @param scene defines the scene that will receive the animationGroup
  38268. * @returns a new AnimationGroup
  38269. */
  38270. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38271. /**
  38272. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38273. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38274. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38275. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38276. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38277. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38278. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38279. */
  38280. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38281. /**
  38282. * Returns the string "AnimationGroup"
  38283. * @returns "AnimationGroup"
  38284. */
  38285. getClassName(): string;
  38286. /**
  38287. * Creates a detailled string about the object
  38288. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38289. * @returns a string representing the object
  38290. */
  38291. toString(fullDetails?: boolean): string;
  38292. }
  38293. }
  38294. declare module BABYLON {
  38295. /**
  38296. * Define an interface for all classes that will hold resources
  38297. */
  38298. export interface IDisposable {
  38299. /**
  38300. * Releases all held resources
  38301. */
  38302. dispose(): void;
  38303. }
  38304. /** Interface defining initialization parameters for Scene class */
  38305. export interface SceneOptions {
  38306. /**
  38307. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38308. * It will improve performance when the number of geometries becomes important.
  38309. */
  38310. useGeometryUniqueIdsMap?: boolean;
  38311. /**
  38312. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38313. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38314. */
  38315. useMaterialMeshMap?: boolean;
  38316. /**
  38317. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38318. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38319. */
  38320. useClonedMeshMap?: boolean;
  38321. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38322. virtual?: boolean;
  38323. }
  38324. /**
  38325. * Represents a scene to be rendered by the engine.
  38326. * @see http://doc.babylonjs.com/features/scene
  38327. */
  38328. export class Scene extends AbstractScene implements IAnimatable {
  38329. /** The fog is deactivated */
  38330. static readonly FOGMODE_NONE: number;
  38331. /** The fog density is following an exponential function */
  38332. static readonly FOGMODE_EXP: number;
  38333. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38334. static readonly FOGMODE_EXP2: number;
  38335. /** The fog density is following a linear function. */
  38336. static readonly FOGMODE_LINEAR: number;
  38337. /**
  38338. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38339. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38340. */
  38341. static MinDeltaTime: number;
  38342. /**
  38343. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38344. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38345. */
  38346. static MaxDeltaTime: number;
  38347. /**
  38348. * Factory used to create the default material.
  38349. * @param name The name of the material to create
  38350. * @param scene The scene to create the material for
  38351. * @returns The default material
  38352. */
  38353. static DefaultMaterialFactory(scene: Scene): Material;
  38354. /**
  38355. * Factory used to create the a collision coordinator.
  38356. * @returns The collision coordinator
  38357. */
  38358. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38359. /** @hidden */
  38360. _inputManager: InputManager;
  38361. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38362. cameraToUseForPointers: Nullable<Camera>;
  38363. /** @hidden */
  38364. readonly _isScene: boolean;
  38365. /** @hidden */
  38366. _blockEntityCollection: boolean;
  38367. /**
  38368. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38369. */
  38370. autoClear: boolean;
  38371. /**
  38372. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38373. */
  38374. autoClearDepthAndStencil: boolean;
  38375. /**
  38376. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38377. */
  38378. clearColor: Color4;
  38379. /**
  38380. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38381. */
  38382. ambientColor: Color3;
  38383. /**
  38384. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38385. * It should only be one of the following (if not the default embedded one):
  38386. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38387. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38388. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38389. * The material properties need to be setup according to the type of texture in use.
  38390. */
  38391. environmentBRDFTexture: BaseTexture;
  38392. /** @hidden */
  38393. protected _environmentTexture: Nullable<BaseTexture>;
  38394. /**
  38395. * Texture used in all pbr material as the reflection texture.
  38396. * As in the majority of the scene they are the same (exception for multi room and so on),
  38397. * this is easier to reference from here than from all the materials.
  38398. */
  38399. get environmentTexture(): Nullable<BaseTexture>;
  38400. /**
  38401. * Texture used in all pbr material as the reflection texture.
  38402. * As in the majority of the scene they are the same (exception for multi room and so on),
  38403. * this is easier to set here than in all the materials.
  38404. */
  38405. set environmentTexture(value: Nullable<BaseTexture>);
  38406. /** @hidden */
  38407. protected _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 reference from here than from all the materials.
  38413. */
  38414. get environmentIntensity(): number;
  38415. /**
  38416. * Intensity of the environment in all pbr material.
  38417. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38418. * As in the majority of the scene they are the same (exception for multi room and so on),
  38419. * this is easier to set here than in all the materials.
  38420. */
  38421. set environmentIntensity(value: number);
  38422. /** @hidden */
  38423. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38424. /**
  38425. * Default image processing configuration used either in the rendering
  38426. * Forward main pass or through the imageProcessingPostProcess if present.
  38427. * As in the majority of the scene they are the same (exception for multi camera),
  38428. * this is easier to reference from here than from all the materials and post process.
  38429. *
  38430. * No setter as we it is a shared configuration, you can set the values instead.
  38431. */
  38432. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38433. private _forceWireframe;
  38434. /**
  38435. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38436. */
  38437. set forceWireframe(value: boolean);
  38438. get forceWireframe(): boolean;
  38439. private _skipFrustumClipping;
  38440. /**
  38441. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38442. */
  38443. set skipFrustumClipping(value: boolean);
  38444. get skipFrustumClipping(): boolean;
  38445. private _forcePointsCloud;
  38446. /**
  38447. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38448. */
  38449. set forcePointsCloud(value: boolean);
  38450. get forcePointsCloud(): boolean;
  38451. /**
  38452. * Gets or sets the active clipplane 1
  38453. */
  38454. clipPlane: Nullable<Plane>;
  38455. /**
  38456. * Gets or sets the active clipplane 2
  38457. */
  38458. clipPlane2: Nullable<Plane>;
  38459. /**
  38460. * Gets or sets the active clipplane 3
  38461. */
  38462. clipPlane3: Nullable<Plane>;
  38463. /**
  38464. * Gets or sets the active clipplane 4
  38465. */
  38466. clipPlane4: Nullable<Plane>;
  38467. /**
  38468. * Gets or sets the active clipplane 5
  38469. */
  38470. clipPlane5: Nullable<Plane>;
  38471. /**
  38472. * Gets or sets the active clipplane 6
  38473. */
  38474. clipPlane6: Nullable<Plane>;
  38475. /**
  38476. * Gets or sets a boolean indicating if animations are enabled
  38477. */
  38478. animationsEnabled: boolean;
  38479. private _animationPropertiesOverride;
  38480. /**
  38481. * Gets or sets the animation properties override
  38482. */
  38483. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38484. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38485. /**
  38486. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38487. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38488. */
  38489. useConstantAnimationDeltaTime: boolean;
  38490. /**
  38491. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38492. * Please note that it requires to run a ray cast through the scene on every frame
  38493. */
  38494. constantlyUpdateMeshUnderPointer: boolean;
  38495. /**
  38496. * Defines the HTML cursor to use when hovering over interactive elements
  38497. */
  38498. hoverCursor: string;
  38499. /**
  38500. * Defines the HTML default cursor to use (empty by default)
  38501. */
  38502. defaultCursor: string;
  38503. /**
  38504. * Defines whether cursors are handled by the scene.
  38505. */
  38506. doNotHandleCursors: boolean;
  38507. /**
  38508. * This is used to call preventDefault() on pointer down
  38509. * in order to block unwanted artifacts like system double clicks
  38510. */
  38511. preventDefaultOnPointerDown: boolean;
  38512. /**
  38513. * This is used to call preventDefault() on pointer up
  38514. * in order to block unwanted artifacts like system double clicks
  38515. */
  38516. preventDefaultOnPointerUp: boolean;
  38517. /**
  38518. * Gets or sets user defined metadata
  38519. */
  38520. metadata: any;
  38521. /**
  38522. * For internal use only. Please do not use.
  38523. */
  38524. reservedDataStore: any;
  38525. /**
  38526. * Gets the name of the plugin used to load this scene (null by default)
  38527. */
  38528. loadingPluginName: string;
  38529. /**
  38530. * Use this array to add regular expressions used to disable offline support for specific urls
  38531. */
  38532. disableOfflineSupportExceptionRules: RegExp[];
  38533. /**
  38534. * An event triggered when the scene is disposed.
  38535. */
  38536. onDisposeObservable: Observable<Scene>;
  38537. private _onDisposeObserver;
  38538. /** Sets a function to be executed when this scene is disposed. */
  38539. set onDispose(callback: () => void);
  38540. /**
  38541. * An event triggered before rendering the scene (right after animations and physics)
  38542. */
  38543. onBeforeRenderObservable: Observable<Scene>;
  38544. private _onBeforeRenderObserver;
  38545. /** Sets a function to be executed before rendering this scene */
  38546. set beforeRender(callback: Nullable<() => void>);
  38547. /**
  38548. * An event triggered after rendering the scene
  38549. */
  38550. onAfterRenderObservable: Observable<Scene>;
  38551. /**
  38552. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38553. */
  38554. onAfterRenderCameraObservable: Observable<Camera>;
  38555. private _onAfterRenderObserver;
  38556. /** Sets a function to be executed after rendering this scene */
  38557. set afterRender(callback: Nullable<() => void>);
  38558. /**
  38559. * An event triggered before animating the scene
  38560. */
  38561. onBeforeAnimationsObservable: Observable<Scene>;
  38562. /**
  38563. * An event triggered after animations processing
  38564. */
  38565. onAfterAnimationsObservable: Observable<Scene>;
  38566. /**
  38567. * An event triggered before draw calls are ready to be sent
  38568. */
  38569. onBeforeDrawPhaseObservable: Observable<Scene>;
  38570. /**
  38571. * An event triggered after draw calls have been sent
  38572. */
  38573. onAfterDrawPhaseObservable: Observable<Scene>;
  38574. /**
  38575. * An event triggered when the scene is ready
  38576. */
  38577. onReadyObservable: Observable<Scene>;
  38578. /**
  38579. * An event triggered before rendering a camera
  38580. */
  38581. onBeforeCameraRenderObservable: Observable<Camera>;
  38582. private _onBeforeCameraRenderObserver;
  38583. /** Sets a function to be executed before rendering a camera*/
  38584. set beforeCameraRender(callback: () => void);
  38585. /**
  38586. * An event triggered after rendering a camera
  38587. */
  38588. onAfterCameraRenderObservable: Observable<Camera>;
  38589. private _onAfterCameraRenderObserver;
  38590. /** Sets a function to be executed after rendering a camera*/
  38591. set afterCameraRender(callback: () => void);
  38592. /**
  38593. * An event triggered when active meshes evaluation is about to start
  38594. */
  38595. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38596. /**
  38597. * An event triggered when active meshes evaluation is done
  38598. */
  38599. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38600. /**
  38601. * An event triggered when particles rendering is about to start
  38602. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38603. */
  38604. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38605. /**
  38606. * An event triggered when particles rendering is done
  38607. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38608. */
  38609. onAfterParticlesRenderingObservable: Observable<Scene>;
  38610. /**
  38611. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38612. */
  38613. onDataLoadedObservable: Observable<Scene>;
  38614. /**
  38615. * An event triggered when a camera is created
  38616. */
  38617. onNewCameraAddedObservable: Observable<Camera>;
  38618. /**
  38619. * An event triggered when a camera is removed
  38620. */
  38621. onCameraRemovedObservable: Observable<Camera>;
  38622. /**
  38623. * An event triggered when a light is created
  38624. */
  38625. onNewLightAddedObservable: Observable<Light>;
  38626. /**
  38627. * An event triggered when a light is removed
  38628. */
  38629. onLightRemovedObservable: Observable<Light>;
  38630. /**
  38631. * An event triggered when a geometry is created
  38632. */
  38633. onNewGeometryAddedObservable: Observable<Geometry>;
  38634. /**
  38635. * An event triggered when a geometry is removed
  38636. */
  38637. onGeometryRemovedObservable: Observable<Geometry>;
  38638. /**
  38639. * An event triggered when a transform node is created
  38640. */
  38641. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38642. /**
  38643. * An event triggered when a transform node is removed
  38644. */
  38645. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38646. /**
  38647. * An event triggered when a mesh is created
  38648. */
  38649. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38650. /**
  38651. * An event triggered when a mesh is removed
  38652. */
  38653. onMeshRemovedObservable: Observable<AbstractMesh>;
  38654. /**
  38655. * An event triggered when a skeleton is created
  38656. */
  38657. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38658. /**
  38659. * An event triggered when a skeleton is removed
  38660. */
  38661. onSkeletonRemovedObservable: Observable<Skeleton>;
  38662. /**
  38663. * An event triggered when a material is created
  38664. */
  38665. onNewMaterialAddedObservable: Observable<Material>;
  38666. /**
  38667. * An event triggered when a material is removed
  38668. */
  38669. onMaterialRemovedObservable: Observable<Material>;
  38670. /**
  38671. * An event triggered when a texture is created
  38672. */
  38673. onNewTextureAddedObservable: Observable<BaseTexture>;
  38674. /**
  38675. * An event triggered when a texture is removed
  38676. */
  38677. onTextureRemovedObservable: Observable<BaseTexture>;
  38678. /**
  38679. * An event triggered when render targets are about to be rendered
  38680. * Can happen multiple times per frame.
  38681. */
  38682. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38683. /**
  38684. * An event triggered when render targets were rendered.
  38685. * Can happen multiple times per frame.
  38686. */
  38687. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38688. /**
  38689. * An event triggered before calculating deterministic simulation step
  38690. */
  38691. onBeforeStepObservable: Observable<Scene>;
  38692. /**
  38693. * An event triggered after calculating deterministic simulation step
  38694. */
  38695. onAfterStepObservable: Observable<Scene>;
  38696. /**
  38697. * An event triggered when the activeCamera property is updated
  38698. */
  38699. onActiveCameraChanged: Observable<Scene>;
  38700. /**
  38701. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38702. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38703. * 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)
  38704. */
  38705. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38706. /**
  38707. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38708. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38709. * 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)
  38710. */
  38711. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38712. /**
  38713. * This Observable will when a mesh has been imported into the scene.
  38714. */
  38715. onMeshImportedObservable: Observable<AbstractMesh>;
  38716. /**
  38717. * This Observable will when an animation file has been imported into the scene.
  38718. */
  38719. onAnimationFileImportedObservable: Observable<Scene>;
  38720. /**
  38721. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38722. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38723. */
  38724. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38725. /** @hidden */
  38726. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38727. /**
  38728. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38729. */
  38730. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38731. /**
  38732. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38733. */
  38734. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38735. /**
  38736. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38737. */
  38738. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38739. /** Callback called when a pointer move is detected */
  38740. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38741. /** Callback called when a pointer down is detected */
  38742. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38743. /** Callback called when a pointer up is detected */
  38744. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38745. /** Callback called when a pointer pick is detected */
  38746. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38747. /**
  38748. * 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).
  38749. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38750. */
  38751. onPrePointerObservable: Observable<PointerInfoPre>;
  38752. /**
  38753. * Observable event triggered each time an input event is received from the rendering canvas
  38754. */
  38755. onPointerObservable: Observable<PointerInfo>;
  38756. /**
  38757. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38758. */
  38759. get unTranslatedPointer(): Vector2;
  38760. /**
  38761. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38762. */
  38763. static get DragMovementThreshold(): number;
  38764. static set DragMovementThreshold(value: number);
  38765. /**
  38766. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38767. */
  38768. static get LongPressDelay(): number;
  38769. static set LongPressDelay(value: number);
  38770. /**
  38771. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38772. */
  38773. static get DoubleClickDelay(): number;
  38774. static set DoubleClickDelay(value: number);
  38775. /** If you need to check double click without raising a single click at first click, enable this flag */
  38776. static get ExclusiveDoubleClickMode(): boolean;
  38777. static set ExclusiveDoubleClickMode(value: boolean);
  38778. /** @hidden */
  38779. _mirroredCameraPosition: Nullable<Vector3>;
  38780. /**
  38781. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38782. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38783. */
  38784. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38785. /**
  38786. * Observable event triggered each time an keyboard event is received from the hosting window
  38787. */
  38788. onKeyboardObservable: Observable<KeyboardInfo>;
  38789. private _useRightHandedSystem;
  38790. /**
  38791. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38792. */
  38793. set useRightHandedSystem(value: boolean);
  38794. get useRightHandedSystem(): boolean;
  38795. private _timeAccumulator;
  38796. private _currentStepId;
  38797. private _currentInternalStep;
  38798. /**
  38799. * Sets the step Id used by deterministic lock step
  38800. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38801. * @param newStepId defines the step Id
  38802. */
  38803. setStepId(newStepId: number): void;
  38804. /**
  38805. * Gets the step Id used by deterministic lock step
  38806. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38807. * @returns the step Id
  38808. */
  38809. getStepId(): number;
  38810. /**
  38811. * Gets the internal step used by deterministic lock step
  38812. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38813. * @returns the internal step
  38814. */
  38815. getInternalStep(): number;
  38816. private _fogEnabled;
  38817. /**
  38818. * Gets or sets a boolean indicating if fog is enabled on this scene
  38819. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38820. * (Default is true)
  38821. */
  38822. set fogEnabled(value: boolean);
  38823. get fogEnabled(): boolean;
  38824. private _fogMode;
  38825. /**
  38826. * Gets or sets the fog mode to use
  38827. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38828. * | mode | value |
  38829. * | --- | --- |
  38830. * | FOGMODE_NONE | 0 |
  38831. * | FOGMODE_EXP | 1 |
  38832. * | FOGMODE_EXP2 | 2 |
  38833. * | FOGMODE_LINEAR | 3 |
  38834. */
  38835. set fogMode(value: number);
  38836. get fogMode(): number;
  38837. /**
  38838. * Gets or sets the fog color to use
  38839. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38840. * (Default is Color3(0.2, 0.2, 0.3))
  38841. */
  38842. fogColor: Color3;
  38843. /**
  38844. * Gets or sets the fog density to use
  38845. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38846. * (Default is 0.1)
  38847. */
  38848. fogDensity: number;
  38849. /**
  38850. * Gets or sets the fog start distance to use
  38851. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38852. * (Default is 0)
  38853. */
  38854. fogStart: number;
  38855. /**
  38856. * Gets or sets the fog end distance to use
  38857. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38858. * (Default is 1000)
  38859. */
  38860. fogEnd: number;
  38861. private _shadowsEnabled;
  38862. /**
  38863. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38864. */
  38865. set shadowsEnabled(value: boolean);
  38866. get shadowsEnabled(): boolean;
  38867. private _lightsEnabled;
  38868. /**
  38869. * Gets or sets a boolean indicating if lights are enabled on this scene
  38870. */
  38871. set lightsEnabled(value: boolean);
  38872. get lightsEnabled(): boolean;
  38873. /** All of the active cameras added to this scene. */
  38874. activeCameras: Camera[];
  38875. /** @hidden */
  38876. _activeCamera: Nullable<Camera>;
  38877. /** Gets or sets the current active camera */
  38878. get activeCamera(): Nullable<Camera>;
  38879. set activeCamera(value: Nullable<Camera>);
  38880. private _defaultMaterial;
  38881. /** The default material used on meshes when no material is affected */
  38882. get defaultMaterial(): Material;
  38883. /** The default material used on meshes when no material is affected */
  38884. set defaultMaterial(value: Material);
  38885. private _texturesEnabled;
  38886. /**
  38887. * Gets or sets a boolean indicating if textures are enabled on this scene
  38888. */
  38889. set texturesEnabled(value: boolean);
  38890. get texturesEnabled(): boolean;
  38891. /**
  38892. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38893. */
  38894. physicsEnabled: boolean;
  38895. /**
  38896. * Gets or sets a boolean indicating if particles are enabled on this scene
  38897. */
  38898. particlesEnabled: boolean;
  38899. /**
  38900. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38901. */
  38902. spritesEnabled: boolean;
  38903. private _skeletonsEnabled;
  38904. /**
  38905. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38906. */
  38907. set skeletonsEnabled(value: boolean);
  38908. get skeletonsEnabled(): boolean;
  38909. /**
  38910. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38911. */
  38912. lensFlaresEnabled: boolean;
  38913. /**
  38914. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38915. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38916. */
  38917. collisionsEnabled: boolean;
  38918. private _collisionCoordinator;
  38919. /** @hidden */
  38920. get collisionCoordinator(): ICollisionCoordinator;
  38921. /**
  38922. * Defines the gravity applied to this scene (used only for collisions)
  38923. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38924. */
  38925. gravity: Vector3;
  38926. /**
  38927. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38928. */
  38929. postProcessesEnabled: boolean;
  38930. /**
  38931. * The list of postprocesses added to the scene
  38932. */
  38933. postProcesses: PostProcess[];
  38934. /**
  38935. * Gets the current postprocess manager
  38936. */
  38937. postProcessManager: PostProcessManager;
  38938. /**
  38939. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38940. */
  38941. renderTargetsEnabled: boolean;
  38942. /**
  38943. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38944. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38945. */
  38946. dumpNextRenderTargets: boolean;
  38947. /**
  38948. * The list of user defined render targets added to the scene
  38949. */
  38950. customRenderTargets: RenderTargetTexture[];
  38951. /**
  38952. * Defines if texture loading must be delayed
  38953. * If true, textures will only be loaded when they need to be rendered
  38954. */
  38955. useDelayedTextureLoading: boolean;
  38956. /**
  38957. * Gets the list of meshes imported to the scene through SceneLoader
  38958. */
  38959. importedMeshesFiles: String[];
  38960. /**
  38961. * Gets or sets a boolean indicating if probes are enabled on this scene
  38962. */
  38963. probesEnabled: boolean;
  38964. /**
  38965. * Gets or sets the current offline provider to use to store scene data
  38966. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38967. */
  38968. offlineProvider: IOfflineProvider;
  38969. /**
  38970. * Gets or sets the action manager associated with the scene
  38971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38972. */
  38973. actionManager: AbstractActionManager;
  38974. private _meshesForIntersections;
  38975. /**
  38976. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38977. */
  38978. proceduralTexturesEnabled: boolean;
  38979. private _engine;
  38980. private _totalVertices;
  38981. /** @hidden */
  38982. _activeIndices: PerfCounter;
  38983. /** @hidden */
  38984. _activeParticles: PerfCounter;
  38985. /** @hidden */
  38986. _activeBones: PerfCounter;
  38987. private _animationRatio;
  38988. /** @hidden */
  38989. _animationTimeLast: number;
  38990. /** @hidden */
  38991. _animationTime: number;
  38992. /**
  38993. * Gets or sets a general scale for animation speed
  38994. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38995. */
  38996. animationTimeScale: number;
  38997. /** @hidden */
  38998. _cachedMaterial: Nullable<Material>;
  38999. /** @hidden */
  39000. _cachedEffect: Nullable<Effect>;
  39001. /** @hidden */
  39002. _cachedVisibility: Nullable<number>;
  39003. private _renderId;
  39004. private _frameId;
  39005. private _executeWhenReadyTimeoutId;
  39006. private _intermediateRendering;
  39007. private _viewUpdateFlag;
  39008. private _projectionUpdateFlag;
  39009. /** @hidden */
  39010. _toBeDisposed: Nullable<IDisposable>[];
  39011. private _activeRequests;
  39012. /** @hidden */
  39013. _pendingData: any[];
  39014. private _isDisposed;
  39015. /**
  39016. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39017. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39018. */
  39019. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39020. private _activeMeshes;
  39021. private _processedMaterials;
  39022. private _renderTargets;
  39023. /** @hidden */
  39024. _activeParticleSystems: SmartArray<IParticleSystem>;
  39025. private _activeSkeletons;
  39026. private _softwareSkinnedMeshes;
  39027. private _renderingManager;
  39028. /** @hidden */
  39029. _activeAnimatables: Animatable[];
  39030. private _transformMatrix;
  39031. private _sceneUbo;
  39032. /** @hidden */
  39033. _viewMatrix: Matrix;
  39034. private _projectionMatrix;
  39035. /** @hidden */
  39036. _forcedViewPosition: Nullable<Vector3>;
  39037. /** @hidden */
  39038. _frustumPlanes: Plane[];
  39039. /**
  39040. * Gets the list of frustum planes (built from the active camera)
  39041. */
  39042. get frustumPlanes(): Plane[];
  39043. /**
  39044. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39045. * This is useful if there are more lights that the maximum simulteanous authorized
  39046. */
  39047. requireLightSorting: boolean;
  39048. /** @hidden */
  39049. readonly useMaterialMeshMap: boolean;
  39050. /** @hidden */
  39051. readonly useClonedMeshMap: boolean;
  39052. private _externalData;
  39053. private _uid;
  39054. /**
  39055. * @hidden
  39056. * Backing store of defined scene components.
  39057. */
  39058. _components: ISceneComponent[];
  39059. /**
  39060. * @hidden
  39061. * Backing store of defined scene components.
  39062. */
  39063. _serializableComponents: ISceneSerializableComponent[];
  39064. /**
  39065. * List of components to register on the next registration step.
  39066. */
  39067. private _transientComponents;
  39068. /**
  39069. * Registers the transient components if needed.
  39070. */
  39071. private _registerTransientComponents;
  39072. /**
  39073. * @hidden
  39074. * Add a component to the scene.
  39075. * Note that the ccomponent could be registered on th next frame if this is called after
  39076. * the register component stage.
  39077. * @param component Defines the component to add to the scene
  39078. */
  39079. _addComponent(component: ISceneComponent): void;
  39080. /**
  39081. * @hidden
  39082. * Gets a component from the scene.
  39083. * @param name defines the name of the component to retrieve
  39084. * @returns the component or null if not present
  39085. */
  39086. _getComponent(name: string): Nullable<ISceneComponent>;
  39087. /**
  39088. * @hidden
  39089. * Defines the actions happening before camera updates.
  39090. */
  39091. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39092. /**
  39093. * @hidden
  39094. * Defines the actions happening before clear the canvas.
  39095. */
  39096. _beforeClearStage: Stage<SimpleStageAction>;
  39097. /**
  39098. * @hidden
  39099. * Defines the actions when collecting render targets for the frame.
  39100. */
  39101. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39102. /**
  39103. * @hidden
  39104. * Defines the actions happening for one camera in the frame.
  39105. */
  39106. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39107. /**
  39108. * @hidden
  39109. * Defines the actions happening during the per mesh ready checks.
  39110. */
  39111. _isReadyForMeshStage: Stage<MeshStageAction>;
  39112. /**
  39113. * @hidden
  39114. * Defines the actions happening before evaluate active mesh checks.
  39115. */
  39116. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39117. /**
  39118. * @hidden
  39119. * Defines the actions happening during the evaluate sub mesh checks.
  39120. */
  39121. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39122. /**
  39123. * @hidden
  39124. * Defines the actions happening during the active mesh stage.
  39125. */
  39126. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39127. /**
  39128. * @hidden
  39129. * Defines the actions happening during the per camera render target step.
  39130. */
  39131. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39132. /**
  39133. * @hidden
  39134. * Defines the actions happening just before the active camera is drawing.
  39135. */
  39136. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39137. /**
  39138. * @hidden
  39139. * Defines the actions happening just before a render target is drawing.
  39140. */
  39141. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39142. /**
  39143. * @hidden
  39144. * Defines the actions happening just before a rendering group is drawing.
  39145. */
  39146. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39147. /**
  39148. * @hidden
  39149. * Defines the actions happening just before a mesh is drawing.
  39150. */
  39151. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39152. /**
  39153. * @hidden
  39154. * Defines the actions happening just after a mesh has been drawn.
  39155. */
  39156. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39157. /**
  39158. * @hidden
  39159. * Defines the actions happening just after a rendering group has been drawn.
  39160. */
  39161. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39162. /**
  39163. * @hidden
  39164. * Defines the actions happening just after the active camera has been drawn.
  39165. */
  39166. _afterCameraDrawStage: Stage<CameraStageAction>;
  39167. /**
  39168. * @hidden
  39169. * Defines the actions happening just after a render target has been drawn.
  39170. */
  39171. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39172. /**
  39173. * @hidden
  39174. * Defines the actions happening just after rendering all cameras and computing intersections.
  39175. */
  39176. _afterRenderStage: Stage<SimpleStageAction>;
  39177. /**
  39178. * @hidden
  39179. * Defines the actions happening when a pointer move event happens.
  39180. */
  39181. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39182. /**
  39183. * @hidden
  39184. * Defines the actions happening when a pointer down event happens.
  39185. */
  39186. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39187. /**
  39188. * @hidden
  39189. * Defines the actions happening when a pointer up event happens.
  39190. */
  39191. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39192. /**
  39193. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39194. */
  39195. private geometriesByUniqueId;
  39196. /**
  39197. * Creates a new Scene
  39198. * @param engine defines the engine to use to render this scene
  39199. * @param options defines the scene options
  39200. */
  39201. constructor(engine: Engine, options?: SceneOptions);
  39202. /**
  39203. * Gets a string idenfifying the name of the class
  39204. * @returns "Scene" string
  39205. */
  39206. getClassName(): string;
  39207. private _defaultMeshCandidates;
  39208. /**
  39209. * @hidden
  39210. */
  39211. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39212. private _defaultSubMeshCandidates;
  39213. /**
  39214. * @hidden
  39215. */
  39216. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39217. /**
  39218. * Sets the default candidate providers for the scene.
  39219. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39220. * and getCollidingSubMeshCandidates to their default function
  39221. */
  39222. setDefaultCandidateProviders(): void;
  39223. /**
  39224. * Gets the mesh that is currently under the pointer
  39225. */
  39226. get meshUnderPointer(): Nullable<AbstractMesh>;
  39227. /**
  39228. * Gets or sets the current on-screen X position of the pointer
  39229. */
  39230. get pointerX(): number;
  39231. set pointerX(value: number);
  39232. /**
  39233. * Gets or sets the current on-screen Y position of the pointer
  39234. */
  39235. get pointerY(): number;
  39236. set pointerY(value: number);
  39237. /**
  39238. * Gets the cached material (ie. the latest rendered one)
  39239. * @returns the cached material
  39240. */
  39241. getCachedMaterial(): Nullable<Material>;
  39242. /**
  39243. * Gets the cached effect (ie. the latest rendered one)
  39244. * @returns the cached effect
  39245. */
  39246. getCachedEffect(): Nullable<Effect>;
  39247. /**
  39248. * Gets the cached visibility state (ie. the latest rendered one)
  39249. * @returns the cached visibility state
  39250. */
  39251. getCachedVisibility(): Nullable<number>;
  39252. /**
  39253. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39254. * @param material defines the current material
  39255. * @param effect defines the current effect
  39256. * @param visibility defines the current visibility state
  39257. * @returns true if one parameter is not cached
  39258. */
  39259. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39260. /**
  39261. * Gets the engine associated with the scene
  39262. * @returns an Engine
  39263. */
  39264. getEngine(): Engine;
  39265. /**
  39266. * Gets the total number of vertices rendered per frame
  39267. * @returns the total number of vertices rendered per frame
  39268. */
  39269. getTotalVertices(): number;
  39270. /**
  39271. * Gets the performance counter for total vertices
  39272. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39273. */
  39274. get totalVerticesPerfCounter(): PerfCounter;
  39275. /**
  39276. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39277. * @returns the total number of active indices rendered per frame
  39278. */
  39279. getActiveIndices(): number;
  39280. /**
  39281. * Gets the performance counter for active indices
  39282. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39283. */
  39284. get totalActiveIndicesPerfCounter(): PerfCounter;
  39285. /**
  39286. * Gets the total number of active particles rendered per frame
  39287. * @returns the total number of active particles rendered per frame
  39288. */
  39289. getActiveParticles(): number;
  39290. /**
  39291. * Gets the performance counter for active particles
  39292. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39293. */
  39294. get activeParticlesPerfCounter(): PerfCounter;
  39295. /**
  39296. * Gets the total number of active bones rendered per frame
  39297. * @returns the total number of active bones rendered per frame
  39298. */
  39299. getActiveBones(): number;
  39300. /**
  39301. * Gets the performance counter for active bones
  39302. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39303. */
  39304. get activeBonesPerfCounter(): PerfCounter;
  39305. /**
  39306. * Gets the array of active meshes
  39307. * @returns an array of AbstractMesh
  39308. */
  39309. getActiveMeshes(): SmartArray<AbstractMesh>;
  39310. /**
  39311. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39312. * @returns a number
  39313. */
  39314. getAnimationRatio(): number;
  39315. /**
  39316. * Gets an unique Id for the current render phase
  39317. * @returns a number
  39318. */
  39319. getRenderId(): number;
  39320. /**
  39321. * Gets an unique Id for the current frame
  39322. * @returns a number
  39323. */
  39324. getFrameId(): number;
  39325. /** Call this function if you want to manually increment the render Id*/
  39326. incrementRenderId(): void;
  39327. private _createUbo;
  39328. /**
  39329. * Use this method to simulate a pointer move on a mesh
  39330. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39331. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39332. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39333. * @returns the current scene
  39334. */
  39335. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39336. /**
  39337. * Use this method to simulate a pointer down on a mesh
  39338. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39339. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39340. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39341. * @returns the current scene
  39342. */
  39343. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39344. /**
  39345. * Use this method to simulate a pointer up on a mesh
  39346. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39347. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39348. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39349. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39350. * @returns the current scene
  39351. */
  39352. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39353. /**
  39354. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39355. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39356. * @returns true if the pointer was captured
  39357. */
  39358. isPointerCaptured(pointerId?: number): boolean;
  39359. /**
  39360. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39361. * @param attachUp defines if you want to attach events to pointerup
  39362. * @param attachDown defines if you want to attach events to pointerdown
  39363. * @param attachMove defines if you want to attach events to pointermove
  39364. */
  39365. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39366. /** Detaches all event handlers*/
  39367. detachControl(): void;
  39368. /**
  39369. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39370. * Delay loaded resources are not taking in account
  39371. * @return true if all required resources are ready
  39372. */
  39373. isReady(): boolean;
  39374. /** Resets all cached information relative to material (including effect and visibility) */
  39375. resetCachedMaterial(): void;
  39376. /**
  39377. * Registers a function to be called before every frame render
  39378. * @param func defines the function to register
  39379. */
  39380. registerBeforeRender(func: () => void): void;
  39381. /**
  39382. * Unregisters a function called before every frame render
  39383. * @param func defines the function to unregister
  39384. */
  39385. unregisterBeforeRender(func: () => void): void;
  39386. /**
  39387. * Registers a function to be called after every frame render
  39388. * @param func defines the function to register
  39389. */
  39390. registerAfterRender(func: () => void): void;
  39391. /**
  39392. * Unregisters a function called after every frame render
  39393. * @param func defines the function to unregister
  39394. */
  39395. unregisterAfterRender(func: () => void): void;
  39396. private _executeOnceBeforeRender;
  39397. /**
  39398. * The provided function will run before render once and will be disposed afterwards.
  39399. * A timeout delay can be provided so that the function will be executed in N ms.
  39400. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39401. * @param func The function to be executed.
  39402. * @param timeout optional delay in ms
  39403. */
  39404. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39405. /** @hidden */
  39406. _addPendingData(data: any): void;
  39407. /** @hidden */
  39408. _removePendingData(data: any): void;
  39409. /**
  39410. * Returns the number of items waiting to be loaded
  39411. * @returns the number of items waiting to be loaded
  39412. */
  39413. getWaitingItemsCount(): number;
  39414. /**
  39415. * Returns a boolean indicating if the scene is still loading data
  39416. */
  39417. get isLoading(): boolean;
  39418. /**
  39419. * Registers a function to be executed when the scene is ready
  39420. * @param {Function} func - the function to be executed
  39421. */
  39422. executeWhenReady(func: () => void): void;
  39423. /**
  39424. * Returns a promise that resolves when the scene is ready
  39425. * @returns A promise that resolves when the scene is ready
  39426. */
  39427. whenReadyAsync(): Promise<void>;
  39428. /** @hidden */
  39429. _checkIsReady(): void;
  39430. /**
  39431. * Gets all animatable attached to the scene
  39432. */
  39433. get animatables(): Animatable[];
  39434. /**
  39435. * Resets the last animation time frame.
  39436. * Useful to override when animations start running when loading a scene for the first time.
  39437. */
  39438. resetLastAnimationTimeFrame(): void;
  39439. /**
  39440. * Gets the current view matrix
  39441. * @returns a Matrix
  39442. */
  39443. getViewMatrix(): Matrix;
  39444. /**
  39445. * Gets the current projection matrix
  39446. * @returns a Matrix
  39447. */
  39448. getProjectionMatrix(): Matrix;
  39449. /**
  39450. * Gets the current transform matrix
  39451. * @returns a Matrix made of View * Projection
  39452. */
  39453. getTransformMatrix(): Matrix;
  39454. /**
  39455. * Sets the current transform matrix
  39456. * @param viewL defines the View matrix to use
  39457. * @param projectionL defines the Projection matrix to use
  39458. * @param viewR defines the right View matrix to use (if provided)
  39459. * @param projectionR defines the right Projection matrix to use (if provided)
  39460. */
  39461. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39462. /**
  39463. * Gets the uniform buffer used to store scene data
  39464. * @returns a UniformBuffer
  39465. */
  39466. getSceneUniformBuffer(): UniformBuffer;
  39467. /**
  39468. * Gets an unique (relatively to the current scene) Id
  39469. * @returns an unique number for the scene
  39470. */
  39471. getUniqueId(): number;
  39472. /**
  39473. * Add a mesh to the list of scene's meshes
  39474. * @param newMesh defines the mesh to add
  39475. * @param recursive if all child meshes should also be added to the scene
  39476. */
  39477. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39478. /**
  39479. * Remove a mesh for the list of scene's meshes
  39480. * @param toRemove defines the mesh to remove
  39481. * @param recursive if all child meshes should also be removed from the scene
  39482. * @returns the index where the mesh was in the mesh list
  39483. */
  39484. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39485. /**
  39486. * Add a transform node to the list of scene's transform nodes
  39487. * @param newTransformNode defines the transform node to add
  39488. */
  39489. addTransformNode(newTransformNode: TransformNode): void;
  39490. /**
  39491. * Remove a transform node for the list of scene's transform nodes
  39492. * @param toRemove defines the transform node to remove
  39493. * @returns the index where the transform node was in the transform node list
  39494. */
  39495. removeTransformNode(toRemove: TransformNode): number;
  39496. /**
  39497. * Remove a skeleton for the list of scene's skeletons
  39498. * @param toRemove defines the skeleton to remove
  39499. * @returns the index where the skeleton was in the skeleton list
  39500. */
  39501. removeSkeleton(toRemove: Skeleton): number;
  39502. /**
  39503. * Remove a morph target for the list of scene's morph targets
  39504. * @param toRemove defines the morph target to remove
  39505. * @returns the index where the morph target was in the morph target list
  39506. */
  39507. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39508. /**
  39509. * Remove a light for the list of scene's lights
  39510. * @param toRemove defines the light to remove
  39511. * @returns the index where the light was in the light list
  39512. */
  39513. removeLight(toRemove: Light): number;
  39514. /**
  39515. * Remove a camera for the list of scene's cameras
  39516. * @param toRemove defines the camera to remove
  39517. * @returns the index where the camera was in the camera list
  39518. */
  39519. removeCamera(toRemove: Camera): number;
  39520. /**
  39521. * Remove a particle system for the list of scene's particle systems
  39522. * @param toRemove defines the particle system to remove
  39523. * @returns the index where the particle system was in the particle system list
  39524. */
  39525. removeParticleSystem(toRemove: IParticleSystem): number;
  39526. /**
  39527. * Remove a animation for the list of scene's animations
  39528. * @param toRemove defines the animation to remove
  39529. * @returns the index where the animation was in the animation list
  39530. */
  39531. removeAnimation(toRemove: Animation): number;
  39532. /**
  39533. * Will stop the animation of the given target
  39534. * @param target - the target
  39535. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39536. * @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)
  39537. */
  39538. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39539. /**
  39540. * Removes the given animation group from this scene.
  39541. * @param toRemove The animation group to remove
  39542. * @returns The index of the removed animation group
  39543. */
  39544. removeAnimationGroup(toRemove: AnimationGroup): number;
  39545. /**
  39546. * Removes the given multi-material from this scene.
  39547. * @param toRemove The multi-material to remove
  39548. * @returns The index of the removed multi-material
  39549. */
  39550. removeMultiMaterial(toRemove: MultiMaterial): number;
  39551. /**
  39552. * Removes the given material from this scene.
  39553. * @param toRemove The material to remove
  39554. * @returns The index of the removed material
  39555. */
  39556. removeMaterial(toRemove: Material): number;
  39557. /**
  39558. * Removes the given action manager from this scene.
  39559. * @param toRemove The action manager to remove
  39560. * @returns The index of the removed action manager
  39561. */
  39562. removeActionManager(toRemove: AbstractActionManager): number;
  39563. /**
  39564. * Removes the given texture from this scene.
  39565. * @param toRemove The texture to remove
  39566. * @returns The index of the removed texture
  39567. */
  39568. removeTexture(toRemove: BaseTexture): number;
  39569. /**
  39570. * Adds the given light to this scene
  39571. * @param newLight The light to add
  39572. */
  39573. addLight(newLight: Light): void;
  39574. /**
  39575. * Sorts the list list based on light priorities
  39576. */
  39577. sortLightsByPriority(): void;
  39578. /**
  39579. * Adds the given camera to this scene
  39580. * @param newCamera The camera to add
  39581. */
  39582. addCamera(newCamera: Camera): void;
  39583. /**
  39584. * Adds the given skeleton to this scene
  39585. * @param newSkeleton The skeleton to add
  39586. */
  39587. addSkeleton(newSkeleton: Skeleton): void;
  39588. /**
  39589. * Adds the given particle system to this scene
  39590. * @param newParticleSystem The particle system to add
  39591. */
  39592. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39593. /**
  39594. * Adds the given animation to this scene
  39595. * @param newAnimation The animation to add
  39596. */
  39597. addAnimation(newAnimation: Animation): void;
  39598. /**
  39599. * Adds the given animation group to this scene.
  39600. * @param newAnimationGroup The animation group to add
  39601. */
  39602. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39603. /**
  39604. * Adds the given multi-material to this scene
  39605. * @param newMultiMaterial The multi-material to add
  39606. */
  39607. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39608. /**
  39609. * Adds the given material to this scene
  39610. * @param newMaterial The material to add
  39611. */
  39612. addMaterial(newMaterial: Material): void;
  39613. /**
  39614. * Adds the given morph target to this scene
  39615. * @param newMorphTargetManager The morph target to add
  39616. */
  39617. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39618. /**
  39619. * Adds the given geometry to this scene
  39620. * @param newGeometry The geometry to add
  39621. */
  39622. addGeometry(newGeometry: Geometry): void;
  39623. /**
  39624. * Adds the given action manager to this scene
  39625. * @param newActionManager The action manager to add
  39626. */
  39627. addActionManager(newActionManager: AbstractActionManager): void;
  39628. /**
  39629. * Adds the given texture to this scene.
  39630. * @param newTexture The texture to add
  39631. */
  39632. addTexture(newTexture: BaseTexture): void;
  39633. /**
  39634. * Switch active camera
  39635. * @param newCamera defines the new active camera
  39636. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39637. */
  39638. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39639. /**
  39640. * sets the active camera of the scene using its ID
  39641. * @param id defines the camera's ID
  39642. * @return the new active camera or null if none found.
  39643. */
  39644. setActiveCameraByID(id: string): Nullable<Camera>;
  39645. /**
  39646. * sets the active camera of the scene using its name
  39647. * @param name defines the camera's name
  39648. * @returns the new active camera or null if none found.
  39649. */
  39650. setActiveCameraByName(name: string): Nullable<Camera>;
  39651. /**
  39652. * get an animation group using its name
  39653. * @param name defines the material's name
  39654. * @return the animation group or null if none found.
  39655. */
  39656. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39657. /**
  39658. * Get a material using its unique id
  39659. * @param uniqueId defines the material's unique id
  39660. * @return the material or null if none found.
  39661. */
  39662. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39663. /**
  39664. * get a material using its id
  39665. * @param id defines the material's ID
  39666. * @return the material or null if none found.
  39667. */
  39668. getMaterialByID(id: string): Nullable<Material>;
  39669. /**
  39670. * Gets a the last added material using a given id
  39671. * @param id defines the material's ID
  39672. * @return the last material with the given id or null if none found.
  39673. */
  39674. getLastMaterialByID(id: string): Nullable<Material>;
  39675. /**
  39676. * Gets a material using its name
  39677. * @param name defines the material's name
  39678. * @return the material or null if none found.
  39679. */
  39680. getMaterialByName(name: string): Nullable<Material>;
  39681. /**
  39682. * Get a texture using its unique id
  39683. * @param uniqueId defines the texture's unique id
  39684. * @return the texture or null if none found.
  39685. */
  39686. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39687. /**
  39688. * Gets a camera using its id
  39689. * @param id defines the id to look for
  39690. * @returns the camera or null if not found
  39691. */
  39692. getCameraByID(id: string): Nullable<Camera>;
  39693. /**
  39694. * Gets a camera using its unique id
  39695. * @param uniqueId defines the unique id to look for
  39696. * @returns the camera or null if not found
  39697. */
  39698. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39699. /**
  39700. * Gets a camera using its name
  39701. * @param name defines the camera's name
  39702. * @return the camera or null if none found.
  39703. */
  39704. getCameraByName(name: string): Nullable<Camera>;
  39705. /**
  39706. * Gets a bone using its id
  39707. * @param id defines the bone's id
  39708. * @return the bone or null if not found
  39709. */
  39710. getBoneByID(id: string): Nullable<Bone>;
  39711. /**
  39712. * Gets a bone using its id
  39713. * @param name defines the bone's name
  39714. * @return the bone or null if not found
  39715. */
  39716. getBoneByName(name: string): Nullable<Bone>;
  39717. /**
  39718. * Gets a light node using its name
  39719. * @param name defines the the light's name
  39720. * @return the light or null if none found.
  39721. */
  39722. getLightByName(name: string): Nullable<Light>;
  39723. /**
  39724. * Gets a light node using its id
  39725. * @param id defines the light's id
  39726. * @return the light or null if none found.
  39727. */
  39728. getLightByID(id: string): Nullable<Light>;
  39729. /**
  39730. * Gets a light node using its scene-generated unique ID
  39731. * @param uniqueId defines the light's unique id
  39732. * @return the light or null if none found.
  39733. */
  39734. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39735. /**
  39736. * Gets a particle system by id
  39737. * @param id defines the particle system id
  39738. * @return the corresponding system or null if none found
  39739. */
  39740. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39741. /**
  39742. * Gets a geometry using its ID
  39743. * @param id defines the geometry's id
  39744. * @return the geometry or null if none found.
  39745. */
  39746. getGeometryByID(id: string): Nullable<Geometry>;
  39747. private _getGeometryByUniqueID;
  39748. /**
  39749. * Add a new geometry to this scene
  39750. * @param geometry defines the geometry to be added to the scene.
  39751. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39752. * @return a boolean defining if the geometry was added or not
  39753. */
  39754. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39755. /**
  39756. * Removes an existing geometry
  39757. * @param geometry defines the geometry to be removed from the scene
  39758. * @return a boolean defining if the geometry was removed or not
  39759. */
  39760. removeGeometry(geometry: Geometry): boolean;
  39761. /**
  39762. * Gets the list of geometries attached to the scene
  39763. * @returns an array of Geometry
  39764. */
  39765. getGeometries(): Geometry[];
  39766. /**
  39767. * Gets the first added mesh found of a given ID
  39768. * @param id defines the id to search for
  39769. * @return the mesh found or null if not found at all
  39770. */
  39771. getMeshByID(id: string): Nullable<AbstractMesh>;
  39772. /**
  39773. * Gets a list of meshes using their id
  39774. * @param id defines the id to search for
  39775. * @returns a list of meshes
  39776. */
  39777. getMeshesByID(id: string): Array<AbstractMesh>;
  39778. /**
  39779. * Gets the first added transform node found of a given ID
  39780. * @param id defines the id to search for
  39781. * @return the found transform node or null if not found at all.
  39782. */
  39783. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39784. /**
  39785. * Gets a transform node with its auto-generated unique id
  39786. * @param uniqueId efines the unique id to search for
  39787. * @return the found transform node or null if not found at all.
  39788. */
  39789. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39790. /**
  39791. * Gets a list of transform nodes using their id
  39792. * @param id defines the id to search for
  39793. * @returns a list of transform nodes
  39794. */
  39795. getTransformNodesByID(id: string): Array<TransformNode>;
  39796. /**
  39797. * Gets a mesh with its auto-generated unique id
  39798. * @param uniqueId defines the unique id to search for
  39799. * @return the found mesh or null if not found at all.
  39800. */
  39801. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39802. /**
  39803. * Gets a the last added mesh using a given id
  39804. * @param id defines the id to search for
  39805. * @return the found mesh or null if not found at all.
  39806. */
  39807. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39808. /**
  39809. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39810. * @param id defines the id to search for
  39811. * @return the found node or null if not found at all
  39812. */
  39813. getLastEntryByID(id: string): Nullable<Node>;
  39814. /**
  39815. * Gets a node (Mesh, Camera, Light) using a given id
  39816. * @param id defines the id to search for
  39817. * @return the found node or null if not found at all
  39818. */
  39819. getNodeByID(id: string): Nullable<Node>;
  39820. /**
  39821. * Gets a node (Mesh, Camera, Light) using a given name
  39822. * @param name defines the name to search for
  39823. * @return the found node or null if not found at all.
  39824. */
  39825. getNodeByName(name: string): Nullable<Node>;
  39826. /**
  39827. * Gets a mesh using a given name
  39828. * @param name defines the name to search for
  39829. * @return the found mesh or null if not found at all.
  39830. */
  39831. getMeshByName(name: string): Nullable<AbstractMesh>;
  39832. /**
  39833. * Gets a transform node using a given name
  39834. * @param name defines the name to search for
  39835. * @return the found transform node or null if not found at all.
  39836. */
  39837. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39838. /**
  39839. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39840. * @param id defines the id to search for
  39841. * @return the found skeleton or null if not found at all.
  39842. */
  39843. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39844. /**
  39845. * Gets a skeleton using a given auto generated unique id
  39846. * @param uniqueId defines the unique id to search for
  39847. * @return the found skeleton or null if not found at all.
  39848. */
  39849. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39850. /**
  39851. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39852. * @param id defines the id to search for
  39853. * @return the found skeleton or null if not found at all.
  39854. */
  39855. getSkeletonById(id: string): Nullable<Skeleton>;
  39856. /**
  39857. * Gets a skeleton using a given name
  39858. * @param name defines the name to search for
  39859. * @return the found skeleton or null if not found at all.
  39860. */
  39861. getSkeletonByName(name: string): Nullable<Skeleton>;
  39862. /**
  39863. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39864. * @param id defines the id to search for
  39865. * @return the found morph target manager or null if not found at all.
  39866. */
  39867. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39868. /**
  39869. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39870. * @param id defines the id to search for
  39871. * @return the found morph target or null if not found at all.
  39872. */
  39873. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39874. /**
  39875. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39876. * @param name defines the name to search for
  39877. * @return the found morph target or null if not found at all.
  39878. */
  39879. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39880. /**
  39881. * Gets a boolean indicating if the given mesh is active
  39882. * @param mesh defines the mesh to look for
  39883. * @returns true if the mesh is in the active list
  39884. */
  39885. isActiveMesh(mesh: AbstractMesh): boolean;
  39886. /**
  39887. * Return a unique id as a string which can serve as an identifier for the scene
  39888. */
  39889. get uid(): string;
  39890. /**
  39891. * Add an externaly attached data from its key.
  39892. * This method call will fail and return false, if such key already exists.
  39893. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39894. * @param key the unique key that identifies the data
  39895. * @param data the data object to associate to the key for this Engine instance
  39896. * @return true if no such key were already present and the data was added successfully, false otherwise
  39897. */
  39898. addExternalData<T>(key: string, data: T): boolean;
  39899. /**
  39900. * Get an externaly attached data from its key
  39901. * @param key the unique key that identifies the data
  39902. * @return the associated data, if present (can be null), or undefined if not present
  39903. */
  39904. getExternalData<T>(key: string): Nullable<T>;
  39905. /**
  39906. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39907. * @param key the unique key that identifies the data
  39908. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39909. * @return the associated data, can be null if the factory returned null.
  39910. */
  39911. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39912. /**
  39913. * Remove an externaly attached data from the Engine instance
  39914. * @param key the unique key that identifies the data
  39915. * @return true if the data was successfully removed, false if it doesn't exist
  39916. */
  39917. removeExternalData(key: string): boolean;
  39918. private _evaluateSubMesh;
  39919. /**
  39920. * Clear the processed materials smart array preventing retention point in material dispose.
  39921. */
  39922. freeProcessedMaterials(): void;
  39923. private _preventFreeActiveMeshesAndRenderingGroups;
  39924. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39925. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39926. * when disposing several meshes in a row or a hierarchy of meshes.
  39927. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39928. */
  39929. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39930. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39931. /**
  39932. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39933. */
  39934. freeActiveMeshes(): void;
  39935. /**
  39936. * Clear the info related to rendering groups preventing retention points during dispose.
  39937. */
  39938. freeRenderingGroups(): void;
  39939. /** @hidden */
  39940. _isInIntermediateRendering(): boolean;
  39941. /**
  39942. * Lambda returning the list of potentially active meshes.
  39943. */
  39944. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39945. /**
  39946. * Lambda returning the list of potentially active sub meshes.
  39947. */
  39948. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39949. /**
  39950. * Lambda returning the list of potentially intersecting sub meshes.
  39951. */
  39952. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39953. /**
  39954. * Lambda returning the list of potentially colliding sub meshes.
  39955. */
  39956. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39957. private _activeMeshesFrozen;
  39958. private _skipEvaluateActiveMeshesCompletely;
  39959. /**
  39960. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39961. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39962. * @returns the current scene
  39963. */
  39964. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39965. /**
  39966. * Use this function to restart evaluating active meshes on every frame
  39967. * @returns the current scene
  39968. */
  39969. unfreezeActiveMeshes(): Scene;
  39970. private _evaluateActiveMeshes;
  39971. private _activeMesh;
  39972. /**
  39973. * Update the transform matrix to update from the current active camera
  39974. * @param force defines a boolean used to force the update even if cache is up to date
  39975. */
  39976. updateTransformMatrix(force?: boolean): void;
  39977. private _bindFrameBuffer;
  39978. /** @hidden */
  39979. _allowPostProcessClearColor: boolean;
  39980. /** @hidden */
  39981. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39982. private _processSubCameras;
  39983. private _checkIntersections;
  39984. /** @hidden */
  39985. _advancePhysicsEngineStep(step: number): void;
  39986. /**
  39987. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39988. */
  39989. getDeterministicFrameTime: () => number;
  39990. /** @hidden */
  39991. _animate(): void;
  39992. /** Execute all animations (for a frame) */
  39993. animate(): void;
  39994. /**
  39995. * Render the scene
  39996. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39997. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39998. */
  39999. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40000. /**
  40001. * Freeze all materials
  40002. * A frozen material will not be updatable but should be faster to render
  40003. */
  40004. freezeMaterials(): void;
  40005. /**
  40006. * Unfreeze all materials
  40007. * A frozen material will not be updatable but should be faster to render
  40008. */
  40009. unfreezeMaterials(): void;
  40010. /**
  40011. * Releases all held ressources
  40012. */
  40013. dispose(): void;
  40014. /**
  40015. * Gets if the scene is already disposed
  40016. */
  40017. get isDisposed(): boolean;
  40018. /**
  40019. * Call this function to reduce memory footprint of the scene.
  40020. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40021. */
  40022. clearCachedVertexData(): void;
  40023. /**
  40024. * This function will remove the local cached buffer data from texture.
  40025. * It will save memory but will prevent the texture from being rebuilt
  40026. */
  40027. cleanCachedTextureBuffer(): void;
  40028. /**
  40029. * Get the world extend vectors with an optional filter
  40030. *
  40031. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40032. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40033. */
  40034. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40035. min: Vector3;
  40036. max: Vector3;
  40037. };
  40038. /**
  40039. * Creates a ray that can be used to pick in the scene
  40040. * @param x defines the x coordinate of the origin (on-screen)
  40041. * @param y defines the y coordinate of the origin (on-screen)
  40042. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40043. * @param camera defines the camera to use for the picking
  40044. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40045. * @returns a Ray
  40046. */
  40047. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40048. /**
  40049. * Creates a ray that can be used to pick in the scene
  40050. * @param x defines the x coordinate of the origin (on-screen)
  40051. * @param y defines the y coordinate of the origin (on-screen)
  40052. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40053. * @param result defines the ray where to store the picking ray
  40054. * @param camera defines the camera to use for the picking
  40055. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40056. * @returns the current scene
  40057. */
  40058. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40059. /**
  40060. * Creates a ray that can be used to pick in the scene
  40061. * @param x defines the x coordinate of the origin (on-screen)
  40062. * @param y defines the y coordinate of the origin (on-screen)
  40063. * @param camera defines the camera to use for the picking
  40064. * @returns a Ray
  40065. */
  40066. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40067. /**
  40068. * Creates a ray that can be used to pick in the scene
  40069. * @param x defines the x coordinate of the origin (on-screen)
  40070. * @param y defines the y coordinate of the origin (on-screen)
  40071. * @param result defines the ray where to store the picking ray
  40072. * @param camera defines the camera to use for the picking
  40073. * @returns the current scene
  40074. */
  40075. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40076. /** Launch a ray to try to pick a mesh in the scene
  40077. * @param x position on screen
  40078. * @param y position on screen
  40079. * @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
  40080. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40081. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40082. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40083. * @returns a PickingInfo
  40084. */
  40085. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40086. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40087. * @param x position on screen
  40088. * @param y position on screen
  40089. * @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
  40090. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40091. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40092. * @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)
  40093. */
  40094. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40095. /** Use the given ray to pick a mesh in the scene
  40096. * @param ray The ray to use to pick meshes
  40097. * @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
  40098. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40099. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40100. * @returns a PickingInfo
  40101. */
  40102. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40103. /**
  40104. * Launch a ray to try to pick a mesh in the scene
  40105. * @param x X position on screen
  40106. * @param y Y position on screen
  40107. * @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
  40108. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40109. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40110. * @returns an array of PickingInfo
  40111. */
  40112. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40113. /**
  40114. * Launch a ray to try to pick a mesh in the scene
  40115. * @param ray Ray to use
  40116. * @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
  40117. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40118. * @returns an array of PickingInfo
  40119. */
  40120. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40121. /**
  40122. * Force the value of meshUnderPointer
  40123. * @param mesh defines the mesh to use
  40124. */
  40125. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40126. /**
  40127. * Gets the mesh under the pointer
  40128. * @returns a Mesh or null if no mesh is under the pointer
  40129. */
  40130. getPointerOverMesh(): Nullable<AbstractMesh>;
  40131. /** @hidden */
  40132. _rebuildGeometries(): void;
  40133. /** @hidden */
  40134. _rebuildTextures(): void;
  40135. private _getByTags;
  40136. /**
  40137. * Get a list of meshes 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 Mesh
  40141. */
  40142. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40143. /**
  40144. * Get a list of cameras 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 Camera
  40148. */
  40149. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40150. /**
  40151. * Get a list of lights 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 Light
  40155. */
  40156. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40157. /**
  40158. * Get a list of materials by tags
  40159. * @param tagsQuery defines the tags query to use
  40160. * @param forEach defines a predicate used to filter results
  40161. * @returns an array of Material
  40162. */
  40163. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40164. /**
  40165. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40166. * This allowed control for front to back rendering or reversly depending of the special needs.
  40167. *
  40168. * @param renderingGroupId The rendering group id corresponding to its index
  40169. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40170. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40171. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40172. */
  40173. 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;
  40174. /**
  40175. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40176. *
  40177. * @param renderingGroupId The rendering group id corresponding to its index
  40178. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40179. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40180. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40181. */
  40182. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40183. /**
  40184. * Gets the current auto clear configuration for one rendering group of the rendering
  40185. * manager.
  40186. * @param index the rendering group index to get the information for
  40187. * @returns The auto clear setup for the requested rendering group
  40188. */
  40189. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40190. private _blockMaterialDirtyMechanism;
  40191. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40192. get blockMaterialDirtyMechanism(): boolean;
  40193. set blockMaterialDirtyMechanism(value: boolean);
  40194. /**
  40195. * Will flag all materials as dirty to trigger new shader compilation
  40196. * @param flag defines the flag used to specify which material part must be marked as dirty
  40197. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40198. */
  40199. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40200. /** @hidden */
  40201. _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;
  40202. /** @hidden */
  40203. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40204. /** @hidden */
  40205. _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;
  40206. /** @hidden */
  40207. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40208. /** @hidden */
  40209. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40210. /** @hidden */
  40211. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40212. }
  40213. }
  40214. declare module BABYLON {
  40215. /**
  40216. * Set of assets to keep when moving a scene into an asset container.
  40217. */
  40218. export class KeepAssets extends AbstractScene {
  40219. }
  40220. /**
  40221. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40222. */
  40223. export class InstantiatedEntries {
  40224. /**
  40225. * List of new root nodes (eg. nodes with no parent)
  40226. */
  40227. rootNodes: TransformNode[];
  40228. /**
  40229. * List of new skeletons
  40230. */
  40231. skeletons: Skeleton[];
  40232. /**
  40233. * List of new animation groups
  40234. */
  40235. animationGroups: AnimationGroup[];
  40236. }
  40237. /**
  40238. * Container with a set of assets that can be added or removed from a scene.
  40239. */
  40240. export class AssetContainer extends AbstractScene {
  40241. private _wasAddedToScene;
  40242. /**
  40243. * The scene the AssetContainer belongs to.
  40244. */
  40245. scene: Scene;
  40246. /**
  40247. * Instantiates an AssetContainer.
  40248. * @param scene The scene the AssetContainer belongs to.
  40249. */
  40250. constructor(scene: Scene);
  40251. /**
  40252. * Instantiate or clone all meshes and add the new ones to the scene.
  40253. * Skeletons and animation groups will all be cloned
  40254. * @param nameFunction defines an optional function used to get new names for clones
  40255. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40256. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40257. */
  40258. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40259. /**
  40260. * Adds all the assets from the container to the scene.
  40261. */
  40262. addAllToScene(): void;
  40263. /**
  40264. * Removes all the assets in the container from the scene
  40265. */
  40266. removeAllFromScene(): void;
  40267. /**
  40268. * Disposes all the assets in the container
  40269. */
  40270. dispose(): void;
  40271. private _moveAssets;
  40272. /**
  40273. * Removes all the assets contained in the scene and adds them to the container.
  40274. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40275. */
  40276. moveAllFromScene(keepAssets?: KeepAssets): void;
  40277. /**
  40278. * 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.
  40279. * @returns the root mesh
  40280. */
  40281. createRootMesh(): Mesh;
  40282. /**
  40283. * Merge animations (direct and animation groups) from this asset container into a scene
  40284. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40285. * @param animatables set of animatables to retarget to a node from the scene
  40286. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40287. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40288. */
  40289. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40290. }
  40291. }
  40292. declare module BABYLON {
  40293. /**
  40294. * Defines how the parser contract is defined.
  40295. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40296. */
  40297. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40298. /**
  40299. * Defines how the individual parser contract is defined.
  40300. * These parser can parse an individual asset
  40301. */
  40302. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40303. /**
  40304. * Base class of the scene acting as a container for the different elements composing a scene.
  40305. * This class is dynamically extended by the different components of the scene increasing
  40306. * flexibility and reducing coupling
  40307. */
  40308. export abstract class AbstractScene {
  40309. /**
  40310. * Stores the list of available parsers in the application.
  40311. */
  40312. private static _BabylonFileParsers;
  40313. /**
  40314. * Stores the list of available individual parsers in the application.
  40315. */
  40316. private static _IndividualBabylonFileParsers;
  40317. /**
  40318. * Adds a parser in the list of available ones
  40319. * @param name Defines the name of the parser
  40320. * @param parser Defines the parser to add
  40321. */
  40322. static AddParser(name: string, parser: BabylonFileParser): void;
  40323. /**
  40324. * Gets a general parser from the list of avaialble ones
  40325. * @param name Defines the name of the parser
  40326. * @returns the requested parser or null
  40327. */
  40328. static GetParser(name: string): Nullable<BabylonFileParser>;
  40329. /**
  40330. * Adds n individual parser in the list of available ones
  40331. * @param name Defines the name of the parser
  40332. * @param parser Defines the parser to add
  40333. */
  40334. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40335. /**
  40336. * Gets an individual parser from the list of avaialble ones
  40337. * @param name Defines the name of the parser
  40338. * @returns the requested parser or null
  40339. */
  40340. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40341. /**
  40342. * Parser json data and populate both a scene and its associated container object
  40343. * @param jsonData Defines the data to parse
  40344. * @param scene Defines the scene to parse the data for
  40345. * @param container Defines the container attached to the parsing sequence
  40346. * @param rootUrl Defines the root url of the data
  40347. */
  40348. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40349. /**
  40350. * Gets the list of root nodes (ie. nodes with no parent)
  40351. */
  40352. rootNodes: Node[];
  40353. /** All of the cameras added to this scene
  40354. * @see http://doc.babylonjs.com/babylon101/cameras
  40355. */
  40356. cameras: Camera[];
  40357. /**
  40358. * All of the lights added to this scene
  40359. * @see http://doc.babylonjs.com/babylon101/lights
  40360. */
  40361. lights: Light[];
  40362. /**
  40363. * All of the (abstract) meshes added to this scene
  40364. */
  40365. meshes: AbstractMesh[];
  40366. /**
  40367. * The list of skeletons added to the scene
  40368. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40369. */
  40370. skeletons: Skeleton[];
  40371. /**
  40372. * All of the particle systems added to this scene
  40373. * @see http://doc.babylonjs.com/babylon101/particles
  40374. */
  40375. particleSystems: IParticleSystem[];
  40376. /**
  40377. * Gets a list of Animations associated with the scene
  40378. */
  40379. animations: Animation[];
  40380. /**
  40381. * All of the animation groups added to this scene
  40382. * @see http://doc.babylonjs.com/how_to/group
  40383. */
  40384. animationGroups: AnimationGroup[];
  40385. /**
  40386. * All of the multi-materials added to this scene
  40387. * @see http://doc.babylonjs.com/how_to/multi_materials
  40388. */
  40389. multiMaterials: MultiMaterial[];
  40390. /**
  40391. * All of the materials added to this scene
  40392. * In the context of a Scene, it is not supposed to be modified manually.
  40393. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40394. * Note also that the order of the Material within the array is not significant and might change.
  40395. * @see http://doc.babylonjs.com/babylon101/materials
  40396. */
  40397. materials: Material[];
  40398. /**
  40399. * The list of morph target managers added to the scene
  40400. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40401. */
  40402. morphTargetManagers: MorphTargetManager[];
  40403. /**
  40404. * The list of geometries used in the scene.
  40405. */
  40406. geometries: Geometry[];
  40407. /**
  40408. * All of the tranform nodes added to this scene
  40409. * In the context of a Scene, it is not supposed to be modified manually.
  40410. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40411. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40412. * @see http://doc.babylonjs.com/how_to/transformnode
  40413. */
  40414. transformNodes: TransformNode[];
  40415. /**
  40416. * ActionManagers available on the scene.
  40417. */
  40418. actionManagers: AbstractActionManager[];
  40419. /**
  40420. * Textures to keep.
  40421. */
  40422. textures: BaseTexture[];
  40423. /**
  40424. * Environment texture for the scene
  40425. */
  40426. environmentTexture: Nullable<BaseTexture>;
  40427. /**
  40428. * @returns all meshes, lights, cameras, transformNodes and bones
  40429. */
  40430. getNodes(): Array<Node>;
  40431. }
  40432. }
  40433. declare module BABYLON {
  40434. /**
  40435. * Interface used to define options for Sound class
  40436. */
  40437. export interface ISoundOptions {
  40438. /**
  40439. * Does the sound autoplay once loaded.
  40440. */
  40441. autoplay?: boolean;
  40442. /**
  40443. * Does the sound loop after it finishes playing once.
  40444. */
  40445. loop?: boolean;
  40446. /**
  40447. * Sound's volume
  40448. */
  40449. volume?: number;
  40450. /**
  40451. * Is it a spatial sound?
  40452. */
  40453. spatialSound?: boolean;
  40454. /**
  40455. * Maximum distance to hear that sound
  40456. */
  40457. maxDistance?: number;
  40458. /**
  40459. * Uses user defined attenuation function
  40460. */
  40461. useCustomAttenuation?: boolean;
  40462. /**
  40463. * Define the roll off factor of spatial sounds.
  40464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40465. */
  40466. rolloffFactor?: number;
  40467. /**
  40468. * Define the reference distance the sound should be heard perfectly.
  40469. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40470. */
  40471. refDistance?: number;
  40472. /**
  40473. * Define the distance attenuation model the sound will follow.
  40474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40475. */
  40476. distanceModel?: string;
  40477. /**
  40478. * Defines the playback speed (1 by default)
  40479. */
  40480. playbackRate?: number;
  40481. /**
  40482. * Defines if the sound is from a streaming source
  40483. */
  40484. streaming?: boolean;
  40485. /**
  40486. * Defines an optional length (in seconds) inside the sound file
  40487. */
  40488. length?: number;
  40489. /**
  40490. * Defines an optional offset (in seconds) inside the sound file
  40491. */
  40492. offset?: number;
  40493. /**
  40494. * If true, URLs will not be required to state the audio file codec to use.
  40495. */
  40496. skipCodecCheck?: boolean;
  40497. }
  40498. /**
  40499. * Defines a sound that can be played in the application.
  40500. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40502. */
  40503. export class Sound {
  40504. /**
  40505. * The name of the sound in the scene.
  40506. */
  40507. name: string;
  40508. /**
  40509. * Does the sound autoplay once loaded.
  40510. */
  40511. autoplay: boolean;
  40512. /**
  40513. * Does the sound loop after it finishes playing once.
  40514. */
  40515. loop: boolean;
  40516. /**
  40517. * Does the sound use a custom attenuation curve to simulate the falloff
  40518. * happening when the source gets further away from the camera.
  40519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40520. */
  40521. useCustomAttenuation: boolean;
  40522. /**
  40523. * The sound track id this sound belongs to.
  40524. */
  40525. soundTrackId: number;
  40526. /**
  40527. * Is this sound currently played.
  40528. */
  40529. isPlaying: boolean;
  40530. /**
  40531. * Is this sound currently paused.
  40532. */
  40533. isPaused: boolean;
  40534. /**
  40535. * Does this sound enables spatial sound.
  40536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40537. */
  40538. spatialSound: boolean;
  40539. /**
  40540. * Define the reference distance the sound should be heard perfectly.
  40541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40542. */
  40543. refDistance: number;
  40544. /**
  40545. * Define the roll off factor of spatial sounds.
  40546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40547. */
  40548. rolloffFactor: number;
  40549. /**
  40550. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40552. */
  40553. maxDistance: number;
  40554. /**
  40555. * Define the distance attenuation model the sound will follow.
  40556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40557. */
  40558. distanceModel: string;
  40559. /**
  40560. * @hidden
  40561. * Back Compat
  40562. **/
  40563. onended: () => any;
  40564. /**
  40565. * Gets or sets an object used to store user defined information for the sound.
  40566. */
  40567. metadata: any;
  40568. /**
  40569. * Observable event when the current playing sound finishes.
  40570. */
  40571. onEndedObservable: Observable<Sound>;
  40572. private _panningModel;
  40573. private _playbackRate;
  40574. private _streaming;
  40575. private _startTime;
  40576. private _startOffset;
  40577. private _position;
  40578. /** @hidden */
  40579. _positionInEmitterSpace: boolean;
  40580. private _localDirection;
  40581. private _volume;
  40582. private _isReadyToPlay;
  40583. private _isDirectional;
  40584. private _readyToPlayCallback;
  40585. private _audioBuffer;
  40586. private _soundSource;
  40587. private _streamingSource;
  40588. private _soundPanner;
  40589. private _soundGain;
  40590. private _inputAudioNode;
  40591. private _outputAudioNode;
  40592. private _coneInnerAngle;
  40593. private _coneOuterAngle;
  40594. private _coneOuterGain;
  40595. private _scene;
  40596. private _connectedTransformNode;
  40597. private _customAttenuationFunction;
  40598. private _registerFunc;
  40599. private _isOutputConnected;
  40600. private _htmlAudioElement;
  40601. private _urlType;
  40602. private _length?;
  40603. private _offset?;
  40604. /** @hidden */
  40605. static _SceneComponentInitialization: (scene: Scene) => void;
  40606. /**
  40607. * Create a sound and attach it to a scene
  40608. * @param name Name of your sound
  40609. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40610. * @param scene defines the scene the sound belongs to
  40611. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40612. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40613. */
  40614. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40615. /**
  40616. * Release the sound and its associated resources
  40617. */
  40618. dispose(): void;
  40619. /**
  40620. * Gets if the sounds is ready to be played or not.
  40621. * @returns true if ready, otherwise false
  40622. */
  40623. isReady(): boolean;
  40624. private _soundLoaded;
  40625. /**
  40626. * Sets the data of the sound from an audiobuffer
  40627. * @param audioBuffer The audioBuffer containing the data
  40628. */
  40629. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40630. /**
  40631. * Updates the current sounds options such as maxdistance, loop...
  40632. * @param options A JSON object containing values named as the object properties
  40633. */
  40634. updateOptions(options: ISoundOptions): void;
  40635. private _createSpatialParameters;
  40636. private _updateSpatialParameters;
  40637. /**
  40638. * Switch the panning model to HRTF:
  40639. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40641. */
  40642. switchPanningModelToHRTF(): void;
  40643. /**
  40644. * Switch the panning model to Equal Power:
  40645. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40646. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40647. */
  40648. switchPanningModelToEqualPower(): void;
  40649. private _switchPanningModel;
  40650. /**
  40651. * Connect this sound to a sound track audio node like gain...
  40652. * @param soundTrackAudioNode the sound track audio node to connect to
  40653. */
  40654. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40655. /**
  40656. * Transform this sound into a directional source
  40657. * @param coneInnerAngle Size of the inner cone in degree
  40658. * @param coneOuterAngle Size of the outer cone in degree
  40659. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40660. */
  40661. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40662. /**
  40663. * Gets or sets the inner angle for the directional cone.
  40664. */
  40665. get directionalConeInnerAngle(): number;
  40666. /**
  40667. * Gets or sets the inner angle for the directional cone.
  40668. */
  40669. set directionalConeInnerAngle(value: number);
  40670. /**
  40671. * Gets or sets the outer angle for the directional cone.
  40672. */
  40673. get directionalConeOuterAngle(): number;
  40674. /**
  40675. * Gets or sets the outer angle for the directional cone.
  40676. */
  40677. set directionalConeOuterAngle(value: number);
  40678. /**
  40679. * Sets the position of the emitter if spatial sound is enabled
  40680. * @param newPosition Defines the new posisiton
  40681. */
  40682. setPosition(newPosition: Vector3): void;
  40683. /**
  40684. * Sets the local direction of the emitter if spatial sound is enabled
  40685. * @param newLocalDirection Defines the new local direction
  40686. */
  40687. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40688. private _updateDirection;
  40689. /** @hidden */
  40690. updateDistanceFromListener(): void;
  40691. /**
  40692. * Sets a new custom attenuation function for the sound.
  40693. * @param callback Defines the function used for the attenuation
  40694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40695. */
  40696. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40697. /**
  40698. * Play the sound
  40699. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40700. * @param offset (optional) Start the sound at a specific time in seconds
  40701. * @param length (optional) Sound duration (in seconds)
  40702. */
  40703. play(time?: number, offset?: number, length?: number): void;
  40704. private _onended;
  40705. /**
  40706. * Stop the sound
  40707. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40708. */
  40709. stop(time?: number): void;
  40710. /**
  40711. * Put the sound in pause
  40712. */
  40713. pause(): void;
  40714. /**
  40715. * Sets a dedicated volume for this sounds
  40716. * @param newVolume Define the new volume of the sound
  40717. * @param time Define time for gradual change to new volume
  40718. */
  40719. setVolume(newVolume: number, time?: number): void;
  40720. /**
  40721. * Set the sound play back rate
  40722. * @param newPlaybackRate Define the playback rate the sound should be played at
  40723. */
  40724. setPlaybackRate(newPlaybackRate: number): void;
  40725. /**
  40726. * Gets the volume of the sound.
  40727. * @returns the volume of the sound
  40728. */
  40729. getVolume(): number;
  40730. /**
  40731. * Attach the sound to a dedicated mesh
  40732. * @param transformNode The transform node to connect the sound with
  40733. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40734. */
  40735. attachToMesh(transformNode: TransformNode): void;
  40736. /**
  40737. * Detach the sound from the previously attached mesh
  40738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40739. */
  40740. detachFromMesh(): void;
  40741. private _onRegisterAfterWorldMatrixUpdate;
  40742. /**
  40743. * Clone the current sound in the scene.
  40744. * @returns the new sound clone
  40745. */
  40746. clone(): Nullable<Sound>;
  40747. /**
  40748. * Gets the current underlying audio buffer containing the data
  40749. * @returns the audio buffer
  40750. */
  40751. getAudioBuffer(): Nullable<AudioBuffer>;
  40752. /**
  40753. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40754. * @returns the source node
  40755. */
  40756. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40757. /**
  40758. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40759. * @returns the gain node
  40760. */
  40761. getSoundGain(): Nullable<GainNode>;
  40762. /**
  40763. * Serializes the Sound in a JSON representation
  40764. * @returns the JSON representation of the sound
  40765. */
  40766. serialize(): any;
  40767. /**
  40768. * Parse a JSON representation of a sound to innstantiate in a given scene
  40769. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40770. * @param scene Define the scene the new parsed sound should be created in
  40771. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40772. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40773. * @returns the newly parsed sound
  40774. */
  40775. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40776. }
  40777. }
  40778. declare module BABYLON {
  40779. /**
  40780. * This defines an action helpful to play a defined sound on a triggered action.
  40781. */
  40782. export class PlaySoundAction extends Action {
  40783. private _sound;
  40784. /**
  40785. * Instantiate the action
  40786. * @param triggerOptions defines the trigger options
  40787. * @param sound defines the sound to play
  40788. * @param condition defines the trigger related conditions
  40789. */
  40790. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40791. /** @hidden */
  40792. _prepare(): void;
  40793. /**
  40794. * Execute the action and play the sound.
  40795. */
  40796. execute(): void;
  40797. /**
  40798. * Serializes the actions and its related information.
  40799. * @param parent defines the object to serialize in
  40800. * @returns the serialized object
  40801. */
  40802. serialize(parent: any): any;
  40803. }
  40804. /**
  40805. * This defines an action helpful to stop a defined sound on a triggered action.
  40806. */
  40807. export class StopSoundAction extends Action {
  40808. private _sound;
  40809. /**
  40810. * Instantiate the action
  40811. * @param triggerOptions defines the trigger options
  40812. * @param sound defines the sound to stop
  40813. * @param condition defines the trigger related conditions
  40814. */
  40815. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40816. /** @hidden */
  40817. _prepare(): void;
  40818. /**
  40819. * Execute the action and stop the sound.
  40820. */
  40821. execute(): void;
  40822. /**
  40823. * Serializes the actions and its related information.
  40824. * @param parent defines the object to serialize in
  40825. * @returns the serialized object
  40826. */
  40827. serialize(parent: any): any;
  40828. }
  40829. }
  40830. declare module BABYLON {
  40831. /**
  40832. * This defines an action responsible to change the value of a property
  40833. * by interpolating between its current value and the newly set one once triggered.
  40834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40835. */
  40836. export class InterpolateValueAction extends Action {
  40837. /**
  40838. * Defines the path of the property where the value should be interpolated
  40839. */
  40840. propertyPath: string;
  40841. /**
  40842. * Defines the target value at the end of the interpolation.
  40843. */
  40844. value: any;
  40845. /**
  40846. * Defines the time it will take for the property to interpolate to the value.
  40847. */
  40848. duration: number;
  40849. /**
  40850. * Defines if the other scene animations should be stopped when the action has been triggered
  40851. */
  40852. stopOtherAnimations?: boolean;
  40853. /**
  40854. * Defines a callback raised once the interpolation animation has been done.
  40855. */
  40856. onInterpolationDone?: () => void;
  40857. /**
  40858. * Observable triggered once the interpolation animation has been done.
  40859. */
  40860. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40861. private _target;
  40862. private _effectiveTarget;
  40863. private _property;
  40864. /**
  40865. * Instantiate the action
  40866. * @param triggerOptions defines the trigger options
  40867. * @param target defines the object containing the value to interpolate
  40868. * @param propertyPath defines the path to the property in the target object
  40869. * @param value defines the target value at the end of the interpolation
  40870. * @param duration deines the time it will take for the property to interpolate to the value.
  40871. * @param condition defines the trigger related conditions
  40872. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40873. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40874. */
  40875. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40876. /** @hidden */
  40877. _prepare(): void;
  40878. /**
  40879. * Execute the action starts the value interpolation.
  40880. */
  40881. execute(): void;
  40882. /**
  40883. * Serializes the actions and its related information.
  40884. * @param parent defines the object to serialize in
  40885. * @returns the serialized object
  40886. */
  40887. serialize(parent: any): any;
  40888. }
  40889. }
  40890. declare module BABYLON {
  40891. /**
  40892. * Options allowed during the creation of a sound track.
  40893. */
  40894. export interface ISoundTrackOptions {
  40895. /**
  40896. * The volume the sound track should take during creation
  40897. */
  40898. volume?: number;
  40899. /**
  40900. * Define if the sound track is the main sound track of the scene
  40901. */
  40902. mainTrack?: boolean;
  40903. }
  40904. /**
  40905. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40906. * It will be also used in a future release to apply effects on a specific track.
  40907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40908. */
  40909. export class SoundTrack {
  40910. /**
  40911. * The unique identifier of the sound track in the scene.
  40912. */
  40913. id: number;
  40914. /**
  40915. * The list of sounds included in the sound track.
  40916. */
  40917. soundCollection: Array<Sound>;
  40918. private _outputAudioNode;
  40919. private _scene;
  40920. private _connectedAnalyser;
  40921. private _options;
  40922. private _isInitialized;
  40923. /**
  40924. * Creates a new sound track.
  40925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40926. * @param scene Define the scene the sound track belongs to
  40927. * @param options
  40928. */
  40929. constructor(scene: Scene, options?: ISoundTrackOptions);
  40930. private _initializeSoundTrackAudioGraph;
  40931. /**
  40932. * Release the sound track and its associated resources
  40933. */
  40934. dispose(): void;
  40935. /**
  40936. * Adds a sound to this sound track
  40937. * @param sound define the cound to add
  40938. * @ignoreNaming
  40939. */
  40940. AddSound(sound: Sound): void;
  40941. /**
  40942. * Removes a sound to this sound track
  40943. * @param sound define the cound to remove
  40944. * @ignoreNaming
  40945. */
  40946. RemoveSound(sound: Sound): void;
  40947. /**
  40948. * Set a global volume for the full sound track.
  40949. * @param newVolume Define the new volume of the sound track
  40950. */
  40951. setVolume(newVolume: number): void;
  40952. /**
  40953. * Switch the panning model to HRTF:
  40954. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40955. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40956. */
  40957. switchPanningModelToHRTF(): void;
  40958. /**
  40959. * Switch the panning model to Equal Power:
  40960. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40961. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40962. */
  40963. switchPanningModelToEqualPower(): void;
  40964. /**
  40965. * Connect the sound track to an audio analyser allowing some amazing
  40966. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40968. * @param analyser The analyser to connect to the engine
  40969. */
  40970. connectToAnalyser(analyser: Analyser): void;
  40971. }
  40972. }
  40973. declare module BABYLON {
  40974. interface AbstractScene {
  40975. /**
  40976. * The list of sounds used in the scene.
  40977. */
  40978. sounds: Nullable<Array<Sound>>;
  40979. }
  40980. interface Scene {
  40981. /**
  40982. * @hidden
  40983. * Backing field
  40984. */
  40985. _mainSoundTrack: SoundTrack;
  40986. /**
  40987. * The main sound track played by the scene.
  40988. * It cotains your primary collection of sounds.
  40989. */
  40990. mainSoundTrack: SoundTrack;
  40991. /**
  40992. * The list of sound tracks added to the scene
  40993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40994. */
  40995. soundTracks: Nullable<Array<SoundTrack>>;
  40996. /**
  40997. * Gets a sound using a given name
  40998. * @param name defines the name to search for
  40999. * @return the found sound or null if not found at all.
  41000. */
  41001. getSoundByName(name: string): Nullable<Sound>;
  41002. /**
  41003. * Gets or sets if audio support is enabled
  41004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41005. */
  41006. audioEnabled: boolean;
  41007. /**
  41008. * Gets or sets if audio will be output to headphones
  41009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41010. */
  41011. headphone: boolean;
  41012. /**
  41013. * Gets or sets custom audio listener position provider
  41014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41015. */
  41016. audioListenerPositionProvider: Nullable<() => Vector3>;
  41017. /**
  41018. * Gets or sets a refresh rate when using 3D audio positioning
  41019. */
  41020. audioPositioningRefreshRate: number;
  41021. }
  41022. /**
  41023. * Defines the sound scene component responsible to manage any sounds
  41024. * in a given scene.
  41025. */
  41026. export class AudioSceneComponent implements ISceneSerializableComponent {
  41027. /**
  41028. * The component name helpfull to identify the component in the list of scene components.
  41029. */
  41030. readonly name: string;
  41031. /**
  41032. * The scene the component belongs to.
  41033. */
  41034. scene: Scene;
  41035. private _audioEnabled;
  41036. /**
  41037. * Gets whether audio is enabled or not.
  41038. * Please use related enable/disable method to switch state.
  41039. */
  41040. get audioEnabled(): boolean;
  41041. private _headphone;
  41042. /**
  41043. * Gets whether audio is outputing to headphone or not.
  41044. * Please use the according Switch methods to change output.
  41045. */
  41046. get headphone(): boolean;
  41047. /**
  41048. * Gets or sets a refresh rate when using 3D audio positioning
  41049. */
  41050. audioPositioningRefreshRate: number;
  41051. private _audioListenerPositionProvider;
  41052. /**
  41053. * Gets the current audio listener position provider
  41054. */
  41055. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41056. /**
  41057. * Sets a custom listener position for all sounds in the scene
  41058. * By default, this is the position of the first active camera
  41059. */
  41060. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41061. /**
  41062. * Creates a new instance of the component for the given scene
  41063. * @param scene Defines the scene to register the component in
  41064. */
  41065. constructor(scene: Scene);
  41066. /**
  41067. * Registers the component in a given scene
  41068. */
  41069. register(): void;
  41070. /**
  41071. * Rebuilds the elements related to this component in case of
  41072. * context lost for instance.
  41073. */
  41074. rebuild(): void;
  41075. /**
  41076. * Serializes the component data to the specified json object
  41077. * @param serializationObject The object to serialize to
  41078. */
  41079. serialize(serializationObject: any): void;
  41080. /**
  41081. * Adds all the elements from the container to the scene
  41082. * @param container the container holding the elements
  41083. */
  41084. addFromContainer(container: AbstractScene): void;
  41085. /**
  41086. * Removes all the elements in the container from the scene
  41087. * @param container contains the elements to remove
  41088. * @param dispose if the removed element should be disposed (default: false)
  41089. */
  41090. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41091. /**
  41092. * Disposes the component and the associated ressources.
  41093. */
  41094. dispose(): void;
  41095. /**
  41096. * Disables audio in the associated scene.
  41097. */
  41098. disableAudio(): void;
  41099. /**
  41100. * Enables audio in the associated scene.
  41101. */
  41102. enableAudio(): void;
  41103. /**
  41104. * Switch audio to headphone output.
  41105. */
  41106. switchAudioModeForHeadphones(): void;
  41107. /**
  41108. * Switch audio to normal speakers.
  41109. */
  41110. switchAudioModeForNormalSpeakers(): void;
  41111. private _cachedCameraDirection;
  41112. private _cachedCameraPosition;
  41113. private _lastCheck;
  41114. private _afterRender;
  41115. }
  41116. }
  41117. declare module BABYLON {
  41118. /**
  41119. * Wraps one or more Sound objects and selects one with random weight for playback.
  41120. */
  41121. export class WeightedSound {
  41122. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41123. loop: boolean;
  41124. private _coneInnerAngle;
  41125. private _coneOuterAngle;
  41126. private _volume;
  41127. /** A Sound is currently playing. */
  41128. isPlaying: boolean;
  41129. /** A Sound is currently paused. */
  41130. isPaused: boolean;
  41131. private _sounds;
  41132. private _weights;
  41133. private _currentIndex?;
  41134. /**
  41135. * Creates a new WeightedSound from the list of sounds given.
  41136. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41137. * @param sounds Array of Sounds that will be selected from.
  41138. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41139. */
  41140. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41141. /**
  41142. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41143. */
  41144. get directionalConeInnerAngle(): number;
  41145. /**
  41146. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41147. */
  41148. set directionalConeInnerAngle(value: number);
  41149. /**
  41150. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41151. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41152. */
  41153. get directionalConeOuterAngle(): number;
  41154. /**
  41155. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41156. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41157. */
  41158. set directionalConeOuterAngle(value: number);
  41159. /**
  41160. * Playback volume.
  41161. */
  41162. get volume(): number;
  41163. /**
  41164. * Playback volume.
  41165. */
  41166. set volume(value: number);
  41167. private _onended;
  41168. /**
  41169. * Suspend playback
  41170. */
  41171. pause(): void;
  41172. /**
  41173. * Stop playback
  41174. */
  41175. stop(): void;
  41176. /**
  41177. * Start playback.
  41178. * @param startOffset Position the clip head at a specific time in seconds.
  41179. */
  41180. play(startOffset?: number): void;
  41181. }
  41182. }
  41183. declare module BABYLON {
  41184. /**
  41185. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41186. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41187. */
  41188. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41189. /**
  41190. * Gets the name of the behavior.
  41191. */
  41192. get name(): string;
  41193. /**
  41194. * The easing function used by animations
  41195. */
  41196. static EasingFunction: BackEase;
  41197. /**
  41198. * The easing mode used by animations
  41199. */
  41200. static EasingMode: number;
  41201. /**
  41202. * The duration of the animation, in milliseconds
  41203. */
  41204. transitionDuration: number;
  41205. /**
  41206. * Length of the distance animated by the transition when lower radius is reached
  41207. */
  41208. lowerRadiusTransitionRange: number;
  41209. /**
  41210. * Length of the distance animated by the transition when upper radius is reached
  41211. */
  41212. upperRadiusTransitionRange: number;
  41213. private _autoTransitionRange;
  41214. /**
  41215. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41216. */
  41217. get autoTransitionRange(): boolean;
  41218. /**
  41219. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41220. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41221. */
  41222. set autoTransitionRange(value: boolean);
  41223. private _attachedCamera;
  41224. private _onAfterCheckInputsObserver;
  41225. private _onMeshTargetChangedObserver;
  41226. /**
  41227. * Initializes the behavior.
  41228. */
  41229. init(): void;
  41230. /**
  41231. * Attaches the behavior to its arc rotate camera.
  41232. * @param camera Defines the camera to attach the behavior to
  41233. */
  41234. attach(camera: ArcRotateCamera): void;
  41235. /**
  41236. * Detaches the behavior from its current arc rotate camera.
  41237. */
  41238. detach(): void;
  41239. private _radiusIsAnimating;
  41240. private _radiusBounceTransition;
  41241. private _animatables;
  41242. private _cachedWheelPrecision;
  41243. /**
  41244. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41245. * @param radiusLimit The limit to check against.
  41246. * @return Bool to indicate if at limit.
  41247. */
  41248. private _isRadiusAtLimit;
  41249. /**
  41250. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41251. * @param radiusDelta The delta by which to animate to. Can be negative.
  41252. */
  41253. private _applyBoundRadiusAnimation;
  41254. /**
  41255. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41256. */
  41257. protected _clearAnimationLocks(): void;
  41258. /**
  41259. * Stops and removes all animations that have been applied to the camera
  41260. */
  41261. stopAllAnimations(): void;
  41262. }
  41263. }
  41264. declare module BABYLON {
  41265. /**
  41266. * 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.
  41267. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41268. */
  41269. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41270. /**
  41271. * Gets the name of the behavior.
  41272. */
  41273. get name(): string;
  41274. private _mode;
  41275. private _radiusScale;
  41276. private _positionScale;
  41277. private _defaultElevation;
  41278. private _elevationReturnTime;
  41279. private _elevationReturnWaitTime;
  41280. private _zoomStopsAnimation;
  41281. private _framingTime;
  41282. /**
  41283. * The easing function used by animations
  41284. */
  41285. static EasingFunction: ExponentialEase;
  41286. /**
  41287. * The easing mode used by animations
  41288. */
  41289. static EasingMode: number;
  41290. /**
  41291. * Sets the current mode used by the behavior
  41292. */
  41293. set mode(mode: number);
  41294. /**
  41295. * Gets current mode used by the behavior.
  41296. */
  41297. get mode(): number;
  41298. /**
  41299. * Sets the scale applied to the radius (1 by default)
  41300. */
  41301. set radiusScale(radius: number);
  41302. /**
  41303. * Gets the scale applied to the radius
  41304. */
  41305. get radiusScale(): number;
  41306. /**
  41307. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41308. */
  41309. set positionScale(scale: number);
  41310. /**
  41311. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41312. */
  41313. get positionScale(): number;
  41314. /**
  41315. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41316. * behaviour is triggered, in radians.
  41317. */
  41318. set defaultElevation(elevation: number);
  41319. /**
  41320. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41321. * behaviour is triggered, in radians.
  41322. */
  41323. get defaultElevation(): number;
  41324. /**
  41325. * Sets the time (in milliseconds) taken to return to the default beta position.
  41326. * Negative value indicates camera should not return to default.
  41327. */
  41328. set elevationReturnTime(speed: number);
  41329. /**
  41330. * Gets the time (in milliseconds) taken to return to the default beta position.
  41331. * Negative value indicates camera should not return to default.
  41332. */
  41333. get elevationReturnTime(): number;
  41334. /**
  41335. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41336. */
  41337. set elevationReturnWaitTime(time: number);
  41338. /**
  41339. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41340. */
  41341. get elevationReturnWaitTime(): number;
  41342. /**
  41343. * Sets the flag that indicates if user zooming should stop animation.
  41344. */
  41345. set zoomStopsAnimation(flag: boolean);
  41346. /**
  41347. * Gets the flag that indicates if user zooming should stop animation.
  41348. */
  41349. get zoomStopsAnimation(): boolean;
  41350. /**
  41351. * Sets the transition time when framing the mesh, in milliseconds
  41352. */
  41353. set framingTime(time: number);
  41354. /**
  41355. * Gets the transition time when framing the mesh, in milliseconds
  41356. */
  41357. get framingTime(): number;
  41358. /**
  41359. * Define if the behavior should automatically change the configured
  41360. * camera limits and sensibilities.
  41361. */
  41362. autoCorrectCameraLimitsAndSensibility: boolean;
  41363. private _onPrePointerObservableObserver;
  41364. private _onAfterCheckInputsObserver;
  41365. private _onMeshTargetChangedObserver;
  41366. private _attachedCamera;
  41367. private _isPointerDown;
  41368. private _lastInteractionTime;
  41369. /**
  41370. * Initializes the behavior.
  41371. */
  41372. init(): void;
  41373. /**
  41374. * Attaches the behavior to its arc rotate camera.
  41375. * @param camera Defines the camera to attach the behavior to
  41376. */
  41377. attach(camera: ArcRotateCamera): void;
  41378. /**
  41379. * Detaches the behavior from its current arc rotate camera.
  41380. */
  41381. detach(): void;
  41382. private _animatables;
  41383. private _betaIsAnimating;
  41384. private _betaTransition;
  41385. private _radiusTransition;
  41386. private _vectorTransition;
  41387. /**
  41388. * Targets the given mesh 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. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41394. /**
  41395. * Targets the given mesh with its children and updates zoom level accordingly.
  41396. * @param mesh 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. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41401. /**
  41402. * Targets the given meshes with their children and updates zoom level accordingly.
  41403. * @param meshes The mesh to target.
  41404. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41405. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41406. */
  41407. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41408. /**
  41409. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41410. * @param minimumWorld Determines the smaller position of the bounding box extend
  41411. * @param maximumWorld Determines the bigger position of the bounding box extend
  41412. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41413. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41414. */
  41415. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41416. /**
  41417. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41418. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41419. * frustum width.
  41420. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41421. * to fully enclose the mesh in the viewing frustum.
  41422. */
  41423. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41424. /**
  41425. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41426. * is automatically returned to its default position (expected to be above ground plane).
  41427. */
  41428. private _maintainCameraAboveGround;
  41429. /**
  41430. * Returns the frustum slope based on the canvas ratio and camera FOV
  41431. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41432. */
  41433. private _getFrustumSlope;
  41434. /**
  41435. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41436. */
  41437. private _clearAnimationLocks;
  41438. /**
  41439. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41440. */
  41441. private _applyUserInteraction;
  41442. /**
  41443. * Stops and removes all animations that have been applied to the camera
  41444. */
  41445. stopAllAnimations(): void;
  41446. /**
  41447. * Gets a value indicating if the user is moving the camera
  41448. */
  41449. get isUserIsMoving(): boolean;
  41450. /**
  41451. * The camera can move all the way towards the mesh.
  41452. */
  41453. static IgnoreBoundsSizeMode: number;
  41454. /**
  41455. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41456. */
  41457. static FitFrustumSidesMode: number;
  41458. }
  41459. }
  41460. declare module BABYLON {
  41461. /**
  41462. * Base class for Camera Pointer Inputs.
  41463. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41464. * for example usage.
  41465. */
  41466. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41467. /**
  41468. * Defines the camera the input is attached to.
  41469. */
  41470. abstract camera: Camera;
  41471. /**
  41472. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41473. */
  41474. protected _altKey: boolean;
  41475. protected _ctrlKey: boolean;
  41476. protected _metaKey: boolean;
  41477. protected _shiftKey: boolean;
  41478. /**
  41479. * Which mouse buttons were pressed at time of last mouse event.
  41480. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41481. */
  41482. protected _buttonsPressed: number;
  41483. /**
  41484. * Defines the buttons associated with the input to handle camera move.
  41485. */
  41486. buttons: number[];
  41487. /**
  41488. * Attach the input controls to a specific dom element to get the input from.
  41489. * @param element Defines the element the controls should be listened from
  41490. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41491. */
  41492. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41493. /**
  41494. * Detach the current controls from the specified dom element.
  41495. * @param element Defines the element to stop listening the inputs from
  41496. */
  41497. detachControl(element: Nullable<HTMLElement>): void;
  41498. /**
  41499. * Gets the class name of the current input.
  41500. * @returns the class name
  41501. */
  41502. getClassName(): string;
  41503. /**
  41504. * Get the friendly name associated with the input class.
  41505. * @returns the input friendly name
  41506. */
  41507. getSimpleName(): string;
  41508. /**
  41509. * Called on pointer POINTERDOUBLETAP event.
  41510. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41511. */
  41512. protected onDoubleTap(type: string): void;
  41513. /**
  41514. * Called on pointer POINTERMOVE event if only a single touch is active.
  41515. * Override this method to provide functionality.
  41516. */
  41517. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41518. /**
  41519. * Called on pointer POINTERMOVE event if multiple touches are active.
  41520. * Override this method to provide functionality.
  41521. */
  41522. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41523. /**
  41524. * Called on JS contextmenu event.
  41525. * Override this method to provide functionality.
  41526. */
  41527. protected onContextMenu(evt: PointerEvent): void;
  41528. /**
  41529. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41530. * press.
  41531. * Override this method to provide functionality.
  41532. */
  41533. protected onButtonDown(evt: PointerEvent): void;
  41534. /**
  41535. * Called each time a new POINTERUP event occurs. Ie, for each button
  41536. * release.
  41537. * Override this method to provide functionality.
  41538. */
  41539. protected onButtonUp(evt: PointerEvent): void;
  41540. /**
  41541. * Called when window becomes inactive.
  41542. * Override this method to provide functionality.
  41543. */
  41544. protected onLostFocus(): void;
  41545. private _pointerInput;
  41546. private _observer;
  41547. private _onLostFocus;
  41548. private pointA;
  41549. private pointB;
  41550. }
  41551. }
  41552. declare module BABYLON {
  41553. /**
  41554. * Manage the pointers inputs to control an arc rotate camera.
  41555. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41556. */
  41557. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41558. /**
  41559. * Defines the camera the input is attached to.
  41560. */
  41561. camera: ArcRotateCamera;
  41562. /**
  41563. * Gets the class name of the current input.
  41564. * @returns the class name
  41565. */
  41566. getClassName(): string;
  41567. /**
  41568. * Defines the buttons associated with the input to handle camera move.
  41569. */
  41570. buttons: number[];
  41571. /**
  41572. * Defines the pointer angular sensibility along the X axis or how fast is
  41573. * the camera rotating.
  41574. */
  41575. angularSensibilityX: number;
  41576. /**
  41577. * Defines the pointer angular sensibility along the Y axis or how fast is
  41578. * the camera rotating.
  41579. */
  41580. angularSensibilityY: number;
  41581. /**
  41582. * Defines the pointer pinch precision or how fast is the camera zooming.
  41583. */
  41584. pinchPrecision: number;
  41585. /**
  41586. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41587. * from 0.
  41588. * It defines the percentage of current camera.radius to use as delta when
  41589. * pinch zoom is used.
  41590. */
  41591. pinchDeltaPercentage: number;
  41592. /**
  41593. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41594. * that any object in the plane at the camera's target point will scale
  41595. * perfectly with finger motion.
  41596. * Overrides pinchDeltaPercentage and pinchPrecision.
  41597. */
  41598. useNaturalPinchZoom: boolean;
  41599. /**
  41600. * Defines the pointer panning sensibility or how fast is the camera moving.
  41601. */
  41602. panningSensibility: number;
  41603. /**
  41604. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41605. */
  41606. multiTouchPanning: boolean;
  41607. /**
  41608. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41609. * zoom (pinch) through multitouch.
  41610. */
  41611. multiTouchPanAndZoom: boolean;
  41612. /**
  41613. * Revers pinch action direction.
  41614. */
  41615. pinchInwards: boolean;
  41616. private _isPanClick;
  41617. private _twoFingerActivityCount;
  41618. private _isPinching;
  41619. /**
  41620. * Called on pointer POINTERMOVE event if only a single touch is active.
  41621. */
  41622. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41623. /**
  41624. * Called on pointer POINTERDOUBLETAP event.
  41625. */
  41626. protected onDoubleTap(type: string): void;
  41627. /**
  41628. * Called on pointer POINTERMOVE event if multiple touches are active.
  41629. */
  41630. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41631. /**
  41632. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41633. * press.
  41634. */
  41635. protected onButtonDown(evt: PointerEvent): void;
  41636. /**
  41637. * Called each time a new POINTERUP event occurs. Ie, for each button
  41638. * release.
  41639. */
  41640. protected onButtonUp(evt: PointerEvent): void;
  41641. /**
  41642. * Called when window becomes inactive.
  41643. */
  41644. protected onLostFocus(): void;
  41645. }
  41646. }
  41647. declare module BABYLON {
  41648. /**
  41649. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41651. */
  41652. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41653. /**
  41654. * Defines the camera the input is attached to.
  41655. */
  41656. camera: ArcRotateCamera;
  41657. /**
  41658. * Defines the list of key codes associated with the up action (increase alpha)
  41659. */
  41660. keysUp: number[];
  41661. /**
  41662. * Defines the list of key codes associated with the down action (decrease alpha)
  41663. */
  41664. keysDown: number[];
  41665. /**
  41666. * Defines the list of key codes associated with the left action (increase beta)
  41667. */
  41668. keysLeft: number[];
  41669. /**
  41670. * Defines the list of key codes associated with the right action (decrease beta)
  41671. */
  41672. keysRight: number[];
  41673. /**
  41674. * Defines the list of key codes associated with the reset action.
  41675. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41676. */
  41677. keysReset: number[];
  41678. /**
  41679. * Defines the panning sensibility of the inputs.
  41680. * (How fast is the camera panning)
  41681. */
  41682. panningSensibility: number;
  41683. /**
  41684. * Defines the zooming sensibility of the inputs.
  41685. * (How fast is the camera zooming)
  41686. */
  41687. zoomingSensibility: number;
  41688. /**
  41689. * Defines whether maintaining the alt key down switch the movement mode from
  41690. * orientation to zoom.
  41691. */
  41692. useAltToZoom: boolean;
  41693. /**
  41694. * Rotation speed of the camera
  41695. */
  41696. angularSpeed: number;
  41697. private _keys;
  41698. private _ctrlPressed;
  41699. private _altPressed;
  41700. private _onCanvasBlurObserver;
  41701. private _onKeyboardObserver;
  41702. private _engine;
  41703. private _scene;
  41704. /**
  41705. * Attach the input controls to a specific dom element to get the input from.
  41706. * @param element Defines the element the controls should be listened from
  41707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41708. */
  41709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41710. /**
  41711. * Detach the current controls from the specified dom element.
  41712. * @param element Defines the element to stop listening the inputs from
  41713. */
  41714. detachControl(element: Nullable<HTMLElement>): void;
  41715. /**
  41716. * Update the current camera state depending on the inputs that have been used this frame.
  41717. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41718. */
  41719. checkInputs(): void;
  41720. /**
  41721. * Gets the class name of the current intput.
  41722. * @returns the class name
  41723. */
  41724. getClassName(): string;
  41725. /**
  41726. * Get the friendly name associated with the input class.
  41727. * @returns the input friendly name
  41728. */
  41729. getSimpleName(): string;
  41730. }
  41731. }
  41732. declare module BABYLON {
  41733. /**
  41734. * Manage the mouse wheel inputs to control an arc rotate camera.
  41735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41736. */
  41737. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41738. /**
  41739. * Defines the camera the input is attached to.
  41740. */
  41741. camera: ArcRotateCamera;
  41742. /**
  41743. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41744. */
  41745. wheelPrecision: number;
  41746. /**
  41747. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41748. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41749. */
  41750. wheelDeltaPercentage: number;
  41751. private _wheel;
  41752. private _observer;
  41753. private computeDeltaFromMouseWheelLegacyEvent;
  41754. /**
  41755. * Attach the input controls to a specific dom element to get the input from.
  41756. * @param element Defines the element the controls should be listened from
  41757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41758. */
  41759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41760. /**
  41761. * Detach the current controls from the specified dom element.
  41762. * @param element Defines the element to stop listening the inputs from
  41763. */
  41764. detachControl(element: Nullable<HTMLElement>): void;
  41765. /**
  41766. * Gets the class name of the current intput.
  41767. * @returns the class name
  41768. */
  41769. getClassName(): string;
  41770. /**
  41771. * Get the friendly name associated with the input class.
  41772. * @returns the input friendly name
  41773. */
  41774. getSimpleName(): string;
  41775. }
  41776. }
  41777. declare module BABYLON {
  41778. /**
  41779. * Default Inputs manager for the ArcRotateCamera.
  41780. * It groups all the default supported inputs for ease of use.
  41781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41782. */
  41783. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41784. /**
  41785. * Instantiates a new ArcRotateCameraInputsManager.
  41786. * @param camera Defines the camera the inputs belong to
  41787. */
  41788. constructor(camera: ArcRotateCamera);
  41789. /**
  41790. * Add mouse wheel input support to the input manager.
  41791. * @returns the current input manager
  41792. */
  41793. addMouseWheel(): ArcRotateCameraInputsManager;
  41794. /**
  41795. * Add pointers input support to the input manager.
  41796. * @returns the current input manager
  41797. */
  41798. addPointers(): ArcRotateCameraInputsManager;
  41799. /**
  41800. * Add keyboard input support to the input manager.
  41801. * @returns the current input manager
  41802. */
  41803. addKeyboard(): ArcRotateCameraInputsManager;
  41804. }
  41805. }
  41806. declare module BABYLON {
  41807. /**
  41808. * This represents an orbital type of camera.
  41809. *
  41810. * 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.
  41811. * 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.
  41812. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41813. */
  41814. export class ArcRotateCamera extends TargetCamera {
  41815. /**
  41816. * Defines the rotation angle of the camera along the longitudinal axis.
  41817. */
  41818. alpha: number;
  41819. /**
  41820. * Defines the rotation angle of the camera along the latitudinal axis.
  41821. */
  41822. beta: number;
  41823. /**
  41824. * Defines the radius of the camera from it s target point.
  41825. */
  41826. radius: number;
  41827. protected _target: Vector3;
  41828. protected _targetHost: Nullable<AbstractMesh>;
  41829. /**
  41830. * Defines the target point of the camera.
  41831. * The camera looks towards it form the radius distance.
  41832. */
  41833. get target(): Vector3;
  41834. set target(value: Vector3);
  41835. /**
  41836. * Define the current local position of the camera in the scene
  41837. */
  41838. get position(): Vector3;
  41839. set position(newPosition: Vector3);
  41840. protected _upVector: Vector3;
  41841. protected _upToYMatrix: Matrix;
  41842. protected _YToUpMatrix: Matrix;
  41843. /**
  41844. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41845. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41846. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41847. */
  41848. set upVector(vec: Vector3);
  41849. get upVector(): Vector3;
  41850. /**
  41851. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41852. */
  41853. setMatUp(): void;
  41854. /**
  41855. * Current inertia value on the longitudinal axis.
  41856. * The bigger this number the longer it will take for the camera to stop.
  41857. */
  41858. inertialAlphaOffset: number;
  41859. /**
  41860. * Current inertia value on the latitudinal axis.
  41861. * The bigger this number the longer it will take for the camera to stop.
  41862. */
  41863. inertialBetaOffset: number;
  41864. /**
  41865. * Current inertia value on the radius axis.
  41866. * The bigger this number the longer it will take for the camera to stop.
  41867. */
  41868. inertialRadiusOffset: number;
  41869. /**
  41870. * Minimum allowed angle on the longitudinal axis.
  41871. * This can help limiting how the Camera is able to move in the scene.
  41872. */
  41873. lowerAlphaLimit: Nullable<number>;
  41874. /**
  41875. * Maximum allowed angle on the longitudinal axis.
  41876. * This can help limiting how the Camera is able to move in the scene.
  41877. */
  41878. upperAlphaLimit: Nullable<number>;
  41879. /**
  41880. * Minimum allowed angle on the latitudinal axis.
  41881. * This can help limiting how the Camera is able to move in the scene.
  41882. */
  41883. lowerBetaLimit: number;
  41884. /**
  41885. * Maximum allowed angle on the latitudinal axis.
  41886. * This can help limiting how the Camera is able to move in the scene.
  41887. */
  41888. upperBetaLimit: number;
  41889. /**
  41890. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41891. * This can help limiting how the Camera is able to move in the scene.
  41892. */
  41893. lowerRadiusLimit: Nullable<number>;
  41894. /**
  41895. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41896. * This can help limiting how the Camera is able to move in the scene.
  41897. */
  41898. upperRadiusLimit: Nullable<number>;
  41899. /**
  41900. * Defines the current inertia value used during panning of the camera along the X axis.
  41901. */
  41902. inertialPanningX: number;
  41903. /**
  41904. * Defines the current inertia value used during panning of the camera along the Y axis.
  41905. */
  41906. inertialPanningY: number;
  41907. /**
  41908. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41909. * Basically if your fingers moves away from more than this distance you will be considered
  41910. * in pinch mode.
  41911. */
  41912. pinchToPanMaxDistance: number;
  41913. /**
  41914. * Defines the maximum distance the camera can pan.
  41915. * This could help keeping the cammera always in your scene.
  41916. */
  41917. panningDistanceLimit: Nullable<number>;
  41918. /**
  41919. * Defines the target of the camera before paning.
  41920. */
  41921. panningOriginTarget: Vector3;
  41922. /**
  41923. * Defines the value of the inertia used during panning.
  41924. * 0 would mean stop inertia and one would mean no decelleration at all.
  41925. */
  41926. panningInertia: number;
  41927. /**
  41928. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41929. */
  41930. get angularSensibilityX(): number;
  41931. set angularSensibilityX(value: number);
  41932. /**
  41933. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41934. */
  41935. get angularSensibilityY(): number;
  41936. set angularSensibilityY(value: number);
  41937. /**
  41938. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41939. */
  41940. get pinchPrecision(): number;
  41941. set pinchPrecision(value: number);
  41942. /**
  41943. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41944. * It will be used instead of pinchDeltaPrecision if different from 0.
  41945. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41946. */
  41947. get pinchDeltaPercentage(): number;
  41948. set pinchDeltaPercentage(value: number);
  41949. /**
  41950. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41951. * and pinch delta percentage.
  41952. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41953. * that any object in the plane at the camera's target point will scale
  41954. * perfectly with finger motion.
  41955. */
  41956. get useNaturalPinchZoom(): boolean;
  41957. set useNaturalPinchZoom(value: boolean);
  41958. /**
  41959. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41960. */
  41961. get panningSensibility(): number;
  41962. set panningSensibility(value: number);
  41963. /**
  41964. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41965. */
  41966. get keysUp(): number[];
  41967. set keysUp(value: number[]);
  41968. /**
  41969. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41970. */
  41971. get keysDown(): number[];
  41972. set keysDown(value: number[]);
  41973. /**
  41974. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41975. */
  41976. get keysLeft(): number[];
  41977. set keysLeft(value: number[]);
  41978. /**
  41979. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41980. */
  41981. get keysRight(): number[];
  41982. set keysRight(value: number[]);
  41983. /**
  41984. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41985. */
  41986. get wheelPrecision(): number;
  41987. set wheelPrecision(value: number);
  41988. /**
  41989. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41990. * It will be used instead of pinchDeltaPrecision if different from 0.
  41991. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41992. */
  41993. get wheelDeltaPercentage(): number;
  41994. set wheelDeltaPercentage(value: number);
  41995. /**
  41996. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41997. */
  41998. zoomOnFactor: number;
  41999. /**
  42000. * Defines a screen offset for the camera position.
  42001. */
  42002. targetScreenOffset: Vector2;
  42003. /**
  42004. * Allows the camera to be completely reversed.
  42005. * If false the camera can not arrive upside down.
  42006. */
  42007. allowUpsideDown: boolean;
  42008. /**
  42009. * Define if double tap/click is used to restore the previously saved state of the camera.
  42010. */
  42011. useInputToRestoreState: boolean;
  42012. /** @hidden */
  42013. _viewMatrix: Matrix;
  42014. /** @hidden */
  42015. _useCtrlForPanning: boolean;
  42016. /** @hidden */
  42017. _panningMouseButton: number;
  42018. /**
  42019. * Defines the input associated to the camera.
  42020. */
  42021. inputs: ArcRotateCameraInputsManager;
  42022. /** @hidden */
  42023. _reset: () => void;
  42024. /**
  42025. * Defines the allowed panning axis.
  42026. */
  42027. panningAxis: Vector3;
  42028. protected _localDirection: Vector3;
  42029. protected _transformedDirection: Vector3;
  42030. private _bouncingBehavior;
  42031. /**
  42032. * Gets the bouncing behavior of the camera if it has been enabled.
  42033. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42034. */
  42035. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42036. /**
  42037. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42038. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42039. */
  42040. get useBouncingBehavior(): boolean;
  42041. set useBouncingBehavior(value: boolean);
  42042. private _framingBehavior;
  42043. /**
  42044. * Gets the framing behavior of the camera if it has been enabled.
  42045. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42046. */
  42047. get framingBehavior(): Nullable<FramingBehavior>;
  42048. /**
  42049. * Defines if the framing behavior of the camera is enabled on the camera.
  42050. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42051. */
  42052. get useFramingBehavior(): boolean;
  42053. set useFramingBehavior(value: boolean);
  42054. private _autoRotationBehavior;
  42055. /**
  42056. * Gets the auto rotation behavior of the camera if it has been enabled.
  42057. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42058. */
  42059. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42060. /**
  42061. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42062. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42063. */
  42064. get useAutoRotationBehavior(): boolean;
  42065. set useAutoRotationBehavior(value: boolean);
  42066. /**
  42067. * Observable triggered when the mesh target has been changed on the camera.
  42068. */
  42069. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42070. /**
  42071. * Event raised when the camera is colliding with a mesh.
  42072. */
  42073. onCollide: (collidedMesh: AbstractMesh) => void;
  42074. /**
  42075. * Defines whether the camera should check collision with the objects oh the scene.
  42076. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42077. */
  42078. checkCollisions: boolean;
  42079. /**
  42080. * Defines the collision radius of the camera.
  42081. * This simulates a sphere around the camera.
  42082. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42083. */
  42084. collisionRadius: Vector3;
  42085. protected _collider: Collider;
  42086. protected _previousPosition: Vector3;
  42087. protected _collisionVelocity: Vector3;
  42088. protected _newPosition: Vector3;
  42089. protected _previousAlpha: number;
  42090. protected _previousBeta: number;
  42091. protected _previousRadius: number;
  42092. protected _collisionTriggered: boolean;
  42093. protected _targetBoundingCenter: Nullable<Vector3>;
  42094. private _computationVector;
  42095. /**
  42096. * Instantiates a new ArcRotateCamera in a given scene
  42097. * @param name Defines the name of the camera
  42098. * @param alpha Defines the camera rotation along the logitudinal axis
  42099. * @param beta Defines the camera rotation along the latitudinal axis
  42100. * @param radius Defines the camera distance from its target
  42101. * @param target Defines the camera target
  42102. * @param scene Defines the scene the camera belongs to
  42103. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42104. */
  42105. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42106. /** @hidden */
  42107. _initCache(): void;
  42108. /** @hidden */
  42109. _updateCache(ignoreParentClass?: boolean): void;
  42110. protected _getTargetPosition(): Vector3;
  42111. private _storedAlpha;
  42112. private _storedBeta;
  42113. private _storedRadius;
  42114. private _storedTarget;
  42115. private _storedTargetScreenOffset;
  42116. /**
  42117. * Stores the current state of the camera (alpha, beta, radius and target)
  42118. * @returns the camera itself
  42119. */
  42120. storeState(): Camera;
  42121. /**
  42122. * @hidden
  42123. * Restored camera state. You must call storeState() first
  42124. */
  42125. _restoreStateValues(): boolean;
  42126. /** @hidden */
  42127. _isSynchronizedViewMatrix(): boolean;
  42128. /**
  42129. * Attached controls to the current camera.
  42130. * @param element Defines the element the controls should be listened from
  42131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42132. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42133. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42134. */
  42135. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42136. /**
  42137. * Detach the current controls from the camera.
  42138. * The camera will stop reacting to inputs.
  42139. * @param element Defines the element to stop listening the inputs from
  42140. */
  42141. detachControl(element: HTMLElement): void;
  42142. /** @hidden */
  42143. _checkInputs(): void;
  42144. protected _checkLimits(): void;
  42145. /**
  42146. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42147. */
  42148. rebuildAnglesAndRadius(): void;
  42149. /**
  42150. * Use a position to define the current camera related information like alpha, beta and radius
  42151. * @param position Defines the position to set the camera at
  42152. */
  42153. setPosition(position: Vector3): void;
  42154. /**
  42155. * Defines the target the camera should look at.
  42156. * This will automatically adapt alpha beta and radius to fit within the new target.
  42157. * @param target Defines the new target as a Vector or a mesh
  42158. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42159. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42160. */
  42161. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42162. /** @hidden */
  42163. _getViewMatrix(): Matrix;
  42164. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42165. /**
  42166. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42167. * @param meshes Defines the mesh to zoom 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. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42171. /**
  42172. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42173. * The target will be changed but the radius
  42174. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42175. * @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)
  42176. */
  42177. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42178. min: Vector3;
  42179. max: Vector3;
  42180. distance: number;
  42181. }, doNotUpdateMaxZ?: boolean): void;
  42182. /**
  42183. * @override
  42184. * Override Camera.createRigCamera
  42185. */
  42186. createRigCamera(name: string, cameraIndex: number): Camera;
  42187. /**
  42188. * @hidden
  42189. * @override
  42190. * Override Camera._updateRigCameras
  42191. */
  42192. _updateRigCameras(): void;
  42193. /**
  42194. * Destroy the camera and release the current resources hold by it.
  42195. */
  42196. dispose(): void;
  42197. /**
  42198. * Gets the current object class name.
  42199. * @return the class name
  42200. */
  42201. getClassName(): string;
  42202. }
  42203. }
  42204. declare module BABYLON {
  42205. /**
  42206. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42207. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42208. */
  42209. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42210. /**
  42211. * Gets the name of the behavior.
  42212. */
  42213. get name(): string;
  42214. private _zoomStopsAnimation;
  42215. private _idleRotationSpeed;
  42216. private _idleRotationWaitTime;
  42217. private _idleRotationSpinupTime;
  42218. /**
  42219. * Sets the flag that indicates if user zooming should stop animation.
  42220. */
  42221. set zoomStopsAnimation(flag: boolean);
  42222. /**
  42223. * Gets the flag that indicates if user zooming should stop animation.
  42224. */
  42225. get zoomStopsAnimation(): boolean;
  42226. /**
  42227. * Sets the default speed at which the camera rotates around the model.
  42228. */
  42229. set idleRotationSpeed(speed: number);
  42230. /**
  42231. * Gets the default speed at which the camera rotates around the model.
  42232. */
  42233. get idleRotationSpeed(): number;
  42234. /**
  42235. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42236. */
  42237. set idleRotationWaitTime(time: number);
  42238. /**
  42239. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42240. */
  42241. get idleRotationWaitTime(): number;
  42242. /**
  42243. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42244. */
  42245. set idleRotationSpinupTime(time: number);
  42246. /**
  42247. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42248. */
  42249. get idleRotationSpinupTime(): number;
  42250. /**
  42251. * Gets a value indicating if the camera is currently rotating because of this behavior
  42252. */
  42253. get rotationInProgress(): boolean;
  42254. private _onPrePointerObservableObserver;
  42255. private _onAfterCheckInputsObserver;
  42256. private _attachedCamera;
  42257. private _isPointerDown;
  42258. private _lastFrameTime;
  42259. private _lastInteractionTime;
  42260. private _cameraRotationSpeed;
  42261. /**
  42262. * Initializes the behavior.
  42263. */
  42264. init(): void;
  42265. /**
  42266. * Attaches the behavior to its arc rotate camera.
  42267. * @param camera Defines the camera to attach the behavior to
  42268. */
  42269. attach(camera: ArcRotateCamera): void;
  42270. /**
  42271. * Detaches the behavior from its current arc rotate camera.
  42272. */
  42273. detach(): void;
  42274. /**
  42275. * Returns true if user is scrolling.
  42276. * @return true if user is scrolling.
  42277. */
  42278. private _userIsZooming;
  42279. private _lastFrameRadius;
  42280. private _shouldAnimationStopForInteraction;
  42281. /**
  42282. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42283. */
  42284. private _applyUserInteraction;
  42285. private _userIsMoving;
  42286. }
  42287. }
  42288. declare module BABYLON {
  42289. /**
  42290. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42291. */
  42292. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42293. private ui;
  42294. /**
  42295. * The name of the behavior
  42296. */
  42297. name: string;
  42298. /**
  42299. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42300. */
  42301. distanceAwayFromFace: number;
  42302. /**
  42303. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42304. */
  42305. distanceAwayFromBottomOfFace: number;
  42306. private _faceVectors;
  42307. private _target;
  42308. private _scene;
  42309. private _onRenderObserver;
  42310. private _tmpMatrix;
  42311. private _tmpVector;
  42312. /**
  42313. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42314. * @param ui The transform node that should be attched to the mesh
  42315. */
  42316. constructor(ui: TransformNode);
  42317. /**
  42318. * Initializes the behavior
  42319. */
  42320. init(): void;
  42321. private _closestFace;
  42322. private _zeroVector;
  42323. private _lookAtTmpMatrix;
  42324. private _lookAtToRef;
  42325. /**
  42326. * Attaches the AttachToBoxBehavior to the passed in mesh
  42327. * @param target The mesh that the specified node will be attached to
  42328. */
  42329. attach(target: Mesh): void;
  42330. /**
  42331. * Detaches the behavior from the mesh
  42332. */
  42333. detach(): void;
  42334. }
  42335. }
  42336. declare module BABYLON {
  42337. /**
  42338. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42339. */
  42340. export class FadeInOutBehavior implements Behavior<Mesh> {
  42341. /**
  42342. * Time in milliseconds to delay before fading in (Default: 0)
  42343. */
  42344. delay: number;
  42345. /**
  42346. * Time in milliseconds for the mesh to fade in (Default: 300)
  42347. */
  42348. fadeInTime: number;
  42349. private _millisecondsPerFrame;
  42350. private _hovered;
  42351. private _hoverValue;
  42352. private _ownerNode;
  42353. /**
  42354. * Instatiates the FadeInOutBehavior
  42355. */
  42356. constructor();
  42357. /**
  42358. * The name of the behavior
  42359. */
  42360. get name(): string;
  42361. /**
  42362. * Initializes the behavior
  42363. */
  42364. init(): void;
  42365. /**
  42366. * Attaches the fade behavior on the passed in mesh
  42367. * @param ownerNode The mesh that will be faded in/out once attached
  42368. */
  42369. attach(ownerNode: Mesh): void;
  42370. /**
  42371. * Detaches the behavior from the mesh
  42372. */
  42373. detach(): void;
  42374. /**
  42375. * Triggers the mesh to begin fading in or out
  42376. * @param value if the object should fade in or out (true to fade in)
  42377. */
  42378. fadeIn(value: boolean): void;
  42379. private _update;
  42380. private _setAllVisibility;
  42381. }
  42382. }
  42383. declare module BABYLON {
  42384. /**
  42385. * Class containing a set of static utilities functions for managing Pivots
  42386. * @hidden
  42387. */
  42388. export class PivotTools {
  42389. private static _PivotCached;
  42390. private static _OldPivotPoint;
  42391. private static _PivotTranslation;
  42392. private static _PivotTmpVector;
  42393. /** @hidden */
  42394. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42395. /** @hidden */
  42396. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42397. }
  42398. }
  42399. declare module BABYLON {
  42400. /**
  42401. * Class containing static functions to help procedurally build meshes
  42402. */
  42403. export class PlaneBuilder {
  42404. /**
  42405. * Creates a plane mesh
  42406. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42407. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42408. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42410. * * 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
  42411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42412. * @param name defines the name of the mesh
  42413. * @param options defines the options used to create the mesh
  42414. * @param scene defines the hosting scene
  42415. * @returns the plane mesh
  42416. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42417. */
  42418. static CreatePlane(name: string, options: {
  42419. size?: number;
  42420. width?: number;
  42421. height?: number;
  42422. sideOrientation?: number;
  42423. frontUVs?: Vector4;
  42424. backUVs?: Vector4;
  42425. updatable?: boolean;
  42426. sourcePlane?: Plane;
  42427. }, scene?: Nullable<Scene>): Mesh;
  42428. }
  42429. }
  42430. declare module BABYLON {
  42431. /**
  42432. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42433. */
  42434. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42435. private static _AnyMouseID;
  42436. /**
  42437. * Abstract mesh the behavior is set on
  42438. */
  42439. attachedNode: AbstractMesh;
  42440. private _dragPlane;
  42441. private _scene;
  42442. private _pointerObserver;
  42443. private _beforeRenderObserver;
  42444. private static _planeScene;
  42445. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42446. /**
  42447. * 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)
  42448. */
  42449. maxDragAngle: number;
  42450. /**
  42451. * @hidden
  42452. */
  42453. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42454. /**
  42455. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42456. */
  42457. currentDraggingPointerID: number;
  42458. /**
  42459. * The last position where the pointer hit the drag plane in world space
  42460. */
  42461. lastDragPosition: Vector3;
  42462. /**
  42463. * If the behavior is currently in a dragging state
  42464. */
  42465. dragging: boolean;
  42466. /**
  42467. * 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)
  42468. */
  42469. dragDeltaRatio: number;
  42470. /**
  42471. * If the drag plane orientation should be updated during the dragging (Default: true)
  42472. */
  42473. updateDragPlane: boolean;
  42474. private _debugMode;
  42475. private _moving;
  42476. /**
  42477. * Fires each time the attached mesh is dragged with the pointer
  42478. * * delta between last drag position and current drag position in world space
  42479. * * dragDistance along the drag axis
  42480. * * dragPlaneNormal normal of the current drag plane used during the drag
  42481. * * dragPlanePoint in world space where the drag intersects the drag plane
  42482. */
  42483. onDragObservable: Observable<{
  42484. delta: Vector3;
  42485. dragPlanePoint: Vector3;
  42486. dragPlaneNormal: Vector3;
  42487. dragDistance: number;
  42488. pointerId: number;
  42489. }>;
  42490. /**
  42491. * Fires each time a drag begins (eg. mouse down on mesh)
  42492. */
  42493. onDragStartObservable: Observable<{
  42494. dragPlanePoint: Vector3;
  42495. pointerId: number;
  42496. }>;
  42497. /**
  42498. * Fires each time a drag ends (eg. mouse release after drag)
  42499. */
  42500. onDragEndObservable: Observable<{
  42501. dragPlanePoint: Vector3;
  42502. pointerId: number;
  42503. }>;
  42504. /**
  42505. * If the attached mesh should be moved when dragged
  42506. */
  42507. moveAttached: boolean;
  42508. /**
  42509. * If the drag behavior will react to drag events (Default: true)
  42510. */
  42511. enabled: boolean;
  42512. /**
  42513. * If pointer events should start and release the drag (Default: true)
  42514. */
  42515. startAndReleaseDragOnPointerEvents: boolean;
  42516. /**
  42517. * If camera controls should be detached during the drag
  42518. */
  42519. detachCameraControls: boolean;
  42520. /**
  42521. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42522. */
  42523. useObjectOrientationForDragging: boolean;
  42524. private _options;
  42525. /**
  42526. * Gets the options used by the behavior
  42527. */
  42528. get options(): {
  42529. dragAxis?: Vector3;
  42530. dragPlaneNormal?: Vector3;
  42531. };
  42532. /**
  42533. * Sets the options used by the behavior
  42534. */
  42535. set options(options: {
  42536. dragAxis?: Vector3;
  42537. dragPlaneNormal?: Vector3;
  42538. });
  42539. /**
  42540. * Creates a pointer drag behavior that can be attached to a mesh
  42541. * @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)
  42542. */
  42543. constructor(options?: {
  42544. dragAxis?: Vector3;
  42545. dragPlaneNormal?: Vector3;
  42546. });
  42547. /**
  42548. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42549. */
  42550. validateDrag: (targetPosition: Vector3) => boolean;
  42551. /**
  42552. * The name of the behavior
  42553. */
  42554. get name(): string;
  42555. /**
  42556. * Initializes the behavior
  42557. */
  42558. init(): void;
  42559. private _tmpVector;
  42560. private _alternatePickedPoint;
  42561. private _worldDragAxis;
  42562. private _targetPosition;
  42563. private _attachedElement;
  42564. /**
  42565. * Attaches the drag behavior the passed in mesh
  42566. * @param ownerNode The mesh that will be dragged around once attached
  42567. * @param predicate Predicate to use for pick filtering
  42568. */
  42569. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42570. /**
  42571. * Force relase the drag action by code.
  42572. */
  42573. releaseDrag(): void;
  42574. private _startDragRay;
  42575. private _lastPointerRay;
  42576. /**
  42577. * Simulates the start of a pointer drag event on the behavior
  42578. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42579. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42580. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42581. */
  42582. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42583. private _startDrag;
  42584. private _dragDelta;
  42585. private _moveDrag;
  42586. private _pickWithRayOnDragPlane;
  42587. private _pointA;
  42588. private _pointB;
  42589. private _pointC;
  42590. private _lineA;
  42591. private _lineB;
  42592. private _localAxis;
  42593. private _lookAt;
  42594. private _updateDragPlanePosition;
  42595. /**
  42596. * Detaches the behavior from the mesh
  42597. */
  42598. detach(): void;
  42599. }
  42600. }
  42601. declare module BABYLON {
  42602. /**
  42603. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42604. */
  42605. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42606. private _dragBehaviorA;
  42607. private _dragBehaviorB;
  42608. private _startDistance;
  42609. private _initialScale;
  42610. private _targetScale;
  42611. private _ownerNode;
  42612. private _sceneRenderObserver;
  42613. /**
  42614. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42615. */
  42616. constructor();
  42617. /**
  42618. * The name of the behavior
  42619. */
  42620. get name(): string;
  42621. /**
  42622. * Initializes the behavior
  42623. */
  42624. init(): void;
  42625. private _getCurrentDistance;
  42626. /**
  42627. * Attaches the scale behavior the passed in mesh
  42628. * @param ownerNode The mesh that will be scaled around once attached
  42629. */
  42630. attach(ownerNode: Mesh): void;
  42631. /**
  42632. * Detaches the behavior from the mesh
  42633. */
  42634. detach(): void;
  42635. }
  42636. }
  42637. declare module BABYLON {
  42638. /**
  42639. * 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
  42640. */
  42641. export class SixDofDragBehavior implements Behavior<Mesh> {
  42642. private static _virtualScene;
  42643. private _ownerNode;
  42644. private _sceneRenderObserver;
  42645. private _scene;
  42646. private _targetPosition;
  42647. private _virtualOriginMesh;
  42648. private _virtualDragMesh;
  42649. private _pointerObserver;
  42650. private _moving;
  42651. private _startingOrientation;
  42652. private _attachedElement;
  42653. /**
  42654. * 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)
  42655. */
  42656. private zDragFactor;
  42657. /**
  42658. * If the object should rotate to face the drag origin
  42659. */
  42660. rotateDraggedObject: boolean;
  42661. /**
  42662. * If the behavior is currently in a dragging state
  42663. */
  42664. dragging: boolean;
  42665. /**
  42666. * 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)
  42667. */
  42668. dragDeltaRatio: number;
  42669. /**
  42670. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42671. */
  42672. currentDraggingPointerID: number;
  42673. /**
  42674. * If camera controls should be detached during the drag
  42675. */
  42676. detachCameraControls: boolean;
  42677. /**
  42678. * Fires each time a drag starts
  42679. */
  42680. onDragStartObservable: Observable<{}>;
  42681. /**
  42682. * Fires each time a drag ends (eg. mouse release after drag)
  42683. */
  42684. onDragEndObservable: Observable<{}>;
  42685. /**
  42686. * 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
  42687. */
  42688. constructor();
  42689. /**
  42690. * The name of the behavior
  42691. */
  42692. get name(): string;
  42693. /**
  42694. * Initializes the behavior
  42695. */
  42696. init(): void;
  42697. /**
  42698. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42699. */
  42700. private get _pointerCamera();
  42701. /**
  42702. * Attaches the scale behavior the passed in mesh
  42703. * @param ownerNode The mesh that will be scaled around once attached
  42704. */
  42705. attach(ownerNode: Mesh): void;
  42706. /**
  42707. * Detaches the behavior from the mesh
  42708. */
  42709. detach(): void;
  42710. }
  42711. }
  42712. declare module BABYLON {
  42713. /**
  42714. * Class used to apply inverse kinematics to bones
  42715. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42716. */
  42717. export class BoneIKController {
  42718. private static _tmpVecs;
  42719. private static _tmpQuat;
  42720. private static _tmpMats;
  42721. /**
  42722. * Gets or sets the target mesh
  42723. */
  42724. targetMesh: AbstractMesh;
  42725. /** Gets or sets the mesh used as pole */
  42726. poleTargetMesh: AbstractMesh;
  42727. /**
  42728. * Gets or sets the bone used as pole
  42729. */
  42730. poleTargetBone: Nullable<Bone>;
  42731. /**
  42732. * Gets or sets the target position
  42733. */
  42734. targetPosition: Vector3;
  42735. /**
  42736. * Gets or sets the pole target position
  42737. */
  42738. poleTargetPosition: Vector3;
  42739. /**
  42740. * Gets or sets the pole target local offset
  42741. */
  42742. poleTargetLocalOffset: Vector3;
  42743. /**
  42744. * Gets or sets the pole angle
  42745. */
  42746. poleAngle: number;
  42747. /**
  42748. * Gets or sets the mesh associated with the controller
  42749. */
  42750. mesh: AbstractMesh;
  42751. /**
  42752. * 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)
  42753. */
  42754. slerpAmount: number;
  42755. private _bone1Quat;
  42756. private _bone1Mat;
  42757. private _bone2Ang;
  42758. private _bone1;
  42759. private _bone2;
  42760. private _bone1Length;
  42761. private _bone2Length;
  42762. private _maxAngle;
  42763. private _maxReach;
  42764. private _rightHandedSystem;
  42765. private _bendAxis;
  42766. private _slerping;
  42767. private _adjustRoll;
  42768. /**
  42769. * Gets or sets maximum allowed angle
  42770. */
  42771. get maxAngle(): number;
  42772. set maxAngle(value: number);
  42773. /**
  42774. * Creates a new BoneIKController
  42775. * @param mesh defines the mesh to control
  42776. * @param bone defines the bone to control
  42777. * @param options defines options to set up the controller
  42778. */
  42779. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42780. targetMesh?: AbstractMesh;
  42781. poleTargetMesh?: AbstractMesh;
  42782. poleTargetBone?: Bone;
  42783. poleTargetLocalOffset?: Vector3;
  42784. poleAngle?: number;
  42785. bendAxis?: Vector3;
  42786. maxAngle?: number;
  42787. slerpAmount?: number;
  42788. });
  42789. private _setMaxAngle;
  42790. /**
  42791. * Force the controller to update the bones
  42792. */
  42793. update(): void;
  42794. }
  42795. }
  42796. declare module BABYLON {
  42797. /**
  42798. * Class used to make a bone look toward a point in space
  42799. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42800. */
  42801. export class BoneLookController {
  42802. private static _tmpVecs;
  42803. private static _tmpQuat;
  42804. private static _tmpMats;
  42805. /**
  42806. * The target Vector3 that the bone will look at
  42807. */
  42808. target: Vector3;
  42809. /**
  42810. * The mesh that the bone is attached to
  42811. */
  42812. mesh: AbstractMesh;
  42813. /**
  42814. * The bone that will be looking to the target
  42815. */
  42816. bone: Bone;
  42817. /**
  42818. * The up axis of the coordinate system that is used when the bone is rotated
  42819. */
  42820. upAxis: Vector3;
  42821. /**
  42822. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42823. */
  42824. upAxisSpace: Space;
  42825. /**
  42826. * Used to make an adjustment to the yaw of the bone
  42827. */
  42828. adjustYaw: number;
  42829. /**
  42830. * Used to make an adjustment to the pitch of the bone
  42831. */
  42832. adjustPitch: number;
  42833. /**
  42834. * Used to make an adjustment to the roll of the bone
  42835. */
  42836. adjustRoll: number;
  42837. /**
  42838. * 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)
  42839. */
  42840. slerpAmount: number;
  42841. private _minYaw;
  42842. private _maxYaw;
  42843. private _minPitch;
  42844. private _maxPitch;
  42845. private _minYawSin;
  42846. private _minYawCos;
  42847. private _maxYawSin;
  42848. private _maxYawCos;
  42849. private _midYawConstraint;
  42850. private _minPitchTan;
  42851. private _maxPitchTan;
  42852. private _boneQuat;
  42853. private _slerping;
  42854. private _transformYawPitch;
  42855. private _transformYawPitchInv;
  42856. private _firstFrameSkipped;
  42857. private _yawRange;
  42858. private _fowardAxis;
  42859. /**
  42860. * Gets or sets the minimum yaw angle that the bone can look to
  42861. */
  42862. get minYaw(): number;
  42863. set minYaw(value: number);
  42864. /**
  42865. * Gets or sets the maximum yaw angle that the bone can look to
  42866. */
  42867. get maxYaw(): number;
  42868. set maxYaw(value: number);
  42869. /**
  42870. * Gets or sets the minimum pitch angle that the bone can look to
  42871. */
  42872. get minPitch(): number;
  42873. set minPitch(value: number);
  42874. /**
  42875. * Gets or sets the maximum pitch angle that the bone can look to
  42876. */
  42877. get maxPitch(): number;
  42878. set maxPitch(value: number);
  42879. /**
  42880. * Create a BoneLookController
  42881. * @param mesh the mesh that the bone belongs to
  42882. * @param bone the bone that will be looking to the target
  42883. * @param target the target Vector3 to look at
  42884. * @param options optional settings:
  42885. * * maxYaw: the maximum angle the bone will yaw to
  42886. * * minYaw: the minimum angle the bone will yaw to
  42887. * * maxPitch: the maximum angle the bone will pitch to
  42888. * * minPitch: the minimum angle the bone will yaw to
  42889. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42890. * * upAxis: the up axis of the coordinate system
  42891. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42892. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42893. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42894. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42895. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42896. * * adjustRoll: used to make an adjustment to the roll of the bone
  42897. **/
  42898. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42899. maxYaw?: number;
  42900. minYaw?: number;
  42901. maxPitch?: number;
  42902. minPitch?: number;
  42903. slerpAmount?: number;
  42904. upAxis?: Vector3;
  42905. upAxisSpace?: Space;
  42906. yawAxis?: Vector3;
  42907. pitchAxis?: Vector3;
  42908. adjustYaw?: number;
  42909. adjustPitch?: number;
  42910. adjustRoll?: number;
  42911. });
  42912. /**
  42913. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42914. */
  42915. update(): void;
  42916. private _getAngleDiff;
  42917. private _getAngleBetween;
  42918. private _isAngleBetween;
  42919. }
  42920. }
  42921. declare module BABYLON {
  42922. /**
  42923. * Manage the gamepad inputs to control an arc rotate camera.
  42924. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42925. */
  42926. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42927. /**
  42928. * Defines the camera the input is attached to.
  42929. */
  42930. camera: ArcRotateCamera;
  42931. /**
  42932. * Defines the gamepad the input is gathering event from.
  42933. */
  42934. gamepad: Nullable<Gamepad>;
  42935. /**
  42936. * Defines the gamepad rotation sensiblity.
  42937. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42938. */
  42939. gamepadRotationSensibility: number;
  42940. /**
  42941. * Defines the gamepad move sensiblity.
  42942. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42943. */
  42944. gamepadMoveSensibility: number;
  42945. private _yAxisScale;
  42946. /**
  42947. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42948. */
  42949. get invertYAxis(): boolean;
  42950. set invertYAxis(value: boolean);
  42951. private _onGamepadConnectedObserver;
  42952. private _onGamepadDisconnectedObserver;
  42953. /**
  42954. * Attach the input controls to a specific dom element to get the input from.
  42955. * @param element Defines the element the controls should be listened from
  42956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42957. */
  42958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42959. /**
  42960. * Detach the current controls from the specified dom element.
  42961. * @param element Defines the element to stop listening the inputs from
  42962. */
  42963. detachControl(element: Nullable<HTMLElement>): void;
  42964. /**
  42965. * Update the current camera state depending on the inputs that have been used this frame.
  42966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42967. */
  42968. checkInputs(): void;
  42969. /**
  42970. * Gets the class name of the current intput.
  42971. * @returns the class name
  42972. */
  42973. getClassName(): string;
  42974. /**
  42975. * Get the friendly name associated with the input class.
  42976. * @returns the input friendly name
  42977. */
  42978. getSimpleName(): string;
  42979. }
  42980. }
  42981. declare module BABYLON {
  42982. interface ArcRotateCameraInputsManager {
  42983. /**
  42984. * Add orientation input support to the input manager.
  42985. * @returns the current input manager
  42986. */
  42987. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42988. }
  42989. /**
  42990. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42992. */
  42993. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42994. /**
  42995. * Defines the camera the input is attached to.
  42996. */
  42997. camera: ArcRotateCamera;
  42998. /**
  42999. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43000. */
  43001. alphaCorrection: number;
  43002. /**
  43003. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43004. */
  43005. gammaCorrection: number;
  43006. private _alpha;
  43007. private _gamma;
  43008. private _dirty;
  43009. private _deviceOrientationHandler;
  43010. /**
  43011. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43012. */
  43013. constructor();
  43014. /**
  43015. * Attach the input controls to a specific dom element to get the input from.
  43016. * @param element Defines the element the controls should be listened from
  43017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43018. */
  43019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43020. /** @hidden */
  43021. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43022. /**
  43023. * Update the current camera state depending on the inputs that have been used this frame.
  43024. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43025. */
  43026. checkInputs(): void;
  43027. /**
  43028. * Detach the current controls from the specified dom element.
  43029. * @param element Defines the element to stop listening the inputs from
  43030. */
  43031. detachControl(element: Nullable<HTMLElement>): void;
  43032. /**
  43033. * Gets the class name of the current intput.
  43034. * @returns the class name
  43035. */
  43036. getClassName(): string;
  43037. /**
  43038. * Get the friendly name associated with the input class.
  43039. * @returns the input friendly name
  43040. */
  43041. getSimpleName(): string;
  43042. }
  43043. }
  43044. declare module BABYLON {
  43045. /**
  43046. * Listen to mouse events to control the camera.
  43047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43048. */
  43049. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43050. /**
  43051. * Defines the camera the input is attached to.
  43052. */
  43053. camera: FlyCamera;
  43054. /**
  43055. * Defines if touch is enabled. (Default is true.)
  43056. */
  43057. touchEnabled: boolean;
  43058. /**
  43059. * Defines the buttons associated with the input to handle camera rotation.
  43060. */
  43061. buttons: number[];
  43062. /**
  43063. * Assign buttons for Yaw control.
  43064. */
  43065. buttonsYaw: number[];
  43066. /**
  43067. * Assign buttons for Pitch control.
  43068. */
  43069. buttonsPitch: number[];
  43070. /**
  43071. * Assign buttons for Roll control.
  43072. */
  43073. buttonsRoll: number[];
  43074. /**
  43075. * Detect if any button is being pressed while mouse is moved.
  43076. * -1 = Mouse locked.
  43077. * 0 = Left button.
  43078. * 1 = Middle Button.
  43079. * 2 = Right Button.
  43080. */
  43081. activeButton: number;
  43082. /**
  43083. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43084. * Higher values reduce its sensitivity.
  43085. */
  43086. angularSensibility: number;
  43087. private _mousemoveCallback;
  43088. private _observer;
  43089. private _rollObserver;
  43090. private previousPosition;
  43091. private noPreventDefault;
  43092. private element;
  43093. /**
  43094. * Listen to mouse events to control the camera.
  43095. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43097. */
  43098. constructor(touchEnabled?: boolean);
  43099. /**
  43100. * Attach the mouse control to the HTML DOM element.
  43101. * @param element Defines the element that listens to the input events.
  43102. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43103. */
  43104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43105. /**
  43106. * Detach the current controls from the specified dom element.
  43107. * @param element Defines the element to stop listening the inputs from
  43108. */
  43109. detachControl(element: Nullable<HTMLElement>): void;
  43110. /**
  43111. * Gets the class name of the current input.
  43112. * @returns the class name.
  43113. */
  43114. getClassName(): string;
  43115. /**
  43116. * Get the friendly name associated with the input class.
  43117. * @returns the input's friendly name.
  43118. */
  43119. getSimpleName(): string;
  43120. private _pointerInput;
  43121. private _onMouseMove;
  43122. /**
  43123. * Rotate camera by mouse offset.
  43124. */
  43125. private rotateCamera;
  43126. }
  43127. }
  43128. declare module BABYLON {
  43129. /**
  43130. * Default Inputs manager for the FlyCamera.
  43131. * It groups all the default supported inputs for ease of use.
  43132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43133. */
  43134. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43135. /**
  43136. * Instantiates a new FlyCameraInputsManager.
  43137. * @param camera Defines the camera the inputs belong to.
  43138. */
  43139. constructor(camera: FlyCamera);
  43140. /**
  43141. * Add keyboard input support to the input manager.
  43142. * @returns the new FlyCameraKeyboardMoveInput().
  43143. */
  43144. addKeyboard(): FlyCameraInputsManager;
  43145. /**
  43146. * Add mouse input support to the input manager.
  43147. * @param touchEnabled Enable touch screen support.
  43148. * @returns the new FlyCameraMouseInput().
  43149. */
  43150. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43151. }
  43152. }
  43153. declare module BABYLON {
  43154. /**
  43155. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43156. * such as in a 3D Space Shooter or a Flight Simulator.
  43157. */
  43158. export class FlyCamera extends TargetCamera {
  43159. /**
  43160. * Define the collision ellipsoid of the camera.
  43161. * This is helpful for simulating a camera body, like a player's body.
  43162. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43163. */
  43164. ellipsoid: Vector3;
  43165. /**
  43166. * Define an offset for the position of the ellipsoid around the camera.
  43167. * This can be helpful if the camera is attached away from the player's body center,
  43168. * such as at its head.
  43169. */
  43170. ellipsoidOffset: Vector3;
  43171. /**
  43172. * Enable or disable collisions of the camera with the rest of the scene objects.
  43173. */
  43174. checkCollisions: boolean;
  43175. /**
  43176. * Enable or disable gravity on the camera.
  43177. */
  43178. applyGravity: boolean;
  43179. /**
  43180. * Define the current direction the camera is moving to.
  43181. */
  43182. cameraDirection: Vector3;
  43183. /**
  43184. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43185. * This overrides and empties cameraRotation.
  43186. */
  43187. rotationQuaternion: Quaternion;
  43188. /**
  43189. * Track Roll to maintain the wanted Rolling when looking around.
  43190. */
  43191. _trackRoll: number;
  43192. /**
  43193. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43194. */
  43195. rollCorrect: number;
  43196. /**
  43197. * Mimic a banked turn, Rolling the camera when Yawing.
  43198. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43199. */
  43200. bankedTurn: boolean;
  43201. /**
  43202. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43203. */
  43204. bankedTurnLimit: number;
  43205. /**
  43206. * Value of 0 disables the banked Roll.
  43207. * Value of 1 is equal to the Yaw angle in radians.
  43208. */
  43209. bankedTurnMultiplier: number;
  43210. /**
  43211. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43212. */
  43213. inputs: FlyCameraInputsManager;
  43214. /**
  43215. * Gets the input sensibility for mouse input.
  43216. * Higher values reduce sensitivity.
  43217. */
  43218. get angularSensibility(): number;
  43219. /**
  43220. * Sets the input sensibility for a mouse input.
  43221. * Higher values reduce sensitivity.
  43222. */
  43223. set angularSensibility(value: number);
  43224. /**
  43225. * Get the keys for camera movement forward.
  43226. */
  43227. get keysForward(): number[];
  43228. /**
  43229. * Set the keys for camera movement forward.
  43230. */
  43231. set keysForward(value: number[]);
  43232. /**
  43233. * Get the keys for camera movement backward.
  43234. */
  43235. get keysBackward(): number[];
  43236. set keysBackward(value: number[]);
  43237. /**
  43238. * Get the keys for camera movement up.
  43239. */
  43240. get keysUp(): number[];
  43241. /**
  43242. * Set the keys for camera movement up.
  43243. */
  43244. set keysUp(value: number[]);
  43245. /**
  43246. * Get the keys for camera movement down.
  43247. */
  43248. get keysDown(): number[];
  43249. /**
  43250. * Set the keys for camera movement down.
  43251. */
  43252. set keysDown(value: number[]);
  43253. /**
  43254. * Get the keys for camera movement left.
  43255. */
  43256. get keysLeft(): number[];
  43257. /**
  43258. * Set the keys for camera movement left.
  43259. */
  43260. set keysLeft(value: number[]);
  43261. /**
  43262. * Set the keys for camera movement right.
  43263. */
  43264. get keysRight(): number[];
  43265. /**
  43266. * Set the keys for camera movement right.
  43267. */
  43268. set keysRight(value: number[]);
  43269. /**
  43270. * Event raised when the camera collides with a mesh in the scene.
  43271. */
  43272. onCollide: (collidedMesh: AbstractMesh) => void;
  43273. private _collider;
  43274. private _needMoveForGravity;
  43275. private _oldPosition;
  43276. private _diffPosition;
  43277. private _newPosition;
  43278. /** @hidden */
  43279. _localDirection: Vector3;
  43280. /** @hidden */
  43281. _transformedDirection: Vector3;
  43282. /**
  43283. * Instantiates a FlyCamera.
  43284. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43285. * such as in a 3D Space Shooter or a Flight Simulator.
  43286. * @param name Define the name of the camera in the scene.
  43287. * @param position Define the starting position of the camera in the scene.
  43288. * @param scene Define the scene the camera belongs to.
  43289. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43290. */
  43291. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43292. /**
  43293. * Attach a control to the HTML DOM element.
  43294. * @param element Defines the element that listens to the input events.
  43295. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43296. */
  43297. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43298. /**
  43299. * Detach a control from the HTML DOM element.
  43300. * The camera will stop reacting to that input.
  43301. * @param element Defines the element that listens to the input events.
  43302. */
  43303. detachControl(element: HTMLElement): void;
  43304. private _collisionMask;
  43305. /**
  43306. * Get the mask that the camera ignores in collision events.
  43307. */
  43308. get collisionMask(): number;
  43309. /**
  43310. * Set the mask that the camera ignores in collision events.
  43311. */
  43312. set collisionMask(mask: number);
  43313. /** @hidden */
  43314. _collideWithWorld(displacement: Vector3): void;
  43315. /** @hidden */
  43316. private _onCollisionPositionChange;
  43317. /** @hidden */
  43318. _checkInputs(): void;
  43319. /** @hidden */
  43320. _decideIfNeedsToMove(): boolean;
  43321. /** @hidden */
  43322. _updatePosition(): void;
  43323. /**
  43324. * Restore the Roll to its target value at the rate specified.
  43325. * @param rate - Higher means slower restoring.
  43326. * @hidden
  43327. */
  43328. restoreRoll(rate: number): void;
  43329. /**
  43330. * Destroy the camera and release the current resources held by it.
  43331. */
  43332. dispose(): void;
  43333. /**
  43334. * Get the current object class name.
  43335. * @returns the class name.
  43336. */
  43337. getClassName(): string;
  43338. }
  43339. }
  43340. declare module BABYLON {
  43341. /**
  43342. * Listen to keyboard events to control the camera.
  43343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43344. */
  43345. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43346. /**
  43347. * Defines the camera the input is attached to.
  43348. */
  43349. camera: FlyCamera;
  43350. /**
  43351. * The list of keyboard keys used to control the forward move of the camera.
  43352. */
  43353. keysForward: number[];
  43354. /**
  43355. * The list of keyboard keys used to control the backward move of the camera.
  43356. */
  43357. keysBackward: number[];
  43358. /**
  43359. * The list of keyboard keys used to control the forward move of the camera.
  43360. */
  43361. keysUp: number[];
  43362. /**
  43363. * The list of keyboard keys used to control the backward move of the camera.
  43364. */
  43365. keysDown: number[];
  43366. /**
  43367. * The list of keyboard keys used to control the right strafe move of the camera.
  43368. */
  43369. keysRight: number[];
  43370. /**
  43371. * The list of keyboard keys used to control the left strafe move of the camera.
  43372. */
  43373. keysLeft: number[];
  43374. private _keys;
  43375. private _onCanvasBlurObserver;
  43376. private _onKeyboardObserver;
  43377. private _engine;
  43378. private _scene;
  43379. /**
  43380. * Attach the input controls to a specific dom element to get the input from.
  43381. * @param element Defines the element the controls should be listened from
  43382. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43383. */
  43384. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43385. /**
  43386. * Detach the current controls from the specified dom element.
  43387. * @param element Defines the element to stop listening the inputs from
  43388. */
  43389. detachControl(element: Nullable<HTMLElement>): void;
  43390. /**
  43391. * Gets the class name of the current intput.
  43392. * @returns the class name
  43393. */
  43394. getClassName(): string;
  43395. /** @hidden */
  43396. _onLostFocus(e: FocusEvent): void;
  43397. /**
  43398. * Get the friendly name associated with the input class.
  43399. * @returns the input friendly name
  43400. */
  43401. getSimpleName(): string;
  43402. /**
  43403. * Update the current camera state depending on the inputs that have been used this frame.
  43404. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43405. */
  43406. checkInputs(): void;
  43407. }
  43408. }
  43409. declare module BABYLON {
  43410. /**
  43411. * Manage the mouse wheel inputs to control a follow camera.
  43412. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43413. */
  43414. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43415. /**
  43416. * Defines the camera the input is attached to.
  43417. */
  43418. camera: FollowCamera;
  43419. /**
  43420. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43421. */
  43422. axisControlRadius: boolean;
  43423. /**
  43424. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43425. */
  43426. axisControlHeight: boolean;
  43427. /**
  43428. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43429. */
  43430. axisControlRotation: boolean;
  43431. /**
  43432. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43433. * relation to mouseWheel events.
  43434. */
  43435. wheelPrecision: number;
  43436. /**
  43437. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43438. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43439. */
  43440. wheelDeltaPercentage: number;
  43441. private _wheel;
  43442. private _observer;
  43443. /**
  43444. * Attach the input controls to a specific dom element to get the input from.
  43445. * @param element Defines the element the controls should be listened from
  43446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43447. */
  43448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43449. /**
  43450. * Detach the current controls from the specified dom element.
  43451. * @param element Defines the element to stop listening the inputs from
  43452. */
  43453. detachControl(element: Nullable<HTMLElement>): void;
  43454. /**
  43455. * Gets the class name of the current intput.
  43456. * @returns the class name
  43457. */
  43458. getClassName(): string;
  43459. /**
  43460. * Get the friendly name associated with the input class.
  43461. * @returns the input friendly name
  43462. */
  43463. getSimpleName(): string;
  43464. }
  43465. }
  43466. declare module BABYLON {
  43467. /**
  43468. * Manage the pointers inputs to control an follow camera.
  43469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43470. */
  43471. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43472. /**
  43473. * Defines the camera the input is attached to.
  43474. */
  43475. camera: FollowCamera;
  43476. /**
  43477. * Gets the class name of the current input.
  43478. * @returns the class name
  43479. */
  43480. getClassName(): string;
  43481. /**
  43482. * Defines the pointer angular sensibility along the X axis or how fast is
  43483. * the camera rotating.
  43484. * A negative number will reverse the axis direction.
  43485. */
  43486. angularSensibilityX: number;
  43487. /**
  43488. * Defines the pointer angular sensibility along the Y axis or how fast is
  43489. * the camera rotating.
  43490. * A negative number will reverse the axis direction.
  43491. */
  43492. angularSensibilityY: number;
  43493. /**
  43494. * Defines the pointer pinch precision or how fast is the camera zooming.
  43495. * A negative number will reverse the axis direction.
  43496. */
  43497. pinchPrecision: number;
  43498. /**
  43499. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43500. * from 0.
  43501. * It defines the percentage of current camera.radius to use as delta when
  43502. * pinch zoom is used.
  43503. */
  43504. pinchDeltaPercentage: number;
  43505. /**
  43506. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43507. */
  43508. axisXControlRadius: boolean;
  43509. /**
  43510. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43511. */
  43512. axisXControlHeight: boolean;
  43513. /**
  43514. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43515. */
  43516. axisXControlRotation: boolean;
  43517. /**
  43518. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43519. */
  43520. axisYControlRadius: boolean;
  43521. /**
  43522. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43523. */
  43524. axisYControlHeight: boolean;
  43525. /**
  43526. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43527. */
  43528. axisYControlRotation: boolean;
  43529. /**
  43530. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43531. */
  43532. axisPinchControlRadius: boolean;
  43533. /**
  43534. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43535. */
  43536. axisPinchControlHeight: boolean;
  43537. /**
  43538. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43539. */
  43540. axisPinchControlRotation: boolean;
  43541. /**
  43542. * Log error messages if basic misconfiguration has occurred.
  43543. */
  43544. warningEnable: boolean;
  43545. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43546. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43547. private _warningCounter;
  43548. private _warning;
  43549. }
  43550. }
  43551. declare module BABYLON {
  43552. /**
  43553. * Default Inputs manager for the FollowCamera.
  43554. * It groups all the default supported inputs for ease of use.
  43555. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43556. */
  43557. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43558. /**
  43559. * Instantiates a new FollowCameraInputsManager.
  43560. * @param camera Defines the camera the inputs belong to
  43561. */
  43562. constructor(camera: FollowCamera);
  43563. /**
  43564. * Add keyboard input support to the input manager.
  43565. * @returns the current input manager
  43566. */
  43567. addKeyboard(): FollowCameraInputsManager;
  43568. /**
  43569. * Add mouse wheel input support to the input manager.
  43570. * @returns the current input manager
  43571. */
  43572. addMouseWheel(): FollowCameraInputsManager;
  43573. /**
  43574. * Add pointers input support to the input manager.
  43575. * @returns the current input manager
  43576. */
  43577. addPointers(): FollowCameraInputsManager;
  43578. /**
  43579. * Add orientation input support to the input manager.
  43580. * @returns the current input manager
  43581. */
  43582. addVRDeviceOrientation(): FollowCameraInputsManager;
  43583. }
  43584. }
  43585. declare module BABYLON {
  43586. /**
  43587. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43588. * an arc rotate version arcFollowCamera are available.
  43589. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43590. */
  43591. export class FollowCamera extends TargetCamera {
  43592. /**
  43593. * Distance the follow camera should follow an object at
  43594. */
  43595. radius: number;
  43596. /**
  43597. * Minimum allowed distance of the camera to the axis of rotation
  43598. * (The camera can not get closer).
  43599. * This can help limiting how the Camera is able to move in the scene.
  43600. */
  43601. lowerRadiusLimit: Nullable<number>;
  43602. /**
  43603. * Maximum allowed distance of the camera to the axis of rotation
  43604. * (The camera can not get further).
  43605. * This can help limiting how the Camera is able to move in the scene.
  43606. */
  43607. upperRadiusLimit: Nullable<number>;
  43608. /**
  43609. * Define a rotation offset between the camera and the object it follows
  43610. */
  43611. rotationOffset: number;
  43612. /**
  43613. * Minimum allowed angle to camera position relative to target object.
  43614. * This can help limiting how the Camera is able to move in the scene.
  43615. */
  43616. lowerRotationOffsetLimit: Nullable<number>;
  43617. /**
  43618. * Maximum allowed angle to camera position relative to target object.
  43619. * This can help limiting how the Camera is able to move in the scene.
  43620. */
  43621. upperRotationOffsetLimit: Nullable<number>;
  43622. /**
  43623. * Define a height offset between the camera and the object it follows.
  43624. * It can help following an object from the top (like a car chaing a plane)
  43625. */
  43626. heightOffset: number;
  43627. /**
  43628. * Minimum allowed height of camera position relative to target object.
  43629. * This can help limiting how the Camera is able to move in the scene.
  43630. */
  43631. lowerHeightOffsetLimit: Nullable<number>;
  43632. /**
  43633. * Maximum allowed height of camera position relative to target object.
  43634. * This can help limiting how the Camera is able to move in the scene.
  43635. */
  43636. upperHeightOffsetLimit: Nullable<number>;
  43637. /**
  43638. * Define how fast the camera can accelerate to follow it s target.
  43639. */
  43640. cameraAcceleration: number;
  43641. /**
  43642. * Define the speed limit of the camera following an object.
  43643. */
  43644. maxCameraSpeed: number;
  43645. /**
  43646. * Define the target of the camera.
  43647. */
  43648. lockedTarget: Nullable<AbstractMesh>;
  43649. /**
  43650. * Defines the input associated with the camera.
  43651. */
  43652. inputs: FollowCameraInputsManager;
  43653. /**
  43654. * Instantiates the follow camera.
  43655. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43656. * @param name Define the name of the camera in the scene
  43657. * @param position Define the position of the camera
  43658. * @param scene Define the scene the camera belong to
  43659. * @param lockedTarget Define the target of the camera
  43660. */
  43661. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43662. private _follow;
  43663. /**
  43664. * Attached controls to the current camera.
  43665. * @param element Defines the element the controls should be listened from
  43666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43667. */
  43668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43669. /**
  43670. * Detach the current controls from the camera.
  43671. * The camera will stop reacting to inputs.
  43672. * @param element Defines the element to stop listening the inputs from
  43673. */
  43674. detachControl(element: HTMLElement): void;
  43675. /** @hidden */
  43676. _checkInputs(): void;
  43677. private _checkLimits;
  43678. /**
  43679. * Gets the camera class name.
  43680. * @returns the class name
  43681. */
  43682. getClassName(): string;
  43683. }
  43684. /**
  43685. * Arc Rotate version of the follow camera.
  43686. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43687. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43688. */
  43689. export class ArcFollowCamera extends TargetCamera {
  43690. /** The longitudinal angle of the camera */
  43691. alpha: number;
  43692. /** The latitudinal angle of the camera */
  43693. beta: number;
  43694. /** The radius of the camera from its target */
  43695. radius: number;
  43696. /** Define the camera target (the mesh it should follow) */
  43697. target: Nullable<AbstractMesh>;
  43698. private _cartesianCoordinates;
  43699. /**
  43700. * Instantiates a new ArcFollowCamera
  43701. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43702. * @param name Define the name of the camera
  43703. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43704. * @param beta Define the rotation angle of the camera around the elevation axis
  43705. * @param radius Define the radius of the camera from its target point
  43706. * @param target Define the target of the camera
  43707. * @param scene Define the scene the camera belongs to
  43708. */
  43709. constructor(name: string,
  43710. /** The longitudinal angle of the camera */
  43711. alpha: number,
  43712. /** The latitudinal angle of the camera */
  43713. beta: number,
  43714. /** The radius of the camera from its target */
  43715. radius: number,
  43716. /** Define the camera target (the mesh it should follow) */
  43717. target: Nullable<AbstractMesh>, scene: Scene);
  43718. private _follow;
  43719. /** @hidden */
  43720. _checkInputs(): void;
  43721. /**
  43722. * Returns the class name of the object.
  43723. * It is mostly used internally for serialization purposes.
  43724. */
  43725. getClassName(): string;
  43726. }
  43727. }
  43728. declare module BABYLON {
  43729. /**
  43730. * Manage the keyboard inputs to control the movement of a follow camera.
  43731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43732. */
  43733. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43734. /**
  43735. * Defines the camera the input is attached to.
  43736. */
  43737. camera: FollowCamera;
  43738. /**
  43739. * Defines the list of key codes associated with the up action (increase heightOffset)
  43740. */
  43741. keysHeightOffsetIncr: number[];
  43742. /**
  43743. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43744. */
  43745. keysHeightOffsetDecr: number[];
  43746. /**
  43747. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43748. */
  43749. keysHeightOffsetModifierAlt: boolean;
  43750. /**
  43751. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43752. */
  43753. keysHeightOffsetModifierCtrl: boolean;
  43754. /**
  43755. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43756. */
  43757. keysHeightOffsetModifierShift: boolean;
  43758. /**
  43759. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43760. */
  43761. keysRotationOffsetIncr: number[];
  43762. /**
  43763. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43764. */
  43765. keysRotationOffsetDecr: number[];
  43766. /**
  43767. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43768. */
  43769. keysRotationOffsetModifierAlt: boolean;
  43770. /**
  43771. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43772. */
  43773. keysRotationOffsetModifierCtrl: boolean;
  43774. /**
  43775. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43776. */
  43777. keysRotationOffsetModifierShift: boolean;
  43778. /**
  43779. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43780. */
  43781. keysRadiusIncr: number[];
  43782. /**
  43783. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43784. */
  43785. keysRadiusDecr: number[];
  43786. /**
  43787. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43788. */
  43789. keysRadiusModifierAlt: boolean;
  43790. /**
  43791. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43792. */
  43793. keysRadiusModifierCtrl: boolean;
  43794. /**
  43795. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43796. */
  43797. keysRadiusModifierShift: boolean;
  43798. /**
  43799. * Defines the rate of change of heightOffset.
  43800. */
  43801. heightSensibility: number;
  43802. /**
  43803. * Defines the rate of change of rotationOffset.
  43804. */
  43805. rotationSensibility: number;
  43806. /**
  43807. * Defines the rate of change of radius.
  43808. */
  43809. radiusSensibility: number;
  43810. private _keys;
  43811. private _ctrlPressed;
  43812. private _altPressed;
  43813. private _shiftPressed;
  43814. private _onCanvasBlurObserver;
  43815. private _onKeyboardObserver;
  43816. private _engine;
  43817. private _scene;
  43818. /**
  43819. * Attach the input controls to a specific dom element to get the input from.
  43820. * @param element Defines the element the controls should be listened from
  43821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43822. */
  43823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43824. /**
  43825. * Detach the current controls from the specified dom element.
  43826. * @param element Defines the element to stop listening the inputs from
  43827. */
  43828. detachControl(element: Nullable<HTMLElement>): void;
  43829. /**
  43830. * Update the current camera state depending on the inputs that have been used this frame.
  43831. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43832. */
  43833. checkInputs(): void;
  43834. /**
  43835. * Gets the class name of the current input.
  43836. * @returns the class name
  43837. */
  43838. getClassName(): string;
  43839. /**
  43840. * Get the friendly name associated with the input class.
  43841. * @returns the input friendly name
  43842. */
  43843. getSimpleName(): string;
  43844. /**
  43845. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43846. * allow modification of the heightOffset value.
  43847. */
  43848. private _modifierHeightOffset;
  43849. /**
  43850. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43851. * allow modification of the rotationOffset value.
  43852. */
  43853. private _modifierRotationOffset;
  43854. /**
  43855. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43856. * allow modification of the radius value.
  43857. */
  43858. private _modifierRadius;
  43859. }
  43860. }
  43861. declare module BABYLON {
  43862. interface FreeCameraInputsManager {
  43863. /**
  43864. * @hidden
  43865. */
  43866. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43867. /**
  43868. * Add orientation input support to the input manager.
  43869. * @returns the current input manager
  43870. */
  43871. addDeviceOrientation(): FreeCameraInputsManager;
  43872. }
  43873. /**
  43874. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43875. * Screen rotation is taken into account.
  43876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43877. */
  43878. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43879. private _camera;
  43880. private _screenOrientationAngle;
  43881. private _constantTranform;
  43882. private _screenQuaternion;
  43883. private _alpha;
  43884. private _beta;
  43885. private _gamma;
  43886. /**
  43887. * Can be used to detect if a device orientation sensor is available on a device
  43888. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43889. * @returns a promise that will resolve on orientation change
  43890. */
  43891. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43892. /**
  43893. * @hidden
  43894. */
  43895. _onDeviceOrientationChangedObservable: Observable<void>;
  43896. /**
  43897. * Instantiates a new input
  43898. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43899. */
  43900. constructor();
  43901. /**
  43902. * Define the camera controlled by the input.
  43903. */
  43904. get camera(): FreeCamera;
  43905. set camera(camera: FreeCamera);
  43906. /**
  43907. * Attach the input controls to a specific dom element to get the input from.
  43908. * @param element Defines the element the controls should be listened from
  43909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43910. */
  43911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43912. private _orientationChanged;
  43913. private _deviceOrientation;
  43914. /**
  43915. * Detach the current controls from the specified dom element.
  43916. * @param element Defines the element to stop listening the inputs from
  43917. */
  43918. detachControl(element: Nullable<HTMLElement>): void;
  43919. /**
  43920. * Update the current camera state depending on the inputs that have been used this frame.
  43921. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43922. */
  43923. checkInputs(): void;
  43924. /**
  43925. * Gets the class name of the current intput.
  43926. * @returns the class name
  43927. */
  43928. getClassName(): string;
  43929. /**
  43930. * Get the friendly name associated with the input class.
  43931. * @returns the input friendly name
  43932. */
  43933. getSimpleName(): string;
  43934. }
  43935. }
  43936. declare module BABYLON {
  43937. /**
  43938. * Manage the gamepad inputs to control a free camera.
  43939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43940. */
  43941. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43942. /**
  43943. * Define the camera the input is attached to.
  43944. */
  43945. camera: FreeCamera;
  43946. /**
  43947. * Define the Gamepad controlling the input
  43948. */
  43949. gamepad: Nullable<Gamepad>;
  43950. /**
  43951. * Defines the gamepad rotation sensiblity.
  43952. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43953. */
  43954. gamepadAngularSensibility: number;
  43955. /**
  43956. * Defines the gamepad move sensiblity.
  43957. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43958. */
  43959. gamepadMoveSensibility: number;
  43960. private _yAxisScale;
  43961. /**
  43962. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43963. */
  43964. get invertYAxis(): boolean;
  43965. set invertYAxis(value: boolean);
  43966. private _onGamepadConnectedObserver;
  43967. private _onGamepadDisconnectedObserver;
  43968. private _cameraTransform;
  43969. private _deltaTransform;
  43970. private _vector3;
  43971. private _vector2;
  43972. /**
  43973. * Attach the input controls to a specific dom element to get the input from.
  43974. * @param element Defines the element the controls should be listened from
  43975. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43976. */
  43977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43978. /**
  43979. * Detach the current controls from the specified dom element.
  43980. * @param element Defines the element to stop listening the inputs from
  43981. */
  43982. detachControl(element: Nullable<HTMLElement>): void;
  43983. /**
  43984. * Update the current camera state depending on the inputs that have been used this frame.
  43985. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43986. */
  43987. checkInputs(): void;
  43988. /**
  43989. * Gets the class name of the current intput.
  43990. * @returns the class name
  43991. */
  43992. getClassName(): string;
  43993. /**
  43994. * Get the friendly name associated with the input class.
  43995. * @returns the input friendly name
  43996. */
  43997. getSimpleName(): string;
  43998. }
  43999. }
  44000. declare module BABYLON {
  44001. /**
  44002. * Defines the potential axis of a Joystick
  44003. */
  44004. export enum JoystickAxis {
  44005. /** X axis */
  44006. X = 0,
  44007. /** Y axis */
  44008. Y = 1,
  44009. /** Z axis */
  44010. Z = 2
  44011. }
  44012. /**
  44013. * Represents the different customization options available
  44014. * for VirtualJoystick
  44015. */
  44016. interface VirtualJoystickCustomizations {
  44017. /**
  44018. * Size of the joystick's puck
  44019. */
  44020. puckSize: number;
  44021. /**
  44022. * Size of the joystick's container
  44023. */
  44024. containerSize: number;
  44025. /**
  44026. * Color of the joystick && puck
  44027. */
  44028. color: string;
  44029. /**
  44030. * Image URL for the joystick's puck
  44031. */
  44032. puckImage?: string;
  44033. /**
  44034. * Image URL for the joystick's container
  44035. */
  44036. containerImage?: string;
  44037. /**
  44038. * Defines the unmoving position of the joystick container
  44039. */
  44040. position?: {
  44041. x: number;
  44042. y: number;
  44043. };
  44044. /**
  44045. * Defines whether or not the joystick container is always visible
  44046. */
  44047. alwaysVisible: boolean;
  44048. /**
  44049. * Defines whether or not to limit the movement of the puck to the joystick's container
  44050. */
  44051. limitToContainer: boolean;
  44052. }
  44053. /**
  44054. * Class used to define virtual joystick (used in touch mode)
  44055. */
  44056. export class VirtualJoystick {
  44057. /**
  44058. * Gets or sets a boolean indicating that left and right values must be inverted
  44059. */
  44060. reverseLeftRight: boolean;
  44061. /**
  44062. * Gets or sets a boolean indicating that up and down values must be inverted
  44063. */
  44064. reverseUpDown: boolean;
  44065. /**
  44066. * Gets the offset value for the position (ie. the change of the position value)
  44067. */
  44068. deltaPosition: Vector3;
  44069. /**
  44070. * Gets a boolean indicating if the virtual joystick was pressed
  44071. */
  44072. pressed: boolean;
  44073. /**
  44074. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44075. */
  44076. static Canvas: Nullable<HTMLCanvasElement>;
  44077. /**
  44078. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  44079. */
  44080. limitToContainer: boolean;
  44081. private static _globalJoystickIndex;
  44082. private static _alwaysVisibleSticks;
  44083. private static vjCanvasContext;
  44084. private static vjCanvasWidth;
  44085. private static vjCanvasHeight;
  44086. private static halfWidth;
  44087. private static _GetDefaultOptions;
  44088. private _action;
  44089. private _axisTargetedByLeftAndRight;
  44090. private _axisTargetedByUpAndDown;
  44091. private _joystickSensibility;
  44092. private _inversedSensibility;
  44093. private _joystickPointerID;
  44094. private _joystickColor;
  44095. private _joystickPointerPos;
  44096. private _joystickPreviousPointerPos;
  44097. private _joystickPointerStartPos;
  44098. private _deltaJoystickVector;
  44099. private _leftJoystick;
  44100. private _touches;
  44101. private _joystickPosition;
  44102. private _alwaysVisible;
  44103. private _puckImage;
  44104. private _containerImage;
  44105. private _joystickPuckSize;
  44106. private _joystickContainerSize;
  44107. private _clearPuckSize;
  44108. private _clearContainerSize;
  44109. private _clearPuckSizeOffset;
  44110. private _clearContainerSizeOffset;
  44111. private _onPointerDownHandlerRef;
  44112. private _onPointerMoveHandlerRef;
  44113. private _onPointerUpHandlerRef;
  44114. private _onResize;
  44115. /**
  44116. * Creates a new virtual joystick
  44117. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44118. * @param customizations Defines the options we want to customize the VirtualJoystick
  44119. */
  44120. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  44121. /**
  44122. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44123. * @param newJoystickSensibility defines the new sensibility
  44124. */
  44125. setJoystickSensibility(newJoystickSensibility: number): void;
  44126. private _onPointerDown;
  44127. private _onPointerMove;
  44128. private _onPointerUp;
  44129. /**
  44130. * Change the color of the virtual joystick
  44131. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44132. */
  44133. setJoystickColor(newColor: string): void;
  44134. /**
  44135. * Size of the joystick's container
  44136. */
  44137. set containerSize(newSize: number);
  44138. get containerSize(): number;
  44139. /**
  44140. * Size of the joystick's puck
  44141. */
  44142. set puckSize(newSize: number);
  44143. get puckSize(): number;
  44144. /**
  44145. * Clears the set position of the joystick
  44146. */
  44147. clearPosition(): void;
  44148. /**
  44149. * Defines whether or not the joystick container is always visible
  44150. */
  44151. set alwaysVisible(value: boolean);
  44152. get alwaysVisible(): boolean;
  44153. /**
  44154. * Sets the constant position of the Joystick container
  44155. * @param x X axis coordinate
  44156. * @param y Y axis coordinate
  44157. */
  44158. setPosition(x: number, y: number): void;
  44159. /**
  44160. * Defines a callback to call when the joystick is touched
  44161. * @param action defines the callback
  44162. */
  44163. setActionOnTouch(action: () => any): void;
  44164. /**
  44165. * Defines which axis you'd like to control for left & right
  44166. * @param axis defines the axis to use
  44167. */
  44168. setAxisForLeftRight(axis: JoystickAxis): void;
  44169. /**
  44170. * Defines which axis you'd like to control for up & down
  44171. * @param axis defines the axis to use
  44172. */
  44173. setAxisForUpDown(axis: JoystickAxis): void;
  44174. /**
  44175. * Clears the canvas from the previous puck / container draw
  44176. */
  44177. private _clearPreviousDraw;
  44178. /**
  44179. * Loads `urlPath` to be used for the container's image
  44180. * @param urlPath defines the urlPath of an image to use
  44181. */
  44182. setContainerImage(urlPath: string): void;
  44183. /**
  44184. * Loads `urlPath` to be used for the puck's image
  44185. * @param urlPath defines the urlPath of an image to use
  44186. */
  44187. setPuckImage(urlPath: string): void;
  44188. /**
  44189. * Draws the Virtual Joystick's container
  44190. */
  44191. private _drawContainer;
  44192. /**
  44193. * Draws the Virtual Joystick's puck
  44194. */
  44195. private _drawPuck;
  44196. private _drawVirtualJoystick;
  44197. /**
  44198. * Release internal HTML canvas
  44199. */
  44200. releaseCanvas(): void;
  44201. }
  44202. }
  44203. declare module BABYLON {
  44204. interface FreeCameraInputsManager {
  44205. /**
  44206. * Add virtual joystick input support to the input manager.
  44207. * @returns the current input manager
  44208. */
  44209. addVirtualJoystick(): FreeCameraInputsManager;
  44210. }
  44211. /**
  44212. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44214. */
  44215. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44216. /**
  44217. * Defines the camera the input is attached to.
  44218. */
  44219. camera: FreeCamera;
  44220. private _leftjoystick;
  44221. private _rightjoystick;
  44222. /**
  44223. * Gets the left stick of the virtual joystick.
  44224. * @returns The virtual Joystick
  44225. */
  44226. getLeftJoystick(): VirtualJoystick;
  44227. /**
  44228. * Gets the right stick of the virtual joystick.
  44229. * @returns The virtual Joystick
  44230. */
  44231. getRightJoystick(): VirtualJoystick;
  44232. /**
  44233. * Update the current camera state depending on the inputs that have been used this frame.
  44234. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44235. */
  44236. checkInputs(): void;
  44237. /**
  44238. * Attach the input controls to a specific dom element to get the input from.
  44239. * @param element Defines the element the controls should be listened from
  44240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44241. */
  44242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44243. /**
  44244. * Detach the current controls from the specified dom element.
  44245. * @param element Defines the element to stop listening the inputs from
  44246. */
  44247. detachControl(element: Nullable<HTMLElement>): void;
  44248. /**
  44249. * Gets the class name of the current intput.
  44250. * @returns the class name
  44251. */
  44252. getClassName(): string;
  44253. /**
  44254. * Get the friendly name associated with the input class.
  44255. * @returns the input friendly name
  44256. */
  44257. getSimpleName(): string;
  44258. }
  44259. }
  44260. declare module BABYLON {
  44261. /**
  44262. * This represents a FPS type of camera controlled by touch.
  44263. * This is like a universal camera minus the Gamepad controls.
  44264. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44265. */
  44266. export class TouchCamera extends FreeCamera {
  44267. /**
  44268. * Defines the touch sensibility for rotation.
  44269. * The higher the faster.
  44270. */
  44271. get touchAngularSensibility(): number;
  44272. set touchAngularSensibility(value: number);
  44273. /**
  44274. * Defines the touch sensibility for move.
  44275. * The higher the faster.
  44276. */
  44277. get touchMoveSensibility(): number;
  44278. set touchMoveSensibility(value: number);
  44279. /**
  44280. * Instantiates a new touch camera.
  44281. * This represents a FPS type of camera controlled by touch.
  44282. * This is like a universal camera minus the Gamepad controls.
  44283. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44284. * @param name Define the name of the camera in the scene
  44285. * @param position Define the start position of the camera in the scene
  44286. * @param scene Define the scene the camera belongs to
  44287. */
  44288. constructor(name: string, position: Vector3, scene: Scene);
  44289. /**
  44290. * Gets the current object class name.
  44291. * @return the class name
  44292. */
  44293. getClassName(): string;
  44294. /** @hidden */
  44295. _setupInputs(): void;
  44296. }
  44297. }
  44298. declare module BABYLON {
  44299. /**
  44300. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44301. * being tilted forward or back and left or right.
  44302. */
  44303. export class DeviceOrientationCamera extends FreeCamera {
  44304. private _initialQuaternion;
  44305. private _quaternionCache;
  44306. private _tmpDragQuaternion;
  44307. private _disablePointerInputWhenUsingDeviceOrientation;
  44308. /**
  44309. * Creates a new device orientation camera
  44310. * @param name The name of the camera
  44311. * @param position The start position camera
  44312. * @param scene The scene the camera belongs to
  44313. */
  44314. constructor(name: string, position: Vector3, scene: Scene);
  44315. /**
  44316. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44317. */
  44318. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44319. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44320. private _dragFactor;
  44321. /**
  44322. * Enabled turning on the y axis when the orientation sensor is active
  44323. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44324. */
  44325. enableHorizontalDragging(dragFactor?: number): void;
  44326. /**
  44327. * Gets the current instance class name ("DeviceOrientationCamera").
  44328. * This helps avoiding instanceof at run time.
  44329. * @returns the class name
  44330. */
  44331. getClassName(): string;
  44332. /**
  44333. * @hidden
  44334. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44335. */
  44336. _checkInputs(): void;
  44337. /**
  44338. * Reset the camera to its default orientation on the specified axis only.
  44339. * @param axis The axis to reset
  44340. */
  44341. resetToCurrentRotation(axis?: Axis): void;
  44342. }
  44343. }
  44344. declare module BABYLON {
  44345. /**
  44346. * Defines supported buttons for XBox360 compatible gamepads
  44347. */
  44348. export enum Xbox360Button {
  44349. /** A */
  44350. A = 0,
  44351. /** B */
  44352. B = 1,
  44353. /** X */
  44354. X = 2,
  44355. /** Y */
  44356. Y = 3,
  44357. /** Left button */
  44358. LB = 4,
  44359. /** Right button */
  44360. RB = 5,
  44361. /** Back */
  44362. Back = 8,
  44363. /** Start */
  44364. Start = 9,
  44365. /** Left stick */
  44366. LeftStick = 10,
  44367. /** Right stick */
  44368. RightStick = 11
  44369. }
  44370. /** Defines values for XBox360 DPad */
  44371. export enum Xbox360Dpad {
  44372. /** Up */
  44373. Up = 12,
  44374. /** Down */
  44375. Down = 13,
  44376. /** Left */
  44377. Left = 14,
  44378. /** Right */
  44379. Right = 15
  44380. }
  44381. /**
  44382. * Defines a XBox360 gamepad
  44383. */
  44384. export class Xbox360Pad extends Gamepad {
  44385. private _leftTrigger;
  44386. private _rightTrigger;
  44387. private _onlefttriggerchanged;
  44388. private _onrighttriggerchanged;
  44389. private _onbuttondown;
  44390. private _onbuttonup;
  44391. private _ondpaddown;
  44392. private _ondpadup;
  44393. /** Observable raised when a button is pressed */
  44394. onButtonDownObservable: Observable<Xbox360Button>;
  44395. /** Observable raised when a button is released */
  44396. onButtonUpObservable: Observable<Xbox360Button>;
  44397. /** Observable raised when a pad is pressed */
  44398. onPadDownObservable: Observable<Xbox360Dpad>;
  44399. /** Observable raised when a pad is released */
  44400. onPadUpObservable: Observable<Xbox360Dpad>;
  44401. private _buttonA;
  44402. private _buttonB;
  44403. private _buttonX;
  44404. private _buttonY;
  44405. private _buttonBack;
  44406. private _buttonStart;
  44407. private _buttonLB;
  44408. private _buttonRB;
  44409. private _buttonLeftStick;
  44410. private _buttonRightStick;
  44411. private _dPadUp;
  44412. private _dPadDown;
  44413. private _dPadLeft;
  44414. private _dPadRight;
  44415. private _isXboxOnePad;
  44416. /**
  44417. * Creates a new XBox360 gamepad object
  44418. * @param id defines the id of this gamepad
  44419. * @param index defines its index
  44420. * @param gamepad defines the internal HTML gamepad object
  44421. * @param xboxOne defines if it is a XBox One gamepad
  44422. */
  44423. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44424. /**
  44425. * Defines the callback to call when left trigger is pressed
  44426. * @param callback defines the callback to use
  44427. */
  44428. onlefttriggerchanged(callback: (value: number) => void): void;
  44429. /**
  44430. * Defines the callback to call when right trigger is pressed
  44431. * @param callback defines the callback to use
  44432. */
  44433. onrighttriggerchanged(callback: (value: number) => void): void;
  44434. /**
  44435. * Gets the left trigger value
  44436. */
  44437. get leftTrigger(): number;
  44438. /**
  44439. * Sets the left trigger value
  44440. */
  44441. set leftTrigger(newValue: number);
  44442. /**
  44443. * Gets the right trigger value
  44444. */
  44445. get rightTrigger(): number;
  44446. /**
  44447. * Sets the right trigger value
  44448. */
  44449. set rightTrigger(newValue: number);
  44450. /**
  44451. * Defines the callback to call when a button is pressed
  44452. * @param callback defines the callback to use
  44453. */
  44454. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44455. /**
  44456. * Defines the callback to call when a button is released
  44457. * @param callback defines the callback to use
  44458. */
  44459. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44460. /**
  44461. * Defines the callback to call when a pad is pressed
  44462. * @param callback defines the callback to use
  44463. */
  44464. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44465. /**
  44466. * Defines the callback to call when a pad is released
  44467. * @param callback defines the callback to use
  44468. */
  44469. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44470. private _setButtonValue;
  44471. private _setDPadValue;
  44472. /**
  44473. * Gets the value of the `A` button
  44474. */
  44475. get buttonA(): number;
  44476. /**
  44477. * Sets the value of the `A` button
  44478. */
  44479. set buttonA(value: number);
  44480. /**
  44481. * Gets the value of the `B` button
  44482. */
  44483. get buttonB(): number;
  44484. /**
  44485. * Sets the value of the `B` button
  44486. */
  44487. set buttonB(value: number);
  44488. /**
  44489. * Gets the value of the `X` button
  44490. */
  44491. get buttonX(): number;
  44492. /**
  44493. * Sets the value of the `X` button
  44494. */
  44495. set buttonX(value: number);
  44496. /**
  44497. * Gets the value of the `Y` button
  44498. */
  44499. get buttonY(): number;
  44500. /**
  44501. * Sets the value of the `Y` button
  44502. */
  44503. set buttonY(value: number);
  44504. /**
  44505. * Gets the value of the `Start` button
  44506. */
  44507. get buttonStart(): number;
  44508. /**
  44509. * Sets the value of the `Start` button
  44510. */
  44511. set buttonStart(value: number);
  44512. /**
  44513. * Gets the value of the `Back` button
  44514. */
  44515. get buttonBack(): number;
  44516. /**
  44517. * Sets the value of the `Back` button
  44518. */
  44519. set buttonBack(value: number);
  44520. /**
  44521. * Gets the value of the `Left` button
  44522. */
  44523. get buttonLB(): number;
  44524. /**
  44525. * Sets the value of the `Left` button
  44526. */
  44527. set buttonLB(value: number);
  44528. /**
  44529. * Gets the value of the `Right` button
  44530. */
  44531. get buttonRB(): number;
  44532. /**
  44533. * Sets the value of the `Right` button
  44534. */
  44535. set buttonRB(value: number);
  44536. /**
  44537. * Gets the value of the Left joystick
  44538. */
  44539. get buttonLeftStick(): number;
  44540. /**
  44541. * Sets the value of the Left joystick
  44542. */
  44543. set buttonLeftStick(value: number);
  44544. /**
  44545. * Gets the value of the Right joystick
  44546. */
  44547. get buttonRightStick(): number;
  44548. /**
  44549. * Sets the value of the Right joystick
  44550. */
  44551. set buttonRightStick(value: number);
  44552. /**
  44553. * Gets the value of D-pad up
  44554. */
  44555. get dPadUp(): number;
  44556. /**
  44557. * Sets the value of D-pad up
  44558. */
  44559. set dPadUp(value: number);
  44560. /**
  44561. * Gets the value of D-pad down
  44562. */
  44563. get dPadDown(): number;
  44564. /**
  44565. * Sets the value of D-pad down
  44566. */
  44567. set dPadDown(value: number);
  44568. /**
  44569. * Gets the value of D-pad left
  44570. */
  44571. get dPadLeft(): number;
  44572. /**
  44573. * Sets the value of D-pad left
  44574. */
  44575. set dPadLeft(value: number);
  44576. /**
  44577. * Gets the value of D-pad right
  44578. */
  44579. get dPadRight(): number;
  44580. /**
  44581. * Sets the value of D-pad right
  44582. */
  44583. set dPadRight(value: number);
  44584. /**
  44585. * Force the gamepad to synchronize with device values
  44586. */
  44587. update(): void;
  44588. /**
  44589. * Disposes the gamepad
  44590. */
  44591. dispose(): void;
  44592. }
  44593. }
  44594. declare module BABYLON {
  44595. /**
  44596. * Defines supported buttons for DualShock compatible gamepads
  44597. */
  44598. export enum DualShockButton {
  44599. /** Cross */
  44600. Cross = 0,
  44601. /** Circle */
  44602. Circle = 1,
  44603. /** Square */
  44604. Square = 2,
  44605. /** Triangle */
  44606. Triangle = 3,
  44607. /** L1 */
  44608. L1 = 4,
  44609. /** R1 */
  44610. R1 = 5,
  44611. /** Share */
  44612. Share = 8,
  44613. /** Options */
  44614. Options = 9,
  44615. /** Left stick */
  44616. LeftStick = 10,
  44617. /** Right stick */
  44618. RightStick = 11
  44619. }
  44620. /** Defines values for DualShock DPad */
  44621. export enum DualShockDpad {
  44622. /** Up */
  44623. Up = 12,
  44624. /** Down */
  44625. Down = 13,
  44626. /** Left */
  44627. Left = 14,
  44628. /** Right */
  44629. Right = 15
  44630. }
  44631. /**
  44632. * Defines a DualShock gamepad
  44633. */
  44634. export class DualShockPad extends Gamepad {
  44635. private _leftTrigger;
  44636. private _rightTrigger;
  44637. private _onlefttriggerchanged;
  44638. private _onrighttriggerchanged;
  44639. private _onbuttondown;
  44640. private _onbuttonup;
  44641. private _ondpaddown;
  44642. private _ondpadup;
  44643. /** Observable raised when a button is pressed */
  44644. onButtonDownObservable: Observable<DualShockButton>;
  44645. /** Observable raised when a button is released */
  44646. onButtonUpObservable: Observable<DualShockButton>;
  44647. /** Observable raised when a pad is pressed */
  44648. onPadDownObservable: Observable<DualShockDpad>;
  44649. /** Observable raised when a pad is released */
  44650. onPadUpObservable: Observable<DualShockDpad>;
  44651. private _buttonCross;
  44652. private _buttonCircle;
  44653. private _buttonSquare;
  44654. private _buttonTriangle;
  44655. private _buttonShare;
  44656. private _buttonOptions;
  44657. private _buttonL1;
  44658. private _buttonR1;
  44659. private _buttonLeftStick;
  44660. private _buttonRightStick;
  44661. private _dPadUp;
  44662. private _dPadDown;
  44663. private _dPadLeft;
  44664. private _dPadRight;
  44665. /**
  44666. * Creates a new DualShock gamepad object
  44667. * @param id defines the id of this gamepad
  44668. * @param index defines its index
  44669. * @param gamepad defines the internal HTML gamepad object
  44670. */
  44671. constructor(id: string, index: number, gamepad: any);
  44672. /**
  44673. * Defines the callback to call when left trigger is pressed
  44674. * @param callback defines the callback to use
  44675. */
  44676. onlefttriggerchanged(callback: (value: number) => void): void;
  44677. /**
  44678. * Defines the callback to call when right trigger is pressed
  44679. * @param callback defines the callback to use
  44680. */
  44681. onrighttriggerchanged(callback: (value: number) => void): void;
  44682. /**
  44683. * Gets the left trigger value
  44684. */
  44685. get leftTrigger(): number;
  44686. /**
  44687. * Sets the left trigger value
  44688. */
  44689. set leftTrigger(newValue: number);
  44690. /**
  44691. * Gets the right trigger value
  44692. */
  44693. get rightTrigger(): number;
  44694. /**
  44695. * Sets the right trigger value
  44696. */
  44697. set rightTrigger(newValue: number);
  44698. /**
  44699. * Defines the callback to call when a button is pressed
  44700. * @param callback defines the callback to use
  44701. */
  44702. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44703. /**
  44704. * Defines the callback to call when a button is released
  44705. * @param callback defines the callback to use
  44706. */
  44707. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44708. /**
  44709. * Defines the callback to call when a pad is pressed
  44710. * @param callback defines the callback to use
  44711. */
  44712. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44713. /**
  44714. * Defines the callback to call when a pad is released
  44715. * @param callback defines the callback to use
  44716. */
  44717. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44718. private _setButtonValue;
  44719. private _setDPadValue;
  44720. /**
  44721. * Gets the value of the `Cross` button
  44722. */
  44723. get buttonCross(): number;
  44724. /**
  44725. * Sets the value of the `Cross` button
  44726. */
  44727. set buttonCross(value: number);
  44728. /**
  44729. * Gets the value of the `Circle` button
  44730. */
  44731. get buttonCircle(): number;
  44732. /**
  44733. * Sets the value of the `Circle` button
  44734. */
  44735. set buttonCircle(value: number);
  44736. /**
  44737. * Gets the value of the `Square` button
  44738. */
  44739. get buttonSquare(): number;
  44740. /**
  44741. * Sets the value of the `Square` button
  44742. */
  44743. set buttonSquare(value: number);
  44744. /**
  44745. * Gets the value of the `Triangle` button
  44746. */
  44747. get buttonTriangle(): number;
  44748. /**
  44749. * Sets the value of the `Triangle` button
  44750. */
  44751. set buttonTriangle(value: number);
  44752. /**
  44753. * Gets the value of the `Options` button
  44754. */
  44755. get buttonOptions(): number;
  44756. /**
  44757. * Sets the value of the `Options` button
  44758. */
  44759. set buttonOptions(value: number);
  44760. /**
  44761. * Gets the value of the `Share` button
  44762. */
  44763. get buttonShare(): number;
  44764. /**
  44765. * Sets the value of the `Share` button
  44766. */
  44767. set buttonShare(value: number);
  44768. /**
  44769. * Gets the value of the `L1` button
  44770. */
  44771. get buttonL1(): number;
  44772. /**
  44773. * Sets the value of the `L1` button
  44774. */
  44775. set buttonL1(value: number);
  44776. /**
  44777. * Gets the value of the `R1` button
  44778. */
  44779. get buttonR1(): number;
  44780. /**
  44781. * Sets the value of the `R1` button
  44782. */
  44783. set buttonR1(value: number);
  44784. /**
  44785. * Gets the value of the Left joystick
  44786. */
  44787. get buttonLeftStick(): number;
  44788. /**
  44789. * Sets the value of the Left joystick
  44790. */
  44791. set buttonLeftStick(value: number);
  44792. /**
  44793. * Gets the value of the Right joystick
  44794. */
  44795. get buttonRightStick(): number;
  44796. /**
  44797. * Sets the value of the Right joystick
  44798. */
  44799. set buttonRightStick(value: number);
  44800. /**
  44801. * Gets the value of D-pad up
  44802. */
  44803. get dPadUp(): number;
  44804. /**
  44805. * Sets the value of D-pad up
  44806. */
  44807. set dPadUp(value: number);
  44808. /**
  44809. * Gets the value of D-pad down
  44810. */
  44811. get dPadDown(): number;
  44812. /**
  44813. * Sets the value of D-pad down
  44814. */
  44815. set dPadDown(value: number);
  44816. /**
  44817. * Gets the value of D-pad left
  44818. */
  44819. get dPadLeft(): number;
  44820. /**
  44821. * Sets the value of D-pad left
  44822. */
  44823. set dPadLeft(value: number);
  44824. /**
  44825. * Gets the value of D-pad right
  44826. */
  44827. get dPadRight(): number;
  44828. /**
  44829. * Sets the value of D-pad right
  44830. */
  44831. set dPadRight(value: number);
  44832. /**
  44833. * Force the gamepad to synchronize with device values
  44834. */
  44835. update(): void;
  44836. /**
  44837. * Disposes the gamepad
  44838. */
  44839. dispose(): void;
  44840. }
  44841. }
  44842. declare module BABYLON {
  44843. /**
  44844. * Manager for handling gamepads
  44845. */
  44846. export class GamepadManager {
  44847. private _scene?;
  44848. private _babylonGamepads;
  44849. private _oneGamepadConnected;
  44850. /** @hidden */
  44851. _isMonitoring: boolean;
  44852. private _gamepadEventSupported;
  44853. private _gamepadSupport?;
  44854. /**
  44855. * observable to be triggered when the gamepad controller has been connected
  44856. */
  44857. onGamepadConnectedObservable: Observable<Gamepad>;
  44858. /**
  44859. * observable to be triggered when the gamepad controller has been disconnected
  44860. */
  44861. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44862. private _onGamepadConnectedEvent;
  44863. private _onGamepadDisconnectedEvent;
  44864. /**
  44865. * Initializes the gamepad manager
  44866. * @param _scene BabylonJS scene
  44867. */
  44868. constructor(_scene?: Scene | undefined);
  44869. /**
  44870. * The gamepads in the game pad manager
  44871. */
  44872. get gamepads(): Gamepad[];
  44873. /**
  44874. * Get the gamepad controllers based on type
  44875. * @param type The type of gamepad controller
  44876. * @returns Nullable gamepad
  44877. */
  44878. getGamepadByType(type?: number): Nullable<Gamepad>;
  44879. /**
  44880. * Disposes the gamepad manager
  44881. */
  44882. dispose(): void;
  44883. private _addNewGamepad;
  44884. private _startMonitoringGamepads;
  44885. private _stopMonitoringGamepads;
  44886. /** @hidden */
  44887. _checkGamepadsStatus(): void;
  44888. private _updateGamepadObjects;
  44889. }
  44890. }
  44891. declare module BABYLON {
  44892. interface Scene {
  44893. /** @hidden */
  44894. _gamepadManager: Nullable<GamepadManager>;
  44895. /**
  44896. * Gets the gamepad manager associated with the scene
  44897. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44898. */
  44899. gamepadManager: GamepadManager;
  44900. }
  44901. /**
  44902. * Interface representing a free camera inputs manager
  44903. */
  44904. interface FreeCameraInputsManager {
  44905. /**
  44906. * Adds gamepad input support to the FreeCameraInputsManager.
  44907. * @returns the FreeCameraInputsManager
  44908. */
  44909. addGamepad(): FreeCameraInputsManager;
  44910. }
  44911. /**
  44912. * Interface representing an arc rotate camera inputs manager
  44913. */
  44914. interface ArcRotateCameraInputsManager {
  44915. /**
  44916. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44917. * @returns the camera inputs manager
  44918. */
  44919. addGamepad(): ArcRotateCameraInputsManager;
  44920. }
  44921. /**
  44922. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44923. */
  44924. export class GamepadSystemSceneComponent implements ISceneComponent {
  44925. /**
  44926. * The component name helpfull to identify the component in the list of scene components.
  44927. */
  44928. readonly name: string;
  44929. /**
  44930. * The scene the component belongs to.
  44931. */
  44932. scene: Scene;
  44933. /**
  44934. * Creates a new instance of the component for the given scene
  44935. * @param scene Defines the scene to register the component in
  44936. */
  44937. constructor(scene: Scene);
  44938. /**
  44939. * Registers the component in a given scene
  44940. */
  44941. register(): void;
  44942. /**
  44943. * Rebuilds the elements related to this component in case of
  44944. * context lost for instance.
  44945. */
  44946. rebuild(): void;
  44947. /**
  44948. * Disposes the component and the associated ressources
  44949. */
  44950. dispose(): void;
  44951. private _beforeCameraUpdate;
  44952. }
  44953. }
  44954. declare module BABYLON {
  44955. /**
  44956. * 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,
  44957. * which still works and will still be found in many Playgrounds.
  44958. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44959. */
  44960. export class UniversalCamera extends TouchCamera {
  44961. /**
  44962. * Defines the gamepad rotation sensiblity.
  44963. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44964. */
  44965. get gamepadAngularSensibility(): number;
  44966. set gamepadAngularSensibility(value: number);
  44967. /**
  44968. * Defines the gamepad move sensiblity.
  44969. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44970. */
  44971. get gamepadMoveSensibility(): number;
  44972. set gamepadMoveSensibility(value: number);
  44973. /**
  44974. * 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,
  44975. * which still works and will still be found in many Playgrounds.
  44976. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44977. * @param name Define the name of the camera in the scene
  44978. * @param position Define the start position of the camera in the scene
  44979. * @param scene Define the scene the camera belongs to
  44980. */
  44981. constructor(name: string, position: Vector3, scene: Scene);
  44982. /**
  44983. * Gets the current object class name.
  44984. * @return the class name
  44985. */
  44986. getClassName(): string;
  44987. }
  44988. }
  44989. declare module BABYLON {
  44990. /**
  44991. * This represents a FPS type of camera. This is only here for back compat purpose.
  44992. * Please use the UniversalCamera instead as both are identical.
  44993. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44994. */
  44995. export class GamepadCamera extends UniversalCamera {
  44996. /**
  44997. * Instantiates a new Gamepad Camera
  44998. * This represents a FPS type of camera. This is only here for back compat purpose.
  44999. * Please use the UniversalCamera instead as both are identical.
  45000. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45001. * @param name Define the name of the camera in the scene
  45002. * @param position Define the start position of the camera in the scene
  45003. * @param scene Define the scene the camera belongs to
  45004. */
  45005. constructor(name: string, position: Vector3, scene: Scene);
  45006. /**
  45007. * Gets the current object class name.
  45008. * @return the class name
  45009. */
  45010. getClassName(): string;
  45011. }
  45012. }
  45013. declare module BABYLON {
  45014. /** @hidden */
  45015. export var passPixelShader: {
  45016. name: string;
  45017. shader: string;
  45018. };
  45019. }
  45020. declare module BABYLON {
  45021. /** @hidden */
  45022. export var passCubePixelShader: {
  45023. name: string;
  45024. shader: string;
  45025. };
  45026. }
  45027. declare module BABYLON {
  45028. /**
  45029. * PassPostProcess which produces an output the same as it's input
  45030. */
  45031. export class PassPostProcess extends PostProcess {
  45032. /**
  45033. * Creates the PassPostProcess
  45034. * @param name The name of the effect.
  45035. * @param options The required width/height ratio to downsize to before computing the render pass.
  45036. * @param camera The camera to apply the render pass to.
  45037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45038. * @param engine The engine which the post process will be applied. (default: current engine)
  45039. * @param reusable If the post process can be reused on the same frame. (default: false)
  45040. * @param textureType The type of texture to be used when performing the post processing.
  45041. * @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)
  45042. */
  45043. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45044. }
  45045. /**
  45046. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45047. */
  45048. export class PassCubePostProcess extends PostProcess {
  45049. private _face;
  45050. /**
  45051. * Gets or sets the cube face to display.
  45052. * * 0 is +X
  45053. * * 1 is -X
  45054. * * 2 is +Y
  45055. * * 3 is -Y
  45056. * * 4 is +Z
  45057. * * 5 is -Z
  45058. */
  45059. get face(): number;
  45060. set face(value: number);
  45061. /**
  45062. * Creates the PassCubePostProcess
  45063. * @param name The name of the effect.
  45064. * @param options The required width/height ratio to downsize to before computing the render pass.
  45065. * @param camera The camera to apply the render pass to.
  45066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45067. * @param engine The engine which the post process will be applied. (default: current engine)
  45068. * @param reusable If the post process can be reused on the same frame. (default: false)
  45069. * @param textureType The type of texture to be used when performing the post processing.
  45070. * @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)
  45071. */
  45072. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45073. }
  45074. }
  45075. declare module BABYLON {
  45076. /** @hidden */
  45077. export var anaglyphPixelShader: {
  45078. name: string;
  45079. shader: string;
  45080. };
  45081. }
  45082. declare module BABYLON {
  45083. /**
  45084. * Postprocess used to generate anaglyphic rendering
  45085. */
  45086. export class AnaglyphPostProcess extends PostProcess {
  45087. private _passedProcess;
  45088. /**
  45089. * Creates a new AnaglyphPostProcess
  45090. * @param name defines postprocess name
  45091. * @param options defines creation options or target ratio scale
  45092. * @param rigCameras defines cameras using this postprocess
  45093. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45094. * @param engine defines hosting engine
  45095. * @param reusable defines if the postprocess will be reused multiple times per frame
  45096. */
  45097. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45098. }
  45099. }
  45100. declare module BABYLON {
  45101. /**
  45102. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45103. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45104. */
  45105. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45106. /**
  45107. * Creates a new AnaglyphArcRotateCamera
  45108. * @param name defines camera name
  45109. * @param alpha defines alpha angle (in radians)
  45110. * @param beta defines beta angle (in radians)
  45111. * @param radius defines radius
  45112. * @param target defines camera target
  45113. * @param interaxialDistance defines distance between each color axis
  45114. * @param scene defines the hosting scene
  45115. */
  45116. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45117. /**
  45118. * Gets camera class name
  45119. * @returns AnaglyphArcRotateCamera
  45120. */
  45121. getClassName(): string;
  45122. }
  45123. }
  45124. declare module BABYLON {
  45125. /**
  45126. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45127. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45128. */
  45129. export class AnaglyphFreeCamera extends FreeCamera {
  45130. /**
  45131. * Creates a new AnaglyphFreeCamera
  45132. * @param name defines camera name
  45133. * @param position defines initial position
  45134. * @param interaxialDistance defines distance between each color axis
  45135. * @param scene defines the hosting scene
  45136. */
  45137. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45138. /**
  45139. * Gets camera class name
  45140. * @returns AnaglyphFreeCamera
  45141. */
  45142. getClassName(): string;
  45143. }
  45144. }
  45145. declare module BABYLON {
  45146. /**
  45147. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45148. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45149. */
  45150. export class AnaglyphGamepadCamera extends GamepadCamera {
  45151. /**
  45152. * Creates a new AnaglyphGamepadCamera
  45153. * @param name defines camera name
  45154. * @param position defines initial position
  45155. * @param interaxialDistance defines distance between each color axis
  45156. * @param scene defines the hosting scene
  45157. */
  45158. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45159. /**
  45160. * Gets camera class name
  45161. * @returns AnaglyphGamepadCamera
  45162. */
  45163. getClassName(): string;
  45164. }
  45165. }
  45166. declare module BABYLON {
  45167. /**
  45168. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45169. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45170. */
  45171. export class AnaglyphUniversalCamera extends UniversalCamera {
  45172. /**
  45173. * Creates a new AnaglyphUniversalCamera
  45174. * @param name defines camera name
  45175. * @param position defines initial position
  45176. * @param interaxialDistance defines distance between each color axis
  45177. * @param scene defines the hosting scene
  45178. */
  45179. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45180. /**
  45181. * Gets camera class name
  45182. * @returns AnaglyphUniversalCamera
  45183. */
  45184. getClassName(): string;
  45185. }
  45186. }
  45187. declare module BABYLON {
  45188. /**
  45189. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  45190. * @see http://doc.babylonjs.com/features/cameras
  45191. */
  45192. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  45193. /**
  45194. * Creates a new StereoscopicArcRotateCamera
  45195. * @param name defines camera name
  45196. * @param alpha defines alpha angle (in radians)
  45197. * @param beta defines beta angle (in radians)
  45198. * @param radius defines radius
  45199. * @param target defines camera target
  45200. * @param interaxialDistance defines distance between each color axis
  45201. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45202. * @param scene defines the hosting scene
  45203. */
  45204. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45205. /**
  45206. * Gets camera class name
  45207. * @returns StereoscopicArcRotateCamera
  45208. */
  45209. getClassName(): string;
  45210. }
  45211. }
  45212. declare module BABYLON {
  45213. /**
  45214. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45215. * @see http://doc.babylonjs.com/features/cameras
  45216. */
  45217. export class StereoscopicFreeCamera extends FreeCamera {
  45218. /**
  45219. * Creates a new StereoscopicFreeCamera
  45220. * @param name defines camera name
  45221. * @param position defines initial position
  45222. * @param interaxialDistance defines distance between each color axis
  45223. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45224. * @param scene defines the hosting scene
  45225. */
  45226. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45227. /**
  45228. * Gets camera class name
  45229. * @returns StereoscopicFreeCamera
  45230. */
  45231. getClassName(): string;
  45232. }
  45233. }
  45234. declare module BABYLON {
  45235. /**
  45236. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45237. * @see http://doc.babylonjs.com/features/cameras
  45238. */
  45239. export class StereoscopicGamepadCamera extends GamepadCamera {
  45240. /**
  45241. * Creates a new StereoscopicGamepadCamera
  45242. * @param name defines camera name
  45243. * @param position defines initial position
  45244. * @param interaxialDistance defines distance between each color axis
  45245. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45246. * @param scene defines the hosting scene
  45247. */
  45248. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45249. /**
  45250. * Gets camera class name
  45251. * @returns StereoscopicGamepadCamera
  45252. */
  45253. getClassName(): string;
  45254. }
  45255. }
  45256. declare module BABYLON {
  45257. /**
  45258. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  45259. * @see http://doc.babylonjs.com/features/cameras
  45260. */
  45261. export class StereoscopicUniversalCamera extends UniversalCamera {
  45262. /**
  45263. * Creates a new StereoscopicUniversalCamera
  45264. * @param name defines camera name
  45265. * @param position defines initial position
  45266. * @param interaxialDistance defines distance between each color axis
  45267. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45268. * @param scene defines the hosting scene
  45269. */
  45270. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45271. /**
  45272. * Gets camera class name
  45273. * @returns StereoscopicUniversalCamera
  45274. */
  45275. getClassName(): string;
  45276. }
  45277. }
  45278. declare module BABYLON {
  45279. /**
  45280. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45281. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45282. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45283. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45284. */
  45285. export class VirtualJoysticksCamera extends FreeCamera {
  45286. /**
  45287. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45288. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45289. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45290. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45291. * @param name Define the name of the camera in the scene
  45292. * @param position Define the start position of the camera in the scene
  45293. * @param scene Define the scene the camera belongs to
  45294. */
  45295. constructor(name: string, position: Vector3, scene: Scene);
  45296. /**
  45297. * Gets the current object class name.
  45298. * @return the class name
  45299. */
  45300. getClassName(): string;
  45301. }
  45302. }
  45303. declare module BABYLON {
  45304. /**
  45305. * This represents all the required metrics to create a VR camera.
  45306. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45307. */
  45308. export class VRCameraMetrics {
  45309. /**
  45310. * Define the horizontal resolution off the screen.
  45311. */
  45312. hResolution: number;
  45313. /**
  45314. * Define the vertical resolution off the screen.
  45315. */
  45316. vResolution: number;
  45317. /**
  45318. * Define the horizontal screen size.
  45319. */
  45320. hScreenSize: number;
  45321. /**
  45322. * Define the vertical screen size.
  45323. */
  45324. vScreenSize: number;
  45325. /**
  45326. * Define the vertical screen center position.
  45327. */
  45328. vScreenCenter: number;
  45329. /**
  45330. * Define the distance of the eyes to the screen.
  45331. */
  45332. eyeToScreenDistance: number;
  45333. /**
  45334. * Define the distance between both lenses
  45335. */
  45336. lensSeparationDistance: number;
  45337. /**
  45338. * Define the distance between both viewer's eyes.
  45339. */
  45340. interpupillaryDistance: number;
  45341. /**
  45342. * Define the distortion factor of the VR postprocess.
  45343. * Please, touch with care.
  45344. */
  45345. distortionK: number[];
  45346. /**
  45347. * Define the chromatic aberration correction factors for the VR post process.
  45348. */
  45349. chromaAbCorrection: number[];
  45350. /**
  45351. * Define the scale factor of the post process.
  45352. * The smaller the better but the slower.
  45353. */
  45354. postProcessScaleFactor: number;
  45355. /**
  45356. * Define an offset for the lens center.
  45357. */
  45358. lensCenterOffset: number;
  45359. /**
  45360. * Define if the current vr camera should compensate the distortion of the lense or not.
  45361. */
  45362. compensateDistortion: boolean;
  45363. /**
  45364. * Defines if multiview should be enabled when rendering (Default: false)
  45365. */
  45366. multiviewEnabled: boolean;
  45367. /**
  45368. * Gets the rendering aspect ratio based on the provided resolutions.
  45369. */
  45370. get aspectRatio(): number;
  45371. /**
  45372. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45373. */
  45374. get aspectRatioFov(): number;
  45375. /**
  45376. * @hidden
  45377. */
  45378. get leftHMatrix(): Matrix;
  45379. /**
  45380. * @hidden
  45381. */
  45382. get rightHMatrix(): Matrix;
  45383. /**
  45384. * @hidden
  45385. */
  45386. get leftPreViewMatrix(): Matrix;
  45387. /**
  45388. * @hidden
  45389. */
  45390. get rightPreViewMatrix(): Matrix;
  45391. /**
  45392. * Get the default VRMetrics based on the most generic setup.
  45393. * @returns the default vr metrics
  45394. */
  45395. static GetDefault(): VRCameraMetrics;
  45396. }
  45397. }
  45398. declare module BABYLON {
  45399. /** @hidden */
  45400. export var vrDistortionCorrectionPixelShader: {
  45401. name: string;
  45402. shader: string;
  45403. };
  45404. }
  45405. declare module BABYLON {
  45406. /**
  45407. * VRDistortionCorrectionPostProcess used for mobile VR
  45408. */
  45409. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45410. private _isRightEye;
  45411. private _distortionFactors;
  45412. private _postProcessScaleFactor;
  45413. private _lensCenterOffset;
  45414. private _scaleIn;
  45415. private _scaleFactor;
  45416. private _lensCenter;
  45417. /**
  45418. * Initializes the VRDistortionCorrectionPostProcess
  45419. * @param name The name of the effect.
  45420. * @param camera The camera to apply the render pass to.
  45421. * @param isRightEye If this is for the right eye distortion
  45422. * @param vrMetrics All the required metrics for the VR camera
  45423. */
  45424. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45425. }
  45426. }
  45427. declare module BABYLON {
  45428. /**
  45429. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45430. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45431. */
  45432. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45433. /**
  45434. * Creates a new VRDeviceOrientationArcRotateCamera
  45435. * @param name defines camera name
  45436. * @param alpha defines the camera rotation along the logitudinal axis
  45437. * @param beta defines the camera rotation along the latitudinal axis
  45438. * @param radius defines the camera distance from its target
  45439. * @param target defines the camera target
  45440. * @param scene defines the scene the camera belongs to
  45441. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45442. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45443. */
  45444. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45445. /**
  45446. * Gets camera class name
  45447. * @returns VRDeviceOrientationArcRotateCamera
  45448. */
  45449. getClassName(): string;
  45450. }
  45451. }
  45452. declare module BABYLON {
  45453. /**
  45454. * Camera used to simulate VR rendering (based on FreeCamera)
  45455. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45456. */
  45457. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45458. /**
  45459. * Creates a new VRDeviceOrientationFreeCamera
  45460. * @param name defines camera name
  45461. * @param position defines the start position of the camera
  45462. * @param scene defines the scene the camera belongs to
  45463. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45464. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45465. */
  45466. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45467. /**
  45468. * Gets camera class name
  45469. * @returns VRDeviceOrientationFreeCamera
  45470. */
  45471. getClassName(): string;
  45472. }
  45473. }
  45474. declare module BABYLON {
  45475. /**
  45476. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45477. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45478. */
  45479. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45480. /**
  45481. * Creates a new VRDeviceOrientationGamepadCamera
  45482. * @param name defines camera name
  45483. * @param position defines the start position of the camera
  45484. * @param scene defines the scene the camera belongs to
  45485. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45486. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45487. */
  45488. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45489. /**
  45490. * Gets camera class name
  45491. * @returns VRDeviceOrientationGamepadCamera
  45492. */
  45493. getClassName(): string;
  45494. }
  45495. }
  45496. declare module BABYLON {
  45497. /**
  45498. * A class extending Texture allowing drawing on a texture
  45499. * @see http://doc.babylonjs.com/how_to/dynamictexture
  45500. */
  45501. export class DynamicTexture extends Texture {
  45502. private _generateMipMaps;
  45503. private _canvas;
  45504. private _context;
  45505. /**
  45506. * Creates a DynamicTexture
  45507. * @param name defines the name of the texture
  45508. * @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
  45509. * @param scene defines the scene where you want the texture
  45510. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  45511. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  45512. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  45513. */
  45514. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  45515. /**
  45516. * Get the current class name of the texture useful for serialization or dynamic coding.
  45517. * @returns "DynamicTexture"
  45518. */
  45519. getClassName(): string;
  45520. /**
  45521. * Gets the current state of canRescale
  45522. */
  45523. get canRescale(): boolean;
  45524. private _recreate;
  45525. /**
  45526. * Scales the texture
  45527. * @param ratio the scale factor to apply to both width and height
  45528. */
  45529. scale(ratio: number): void;
  45530. /**
  45531. * Resizes the texture
  45532. * @param width the new width
  45533. * @param height the new height
  45534. */
  45535. scaleTo(width: number, height: number): void;
  45536. /**
  45537. * Gets the context of the canvas used by the texture
  45538. * @returns the canvas context of the dynamic texture
  45539. */
  45540. getContext(): CanvasRenderingContext2D;
  45541. /**
  45542. * Clears the texture
  45543. */
  45544. clear(): void;
  45545. /**
  45546. * Updates the texture
  45547. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45548. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  45549. */
  45550. update(invertY?: boolean, premulAlpha?: boolean): void;
  45551. /**
  45552. * Draws text onto the texture
  45553. * @param text defines the text to be drawn
  45554. * @param x defines the placement of the text from the left
  45555. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  45556. * @param font defines the font to be used with font-style, font-size, font-name
  45557. * @param color defines the color used for the text
  45558. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  45559. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45560. * @param update defines whether texture is immediately update (default is true)
  45561. */
  45562. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  45563. /**
  45564. * Clones the texture
  45565. * @returns the clone of the texture.
  45566. */
  45567. clone(): DynamicTexture;
  45568. /**
  45569. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  45570. * @returns a serialized dynamic texture object
  45571. */
  45572. serialize(): any;
  45573. private _IsCanvasElement;
  45574. /** @hidden */
  45575. _rebuild(): void;
  45576. }
  45577. }
  45578. declare module BABYLON {
  45579. /** @hidden */
  45580. export var imageProcessingPixelShader: {
  45581. name: string;
  45582. shader: string;
  45583. };
  45584. }
  45585. declare module BABYLON {
  45586. /**
  45587. * ImageProcessingPostProcess
  45588. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45589. */
  45590. export class ImageProcessingPostProcess extends PostProcess {
  45591. /**
  45592. * Default configuration related to image processing available in the PBR Material.
  45593. */
  45594. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45595. /**
  45596. * Gets the image processing configuration used either in this material.
  45597. */
  45598. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45599. /**
  45600. * Sets the Default image processing configuration used either in the this material.
  45601. *
  45602. * If sets to null, the scene one is in use.
  45603. */
  45604. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45605. /**
  45606. * Keep track of the image processing observer to allow dispose and replace.
  45607. */
  45608. private _imageProcessingObserver;
  45609. /**
  45610. * Attaches a new image processing configuration to the PBR Material.
  45611. * @param configuration
  45612. */
  45613. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45614. /**
  45615. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45616. */
  45617. get colorCurves(): Nullable<ColorCurves>;
  45618. /**
  45619. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45620. */
  45621. set colorCurves(value: Nullable<ColorCurves>);
  45622. /**
  45623. * Gets wether the color curves effect is enabled.
  45624. */
  45625. get colorCurvesEnabled(): boolean;
  45626. /**
  45627. * Sets wether the color curves effect is enabled.
  45628. */
  45629. set colorCurvesEnabled(value: boolean);
  45630. /**
  45631. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45632. */
  45633. get colorGradingTexture(): Nullable<BaseTexture>;
  45634. /**
  45635. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45636. */
  45637. set colorGradingTexture(value: Nullable<BaseTexture>);
  45638. /**
  45639. * Gets wether the color grading effect is enabled.
  45640. */
  45641. get colorGradingEnabled(): boolean;
  45642. /**
  45643. * Gets wether the color grading effect is enabled.
  45644. */
  45645. set colorGradingEnabled(value: boolean);
  45646. /**
  45647. * Gets exposure used in the effect.
  45648. */
  45649. get exposure(): number;
  45650. /**
  45651. * Sets exposure used in the effect.
  45652. */
  45653. set exposure(value: number);
  45654. /**
  45655. * Gets wether tonemapping is enabled or not.
  45656. */
  45657. get toneMappingEnabled(): boolean;
  45658. /**
  45659. * Sets wether tonemapping is enabled or not
  45660. */
  45661. set toneMappingEnabled(value: boolean);
  45662. /**
  45663. * Gets the type of tone mapping effect.
  45664. */
  45665. get toneMappingType(): number;
  45666. /**
  45667. * Sets the type of tone mapping effect.
  45668. */
  45669. set toneMappingType(value: number);
  45670. /**
  45671. * Gets contrast used in the effect.
  45672. */
  45673. get contrast(): number;
  45674. /**
  45675. * Sets contrast used in the effect.
  45676. */
  45677. set contrast(value: number);
  45678. /**
  45679. * Gets Vignette stretch size.
  45680. */
  45681. get vignetteStretch(): number;
  45682. /**
  45683. * Sets Vignette stretch size.
  45684. */
  45685. set vignetteStretch(value: number);
  45686. /**
  45687. * Gets Vignette centre X Offset.
  45688. */
  45689. get vignetteCentreX(): number;
  45690. /**
  45691. * Sets Vignette centre X Offset.
  45692. */
  45693. set vignetteCentreX(value: number);
  45694. /**
  45695. * Gets Vignette centre Y Offset.
  45696. */
  45697. get vignetteCentreY(): number;
  45698. /**
  45699. * Sets Vignette centre Y Offset.
  45700. */
  45701. set vignetteCentreY(value: number);
  45702. /**
  45703. * Gets Vignette weight or intensity of the vignette effect.
  45704. */
  45705. get vignetteWeight(): number;
  45706. /**
  45707. * Sets Vignette weight or intensity of the vignette effect.
  45708. */
  45709. set vignetteWeight(value: number);
  45710. /**
  45711. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45712. * if vignetteEnabled is set to true.
  45713. */
  45714. get vignetteColor(): Color4;
  45715. /**
  45716. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45717. * if vignetteEnabled is set to true.
  45718. */
  45719. set vignetteColor(value: Color4);
  45720. /**
  45721. * Gets Camera field of view used by the Vignette effect.
  45722. */
  45723. get vignetteCameraFov(): number;
  45724. /**
  45725. * Sets Camera field of view used by the Vignette effect.
  45726. */
  45727. set vignetteCameraFov(value: number);
  45728. /**
  45729. * Gets the vignette blend mode allowing different kind of effect.
  45730. */
  45731. get vignetteBlendMode(): number;
  45732. /**
  45733. * Sets the vignette blend mode allowing different kind of effect.
  45734. */
  45735. set vignetteBlendMode(value: number);
  45736. /**
  45737. * Gets wether the vignette effect is enabled.
  45738. */
  45739. get vignetteEnabled(): boolean;
  45740. /**
  45741. * Sets wether the vignette effect is enabled.
  45742. */
  45743. set vignetteEnabled(value: boolean);
  45744. private _fromLinearSpace;
  45745. /**
  45746. * Gets wether the input of the processing is in Gamma or Linear Space.
  45747. */
  45748. get fromLinearSpace(): boolean;
  45749. /**
  45750. * Sets wether the input of the processing is in Gamma or Linear Space.
  45751. */
  45752. set fromLinearSpace(value: boolean);
  45753. /**
  45754. * Defines cache preventing GC.
  45755. */
  45756. private _defines;
  45757. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45758. /**
  45759. * "ImageProcessingPostProcess"
  45760. * @returns "ImageProcessingPostProcess"
  45761. */
  45762. getClassName(): string;
  45763. protected _updateParameters(): void;
  45764. dispose(camera?: Camera): void;
  45765. }
  45766. }
  45767. declare module BABYLON {
  45768. /**
  45769. * Class containing static functions to help procedurally build meshes
  45770. */
  45771. export class GroundBuilder {
  45772. /**
  45773. * Creates a ground mesh
  45774. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45775. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45777. * @param name defines the name of the mesh
  45778. * @param options defines the options used to create the mesh
  45779. * @param scene defines the hosting scene
  45780. * @returns the ground mesh
  45781. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45782. */
  45783. static CreateGround(name: string, options: {
  45784. width?: number;
  45785. height?: number;
  45786. subdivisions?: number;
  45787. subdivisionsX?: number;
  45788. subdivisionsY?: number;
  45789. updatable?: boolean;
  45790. }, scene: any): Mesh;
  45791. /**
  45792. * Creates a tiled ground mesh
  45793. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45794. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45795. * * 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
  45796. * * 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
  45797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45798. * @param name defines the name of the mesh
  45799. * @param options defines the options used to create the mesh
  45800. * @param scene defines the hosting scene
  45801. * @returns the tiled ground mesh
  45802. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45803. */
  45804. static CreateTiledGround(name: string, options: {
  45805. xmin: number;
  45806. zmin: number;
  45807. xmax: number;
  45808. zmax: number;
  45809. subdivisions?: {
  45810. w: number;
  45811. h: number;
  45812. };
  45813. precision?: {
  45814. w: number;
  45815. h: number;
  45816. };
  45817. updatable?: boolean;
  45818. }, scene?: Nullable<Scene>): Mesh;
  45819. /**
  45820. * Creates a ground mesh from a height map
  45821. * * The parameter `url` sets the URL of the height map image resource.
  45822. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45823. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45824. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45825. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45826. * * 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.
  45827. * * 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).
  45828. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45830. * @param name defines the name of the mesh
  45831. * @param url defines the url to the height map
  45832. * @param options defines the options used to create the mesh
  45833. * @param scene defines the hosting scene
  45834. * @returns the ground mesh
  45835. * @see https://doc.babylonjs.com/babylon101/height_map
  45836. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45837. */
  45838. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45839. width?: number;
  45840. height?: number;
  45841. subdivisions?: number;
  45842. minHeight?: number;
  45843. maxHeight?: number;
  45844. colorFilter?: Color3;
  45845. alphaFilter?: number;
  45846. updatable?: boolean;
  45847. onReady?: (mesh: GroundMesh) => void;
  45848. }, scene?: Nullable<Scene>): GroundMesh;
  45849. }
  45850. }
  45851. declare module BABYLON {
  45852. /**
  45853. * Class containing static functions to help procedurally build meshes
  45854. */
  45855. export class TorusBuilder {
  45856. /**
  45857. * Creates a torus mesh
  45858. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45859. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45860. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45862. * * 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
  45863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45864. * @param name defines the name of the mesh
  45865. * @param options defines the options used to create the mesh
  45866. * @param scene defines the hosting scene
  45867. * @returns the torus mesh
  45868. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45869. */
  45870. static CreateTorus(name: string, options: {
  45871. diameter?: number;
  45872. thickness?: number;
  45873. tessellation?: number;
  45874. updatable?: boolean;
  45875. sideOrientation?: number;
  45876. frontUVs?: Vector4;
  45877. backUVs?: Vector4;
  45878. }, scene: any): Mesh;
  45879. }
  45880. }
  45881. declare module BABYLON {
  45882. /**
  45883. * Class containing static functions to help procedurally build meshes
  45884. */
  45885. export class CylinderBuilder {
  45886. /**
  45887. * Creates a cylinder or a cone mesh
  45888. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45889. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45890. * * 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.
  45891. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45892. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45893. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45894. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45895. * * 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).
  45896. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45897. * * 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).
  45898. * * 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
  45899. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45900. * * 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
  45901. * * 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.
  45902. * * If `enclose` is false, a ring surface is one element.
  45903. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45904. * * 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
  45905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45906. * * 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
  45907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45908. * @param name defines the name of the mesh
  45909. * @param options defines the options used to create the mesh
  45910. * @param scene defines the hosting scene
  45911. * @returns the cylinder mesh
  45912. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45913. */
  45914. static CreateCylinder(name: string, options: {
  45915. height?: number;
  45916. diameterTop?: number;
  45917. diameterBottom?: number;
  45918. diameter?: number;
  45919. tessellation?: number;
  45920. subdivisions?: number;
  45921. arc?: number;
  45922. faceColors?: Color4[];
  45923. faceUV?: Vector4[];
  45924. updatable?: boolean;
  45925. hasRings?: boolean;
  45926. enclose?: boolean;
  45927. cap?: number;
  45928. sideOrientation?: number;
  45929. frontUVs?: Vector4;
  45930. backUVs?: Vector4;
  45931. }, scene: any): Mesh;
  45932. }
  45933. }
  45934. declare module BABYLON {
  45935. /**
  45936. * States of the webXR experience
  45937. */
  45938. export enum WebXRState {
  45939. /**
  45940. * Transitioning to being in XR mode
  45941. */
  45942. ENTERING_XR = 0,
  45943. /**
  45944. * Transitioning to non XR mode
  45945. */
  45946. EXITING_XR = 1,
  45947. /**
  45948. * In XR mode and presenting
  45949. */
  45950. IN_XR = 2,
  45951. /**
  45952. * Not entered XR mode
  45953. */
  45954. NOT_IN_XR = 3
  45955. }
  45956. /**
  45957. * Abstraction of the XR render target
  45958. */
  45959. export interface WebXRRenderTarget extends IDisposable {
  45960. /**
  45961. * xrpresent context of the canvas which can be used to display/mirror xr content
  45962. */
  45963. canvasContext: WebGLRenderingContext;
  45964. /**
  45965. * xr layer for the canvas
  45966. */
  45967. xrLayer: Nullable<XRWebGLLayer>;
  45968. /**
  45969. * Initializes the xr layer for the session
  45970. * @param xrSession xr session
  45971. * @returns a promise that will resolve once the XR Layer has been created
  45972. */
  45973. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45974. }
  45975. }
  45976. declare module BABYLON {
  45977. /**
  45978. * COnfiguration object for WebXR output canvas
  45979. */
  45980. export class WebXRManagedOutputCanvasOptions {
  45981. /**
  45982. * An optional canvas in case you wish to create it yourself and provide it here.
  45983. * If not provided, a new canvas will be created
  45984. */
  45985. canvasElement?: HTMLCanvasElement;
  45986. /**
  45987. * Options for this XR Layer output
  45988. */
  45989. canvasOptions?: XRWebGLLayerOptions;
  45990. /**
  45991. * CSS styling for a newly created canvas (if not provided)
  45992. */
  45993. newCanvasCssStyle?: string;
  45994. /**
  45995. * Get the default values of the configuration object
  45996. * @returns default values of this configuration object
  45997. */
  45998. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45999. }
  46000. /**
  46001. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46002. */
  46003. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46004. private _options;
  46005. private _canvas;
  46006. private _engine;
  46007. /**
  46008. * Rendering context of the canvas which can be used to display/mirror xr content
  46009. */
  46010. canvasContext: WebGLRenderingContext;
  46011. /**
  46012. * xr layer for the canvas
  46013. */
  46014. xrLayer: Nullable<XRWebGLLayer>;
  46015. /**
  46016. * Initializes the canvas to be added/removed upon entering/exiting xr
  46017. * @param _xrSessionManager The XR Session manager
  46018. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46019. */
  46020. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46021. /**
  46022. * Disposes of the object
  46023. */
  46024. dispose(): void;
  46025. /**
  46026. * Initializes the xr layer for the session
  46027. * @param xrSession xr session
  46028. * @returns a promise that will resolve once the XR Layer has been created
  46029. */
  46030. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46031. private _addCanvas;
  46032. private _removeCanvas;
  46033. private _setManagedOutputCanvas;
  46034. }
  46035. }
  46036. declare module BABYLON {
  46037. /**
  46038. * Manages an XRSession to work with Babylon's engine
  46039. * @see https://doc.babylonjs.com/how_to/webxr
  46040. */
  46041. export class WebXRSessionManager implements IDisposable {
  46042. /** The scene which the session should be created for */
  46043. scene: Scene;
  46044. private _referenceSpace;
  46045. private _rttProvider;
  46046. private _sessionEnded;
  46047. private _xrNavigator;
  46048. private baseLayer;
  46049. /**
  46050. * The base reference space from which the session started. good if you want to reset your
  46051. * reference space
  46052. */
  46053. baseReferenceSpace: XRReferenceSpace;
  46054. /**
  46055. * Current XR frame
  46056. */
  46057. currentFrame: Nullable<XRFrame>;
  46058. /** WebXR timestamp updated every frame */
  46059. currentTimestamp: number;
  46060. /**
  46061. * Used just in case of a failure to initialize an immersive session.
  46062. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46063. */
  46064. defaultHeightCompensation: number;
  46065. /**
  46066. * Fires every time a new xrFrame arrives which can be used to update the camera
  46067. */
  46068. onXRFrameObservable: Observable<XRFrame>;
  46069. /**
  46070. * Fires when the reference space changed
  46071. */
  46072. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46073. /**
  46074. * Fires when the xr session is ended either by the device or manually done
  46075. */
  46076. onXRSessionEnded: Observable<any>;
  46077. /**
  46078. * Fires when the xr session is ended either by the device or manually done
  46079. */
  46080. onXRSessionInit: Observable<XRSession>;
  46081. /**
  46082. * Underlying xr session
  46083. */
  46084. session: XRSession;
  46085. /**
  46086. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46087. * or get the offset the player is currently at.
  46088. */
  46089. viewerReferenceSpace: XRReferenceSpace;
  46090. /**
  46091. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46092. * @param scene The scene which the session should be created for
  46093. */
  46094. constructor(
  46095. /** The scene which the session should be created for */
  46096. scene: Scene);
  46097. /**
  46098. * The current reference space used in this session. This reference space can constantly change!
  46099. * It is mainly used to offset the camera's position.
  46100. */
  46101. get referenceSpace(): XRReferenceSpace;
  46102. /**
  46103. * Set a new reference space and triggers the observable
  46104. */
  46105. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46106. /**
  46107. * Disposes of the session manager
  46108. */
  46109. dispose(): void;
  46110. /**
  46111. * Stops the xrSession and restores the render loop
  46112. * @returns Promise which resolves after it exits XR
  46113. */
  46114. exitXRAsync(): Promise<void>;
  46115. /**
  46116. * Gets the correct render target texture to be rendered this frame for this eye
  46117. * @param eye the eye for which to get the render target
  46118. * @returns the render target for the specified eye
  46119. */
  46120. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46121. /**
  46122. * Creates a WebXRRenderTarget object for the XR session
  46123. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46124. * @param options optional options to provide when creating a new render target
  46125. * @returns a WebXR render target to which the session can render
  46126. */
  46127. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46128. /**
  46129. * Initializes the manager
  46130. * After initialization enterXR can be called to start an XR session
  46131. * @returns Promise which resolves after it is initialized
  46132. */
  46133. initializeAsync(): Promise<void>;
  46134. /**
  46135. * Initializes an xr session
  46136. * @param xrSessionMode mode to initialize
  46137. * @param xrSessionInit defines optional and required values to pass to the session builder
  46138. * @returns a promise which will resolve once the session has been initialized
  46139. */
  46140. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46141. /**
  46142. * Checks if a session would be supported for the creation options specified
  46143. * @param sessionMode session mode to check if supported eg. immersive-vr
  46144. * @returns A Promise that resolves to true if supported and false if not
  46145. */
  46146. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46147. /**
  46148. * Resets the reference space to the one started the session
  46149. */
  46150. resetReferenceSpace(): void;
  46151. /**
  46152. * Starts rendering to the xr layer
  46153. */
  46154. runXRRenderLoop(): void;
  46155. /**
  46156. * Sets the reference space on the xr session
  46157. * @param referenceSpaceType space to set
  46158. * @returns a promise that will resolve once the reference space has been set
  46159. */
  46160. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46161. /**
  46162. * Updates the render state of the session
  46163. * @param state state to set
  46164. * @returns a promise that resolves once the render state has been updated
  46165. */
  46166. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46167. /**
  46168. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46169. * @param sessionMode defines the session to test
  46170. * @returns a promise with boolean as final value
  46171. */
  46172. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46173. private _createRenderTargetTexture;
  46174. }
  46175. }
  46176. declare module BABYLON {
  46177. /**
  46178. * WebXR Camera which holds the views for the xrSession
  46179. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46180. */
  46181. export class WebXRCamera extends FreeCamera {
  46182. private _xrSessionManager;
  46183. private _firstFrame;
  46184. private _referenceQuaternion;
  46185. private _referencedPosition;
  46186. private _xrInvPositionCache;
  46187. private _xrInvQuaternionCache;
  46188. /**
  46189. * Should position compensation execute on first frame.
  46190. * This is used when copying the position from a native (non XR) camera
  46191. */
  46192. compensateOnFirstFrame: boolean;
  46193. /**
  46194. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46195. * @param name the name of the camera
  46196. * @param scene the scene to add the camera to
  46197. * @param _xrSessionManager a constructed xr session manager
  46198. */
  46199. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46200. /**
  46201. * Return the user's height, unrelated to the current ground.
  46202. * This will be the y position of this camera, when ground level is 0.
  46203. */
  46204. get realWorldHeight(): number;
  46205. /** @hidden */
  46206. _updateForDualEyeDebugging(): void;
  46207. /**
  46208. * Sets this camera's transformation based on a non-vr camera
  46209. * @param otherCamera the non-vr camera to copy the transformation from
  46210. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46211. */
  46212. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46213. /**
  46214. * Gets the current instance class name ("WebXRCamera").
  46215. * @returns the class name
  46216. */
  46217. getClassName(): string;
  46218. /**
  46219. * Overriding the _getViewMatrix function, as it is computed by WebXR
  46220. */
  46221. _getViewMatrix(): Matrix;
  46222. private _updateFromXRSession;
  46223. private _updateNumberOfRigCameras;
  46224. private _updateReferenceSpace;
  46225. private _updateReferenceSpaceOffset;
  46226. }
  46227. }
  46228. declare module BABYLON {
  46229. /**
  46230. * Defining the interface required for a (webxr) feature
  46231. */
  46232. export interface IWebXRFeature extends IDisposable {
  46233. /**
  46234. * Is this feature attached
  46235. */
  46236. attached: boolean;
  46237. /**
  46238. * Should auto-attach be disabled?
  46239. */
  46240. disableAutoAttach: boolean;
  46241. /**
  46242. * Attach the feature to the session
  46243. * Will usually be called by the features manager
  46244. *
  46245. * @param force should attachment be forced (even when already attached)
  46246. * @returns true if successful.
  46247. */
  46248. attach(force?: boolean): boolean;
  46249. /**
  46250. * Detach the feature from the session
  46251. * Will usually be called by the features manager
  46252. *
  46253. * @returns true if successful.
  46254. */
  46255. detach(): boolean;
  46256. }
  46257. /**
  46258. * A list of the currently available features without referencing them
  46259. */
  46260. export class WebXRFeatureName {
  46261. /**
  46262. * The name of the anchor system feature
  46263. */
  46264. static ANCHOR_SYSTEM: string;
  46265. /**
  46266. * The name of the background remover feature
  46267. */
  46268. static BACKGROUND_REMOVER: string;
  46269. /**
  46270. * The name of the hit test feature
  46271. */
  46272. static HIT_TEST: string;
  46273. /**
  46274. * physics impostors for xr controllers feature
  46275. */
  46276. static PHYSICS_CONTROLLERS: string;
  46277. /**
  46278. * The name of the plane detection feature
  46279. */
  46280. static PLANE_DETECTION: string;
  46281. /**
  46282. * The name of the pointer selection feature
  46283. */
  46284. static POINTER_SELECTION: string;
  46285. /**
  46286. * The name of the teleportation feature
  46287. */
  46288. static TELEPORTATION: string;
  46289. }
  46290. /**
  46291. * Defining the constructor of a feature. Used to register the modules.
  46292. */
  46293. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46294. /**
  46295. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46296. * It is mainly used in AR sessions.
  46297. *
  46298. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46299. */
  46300. export class WebXRFeaturesManager implements IDisposable {
  46301. private _xrSessionManager;
  46302. private static readonly _AvailableFeatures;
  46303. private _features;
  46304. /**
  46305. * constructs a new features manages.
  46306. *
  46307. * @param _xrSessionManager an instance of WebXRSessionManager
  46308. */
  46309. constructor(_xrSessionManager: WebXRSessionManager);
  46310. /**
  46311. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46312. * Mainly used internally.
  46313. *
  46314. * @param featureName the name of the feature to register
  46315. * @param constructorFunction the function used to construct the module
  46316. * @param version the (babylon) version of the module
  46317. * @param stable is that a stable version of this module
  46318. */
  46319. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46320. /**
  46321. * Returns a constructor of a specific feature.
  46322. *
  46323. * @param featureName the name of the feature to construct
  46324. * @param version the version of the feature to load
  46325. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46326. * @param options optional options provided to the module.
  46327. * @returns a function that, when called, will return a new instance of this feature
  46328. */
  46329. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46330. /**
  46331. * Can be used to return the list of features currently registered
  46332. *
  46333. * @returns an Array of available features
  46334. */
  46335. static GetAvailableFeatures(): string[];
  46336. /**
  46337. * Gets the versions available for a specific feature
  46338. * @param featureName the name of the feature
  46339. * @returns an array with the available versions
  46340. */
  46341. static GetAvailableVersions(featureName: string): string[];
  46342. /**
  46343. * Return the latest unstable version of this feature
  46344. * @param featureName the name of the feature to search
  46345. * @returns the version number. if not found will return -1
  46346. */
  46347. static GetLatestVersionOfFeature(featureName: string): number;
  46348. /**
  46349. * Return the latest stable version of this feature
  46350. * @param featureName the name of the feature to search
  46351. * @returns the version number. if not found will return -1
  46352. */
  46353. static GetStableVersionOfFeature(featureName: string): number;
  46354. /**
  46355. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46356. * Can be used during a session to start a feature
  46357. * @param featureName the name of feature to attach
  46358. */
  46359. attachFeature(featureName: string): void;
  46360. /**
  46361. * Can be used inside a session or when the session ends to detach a specific feature
  46362. * @param featureName the name of the feature to detach
  46363. */
  46364. detachFeature(featureName: string): void;
  46365. /**
  46366. * Used to disable an already-enabled feature
  46367. * The feature will be disposed and will be recreated once enabled.
  46368. * @param featureName the feature to disable
  46369. * @returns true if disable was successful
  46370. */
  46371. disableFeature(featureName: string | {
  46372. Name: string;
  46373. }): boolean;
  46374. /**
  46375. * dispose this features manager
  46376. */
  46377. dispose(): void;
  46378. /**
  46379. * 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.
  46380. * 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.
  46381. *
  46382. * @param featureName the name of the feature to load or the class of the feature
  46383. * @param version optional version to load. if not provided the latest version will be enabled
  46384. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46385. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46386. * @returns a new constructed feature or throws an error if feature not found.
  46387. */
  46388. enableFeature(featureName: string | {
  46389. Name: string;
  46390. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46391. /**
  46392. * get the implementation of an enabled feature.
  46393. * @param featureName the name of the feature to load
  46394. * @returns the feature class, if found
  46395. */
  46396. getEnabledFeature(featureName: string): IWebXRFeature;
  46397. /**
  46398. * Get the list of enabled features
  46399. * @returns an array of enabled features
  46400. */
  46401. getEnabledFeatures(): string[];
  46402. }
  46403. }
  46404. declare module BABYLON {
  46405. /**
  46406. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46407. * @see https://doc.babylonjs.com/how_to/webxr
  46408. */
  46409. export class WebXRExperienceHelper implements IDisposable {
  46410. private scene;
  46411. private _nonVRCamera;
  46412. private _originalSceneAutoClear;
  46413. private _supported;
  46414. /**
  46415. * Camera used to render xr content
  46416. */
  46417. camera: WebXRCamera;
  46418. /** A features manager for this xr session */
  46419. featuresManager: WebXRFeaturesManager;
  46420. /**
  46421. * Observers registered here will be triggered after the camera's initial transformation is set
  46422. * This can be used to set a different ground level or an extra rotation.
  46423. *
  46424. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46425. * to the position set after this observable is done executing.
  46426. */
  46427. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46428. /**
  46429. * Fires when the state of the experience helper has changed
  46430. */
  46431. onStateChangedObservable: Observable<WebXRState>;
  46432. /** Session manager used to keep track of xr session */
  46433. sessionManager: WebXRSessionManager;
  46434. /**
  46435. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46436. */
  46437. state: WebXRState;
  46438. /**
  46439. * Creates a WebXRExperienceHelper
  46440. * @param scene The scene the helper should be created in
  46441. */
  46442. private constructor();
  46443. /**
  46444. * Creates the experience helper
  46445. * @param scene the scene to attach the experience helper to
  46446. * @returns a promise for the experience helper
  46447. */
  46448. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46449. /**
  46450. * Disposes of the experience helper
  46451. */
  46452. dispose(): void;
  46453. /**
  46454. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46455. * @param sessionMode options for the XR session
  46456. * @param referenceSpaceType frame of reference of the XR session
  46457. * @param renderTarget the output canvas that will be used to enter XR mode
  46458. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46459. * @returns promise that resolves after xr mode has entered
  46460. */
  46461. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46462. /**
  46463. * Exits XR mode and returns the scene to its original state
  46464. * @returns promise that resolves after xr mode has exited
  46465. */
  46466. exitXRAsync(): Promise<void>;
  46467. private _nonXRToXRCamera;
  46468. private _setState;
  46469. }
  46470. }
  46471. declare module BABYLON {
  46472. /**
  46473. * X-Y values for axes in WebXR
  46474. */
  46475. export interface IWebXRMotionControllerAxesValue {
  46476. /**
  46477. * The value of the x axis
  46478. */
  46479. x: number;
  46480. /**
  46481. * The value of the y-axis
  46482. */
  46483. y: number;
  46484. }
  46485. /**
  46486. * changed / previous values for the values of this component
  46487. */
  46488. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46489. /**
  46490. * current (this frame) value
  46491. */
  46492. current: T;
  46493. /**
  46494. * previous (last change) value
  46495. */
  46496. previous: T;
  46497. }
  46498. /**
  46499. * Represents changes in the component between current frame and last values recorded
  46500. */
  46501. export interface IWebXRMotionControllerComponentChanges {
  46502. /**
  46503. * will be populated with previous and current values if axes changed
  46504. */
  46505. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46506. /**
  46507. * will be populated with previous and current values if pressed changed
  46508. */
  46509. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46510. /**
  46511. * will be populated with previous and current values if touched changed
  46512. */
  46513. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46514. /**
  46515. * will be populated with previous and current values if value changed
  46516. */
  46517. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46518. }
  46519. /**
  46520. * This class represents a single component (for example button or thumbstick) of a motion controller
  46521. */
  46522. export class WebXRControllerComponent implements IDisposable {
  46523. /**
  46524. * the id of this component
  46525. */
  46526. id: string;
  46527. /**
  46528. * the type of the component
  46529. */
  46530. type: MotionControllerComponentType;
  46531. private _buttonIndex;
  46532. private _axesIndices;
  46533. private _axes;
  46534. private _changes;
  46535. private _currentValue;
  46536. private _hasChanges;
  46537. private _pressed;
  46538. private _touched;
  46539. /**
  46540. * button component type
  46541. */
  46542. static BUTTON_TYPE: MotionControllerComponentType;
  46543. /**
  46544. * squeeze component type
  46545. */
  46546. static SQUEEZE_TYPE: MotionControllerComponentType;
  46547. /**
  46548. * Thumbstick component type
  46549. */
  46550. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46551. /**
  46552. * Touchpad component type
  46553. */
  46554. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46555. /**
  46556. * trigger component type
  46557. */
  46558. static TRIGGER_TYPE: MotionControllerComponentType;
  46559. /**
  46560. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46561. * the axes data changes
  46562. */
  46563. onAxisValueChangedObservable: Observable<{
  46564. x: number;
  46565. y: number;
  46566. }>;
  46567. /**
  46568. * Observers registered here will be triggered when the state of a button changes
  46569. * State change is either pressed / touched / value
  46570. */
  46571. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46572. /**
  46573. * Creates a new component for a motion controller.
  46574. * It is created by the motion controller itself
  46575. *
  46576. * @param id the id of this component
  46577. * @param type the type of the component
  46578. * @param _buttonIndex index in the buttons array of the gamepad
  46579. * @param _axesIndices indices of the values in the axes array of the gamepad
  46580. */
  46581. constructor(
  46582. /**
  46583. * the id of this component
  46584. */
  46585. id: string,
  46586. /**
  46587. * the type of the component
  46588. */
  46589. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46590. /**
  46591. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46592. */
  46593. get axes(): IWebXRMotionControllerAxesValue;
  46594. /**
  46595. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46596. */
  46597. get changes(): IWebXRMotionControllerComponentChanges;
  46598. /**
  46599. * Return whether or not the component changed the last frame
  46600. */
  46601. get hasChanges(): boolean;
  46602. /**
  46603. * is the button currently pressed
  46604. */
  46605. get pressed(): boolean;
  46606. /**
  46607. * is the button currently touched
  46608. */
  46609. get touched(): boolean;
  46610. /**
  46611. * Get the current value of this component
  46612. */
  46613. get value(): number;
  46614. /**
  46615. * Dispose this component
  46616. */
  46617. dispose(): void;
  46618. /**
  46619. * Are there axes correlating to this component
  46620. * @return true is axes data is available
  46621. */
  46622. isAxes(): boolean;
  46623. /**
  46624. * Is this component a button (hence - pressable)
  46625. * @returns true if can be pressed
  46626. */
  46627. isButton(): boolean;
  46628. /**
  46629. * update this component using the gamepad object it is in. Called on every frame
  46630. * @param nativeController the native gamepad controller object
  46631. */
  46632. update(nativeController: IMinimalMotionControllerObject): void;
  46633. }
  46634. }
  46635. declare module BABYLON {
  46636. /**
  46637. * Interface used to represent data loading progression
  46638. */
  46639. export interface ISceneLoaderProgressEvent {
  46640. /**
  46641. * Defines if data length to load can be evaluated
  46642. */
  46643. readonly lengthComputable: boolean;
  46644. /**
  46645. * Defines the loaded data length
  46646. */
  46647. readonly loaded: number;
  46648. /**
  46649. * Defines the data length to load
  46650. */
  46651. readonly total: number;
  46652. }
  46653. /**
  46654. * Interface used by SceneLoader plugins to define supported file extensions
  46655. */
  46656. export interface ISceneLoaderPluginExtensions {
  46657. /**
  46658. * Defines the list of supported extensions
  46659. */
  46660. [extension: string]: {
  46661. isBinary: boolean;
  46662. };
  46663. }
  46664. /**
  46665. * Interface used by SceneLoader plugin factory
  46666. */
  46667. export interface ISceneLoaderPluginFactory {
  46668. /**
  46669. * Defines the name of the factory
  46670. */
  46671. name: string;
  46672. /**
  46673. * Function called to create a new plugin
  46674. * @return the new plugin
  46675. */
  46676. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46677. /**
  46678. * The callback that returns true if the data can be directly loaded.
  46679. * @param data string containing the file data
  46680. * @returns if the data can be loaded directly
  46681. */
  46682. canDirectLoad?(data: string): boolean;
  46683. }
  46684. /**
  46685. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46686. */
  46687. export interface ISceneLoaderPluginBase {
  46688. /**
  46689. * The friendly name of this plugin.
  46690. */
  46691. name: string;
  46692. /**
  46693. * The file extensions supported by this plugin.
  46694. */
  46695. extensions: string | ISceneLoaderPluginExtensions;
  46696. /**
  46697. * The callback called when loading from a url.
  46698. * @param scene scene loading this url
  46699. * @param url url to load
  46700. * @param onSuccess callback called when the file successfully loads
  46701. * @param onProgress callback called while file is loading (if the server supports this mode)
  46702. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46703. * @param onError callback called when the file fails to load
  46704. * @returns a file request object
  46705. */
  46706. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46707. /**
  46708. * The callback called when loading from a file object.
  46709. * @param scene scene loading this file
  46710. * @param file defines the file to load
  46711. * @param onSuccess defines the callback to call when data is loaded
  46712. * @param onProgress defines the callback to call during loading process
  46713. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46714. * @param onError defines the callback to call when an error occurs
  46715. * @returns a file request object
  46716. */
  46717. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46718. /**
  46719. * The callback that returns true if the data can be directly loaded.
  46720. * @param data string containing the file data
  46721. * @returns if the data can be loaded directly
  46722. */
  46723. canDirectLoad?(data: string): boolean;
  46724. /**
  46725. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46726. * @param scene scene loading this data
  46727. * @param data string containing the data
  46728. * @returns data to pass to the plugin
  46729. */
  46730. directLoad?(scene: Scene, data: string): any;
  46731. /**
  46732. * The callback that allows custom handling of the root url based on the response url.
  46733. * @param rootUrl the original root url
  46734. * @param responseURL the response url if available
  46735. * @returns the new root url
  46736. */
  46737. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46738. }
  46739. /**
  46740. * Interface used to define a SceneLoader plugin
  46741. */
  46742. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46743. /**
  46744. * Import meshes into a scene.
  46745. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46746. * @param scene The scene to import into
  46747. * @param data The data to import
  46748. * @param rootUrl The root url for scene and resources
  46749. * @param meshes The meshes array to import into
  46750. * @param particleSystems The particle systems array to import into
  46751. * @param skeletons The skeletons array to import into
  46752. * @param onError The callback when import fails
  46753. * @returns True if successful or false otherwise
  46754. */
  46755. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46756. /**
  46757. * Load into a scene.
  46758. * @param scene The scene to load into
  46759. * @param data The data to import
  46760. * @param rootUrl The root url for scene and resources
  46761. * @param onError The callback when import fails
  46762. * @returns True if successful or false otherwise
  46763. */
  46764. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46765. /**
  46766. * Load into an asset container.
  46767. * @param scene The scene to load into
  46768. * @param data The data to import
  46769. * @param rootUrl The root url for scene and resources
  46770. * @param onError The callback when import fails
  46771. * @returns The loaded asset container
  46772. */
  46773. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46774. }
  46775. /**
  46776. * Interface used to define an async SceneLoader plugin
  46777. */
  46778. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46779. /**
  46780. * Import meshes into a scene.
  46781. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46782. * @param scene The scene to import into
  46783. * @param data The data to import
  46784. * @param rootUrl The root url for scene and resources
  46785. * @param onProgress The callback when the load progresses
  46786. * @param fileName Defines the name of the file to load
  46787. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46788. */
  46789. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46790. meshes: AbstractMesh[];
  46791. particleSystems: IParticleSystem[];
  46792. skeletons: Skeleton[];
  46793. animationGroups: AnimationGroup[];
  46794. }>;
  46795. /**
  46796. * Load into a scene.
  46797. * @param scene The scene to load into
  46798. * @param data The data to import
  46799. * @param rootUrl The root url for scene and resources
  46800. * @param onProgress The callback when the load progresses
  46801. * @param fileName Defines the name of the file to load
  46802. * @returns Nothing
  46803. */
  46804. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46805. /**
  46806. * Load into an asset container.
  46807. * @param scene The scene to load into
  46808. * @param data The data to import
  46809. * @param rootUrl The root url for scene and resources
  46810. * @param onProgress The callback when the load progresses
  46811. * @param fileName Defines the name of the file to load
  46812. * @returns The loaded asset container
  46813. */
  46814. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46815. }
  46816. /**
  46817. * Mode that determines how to handle old animation groups before loading new ones.
  46818. */
  46819. export enum SceneLoaderAnimationGroupLoadingMode {
  46820. /**
  46821. * Reset all old animations to initial state then dispose them.
  46822. */
  46823. Clean = 0,
  46824. /**
  46825. * Stop all old animations.
  46826. */
  46827. Stop = 1,
  46828. /**
  46829. * Restart old animations from first frame.
  46830. */
  46831. Sync = 2,
  46832. /**
  46833. * Old animations remains untouched.
  46834. */
  46835. NoSync = 3
  46836. }
  46837. /**
  46838. * Class used to load scene from various file formats using registered plugins
  46839. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46840. */
  46841. export class SceneLoader {
  46842. /**
  46843. * No logging while loading
  46844. */
  46845. static readonly NO_LOGGING: number;
  46846. /**
  46847. * Minimal logging while loading
  46848. */
  46849. static readonly MINIMAL_LOGGING: number;
  46850. /**
  46851. * Summary logging while loading
  46852. */
  46853. static readonly SUMMARY_LOGGING: number;
  46854. /**
  46855. * Detailled logging while loading
  46856. */
  46857. static readonly DETAILED_LOGGING: number;
  46858. /**
  46859. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46860. */
  46861. static get ForceFullSceneLoadingForIncremental(): boolean;
  46862. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46863. /**
  46864. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46865. */
  46866. static get ShowLoadingScreen(): boolean;
  46867. static set ShowLoadingScreen(value: boolean);
  46868. /**
  46869. * Defines the current logging level (while loading the scene)
  46870. * @ignorenaming
  46871. */
  46872. static get loggingLevel(): number;
  46873. static set loggingLevel(value: number);
  46874. /**
  46875. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46876. */
  46877. static get CleanBoneMatrixWeights(): boolean;
  46878. static set CleanBoneMatrixWeights(value: boolean);
  46879. /**
  46880. * Event raised when a plugin is used to load a scene
  46881. */
  46882. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46883. private static _registeredPlugins;
  46884. private static _getDefaultPlugin;
  46885. private static _getPluginForExtension;
  46886. private static _getPluginForDirectLoad;
  46887. private static _getPluginForFilename;
  46888. private static _getDirectLoad;
  46889. private static _loadData;
  46890. private static _getFileInfo;
  46891. /**
  46892. * Gets a plugin that can load the given extension
  46893. * @param extension defines the extension to load
  46894. * @returns a plugin or null if none works
  46895. */
  46896. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46897. /**
  46898. * Gets a boolean indicating that the given extension can be loaded
  46899. * @param extension defines the extension to load
  46900. * @returns true if the extension is supported
  46901. */
  46902. static IsPluginForExtensionAvailable(extension: string): boolean;
  46903. /**
  46904. * Adds a new plugin to the list of registered plugins
  46905. * @param plugin defines the plugin to add
  46906. */
  46907. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46908. /**
  46909. * Import meshes into a scene
  46910. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46911. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  46912. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  46913. * @param scene the instance of BABYLON.Scene to append to
  46914. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46915. * @param onProgress a callback with a progress event for each file being loaded
  46916. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46917. * @param pluginExtension the extension used to determine the plugin
  46918. * @returns The loaded plugin
  46919. */
  46920. 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>;
  46921. /**
  46922. * Import meshes into a scene
  46923. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46924. * @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)
  46925. * @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)
  46926. * @param scene the instance of BABYLON.Scene to append to
  46927. * @param onProgress a callback with a progress event for each file being loaded
  46928. * @param pluginExtension the extension used to determine the plugin
  46929. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46930. */
  46931. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46932. meshes: AbstractMesh[];
  46933. particleSystems: IParticleSystem[];
  46934. skeletons: Skeleton[];
  46935. animationGroups: AnimationGroup[];
  46936. }>;
  46937. /**
  46938. * Load a scene
  46939. * @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)
  46940. * @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)
  46941. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46942. * @param onSuccess a callback with the scene when import succeeds
  46943. * @param onProgress a callback with a progress event for each file being loaded
  46944. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46945. * @param pluginExtension the extension used to determine the plugin
  46946. * @returns The loaded plugin
  46947. */
  46948. 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>;
  46949. /**
  46950. * Load a scene
  46951. * @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)
  46952. * @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)
  46953. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46954. * @param onProgress a callback with a progress event for each file being loaded
  46955. * @param pluginExtension the extension used to determine the plugin
  46956. * @returns The loaded scene
  46957. */
  46958. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46959. /**
  46960. * Append a scene
  46961. * @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)
  46962. * @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)
  46963. * @param scene is the instance of BABYLON.Scene to append to
  46964. * @param onSuccess a callback with the scene when import succeeds
  46965. * @param onProgress a callback with a progress event for each file being loaded
  46966. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46967. * @param pluginExtension the extension used to determine the plugin
  46968. * @returns The loaded plugin
  46969. */
  46970. 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>;
  46971. /**
  46972. * Append a scene
  46973. * @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)
  46974. * @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)
  46975. * @param scene is the instance of BABYLON.Scene to append to
  46976. * @param onProgress a callback with a progress event for each file being loaded
  46977. * @param pluginExtension the extension used to determine the plugin
  46978. * @returns The given scene
  46979. */
  46980. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46981. /**
  46982. * Load a scene into an asset container
  46983. * @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)
  46984. * @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)
  46985. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46986. * @param onSuccess a callback with the scene when import succeeds
  46987. * @param onProgress a callback with a progress event for each file being loaded
  46988. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46989. * @param pluginExtension the extension used to determine the plugin
  46990. * @returns The loaded plugin
  46991. */
  46992. 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>;
  46993. /**
  46994. * Load a scene into an asset container
  46995. * @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)
  46996. * @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)
  46997. * @param scene is the instance of Scene to append to
  46998. * @param onProgress a callback with a progress event for each file being loaded
  46999. * @param pluginExtension the extension used to determine the plugin
  47000. * @returns The loaded asset container
  47001. */
  47002. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47003. /**
  47004. * Import animations from a file into a scene
  47005. * @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)
  47006. * @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)
  47007. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47008. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47009. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47010. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47011. * @param onSuccess a callback with the scene when import succeeds
  47012. * @param onProgress a callback with a progress event for each file being loaded
  47013. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47014. */
  47015. 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;
  47016. /**
  47017. * Import animations from a file into a scene
  47018. * @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)
  47019. * @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)
  47020. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47021. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47022. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47023. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47024. * @param onSuccess a callback with the scene when import succeeds
  47025. * @param onProgress a callback with a progress event for each file being loaded
  47026. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47027. * @returns the updated scene with imported animations
  47028. */
  47029. 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>;
  47030. }
  47031. }
  47032. declare module BABYLON {
  47033. /**
  47034. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47035. */
  47036. export type MotionControllerHandedness = "none" | "left" | "right";
  47037. /**
  47038. * The type of components available in motion controllers.
  47039. * This is not the name of the component.
  47040. */
  47041. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47042. /**
  47043. * The state of a controller component
  47044. */
  47045. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47046. /**
  47047. * The schema of motion controller layout.
  47048. * No object will be initialized using this interface
  47049. * This is used just to define the profile.
  47050. */
  47051. export interface IMotionControllerLayout {
  47052. /**
  47053. * Path to load the assets. Usually relative to the base path
  47054. */
  47055. assetPath: string;
  47056. /**
  47057. * Available components (unsorted)
  47058. */
  47059. components: {
  47060. /**
  47061. * A map of component Ids
  47062. */
  47063. [componentId: string]: {
  47064. /**
  47065. * The type of input the component outputs
  47066. */
  47067. type: MotionControllerComponentType;
  47068. /**
  47069. * The indices of this component in the gamepad object
  47070. */
  47071. gamepadIndices: {
  47072. /**
  47073. * Index of button
  47074. */
  47075. button?: number;
  47076. /**
  47077. * If available, index of x-axis
  47078. */
  47079. xAxis?: number;
  47080. /**
  47081. * If available, index of y-axis
  47082. */
  47083. yAxis?: number;
  47084. };
  47085. /**
  47086. * The mesh's root node name
  47087. */
  47088. rootNodeName: string;
  47089. /**
  47090. * Animation definitions for this model
  47091. */
  47092. visualResponses: {
  47093. [stateKey: string]: {
  47094. /**
  47095. * What property will be animated
  47096. */
  47097. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47098. /**
  47099. * What states influence this visual response
  47100. */
  47101. states: MotionControllerComponentStateType[];
  47102. /**
  47103. * Type of animation - movement or visibility
  47104. */
  47105. valueNodeProperty: "transform" | "visibility";
  47106. /**
  47107. * Base node name to move. Its position will be calculated according to the min and max nodes
  47108. */
  47109. valueNodeName?: string;
  47110. /**
  47111. * Minimum movement node
  47112. */
  47113. minNodeName?: string;
  47114. /**
  47115. * Max movement node
  47116. */
  47117. maxNodeName?: string;
  47118. };
  47119. };
  47120. /**
  47121. * If touch enabled, what is the name of node to display user feedback
  47122. */
  47123. touchPointNodeName?: string;
  47124. };
  47125. };
  47126. /**
  47127. * Is it xr standard mapping or not
  47128. */
  47129. gamepadMapping: "" | "xr-standard";
  47130. /**
  47131. * Base root node of this entire model
  47132. */
  47133. rootNodeName: string;
  47134. /**
  47135. * Defines the main button component id
  47136. */
  47137. selectComponentId: string;
  47138. }
  47139. /**
  47140. * A definition for the layout map in the input profile
  47141. */
  47142. export interface IMotionControllerLayoutMap {
  47143. /**
  47144. * Layouts with handedness type as a key
  47145. */
  47146. [handedness: string]: IMotionControllerLayout;
  47147. }
  47148. /**
  47149. * The XR Input profile schema
  47150. * Profiles can be found here:
  47151. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47152. */
  47153. export interface IMotionControllerProfile {
  47154. /**
  47155. * fallback profiles for this profileId
  47156. */
  47157. fallbackProfileIds: string[];
  47158. /**
  47159. * The layout map, with handedness as key
  47160. */
  47161. layouts: IMotionControllerLayoutMap;
  47162. /**
  47163. * The id of this profile
  47164. * correlates to the profile(s) in the xrInput.profiles array
  47165. */
  47166. profileId: string;
  47167. }
  47168. /**
  47169. * A helper-interface for the 3 meshes needed for controller button animation
  47170. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47171. */
  47172. export interface IMotionControllerButtonMeshMap {
  47173. /**
  47174. * the mesh that defines the pressed value mesh position.
  47175. * This is used to find the max-position of this button
  47176. */
  47177. pressedMesh: AbstractMesh;
  47178. /**
  47179. * the mesh that defines the unpressed value mesh position.
  47180. * This is used to find the min (or initial) position of this button
  47181. */
  47182. unpressedMesh: AbstractMesh;
  47183. /**
  47184. * The mesh that will be changed when value changes
  47185. */
  47186. valueMesh: AbstractMesh;
  47187. }
  47188. /**
  47189. * A helper-interface for the 3 meshes needed for controller axis animation.
  47190. * This will be expanded when touchpad animations are fully supported
  47191. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47192. */
  47193. export interface IMotionControllerMeshMap {
  47194. /**
  47195. * the mesh that defines the maximum value mesh position.
  47196. */
  47197. maxMesh?: AbstractMesh;
  47198. /**
  47199. * the mesh that defines the minimum value mesh position.
  47200. */
  47201. minMesh?: AbstractMesh;
  47202. /**
  47203. * The mesh that will be changed when axis value changes
  47204. */
  47205. valueMesh: AbstractMesh;
  47206. }
  47207. /**
  47208. * The elements needed for change-detection of the gamepad objects in motion controllers
  47209. */
  47210. export interface IMinimalMotionControllerObject {
  47211. /**
  47212. * Available axes of this controller
  47213. */
  47214. axes: number[];
  47215. /**
  47216. * An array of available buttons
  47217. */
  47218. buttons: Array<{
  47219. /**
  47220. * Value of the button/trigger
  47221. */
  47222. value: number;
  47223. /**
  47224. * If the button/trigger is currently touched
  47225. */
  47226. touched: boolean;
  47227. /**
  47228. * If the button/trigger is currently pressed
  47229. */
  47230. pressed: boolean;
  47231. }>;
  47232. /**
  47233. * EXPERIMENTAL haptic support.
  47234. */
  47235. hapticActuators?: Array<{
  47236. pulse: (value: number, duration: number) => Promise<boolean>;
  47237. }>;
  47238. }
  47239. /**
  47240. * An Abstract Motion controller
  47241. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47242. * Each component has an observable to check for changes in value and state
  47243. */
  47244. export abstract class WebXRAbstractMotionController implements IDisposable {
  47245. protected scene: Scene;
  47246. protected layout: IMotionControllerLayout;
  47247. /**
  47248. * The gamepad object correlating to this controller
  47249. */
  47250. gamepadObject: IMinimalMotionControllerObject;
  47251. /**
  47252. * handedness (left/right/none) of this controller
  47253. */
  47254. handedness: MotionControllerHandedness;
  47255. private _initComponent;
  47256. private _modelReady;
  47257. /**
  47258. * A map of components (WebXRControllerComponent) in this motion controller
  47259. * Components have a ComponentType and can also have both button and axis definitions
  47260. */
  47261. readonly components: {
  47262. [id: string]: WebXRControllerComponent;
  47263. };
  47264. /**
  47265. * Disable the model's animation. Can be set at any time.
  47266. */
  47267. disableAnimation: boolean;
  47268. /**
  47269. * Observers registered here will be triggered when the model of this controller is done loading
  47270. */
  47271. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47272. /**
  47273. * The profile id of this motion controller
  47274. */
  47275. abstract profileId: string;
  47276. /**
  47277. * The root mesh of the model. It is null if the model was not yet initialized
  47278. */
  47279. rootMesh: Nullable<AbstractMesh>;
  47280. /**
  47281. * constructs a new abstract motion controller
  47282. * @param scene the scene to which the model of the controller will be added
  47283. * @param layout The profile layout to load
  47284. * @param gamepadObject The gamepad object correlating to this controller
  47285. * @param handedness handedness (left/right/none) of this controller
  47286. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47287. */
  47288. constructor(scene: Scene, layout: IMotionControllerLayout,
  47289. /**
  47290. * The gamepad object correlating to this controller
  47291. */
  47292. gamepadObject: IMinimalMotionControllerObject,
  47293. /**
  47294. * handedness (left/right/none) of this controller
  47295. */
  47296. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47297. /**
  47298. * Dispose this controller, the model mesh and all its components
  47299. */
  47300. dispose(): void;
  47301. /**
  47302. * Returns all components of specific type
  47303. * @param type the type to search for
  47304. * @return an array of components with this type
  47305. */
  47306. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47307. /**
  47308. * get a component based an its component id as defined in layout.components
  47309. * @param id the id of the component
  47310. * @returns the component correlates to the id or undefined if not found
  47311. */
  47312. getComponent(id: string): WebXRControllerComponent;
  47313. /**
  47314. * Get the list of components available in this motion controller
  47315. * @returns an array of strings correlating to available components
  47316. */
  47317. getComponentIds(): string[];
  47318. /**
  47319. * Get the first component of specific type
  47320. * @param type type of component to find
  47321. * @return a controller component or null if not found
  47322. */
  47323. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47324. /**
  47325. * Get the main (Select) component of this controller as defined in the layout
  47326. * @returns the main component of this controller
  47327. */
  47328. getMainComponent(): WebXRControllerComponent;
  47329. /**
  47330. * Loads the model correlating to this controller
  47331. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47332. * @returns A promise fulfilled with the result of the model loading
  47333. */
  47334. loadModel(): Promise<boolean>;
  47335. /**
  47336. * Update this model using the current XRFrame
  47337. * @param xrFrame the current xr frame to use and update the model
  47338. */
  47339. updateFromXRFrame(xrFrame: XRFrame): void;
  47340. /**
  47341. * Backwards compatibility due to a deeply-integrated typo
  47342. */
  47343. get handness(): XREye;
  47344. /**
  47345. * Pulse (vibrate) this controller
  47346. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47347. * Consecutive calls to this function will cancel the last pulse call
  47348. *
  47349. * @param value the strength of the pulse in 0.0...1.0 range
  47350. * @param duration Duration of the pulse in milliseconds
  47351. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47352. * @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
  47353. */
  47354. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47355. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47356. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47357. /**
  47358. * Moves the axis on the controller mesh based on its current state
  47359. * @param axis the index of the axis
  47360. * @param axisValue the value of the axis which determines the meshes new position
  47361. * @hidden
  47362. */
  47363. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47364. /**
  47365. * Update the model itself with the current frame data
  47366. * @param xrFrame the frame to use for updating the model mesh
  47367. */
  47368. protected updateModel(xrFrame: XRFrame): void;
  47369. /**
  47370. * Get the filename and path for this controller's model
  47371. * @returns a map of filename and path
  47372. */
  47373. protected abstract _getFilenameAndPath(): {
  47374. filename: string;
  47375. path: string;
  47376. };
  47377. /**
  47378. * This function is called before the mesh is loaded. It checks for loading constraints.
  47379. * For example, this function can check if the GLB loader is available
  47380. * If this function returns false, the generic controller will be loaded instead
  47381. * @returns Is the client ready to load the mesh
  47382. */
  47383. protected abstract _getModelLoadingConstraints(): boolean;
  47384. /**
  47385. * This function will be called after the model was successfully loaded and can be used
  47386. * for mesh transformations before it is available for the user
  47387. * @param meshes the loaded meshes
  47388. */
  47389. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47390. /**
  47391. * Set the root mesh for this controller. Important for the WebXR controller class
  47392. * @param meshes the loaded meshes
  47393. */
  47394. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47395. /**
  47396. * A function executed each frame that updates the mesh (if needed)
  47397. * @param xrFrame the current xrFrame
  47398. */
  47399. protected abstract _updateModel(xrFrame: XRFrame): void;
  47400. private _getGenericFilenameAndPath;
  47401. private _getGenericParentMesh;
  47402. }
  47403. }
  47404. declare module BABYLON {
  47405. /**
  47406. * A generic trigger-only motion controller for WebXR
  47407. */
  47408. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47409. /**
  47410. * Static version of the profile id of this controller
  47411. */
  47412. static ProfileId: string;
  47413. profileId: string;
  47414. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47415. protected _getFilenameAndPath(): {
  47416. filename: string;
  47417. path: string;
  47418. };
  47419. protected _getModelLoadingConstraints(): boolean;
  47420. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47421. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47422. protected _updateModel(): void;
  47423. }
  47424. }
  47425. declare module BABYLON {
  47426. /**
  47427. * Class containing static functions to help procedurally build meshes
  47428. */
  47429. export class SphereBuilder {
  47430. /**
  47431. * Creates a sphere mesh
  47432. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47433. * * 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`)
  47434. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47435. * * 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
  47436. * * 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)
  47437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47438. * * 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
  47439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47440. * @param name defines the name of the mesh
  47441. * @param options defines the options used to create the mesh
  47442. * @param scene defines the hosting scene
  47443. * @returns the sphere mesh
  47444. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47445. */
  47446. static CreateSphere(name: string, options: {
  47447. segments?: number;
  47448. diameter?: number;
  47449. diameterX?: number;
  47450. diameterY?: number;
  47451. diameterZ?: number;
  47452. arc?: number;
  47453. slice?: number;
  47454. sideOrientation?: number;
  47455. frontUVs?: Vector4;
  47456. backUVs?: Vector4;
  47457. updatable?: boolean;
  47458. }, scene?: Nullable<Scene>): Mesh;
  47459. }
  47460. }
  47461. declare module BABYLON {
  47462. /**
  47463. * A profiled motion controller has its profile loaded from an online repository.
  47464. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47465. */
  47466. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47467. private _repositoryUrl;
  47468. private _buttonMeshMapping;
  47469. private _touchDots;
  47470. /**
  47471. * The profile ID of this controller. Will be populated when the controller initializes.
  47472. */
  47473. profileId: string;
  47474. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47475. dispose(): void;
  47476. protected _getFilenameAndPath(): {
  47477. filename: string;
  47478. path: string;
  47479. };
  47480. protected _getModelLoadingConstraints(): boolean;
  47481. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47482. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47483. protected _updateModel(_xrFrame: XRFrame): void;
  47484. }
  47485. }
  47486. declare module BABYLON {
  47487. /**
  47488. * A construction function type to create a new controller based on an xrInput object
  47489. */
  47490. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47491. /**
  47492. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47493. *
  47494. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47495. * it should be replaced with auto-loaded controllers.
  47496. *
  47497. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47498. */
  47499. export class WebXRMotionControllerManager {
  47500. private static _AvailableControllers;
  47501. private static _Fallbacks;
  47502. private static _ProfileLoadingPromises;
  47503. private static _ProfilesList;
  47504. /**
  47505. * The base URL of the online controller repository. Can be changed at any time.
  47506. */
  47507. static BaseRepositoryUrl: string;
  47508. /**
  47509. * Which repository gets priority - local or online
  47510. */
  47511. static PrioritizeOnlineRepository: boolean;
  47512. /**
  47513. * Use the online repository, or use only locally-defined controllers
  47514. */
  47515. static UseOnlineRepository: boolean;
  47516. /**
  47517. * Clear the cache used for profile loading and reload when requested again
  47518. */
  47519. static ClearProfilesCache(): void;
  47520. /**
  47521. * Register the default fallbacks.
  47522. * This function is called automatically when this file is imported.
  47523. */
  47524. static DefaultFallbacks(): void;
  47525. /**
  47526. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47527. * @param profileId the profile to which a fallback needs to be found
  47528. * @return an array with corresponding fallback profiles
  47529. */
  47530. static FindFallbackWithProfileId(profileId: string): string[];
  47531. /**
  47532. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47533. * The order of search:
  47534. *
  47535. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47536. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47537. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47538. * 4) return the generic trigger controller if none were found
  47539. *
  47540. * @param xrInput the xrInput to which a new controller is initialized
  47541. * @param scene the scene to which the model will be added
  47542. * @param forceProfile force a certain profile for this controller
  47543. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47544. */
  47545. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47546. /**
  47547. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47548. *
  47549. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47550. *
  47551. * @param type the profile type to register
  47552. * @param constructFunction the function to be called when loading this profile
  47553. */
  47554. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47555. /**
  47556. * Register a fallback to a specific profile.
  47557. * @param profileId the profileId that will receive the fallbacks
  47558. * @param fallbacks A list of fallback profiles
  47559. */
  47560. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47561. /**
  47562. * Will update the list of profiles available in the repository
  47563. * @return a promise that resolves to a map of profiles available online
  47564. */
  47565. static UpdateProfilesList(): Promise<{
  47566. [profile: string]: string;
  47567. }>;
  47568. private static _LoadProfileFromRepository;
  47569. private static _LoadProfilesFromAvailableControllers;
  47570. }
  47571. }
  47572. declare module BABYLON {
  47573. /**
  47574. * Configuration options for the WebXR controller creation
  47575. */
  47576. export interface IWebXRControllerOptions {
  47577. /**
  47578. * Should the controller mesh be animated when a user interacts with it
  47579. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47580. */
  47581. disableMotionControllerAnimation?: boolean;
  47582. /**
  47583. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47584. */
  47585. doNotLoadControllerMesh?: boolean;
  47586. /**
  47587. * Force a specific controller type for this controller.
  47588. * This can be used when creating your own profile or when testing different controllers
  47589. */
  47590. forceControllerProfile?: string;
  47591. /**
  47592. * Defines a rendering group ID for meshes that will be loaded.
  47593. * This is for the default controllers only.
  47594. */
  47595. renderingGroupId?: number;
  47596. }
  47597. /**
  47598. * Represents an XR controller
  47599. */
  47600. export class WebXRInputSource {
  47601. private _scene;
  47602. /** The underlying input source for the controller */
  47603. inputSource: XRInputSource;
  47604. private _options;
  47605. private _tmpVector;
  47606. private _uniqueId;
  47607. /**
  47608. * 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
  47609. */
  47610. grip?: AbstractMesh;
  47611. /**
  47612. * If available, this is the gamepad object related to this controller.
  47613. * Using this object it is possible to get click events and trackpad changes of the
  47614. * webxr controller that is currently being used.
  47615. */
  47616. motionController?: WebXRAbstractMotionController;
  47617. /**
  47618. * Event that fires when the controller is removed/disposed.
  47619. * The object provided as event data is this controller, after associated assets were disposed.
  47620. * uniqueId is still available.
  47621. */
  47622. onDisposeObservable: Observable<WebXRInputSource>;
  47623. /**
  47624. * Will be triggered when the mesh associated with the motion controller is done loading.
  47625. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47626. * A shortened version of controller -> motion controller -> on mesh loaded.
  47627. */
  47628. onMeshLoadedObservable: Observable<AbstractMesh>;
  47629. /**
  47630. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47631. */
  47632. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47633. /**
  47634. * Pointer which can be used to select objects or attach a visible laser to
  47635. */
  47636. pointer: AbstractMesh;
  47637. /**
  47638. * Creates the controller
  47639. * @see https://doc.babylonjs.com/how_to/webxr
  47640. * @param _scene the scene which the controller should be associated to
  47641. * @param inputSource the underlying input source for the controller
  47642. * @param _options options for this controller creation
  47643. */
  47644. constructor(_scene: Scene,
  47645. /** The underlying input source for the controller */
  47646. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47647. /**
  47648. * Get this controllers unique id
  47649. */
  47650. get uniqueId(): string;
  47651. /**
  47652. * Disposes of the object
  47653. */
  47654. dispose(): void;
  47655. /**
  47656. * Gets a world space ray coming from the pointer or grip
  47657. * @param result the resulting ray
  47658. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47659. */
  47660. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47661. /**
  47662. * Updates the controller pose based on the given XRFrame
  47663. * @param xrFrame xr frame to update the pose with
  47664. * @param referenceSpace reference space to use
  47665. */
  47666. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47667. }
  47668. }
  47669. declare module BABYLON {
  47670. /**
  47671. * The schema for initialization options of the XR Input class
  47672. */
  47673. export interface IWebXRInputOptions {
  47674. /**
  47675. * If set to true no model will be automatically loaded
  47676. */
  47677. doNotLoadControllerMeshes?: boolean;
  47678. /**
  47679. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47680. * If not found, the xr input profile data will be used.
  47681. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47682. */
  47683. forceInputProfile?: string;
  47684. /**
  47685. * Do not send a request to the controller repository to load the profile.
  47686. *
  47687. * Instead, use the controllers available in babylon itself.
  47688. */
  47689. disableOnlineControllerRepository?: boolean;
  47690. /**
  47691. * A custom URL for the controllers repository
  47692. */
  47693. customControllersRepositoryURL?: string;
  47694. /**
  47695. * Should the controller model's components not move according to the user input
  47696. */
  47697. disableControllerAnimation?: boolean;
  47698. /**
  47699. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47700. */
  47701. controllerOptions?: IWebXRControllerOptions;
  47702. }
  47703. /**
  47704. * XR input used to track XR inputs such as controllers/rays
  47705. */
  47706. export class WebXRInput implements IDisposable {
  47707. /**
  47708. * the xr session manager for this session
  47709. */
  47710. xrSessionManager: WebXRSessionManager;
  47711. /**
  47712. * the WebXR camera for this session. Mainly used for teleportation
  47713. */
  47714. xrCamera: WebXRCamera;
  47715. private readonly options;
  47716. /**
  47717. * XR controllers being tracked
  47718. */
  47719. controllers: Array<WebXRInputSource>;
  47720. private _frameObserver;
  47721. private _sessionEndedObserver;
  47722. private _sessionInitObserver;
  47723. /**
  47724. * Event when a controller has been connected/added
  47725. */
  47726. onControllerAddedObservable: Observable<WebXRInputSource>;
  47727. /**
  47728. * Event when a controller has been removed/disconnected
  47729. */
  47730. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47731. /**
  47732. * Initializes the WebXRInput
  47733. * @param xrSessionManager the xr session manager for this session
  47734. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47735. * @param options = initialization options for this xr input
  47736. */
  47737. constructor(
  47738. /**
  47739. * the xr session manager for this session
  47740. */
  47741. xrSessionManager: WebXRSessionManager,
  47742. /**
  47743. * the WebXR camera for this session. Mainly used for teleportation
  47744. */
  47745. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47746. private _onInputSourcesChange;
  47747. private _addAndRemoveControllers;
  47748. /**
  47749. * Disposes of the object
  47750. */
  47751. dispose(): void;
  47752. }
  47753. }
  47754. declare module BABYLON {
  47755. /**
  47756. * This is the base class for all WebXR features.
  47757. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47758. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47759. */
  47760. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47761. protected _xrSessionManager: WebXRSessionManager;
  47762. private _attached;
  47763. private _removeOnDetach;
  47764. /**
  47765. * Should auto-attach be disabled?
  47766. */
  47767. disableAutoAttach: boolean;
  47768. /**
  47769. * Construct a new (abstract) WebXR feature
  47770. * @param _xrSessionManager the xr session manager for this feature
  47771. */
  47772. constructor(_xrSessionManager: WebXRSessionManager);
  47773. /**
  47774. * Is this feature attached
  47775. */
  47776. get attached(): boolean;
  47777. /**
  47778. * attach this feature
  47779. *
  47780. * @param force should attachment be forced (even when already attached)
  47781. * @returns true if successful, false is failed or already attached
  47782. */
  47783. attach(force?: boolean): boolean;
  47784. /**
  47785. * detach this feature.
  47786. *
  47787. * @returns true if successful, false if failed or already detached
  47788. */
  47789. detach(): boolean;
  47790. /**
  47791. * Dispose this feature and all of the resources attached
  47792. */
  47793. dispose(): void;
  47794. /**
  47795. * This is used to register callbacks that will automatically be removed when detach is called.
  47796. * @param observable the observable to which the observer will be attached
  47797. * @param callback the callback to register
  47798. */
  47799. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47800. /**
  47801. * Code in this function will be executed on each xrFrame received from the browser.
  47802. * This function will not execute after the feature is detached.
  47803. * @param _xrFrame the current frame
  47804. */
  47805. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47806. }
  47807. }
  47808. declare module BABYLON {
  47809. /**
  47810. * Renders a layer on top of an existing scene
  47811. */
  47812. export class UtilityLayerRenderer implements IDisposable {
  47813. /** the original scene that will be rendered on top of */
  47814. originalScene: Scene;
  47815. private _pointerCaptures;
  47816. private _lastPointerEvents;
  47817. private static _DefaultUtilityLayer;
  47818. private static _DefaultKeepDepthUtilityLayer;
  47819. private _sharedGizmoLight;
  47820. private _renderCamera;
  47821. /**
  47822. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47823. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47824. * @returns the camera that is used when rendering the utility layer
  47825. */
  47826. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47827. /**
  47828. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47829. * @param cam the camera that should be used when rendering the utility layer
  47830. */
  47831. setRenderCamera(cam: Nullable<Camera>): void;
  47832. /**
  47833. * @hidden
  47834. * Light which used by gizmos to get light shading
  47835. */
  47836. _getSharedGizmoLight(): HemisphericLight;
  47837. /**
  47838. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47839. */
  47840. pickUtilitySceneFirst: boolean;
  47841. /**
  47842. * 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)
  47843. */
  47844. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47845. /**
  47846. * 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)
  47847. */
  47848. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47849. /**
  47850. * The scene that is rendered on top of the original scene
  47851. */
  47852. utilityLayerScene: Scene;
  47853. /**
  47854. * If the utility layer should automatically be rendered on top of existing scene
  47855. */
  47856. shouldRender: boolean;
  47857. /**
  47858. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47859. */
  47860. onlyCheckPointerDownEvents: boolean;
  47861. /**
  47862. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47863. */
  47864. processAllEvents: boolean;
  47865. /**
  47866. * Observable raised when the pointer move from the utility layer scene to the main scene
  47867. */
  47868. onPointerOutObservable: Observable<number>;
  47869. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47870. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47871. private _afterRenderObserver;
  47872. private _sceneDisposeObserver;
  47873. private _originalPointerObserver;
  47874. /**
  47875. * Instantiates a UtilityLayerRenderer
  47876. * @param originalScene the original scene that will be rendered on top of
  47877. * @param handleEvents boolean indicating if the utility layer should handle events
  47878. */
  47879. constructor(
  47880. /** the original scene that will be rendered on top of */
  47881. originalScene: Scene, handleEvents?: boolean);
  47882. private _notifyObservers;
  47883. /**
  47884. * Renders the utility layers scene on top of the original scene
  47885. */
  47886. render(): void;
  47887. /**
  47888. * Disposes of the renderer
  47889. */
  47890. dispose(): void;
  47891. private _updateCamera;
  47892. }
  47893. }
  47894. declare module BABYLON {
  47895. /**
  47896. * Options interface for the pointer selection module
  47897. */
  47898. export interface IWebXRControllerPointerSelectionOptions {
  47899. /**
  47900. * if provided, this scene will be used to render meshes.
  47901. */
  47902. customUtilityLayerScene?: Scene;
  47903. /**
  47904. * 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)
  47905. * If not disabled, the last picked point will be used to execute a pointer up event
  47906. * If disabled, pointer up event will be triggered right after the pointer down event.
  47907. * Used in screen and gaze target ray mode only
  47908. */
  47909. disablePointerUpOnTouchOut: boolean;
  47910. /**
  47911. * For gaze mode (time to select instead of press)
  47912. */
  47913. forceGazeMode: boolean;
  47914. /**
  47915. * 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
  47916. * to start a new countdown to the pointer down event.
  47917. * Defaults to 1.
  47918. */
  47919. gazeModePointerMovedFactor?: number;
  47920. /**
  47921. * Different button type to use instead of the main component
  47922. */
  47923. overrideButtonId?: string;
  47924. /**
  47925. * use this rendering group id for the meshes (optional)
  47926. */
  47927. renderingGroupId?: number;
  47928. /**
  47929. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47930. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47931. * 3000 means 3 seconds between pointing at something and selecting it
  47932. */
  47933. timeToSelect?: number;
  47934. /**
  47935. * Should meshes created here be added to a utility layer or the main scene
  47936. */
  47937. useUtilityLayer?: boolean;
  47938. /**
  47939. * the xr input to use with this pointer selection
  47940. */
  47941. xrInput: WebXRInput;
  47942. }
  47943. /**
  47944. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47945. */
  47946. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47947. private readonly _options;
  47948. private static _idCounter;
  47949. private _attachController;
  47950. private _controllers;
  47951. private _scene;
  47952. private _tmpVectorForPickCompare;
  47953. /**
  47954. * The module's name
  47955. */
  47956. static readonly Name: string;
  47957. /**
  47958. * The (Babylon) version of this module.
  47959. * This is an integer representing the implementation version.
  47960. * This number does not correspond to the WebXR specs version
  47961. */
  47962. static readonly Version: number;
  47963. /**
  47964. * Disable lighting on the laser pointer (so it will always be visible)
  47965. */
  47966. disablePointerLighting: boolean;
  47967. /**
  47968. * Disable lighting on the selection mesh (so it will always be visible)
  47969. */
  47970. disableSelectionMeshLighting: boolean;
  47971. /**
  47972. * Should the laser pointer be displayed
  47973. */
  47974. displayLaserPointer: boolean;
  47975. /**
  47976. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47977. */
  47978. displaySelectionMesh: boolean;
  47979. /**
  47980. * This color will be set to the laser pointer when selection is triggered
  47981. */
  47982. laserPointerPickedColor: Color3;
  47983. /**
  47984. * Default color of the laser pointer
  47985. */
  47986. laserPointerDefaultColor: Color3;
  47987. /**
  47988. * default color of the selection ring
  47989. */
  47990. selectionMeshDefaultColor: Color3;
  47991. /**
  47992. * This color will be applied to the selection ring when selection is triggered
  47993. */
  47994. selectionMeshPickedColor: Color3;
  47995. /**
  47996. * Optional filter to be used for ray selection. This predicate shares behavior with
  47997. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47998. */
  47999. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48000. /**
  48001. * constructs a new background remover module
  48002. * @param _xrSessionManager the session manager for this module
  48003. * @param _options read-only options to be used in this module
  48004. */
  48005. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48006. /**
  48007. * attach this feature
  48008. * Will usually be called by the features manager
  48009. *
  48010. * @returns true if successful.
  48011. */
  48012. attach(): boolean;
  48013. /**
  48014. * detach this feature.
  48015. * Will usually be called by the features manager
  48016. *
  48017. * @returns true if successful.
  48018. */
  48019. detach(): boolean;
  48020. /**
  48021. * Will get the mesh under a specific pointer.
  48022. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48023. * @param controllerId the controllerId to check
  48024. * @returns The mesh under pointer or null if no mesh is under the pointer
  48025. */
  48026. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48027. /**
  48028. * Get the xr controller that correlates to the pointer id in the pointer event
  48029. *
  48030. * @param id the pointer id to search for
  48031. * @returns the controller that correlates to this id or null if not found
  48032. */
  48033. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48034. protected _onXRFrame(_xrFrame: XRFrame): void;
  48035. private _attachGazeMode;
  48036. private _attachScreenRayMode;
  48037. private _attachTrackedPointerRayMode;
  48038. private _convertNormalToDirectionOfRay;
  48039. private _detachController;
  48040. private _generateNewMeshPair;
  48041. private _pickingMoved;
  48042. private _updatePointerDistance;
  48043. /** @hidden */
  48044. get lasterPointerDefaultColor(): Color3;
  48045. }
  48046. }
  48047. declare module BABYLON {
  48048. /**
  48049. * Button which can be used to enter a different mode of XR
  48050. */
  48051. export class WebXREnterExitUIButton {
  48052. /** button element */
  48053. element: HTMLElement;
  48054. /** XR initialization options for the button */
  48055. sessionMode: XRSessionMode;
  48056. /** Reference space type */
  48057. referenceSpaceType: XRReferenceSpaceType;
  48058. /**
  48059. * Creates a WebXREnterExitUIButton
  48060. * @param element button element
  48061. * @param sessionMode XR initialization session mode
  48062. * @param referenceSpaceType the type of reference space to be used
  48063. */
  48064. constructor(
  48065. /** button element */
  48066. element: HTMLElement,
  48067. /** XR initialization options for the button */
  48068. sessionMode: XRSessionMode,
  48069. /** Reference space type */
  48070. referenceSpaceType: XRReferenceSpaceType);
  48071. /**
  48072. * Extendable function which can be used to update the button's visuals when the state changes
  48073. * @param activeButton the current active button in the UI
  48074. */
  48075. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48076. }
  48077. /**
  48078. * Options to create the webXR UI
  48079. */
  48080. export class WebXREnterExitUIOptions {
  48081. /**
  48082. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48083. */
  48084. customButtons?: Array<WebXREnterExitUIButton>;
  48085. /**
  48086. * A reference space type to use when creating the default button.
  48087. * Default is local-floor
  48088. */
  48089. referenceSpaceType?: XRReferenceSpaceType;
  48090. /**
  48091. * Context to enter xr with
  48092. */
  48093. renderTarget?: Nullable<WebXRRenderTarget>;
  48094. /**
  48095. * A session mode to use when creating the default button.
  48096. * Default is immersive-vr
  48097. */
  48098. sessionMode?: XRSessionMode;
  48099. /**
  48100. * A list of optional features to init the session with
  48101. */
  48102. optionalFeatures?: string[];
  48103. }
  48104. /**
  48105. * UI to allow the user to enter/exit XR mode
  48106. */
  48107. export class WebXREnterExitUI implements IDisposable {
  48108. private scene;
  48109. /** version of the options passed to this UI */
  48110. options: WebXREnterExitUIOptions;
  48111. private _activeButton;
  48112. private _buttons;
  48113. private _overlay;
  48114. /**
  48115. * Fired every time the active button is changed.
  48116. *
  48117. * When xr is entered via a button that launches xr that button will be the callback parameter
  48118. *
  48119. * When exiting xr the callback parameter will be null)
  48120. */
  48121. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48122. /**
  48123. *
  48124. * @param scene babylon scene object to use
  48125. * @param options (read-only) version of the options passed to this UI
  48126. */
  48127. private constructor();
  48128. /**
  48129. * Creates UI to allow the user to enter/exit XR mode
  48130. * @param scene the scene to add the ui to
  48131. * @param helper the xr experience helper to enter/exit xr with
  48132. * @param options options to configure the UI
  48133. * @returns the created ui
  48134. */
  48135. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48136. /**
  48137. * Disposes of the XR UI component
  48138. */
  48139. dispose(): void;
  48140. private _updateButtons;
  48141. }
  48142. }
  48143. declare module BABYLON {
  48144. /**
  48145. * Class containing static functions to help procedurally build meshes
  48146. */
  48147. export class LinesBuilder {
  48148. /**
  48149. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48150. * * 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
  48151. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48152. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48153. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48154. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48155. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48156. * * 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
  48157. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48159. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48160. * @param name defines the name of the new line system
  48161. * @param options defines the options used to create the line system
  48162. * @param scene defines the hosting scene
  48163. * @returns a new line system mesh
  48164. */
  48165. static CreateLineSystem(name: string, options: {
  48166. lines: Vector3[][];
  48167. updatable?: boolean;
  48168. instance?: Nullable<LinesMesh>;
  48169. colors?: Nullable<Color4[][]>;
  48170. useVertexAlpha?: boolean;
  48171. }, scene: Nullable<Scene>): LinesMesh;
  48172. /**
  48173. * Creates a line mesh
  48174. * 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
  48175. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48176. * * The parameter `points` is an array successive Vector3
  48177. * * 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
  48178. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48179. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48180. * * When updating an instance, remember that only point positions can change, not the number of points
  48181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48182. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48183. * @param name defines the name of the new line system
  48184. * @param options defines the options used to create the line system
  48185. * @param scene defines the hosting scene
  48186. * @returns a new line mesh
  48187. */
  48188. static CreateLines(name: string, options: {
  48189. points: Vector3[];
  48190. updatable?: boolean;
  48191. instance?: Nullable<LinesMesh>;
  48192. colors?: Color4[];
  48193. useVertexAlpha?: boolean;
  48194. }, scene?: Nullable<Scene>): LinesMesh;
  48195. /**
  48196. * Creates a dashed line mesh
  48197. * * 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
  48198. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48199. * * The parameter `points` is an array successive Vector3
  48200. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48201. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48202. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48203. * * 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
  48204. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48205. * * When updating an instance, remember that only point positions can change, not the number of points
  48206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48207. * @param name defines the name of the mesh
  48208. * @param options defines the options used to create the mesh
  48209. * @param scene defines the hosting scene
  48210. * @returns the dashed line mesh
  48211. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48212. */
  48213. static CreateDashedLines(name: string, options: {
  48214. points: Vector3[];
  48215. dashSize?: number;
  48216. gapSize?: number;
  48217. dashNb?: number;
  48218. updatable?: boolean;
  48219. instance?: LinesMesh;
  48220. useVertexAlpha?: boolean;
  48221. }, scene?: Nullable<Scene>): LinesMesh;
  48222. }
  48223. }
  48224. declare module BABYLON {
  48225. /**
  48226. * Construction options for a timer
  48227. */
  48228. export interface ITimerOptions<T> {
  48229. /**
  48230. * Time-to-end
  48231. */
  48232. timeout: number;
  48233. /**
  48234. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48235. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48236. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48237. */
  48238. contextObservable: Observable<T>;
  48239. /**
  48240. * Optional parameters when adding an observer to the observable
  48241. */
  48242. observableParameters?: {
  48243. mask?: number;
  48244. insertFirst?: boolean;
  48245. scope?: any;
  48246. };
  48247. /**
  48248. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48249. */
  48250. breakCondition?: (data?: ITimerData<T>) => boolean;
  48251. /**
  48252. * Will be triggered when the time condition has met
  48253. */
  48254. onEnded?: (data: ITimerData<any>) => void;
  48255. /**
  48256. * Will be triggered when the break condition has met (prematurely ended)
  48257. */
  48258. onAborted?: (data: ITimerData<any>) => void;
  48259. /**
  48260. * Optional function to execute on each tick (or count)
  48261. */
  48262. onTick?: (data: ITimerData<any>) => void;
  48263. }
  48264. /**
  48265. * An interface defining the data sent by the timer
  48266. */
  48267. export interface ITimerData<T> {
  48268. /**
  48269. * When did it start
  48270. */
  48271. startTime: number;
  48272. /**
  48273. * Time now
  48274. */
  48275. currentTime: number;
  48276. /**
  48277. * Time passed since started
  48278. */
  48279. deltaTime: number;
  48280. /**
  48281. * How much is completed, in [0.0...1.0].
  48282. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48283. */
  48284. completeRate: number;
  48285. /**
  48286. * What the registered observable sent in the last count
  48287. */
  48288. payload: T;
  48289. }
  48290. /**
  48291. * The current state of the timer
  48292. */
  48293. export enum TimerState {
  48294. /**
  48295. * Timer initialized, not yet started
  48296. */
  48297. INIT = 0,
  48298. /**
  48299. * Timer started and counting
  48300. */
  48301. STARTED = 1,
  48302. /**
  48303. * Timer ended (whether aborted or time reached)
  48304. */
  48305. ENDED = 2
  48306. }
  48307. /**
  48308. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48309. *
  48310. * @param options options with which to initialize this timer
  48311. */
  48312. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48313. /**
  48314. * An advanced implementation of a timer class
  48315. */
  48316. export class AdvancedTimer<T = any> implements IDisposable {
  48317. /**
  48318. * Will notify each time the timer calculates the remaining time
  48319. */
  48320. onEachCountObservable: Observable<ITimerData<T>>;
  48321. /**
  48322. * Will trigger when the timer was aborted due to the break condition
  48323. */
  48324. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48325. /**
  48326. * Will trigger when the timer ended successfully
  48327. */
  48328. onTimerEndedObservable: Observable<ITimerData<T>>;
  48329. /**
  48330. * Will trigger when the timer state has changed
  48331. */
  48332. onStateChangedObservable: Observable<TimerState>;
  48333. private _observer;
  48334. private _contextObservable;
  48335. private _observableParameters;
  48336. private _startTime;
  48337. private _timer;
  48338. private _state;
  48339. private _breakCondition;
  48340. private _timeToEnd;
  48341. private _breakOnNextTick;
  48342. /**
  48343. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48344. * @param options construction options for this advanced timer
  48345. */
  48346. constructor(options: ITimerOptions<T>);
  48347. /**
  48348. * set a breaking condition for this timer. Default is to never break during count
  48349. * @param predicate the new break condition. Returns true to break, false otherwise
  48350. */
  48351. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48352. /**
  48353. * Reset ALL associated observables in this advanced timer
  48354. */
  48355. clearObservables(): void;
  48356. /**
  48357. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48358. *
  48359. * @param timeToEnd how much time to measure until timer ended
  48360. */
  48361. start(timeToEnd?: number): void;
  48362. /**
  48363. * Will force a stop on the next tick.
  48364. */
  48365. stop(): void;
  48366. /**
  48367. * Dispose this timer, clearing all resources
  48368. */
  48369. dispose(): void;
  48370. private _setState;
  48371. private _tick;
  48372. private _stop;
  48373. }
  48374. }
  48375. declare module BABYLON {
  48376. /**
  48377. * The options container for the teleportation module
  48378. */
  48379. export interface IWebXRTeleportationOptions {
  48380. /**
  48381. * if provided, this scene will be used to render meshes.
  48382. */
  48383. customUtilityLayerScene?: Scene;
  48384. /**
  48385. * Values to configure the default target mesh
  48386. */
  48387. defaultTargetMeshOptions?: {
  48388. /**
  48389. * Fill color of the teleportation area
  48390. */
  48391. teleportationFillColor?: string;
  48392. /**
  48393. * Border color for the teleportation area
  48394. */
  48395. teleportationBorderColor?: string;
  48396. /**
  48397. * Disable the mesh's animation sequence
  48398. */
  48399. disableAnimation?: boolean;
  48400. /**
  48401. * Disable lighting on the material or the ring and arrow
  48402. */
  48403. disableLighting?: boolean;
  48404. /**
  48405. * Override the default material of the torus and arrow
  48406. */
  48407. torusArrowMaterial?: Material;
  48408. };
  48409. /**
  48410. * A list of meshes to use as floor meshes.
  48411. * Meshes can be added and removed after initializing the feature using the
  48412. * addFloorMesh and removeFloorMesh functions
  48413. * If empty, rotation will still work
  48414. */
  48415. floorMeshes?: AbstractMesh[];
  48416. /**
  48417. * use this rendering group id for the meshes (optional)
  48418. */
  48419. renderingGroupId?: number;
  48420. /**
  48421. * Should teleportation move only to snap points
  48422. */
  48423. snapPointsOnly?: boolean;
  48424. /**
  48425. * An array of points to which the teleportation will snap to.
  48426. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48427. */
  48428. snapPositions?: Vector3[];
  48429. /**
  48430. * How close should the teleportation ray be in order to snap to position.
  48431. * Default to 0.8 units (meters)
  48432. */
  48433. snapToPositionRadius?: number;
  48434. /**
  48435. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48436. * If you want to support rotation, make sure your mesh has a direction indicator.
  48437. *
  48438. * When left untouched, the default mesh will be initialized.
  48439. */
  48440. teleportationTargetMesh?: AbstractMesh;
  48441. /**
  48442. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48443. */
  48444. timeToTeleport?: number;
  48445. /**
  48446. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48447. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48448. */
  48449. useMainComponentOnly?: boolean;
  48450. /**
  48451. * Should meshes created here be added to a utility layer or the main scene
  48452. */
  48453. useUtilityLayer?: boolean;
  48454. /**
  48455. * Babylon XR Input class for controller
  48456. */
  48457. xrInput: WebXRInput;
  48458. }
  48459. /**
  48460. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48461. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48462. * the input of the attached controllers.
  48463. */
  48464. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48465. private _options;
  48466. private _controllers;
  48467. private _currentTeleportationControllerId;
  48468. private _floorMeshes;
  48469. private _quadraticBezierCurve;
  48470. private _selectionFeature;
  48471. private _snapToPositions;
  48472. private _snappedToPoint;
  48473. private _teleportationRingMaterial?;
  48474. private _tmpRay;
  48475. private _tmpVector;
  48476. /**
  48477. * The module's name
  48478. */
  48479. static readonly Name: string;
  48480. /**
  48481. * The (Babylon) version of this module.
  48482. * This is an integer representing the implementation version.
  48483. * This number does not correspond to the webxr specs version
  48484. */
  48485. static readonly Version: number;
  48486. /**
  48487. * Is movement backwards enabled
  48488. */
  48489. backwardsMovementEnabled: boolean;
  48490. /**
  48491. * Distance to travel when moving backwards
  48492. */
  48493. backwardsTeleportationDistance: number;
  48494. /**
  48495. * The distance from the user to the inspection point in the direction of the controller
  48496. * A higher number will allow the user to move further
  48497. * defaults to 5 (meters, in xr units)
  48498. */
  48499. parabolicCheckRadius: number;
  48500. /**
  48501. * Should the module support parabolic ray on top of direct ray
  48502. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48503. * Very helpful when moving between floors / different heights
  48504. */
  48505. parabolicRayEnabled: boolean;
  48506. /**
  48507. * How much rotation should be applied when rotating right and left
  48508. */
  48509. rotationAngle: number;
  48510. /**
  48511. * Is rotation enabled when moving forward?
  48512. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48513. */
  48514. rotationEnabled: boolean;
  48515. /**
  48516. * constructs a new anchor system
  48517. * @param _xrSessionManager an instance of WebXRSessionManager
  48518. * @param _options configuration object for this feature
  48519. */
  48520. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48521. /**
  48522. * Get the snapPointsOnly flag
  48523. */
  48524. get snapPointsOnly(): boolean;
  48525. /**
  48526. * Sets the snapPointsOnly flag
  48527. * @param snapToPoints should teleportation be exclusively to snap points
  48528. */
  48529. set snapPointsOnly(snapToPoints: boolean);
  48530. /**
  48531. * Add a new mesh to the floor meshes array
  48532. * @param mesh the mesh to use as floor mesh
  48533. */
  48534. addFloorMesh(mesh: AbstractMesh): void;
  48535. /**
  48536. * Add a new snap-to point to fix teleportation to this position
  48537. * @param newSnapPoint The new Snap-To point
  48538. */
  48539. addSnapPoint(newSnapPoint: Vector3): void;
  48540. attach(): boolean;
  48541. detach(): boolean;
  48542. dispose(): void;
  48543. /**
  48544. * Remove a mesh from the floor meshes array
  48545. * @param mesh the mesh to remove
  48546. */
  48547. removeFloorMesh(mesh: AbstractMesh): void;
  48548. /**
  48549. * Remove a mesh from the floor meshes array using its name
  48550. * @param name the mesh name to remove
  48551. */
  48552. removeFloorMeshByName(name: string): void;
  48553. /**
  48554. * 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
  48555. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48556. * @returns was the point found and removed or not
  48557. */
  48558. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48559. /**
  48560. * This function sets a selection feature that will be disabled when
  48561. * the forward ray is shown and will be reattached when hidden.
  48562. * This is used to remove the selection rays when moving.
  48563. * @param selectionFeature the feature to disable when forward movement is enabled
  48564. */
  48565. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48566. protected _onXRFrame(_xrFrame: XRFrame): void;
  48567. private _attachController;
  48568. private _createDefaultTargetMesh;
  48569. private _detachController;
  48570. private _findClosestSnapPointWithRadius;
  48571. private _setTargetMeshPosition;
  48572. private _setTargetMeshVisibility;
  48573. private _showParabolicPath;
  48574. private _teleportForward;
  48575. }
  48576. }
  48577. declare module BABYLON {
  48578. /**
  48579. * Options for the default xr helper
  48580. */
  48581. export class WebXRDefaultExperienceOptions {
  48582. /**
  48583. * Enable or disable default UI to enter XR
  48584. */
  48585. disableDefaultUI?: boolean;
  48586. /**
  48587. * Should teleportation not initialize. defaults to false.
  48588. */
  48589. disableTeleportation?: boolean;
  48590. /**
  48591. * Floor meshes that will be used for teleport
  48592. */
  48593. floorMeshes?: Array<AbstractMesh>;
  48594. /**
  48595. * If set to true, the first frame will not be used to reset position
  48596. * The first frame is mainly used when copying transformation from the old camera
  48597. * Mainly used in AR
  48598. */
  48599. ignoreNativeCameraTransformation?: boolean;
  48600. /**
  48601. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48602. */
  48603. inputOptions?: IWebXRInputOptions;
  48604. /**
  48605. * optional configuration for the output canvas
  48606. */
  48607. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48608. /**
  48609. * optional UI options. This can be used among other to change session mode and reference space type
  48610. */
  48611. uiOptions?: WebXREnterExitUIOptions;
  48612. /**
  48613. * When loading teleportation and pointer select, use stable versions instead of latest.
  48614. */
  48615. useStablePlugins?: boolean;
  48616. /**
  48617. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48618. */
  48619. renderingGroupId?: number;
  48620. /**
  48621. * A list of optional features to init the session with
  48622. * If set to true, all features we support will be added
  48623. */
  48624. optionalFeatures?: boolean | string[];
  48625. }
  48626. /**
  48627. * Default experience which provides a similar setup to the previous webVRExperience
  48628. */
  48629. export class WebXRDefaultExperience {
  48630. /**
  48631. * Base experience
  48632. */
  48633. baseExperience: WebXRExperienceHelper;
  48634. /**
  48635. * Enables ui for entering/exiting xr
  48636. */
  48637. enterExitUI: WebXREnterExitUI;
  48638. /**
  48639. * Input experience extension
  48640. */
  48641. input: WebXRInput;
  48642. /**
  48643. * Enables laser pointer and selection
  48644. */
  48645. pointerSelection: WebXRControllerPointerSelection;
  48646. /**
  48647. * Default target xr should render to
  48648. */
  48649. renderTarget: WebXRRenderTarget;
  48650. /**
  48651. * Enables teleportation
  48652. */
  48653. teleportation: WebXRMotionControllerTeleportation;
  48654. private constructor();
  48655. /**
  48656. * Creates the default xr experience
  48657. * @param scene scene
  48658. * @param options options for basic configuration
  48659. * @returns resulting WebXRDefaultExperience
  48660. */
  48661. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48662. /**
  48663. * DIsposes of the experience helper
  48664. */
  48665. dispose(): void;
  48666. }
  48667. }
  48668. declare module BABYLON {
  48669. /**
  48670. * Options to modify the vr teleportation behavior.
  48671. */
  48672. export interface VRTeleportationOptions {
  48673. /**
  48674. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48675. */
  48676. floorMeshName?: string;
  48677. /**
  48678. * A list of meshes to be used as the teleportation floor. (default: empty)
  48679. */
  48680. floorMeshes?: Mesh[];
  48681. /**
  48682. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48683. */
  48684. teleportationMode?: number;
  48685. /**
  48686. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48687. */
  48688. teleportationTime?: number;
  48689. /**
  48690. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48691. */
  48692. teleportationSpeed?: number;
  48693. /**
  48694. * The easing function used in the animation or null for Linear. (default CircleEase)
  48695. */
  48696. easingFunction?: EasingFunction;
  48697. }
  48698. /**
  48699. * Options to modify the vr experience helper's behavior.
  48700. */
  48701. export interface VRExperienceHelperOptions extends WebVROptions {
  48702. /**
  48703. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48704. */
  48705. createDeviceOrientationCamera?: boolean;
  48706. /**
  48707. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48708. */
  48709. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48710. /**
  48711. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48712. */
  48713. laserToggle?: boolean;
  48714. /**
  48715. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48716. */
  48717. floorMeshes?: Mesh[];
  48718. /**
  48719. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48720. */
  48721. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48722. /**
  48723. * Defines if WebXR should be used instead of WebVR (if available)
  48724. */
  48725. useXR?: boolean;
  48726. }
  48727. /**
  48728. * Event containing information after VR has been entered
  48729. */
  48730. export class OnAfterEnteringVRObservableEvent {
  48731. /**
  48732. * If entering vr was successful
  48733. */
  48734. success: boolean;
  48735. }
  48736. /**
  48737. * Helps to quickly add VR support to an existing scene.
  48738. * See http://doc.babylonjs.com/how_to/webvr_helper
  48739. */
  48740. export class VRExperienceHelper {
  48741. /** Options to modify the vr experience helper's behavior. */
  48742. webVROptions: VRExperienceHelperOptions;
  48743. private _scene;
  48744. private _position;
  48745. private _btnVR;
  48746. private _btnVRDisplayed;
  48747. private _webVRsupported;
  48748. private _webVRready;
  48749. private _webVRrequesting;
  48750. private _webVRpresenting;
  48751. private _hasEnteredVR;
  48752. private _fullscreenVRpresenting;
  48753. private _inputElement;
  48754. private _webVRCamera;
  48755. private _vrDeviceOrientationCamera;
  48756. private _deviceOrientationCamera;
  48757. private _existingCamera;
  48758. private _onKeyDown;
  48759. private _onVrDisplayPresentChange;
  48760. private _onVRDisplayChanged;
  48761. private _onVRRequestPresentStart;
  48762. private _onVRRequestPresentComplete;
  48763. /**
  48764. * 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)
  48765. */
  48766. enableGazeEvenWhenNoPointerLock: boolean;
  48767. /**
  48768. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48769. */
  48770. exitVROnDoubleTap: boolean;
  48771. /**
  48772. * Observable raised right before entering VR.
  48773. */
  48774. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48775. /**
  48776. * Observable raised when entering VR has completed.
  48777. */
  48778. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48779. /**
  48780. * Observable raised when exiting VR.
  48781. */
  48782. onExitingVRObservable: Observable<VRExperienceHelper>;
  48783. /**
  48784. * Observable raised when controller mesh is loaded.
  48785. */
  48786. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48787. /** Return this.onEnteringVRObservable
  48788. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48789. */
  48790. get onEnteringVR(): Observable<VRExperienceHelper>;
  48791. /** Return this.onExitingVRObservable
  48792. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48793. */
  48794. get onExitingVR(): Observable<VRExperienceHelper>;
  48795. /** Return this.onControllerMeshLoadedObservable
  48796. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48797. */
  48798. get onControllerMeshLoaded(): Observable<WebVRController>;
  48799. private _rayLength;
  48800. private _useCustomVRButton;
  48801. private _teleportationRequested;
  48802. private _teleportActive;
  48803. private _floorMeshName;
  48804. private _floorMeshesCollection;
  48805. private _teleportationMode;
  48806. private _teleportationTime;
  48807. private _teleportationSpeed;
  48808. private _teleportationEasing;
  48809. private _rotationAllowed;
  48810. private _teleportBackwardsVector;
  48811. private _teleportationTarget;
  48812. private _isDefaultTeleportationTarget;
  48813. private _postProcessMove;
  48814. private _teleportationFillColor;
  48815. private _teleportationBorderColor;
  48816. private _rotationAngle;
  48817. private _haloCenter;
  48818. private _cameraGazer;
  48819. private _padSensibilityUp;
  48820. private _padSensibilityDown;
  48821. private _leftController;
  48822. private _rightController;
  48823. private _gazeColor;
  48824. private _laserColor;
  48825. private _pickedLaserColor;
  48826. private _pickedGazeColor;
  48827. /**
  48828. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48829. */
  48830. onNewMeshSelected: Observable<AbstractMesh>;
  48831. /**
  48832. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48833. * This observable will provide the mesh and the controller used to select the mesh
  48834. */
  48835. onMeshSelectedWithController: Observable<{
  48836. mesh: AbstractMesh;
  48837. controller: WebVRController;
  48838. }>;
  48839. /**
  48840. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48841. */
  48842. onNewMeshPicked: Observable<PickingInfo>;
  48843. private _circleEase;
  48844. /**
  48845. * Observable raised before camera teleportation
  48846. */
  48847. onBeforeCameraTeleport: Observable<Vector3>;
  48848. /**
  48849. * Observable raised after camera teleportation
  48850. */
  48851. onAfterCameraTeleport: Observable<Vector3>;
  48852. /**
  48853. * Observable raised when current selected mesh gets unselected
  48854. */
  48855. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48856. private _raySelectionPredicate;
  48857. /**
  48858. * To be optionaly changed by user to define custom ray selection
  48859. */
  48860. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48861. /**
  48862. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48863. */
  48864. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48865. /**
  48866. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48867. */
  48868. teleportationEnabled: boolean;
  48869. private _defaultHeight;
  48870. private _teleportationInitialized;
  48871. private _interactionsEnabled;
  48872. private _interactionsRequested;
  48873. private _displayGaze;
  48874. private _displayLaserPointer;
  48875. /**
  48876. * The mesh used to display where the user is going to teleport.
  48877. */
  48878. get teleportationTarget(): Mesh;
  48879. /**
  48880. * Sets the mesh to be used to display where the user is going to teleport.
  48881. */
  48882. set teleportationTarget(value: Mesh);
  48883. /**
  48884. * 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
  48885. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48886. * See http://doc.babylonjs.com/resources/baking_transformations
  48887. */
  48888. get gazeTrackerMesh(): Mesh;
  48889. set gazeTrackerMesh(value: Mesh);
  48890. /**
  48891. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48892. */
  48893. updateGazeTrackerScale: boolean;
  48894. /**
  48895. * If the gaze trackers color should be updated when selecting meshes
  48896. */
  48897. updateGazeTrackerColor: boolean;
  48898. /**
  48899. * If the controller laser color should be updated when selecting meshes
  48900. */
  48901. updateControllerLaserColor: boolean;
  48902. /**
  48903. * The gaze tracking mesh corresponding to the left controller
  48904. */
  48905. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48906. /**
  48907. * The gaze tracking mesh corresponding to the right controller
  48908. */
  48909. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48910. /**
  48911. * If the ray of the gaze should be displayed.
  48912. */
  48913. get displayGaze(): boolean;
  48914. /**
  48915. * Sets if the ray of the gaze should be displayed.
  48916. */
  48917. set displayGaze(value: boolean);
  48918. /**
  48919. * If the ray of the LaserPointer should be displayed.
  48920. */
  48921. get displayLaserPointer(): boolean;
  48922. /**
  48923. * Sets if the ray of the LaserPointer should be displayed.
  48924. */
  48925. set displayLaserPointer(value: boolean);
  48926. /**
  48927. * The deviceOrientationCamera used as the camera when not in VR.
  48928. */
  48929. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48930. /**
  48931. * Based on the current WebVR support, returns the current VR camera used.
  48932. */
  48933. get currentVRCamera(): Nullable<Camera>;
  48934. /**
  48935. * The webVRCamera which is used when in VR.
  48936. */
  48937. get webVRCamera(): WebVRFreeCamera;
  48938. /**
  48939. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48940. */
  48941. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48942. /**
  48943. * The html button that is used to trigger entering into VR.
  48944. */
  48945. get vrButton(): Nullable<HTMLButtonElement>;
  48946. private get _teleportationRequestInitiated();
  48947. /**
  48948. * Defines whether or not Pointer lock should be requested when switching to
  48949. * full screen.
  48950. */
  48951. requestPointerLockOnFullScreen: boolean;
  48952. /**
  48953. * If asking to force XR, this will be populated with the default xr experience
  48954. */
  48955. xr: WebXRDefaultExperience;
  48956. /**
  48957. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48958. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48959. */
  48960. xrTestDone: boolean;
  48961. /**
  48962. * Instantiates a VRExperienceHelper.
  48963. * Helps to quickly add VR support to an existing scene.
  48964. * @param scene The scene the VRExperienceHelper belongs to.
  48965. * @param webVROptions Options to modify the vr experience helper's behavior.
  48966. */
  48967. constructor(scene: Scene,
  48968. /** Options to modify the vr experience helper's behavior. */
  48969. webVROptions?: VRExperienceHelperOptions);
  48970. private completeVRInit;
  48971. private _onDefaultMeshLoaded;
  48972. private _onResize;
  48973. private _onFullscreenChange;
  48974. /**
  48975. * Gets a value indicating if we are currently in VR mode.
  48976. */
  48977. get isInVRMode(): boolean;
  48978. private onVrDisplayPresentChange;
  48979. private onVRDisplayChanged;
  48980. private moveButtonToBottomRight;
  48981. private displayVRButton;
  48982. private updateButtonVisibility;
  48983. private _cachedAngularSensibility;
  48984. /**
  48985. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48986. * Otherwise, will use the fullscreen API.
  48987. */
  48988. enterVR(): void;
  48989. /**
  48990. * Attempt to exit VR, or fullscreen.
  48991. */
  48992. exitVR(): void;
  48993. /**
  48994. * The position of the vr experience helper.
  48995. */
  48996. get position(): Vector3;
  48997. /**
  48998. * Sets the position of the vr experience helper.
  48999. */
  49000. set position(value: Vector3);
  49001. /**
  49002. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49003. */
  49004. enableInteractions(): void;
  49005. private get _noControllerIsActive();
  49006. private beforeRender;
  49007. private _isTeleportationFloor;
  49008. /**
  49009. * Adds a floor mesh to be used for teleportation.
  49010. * @param floorMesh the mesh to be used for teleportation.
  49011. */
  49012. addFloorMesh(floorMesh: Mesh): void;
  49013. /**
  49014. * Removes a floor mesh from being used for teleportation.
  49015. * @param floorMesh the mesh to be removed.
  49016. */
  49017. removeFloorMesh(floorMesh: Mesh): void;
  49018. /**
  49019. * Enables interactions and teleportation using the VR controllers and gaze.
  49020. * @param vrTeleportationOptions options to modify teleportation behavior.
  49021. */
  49022. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49023. private _onNewGamepadConnected;
  49024. private _tryEnableInteractionOnController;
  49025. private _onNewGamepadDisconnected;
  49026. private _enableInteractionOnController;
  49027. private _checkTeleportWithRay;
  49028. private _checkRotate;
  49029. private _checkTeleportBackwards;
  49030. private _enableTeleportationOnController;
  49031. private _createTeleportationCircles;
  49032. private _displayTeleportationTarget;
  49033. private _hideTeleportationTarget;
  49034. private _rotateCamera;
  49035. private _moveTeleportationSelectorTo;
  49036. private _workingVector;
  49037. private _workingQuaternion;
  49038. private _workingMatrix;
  49039. /**
  49040. * Time Constant Teleportation Mode
  49041. */
  49042. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49043. /**
  49044. * Speed Constant Teleportation Mode
  49045. */
  49046. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49047. /**
  49048. * Teleports the users feet to the desired location
  49049. * @param location The location where the user's feet should be placed
  49050. */
  49051. teleportCamera(location: Vector3): void;
  49052. private _convertNormalToDirectionOfRay;
  49053. private _castRayAndSelectObject;
  49054. private _notifySelectedMeshUnselected;
  49055. /**
  49056. * Permanently set new colors for the laser pointer
  49057. * @param color the new laser color
  49058. * @param pickedColor the new laser color when picked mesh detected
  49059. */
  49060. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49061. /**
  49062. * Set lighting enabled / disabled on the laser pointer of both controllers
  49063. * @param enabled should the lighting be enabled on the laser pointer
  49064. */
  49065. setLaserLightingState(enabled?: boolean): void;
  49066. /**
  49067. * Permanently set new colors for the gaze pointer
  49068. * @param color the new gaze color
  49069. * @param pickedColor the new gaze color when picked mesh detected
  49070. */
  49071. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49072. /**
  49073. * Sets the color of the laser ray from the vr controllers.
  49074. * @param color new color for the ray.
  49075. */
  49076. changeLaserColor(color: Color3): void;
  49077. /**
  49078. * Sets the color of the ray from the vr headsets gaze.
  49079. * @param color new color for the ray.
  49080. */
  49081. changeGazeColor(color: Color3): void;
  49082. /**
  49083. * Exits VR and disposes of the vr experience helper
  49084. */
  49085. dispose(): void;
  49086. /**
  49087. * Gets the name of the VRExperienceHelper class
  49088. * @returns "VRExperienceHelper"
  49089. */
  49090. getClassName(): string;
  49091. }
  49092. }
  49093. declare module BABYLON {
  49094. /**
  49095. * Contains an array of blocks representing the octree
  49096. */
  49097. export interface IOctreeContainer<T> {
  49098. /**
  49099. * Blocks within the octree
  49100. */
  49101. blocks: Array<OctreeBlock<T>>;
  49102. }
  49103. /**
  49104. * Class used to store a cell in an octree
  49105. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49106. */
  49107. export class OctreeBlock<T> {
  49108. /**
  49109. * Gets the content of the current block
  49110. */
  49111. entries: T[];
  49112. /**
  49113. * Gets the list of block children
  49114. */
  49115. blocks: Array<OctreeBlock<T>>;
  49116. private _depth;
  49117. private _maxDepth;
  49118. private _capacity;
  49119. private _minPoint;
  49120. private _maxPoint;
  49121. private _boundingVectors;
  49122. private _creationFunc;
  49123. /**
  49124. * Creates a new block
  49125. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49126. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49127. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49128. * @param depth defines the current depth of this block in the octree
  49129. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49130. * @param creationFunc defines a callback to call when an element is added to the block
  49131. */
  49132. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49133. /**
  49134. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49135. */
  49136. get capacity(): number;
  49137. /**
  49138. * Gets the minimum vector (in world space) of the block's bounding box
  49139. */
  49140. get minPoint(): Vector3;
  49141. /**
  49142. * Gets the maximum vector (in world space) of the block's bounding box
  49143. */
  49144. get maxPoint(): Vector3;
  49145. /**
  49146. * Add a new element to this block
  49147. * @param entry defines the element to add
  49148. */
  49149. addEntry(entry: T): void;
  49150. /**
  49151. * Remove an element from this block
  49152. * @param entry defines the element to remove
  49153. */
  49154. removeEntry(entry: T): void;
  49155. /**
  49156. * Add an array of elements to this block
  49157. * @param entries defines the array of elements to add
  49158. */
  49159. addEntries(entries: T[]): void;
  49160. /**
  49161. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49162. * @param frustumPlanes defines the frustum planes to test
  49163. * @param selection defines the array to store current content if selection is positive
  49164. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49165. */
  49166. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49167. /**
  49168. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49169. * @param sphereCenter defines the bounding sphere center
  49170. * @param sphereRadius defines the bounding sphere radius
  49171. * @param selection defines the array to store current content if selection is positive
  49172. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49173. */
  49174. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49175. /**
  49176. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49177. * @param ray defines the ray to test with
  49178. * @param selection defines the array to store current content if selection is positive
  49179. */
  49180. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49181. /**
  49182. * Subdivide the content into child blocks (this block will then be empty)
  49183. */
  49184. createInnerBlocks(): void;
  49185. /**
  49186. * @hidden
  49187. */
  49188. 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;
  49189. }
  49190. }
  49191. declare module BABYLON {
  49192. /**
  49193. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49194. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49195. */
  49196. export class Octree<T> {
  49197. /** 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.) */
  49198. maxDepth: number;
  49199. /**
  49200. * Blocks within the octree containing objects
  49201. */
  49202. blocks: Array<OctreeBlock<T>>;
  49203. /**
  49204. * Content stored in the octree
  49205. */
  49206. dynamicContent: T[];
  49207. private _maxBlockCapacity;
  49208. private _selectionContent;
  49209. private _creationFunc;
  49210. /**
  49211. * Creates a octree
  49212. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49213. * @param creationFunc function to be used to instatiate the octree
  49214. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49215. * @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.)
  49216. */
  49217. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49218. /** 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.) */
  49219. maxDepth?: number);
  49220. /**
  49221. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49222. * @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);
  49223. * @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);
  49224. * @param entries meshes to be added to the octree blocks
  49225. */
  49226. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49227. /**
  49228. * Adds a mesh to the octree
  49229. * @param entry Mesh to add to the octree
  49230. */
  49231. addMesh(entry: T): void;
  49232. /**
  49233. * Remove an element from the octree
  49234. * @param entry defines the element to remove
  49235. */
  49236. removeMesh(entry: T): void;
  49237. /**
  49238. * Selects an array of meshes within the frustum
  49239. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49240. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49241. * @returns array of meshes within the frustum
  49242. */
  49243. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49244. /**
  49245. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49246. * @param sphereCenter defines the bounding sphere center
  49247. * @param sphereRadius defines the bounding sphere radius
  49248. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49249. * @returns an array of objects that intersect the sphere
  49250. */
  49251. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49252. /**
  49253. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49254. * @param ray defines the ray to test with
  49255. * @returns array of intersected objects
  49256. */
  49257. intersectsRay(ray: Ray): SmartArray<T>;
  49258. /**
  49259. * Adds a mesh into the octree block if it intersects the block
  49260. */
  49261. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49262. /**
  49263. * Adds a submesh into the octree block if it intersects the block
  49264. */
  49265. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49266. }
  49267. }
  49268. declare module BABYLON {
  49269. interface Scene {
  49270. /**
  49271. * @hidden
  49272. * Backing Filed
  49273. */
  49274. _selectionOctree: Octree<AbstractMesh>;
  49275. /**
  49276. * Gets the octree used to boost mesh selection (picking)
  49277. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49278. */
  49279. selectionOctree: Octree<AbstractMesh>;
  49280. /**
  49281. * Creates or updates the octree used to boost selection (picking)
  49282. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49283. * @param maxCapacity defines the maximum capacity per leaf
  49284. * @param maxDepth defines the maximum depth of the octree
  49285. * @returns an octree of AbstractMesh
  49286. */
  49287. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49288. }
  49289. interface AbstractMesh {
  49290. /**
  49291. * @hidden
  49292. * Backing Field
  49293. */
  49294. _submeshesOctree: Octree<SubMesh>;
  49295. /**
  49296. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49297. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49298. * @param maxCapacity defines the maximum size of each block (64 by default)
  49299. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49300. * @returns the new octree
  49301. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49302. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49303. */
  49304. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49305. }
  49306. /**
  49307. * Defines the octree scene component responsible to manage any octrees
  49308. * in a given scene.
  49309. */
  49310. export class OctreeSceneComponent {
  49311. /**
  49312. * The component name help to identify the component in the list of scene components.
  49313. */
  49314. readonly name: string;
  49315. /**
  49316. * The scene the component belongs to.
  49317. */
  49318. scene: Scene;
  49319. /**
  49320. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49321. */
  49322. readonly checksIsEnabled: boolean;
  49323. /**
  49324. * Creates a new instance of the component for the given scene
  49325. * @param scene Defines the scene to register the component in
  49326. */
  49327. constructor(scene: Scene);
  49328. /**
  49329. * Registers the component in a given scene
  49330. */
  49331. register(): void;
  49332. /**
  49333. * Return the list of active meshes
  49334. * @returns the list of active meshes
  49335. */
  49336. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49337. /**
  49338. * Return the list of active sub meshes
  49339. * @param mesh The mesh to get the candidates sub meshes from
  49340. * @returns the list of active sub meshes
  49341. */
  49342. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49343. private _tempRay;
  49344. /**
  49345. * Return the list of sub meshes intersecting with a given local ray
  49346. * @param mesh defines the mesh to find the submesh for
  49347. * @param localRay defines the ray in local space
  49348. * @returns the list of intersecting sub meshes
  49349. */
  49350. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49351. /**
  49352. * Return the list of sub meshes colliding with a collider
  49353. * @param mesh defines the mesh to find the submesh for
  49354. * @param collider defines the collider to evaluate the collision against
  49355. * @returns the list of colliding sub meshes
  49356. */
  49357. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49358. /**
  49359. * Rebuilds the elements related to this component in case of
  49360. * context lost for instance.
  49361. */
  49362. rebuild(): void;
  49363. /**
  49364. * Disposes the component and the associated ressources.
  49365. */
  49366. dispose(): void;
  49367. }
  49368. }
  49369. declare module BABYLON {
  49370. /**
  49371. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49372. */
  49373. export class Gizmo implements IDisposable {
  49374. /** The utility layer the gizmo will be added to */
  49375. gizmoLayer: UtilityLayerRenderer;
  49376. /**
  49377. * The root mesh of the gizmo
  49378. */
  49379. _rootMesh: Mesh;
  49380. private _attachedMesh;
  49381. /**
  49382. * Ratio for the scale of the gizmo (Default: 1)
  49383. */
  49384. scaleRatio: number;
  49385. /**
  49386. * If a custom mesh has been set (Default: false)
  49387. */
  49388. protected _customMeshSet: boolean;
  49389. /**
  49390. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49391. * * When set, interactions will be enabled
  49392. */
  49393. get attachedMesh(): Nullable<AbstractMesh>;
  49394. set attachedMesh(value: Nullable<AbstractMesh>);
  49395. /**
  49396. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49397. * @param mesh The mesh to replace the default mesh of the gizmo
  49398. */
  49399. setCustomMesh(mesh: Mesh): void;
  49400. /**
  49401. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49402. */
  49403. updateGizmoRotationToMatchAttachedMesh: boolean;
  49404. /**
  49405. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49406. */
  49407. updateGizmoPositionToMatchAttachedMesh: boolean;
  49408. /**
  49409. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49410. */
  49411. updateScale: boolean;
  49412. protected _interactionsEnabled: boolean;
  49413. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49414. private _beforeRenderObserver;
  49415. private _tempVector;
  49416. /**
  49417. * Creates a gizmo
  49418. * @param gizmoLayer The utility layer the gizmo will be added to
  49419. */
  49420. constructor(
  49421. /** The utility layer the gizmo will be added to */
  49422. gizmoLayer?: UtilityLayerRenderer);
  49423. /**
  49424. * Updates the gizmo to match the attached mesh's position/rotation
  49425. */
  49426. protected _update(): void;
  49427. /**
  49428. * Disposes of the gizmo
  49429. */
  49430. dispose(): void;
  49431. }
  49432. }
  49433. declare module BABYLON {
  49434. /**
  49435. * Single plane drag gizmo
  49436. */
  49437. export class PlaneDragGizmo extends Gizmo {
  49438. /**
  49439. * Drag behavior responsible for the gizmos dragging interactions
  49440. */
  49441. dragBehavior: PointerDragBehavior;
  49442. private _pointerObserver;
  49443. /**
  49444. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49445. */
  49446. snapDistance: number;
  49447. /**
  49448. * Event that fires each time the gizmo snaps to a new location.
  49449. * * snapDistance is the the change in distance
  49450. */
  49451. onSnapObservable: Observable<{
  49452. snapDistance: number;
  49453. }>;
  49454. private _plane;
  49455. private _coloredMaterial;
  49456. private _hoverMaterial;
  49457. private _isEnabled;
  49458. private _parent;
  49459. /** @hidden */
  49460. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49461. /** @hidden */
  49462. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49463. /**
  49464. * Creates a PlaneDragGizmo
  49465. * @param gizmoLayer The utility layer the gizmo will be added to
  49466. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49467. * @param color The color of the gizmo
  49468. */
  49469. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49470. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49471. /**
  49472. * If the gizmo is enabled
  49473. */
  49474. set isEnabled(value: boolean);
  49475. get isEnabled(): boolean;
  49476. /**
  49477. * Disposes of the gizmo
  49478. */
  49479. dispose(): void;
  49480. }
  49481. }
  49482. declare module BABYLON {
  49483. /**
  49484. * Gizmo that enables dragging a mesh along 3 axis
  49485. */
  49486. export class PositionGizmo extends Gizmo {
  49487. /**
  49488. * Internal gizmo used for interactions on the x axis
  49489. */
  49490. xGizmo: AxisDragGizmo;
  49491. /**
  49492. * Internal gizmo used for interactions on the y axis
  49493. */
  49494. yGizmo: AxisDragGizmo;
  49495. /**
  49496. * Internal gizmo used for interactions on the z axis
  49497. */
  49498. zGizmo: AxisDragGizmo;
  49499. /**
  49500. * Internal gizmo used for interactions on the yz plane
  49501. */
  49502. xPlaneGizmo: PlaneDragGizmo;
  49503. /**
  49504. * Internal gizmo used for interactions on the xz plane
  49505. */
  49506. yPlaneGizmo: PlaneDragGizmo;
  49507. /**
  49508. * Internal gizmo used for interactions on the xy plane
  49509. */
  49510. zPlaneGizmo: PlaneDragGizmo;
  49511. /**
  49512. * private variables
  49513. */
  49514. private _meshAttached;
  49515. private _updateGizmoRotationToMatchAttachedMesh;
  49516. private _snapDistance;
  49517. private _scaleRatio;
  49518. /** Fires an event when any of it's sub gizmos are dragged */
  49519. onDragStartObservable: Observable<unknown>;
  49520. /** Fires an event when any of it's sub gizmos are released from dragging */
  49521. onDragEndObservable: Observable<unknown>;
  49522. /**
  49523. * If set to true, planar drag is enabled
  49524. */
  49525. private _planarGizmoEnabled;
  49526. get attachedMesh(): Nullable<AbstractMesh>;
  49527. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49528. /**
  49529. * Creates a PositionGizmo
  49530. * @param gizmoLayer The utility layer the gizmo will be added to
  49531. */
  49532. constructor(gizmoLayer?: UtilityLayerRenderer);
  49533. /**
  49534. * If the planar drag gizmo is enabled
  49535. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49536. */
  49537. set planarGizmoEnabled(value: boolean);
  49538. get planarGizmoEnabled(): boolean;
  49539. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49540. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49541. /**
  49542. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49543. */
  49544. set snapDistance(value: number);
  49545. get snapDistance(): number;
  49546. /**
  49547. * Ratio for the scale of the gizmo (Default: 1)
  49548. */
  49549. set scaleRatio(value: number);
  49550. get scaleRatio(): number;
  49551. /**
  49552. * Disposes of the gizmo
  49553. */
  49554. dispose(): void;
  49555. /**
  49556. * CustomMeshes are not supported by this gizmo
  49557. * @param mesh The mesh to replace the default mesh of the gizmo
  49558. */
  49559. setCustomMesh(mesh: Mesh): void;
  49560. }
  49561. }
  49562. declare module BABYLON {
  49563. /**
  49564. * Single axis drag gizmo
  49565. */
  49566. export class AxisDragGizmo extends Gizmo {
  49567. /**
  49568. * Drag behavior responsible for the gizmos dragging interactions
  49569. */
  49570. dragBehavior: PointerDragBehavior;
  49571. private _pointerObserver;
  49572. /**
  49573. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49574. */
  49575. snapDistance: number;
  49576. /**
  49577. * Event that fires each time the gizmo snaps to a new location.
  49578. * * snapDistance is the the change in distance
  49579. */
  49580. onSnapObservable: Observable<{
  49581. snapDistance: number;
  49582. }>;
  49583. private _isEnabled;
  49584. private _parent;
  49585. private _arrow;
  49586. private _coloredMaterial;
  49587. private _hoverMaterial;
  49588. /** @hidden */
  49589. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49590. /** @hidden */
  49591. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49592. /**
  49593. * Creates an AxisDragGizmo
  49594. * @param gizmoLayer The utility layer the gizmo will be added to
  49595. * @param dragAxis The axis which the gizmo will be able to drag on
  49596. * @param color The color of the gizmo
  49597. */
  49598. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49599. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49600. /**
  49601. * If the gizmo is enabled
  49602. */
  49603. set isEnabled(value: boolean);
  49604. get isEnabled(): boolean;
  49605. /**
  49606. * Disposes of the gizmo
  49607. */
  49608. dispose(): void;
  49609. }
  49610. }
  49611. declare module BABYLON.Debug {
  49612. /**
  49613. * The Axes viewer will show 3 axes in a specific point in space
  49614. */
  49615. export class AxesViewer {
  49616. private _xAxis;
  49617. private _yAxis;
  49618. private _zAxis;
  49619. private _scaleLinesFactor;
  49620. private _instanced;
  49621. /**
  49622. * Gets the hosting scene
  49623. */
  49624. scene: Scene;
  49625. /**
  49626. * Gets or sets a number used to scale line length
  49627. */
  49628. scaleLines: number;
  49629. /** Gets the node hierarchy used to render x-axis */
  49630. get xAxis(): TransformNode;
  49631. /** Gets the node hierarchy used to render y-axis */
  49632. get yAxis(): TransformNode;
  49633. /** Gets the node hierarchy used to render z-axis */
  49634. get zAxis(): TransformNode;
  49635. /**
  49636. * Creates a new AxesViewer
  49637. * @param scene defines the hosting scene
  49638. * @param scaleLines defines a number used to scale line length (1 by default)
  49639. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49640. * @param xAxis defines the node hierarchy used to render the x-axis
  49641. * @param yAxis defines the node hierarchy used to render the y-axis
  49642. * @param zAxis defines the node hierarchy used to render the z-axis
  49643. */
  49644. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49645. /**
  49646. * Force the viewer to update
  49647. * @param position defines the position of the viewer
  49648. * @param xaxis defines the x axis of the viewer
  49649. * @param yaxis defines the y axis of the viewer
  49650. * @param zaxis defines the z axis of the viewer
  49651. */
  49652. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49653. /**
  49654. * Creates an instance of this axes viewer.
  49655. * @returns a new axes viewer with instanced meshes
  49656. */
  49657. createInstance(): AxesViewer;
  49658. /** Releases resources */
  49659. dispose(): void;
  49660. private static _SetRenderingGroupId;
  49661. }
  49662. }
  49663. declare module BABYLON.Debug {
  49664. /**
  49665. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49666. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49667. */
  49668. export class BoneAxesViewer extends AxesViewer {
  49669. /**
  49670. * Gets or sets the target mesh where to display the axes viewer
  49671. */
  49672. mesh: Nullable<Mesh>;
  49673. /**
  49674. * Gets or sets the target bone where to display the axes viewer
  49675. */
  49676. bone: Nullable<Bone>;
  49677. /** Gets current position */
  49678. pos: Vector3;
  49679. /** Gets direction of X axis */
  49680. xaxis: Vector3;
  49681. /** Gets direction of Y axis */
  49682. yaxis: Vector3;
  49683. /** Gets direction of Z axis */
  49684. zaxis: Vector3;
  49685. /**
  49686. * Creates a new BoneAxesViewer
  49687. * @param scene defines the hosting scene
  49688. * @param bone defines the target bone
  49689. * @param mesh defines the target mesh
  49690. * @param scaleLines defines a scaling factor for line length (1 by default)
  49691. */
  49692. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49693. /**
  49694. * Force the viewer to update
  49695. */
  49696. update(): void;
  49697. /** Releases resources */
  49698. dispose(): void;
  49699. }
  49700. }
  49701. declare module BABYLON {
  49702. /**
  49703. * Interface used to define scene explorer extensibility option
  49704. */
  49705. export interface IExplorerExtensibilityOption {
  49706. /**
  49707. * Define the option label
  49708. */
  49709. label: string;
  49710. /**
  49711. * Defines the action to execute on click
  49712. */
  49713. action: (entity: any) => void;
  49714. }
  49715. /**
  49716. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49717. */
  49718. export interface IExplorerExtensibilityGroup {
  49719. /**
  49720. * Defines a predicate to test if a given type mut be extended
  49721. */
  49722. predicate: (entity: any) => boolean;
  49723. /**
  49724. * Gets the list of options added to a type
  49725. */
  49726. entries: IExplorerExtensibilityOption[];
  49727. }
  49728. /**
  49729. * Interface used to define the options to use to create the Inspector
  49730. */
  49731. export interface IInspectorOptions {
  49732. /**
  49733. * Display in overlay mode (default: false)
  49734. */
  49735. overlay?: boolean;
  49736. /**
  49737. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49738. */
  49739. globalRoot?: HTMLElement;
  49740. /**
  49741. * Display the Scene explorer
  49742. */
  49743. showExplorer?: boolean;
  49744. /**
  49745. * Display the property inspector
  49746. */
  49747. showInspector?: boolean;
  49748. /**
  49749. * Display in embed mode (both panes on the right)
  49750. */
  49751. embedMode?: boolean;
  49752. /**
  49753. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49754. */
  49755. handleResize?: boolean;
  49756. /**
  49757. * Allow the panes to popup (default: true)
  49758. */
  49759. enablePopup?: boolean;
  49760. /**
  49761. * Allow the panes to be closed by users (default: true)
  49762. */
  49763. enableClose?: boolean;
  49764. /**
  49765. * Optional list of extensibility entries
  49766. */
  49767. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49768. /**
  49769. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49770. */
  49771. inspectorURL?: string;
  49772. /**
  49773. * Optional initial tab (default to DebugLayerTab.Properties)
  49774. */
  49775. initialTab?: DebugLayerTab;
  49776. }
  49777. interface Scene {
  49778. /**
  49779. * @hidden
  49780. * Backing field
  49781. */
  49782. _debugLayer: DebugLayer;
  49783. /**
  49784. * Gets the debug layer (aka Inspector) associated with the scene
  49785. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49786. */
  49787. debugLayer: DebugLayer;
  49788. }
  49789. /**
  49790. * Enum of inspector action tab
  49791. */
  49792. export enum DebugLayerTab {
  49793. /**
  49794. * Properties tag (default)
  49795. */
  49796. Properties = 0,
  49797. /**
  49798. * Debug tab
  49799. */
  49800. Debug = 1,
  49801. /**
  49802. * Statistics tab
  49803. */
  49804. Statistics = 2,
  49805. /**
  49806. * Tools tab
  49807. */
  49808. Tools = 3,
  49809. /**
  49810. * Settings tab
  49811. */
  49812. Settings = 4
  49813. }
  49814. /**
  49815. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49816. * what is happening in your scene
  49817. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49818. */
  49819. export class DebugLayer {
  49820. /**
  49821. * Define the url to get the inspector script from.
  49822. * By default it uses the babylonjs CDN.
  49823. * @ignoreNaming
  49824. */
  49825. static InspectorURL: string;
  49826. private _scene;
  49827. private BJSINSPECTOR;
  49828. private _onPropertyChangedObservable?;
  49829. /**
  49830. * Observable triggered when a property is changed through the inspector.
  49831. */
  49832. get onPropertyChangedObservable(): any;
  49833. /**
  49834. * Instantiates a new debug layer.
  49835. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49836. * what is happening in your scene
  49837. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49838. * @param scene Defines the scene to inspect
  49839. */
  49840. constructor(scene: Scene);
  49841. /** Creates the inspector window. */
  49842. private _createInspector;
  49843. /**
  49844. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49845. * @param entity defines the entity to select
  49846. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49847. */
  49848. select(entity: any, lineContainerTitles?: string | string[]): void;
  49849. /** Get the inspector from bundle or global */
  49850. private _getGlobalInspector;
  49851. /**
  49852. * Get if the inspector is visible or not.
  49853. * @returns true if visible otherwise, false
  49854. */
  49855. isVisible(): boolean;
  49856. /**
  49857. * Hide the inspector and close its window.
  49858. */
  49859. hide(): void;
  49860. /**
  49861. * Update the scene in the inspector
  49862. */
  49863. setAsActiveScene(): void;
  49864. /**
  49865. * Launch the debugLayer.
  49866. * @param config Define the configuration of the inspector
  49867. * @return a promise fulfilled when the debug layer is visible
  49868. */
  49869. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49870. }
  49871. }
  49872. declare module BABYLON {
  49873. /**
  49874. * Class containing static functions to help procedurally build meshes
  49875. */
  49876. export class BoxBuilder {
  49877. /**
  49878. * Creates a box mesh
  49879. * * The parameter `size` sets the size (float) of each box side (default 1)
  49880. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49881. * * 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)
  49882. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49884. * * 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
  49885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49886. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49887. * @param name defines the name of the mesh
  49888. * @param options defines the options used to create the mesh
  49889. * @param scene defines the hosting scene
  49890. * @returns the box mesh
  49891. */
  49892. static CreateBox(name: string, options: {
  49893. size?: number;
  49894. width?: number;
  49895. height?: number;
  49896. depth?: number;
  49897. faceUV?: Vector4[];
  49898. faceColors?: Color4[];
  49899. sideOrientation?: number;
  49900. frontUVs?: Vector4;
  49901. backUVs?: Vector4;
  49902. wrap?: boolean;
  49903. topBaseAt?: number;
  49904. bottomBaseAt?: number;
  49905. updatable?: boolean;
  49906. }, scene?: Nullable<Scene>): Mesh;
  49907. }
  49908. }
  49909. declare module BABYLON.Debug {
  49910. /**
  49911. * Used to show the physics impostor around the specific mesh
  49912. */
  49913. export class PhysicsViewer {
  49914. /** @hidden */
  49915. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49916. /** @hidden */
  49917. protected _meshes: Array<Nullable<AbstractMesh>>;
  49918. /** @hidden */
  49919. protected _scene: Nullable<Scene>;
  49920. /** @hidden */
  49921. protected _numMeshes: number;
  49922. /** @hidden */
  49923. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49924. private _renderFunction;
  49925. private _utilityLayer;
  49926. private _debugBoxMesh;
  49927. private _debugSphereMesh;
  49928. private _debugCylinderMesh;
  49929. private _debugMaterial;
  49930. private _debugMeshMeshes;
  49931. /**
  49932. * Creates a new PhysicsViewer
  49933. * @param scene defines the hosting scene
  49934. */
  49935. constructor(scene: Scene);
  49936. /** @hidden */
  49937. protected _updateDebugMeshes(): void;
  49938. /**
  49939. * Renders a specified physic impostor
  49940. * @param impostor defines the impostor to render
  49941. * @param targetMesh defines the mesh represented by the impostor
  49942. * @returns the new debug mesh used to render the impostor
  49943. */
  49944. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49945. /**
  49946. * Hides a specified physic impostor
  49947. * @param impostor defines the impostor to hide
  49948. */
  49949. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49950. private _getDebugMaterial;
  49951. private _getDebugBoxMesh;
  49952. private _getDebugSphereMesh;
  49953. private _getDebugCylinderMesh;
  49954. private _getDebugMeshMesh;
  49955. private _getDebugMesh;
  49956. /** Releases all resources */
  49957. dispose(): void;
  49958. }
  49959. }
  49960. declare module BABYLON {
  49961. /**
  49962. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49963. * in order to better appreciate the issue one might have.
  49964. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49965. */
  49966. export class RayHelper {
  49967. /**
  49968. * Defines the ray we are currently tryin to visualize.
  49969. */
  49970. ray: Nullable<Ray>;
  49971. private _renderPoints;
  49972. private _renderLine;
  49973. private _renderFunction;
  49974. private _scene;
  49975. private _updateToMeshFunction;
  49976. private _attachedToMesh;
  49977. private _meshSpaceDirection;
  49978. private _meshSpaceOrigin;
  49979. /**
  49980. * Helper function to create a colored helper in a scene in one line.
  49981. * @param ray Defines the ray we are currently tryin to visualize
  49982. * @param scene Defines the scene the ray is used in
  49983. * @param color Defines the color we want to see the ray in
  49984. * @returns The newly created ray helper.
  49985. */
  49986. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49987. /**
  49988. * Instantiate a new ray helper.
  49989. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49990. * in order to better appreciate the issue one might have.
  49991. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49992. * @param ray Defines the ray we are currently tryin to visualize
  49993. */
  49994. constructor(ray: Ray);
  49995. /**
  49996. * Shows the ray we are willing to debug.
  49997. * @param scene Defines the scene the ray needs to be rendered in
  49998. * @param color Defines the color the ray needs to be rendered in
  49999. */
  50000. show(scene: Scene, color?: Color3): void;
  50001. /**
  50002. * Hides the ray we are debugging.
  50003. */
  50004. hide(): void;
  50005. private _render;
  50006. /**
  50007. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50008. * @param mesh Defines the mesh we want the helper attached to
  50009. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50010. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50011. * @param length Defines the length of the ray
  50012. */
  50013. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50014. /**
  50015. * Detach the ray helper from the mesh it has previously been attached to.
  50016. */
  50017. detachFromMesh(): void;
  50018. private _updateToMesh;
  50019. /**
  50020. * Dispose the helper and release its associated resources.
  50021. */
  50022. dispose(): void;
  50023. }
  50024. }
  50025. declare module BABYLON.Debug {
  50026. /**
  50027. * Class used to render a debug view of a given skeleton
  50028. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  50029. */
  50030. export class SkeletonViewer {
  50031. /** defines the skeleton to render */
  50032. skeleton: Skeleton;
  50033. /** defines the mesh attached to the skeleton */
  50034. mesh: AbstractMesh;
  50035. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50036. autoUpdateBonesMatrices: boolean;
  50037. /** defines the rendering group id to use with the viewer */
  50038. renderingGroupId: number;
  50039. /** Gets or sets the color used to render the skeleton */
  50040. color: Color3;
  50041. private _scene;
  50042. private _debugLines;
  50043. private _debugMesh;
  50044. private _isEnabled;
  50045. private _renderFunction;
  50046. private _utilityLayer;
  50047. /**
  50048. * Returns the mesh used to render the bones
  50049. */
  50050. get debugMesh(): Nullable<LinesMesh>;
  50051. /**
  50052. * Creates a new SkeletonViewer
  50053. * @param skeleton defines the skeleton to render
  50054. * @param mesh defines the mesh attached to the skeleton
  50055. * @param scene defines the hosting scene
  50056. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  50057. * @param renderingGroupId defines the rendering group id to use with the viewer
  50058. */
  50059. constructor(
  50060. /** defines the skeleton to render */
  50061. skeleton: Skeleton,
  50062. /** defines the mesh attached to the skeleton */
  50063. mesh: AbstractMesh, scene: Scene,
  50064. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50065. autoUpdateBonesMatrices?: boolean,
  50066. /** defines the rendering group id to use with the viewer */
  50067. renderingGroupId?: number);
  50068. /** Gets or sets a boolean indicating if the viewer is enabled */
  50069. set isEnabled(value: boolean);
  50070. get isEnabled(): boolean;
  50071. private _getBonePosition;
  50072. private _getLinesForBonesWithLength;
  50073. private _getLinesForBonesNoLength;
  50074. /** Update the viewer to sync with current skeleton state */
  50075. update(): void;
  50076. /** Release associated resources */
  50077. dispose(): void;
  50078. }
  50079. }
  50080. declare module BABYLON {
  50081. /**
  50082. * Enum for Device Types
  50083. */
  50084. export enum DeviceType {
  50085. /** Generic */
  50086. Generic = 0,
  50087. /** Keyboard */
  50088. Keyboard = 1,
  50089. /** Mouse */
  50090. Mouse = 2,
  50091. /** Touch Pointers */
  50092. Touch = 3,
  50093. /** PS4 Dual Shock */
  50094. DualShock = 4,
  50095. /** Xbox */
  50096. Xbox = 5,
  50097. /** Switch Controller */
  50098. Switch = 6
  50099. }
  50100. /**
  50101. * Enum for All Pointers (Touch/Mouse)
  50102. */
  50103. export enum PointerInput {
  50104. /** Horizontal Axis */
  50105. Horizontal = 0,
  50106. /** Vertical Axis */
  50107. Vertical = 1,
  50108. /** Left Click or Touch */
  50109. LeftClick = 2,
  50110. /** Middle Click */
  50111. MiddleClick = 3,
  50112. /** Right Click */
  50113. RightClick = 4,
  50114. /** Browser Back */
  50115. BrowserBack = 5,
  50116. /** Browser Forward */
  50117. BrowserForward = 6
  50118. }
  50119. /**
  50120. * Enum for Dual Shock Gamepad
  50121. */
  50122. export enum DualShockInput {
  50123. /** Cross */
  50124. Cross = 0,
  50125. /** Circle */
  50126. Circle = 1,
  50127. /** Square */
  50128. Square = 2,
  50129. /** Triangle */
  50130. Triangle = 3,
  50131. /** L1 */
  50132. L1 = 4,
  50133. /** R1 */
  50134. R1 = 5,
  50135. /** L2 */
  50136. L2 = 6,
  50137. /** R2 */
  50138. R2 = 7,
  50139. /** Share */
  50140. Share = 8,
  50141. /** Options */
  50142. Options = 9,
  50143. /** L3 */
  50144. L3 = 10,
  50145. /** R3 */
  50146. R3 = 11,
  50147. /** DPadUp */
  50148. DPadUp = 12,
  50149. /** DPadDown */
  50150. DPadDown = 13,
  50151. /** DPadLeft */
  50152. DPadLeft = 14,
  50153. /** DRight */
  50154. DPadRight = 15,
  50155. /** Home */
  50156. Home = 16,
  50157. /** TouchPad */
  50158. TouchPad = 17,
  50159. /** LStickXAxis */
  50160. LStickXAxis = 18,
  50161. /** LStickYAxis */
  50162. LStickYAxis = 19,
  50163. /** RStickXAxis */
  50164. RStickXAxis = 20,
  50165. /** RStickYAxis */
  50166. RStickYAxis = 21
  50167. }
  50168. /**
  50169. * Enum for Xbox Gamepad
  50170. */
  50171. export enum XboxInput {
  50172. /** A */
  50173. A = 0,
  50174. /** B */
  50175. B = 1,
  50176. /** X */
  50177. X = 2,
  50178. /** Y */
  50179. Y = 3,
  50180. /** LB */
  50181. LB = 4,
  50182. /** RB */
  50183. RB = 5,
  50184. /** LT */
  50185. LT = 6,
  50186. /** RT */
  50187. RT = 7,
  50188. /** Back */
  50189. Back = 8,
  50190. /** Start */
  50191. Start = 9,
  50192. /** LS */
  50193. LS = 10,
  50194. /** RS */
  50195. RS = 11,
  50196. /** DPadUp */
  50197. DPadUp = 12,
  50198. /** DPadDown */
  50199. DPadDown = 13,
  50200. /** DPadLeft */
  50201. DPadLeft = 14,
  50202. /** DRight */
  50203. DPadRight = 15,
  50204. /** Home */
  50205. Home = 16,
  50206. /** LStickXAxis */
  50207. LStickXAxis = 17,
  50208. /** LStickYAxis */
  50209. LStickYAxis = 18,
  50210. /** RStickXAxis */
  50211. RStickXAxis = 19,
  50212. /** RStickYAxis */
  50213. RStickYAxis = 20
  50214. }
  50215. /**
  50216. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50217. */
  50218. export enum SwitchInput {
  50219. /** B */
  50220. B = 0,
  50221. /** A */
  50222. A = 1,
  50223. /** Y */
  50224. Y = 2,
  50225. /** X */
  50226. X = 3,
  50227. /** L */
  50228. L = 4,
  50229. /** R */
  50230. R = 5,
  50231. /** ZL */
  50232. ZL = 6,
  50233. /** ZR */
  50234. ZR = 7,
  50235. /** Minus */
  50236. Minus = 8,
  50237. /** Plus */
  50238. Plus = 9,
  50239. /** LS */
  50240. LS = 10,
  50241. /** RS */
  50242. RS = 11,
  50243. /** DPadUp */
  50244. DPadUp = 12,
  50245. /** DPadDown */
  50246. DPadDown = 13,
  50247. /** DPadLeft */
  50248. DPadLeft = 14,
  50249. /** DRight */
  50250. DPadRight = 15,
  50251. /** Home */
  50252. Home = 16,
  50253. /** Capture */
  50254. Capture = 17,
  50255. /** LStickXAxis */
  50256. LStickXAxis = 18,
  50257. /** LStickYAxis */
  50258. LStickYAxis = 19,
  50259. /** RStickXAxis */
  50260. RStickXAxis = 20,
  50261. /** RStickYAxis */
  50262. RStickYAxis = 21
  50263. }
  50264. }
  50265. declare module BABYLON {
  50266. /**
  50267. * This class will take all inputs from Keyboard, Pointer, and
  50268. * any Gamepads and provide a polling system that all devices
  50269. * will use. This class assumes that there will only be one
  50270. * pointer device and one keyboard.
  50271. */
  50272. export class DeviceInputSystem implements IDisposable {
  50273. /**
  50274. * Callback to be triggered when a device is connected
  50275. */
  50276. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50277. /**
  50278. * Callback to be triggered when a device is disconnected
  50279. */
  50280. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50281. /**
  50282. * Callback to be triggered when event driven input is updated
  50283. */
  50284. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50285. private _inputs;
  50286. private _gamepads;
  50287. private _keyboardActive;
  50288. private _pointerActive;
  50289. private _elementToAttachTo;
  50290. private _keyboardDownEvent;
  50291. private _keyboardUpEvent;
  50292. private _pointerMoveEvent;
  50293. private _pointerDownEvent;
  50294. private _pointerUpEvent;
  50295. private _gamepadConnectedEvent;
  50296. private _gamepadDisconnectedEvent;
  50297. private static _MAX_KEYCODES;
  50298. private static _MAX_POINTER_INPUTS;
  50299. private constructor();
  50300. /**
  50301. * Creates a new DeviceInputSystem instance
  50302. * @param engine Engine to pull input element from
  50303. * @returns The new instance
  50304. */
  50305. static Create(engine: Engine): DeviceInputSystem;
  50306. /**
  50307. * Checks for current device input value, given an id and input index
  50308. * @param deviceName Id of connected device
  50309. * @param inputIndex Index of device input
  50310. * @returns Current value of input
  50311. */
  50312. /**
  50313. * Checks for current device input value, given an id and input index
  50314. * @param deviceType Enum specifiying device type
  50315. * @param deviceSlot "Slot" or index that device is referenced in
  50316. * @param inputIndex Id of input to be checked
  50317. * @returns Current value of input
  50318. */
  50319. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50320. /**
  50321. * Dispose of all the eventlisteners
  50322. */
  50323. dispose(): void;
  50324. /**
  50325. * Add device and inputs to device array
  50326. * @param deviceType Enum specifiying device type
  50327. * @param deviceSlot "Slot" or index that device is referenced in
  50328. * @param numberOfInputs Number of input entries to create for given device
  50329. */
  50330. private _registerDevice;
  50331. /**
  50332. * Given a specific device name, remove that device from the device map
  50333. * @param deviceType Enum specifiying device type
  50334. * @param deviceSlot "Slot" or index that device is referenced in
  50335. */
  50336. private _unregisterDevice;
  50337. /**
  50338. * Handle all actions that come from keyboard interaction
  50339. */
  50340. private _handleKeyActions;
  50341. /**
  50342. * Handle all actions that come from pointer interaction
  50343. */
  50344. private _handlePointerActions;
  50345. /**
  50346. * Handle all actions that come from gamepad interaction
  50347. */
  50348. private _handleGamepadActions;
  50349. /**
  50350. * Update all non-event based devices with each frame
  50351. * @param deviceType Enum specifiying device type
  50352. * @param deviceSlot "Slot" or index that device is referenced in
  50353. * @param inputIndex Id of input to be checked
  50354. */
  50355. private _updateDevice;
  50356. /**
  50357. * Gets DeviceType from the device name
  50358. * @param deviceName Name of Device from DeviceInputSystem
  50359. * @returns DeviceType enum value
  50360. */
  50361. private _getGamepadDeviceType;
  50362. }
  50363. }
  50364. declare module BABYLON {
  50365. /**
  50366. * Type to handle enforcement of inputs
  50367. */
  50368. 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;
  50369. }
  50370. declare module BABYLON {
  50371. /**
  50372. * Class that handles all input for a specific device
  50373. */
  50374. export class DeviceSource<T extends DeviceType> {
  50375. /** Type of device */
  50376. readonly deviceType: DeviceType;
  50377. /** "Slot" or index that device is referenced in */
  50378. readonly deviceSlot: number;
  50379. /**
  50380. * Observable to handle device input changes per device
  50381. */
  50382. readonly onInputChangedObservable: Observable<{
  50383. inputIndex: DeviceInput<T>;
  50384. previousState: Nullable<number>;
  50385. currentState: Nullable<number>;
  50386. }>;
  50387. private readonly _deviceInputSystem;
  50388. /**
  50389. * Default Constructor
  50390. * @param deviceInputSystem Reference to DeviceInputSystem
  50391. * @param deviceType Type of device
  50392. * @param deviceSlot "Slot" or index that device is referenced in
  50393. */
  50394. constructor(deviceInputSystem: DeviceInputSystem,
  50395. /** Type of device */
  50396. deviceType: DeviceType,
  50397. /** "Slot" or index that device is referenced in */
  50398. deviceSlot?: number);
  50399. /**
  50400. * Get input for specific input
  50401. * @param inputIndex index of specific input on device
  50402. * @returns Input value from DeviceInputSystem
  50403. */
  50404. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50405. }
  50406. /**
  50407. * Class to keep track of devices
  50408. */
  50409. export class DeviceSourceManager implements IDisposable {
  50410. /**
  50411. * Observable to be triggered when before a device is connected
  50412. */
  50413. readonly onBeforeDeviceConnectedObservable: Observable<{
  50414. deviceType: DeviceType;
  50415. deviceSlot: number;
  50416. }>;
  50417. /**
  50418. * Observable to be triggered when before a device is disconnected
  50419. */
  50420. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50421. deviceType: DeviceType;
  50422. deviceSlot: number;
  50423. }>;
  50424. /**
  50425. * Observable to be triggered when after a device is connected
  50426. */
  50427. readonly onAfterDeviceConnectedObservable: Observable<{
  50428. deviceType: DeviceType;
  50429. deviceSlot: number;
  50430. }>;
  50431. /**
  50432. * Observable to be triggered when after a device is disconnected
  50433. */
  50434. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50435. deviceType: DeviceType;
  50436. deviceSlot: number;
  50437. }>;
  50438. private readonly _devices;
  50439. private readonly _firstDevice;
  50440. private readonly _deviceInputSystem;
  50441. /**
  50442. * Default Constructor
  50443. * @param engine engine to pull input element from
  50444. */
  50445. constructor(engine: Engine);
  50446. /**
  50447. * Gets a DeviceSource, given a type and slot
  50448. * @param deviceType Enum specifying device type
  50449. * @param deviceSlot "Slot" or index that device is referenced in
  50450. * @returns DeviceSource object
  50451. */
  50452. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50453. /**
  50454. * Gets an array of DeviceSource objects for a given device type
  50455. * @param deviceType Enum specifying device type
  50456. * @returns Array of DeviceSource objects
  50457. */
  50458. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50459. /**
  50460. * Dispose of DeviceInputSystem and other parts
  50461. */
  50462. dispose(): void;
  50463. /**
  50464. * Function to add device name to device list
  50465. * @param deviceType Enum specifying device type
  50466. * @param deviceSlot "Slot" or index that device is referenced in
  50467. */
  50468. private _addDevice;
  50469. /**
  50470. * Function to remove device name to device list
  50471. * @param deviceType Enum specifying device type
  50472. * @param deviceSlot "Slot" or index that device is referenced in
  50473. */
  50474. private _removeDevice;
  50475. /**
  50476. * Updates array storing first connected device of each type
  50477. * @param type Type of Device
  50478. */
  50479. private _updateFirstDevices;
  50480. }
  50481. }
  50482. declare module BABYLON {
  50483. /**
  50484. * Options to create the null engine
  50485. */
  50486. export class NullEngineOptions {
  50487. /**
  50488. * Render width (Default: 512)
  50489. */
  50490. renderWidth: number;
  50491. /**
  50492. * Render height (Default: 256)
  50493. */
  50494. renderHeight: number;
  50495. /**
  50496. * Texture size (Default: 512)
  50497. */
  50498. textureSize: number;
  50499. /**
  50500. * If delta time between frames should be constant
  50501. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50502. */
  50503. deterministicLockstep: boolean;
  50504. /**
  50505. * Maximum about of steps between frames (Default: 4)
  50506. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50507. */
  50508. lockstepMaxSteps: number;
  50509. }
  50510. /**
  50511. * The null engine class provides support for headless version of babylon.js.
  50512. * This can be used in server side scenario or for testing purposes
  50513. */
  50514. export class NullEngine extends Engine {
  50515. private _options;
  50516. /**
  50517. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50518. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50519. * @returns true if engine is in deterministic lock step mode
  50520. */
  50521. isDeterministicLockStep(): boolean;
  50522. /**
  50523. * Gets the max steps when engine is running in deterministic lock step
  50524. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50525. * @returns the max steps
  50526. */
  50527. getLockstepMaxSteps(): number;
  50528. /**
  50529. * Gets the current hardware scaling level.
  50530. * By default the hardware scaling level is computed from the window device ratio.
  50531. * 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.
  50532. * @returns a number indicating the current hardware scaling level
  50533. */
  50534. getHardwareScalingLevel(): number;
  50535. constructor(options?: NullEngineOptions);
  50536. /**
  50537. * Creates a vertex buffer
  50538. * @param vertices the data for the vertex buffer
  50539. * @returns the new WebGL static buffer
  50540. */
  50541. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50542. /**
  50543. * Creates a new index buffer
  50544. * @param indices defines the content of the index buffer
  50545. * @param updatable defines if the index buffer must be updatable
  50546. * @returns a new webGL buffer
  50547. */
  50548. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50549. /**
  50550. * Clear the current render buffer or the current render target (if any is set up)
  50551. * @param color defines the color to use
  50552. * @param backBuffer defines if the back buffer must be cleared
  50553. * @param depth defines if the depth buffer must be cleared
  50554. * @param stencil defines if the stencil buffer must be cleared
  50555. */
  50556. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50557. /**
  50558. * Gets the current render width
  50559. * @param useScreen defines if screen size must be used (or the current render target if any)
  50560. * @returns a number defining the current render width
  50561. */
  50562. getRenderWidth(useScreen?: boolean): number;
  50563. /**
  50564. * Gets the current render height
  50565. * @param useScreen defines if screen size must be used (or the current render target if any)
  50566. * @returns a number defining the current render height
  50567. */
  50568. getRenderHeight(useScreen?: boolean): number;
  50569. /**
  50570. * Set the WebGL's viewport
  50571. * @param viewport defines the viewport element to be used
  50572. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50573. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50574. */
  50575. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50576. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50577. /**
  50578. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50579. * @param pipelineContext defines the pipeline context to use
  50580. * @param uniformsNames defines the list of uniform names
  50581. * @returns an array of webGL uniform locations
  50582. */
  50583. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50584. /**
  50585. * Gets the lsit of active attributes for a given webGL program
  50586. * @param pipelineContext defines the pipeline context to use
  50587. * @param attributesNames defines the list of attribute names to get
  50588. * @returns an array of indices indicating the offset of each attribute
  50589. */
  50590. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50591. /**
  50592. * Binds an effect to the webGL context
  50593. * @param effect defines the effect to bind
  50594. */
  50595. bindSamplers(effect: Effect): void;
  50596. /**
  50597. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50598. * @param effect defines the effect to activate
  50599. */
  50600. enableEffect(effect: Effect): void;
  50601. /**
  50602. * Set various states to the webGL context
  50603. * @param culling defines backface culling state
  50604. * @param zOffset defines the value to apply to zOffset (0 by default)
  50605. * @param force defines if states must be applied even if cache is up to date
  50606. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50607. */
  50608. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50609. /**
  50610. * Set the value of an uniform to an array of int32
  50611. * @param uniform defines the webGL uniform location where to store the value
  50612. * @param array defines the array of int32 to store
  50613. */
  50614. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50615. /**
  50616. * Set the value of an uniform to an array of int32 (stored as vec2)
  50617. * @param uniform defines the webGL uniform location where to store the value
  50618. * @param array defines the array of int32 to store
  50619. */
  50620. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50621. /**
  50622. * Set the value of an uniform to an array of int32 (stored as vec3)
  50623. * @param uniform defines the webGL uniform location where to store the value
  50624. * @param array defines the array of int32 to store
  50625. */
  50626. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50627. /**
  50628. * Set the value of an uniform to an array of int32 (stored as vec4)
  50629. * @param uniform defines the webGL uniform location where to store the value
  50630. * @param array defines the array of int32 to store
  50631. */
  50632. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50633. /**
  50634. * Set the value of an uniform to an array of float32
  50635. * @param uniform defines the webGL uniform location where to store the value
  50636. * @param array defines the array of float32 to store
  50637. */
  50638. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50639. /**
  50640. * Set the value of an uniform to an array of float32 (stored as vec2)
  50641. * @param uniform defines the webGL uniform location where to store the value
  50642. * @param array defines the array of float32 to store
  50643. */
  50644. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50645. /**
  50646. * Set the value of an uniform to an array of float32 (stored as vec3)
  50647. * @param uniform defines the webGL uniform location where to store the value
  50648. * @param array defines the array of float32 to store
  50649. */
  50650. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50651. /**
  50652. * Set the value of an uniform to an array of float32 (stored as vec4)
  50653. * @param uniform defines the webGL uniform location where to store the value
  50654. * @param array defines the array of float32 to store
  50655. */
  50656. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50657. /**
  50658. * Set the value of an uniform to an array of number
  50659. * @param uniform defines the webGL uniform location where to store the value
  50660. * @param array defines the array of number to store
  50661. */
  50662. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50663. /**
  50664. * Set the value of an uniform to an array of number (stored as vec2)
  50665. * @param uniform defines the webGL uniform location where to store the value
  50666. * @param array defines the array of number to store
  50667. */
  50668. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50669. /**
  50670. * Set the value of an uniform to an array of number (stored as vec3)
  50671. * @param uniform defines the webGL uniform location where to store the value
  50672. * @param array defines the array of number to store
  50673. */
  50674. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50675. /**
  50676. * Set the value of an uniform to an array of number (stored as vec4)
  50677. * @param uniform defines the webGL uniform location where to store the value
  50678. * @param array defines the array of number to store
  50679. */
  50680. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50681. /**
  50682. * Set the value of an uniform to an array of float32 (stored as matrices)
  50683. * @param uniform defines the webGL uniform location where to store the value
  50684. * @param matrices defines the array of float32 to store
  50685. */
  50686. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50687. /**
  50688. * Set the value of an uniform to a matrix (3x3)
  50689. * @param uniform defines the webGL uniform location where to store the value
  50690. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50691. */
  50692. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50693. /**
  50694. * Set the value of an uniform to a matrix (2x2)
  50695. * @param uniform defines the webGL uniform location where to store the value
  50696. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50697. */
  50698. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50699. /**
  50700. * Set the value of an uniform to a number (float)
  50701. * @param uniform defines the webGL uniform location where to store the value
  50702. * @param value defines the float number to store
  50703. */
  50704. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50705. /**
  50706. * Set the value of an uniform to a vec2
  50707. * @param uniform defines the webGL uniform location where to store the value
  50708. * @param x defines the 1st component of the value
  50709. * @param y defines the 2nd component of the value
  50710. */
  50711. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50712. /**
  50713. * Set the value of an uniform to a vec3
  50714. * @param uniform defines the webGL uniform location where to store the value
  50715. * @param x defines the 1st component of the value
  50716. * @param y defines the 2nd component of the value
  50717. * @param z defines the 3rd component of the value
  50718. */
  50719. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50720. /**
  50721. * Set the value of an uniform to a boolean
  50722. * @param uniform defines the webGL uniform location where to store the value
  50723. * @param bool defines the boolean to store
  50724. */
  50725. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50726. /**
  50727. * Set the value of an uniform to a vec4
  50728. * @param uniform defines the webGL uniform location where to store the value
  50729. * @param x defines the 1st component of the value
  50730. * @param y defines the 2nd component of the value
  50731. * @param z defines the 3rd component of the value
  50732. * @param w defines the 4th component of the value
  50733. */
  50734. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50735. /**
  50736. * Sets the current alpha mode
  50737. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50738. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50739. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50740. */
  50741. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50742. /**
  50743. * Bind webGl buffers directly to the webGL context
  50744. * @param vertexBuffers defines the vertex buffer to bind
  50745. * @param indexBuffer defines the index buffer to bind
  50746. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50747. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50748. * @param effect defines the effect associated with the vertex buffer
  50749. */
  50750. bindBuffers(vertexBuffers: {
  50751. [key: string]: VertexBuffer;
  50752. }, indexBuffer: DataBuffer, effect: Effect): void;
  50753. /**
  50754. * Force the entire cache to be cleared
  50755. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50756. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50757. */
  50758. wipeCaches(bruteForce?: boolean): void;
  50759. /**
  50760. * Send a draw order
  50761. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50762. * @param indexStart defines the starting index
  50763. * @param indexCount defines the number of index to draw
  50764. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50765. */
  50766. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50767. /**
  50768. * Draw a list of indexed primitives
  50769. * @param fillMode defines the primitive to use
  50770. * @param indexStart defines the starting index
  50771. * @param indexCount defines the number of index to draw
  50772. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50773. */
  50774. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50775. /**
  50776. * Draw a list of unindexed primitives
  50777. * @param fillMode defines the primitive to use
  50778. * @param verticesStart defines the index of first vertex to draw
  50779. * @param verticesCount defines the count of vertices to draw
  50780. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50781. */
  50782. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50783. /** @hidden */
  50784. _createTexture(): WebGLTexture;
  50785. /** @hidden */
  50786. _releaseTexture(texture: InternalTexture): void;
  50787. /**
  50788. * Usually called from Texture.ts.
  50789. * Passed information to create a WebGLTexture
  50790. * @param urlArg defines a value which contains one of the following:
  50791. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50792. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50793. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50794. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50795. * @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)
  50796. * @param scene needed for loading to the correct scene
  50797. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50798. * @param onLoad optional callback to be called upon successful completion
  50799. * @param onError optional callback to be called upon failure
  50800. * @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
  50801. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50802. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50803. * @param forcedExtension defines the extension to use to pick the right loader
  50804. * @param mimeType defines an optional mime type
  50805. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50806. */
  50807. 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;
  50808. /**
  50809. * Creates a new render target texture
  50810. * @param size defines the size of the texture
  50811. * @param options defines the options used to create the texture
  50812. * @returns a new render target texture stored in an InternalTexture
  50813. */
  50814. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50815. /**
  50816. * Update the sampling mode of a given texture
  50817. * @param samplingMode defines the required sampling mode
  50818. * @param texture defines the texture to update
  50819. */
  50820. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50821. /**
  50822. * Binds the frame buffer to the specified texture.
  50823. * @param texture The texture to render to or null for the default canvas
  50824. * @param faceIndex The face of the texture to render to in case of cube texture
  50825. * @param requiredWidth The width of the target to render to
  50826. * @param requiredHeight The height of the target to render to
  50827. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50828. * @param lodLevel defines le lod level to bind to the frame buffer
  50829. */
  50830. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50831. /**
  50832. * Unbind the current render target texture from the webGL context
  50833. * @param texture defines the render target texture to unbind
  50834. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50835. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50836. */
  50837. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50838. /**
  50839. * Creates a dynamic vertex buffer
  50840. * @param vertices the data for the dynamic vertex buffer
  50841. * @returns the new WebGL dynamic buffer
  50842. */
  50843. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50844. /**
  50845. * Update the content of a dynamic texture
  50846. * @param texture defines the texture to update
  50847. * @param canvas defines the canvas containing the source
  50848. * @param invertY defines if data must be stored with Y axis inverted
  50849. * @param premulAlpha defines if alpha is stored as premultiplied
  50850. * @param format defines the format of the data
  50851. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50852. */
  50853. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50854. /**
  50855. * Gets a boolean indicating if all created effects are ready
  50856. * @returns true if all effects are ready
  50857. */
  50858. areAllEffectsReady(): boolean;
  50859. /**
  50860. * @hidden
  50861. * Get the current error code of the webGL context
  50862. * @returns the error code
  50863. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50864. */
  50865. getError(): number;
  50866. /** @hidden */
  50867. _getUnpackAlignement(): number;
  50868. /** @hidden */
  50869. _unpackFlipY(value: boolean): void;
  50870. /**
  50871. * Update a dynamic index buffer
  50872. * @param indexBuffer defines the target index buffer
  50873. * @param indices defines the data to update
  50874. * @param offset defines the offset in the target index buffer where update should start
  50875. */
  50876. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50877. /**
  50878. * Updates a dynamic vertex buffer.
  50879. * @param vertexBuffer the vertex buffer to update
  50880. * @param vertices the data used to update the vertex buffer
  50881. * @param byteOffset the byte offset of the data (optional)
  50882. * @param byteLength the byte length of the data (optional)
  50883. */
  50884. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50885. /** @hidden */
  50886. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50887. /** @hidden */
  50888. _bindTexture(channel: number, texture: InternalTexture): void;
  50889. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50890. /**
  50891. * 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
  50892. */
  50893. releaseEffects(): void;
  50894. displayLoadingUI(): void;
  50895. hideLoadingUI(): void;
  50896. /** @hidden */
  50897. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50898. /** @hidden */
  50899. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50900. /** @hidden */
  50901. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50902. /** @hidden */
  50903. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50904. }
  50905. }
  50906. declare module BABYLON {
  50907. /**
  50908. * @hidden
  50909. **/
  50910. export class _TimeToken {
  50911. _startTimeQuery: Nullable<WebGLQuery>;
  50912. _endTimeQuery: Nullable<WebGLQuery>;
  50913. _timeElapsedQuery: Nullable<WebGLQuery>;
  50914. _timeElapsedQueryEnded: boolean;
  50915. }
  50916. }
  50917. declare module BABYLON {
  50918. /** @hidden */
  50919. export class _OcclusionDataStorage {
  50920. /** @hidden */
  50921. occlusionInternalRetryCounter: number;
  50922. /** @hidden */
  50923. isOcclusionQueryInProgress: boolean;
  50924. /** @hidden */
  50925. isOccluded: boolean;
  50926. /** @hidden */
  50927. occlusionRetryCount: number;
  50928. /** @hidden */
  50929. occlusionType: number;
  50930. /** @hidden */
  50931. occlusionQueryAlgorithmType: number;
  50932. }
  50933. interface Engine {
  50934. /**
  50935. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50936. * @return the new query
  50937. */
  50938. createQuery(): WebGLQuery;
  50939. /**
  50940. * Delete and release a webGL query
  50941. * @param query defines the query to delete
  50942. * @return the current engine
  50943. */
  50944. deleteQuery(query: WebGLQuery): Engine;
  50945. /**
  50946. * Check if a given query has resolved and got its value
  50947. * @param query defines the query to check
  50948. * @returns true if the query got its value
  50949. */
  50950. isQueryResultAvailable(query: WebGLQuery): boolean;
  50951. /**
  50952. * Gets the value of a given query
  50953. * @param query defines the query to check
  50954. * @returns the value of the query
  50955. */
  50956. getQueryResult(query: WebGLQuery): number;
  50957. /**
  50958. * Initiates an occlusion query
  50959. * @param algorithmType defines the algorithm to use
  50960. * @param query defines the query to use
  50961. * @returns the current engine
  50962. * @see http://doc.babylonjs.com/features/occlusionquery
  50963. */
  50964. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50965. /**
  50966. * Ends an occlusion query
  50967. * @see http://doc.babylonjs.com/features/occlusionquery
  50968. * @param algorithmType defines the algorithm to use
  50969. * @returns the current engine
  50970. */
  50971. endOcclusionQuery(algorithmType: number): Engine;
  50972. /**
  50973. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50974. * Please note that only one query can be issued at a time
  50975. * @returns a time token used to track the time span
  50976. */
  50977. startTimeQuery(): Nullable<_TimeToken>;
  50978. /**
  50979. * Ends a time query
  50980. * @param token defines the token used to measure the time span
  50981. * @returns the time spent (in ns)
  50982. */
  50983. endTimeQuery(token: _TimeToken): int;
  50984. /** @hidden */
  50985. _currentNonTimestampToken: Nullable<_TimeToken>;
  50986. /** @hidden */
  50987. _createTimeQuery(): WebGLQuery;
  50988. /** @hidden */
  50989. _deleteTimeQuery(query: WebGLQuery): void;
  50990. /** @hidden */
  50991. _getGlAlgorithmType(algorithmType: number): number;
  50992. /** @hidden */
  50993. _getTimeQueryResult(query: WebGLQuery): any;
  50994. /** @hidden */
  50995. _getTimeQueryAvailability(query: WebGLQuery): any;
  50996. }
  50997. interface AbstractMesh {
  50998. /**
  50999. * Backing filed
  51000. * @hidden
  51001. */
  51002. __occlusionDataStorage: _OcclusionDataStorage;
  51003. /**
  51004. * Access property
  51005. * @hidden
  51006. */
  51007. _occlusionDataStorage: _OcclusionDataStorage;
  51008. /**
  51009. * 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.
  51010. * The default value is -1 which means don't break the query and wait till the result
  51011. * @see http://doc.babylonjs.com/features/occlusionquery
  51012. */
  51013. occlusionRetryCount: number;
  51014. /**
  51015. * 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:
  51016. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  51017. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  51018. * * 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.
  51019. * @see http://doc.babylonjs.com/features/occlusionquery
  51020. */
  51021. occlusionType: number;
  51022. /**
  51023. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  51024. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  51025. * * 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.
  51026. * @see http://doc.babylonjs.com/features/occlusionquery
  51027. */
  51028. occlusionQueryAlgorithmType: number;
  51029. /**
  51030. * 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
  51031. * @see http://doc.babylonjs.com/features/occlusionquery
  51032. */
  51033. isOccluded: boolean;
  51034. /**
  51035. * Flag to check the progress status of the query
  51036. * @see http://doc.babylonjs.com/features/occlusionquery
  51037. */
  51038. isOcclusionQueryInProgress: boolean;
  51039. }
  51040. }
  51041. declare module BABYLON {
  51042. /** @hidden */
  51043. export var _forceTransformFeedbackToBundle: boolean;
  51044. interface Engine {
  51045. /**
  51046. * Creates a webGL transform feedback object
  51047. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  51048. * @returns the webGL transform feedback object
  51049. */
  51050. createTransformFeedback(): WebGLTransformFeedback;
  51051. /**
  51052. * Delete a webGL transform feedback object
  51053. * @param value defines the webGL transform feedback object to delete
  51054. */
  51055. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  51056. /**
  51057. * Bind a webGL transform feedback object to the webgl context
  51058. * @param value defines the webGL transform feedback object to bind
  51059. */
  51060. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  51061. /**
  51062. * Begins a transform feedback operation
  51063. * @param usePoints defines if points or triangles must be used
  51064. */
  51065. beginTransformFeedback(usePoints: boolean): void;
  51066. /**
  51067. * Ends a transform feedback operation
  51068. */
  51069. endTransformFeedback(): void;
  51070. /**
  51071. * Specify the varyings to use with transform feedback
  51072. * @param program defines the associated webGL program
  51073. * @param value defines the list of strings representing the varying names
  51074. */
  51075. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  51076. /**
  51077. * Bind a webGL buffer for a transform feedback operation
  51078. * @param value defines the webGL buffer to bind
  51079. */
  51080. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  51081. }
  51082. }
  51083. declare module BABYLON {
  51084. /**
  51085. * Creation options of the multi render target texture.
  51086. */
  51087. export interface IMultiRenderTargetOptions {
  51088. /**
  51089. * Define if the texture needs to create mip maps after render.
  51090. */
  51091. generateMipMaps?: boolean;
  51092. /**
  51093. * Define the types of all the draw buffers we want to create
  51094. */
  51095. types?: number[];
  51096. /**
  51097. * Define the sampling modes of all the draw buffers we want to create
  51098. */
  51099. samplingModes?: number[];
  51100. /**
  51101. * Define if a depth buffer is required
  51102. */
  51103. generateDepthBuffer?: boolean;
  51104. /**
  51105. * Define if a stencil buffer is required
  51106. */
  51107. generateStencilBuffer?: boolean;
  51108. /**
  51109. * Define if a depth texture is required instead of a depth buffer
  51110. */
  51111. generateDepthTexture?: boolean;
  51112. /**
  51113. * Define the number of desired draw buffers
  51114. */
  51115. textureCount?: number;
  51116. /**
  51117. * Define if aspect ratio should be adapted to the texture or stay the scene one
  51118. */
  51119. doNotChangeAspectRatio?: boolean;
  51120. /**
  51121. * Define the default type of the buffers we are creating
  51122. */
  51123. defaultType?: number;
  51124. }
  51125. /**
  51126. * A multi render target, like a render target provides the ability to render to a texture.
  51127. * Unlike the render target, it can render to several draw buffers in one draw.
  51128. * This is specially interesting in deferred rendering or for any effects requiring more than
  51129. * just one color from a single pass.
  51130. */
  51131. export class MultiRenderTarget extends RenderTargetTexture {
  51132. private _internalTextures;
  51133. private _textures;
  51134. private _multiRenderTargetOptions;
  51135. /**
  51136. * Get if draw buffers are currently supported by the used hardware and browser.
  51137. */
  51138. get isSupported(): boolean;
  51139. /**
  51140. * Get the list of textures generated by the multi render target.
  51141. */
  51142. get textures(): Texture[];
  51143. /**
  51144. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  51145. */
  51146. get depthTexture(): Texture;
  51147. /**
  51148. * Set the wrapping mode on U of all the textures we are rendering to.
  51149. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51150. */
  51151. set wrapU(wrap: number);
  51152. /**
  51153. * Set the wrapping mode on V of all the textures we are rendering to.
  51154. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51155. */
  51156. set wrapV(wrap: number);
  51157. /**
  51158. * Instantiate a new multi render target texture.
  51159. * A multi render target, like a render target provides the ability to render to a texture.
  51160. * Unlike the render target, it can render to several draw buffers in one draw.
  51161. * This is specially interesting in deferred rendering or for any effects requiring more than
  51162. * just one color from a single pass.
  51163. * @param name Define the name of the texture
  51164. * @param size Define the size of the buffers to render to
  51165. * @param count Define the number of target we are rendering into
  51166. * @param scene Define the scene the texture belongs to
  51167. * @param options Define the options used to create the multi render target
  51168. */
  51169. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  51170. /** @hidden */
  51171. _rebuild(): void;
  51172. private _createInternalTextures;
  51173. private _createTextures;
  51174. /**
  51175. * Define the number of samples used if MSAA is enabled.
  51176. */
  51177. get samples(): number;
  51178. set samples(value: number);
  51179. /**
  51180. * Resize all the textures in the multi render target.
  51181. * Be carrefull as it will recreate all the data in the new texture.
  51182. * @param size Define the new size
  51183. */
  51184. resize(size: any): void;
  51185. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  51186. /**
  51187. * Dispose the render targets and their associated resources
  51188. */
  51189. dispose(): void;
  51190. /**
  51191. * Release all the underlying texture used as draw buffers.
  51192. */
  51193. releaseInternalTextures(): void;
  51194. }
  51195. }
  51196. declare module BABYLON {
  51197. interface ThinEngine {
  51198. /**
  51199. * Unbind a list of render target textures from the webGL context
  51200. * This is used only when drawBuffer extension or webGL2 are active
  51201. * @param textures defines the render target textures to unbind
  51202. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51203. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51204. */
  51205. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  51206. /**
  51207. * Create a multi render target texture
  51208. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  51209. * @param size defines the size of the texture
  51210. * @param options defines the creation options
  51211. * @returns the cube texture as an InternalTexture
  51212. */
  51213. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  51214. /**
  51215. * Update the sample count for a given multiple render target texture
  51216. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  51217. * @param textures defines the textures to update
  51218. * @param samples defines the sample count to set
  51219. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  51220. */
  51221. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  51222. }
  51223. }
  51224. declare module BABYLON {
  51225. /**
  51226. * Class used to define an additional view for the engine
  51227. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51228. */
  51229. export class EngineView {
  51230. /** Defines the canvas where to render the view */
  51231. target: HTMLCanvasElement;
  51232. /** Defines an optional camera used to render the view (will use active camera else) */
  51233. camera?: Camera;
  51234. }
  51235. interface Engine {
  51236. /**
  51237. * Gets or sets the HTML element to use for attaching events
  51238. */
  51239. inputElement: Nullable<HTMLElement>;
  51240. /**
  51241. * Gets the current engine view
  51242. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51243. */
  51244. activeView: Nullable<EngineView>;
  51245. /** Gets or sets the list of views */
  51246. views: EngineView[];
  51247. /**
  51248. * Register a new child canvas
  51249. * @param canvas defines the canvas to register
  51250. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51251. * @returns the associated view
  51252. */
  51253. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51254. /**
  51255. * Remove a registered child canvas
  51256. * @param canvas defines the canvas to remove
  51257. * @returns the current engine
  51258. */
  51259. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51260. }
  51261. }
  51262. declare module BABYLON {
  51263. interface Engine {
  51264. /** @hidden */
  51265. _excludedCompressedTextures: string[];
  51266. /** @hidden */
  51267. _textureFormatInUse: string;
  51268. /**
  51269. * Gets the list of texture formats supported
  51270. */
  51271. readonly texturesSupported: Array<string>;
  51272. /**
  51273. * Gets the texture format in use
  51274. */
  51275. readonly textureFormatInUse: Nullable<string>;
  51276. /**
  51277. * Set the compressed texture extensions or file names to skip.
  51278. *
  51279. * @param skippedFiles defines the list of those texture files you want to skip
  51280. * Example: [".dds", ".env", "myfile.png"]
  51281. */
  51282. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51283. /**
  51284. * Set the compressed texture format to use, based on the formats you have, and the formats
  51285. * supported by the hardware / browser.
  51286. *
  51287. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51288. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51289. * to API arguments needed to compressed textures. This puts the burden on the container
  51290. * generator to house the arcane code for determining these for current & future formats.
  51291. *
  51292. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51293. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51294. *
  51295. * Note: The result of this call is not taken into account when a texture is base64.
  51296. *
  51297. * @param formatsAvailable defines the list of those format families you have created
  51298. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51299. *
  51300. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51301. * @returns The extension selected.
  51302. */
  51303. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51304. }
  51305. }
  51306. declare module BABYLON {
  51307. /**
  51308. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51309. */
  51310. export interface CubeMapInfo {
  51311. /**
  51312. * The pixel array for the front face.
  51313. * This is stored in format, left to right, up to down format.
  51314. */
  51315. front: Nullable<ArrayBufferView>;
  51316. /**
  51317. * The pixel array for the back face.
  51318. * This is stored in format, left to right, up to down format.
  51319. */
  51320. back: Nullable<ArrayBufferView>;
  51321. /**
  51322. * The pixel array for the left face.
  51323. * This is stored in format, left to right, up to down format.
  51324. */
  51325. left: Nullable<ArrayBufferView>;
  51326. /**
  51327. * The pixel array for the right face.
  51328. * This is stored in format, left to right, up to down format.
  51329. */
  51330. right: Nullable<ArrayBufferView>;
  51331. /**
  51332. * The pixel array for the up face.
  51333. * This is stored in format, left to right, up to down format.
  51334. */
  51335. up: Nullable<ArrayBufferView>;
  51336. /**
  51337. * The pixel array for the down face.
  51338. * This is stored in format, left to right, up to down format.
  51339. */
  51340. down: Nullable<ArrayBufferView>;
  51341. /**
  51342. * The size of the cubemap stored.
  51343. *
  51344. * Each faces will be size * size pixels.
  51345. */
  51346. size: number;
  51347. /**
  51348. * The format of the texture.
  51349. *
  51350. * RGBA, RGB.
  51351. */
  51352. format: number;
  51353. /**
  51354. * The type of the texture data.
  51355. *
  51356. * UNSIGNED_INT, FLOAT.
  51357. */
  51358. type: number;
  51359. /**
  51360. * Specifies whether the texture is in gamma space.
  51361. */
  51362. gammaSpace: boolean;
  51363. }
  51364. /**
  51365. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51366. */
  51367. export class PanoramaToCubeMapTools {
  51368. private static FACE_LEFT;
  51369. private static FACE_RIGHT;
  51370. private static FACE_FRONT;
  51371. private static FACE_BACK;
  51372. private static FACE_DOWN;
  51373. private static FACE_UP;
  51374. /**
  51375. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51376. *
  51377. * @param float32Array The source data.
  51378. * @param inputWidth The width of the input panorama.
  51379. * @param inputHeight The height of the input panorama.
  51380. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51381. * @return The cubemap data
  51382. */
  51383. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51384. private static CreateCubemapTexture;
  51385. private static CalcProjectionSpherical;
  51386. }
  51387. }
  51388. declare module BABYLON {
  51389. /**
  51390. * Helper class dealing with the extraction of spherical polynomial dataArray
  51391. * from a cube map.
  51392. */
  51393. export class CubeMapToSphericalPolynomialTools {
  51394. private static FileFaces;
  51395. /**
  51396. * Converts a texture to the according Spherical Polynomial data.
  51397. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51398. *
  51399. * @param texture The texture to extract the information from.
  51400. * @return The Spherical Polynomial data.
  51401. */
  51402. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51403. /**
  51404. * Converts a cubemap to the according Spherical Polynomial data.
  51405. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51406. *
  51407. * @param cubeInfo The Cube map to extract the information from.
  51408. * @return The Spherical Polynomial data.
  51409. */
  51410. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51411. }
  51412. }
  51413. declare module BABYLON {
  51414. interface BaseTexture {
  51415. /**
  51416. * Get the polynomial representation of the texture data.
  51417. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51418. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51419. */
  51420. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51421. }
  51422. }
  51423. declare module BABYLON {
  51424. /** @hidden */
  51425. export var rgbdEncodePixelShader: {
  51426. name: string;
  51427. shader: string;
  51428. };
  51429. }
  51430. declare module BABYLON {
  51431. /** @hidden */
  51432. export var rgbdDecodePixelShader: {
  51433. name: string;
  51434. shader: string;
  51435. };
  51436. }
  51437. declare module BABYLON {
  51438. /**
  51439. * Raw texture data and descriptor sufficient for WebGL texture upload
  51440. */
  51441. export interface EnvironmentTextureInfo {
  51442. /**
  51443. * Version of the environment map
  51444. */
  51445. version: number;
  51446. /**
  51447. * Width of image
  51448. */
  51449. width: number;
  51450. /**
  51451. * Irradiance information stored in the file.
  51452. */
  51453. irradiance: any;
  51454. /**
  51455. * Specular information stored in the file.
  51456. */
  51457. specular: any;
  51458. }
  51459. /**
  51460. * Defines One Image in the file. It requires only the position in the file
  51461. * as well as the length.
  51462. */
  51463. interface BufferImageData {
  51464. /**
  51465. * Length of the image data.
  51466. */
  51467. length: number;
  51468. /**
  51469. * Position of the data from the null terminator delimiting the end of the JSON.
  51470. */
  51471. position: number;
  51472. }
  51473. /**
  51474. * Defines the specular data enclosed in the file.
  51475. * This corresponds to the version 1 of the data.
  51476. */
  51477. export interface EnvironmentTextureSpecularInfoV1 {
  51478. /**
  51479. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51480. */
  51481. specularDataPosition?: number;
  51482. /**
  51483. * This contains all the images data needed to reconstruct the cubemap.
  51484. */
  51485. mipmaps: Array<BufferImageData>;
  51486. /**
  51487. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51488. */
  51489. lodGenerationScale: number;
  51490. }
  51491. /**
  51492. * Sets of helpers addressing the serialization and deserialization of environment texture
  51493. * stored in a BabylonJS env file.
  51494. * Those files are usually stored as .env files.
  51495. */
  51496. export class EnvironmentTextureTools {
  51497. /**
  51498. * Magic number identifying the env file.
  51499. */
  51500. private static _MagicBytes;
  51501. /**
  51502. * Gets the environment info from an env file.
  51503. * @param data The array buffer containing the .env bytes.
  51504. * @returns the environment file info (the json header) if successfully parsed.
  51505. */
  51506. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51507. /**
  51508. * Creates an environment texture from a loaded cube texture.
  51509. * @param texture defines the cube texture to convert in env file
  51510. * @return a promise containing the environment data if succesfull.
  51511. */
  51512. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51513. /**
  51514. * Creates a JSON representation of the spherical data.
  51515. * @param texture defines the texture containing the polynomials
  51516. * @return the JSON representation of the spherical info
  51517. */
  51518. private static _CreateEnvTextureIrradiance;
  51519. /**
  51520. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51521. * @param data the image data
  51522. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51523. * @return the views described by info providing access to the underlying buffer
  51524. */
  51525. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51526. /**
  51527. * Uploads the texture info contained in the env file to the GPU.
  51528. * @param texture defines the internal texture to upload to
  51529. * @param data defines the data to load
  51530. * @param info defines the texture info retrieved through the GetEnvInfo method
  51531. * @returns a promise
  51532. */
  51533. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51534. private static _OnImageReadyAsync;
  51535. /**
  51536. * Uploads the levels of image data to the GPU.
  51537. * @param texture defines the internal texture to upload to
  51538. * @param imageData defines the array buffer views of image data [mipmap][face]
  51539. * @returns a promise
  51540. */
  51541. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51542. /**
  51543. * Uploads spherical polynomials information to the texture.
  51544. * @param texture defines the texture we are trying to upload the information to
  51545. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51546. */
  51547. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51548. /** @hidden */
  51549. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51550. }
  51551. }
  51552. declare module BABYLON {
  51553. /** @hidden */
  51554. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  51555. private _genericAttributeLocation;
  51556. private _varyingLocationCount;
  51557. private _varyingLocationMap;
  51558. private _replacements;
  51559. private _textureCount;
  51560. private _uniforms;
  51561. lineProcessor(line: string): string;
  51562. attributeProcessor(attribute: string): string;
  51563. varyingProcessor(varying: string, isFragment: boolean): string;
  51564. uniformProcessor(uniform: string): string;
  51565. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51566. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51567. }
  51568. }
  51569. declare module BABYLON {
  51570. /**
  51571. * Class used to inline functions in shader code
  51572. */
  51573. export class ShaderCodeInliner {
  51574. private static readonly _RegexpFindFunctionNameAndType;
  51575. private _sourceCode;
  51576. private _functionDescr;
  51577. private _numMaxIterations;
  51578. /** Gets or sets the token used to mark the functions to inline */
  51579. inlineToken: string;
  51580. /** Gets or sets the debug mode */
  51581. debug: boolean;
  51582. /** Gets the code after the inlining process */
  51583. get code(): string;
  51584. /**
  51585. * Initializes the inliner
  51586. * @param sourceCode shader code source to inline
  51587. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51588. */
  51589. constructor(sourceCode: string, numMaxIterations?: number);
  51590. /**
  51591. * Start the processing of the shader code
  51592. */
  51593. processCode(): void;
  51594. private _collectFunctions;
  51595. private _processInlining;
  51596. private _extractBetweenMarkers;
  51597. private _skipWhitespaces;
  51598. private _removeComments;
  51599. private _replaceFunctionCallsByCode;
  51600. private _findBackward;
  51601. private _escapeRegExp;
  51602. private _replaceNames;
  51603. }
  51604. }
  51605. declare module BABYLON {
  51606. /**
  51607. * Container for accessors for natively-stored mesh data buffers.
  51608. */
  51609. class NativeDataBuffer extends DataBuffer {
  51610. /**
  51611. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51612. */
  51613. nativeIndexBuffer?: any;
  51614. /**
  51615. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51616. */
  51617. nativeVertexBuffer?: any;
  51618. }
  51619. /** @hidden */
  51620. class NativeTexture extends InternalTexture {
  51621. getInternalTexture(): InternalTexture;
  51622. getViewCount(): number;
  51623. }
  51624. /** @hidden */
  51625. export class NativeEngine extends Engine {
  51626. private readonly _native;
  51627. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51628. private readonly INVALID_HANDLE;
  51629. getHardwareScalingLevel(): number;
  51630. constructor();
  51631. dispose(): void;
  51632. /**
  51633. * Can be used to override the current requestAnimationFrame requester.
  51634. * @hidden
  51635. */
  51636. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51637. /**
  51638. * Override default engine behavior.
  51639. * @param color
  51640. * @param backBuffer
  51641. * @param depth
  51642. * @param stencil
  51643. */
  51644. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51645. /**
  51646. * Gets host document
  51647. * @returns the host document object
  51648. */
  51649. getHostDocument(): Nullable<Document>;
  51650. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51651. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51652. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51653. recordVertexArrayObject(vertexBuffers: {
  51654. [key: string]: VertexBuffer;
  51655. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51656. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51657. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51658. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51659. /**
  51660. * Draw a list of indexed primitives
  51661. * @param fillMode defines the primitive to use
  51662. * @param indexStart defines the starting index
  51663. * @param indexCount defines the number of index to draw
  51664. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51665. */
  51666. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51667. /**
  51668. * Draw a list of unindexed primitives
  51669. * @param fillMode defines the primitive to use
  51670. * @param verticesStart defines the index of first vertex to draw
  51671. * @param verticesCount defines the count of vertices to draw
  51672. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51673. */
  51674. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51675. createPipelineContext(): IPipelineContext;
  51676. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51677. /** @hidden */
  51678. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51679. /** @hidden */
  51680. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51681. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51682. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51683. protected _setProgram(program: WebGLProgram): void;
  51684. _releaseEffect(effect: Effect): void;
  51685. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51686. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51687. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51688. bindSamplers(effect: Effect): void;
  51689. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51690. getRenderWidth(useScreen?: boolean): number;
  51691. getRenderHeight(useScreen?: boolean): number;
  51692. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51693. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51694. /**
  51695. * Set the z offset to apply to current rendering
  51696. * @param value defines the offset to apply
  51697. */
  51698. setZOffset(value: number): void;
  51699. /**
  51700. * Gets the current value of the zOffset
  51701. * @returns the current zOffset state
  51702. */
  51703. getZOffset(): number;
  51704. /**
  51705. * Enable or disable depth buffering
  51706. * @param enable defines the state to set
  51707. */
  51708. setDepthBuffer(enable: boolean): void;
  51709. /**
  51710. * Gets a boolean indicating if depth writing is enabled
  51711. * @returns the current depth writing state
  51712. */
  51713. getDepthWrite(): boolean;
  51714. /**
  51715. * Enable or disable depth writing
  51716. * @param enable defines the state to set
  51717. */
  51718. setDepthWrite(enable: boolean): void;
  51719. /**
  51720. * Enable or disable color writing
  51721. * @param enable defines the state to set
  51722. */
  51723. setColorWrite(enable: boolean): void;
  51724. /**
  51725. * Gets a boolean indicating if color writing is enabled
  51726. * @returns the current color writing state
  51727. */
  51728. getColorWrite(): boolean;
  51729. /**
  51730. * Sets alpha constants used by some alpha blending modes
  51731. * @param r defines the red component
  51732. * @param g defines the green component
  51733. * @param b defines the blue component
  51734. * @param a defines the alpha component
  51735. */
  51736. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51737. /**
  51738. * Sets the current alpha mode
  51739. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51740. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51741. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51742. */
  51743. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51744. /**
  51745. * Gets the current alpha mode
  51746. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51747. * @returns the current alpha mode
  51748. */
  51749. getAlphaMode(): number;
  51750. setInt(uniform: WebGLUniformLocation, int: number): void;
  51751. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51752. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51753. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51754. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51755. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51756. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51757. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51758. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51759. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51760. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51761. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51762. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51763. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51764. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51765. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51766. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51767. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51768. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51769. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51770. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51771. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51772. wipeCaches(bruteForce?: boolean): void;
  51773. _createTexture(): WebGLTexture;
  51774. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51775. /**
  51776. * Usually called from Texture.ts.
  51777. * Passed information to create a WebGLTexture
  51778. * @param url defines a value which contains one of the following:
  51779. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51780. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51781. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51782. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51783. * @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)
  51784. * @param scene needed for loading to the correct scene
  51785. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51786. * @param onLoad optional callback to be called upon successful completion
  51787. * @param onError optional callback to be called upon failure
  51788. * @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
  51789. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51790. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51791. * @param forcedExtension defines the extension to use to pick the right loader
  51792. * @param mimeType defines an optional mime type
  51793. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51794. */
  51795. 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;
  51796. /**
  51797. * Creates a cube texture
  51798. * @param rootUrl defines the url where the files to load is located
  51799. * @param scene defines the current scene
  51800. * @param files defines the list of files to load (1 per face)
  51801. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51802. * @param onLoad defines an optional callback raised when the texture is loaded
  51803. * @param onError defines an optional callback raised if there is an issue to load the texture
  51804. * @param format defines the format of the data
  51805. * @param forcedExtension defines the extension to use to pick the right loader
  51806. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51807. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51808. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51809. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51810. * @returns the cube texture as an InternalTexture
  51811. */
  51812. 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;
  51813. private _getSamplingFilter;
  51814. private static _GetNativeTextureFormat;
  51815. createRenderTargetTexture(size: number | {
  51816. width: number;
  51817. height: number;
  51818. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51819. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51820. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51821. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51822. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51823. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51824. /**
  51825. * Updates a dynamic vertex buffer.
  51826. * @param vertexBuffer the vertex buffer to update
  51827. * @param data the data used to update the vertex buffer
  51828. * @param byteOffset the byte offset of the data (optional)
  51829. * @param byteLength the byte length of the data (optional)
  51830. */
  51831. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51832. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51833. private _updateAnisotropicLevel;
  51834. private _getAddressMode;
  51835. /** @hidden */
  51836. _bindTexture(channel: number, texture: InternalTexture): void;
  51837. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51838. releaseEffects(): void;
  51839. /** @hidden */
  51840. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51841. /** @hidden */
  51842. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51843. /** @hidden */
  51844. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51845. /** @hidden */
  51846. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51847. }
  51848. }
  51849. declare module BABYLON {
  51850. /**
  51851. * Gather the list of clipboard event types as constants.
  51852. */
  51853. export class ClipboardEventTypes {
  51854. /**
  51855. * The clipboard event is fired when a copy command is active (pressed).
  51856. */
  51857. static readonly COPY: number;
  51858. /**
  51859. * The clipboard event is fired when a cut command is active (pressed).
  51860. */
  51861. static readonly CUT: number;
  51862. /**
  51863. * The clipboard event is fired when a paste command is active (pressed).
  51864. */
  51865. static readonly PASTE: number;
  51866. }
  51867. /**
  51868. * This class is used to store clipboard related info for the onClipboardObservable event.
  51869. */
  51870. export class ClipboardInfo {
  51871. /**
  51872. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51873. */
  51874. type: number;
  51875. /**
  51876. * Defines the related dom event
  51877. */
  51878. event: ClipboardEvent;
  51879. /**
  51880. *Creates an instance of ClipboardInfo.
  51881. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51882. * @param event Defines the related dom event
  51883. */
  51884. constructor(
  51885. /**
  51886. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51887. */
  51888. type: number,
  51889. /**
  51890. * Defines the related dom event
  51891. */
  51892. event: ClipboardEvent);
  51893. /**
  51894. * Get the clipboard event's type from the keycode.
  51895. * @param keyCode Defines the keyCode for the current keyboard event.
  51896. * @return {number}
  51897. */
  51898. static GetTypeFromCharacter(keyCode: number): number;
  51899. }
  51900. }
  51901. declare module BABYLON {
  51902. /**
  51903. * Google Daydream controller
  51904. */
  51905. export class DaydreamController extends WebVRController {
  51906. /**
  51907. * Base Url for the controller model.
  51908. */
  51909. static MODEL_BASE_URL: string;
  51910. /**
  51911. * File name for the controller model.
  51912. */
  51913. static MODEL_FILENAME: string;
  51914. /**
  51915. * Gamepad Id prefix used to identify Daydream Controller.
  51916. */
  51917. static readonly GAMEPAD_ID_PREFIX: string;
  51918. /**
  51919. * Creates a new DaydreamController from a gamepad
  51920. * @param vrGamepad the gamepad that the controller should be created from
  51921. */
  51922. constructor(vrGamepad: any);
  51923. /**
  51924. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51925. * @param scene scene in which to add meshes
  51926. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51927. */
  51928. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51929. /**
  51930. * Called once for each button that changed state since the last frame
  51931. * @param buttonIdx Which button index changed
  51932. * @param state New state of the button
  51933. * @param changes Which properties on the state changed since last frame
  51934. */
  51935. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51936. }
  51937. }
  51938. declare module BABYLON {
  51939. /**
  51940. * Gear VR Controller
  51941. */
  51942. export class GearVRController extends WebVRController {
  51943. /**
  51944. * Base Url for the controller model.
  51945. */
  51946. static MODEL_BASE_URL: string;
  51947. /**
  51948. * File name for the controller model.
  51949. */
  51950. static MODEL_FILENAME: string;
  51951. /**
  51952. * Gamepad Id prefix used to identify this controller.
  51953. */
  51954. static readonly GAMEPAD_ID_PREFIX: string;
  51955. private readonly _buttonIndexToObservableNameMap;
  51956. /**
  51957. * Creates a new GearVRController from a gamepad
  51958. * @param vrGamepad the gamepad that the controller should be created from
  51959. */
  51960. constructor(vrGamepad: any);
  51961. /**
  51962. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51963. * @param scene scene in which to add meshes
  51964. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51965. */
  51966. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51967. /**
  51968. * Called once for each button that changed state since the last frame
  51969. * @param buttonIdx Which button index changed
  51970. * @param state New state of the button
  51971. * @param changes Which properties on the state changed since last frame
  51972. */
  51973. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51974. }
  51975. }
  51976. declare module BABYLON {
  51977. /**
  51978. * Generic Controller
  51979. */
  51980. export class GenericController extends WebVRController {
  51981. /**
  51982. * Base Url for the controller model.
  51983. */
  51984. static readonly MODEL_BASE_URL: string;
  51985. /**
  51986. * File name for the controller model.
  51987. */
  51988. static readonly MODEL_FILENAME: string;
  51989. /**
  51990. * Creates a new GenericController from a gamepad
  51991. * @param vrGamepad the gamepad that the controller should be created from
  51992. */
  51993. constructor(vrGamepad: any);
  51994. /**
  51995. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51996. * @param scene scene in which to add meshes
  51997. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51998. */
  51999. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52000. /**
  52001. * Called once for each button that changed state since the last frame
  52002. * @param buttonIdx Which button index changed
  52003. * @param state New state of the button
  52004. * @param changes Which properties on the state changed since last frame
  52005. */
  52006. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52007. }
  52008. }
  52009. declare module BABYLON {
  52010. /**
  52011. * Oculus Touch Controller
  52012. */
  52013. export class OculusTouchController extends WebVRController {
  52014. /**
  52015. * Base Url for the controller model.
  52016. */
  52017. static MODEL_BASE_URL: string;
  52018. /**
  52019. * File name for the left controller model.
  52020. */
  52021. static MODEL_LEFT_FILENAME: string;
  52022. /**
  52023. * File name for the right controller model.
  52024. */
  52025. static MODEL_RIGHT_FILENAME: string;
  52026. /**
  52027. * Base Url for the Quest controller model.
  52028. */
  52029. static QUEST_MODEL_BASE_URL: string;
  52030. /**
  52031. * @hidden
  52032. * If the controllers are running on a device that needs the updated Quest controller models
  52033. */
  52034. static _IsQuest: boolean;
  52035. /**
  52036. * Fired when the secondary trigger on this controller is modified
  52037. */
  52038. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52039. /**
  52040. * Fired when the thumb rest on this controller is modified
  52041. */
  52042. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52043. /**
  52044. * Creates a new OculusTouchController from a gamepad
  52045. * @param vrGamepad the gamepad that the controller should be created from
  52046. */
  52047. constructor(vrGamepad: any);
  52048. /**
  52049. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52050. * @param scene scene in which to add meshes
  52051. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52052. */
  52053. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52054. /**
  52055. * Fired when the A button on this controller is modified
  52056. */
  52057. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52058. /**
  52059. * Fired when the B button on this controller is modified
  52060. */
  52061. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52062. /**
  52063. * Fired when the X button on this controller is modified
  52064. */
  52065. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52066. /**
  52067. * Fired when the Y button on this controller is modified
  52068. */
  52069. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52070. /**
  52071. * Called once for each button that changed state since the last frame
  52072. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52073. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52074. * 2) secondary trigger (same)
  52075. * 3) A (right) X (left), touch, pressed = value
  52076. * 4) B / Y
  52077. * 5) thumb rest
  52078. * @param buttonIdx Which button index changed
  52079. * @param state New state of the button
  52080. * @param changes Which properties on the state changed since last frame
  52081. */
  52082. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52083. }
  52084. }
  52085. declare module BABYLON {
  52086. /**
  52087. * Vive Controller
  52088. */
  52089. export class ViveController extends WebVRController {
  52090. /**
  52091. * Base Url for the controller model.
  52092. */
  52093. static MODEL_BASE_URL: string;
  52094. /**
  52095. * File name for the controller model.
  52096. */
  52097. static MODEL_FILENAME: string;
  52098. /**
  52099. * Creates a new ViveController from a gamepad
  52100. * @param vrGamepad the gamepad that the controller should be created from
  52101. */
  52102. constructor(vrGamepad: any);
  52103. /**
  52104. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52105. * @param scene scene in which to add meshes
  52106. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52107. */
  52108. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52109. /**
  52110. * Fired when the left button on this controller is modified
  52111. */
  52112. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52113. /**
  52114. * Fired when the right button on this controller is modified
  52115. */
  52116. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52117. /**
  52118. * Fired when the menu button on this controller is modified
  52119. */
  52120. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52121. /**
  52122. * Called once for each button that changed state since the last frame
  52123. * Vive mapping:
  52124. * 0: touchpad
  52125. * 1: trigger
  52126. * 2: left AND right buttons
  52127. * 3: menu button
  52128. * @param buttonIdx Which button index changed
  52129. * @param state New state of the button
  52130. * @param changes Which properties on the state changed since last frame
  52131. */
  52132. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52133. }
  52134. }
  52135. declare module BABYLON {
  52136. /**
  52137. * Defines the WindowsMotionController object that the state of the windows motion controller
  52138. */
  52139. export class WindowsMotionController extends WebVRController {
  52140. /**
  52141. * The base url used to load the left and right controller models
  52142. */
  52143. static MODEL_BASE_URL: string;
  52144. /**
  52145. * The name of the left controller model file
  52146. */
  52147. static MODEL_LEFT_FILENAME: string;
  52148. /**
  52149. * The name of the right controller model file
  52150. */
  52151. static MODEL_RIGHT_FILENAME: string;
  52152. /**
  52153. * The controller name prefix for this controller type
  52154. */
  52155. static readonly GAMEPAD_ID_PREFIX: string;
  52156. /**
  52157. * The controller id pattern for this controller type
  52158. */
  52159. private static readonly GAMEPAD_ID_PATTERN;
  52160. private _loadedMeshInfo;
  52161. protected readonly _mapping: {
  52162. buttons: string[];
  52163. buttonMeshNames: {
  52164. trigger: string;
  52165. menu: string;
  52166. grip: string;
  52167. thumbstick: string;
  52168. trackpad: string;
  52169. };
  52170. buttonObservableNames: {
  52171. trigger: string;
  52172. menu: string;
  52173. grip: string;
  52174. thumbstick: string;
  52175. trackpad: string;
  52176. };
  52177. axisMeshNames: string[];
  52178. pointingPoseMeshName: string;
  52179. };
  52180. /**
  52181. * Fired when the trackpad on this controller is clicked
  52182. */
  52183. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52184. /**
  52185. * Fired when the trackpad on this controller is modified
  52186. */
  52187. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52188. /**
  52189. * The current x and y values of this controller's trackpad
  52190. */
  52191. trackpad: StickValues;
  52192. /**
  52193. * Creates a new WindowsMotionController from a gamepad
  52194. * @param vrGamepad the gamepad that the controller should be created from
  52195. */
  52196. constructor(vrGamepad: any);
  52197. /**
  52198. * Fired when the trigger on this controller is modified
  52199. */
  52200. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52201. /**
  52202. * Fired when the menu button on this controller is modified
  52203. */
  52204. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52205. /**
  52206. * Fired when the grip button on this controller is modified
  52207. */
  52208. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52209. /**
  52210. * Fired when the thumbstick button on this controller is modified
  52211. */
  52212. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52213. /**
  52214. * Fired when the touchpad button on this controller is modified
  52215. */
  52216. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52217. /**
  52218. * Fired when the touchpad values on this controller are modified
  52219. */
  52220. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52221. protected _updateTrackpad(): void;
  52222. /**
  52223. * Called once per frame by the engine.
  52224. */
  52225. update(): void;
  52226. /**
  52227. * Called once for each button that changed state since the last frame
  52228. * @param buttonIdx Which button index changed
  52229. * @param state New state of the button
  52230. * @param changes Which properties on the state changed since last frame
  52231. */
  52232. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52233. /**
  52234. * Moves the buttons on the controller mesh based on their current state
  52235. * @param buttonName the name of the button to move
  52236. * @param buttonValue the value of the button which determines the buttons new position
  52237. */
  52238. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52239. /**
  52240. * Moves the axis on the controller mesh based on its current state
  52241. * @param axis the index of the axis
  52242. * @param axisValue the value of the axis which determines the meshes new position
  52243. * @hidden
  52244. */
  52245. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52246. /**
  52247. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52248. * @param scene scene in which to add meshes
  52249. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52250. */
  52251. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52252. /**
  52253. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52254. * can be transformed by button presses and axes values, based on this._mapping.
  52255. *
  52256. * @param scene scene in which the meshes exist
  52257. * @param meshes list of meshes that make up the controller model to process
  52258. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52259. */
  52260. private processModel;
  52261. private createMeshInfo;
  52262. /**
  52263. * Gets the ray of the controller in the direction the controller is pointing
  52264. * @param length the length the resulting ray should be
  52265. * @returns a ray in the direction the controller is pointing
  52266. */
  52267. getForwardRay(length?: number): Ray;
  52268. /**
  52269. * Disposes of the controller
  52270. */
  52271. dispose(): void;
  52272. }
  52273. /**
  52274. * This class represents a new windows motion controller in XR.
  52275. */
  52276. export class XRWindowsMotionController extends WindowsMotionController {
  52277. /**
  52278. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52279. */
  52280. protected readonly _mapping: {
  52281. buttons: string[];
  52282. buttonMeshNames: {
  52283. trigger: string;
  52284. menu: string;
  52285. grip: string;
  52286. thumbstick: string;
  52287. trackpad: string;
  52288. };
  52289. buttonObservableNames: {
  52290. trigger: string;
  52291. menu: string;
  52292. grip: string;
  52293. thumbstick: string;
  52294. trackpad: string;
  52295. };
  52296. axisMeshNames: string[];
  52297. pointingPoseMeshName: string;
  52298. };
  52299. /**
  52300. * Construct a new XR-Based windows motion controller
  52301. *
  52302. * @param gamepadInfo the gamepad object from the browser
  52303. */
  52304. constructor(gamepadInfo: any);
  52305. /**
  52306. * holds the thumbstick values (X,Y)
  52307. */
  52308. thumbstickValues: StickValues;
  52309. /**
  52310. * Fired when the thumbstick on this controller is clicked
  52311. */
  52312. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52313. /**
  52314. * Fired when the thumbstick on this controller is modified
  52315. */
  52316. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52317. /**
  52318. * Fired when the touchpad button on this controller is modified
  52319. */
  52320. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52321. /**
  52322. * Fired when the touchpad values on this controller are modified
  52323. */
  52324. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52325. /**
  52326. * Fired when the thumbstick button on this controller is modified
  52327. * here to prevent breaking changes
  52328. */
  52329. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52330. /**
  52331. * updating the thumbstick(!) and not the trackpad.
  52332. * This is named this way due to the difference between WebVR and XR and to avoid
  52333. * changing the parent class.
  52334. */
  52335. protected _updateTrackpad(): void;
  52336. /**
  52337. * Disposes the class with joy
  52338. */
  52339. dispose(): void;
  52340. }
  52341. }
  52342. declare module BABYLON {
  52343. /**
  52344. * Class containing static functions to help procedurally build meshes
  52345. */
  52346. export class PolyhedronBuilder {
  52347. /**
  52348. * Creates a polyhedron mesh
  52349. * * 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
  52350. * * The parameter `size` (positive float, default 1) sets the polygon size
  52351. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52352. * * 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`
  52353. * * 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
  52354. * * 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)`)
  52355. * * 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
  52356. * * 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
  52357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52358. * * 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
  52359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52360. * @param name defines the name of the mesh
  52361. * @param options defines the options used to create the mesh
  52362. * @param scene defines the hosting scene
  52363. * @returns the polyhedron mesh
  52364. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52365. */
  52366. static CreatePolyhedron(name: string, options: {
  52367. type?: number;
  52368. size?: number;
  52369. sizeX?: number;
  52370. sizeY?: number;
  52371. sizeZ?: number;
  52372. custom?: any;
  52373. faceUV?: Vector4[];
  52374. faceColors?: Color4[];
  52375. flat?: boolean;
  52376. updatable?: boolean;
  52377. sideOrientation?: number;
  52378. frontUVs?: Vector4;
  52379. backUVs?: Vector4;
  52380. }, scene?: Nullable<Scene>): Mesh;
  52381. }
  52382. }
  52383. declare module BABYLON {
  52384. /**
  52385. * Gizmo that enables scaling a mesh along 3 axis
  52386. */
  52387. export class ScaleGizmo extends Gizmo {
  52388. /**
  52389. * Internal gizmo used for interactions on the x axis
  52390. */
  52391. xGizmo: AxisScaleGizmo;
  52392. /**
  52393. * Internal gizmo used for interactions on the y axis
  52394. */
  52395. yGizmo: AxisScaleGizmo;
  52396. /**
  52397. * Internal gizmo used for interactions on the z axis
  52398. */
  52399. zGizmo: AxisScaleGizmo;
  52400. /**
  52401. * Internal gizmo used to scale all axis equally
  52402. */
  52403. uniformScaleGizmo: AxisScaleGizmo;
  52404. private _meshAttached;
  52405. private _updateGizmoRotationToMatchAttachedMesh;
  52406. private _snapDistance;
  52407. private _scaleRatio;
  52408. private _uniformScalingMesh;
  52409. private _octahedron;
  52410. private _sensitivity;
  52411. /** Fires an event when any of it's sub gizmos are dragged */
  52412. onDragStartObservable: Observable<unknown>;
  52413. /** Fires an event when any of it's sub gizmos are released from dragging */
  52414. onDragEndObservable: Observable<unknown>;
  52415. get attachedMesh(): Nullable<AbstractMesh>;
  52416. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52417. /**
  52418. * Creates a ScaleGizmo
  52419. * @param gizmoLayer The utility layer the gizmo will be added to
  52420. */
  52421. constructor(gizmoLayer?: UtilityLayerRenderer);
  52422. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52423. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52424. /**
  52425. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52426. */
  52427. set snapDistance(value: number);
  52428. get snapDistance(): number;
  52429. /**
  52430. * Ratio for the scale of the gizmo (Default: 1)
  52431. */
  52432. set scaleRatio(value: number);
  52433. get scaleRatio(): number;
  52434. /**
  52435. * Sensitivity factor for dragging (Default: 1)
  52436. */
  52437. set sensitivity(value: number);
  52438. get sensitivity(): number;
  52439. /**
  52440. * Disposes of the gizmo
  52441. */
  52442. dispose(): void;
  52443. }
  52444. }
  52445. declare module BABYLON {
  52446. /**
  52447. * Single axis scale gizmo
  52448. */
  52449. export class AxisScaleGizmo extends Gizmo {
  52450. /**
  52451. * Drag behavior responsible for the gizmos dragging interactions
  52452. */
  52453. dragBehavior: PointerDragBehavior;
  52454. private _pointerObserver;
  52455. /**
  52456. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52457. */
  52458. snapDistance: number;
  52459. /**
  52460. * Event that fires each time the gizmo snaps to a new location.
  52461. * * snapDistance is the the change in distance
  52462. */
  52463. onSnapObservable: Observable<{
  52464. snapDistance: number;
  52465. }>;
  52466. /**
  52467. * If the scaling operation should be done on all axis (default: false)
  52468. */
  52469. uniformScaling: boolean;
  52470. /**
  52471. * Custom sensitivity value for the drag strength
  52472. */
  52473. sensitivity: number;
  52474. private _isEnabled;
  52475. private _parent;
  52476. private _arrow;
  52477. private _coloredMaterial;
  52478. private _hoverMaterial;
  52479. /**
  52480. * Creates an AxisScaleGizmo
  52481. * @param gizmoLayer The utility layer the gizmo will be added to
  52482. * @param dragAxis The axis which the gizmo will be able to scale on
  52483. * @param color The color of the gizmo
  52484. */
  52485. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52486. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52487. /**
  52488. * If the gizmo is enabled
  52489. */
  52490. set isEnabled(value: boolean);
  52491. get isEnabled(): boolean;
  52492. /**
  52493. * Disposes of the gizmo
  52494. */
  52495. dispose(): void;
  52496. /**
  52497. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52498. * @param mesh The mesh to replace the default mesh of the gizmo
  52499. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52500. */
  52501. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52502. }
  52503. }
  52504. declare module BABYLON {
  52505. /**
  52506. * Bounding box gizmo
  52507. */
  52508. export class BoundingBoxGizmo extends Gizmo {
  52509. private _lineBoundingBox;
  52510. private _rotateSpheresParent;
  52511. private _scaleBoxesParent;
  52512. private _boundingDimensions;
  52513. private _renderObserver;
  52514. private _pointerObserver;
  52515. private _scaleDragSpeed;
  52516. private _tmpQuaternion;
  52517. private _tmpVector;
  52518. private _tmpRotationMatrix;
  52519. /**
  52520. * 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)
  52521. */
  52522. ignoreChildren: boolean;
  52523. /**
  52524. * 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)
  52525. */
  52526. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52527. /**
  52528. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52529. */
  52530. rotationSphereSize: number;
  52531. /**
  52532. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52533. */
  52534. scaleBoxSize: number;
  52535. /**
  52536. * 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)
  52537. */
  52538. fixedDragMeshScreenSize: boolean;
  52539. /**
  52540. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52541. */
  52542. fixedDragMeshScreenSizeDistanceFactor: number;
  52543. /**
  52544. * Fired when a rotation sphere or scale box is dragged
  52545. */
  52546. onDragStartObservable: Observable<{}>;
  52547. /**
  52548. * Fired when a scale box is dragged
  52549. */
  52550. onScaleBoxDragObservable: Observable<{}>;
  52551. /**
  52552. * Fired when a scale box drag is ended
  52553. */
  52554. onScaleBoxDragEndObservable: Observable<{}>;
  52555. /**
  52556. * Fired when a rotation sphere is dragged
  52557. */
  52558. onRotationSphereDragObservable: Observable<{}>;
  52559. /**
  52560. * Fired when a rotation sphere drag is ended
  52561. */
  52562. onRotationSphereDragEndObservable: Observable<{}>;
  52563. /**
  52564. * 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)
  52565. */
  52566. scalePivot: Nullable<Vector3>;
  52567. /**
  52568. * Mesh used as a pivot to rotate the attached mesh
  52569. */
  52570. private _anchorMesh;
  52571. private _existingMeshScale;
  52572. private _dragMesh;
  52573. private pointerDragBehavior;
  52574. private coloredMaterial;
  52575. private hoverColoredMaterial;
  52576. /**
  52577. * Sets the color of the bounding box gizmo
  52578. * @param color the color to set
  52579. */
  52580. setColor(color: Color3): void;
  52581. /**
  52582. * Creates an BoundingBoxGizmo
  52583. * @param gizmoLayer The utility layer the gizmo will be added to
  52584. * @param color The color of the gizmo
  52585. */
  52586. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52587. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52588. private _selectNode;
  52589. /**
  52590. * Updates the bounding box information for the Gizmo
  52591. */
  52592. updateBoundingBox(): void;
  52593. private _updateRotationSpheres;
  52594. private _updateScaleBoxes;
  52595. /**
  52596. * Enables rotation on the specified axis and disables rotation on the others
  52597. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52598. */
  52599. setEnabledRotationAxis(axis: string): void;
  52600. /**
  52601. * Enables/disables scaling
  52602. * @param enable if scaling should be enabled
  52603. * @param homogeneousScaling defines if scaling should only be homogeneous
  52604. */
  52605. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52606. private _updateDummy;
  52607. /**
  52608. * Enables a pointer drag behavior on the bounding box of the gizmo
  52609. */
  52610. enableDragBehavior(): void;
  52611. /**
  52612. * Disposes of the gizmo
  52613. */
  52614. dispose(): void;
  52615. /**
  52616. * 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)
  52617. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52618. * @returns the bounding box mesh with the passed in mesh as a child
  52619. */
  52620. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52621. /**
  52622. * CustomMeshes are not supported by this gizmo
  52623. * @param mesh The mesh to replace the default mesh of the gizmo
  52624. */
  52625. setCustomMesh(mesh: Mesh): void;
  52626. }
  52627. }
  52628. declare module BABYLON {
  52629. /**
  52630. * Single plane rotation gizmo
  52631. */
  52632. export class PlaneRotationGizmo extends Gizmo {
  52633. /**
  52634. * Drag behavior responsible for the gizmos dragging interactions
  52635. */
  52636. dragBehavior: PointerDragBehavior;
  52637. private _pointerObserver;
  52638. /**
  52639. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52640. */
  52641. snapDistance: number;
  52642. /**
  52643. * Event that fires each time the gizmo snaps to a new location.
  52644. * * snapDistance is the the change in distance
  52645. */
  52646. onSnapObservable: Observable<{
  52647. snapDistance: number;
  52648. }>;
  52649. private _isEnabled;
  52650. private _parent;
  52651. /**
  52652. * Creates a PlaneRotationGizmo
  52653. * @param gizmoLayer The utility layer the gizmo will be added to
  52654. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52655. * @param color The color of the gizmo
  52656. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52657. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52658. */
  52659. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52660. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52661. /**
  52662. * If the gizmo is enabled
  52663. */
  52664. set isEnabled(value: boolean);
  52665. get isEnabled(): boolean;
  52666. /**
  52667. * Disposes of the gizmo
  52668. */
  52669. dispose(): void;
  52670. }
  52671. }
  52672. declare module BABYLON {
  52673. /**
  52674. * Gizmo that enables rotating a mesh along 3 axis
  52675. */
  52676. export class RotationGizmo extends Gizmo {
  52677. /**
  52678. * Internal gizmo used for interactions on the x axis
  52679. */
  52680. xGizmo: PlaneRotationGizmo;
  52681. /**
  52682. * Internal gizmo used for interactions on the y axis
  52683. */
  52684. yGizmo: PlaneRotationGizmo;
  52685. /**
  52686. * Internal gizmo used for interactions on the z axis
  52687. */
  52688. zGizmo: PlaneRotationGizmo;
  52689. /** Fires an event when any of it's sub gizmos are dragged */
  52690. onDragStartObservable: Observable<unknown>;
  52691. /** Fires an event when any of it's sub gizmos are released from dragging */
  52692. onDragEndObservable: Observable<unknown>;
  52693. private _meshAttached;
  52694. get attachedMesh(): Nullable<AbstractMesh>;
  52695. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52696. /**
  52697. * Creates a RotationGizmo
  52698. * @param gizmoLayer The utility layer the gizmo will be added to
  52699. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52700. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52701. */
  52702. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52703. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52704. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52705. /**
  52706. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52707. */
  52708. set snapDistance(value: number);
  52709. get snapDistance(): number;
  52710. /**
  52711. * Ratio for the scale of the gizmo (Default: 1)
  52712. */
  52713. set scaleRatio(value: number);
  52714. get scaleRatio(): number;
  52715. /**
  52716. * Disposes of the gizmo
  52717. */
  52718. dispose(): void;
  52719. /**
  52720. * CustomMeshes are not supported by this gizmo
  52721. * @param mesh The mesh to replace the default mesh of the gizmo
  52722. */
  52723. setCustomMesh(mesh: Mesh): void;
  52724. }
  52725. }
  52726. declare module BABYLON {
  52727. /**
  52728. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52729. */
  52730. export class GizmoManager implements IDisposable {
  52731. private scene;
  52732. /**
  52733. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52734. */
  52735. gizmos: {
  52736. positionGizmo: Nullable<PositionGizmo>;
  52737. rotationGizmo: Nullable<RotationGizmo>;
  52738. scaleGizmo: Nullable<ScaleGizmo>;
  52739. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52740. };
  52741. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52742. clearGizmoOnEmptyPointerEvent: boolean;
  52743. /** Fires an event when the manager is attached to a mesh */
  52744. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52745. private _gizmosEnabled;
  52746. private _pointerObserver;
  52747. private _attachedMesh;
  52748. private _boundingBoxColor;
  52749. private _defaultUtilityLayer;
  52750. private _defaultKeepDepthUtilityLayer;
  52751. /**
  52752. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52753. */
  52754. boundingBoxDragBehavior: SixDofDragBehavior;
  52755. /**
  52756. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52757. */
  52758. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52759. /**
  52760. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52761. */
  52762. usePointerToAttachGizmos: boolean;
  52763. /**
  52764. * Utility layer that the bounding box gizmo belongs to
  52765. */
  52766. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52767. /**
  52768. * Utility layer that all gizmos besides bounding box belong to
  52769. */
  52770. get utilityLayer(): UtilityLayerRenderer;
  52771. /**
  52772. * Instatiates a gizmo manager
  52773. * @param scene the scene to overlay the gizmos on top of
  52774. */
  52775. constructor(scene: Scene);
  52776. /**
  52777. * Attaches a set of gizmos to the specified mesh
  52778. * @param mesh The mesh the gizmo's should be attached to
  52779. */
  52780. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52781. /**
  52782. * If the position gizmo is enabled
  52783. */
  52784. set positionGizmoEnabled(value: boolean);
  52785. get positionGizmoEnabled(): boolean;
  52786. /**
  52787. * If the rotation gizmo is enabled
  52788. */
  52789. set rotationGizmoEnabled(value: boolean);
  52790. get rotationGizmoEnabled(): boolean;
  52791. /**
  52792. * If the scale gizmo is enabled
  52793. */
  52794. set scaleGizmoEnabled(value: boolean);
  52795. get scaleGizmoEnabled(): boolean;
  52796. /**
  52797. * If the boundingBox gizmo is enabled
  52798. */
  52799. set boundingBoxGizmoEnabled(value: boolean);
  52800. get boundingBoxGizmoEnabled(): boolean;
  52801. /**
  52802. * Disposes of the gizmo manager
  52803. */
  52804. dispose(): void;
  52805. }
  52806. }
  52807. declare module BABYLON {
  52808. /**
  52809. * A directional light is defined by a direction (what a surprise!).
  52810. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52811. * 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.
  52812. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52813. */
  52814. export class DirectionalLight extends ShadowLight {
  52815. private _shadowFrustumSize;
  52816. /**
  52817. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52818. */
  52819. get shadowFrustumSize(): number;
  52820. /**
  52821. * Specifies a fix frustum size for the shadow generation.
  52822. */
  52823. set shadowFrustumSize(value: number);
  52824. private _shadowOrthoScale;
  52825. /**
  52826. * Gets the shadow projection scale against the optimal computed one.
  52827. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52828. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52829. */
  52830. get shadowOrthoScale(): number;
  52831. /**
  52832. * Sets the shadow projection scale against the optimal computed one.
  52833. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52834. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52835. */
  52836. set shadowOrthoScale(value: number);
  52837. /**
  52838. * Automatically compute the projection matrix to best fit (including all the casters)
  52839. * on each frame.
  52840. */
  52841. autoUpdateExtends: boolean;
  52842. /**
  52843. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52844. * on each frame. autoUpdateExtends must be set to true for this to work
  52845. */
  52846. autoCalcShadowZBounds: boolean;
  52847. private _orthoLeft;
  52848. private _orthoRight;
  52849. private _orthoTop;
  52850. private _orthoBottom;
  52851. /**
  52852. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52853. * The directional light is emitted from everywhere in the given direction.
  52854. * It can cast shadows.
  52855. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52856. * @param name The friendly name of the light
  52857. * @param direction The direction of the light
  52858. * @param scene The scene the light belongs to
  52859. */
  52860. constructor(name: string, direction: Vector3, scene: Scene);
  52861. /**
  52862. * Returns the string "DirectionalLight".
  52863. * @return The class name
  52864. */
  52865. getClassName(): string;
  52866. /**
  52867. * Returns the integer 1.
  52868. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52869. */
  52870. getTypeID(): number;
  52871. /**
  52872. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52873. * Returns the DirectionalLight Shadow projection matrix.
  52874. */
  52875. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52876. /**
  52877. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52878. * Returns the DirectionalLight Shadow projection matrix.
  52879. */
  52880. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52881. /**
  52882. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52883. * Returns the DirectionalLight Shadow projection matrix.
  52884. */
  52885. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52886. protected _buildUniformLayout(): void;
  52887. /**
  52888. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52889. * @param effect The effect to update
  52890. * @param lightIndex The index of the light in the effect to update
  52891. * @returns The directional light
  52892. */
  52893. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52894. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52895. /**
  52896. * Gets the minZ used for shadow according to both the scene and the light.
  52897. *
  52898. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52899. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52900. * @param activeCamera The camera we are returning the min for
  52901. * @returns the depth min z
  52902. */
  52903. getDepthMinZ(activeCamera: Camera): number;
  52904. /**
  52905. * Gets the maxZ used for shadow according to both the scene and the light.
  52906. *
  52907. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52908. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52909. * @param activeCamera The camera we are returning the max for
  52910. * @returns the depth max z
  52911. */
  52912. getDepthMaxZ(activeCamera: Camera): number;
  52913. /**
  52914. * Prepares the list of defines specific to the light type.
  52915. * @param defines the list of defines
  52916. * @param lightIndex defines the index of the light for the effect
  52917. */
  52918. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52919. }
  52920. }
  52921. declare module BABYLON {
  52922. /**
  52923. * Class containing static functions to help procedurally build meshes
  52924. */
  52925. export class HemisphereBuilder {
  52926. /**
  52927. * Creates a hemisphere mesh
  52928. * @param name defines the name of the mesh
  52929. * @param options defines the options used to create the mesh
  52930. * @param scene defines the hosting scene
  52931. * @returns the hemisphere mesh
  52932. */
  52933. static CreateHemisphere(name: string, options: {
  52934. segments?: number;
  52935. diameter?: number;
  52936. sideOrientation?: number;
  52937. }, scene: any): Mesh;
  52938. }
  52939. }
  52940. declare module BABYLON {
  52941. /**
  52942. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52943. * These values define a cone of light starting from the position, emitting toward the direction.
  52944. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52945. * and the exponent defines the speed of the decay of the light with distance (reach).
  52946. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52947. */
  52948. export class SpotLight extends ShadowLight {
  52949. private _angle;
  52950. private _innerAngle;
  52951. private _cosHalfAngle;
  52952. private _lightAngleScale;
  52953. private _lightAngleOffset;
  52954. /**
  52955. * Gets the cone angle of the spot light in Radians.
  52956. */
  52957. get angle(): number;
  52958. /**
  52959. * Sets the cone angle of the spot light in Radians.
  52960. */
  52961. set angle(value: number);
  52962. /**
  52963. * Only used in gltf falloff mode, this defines the angle where
  52964. * the directional falloff will start before cutting at angle which could be seen
  52965. * as outer angle.
  52966. */
  52967. get innerAngle(): number;
  52968. /**
  52969. * Only used in gltf falloff mode, this defines the angle where
  52970. * the directional falloff will start before cutting at angle which could be seen
  52971. * as outer angle.
  52972. */
  52973. set innerAngle(value: number);
  52974. private _shadowAngleScale;
  52975. /**
  52976. * Allows scaling the angle of the light for shadow generation only.
  52977. */
  52978. get shadowAngleScale(): number;
  52979. /**
  52980. * Allows scaling the angle of the light for shadow generation only.
  52981. */
  52982. set shadowAngleScale(value: number);
  52983. /**
  52984. * The light decay speed with the distance from the emission spot.
  52985. */
  52986. exponent: number;
  52987. private _projectionTextureMatrix;
  52988. /**
  52989. * Allows reading the projecton texture
  52990. */
  52991. get projectionTextureMatrix(): Matrix;
  52992. protected _projectionTextureLightNear: number;
  52993. /**
  52994. * Gets the near clip of the Spotlight for texture projection.
  52995. */
  52996. get projectionTextureLightNear(): number;
  52997. /**
  52998. * Sets the near clip of the Spotlight for texture projection.
  52999. */
  53000. set projectionTextureLightNear(value: number);
  53001. protected _projectionTextureLightFar: number;
  53002. /**
  53003. * Gets the far clip of the Spotlight for texture projection.
  53004. */
  53005. get projectionTextureLightFar(): number;
  53006. /**
  53007. * Sets the far clip of the Spotlight for texture projection.
  53008. */
  53009. set projectionTextureLightFar(value: number);
  53010. protected _projectionTextureUpDirection: Vector3;
  53011. /**
  53012. * Gets the Up vector of the Spotlight for texture projection.
  53013. */
  53014. get projectionTextureUpDirection(): Vector3;
  53015. /**
  53016. * Sets the Up vector of the Spotlight for texture projection.
  53017. */
  53018. set projectionTextureUpDirection(value: Vector3);
  53019. private _projectionTexture;
  53020. /**
  53021. * Gets the projection texture of the light.
  53022. */
  53023. get projectionTexture(): Nullable<BaseTexture>;
  53024. /**
  53025. * Sets the projection texture of the light.
  53026. */
  53027. set projectionTexture(value: Nullable<BaseTexture>);
  53028. private _projectionTextureViewLightDirty;
  53029. private _projectionTextureProjectionLightDirty;
  53030. private _projectionTextureDirty;
  53031. private _projectionTextureViewTargetVector;
  53032. private _projectionTextureViewLightMatrix;
  53033. private _projectionTextureProjectionLightMatrix;
  53034. private _projectionTextureScalingMatrix;
  53035. /**
  53036. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53037. * It can cast shadows.
  53038. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53039. * @param name The light friendly name
  53040. * @param position The position of the spot light in the scene
  53041. * @param direction The direction of the light in the scene
  53042. * @param angle The cone angle of the light in Radians
  53043. * @param exponent The light decay speed with the distance from the emission spot
  53044. * @param scene The scene the lights belongs to
  53045. */
  53046. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53047. /**
  53048. * Returns the string "SpotLight".
  53049. * @returns the class name
  53050. */
  53051. getClassName(): string;
  53052. /**
  53053. * Returns the integer 2.
  53054. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53055. */
  53056. getTypeID(): number;
  53057. /**
  53058. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53059. */
  53060. protected _setDirection(value: Vector3): void;
  53061. /**
  53062. * Overrides the position setter to recompute the projection texture view light Matrix.
  53063. */
  53064. protected _setPosition(value: Vector3): void;
  53065. /**
  53066. * 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.
  53067. * Returns the SpotLight.
  53068. */
  53069. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53070. protected _computeProjectionTextureViewLightMatrix(): void;
  53071. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53072. /**
  53073. * Main function for light texture projection matrix computing.
  53074. */
  53075. protected _computeProjectionTextureMatrix(): void;
  53076. protected _buildUniformLayout(): void;
  53077. private _computeAngleValues;
  53078. /**
  53079. * Sets the passed Effect "effect" with the Light textures.
  53080. * @param effect The effect to update
  53081. * @param lightIndex The index of the light in the effect to update
  53082. * @returns The light
  53083. */
  53084. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53085. /**
  53086. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53087. * @param effect The effect to update
  53088. * @param lightIndex The index of the light in the effect to update
  53089. * @returns The spot light
  53090. */
  53091. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53092. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53093. /**
  53094. * Disposes the light and the associated resources.
  53095. */
  53096. dispose(): void;
  53097. /**
  53098. * Prepares the list of defines specific to the light type.
  53099. * @param defines the list of defines
  53100. * @param lightIndex defines the index of the light for the effect
  53101. */
  53102. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53103. }
  53104. }
  53105. declare module BABYLON {
  53106. /**
  53107. * Gizmo that enables viewing a light
  53108. */
  53109. export class LightGizmo extends Gizmo {
  53110. private _lightMesh;
  53111. private _material;
  53112. private _cachedPosition;
  53113. private _cachedForward;
  53114. private _attachedMeshParent;
  53115. /**
  53116. * Creates a LightGizmo
  53117. * @param gizmoLayer The utility layer the gizmo will be added to
  53118. */
  53119. constructor(gizmoLayer?: UtilityLayerRenderer);
  53120. private _light;
  53121. /**
  53122. * The light that the gizmo is attached to
  53123. */
  53124. set light(light: Nullable<Light>);
  53125. get light(): Nullable<Light>;
  53126. /**
  53127. * Gets the material used to render the light gizmo
  53128. */
  53129. get material(): StandardMaterial;
  53130. /**
  53131. * @hidden
  53132. * Updates the gizmo to match the attached mesh's position/rotation
  53133. */
  53134. protected _update(): void;
  53135. private static _Scale;
  53136. /**
  53137. * Creates the lines for a light mesh
  53138. */
  53139. private static _CreateLightLines;
  53140. /**
  53141. * Disposes of the light gizmo
  53142. */
  53143. dispose(): void;
  53144. private static _CreateHemisphericLightMesh;
  53145. private static _CreatePointLightMesh;
  53146. private static _CreateSpotLightMesh;
  53147. private static _CreateDirectionalLightMesh;
  53148. }
  53149. }
  53150. declare module BABYLON {
  53151. /** @hidden */
  53152. export var backgroundFragmentDeclaration: {
  53153. name: string;
  53154. shader: string;
  53155. };
  53156. }
  53157. declare module BABYLON {
  53158. /** @hidden */
  53159. export var backgroundUboDeclaration: {
  53160. name: string;
  53161. shader: string;
  53162. };
  53163. }
  53164. declare module BABYLON {
  53165. /** @hidden */
  53166. export var backgroundPixelShader: {
  53167. name: string;
  53168. shader: string;
  53169. };
  53170. }
  53171. declare module BABYLON {
  53172. /** @hidden */
  53173. export var backgroundVertexDeclaration: {
  53174. name: string;
  53175. shader: string;
  53176. };
  53177. }
  53178. declare module BABYLON {
  53179. /** @hidden */
  53180. export var backgroundVertexShader: {
  53181. name: string;
  53182. shader: string;
  53183. };
  53184. }
  53185. declare module BABYLON {
  53186. /**
  53187. * Background material used to create an efficient environement around your scene.
  53188. */
  53189. export class BackgroundMaterial extends PushMaterial {
  53190. /**
  53191. * Standard reflectance value at parallel view angle.
  53192. */
  53193. static StandardReflectance0: number;
  53194. /**
  53195. * Standard reflectance value at grazing angle.
  53196. */
  53197. static StandardReflectance90: number;
  53198. protected _primaryColor: Color3;
  53199. /**
  53200. * Key light Color (multiply against the environement texture)
  53201. */
  53202. primaryColor: Color3;
  53203. protected __perceptualColor: Nullable<Color3>;
  53204. /**
  53205. * Experimental Internal Use Only.
  53206. *
  53207. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53208. * This acts as a helper to set the primary color to a more "human friendly" value.
  53209. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53210. * output color as close as possible from the chosen value.
  53211. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53212. * part of lighting setup.)
  53213. */
  53214. get _perceptualColor(): Nullable<Color3>;
  53215. set _perceptualColor(value: Nullable<Color3>);
  53216. protected _primaryColorShadowLevel: float;
  53217. /**
  53218. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53219. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53220. */
  53221. get primaryColorShadowLevel(): float;
  53222. set primaryColorShadowLevel(value: float);
  53223. protected _primaryColorHighlightLevel: float;
  53224. /**
  53225. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53226. * The primary color is used at the level chosen to define what the white area would look.
  53227. */
  53228. get primaryColorHighlightLevel(): float;
  53229. set primaryColorHighlightLevel(value: float);
  53230. protected _reflectionTexture: Nullable<BaseTexture>;
  53231. /**
  53232. * Reflection Texture used in the material.
  53233. * Should be author in a specific way for the best result (refer to the documentation).
  53234. */
  53235. reflectionTexture: Nullable<BaseTexture>;
  53236. protected _reflectionBlur: float;
  53237. /**
  53238. * Reflection Texture level of blur.
  53239. *
  53240. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53241. * texture twice.
  53242. */
  53243. reflectionBlur: float;
  53244. protected _diffuseTexture: Nullable<BaseTexture>;
  53245. /**
  53246. * Diffuse Texture used in the material.
  53247. * Should be author in a specific way for the best result (refer to the documentation).
  53248. */
  53249. diffuseTexture: Nullable<BaseTexture>;
  53250. protected _shadowLights: Nullable<IShadowLight[]>;
  53251. /**
  53252. * Specify the list of lights casting shadow on the material.
  53253. * All scene shadow lights will be included if null.
  53254. */
  53255. shadowLights: Nullable<IShadowLight[]>;
  53256. protected _shadowLevel: float;
  53257. /**
  53258. * Helps adjusting the shadow to a softer level if required.
  53259. * 0 means black shadows and 1 means no shadows.
  53260. */
  53261. shadowLevel: float;
  53262. protected _sceneCenter: Vector3;
  53263. /**
  53264. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53265. * It is usually zero but might be interesting to modify according to your setup.
  53266. */
  53267. sceneCenter: Vector3;
  53268. protected _opacityFresnel: boolean;
  53269. /**
  53270. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53271. * This helps ensuring a nice transition when the camera goes under the ground.
  53272. */
  53273. opacityFresnel: boolean;
  53274. protected _reflectionFresnel: boolean;
  53275. /**
  53276. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53277. * This helps adding a mirror texture on the ground.
  53278. */
  53279. reflectionFresnel: boolean;
  53280. protected _reflectionFalloffDistance: number;
  53281. /**
  53282. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53283. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53284. */
  53285. reflectionFalloffDistance: number;
  53286. protected _reflectionAmount: number;
  53287. /**
  53288. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53289. */
  53290. reflectionAmount: number;
  53291. protected _reflectionReflectance0: number;
  53292. /**
  53293. * This specifies the weight of the reflection at grazing angle.
  53294. */
  53295. reflectionReflectance0: number;
  53296. protected _reflectionReflectance90: number;
  53297. /**
  53298. * This specifies the weight of the reflection at a perpendicular point of view.
  53299. */
  53300. reflectionReflectance90: number;
  53301. /**
  53302. * Sets the reflection reflectance fresnel values according to the default standard
  53303. * empirically know to work well :-)
  53304. */
  53305. set reflectionStandardFresnelWeight(value: number);
  53306. protected _useRGBColor: boolean;
  53307. /**
  53308. * Helps to directly use the maps channels instead of their level.
  53309. */
  53310. useRGBColor: boolean;
  53311. protected _enableNoise: boolean;
  53312. /**
  53313. * This helps reducing the banding effect that could occur on the background.
  53314. */
  53315. enableNoise: boolean;
  53316. /**
  53317. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53318. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53319. * Recommended to be keep at 1.0 except for special cases.
  53320. */
  53321. get fovMultiplier(): number;
  53322. set fovMultiplier(value: number);
  53323. private _fovMultiplier;
  53324. /**
  53325. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53326. */
  53327. useEquirectangularFOV: boolean;
  53328. private _maxSimultaneousLights;
  53329. /**
  53330. * Number of Simultaneous lights allowed on the material.
  53331. */
  53332. maxSimultaneousLights: int;
  53333. private _shadowOnly;
  53334. /**
  53335. * Make the material only render shadows
  53336. */
  53337. shadowOnly: boolean;
  53338. /**
  53339. * Default configuration related to image processing available in the Background Material.
  53340. */
  53341. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53342. /**
  53343. * Keep track of the image processing observer to allow dispose and replace.
  53344. */
  53345. private _imageProcessingObserver;
  53346. /**
  53347. * Attaches a new image processing configuration to the PBR Material.
  53348. * @param configuration (if null the scene configuration will be use)
  53349. */
  53350. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53351. /**
  53352. * Gets the image processing configuration used either in this material.
  53353. */
  53354. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53355. /**
  53356. * Sets the Default image processing configuration used either in the this material.
  53357. *
  53358. * If sets to null, the scene one is in use.
  53359. */
  53360. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53361. /**
  53362. * Gets wether the color curves effect is enabled.
  53363. */
  53364. get cameraColorCurvesEnabled(): boolean;
  53365. /**
  53366. * Sets wether the color curves effect is enabled.
  53367. */
  53368. set cameraColorCurvesEnabled(value: boolean);
  53369. /**
  53370. * Gets wether the color grading effect is enabled.
  53371. */
  53372. get cameraColorGradingEnabled(): boolean;
  53373. /**
  53374. * Gets wether the color grading effect is enabled.
  53375. */
  53376. set cameraColorGradingEnabled(value: boolean);
  53377. /**
  53378. * Gets wether tonemapping is enabled or not.
  53379. */
  53380. get cameraToneMappingEnabled(): boolean;
  53381. /**
  53382. * Sets wether tonemapping is enabled or not
  53383. */
  53384. set cameraToneMappingEnabled(value: boolean);
  53385. /**
  53386. * The camera exposure used on this material.
  53387. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53388. * This corresponds to a photographic exposure.
  53389. */
  53390. get cameraExposure(): float;
  53391. /**
  53392. * The camera exposure used on this material.
  53393. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53394. * This corresponds to a photographic exposure.
  53395. */
  53396. set cameraExposure(value: float);
  53397. /**
  53398. * Gets The camera contrast used on this material.
  53399. */
  53400. get cameraContrast(): float;
  53401. /**
  53402. * Sets The camera contrast used on this material.
  53403. */
  53404. set cameraContrast(value: float);
  53405. /**
  53406. * Gets the Color Grading 2D Lookup Texture.
  53407. */
  53408. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53409. /**
  53410. * Sets the Color Grading 2D Lookup Texture.
  53411. */
  53412. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53413. /**
  53414. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53415. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53416. * 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;
  53417. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53418. */
  53419. get cameraColorCurves(): Nullable<ColorCurves>;
  53420. /**
  53421. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53422. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53423. * 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;
  53424. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53425. */
  53426. set cameraColorCurves(value: Nullable<ColorCurves>);
  53427. /**
  53428. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53429. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53430. */
  53431. switchToBGR: boolean;
  53432. private _renderTargets;
  53433. private _reflectionControls;
  53434. private _white;
  53435. private _primaryShadowColor;
  53436. private _primaryHighlightColor;
  53437. /**
  53438. * Instantiates a Background Material in the given scene
  53439. * @param name The friendly name of the material
  53440. * @param scene The scene to add the material to
  53441. */
  53442. constructor(name: string, scene: Scene);
  53443. /**
  53444. * Gets a boolean indicating that current material needs to register RTT
  53445. */
  53446. get hasRenderTargetTextures(): boolean;
  53447. /**
  53448. * The entire material has been created in order to prevent overdraw.
  53449. * @returns false
  53450. */
  53451. needAlphaTesting(): boolean;
  53452. /**
  53453. * The entire material has been created in order to prevent overdraw.
  53454. * @returns true if blending is enable
  53455. */
  53456. needAlphaBlending(): boolean;
  53457. /**
  53458. * Checks wether the material is ready to be rendered for a given mesh.
  53459. * @param mesh The mesh to render
  53460. * @param subMesh The submesh to check against
  53461. * @param useInstances Specify wether or not the material is used with instances
  53462. * @returns true if all the dependencies are ready (Textures, Effects...)
  53463. */
  53464. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53465. /**
  53466. * Compute the primary color according to the chosen perceptual color.
  53467. */
  53468. private _computePrimaryColorFromPerceptualColor;
  53469. /**
  53470. * Compute the highlights and shadow colors according to their chosen levels.
  53471. */
  53472. private _computePrimaryColors;
  53473. /**
  53474. * Build the uniform buffer used in the material.
  53475. */
  53476. buildUniformLayout(): void;
  53477. /**
  53478. * Unbind the material.
  53479. */
  53480. unbind(): void;
  53481. /**
  53482. * Bind only the world matrix to the material.
  53483. * @param world The world matrix to bind.
  53484. */
  53485. bindOnlyWorldMatrix(world: Matrix): void;
  53486. /**
  53487. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53488. * @param world The world matrix to bind.
  53489. * @param subMesh The submesh to bind for.
  53490. */
  53491. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53492. /**
  53493. * Checks to see if a texture is used in the material.
  53494. * @param texture - Base texture to use.
  53495. * @returns - Boolean specifying if a texture is used in the material.
  53496. */
  53497. hasTexture(texture: BaseTexture): boolean;
  53498. /**
  53499. * Dispose the material.
  53500. * @param forceDisposeEffect Force disposal of the associated effect.
  53501. * @param forceDisposeTextures Force disposal of the associated textures.
  53502. */
  53503. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53504. /**
  53505. * Clones the material.
  53506. * @param name The cloned name.
  53507. * @returns The cloned material.
  53508. */
  53509. clone(name: string): BackgroundMaterial;
  53510. /**
  53511. * Serializes the current material to its JSON representation.
  53512. * @returns The JSON representation.
  53513. */
  53514. serialize(): any;
  53515. /**
  53516. * Gets the class name of the material
  53517. * @returns "BackgroundMaterial"
  53518. */
  53519. getClassName(): string;
  53520. /**
  53521. * Parse a JSON input to create back a background material.
  53522. * @param source The JSON data to parse
  53523. * @param scene The scene to create the parsed material in
  53524. * @param rootUrl The root url of the assets the material depends upon
  53525. * @returns the instantiated BackgroundMaterial.
  53526. */
  53527. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53528. }
  53529. }
  53530. declare module BABYLON {
  53531. /**
  53532. * Represents the different options available during the creation of
  53533. * a Environment helper.
  53534. *
  53535. * This can control the default ground, skybox and image processing setup of your scene.
  53536. */
  53537. export interface IEnvironmentHelperOptions {
  53538. /**
  53539. * Specifies whether or not to create a ground.
  53540. * True by default.
  53541. */
  53542. createGround: boolean;
  53543. /**
  53544. * Specifies the ground size.
  53545. * 15 by default.
  53546. */
  53547. groundSize: number;
  53548. /**
  53549. * The texture used on the ground for the main color.
  53550. * Comes from the BabylonJS CDN by default.
  53551. *
  53552. * Remarks: Can be either a texture or a url.
  53553. */
  53554. groundTexture: string | BaseTexture;
  53555. /**
  53556. * The color mixed in the ground texture by default.
  53557. * BabylonJS clearColor by default.
  53558. */
  53559. groundColor: Color3;
  53560. /**
  53561. * Specifies the ground opacity.
  53562. * 1 by default.
  53563. */
  53564. groundOpacity: number;
  53565. /**
  53566. * Enables the ground to receive shadows.
  53567. * True by default.
  53568. */
  53569. enableGroundShadow: boolean;
  53570. /**
  53571. * Helps preventing the shadow to be fully black on the ground.
  53572. * 0.5 by default.
  53573. */
  53574. groundShadowLevel: number;
  53575. /**
  53576. * Creates a mirror texture attach to the ground.
  53577. * false by default.
  53578. */
  53579. enableGroundMirror: boolean;
  53580. /**
  53581. * Specifies the ground mirror size ratio.
  53582. * 0.3 by default as the default kernel is 64.
  53583. */
  53584. groundMirrorSizeRatio: number;
  53585. /**
  53586. * Specifies the ground mirror blur kernel size.
  53587. * 64 by default.
  53588. */
  53589. groundMirrorBlurKernel: number;
  53590. /**
  53591. * Specifies the ground mirror visibility amount.
  53592. * 1 by default
  53593. */
  53594. groundMirrorAmount: number;
  53595. /**
  53596. * Specifies the ground mirror reflectance weight.
  53597. * This uses the standard weight of the background material to setup the fresnel effect
  53598. * of the mirror.
  53599. * 1 by default.
  53600. */
  53601. groundMirrorFresnelWeight: number;
  53602. /**
  53603. * Specifies the ground mirror Falloff distance.
  53604. * This can helps reducing the size of the reflection.
  53605. * 0 by Default.
  53606. */
  53607. groundMirrorFallOffDistance: number;
  53608. /**
  53609. * Specifies the ground mirror texture type.
  53610. * Unsigned Int by Default.
  53611. */
  53612. groundMirrorTextureType: number;
  53613. /**
  53614. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53615. * the shown objects.
  53616. */
  53617. groundYBias: number;
  53618. /**
  53619. * Specifies whether or not to create a skybox.
  53620. * True by default.
  53621. */
  53622. createSkybox: boolean;
  53623. /**
  53624. * Specifies the skybox size.
  53625. * 20 by default.
  53626. */
  53627. skyboxSize: number;
  53628. /**
  53629. * The texture used on the skybox for the main color.
  53630. * Comes from the BabylonJS CDN by default.
  53631. *
  53632. * Remarks: Can be either a texture or a url.
  53633. */
  53634. skyboxTexture: string | BaseTexture;
  53635. /**
  53636. * The color mixed in the skybox texture by default.
  53637. * BabylonJS clearColor by default.
  53638. */
  53639. skyboxColor: Color3;
  53640. /**
  53641. * The background rotation around the Y axis of the scene.
  53642. * This helps aligning the key lights of your scene with the background.
  53643. * 0 by default.
  53644. */
  53645. backgroundYRotation: number;
  53646. /**
  53647. * Compute automatically the size of the elements to best fit with the scene.
  53648. */
  53649. sizeAuto: boolean;
  53650. /**
  53651. * Default position of the rootMesh if autoSize is not true.
  53652. */
  53653. rootPosition: Vector3;
  53654. /**
  53655. * Sets up the image processing in the scene.
  53656. * true by default.
  53657. */
  53658. setupImageProcessing: boolean;
  53659. /**
  53660. * The texture used as your environment texture in the scene.
  53661. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53662. *
  53663. * Remarks: Can be either a texture or a url.
  53664. */
  53665. environmentTexture: string | BaseTexture;
  53666. /**
  53667. * The value of the exposure to apply to the scene.
  53668. * 0.6 by default if setupImageProcessing is true.
  53669. */
  53670. cameraExposure: number;
  53671. /**
  53672. * The value of the contrast to apply to the scene.
  53673. * 1.6 by default if setupImageProcessing is true.
  53674. */
  53675. cameraContrast: number;
  53676. /**
  53677. * Specifies whether or not tonemapping should be enabled in the scene.
  53678. * true by default if setupImageProcessing is true.
  53679. */
  53680. toneMappingEnabled: boolean;
  53681. }
  53682. /**
  53683. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53684. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53685. * It also helps with the default setup of your imageProcessing configuration.
  53686. */
  53687. export class EnvironmentHelper {
  53688. /**
  53689. * Default ground texture URL.
  53690. */
  53691. private static _groundTextureCDNUrl;
  53692. /**
  53693. * Default skybox texture URL.
  53694. */
  53695. private static _skyboxTextureCDNUrl;
  53696. /**
  53697. * Default environment texture URL.
  53698. */
  53699. private static _environmentTextureCDNUrl;
  53700. /**
  53701. * Creates the default options for the helper.
  53702. */
  53703. private static _getDefaultOptions;
  53704. private _rootMesh;
  53705. /**
  53706. * Gets the root mesh created by the helper.
  53707. */
  53708. get rootMesh(): Mesh;
  53709. private _skybox;
  53710. /**
  53711. * Gets the skybox created by the helper.
  53712. */
  53713. get skybox(): Nullable<Mesh>;
  53714. private _skyboxTexture;
  53715. /**
  53716. * Gets the skybox texture created by the helper.
  53717. */
  53718. get skyboxTexture(): Nullable<BaseTexture>;
  53719. private _skyboxMaterial;
  53720. /**
  53721. * Gets the skybox material created by the helper.
  53722. */
  53723. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53724. private _ground;
  53725. /**
  53726. * Gets the ground mesh created by the helper.
  53727. */
  53728. get ground(): Nullable<Mesh>;
  53729. private _groundTexture;
  53730. /**
  53731. * Gets the ground texture created by the helper.
  53732. */
  53733. get groundTexture(): Nullable<BaseTexture>;
  53734. private _groundMirror;
  53735. /**
  53736. * Gets the ground mirror created by the helper.
  53737. */
  53738. get groundMirror(): Nullable<MirrorTexture>;
  53739. /**
  53740. * Gets the ground mirror render list to helps pushing the meshes
  53741. * you wish in the ground reflection.
  53742. */
  53743. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53744. private _groundMaterial;
  53745. /**
  53746. * Gets the ground material created by the helper.
  53747. */
  53748. get groundMaterial(): Nullable<BackgroundMaterial>;
  53749. /**
  53750. * Stores the creation options.
  53751. */
  53752. private readonly _scene;
  53753. private _options;
  53754. /**
  53755. * This observable will be notified with any error during the creation of the environment,
  53756. * mainly texture creation errors.
  53757. */
  53758. onErrorObservable: Observable<{
  53759. message?: string;
  53760. exception?: any;
  53761. }>;
  53762. /**
  53763. * constructor
  53764. * @param options Defines the options we want to customize the helper
  53765. * @param scene The scene to add the material to
  53766. */
  53767. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53768. /**
  53769. * Updates the background according to the new options
  53770. * @param options
  53771. */
  53772. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53773. /**
  53774. * Sets the primary color of all the available elements.
  53775. * @param color the main color to affect to the ground and the background
  53776. */
  53777. setMainColor(color: Color3): void;
  53778. /**
  53779. * Setup the image processing according to the specified options.
  53780. */
  53781. private _setupImageProcessing;
  53782. /**
  53783. * Setup the environment texture according to the specified options.
  53784. */
  53785. private _setupEnvironmentTexture;
  53786. /**
  53787. * Setup the background according to the specified options.
  53788. */
  53789. private _setupBackground;
  53790. /**
  53791. * Get the scene sizes according to the setup.
  53792. */
  53793. private _getSceneSize;
  53794. /**
  53795. * Setup the ground according to the specified options.
  53796. */
  53797. private _setupGround;
  53798. /**
  53799. * Setup the ground material according to the specified options.
  53800. */
  53801. private _setupGroundMaterial;
  53802. /**
  53803. * Setup the ground diffuse texture according to the specified options.
  53804. */
  53805. private _setupGroundDiffuseTexture;
  53806. /**
  53807. * Setup the ground mirror texture according to the specified options.
  53808. */
  53809. private _setupGroundMirrorTexture;
  53810. /**
  53811. * Setup the ground to receive the mirror texture.
  53812. */
  53813. private _setupMirrorInGroundMaterial;
  53814. /**
  53815. * Setup the skybox according to the specified options.
  53816. */
  53817. private _setupSkybox;
  53818. /**
  53819. * Setup the skybox material according to the specified options.
  53820. */
  53821. private _setupSkyboxMaterial;
  53822. /**
  53823. * Setup the skybox reflection texture according to the specified options.
  53824. */
  53825. private _setupSkyboxReflectionTexture;
  53826. private _errorHandler;
  53827. /**
  53828. * Dispose all the elements created by the Helper.
  53829. */
  53830. dispose(): void;
  53831. }
  53832. }
  53833. declare module BABYLON {
  53834. /**
  53835. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53836. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53837. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53838. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53839. */
  53840. export class PhotoDome extends TransformNode {
  53841. /**
  53842. * Define the image as a Monoscopic panoramic 360 image.
  53843. */
  53844. static readonly MODE_MONOSCOPIC: number;
  53845. /**
  53846. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53847. */
  53848. static readonly MODE_TOPBOTTOM: number;
  53849. /**
  53850. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53851. */
  53852. static readonly MODE_SIDEBYSIDE: number;
  53853. private _useDirectMapping;
  53854. /**
  53855. * The texture being displayed on the sphere
  53856. */
  53857. protected _photoTexture: Texture;
  53858. /**
  53859. * Gets or sets the texture being displayed on the sphere
  53860. */
  53861. get photoTexture(): Texture;
  53862. set photoTexture(value: Texture);
  53863. /**
  53864. * Observable raised when an error occured while loading the 360 image
  53865. */
  53866. onLoadErrorObservable: Observable<string>;
  53867. /**
  53868. * The skybox material
  53869. */
  53870. protected _material: BackgroundMaterial;
  53871. /**
  53872. * The surface used for the skybox
  53873. */
  53874. protected _mesh: Mesh;
  53875. /**
  53876. * Gets the mesh used for the skybox.
  53877. */
  53878. get mesh(): Mesh;
  53879. /**
  53880. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53881. * Also see the options.resolution property.
  53882. */
  53883. get fovMultiplier(): number;
  53884. set fovMultiplier(value: number);
  53885. private _imageMode;
  53886. /**
  53887. * Gets or set the current video mode for the video. It can be:
  53888. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53889. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53890. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53891. */
  53892. get imageMode(): number;
  53893. set imageMode(value: number);
  53894. /**
  53895. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53896. * @param name Element's name, child elements will append suffixes for their own names.
  53897. * @param urlsOfPhoto defines the url of the photo to display
  53898. * @param options defines an object containing optional or exposed sub element properties
  53899. * @param onError defines a callback called when an error occured while loading the texture
  53900. */
  53901. constructor(name: string, urlOfPhoto: string, options: {
  53902. resolution?: number;
  53903. size?: number;
  53904. useDirectMapping?: boolean;
  53905. faceForward?: boolean;
  53906. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53907. private _onBeforeCameraRenderObserver;
  53908. private _changeImageMode;
  53909. /**
  53910. * Releases resources associated with this node.
  53911. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53912. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53913. */
  53914. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53915. }
  53916. }
  53917. declare module BABYLON {
  53918. /**
  53919. * Class used to host RGBD texture specific utilities
  53920. */
  53921. export class RGBDTextureTools {
  53922. /**
  53923. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53924. * @param texture the texture to expand.
  53925. */
  53926. static ExpandRGBDTexture(texture: Texture): void;
  53927. }
  53928. }
  53929. declare module BABYLON {
  53930. /**
  53931. * Class used to host texture specific utilities
  53932. */
  53933. export class BRDFTextureTools {
  53934. /**
  53935. * Prevents texture cache collision
  53936. */
  53937. private static _instanceNumber;
  53938. /**
  53939. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53940. * @param scene defines the hosting scene
  53941. * @returns the environment BRDF texture
  53942. */
  53943. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53944. private static _environmentBRDFBase64Texture;
  53945. }
  53946. }
  53947. declare module BABYLON {
  53948. /**
  53949. * @hidden
  53950. */
  53951. export interface IMaterialClearCoatDefines {
  53952. CLEARCOAT: boolean;
  53953. CLEARCOAT_DEFAULTIOR: boolean;
  53954. CLEARCOAT_TEXTURE: boolean;
  53955. CLEARCOAT_TEXTUREDIRECTUV: number;
  53956. CLEARCOAT_BUMP: boolean;
  53957. CLEARCOAT_BUMPDIRECTUV: number;
  53958. CLEARCOAT_TINT: boolean;
  53959. CLEARCOAT_TINT_TEXTURE: boolean;
  53960. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53961. /** @hidden */
  53962. _areTexturesDirty: boolean;
  53963. }
  53964. /**
  53965. * Define the code related to the clear coat parameters of the pbr material.
  53966. */
  53967. export class PBRClearCoatConfiguration {
  53968. /**
  53969. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53970. * The default fits with a polyurethane material.
  53971. */
  53972. private static readonly _DefaultIndexOfRefraction;
  53973. private _isEnabled;
  53974. /**
  53975. * Defines if the clear coat is enabled in the material.
  53976. */
  53977. isEnabled: boolean;
  53978. /**
  53979. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53980. */
  53981. intensity: number;
  53982. /**
  53983. * Defines the clear coat layer roughness.
  53984. */
  53985. roughness: number;
  53986. private _indexOfRefraction;
  53987. /**
  53988. * Defines the index of refraction of the clear coat.
  53989. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53990. * The default fits with a polyurethane material.
  53991. * Changing the default value is more performance intensive.
  53992. */
  53993. indexOfRefraction: number;
  53994. private _texture;
  53995. /**
  53996. * Stores the clear coat values in a texture.
  53997. */
  53998. texture: Nullable<BaseTexture>;
  53999. private _bumpTexture;
  54000. /**
  54001. * Define the clear coat specific bump texture.
  54002. */
  54003. bumpTexture: Nullable<BaseTexture>;
  54004. private _isTintEnabled;
  54005. /**
  54006. * Defines if the clear coat tint is enabled in the material.
  54007. */
  54008. isTintEnabled: boolean;
  54009. /**
  54010. * Defines the clear coat tint of the material.
  54011. * This is only use if tint is enabled
  54012. */
  54013. tintColor: Color3;
  54014. /**
  54015. * Defines the distance at which the tint color should be found in the
  54016. * clear coat media.
  54017. * This is only use if tint is enabled
  54018. */
  54019. tintColorAtDistance: number;
  54020. /**
  54021. * Defines the clear coat layer thickness.
  54022. * This is only use if tint is enabled
  54023. */
  54024. tintThickness: number;
  54025. private _tintTexture;
  54026. /**
  54027. * Stores the clear tint values in a texture.
  54028. * rgb is tint
  54029. * a is a thickness factor
  54030. */
  54031. tintTexture: Nullable<BaseTexture>;
  54032. /** @hidden */
  54033. private _internalMarkAllSubMeshesAsTexturesDirty;
  54034. /** @hidden */
  54035. _markAllSubMeshesAsTexturesDirty(): void;
  54036. /**
  54037. * Instantiate a new istance of clear coat configuration.
  54038. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54039. */
  54040. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54041. /**
  54042. * Gets wehter the submesh is ready to be used or not.
  54043. * @param defines the list of "defines" to update.
  54044. * @param scene defines the scene the material belongs to.
  54045. * @param engine defines the engine the material belongs to.
  54046. * @param disableBumpMap defines wether the material disables bump or not.
  54047. * @returns - boolean indicating that the submesh is ready or not.
  54048. */
  54049. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54050. /**
  54051. * Checks to see if a texture is used in the material.
  54052. * @param defines the list of "defines" to update.
  54053. * @param scene defines the scene to the material belongs to.
  54054. */
  54055. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  54056. /**
  54057. * Binds the material data.
  54058. * @param uniformBuffer defines the Uniform buffer to fill in.
  54059. * @param scene defines the scene the material belongs to.
  54060. * @param engine defines the engine the material belongs to.
  54061. * @param disableBumpMap defines wether the material disables bump or not.
  54062. * @param isFrozen defines wether the material is frozen or not.
  54063. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54064. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54065. */
  54066. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  54067. /**
  54068. * Checks to see if a texture is used in the material.
  54069. * @param texture - Base texture to use.
  54070. * @returns - Boolean specifying if a texture is used in the material.
  54071. */
  54072. hasTexture(texture: BaseTexture): boolean;
  54073. /**
  54074. * Returns an array of the actively used textures.
  54075. * @param activeTextures Array of BaseTextures
  54076. */
  54077. getActiveTextures(activeTextures: BaseTexture[]): void;
  54078. /**
  54079. * Returns the animatable textures.
  54080. * @param animatables Array of animatable textures.
  54081. */
  54082. getAnimatables(animatables: IAnimatable[]): void;
  54083. /**
  54084. * Disposes the resources of the material.
  54085. * @param forceDisposeTextures - Forces the disposal of all textures.
  54086. */
  54087. dispose(forceDisposeTextures?: boolean): void;
  54088. /**
  54089. * Get the current class name of the texture useful for serialization or dynamic coding.
  54090. * @returns "PBRClearCoatConfiguration"
  54091. */
  54092. getClassName(): string;
  54093. /**
  54094. * Add fallbacks to the effect fallbacks list.
  54095. * @param defines defines the Base texture to use.
  54096. * @param fallbacks defines the current fallback list.
  54097. * @param currentRank defines the current fallback rank.
  54098. * @returns the new fallback rank.
  54099. */
  54100. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54101. /**
  54102. * Add the required uniforms to the current list.
  54103. * @param uniforms defines the current uniform list.
  54104. */
  54105. static AddUniforms(uniforms: string[]): void;
  54106. /**
  54107. * Add the required samplers to the current list.
  54108. * @param samplers defines the current sampler list.
  54109. */
  54110. static AddSamplers(samplers: string[]): void;
  54111. /**
  54112. * Add the required uniforms to the current buffer.
  54113. * @param uniformBuffer defines the current uniform buffer.
  54114. */
  54115. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54116. /**
  54117. * Makes a duplicate of the current configuration into another one.
  54118. * @param clearCoatConfiguration define the config where to copy the info
  54119. */
  54120. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54121. /**
  54122. * Serializes this clear coat configuration.
  54123. * @returns - An object with the serialized config.
  54124. */
  54125. serialize(): any;
  54126. /**
  54127. * Parses a anisotropy Configuration from a serialized object.
  54128. * @param source - Serialized object.
  54129. * @param scene Defines the scene we are parsing for
  54130. * @param rootUrl Defines the rootUrl to load from
  54131. */
  54132. parse(source: any, scene: Scene, rootUrl: string): void;
  54133. }
  54134. }
  54135. declare module BABYLON {
  54136. /**
  54137. * @hidden
  54138. */
  54139. export interface IMaterialAnisotropicDefines {
  54140. ANISOTROPIC: boolean;
  54141. ANISOTROPIC_TEXTURE: boolean;
  54142. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54143. MAINUV1: boolean;
  54144. _areTexturesDirty: boolean;
  54145. _needUVs: boolean;
  54146. }
  54147. /**
  54148. * Define the code related to the anisotropic parameters of the pbr material.
  54149. */
  54150. export class PBRAnisotropicConfiguration {
  54151. private _isEnabled;
  54152. /**
  54153. * Defines if the anisotropy is enabled in the material.
  54154. */
  54155. isEnabled: boolean;
  54156. /**
  54157. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54158. */
  54159. intensity: number;
  54160. /**
  54161. * Defines if the effect is along the tangents, bitangents or in between.
  54162. * By default, the effect is "strectching" the highlights along the tangents.
  54163. */
  54164. direction: Vector2;
  54165. private _texture;
  54166. /**
  54167. * Stores the anisotropy values in a texture.
  54168. * rg is direction (like normal from -1 to 1)
  54169. * b is a intensity
  54170. */
  54171. texture: Nullable<BaseTexture>;
  54172. /** @hidden */
  54173. private _internalMarkAllSubMeshesAsTexturesDirty;
  54174. /** @hidden */
  54175. _markAllSubMeshesAsTexturesDirty(): void;
  54176. /**
  54177. * Instantiate a new istance of anisotropy configuration.
  54178. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54179. */
  54180. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54181. /**
  54182. * Specifies that the submesh is ready to be used.
  54183. * @param defines the list of "defines" to update.
  54184. * @param scene defines the scene the material belongs to.
  54185. * @returns - boolean indicating that the submesh is ready or not.
  54186. */
  54187. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54188. /**
  54189. * Checks to see if a texture is used in the material.
  54190. * @param defines the list of "defines" to update.
  54191. * @param mesh the mesh we are preparing the defines for.
  54192. * @param scene defines the scene the material belongs to.
  54193. */
  54194. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54195. /**
  54196. * Binds the material data.
  54197. * @param uniformBuffer defines the Uniform buffer to fill in.
  54198. * @param scene defines the scene the material belongs to.
  54199. * @param isFrozen defines wether the material is frozen or not.
  54200. */
  54201. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54202. /**
  54203. * Checks to see if a texture is used in the material.
  54204. * @param texture - Base texture to use.
  54205. * @returns - Boolean specifying if a texture is used in the material.
  54206. */
  54207. hasTexture(texture: BaseTexture): boolean;
  54208. /**
  54209. * Returns an array of the actively used textures.
  54210. * @param activeTextures Array of BaseTextures
  54211. */
  54212. getActiveTextures(activeTextures: BaseTexture[]): void;
  54213. /**
  54214. * Returns the animatable textures.
  54215. * @param animatables Array of animatable textures.
  54216. */
  54217. getAnimatables(animatables: IAnimatable[]): void;
  54218. /**
  54219. * Disposes the resources of the material.
  54220. * @param forceDisposeTextures - Forces the disposal of all textures.
  54221. */
  54222. dispose(forceDisposeTextures?: boolean): void;
  54223. /**
  54224. * Get the current class name of the texture useful for serialization or dynamic coding.
  54225. * @returns "PBRAnisotropicConfiguration"
  54226. */
  54227. getClassName(): string;
  54228. /**
  54229. * Add fallbacks to the effect fallbacks list.
  54230. * @param defines defines the Base texture to use.
  54231. * @param fallbacks defines the current fallback list.
  54232. * @param currentRank defines the current fallback rank.
  54233. * @returns the new fallback rank.
  54234. */
  54235. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54236. /**
  54237. * Add the required uniforms to the current list.
  54238. * @param uniforms defines the current uniform list.
  54239. */
  54240. static AddUniforms(uniforms: string[]): void;
  54241. /**
  54242. * Add the required uniforms to the current buffer.
  54243. * @param uniformBuffer defines the current uniform buffer.
  54244. */
  54245. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54246. /**
  54247. * Add the required samplers to the current list.
  54248. * @param samplers defines the current sampler list.
  54249. */
  54250. static AddSamplers(samplers: string[]): void;
  54251. /**
  54252. * Makes a duplicate of the current configuration into another one.
  54253. * @param anisotropicConfiguration define the config where to copy the info
  54254. */
  54255. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54256. /**
  54257. * Serializes this anisotropy configuration.
  54258. * @returns - An object with the serialized config.
  54259. */
  54260. serialize(): any;
  54261. /**
  54262. * Parses a anisotropy Configuration from a serialized object.
  54263. * @param source - Serialized object.
  54264. * @param scene Defines the scene we are parsing for
  54265. * @param rootUrl Defines the rootUrl to load from
  54266. */
  54267. parse(source: any, scene: Scene, rootUrl: string): void;
  54268. }
  54269. }
  54270. declare module BABYLON {
  54271. /**
  54272. * @hidden
  54273. */
  54274. export interface IMaterialBRDFDefines {
  54275. BRDF_V_HEIGHT_CORRELATED: boolean;
  54276. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54277. SPHERICAL_HARMONICS: boolean;
  54278. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54279. /** @hidden */
  54280. _areMiscDirty: boolean;
  54281. }
  54282. /**
  54283. * Define the code related to the BRDF parameters of the pbr material.
  54284. */
  54285. export class PBRBRDFConfiguration {
  54286. /**
  54287. * Default value used for the energy conservation.
  54288. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54289. */
  54290. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54291. /**
  54292. * Default value used for the Smith Visibility Height Correlated mode.
  54293. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54294. */
  54295. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54296. /**
  54297. * Default value used for the IBL diffuse part.
  54298. * This can help switching back to the polynomials mode globally which is a tiny bit
  54299. * less GPU intensive at the drawback of a lower quality.
  54300. */
  54301. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54302. /**
  54303. * Default value used for activating energy conservation for the specular workflow.
  54304. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54305. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54306. */
  54307. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54308. private _useEnergyConservation;
  54309. /**
  54310. * Defines if the material uses energy conservation.
  54311. */
  54312. useEnergyConservation: boolean;
  54313. private _useSmithVisibilityHeightCorrelated;
  54314. /**
  54315. * LEGACY Mode set to false
  54316. * Defines if the material uses height smith correlated visibility term.
  54317. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54318. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54319. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54320. * Not relying on height correlated will also disable energy conservation.
  54321. */
  54322. useSmithVisibilityHeightCorrelated: boolean;
  54323. private _useSphericalHarmonics;
  54324. /**
  54325. * LEGACY Mode set to false
  54326. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54327. * diffuse part of the IBL.
  54328. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54329. * to the ground truth.
  54330. */
  54331. useSphericalHarmonics: boolean;
  54332. private _useSpecularGlossinessInputEnergyConservation;
  54333. /**
  54334. * Defines if the material uses energy conservation, when the specular workflow is active.
  54335. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54336. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54337. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54338. */
  54339. useSpecularGlossinessInputEnergyConservation: boolean;
  54340. /** @hidden */
  54341. private _internalMarkAllSubMeshesAsMiscDirty;
  54342. /** @hidden */
  54343. _markAllSubMeshesAsMiscDirty(): void;
  54344. /**
  54345. * Instantiate a new istance of clear coat configuration.
  54346. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54347. */
  54348. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54349. /**
  54350. * Checks to see if a texture is used in the material.
  54351. * @param defines the list of "defines" to update.
  54352. */
  54353. prepareDefines(defines: IMaterialBRDFDefines): void;
  54354. /**
  54355. * Get the current class name of the texture useful for serialization or dynamic coding.
  54356. * @returns "PBRClearCoatConfiguration"
  54357. */
  54358. getClassName(): string;
  54359. /**
  54360. * Makes a duplicate of the current configuration into another one.
  54361. * @param brdfConfiguration define the config where to copy the info
  54362. */
  54363. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54364. /**
  54365. * Serializes this BRDF configuration.
  54366. * @returns - An object with the serialized config.
  54367. */
  54368. serialize(): any;
  54369. /**
  54370. * Parses a anisotropy Configuration from a serialized object.
  54371. * @param source - Serialized object.
  54372. * @param scene Defines the scene we are parsing for
  54373. * @param rootUrl Defines the rootUrl to load from
  54374. */
  54375. parse(source: any, scene: Scene, rootUrl: string): void;
  54376. }
  54377. }
  54378. declare module BABYLON {
  54379. /**
  54380. * @hidden
  54381. */
  54382. export interface IMaterialSheenDefines {
  54383. SHEEN: boolean;
  54384. SHEEN_TEXTURE: boolean;
  54385. SHEEN_TEXTUREDIRECTUV: number;
  54386. SHEEN_LINKWITHALBEDO: boolean;
  54387. SHEEN_ROUGHNESS: boolean;
  54388. SHEEN_ALBEDOSCALING: boolean;
  54389. /** @hidden */
  54390. _areTexturesDirty: boolean;
  54391. }
  54392. /**
  54393. * Define the code related to the Sheen parameters of the pbr material.
  54394. */
  54395. export class PBRSheenConfiguration {
  54396. private _isEnabled;
  54397. /**
  54398. * Defines if the material uses sheen.
  54399. */
  54400. isEnabled: boolean;
  54401. private _linkSheenWithAlbedo;
  54402. /**
  54403. * Defines if the sheen is linked to the sheen color.
  54404. */
  54405. linkSheenWithAlbedo: boolean;
  54406. /**
  54407. * Defines the sheen intensity.
  54408. */
  54409. intensity: number;
  54410. /**
  54411. * Defines the sheen color.
  54412. */
  54413. color: Color3;
  54414. private _texture;
  54415. /**
  54416. * Stores the sheen tint values in a texture.
  54417. * rgb is tint
  54418. * a is a intensity
  54419. */
  54420. texture: Nullable<BaseTexture>;
  54421. private _roughness;
  54422. /**
  54423. * Defines the sheen roughness.
  54424. * It is not taken into account if linkSheenWithAlbedo is true.
  54425. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54426. */
  54427. roughness: Nullable<number>;
  54428. private _albedoScaling;
  54429. /**
  54430. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54431. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54432. * making it easier to setup and tweak the effect
  54433. */
  54434. albedoScaling: boolean;
  54435. /** @hidden */
  54436. private _internalMarkAllSubMeshesAsTexturesDirty;
  54437. /** @hidden */
  54438. _markAllSubMeshesAsTexturesDirty(): void;
  54439. /**
  54440. * Instantiate a new istance of clear coat configuration.
  54441. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54442. */
  54443. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54444. /**
  54445. * Specifies that the submesh is ready to be used.
  54446. * @param defines the list of "defines" to update.
  54447. * @param scene defines the scene the material belongs to.
  54448. * @returns - boolean indicating that the submesh is ready or not.
  54449. */
  54450. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54451. /**
  54452. * Checks to see if a texture is used in the material.
  54453. * @param defines the list of "defines" to update.
  54454. * @param scene defines the scene the material belongs to.
  54455. */
  54456. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54457. /**
  54458. * Binds the material data.
  54459. * @param uniformBuffer defines the Uniform buffer to fill in.
  54460. * @param scene defines the scene the material belongs to.
  54461. * @param isFrozen defines wether the material is frozen or not.
  54462. */
  54463. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54464. /**
  54465. * Checks to see if a texture is used in the material.
  54466. * @param texture - Base texture to use.
  54467. * @returns - Boolean specifying if a texture is used in the material.
  54468. */
  54469. hasTexture(texture: BaseTexture): boolean;
  54470. /**
  54471. * Returns an array of the actively used textures.
  54472. * @param activeTextures Array of BaseTextures
  54473. */
  54474. getActiveTextures(activeTextures: BaseTexture[]): void;
  54475. /**
  54476. * Returns the animatable textures.
  54477. * @param animatables Array of animatable textures.
  54478. */
  54479. getAnimatables(animatables: IAnimatable[]): void;
  54480. /**
  54481. * Disposes the resources of the material.
  54482. * @param forceDisposeTextures - Forces the disposal of all textures.
  54483. */
  54484. dispose(forceDisposeTextures?: boolean): void;
  54485. /**
  54486. * Get the current class name of the texture useful for serialization or dynamic coding.
  54487. * @returns "PBRSheenConfiguration"
  54488. */
  54489. getClassName(): string;
  54490. /**
  54491. * Add fallbacks to the effect fallbacks list.
  54492. * @param defines defines the Base texture to use.
  54493. * @param fallbacks defines the current fallback list.
  54494. * @param currentRank defines the current fallback rank.
  54495. * @returns the new fallback rank.
  54496. */
  54497. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54498. /**
  54499. * Add the required uniforms to the current list.
  54500. * @param uniforms defines the current uniform list.
  54501. */
  54502. static AddUniforms(uniforms: string[]): void;
  54503. /**
  54504. * Add the required uniforms to the current buffer.
  54505. * @param uniformBuffer defines the current uniform buffer.
  54506. */
  54507. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54508. /**
  54509. * Add the required samplers to the current list.
  54510. * @param samplers defines the current sampler list.
  54511. */
  54512. static AddSamplers(samplers: string[]): void;
  54513. /**
  54514. * Makes a duplicate of the current configuration into another one.
  54515. * @param sheenConfiguration define the config where to copy the info
  54516. */
  54517. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54518. /**
  54519. * Serializes this BRDF configuration.
  54520. * @returns - An object with the serialized config.
  54521. */
  54522. serialize(): any;
  54523. /**
  54524. * Parses a anisotropy Configuration from a serialized object.
  54525. * @param source - Serialized object.
  54526. * @param scene Defines the scene we are parsing for
  54527. * @param rootUrl Defines the rootUrl to load from
  54528. */
  54529. parse(source: any, scene: Scene, rootUrl: string): void;
  54530. }
  54531. }
  54532. declare module BABYLON {
  54533. /**
  54534. * @hidden
  54535. */
  54536. export interface IMaterialSubSurfaceDefines {
  54537. SUBSURFACE: boolean;
  54538. SS_REFRACTION: boolean;
  54539. SS_TRANSLUCENCY: boolean;
  54540. SS_SCATTERING: boolean;
  54541. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54542. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54543. SS_REFRACTIONMAP_3D: boolean;
  54544. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54545. SS_LODINREFRACTIONALPHA: boolean;
  54546. SS_GAMMAREFRACTION: boolean;
  54547. SS_RGBDREFRACTION: boolean;
  54548. SS_LINEARSPECULARREFRACTION: boolean;
  54549. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54550. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54551. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54552. /** @hidden */
  54553. _areTexturesDirty: boolean;
  54554. }
  54555. /**
  54556. * Define the code related to the sub surface parameters of the pbr material.
  54557. */
  54558. export class PBRSubSurfaceConfiguration {
  54559. private _isRefractionEnabled;
  54560. /**
  54561. * Defines if the refraction is enabled in the material.
  54562. */
  54563. isRefractionEnabled: boolean;
  54564. private _isTranslucencyEnabled;
  54565. /**
  54566. * Defines if the translucency is enabled in the material.
  54567. */
  54568. isTranslucencyEnabled: boolean;
  54569. private _isScatteringEnabled;
  54570. /**
  54571. * Defines the refraction intensity of the material.
  54572. * The refraction when enabled replaces the Diffuse part of the material.
  54573. * The intensity helps transitionning between diffuse and refraction.
  54574. */
  54575. refractionIntensity: number;
  54576. /**
  54577. * Defines the translucency intensity of the material.
  54578. * When translucency has been enabled, this defines how much of the "translucency"
  54579. * is addded to the diffuse part of the material.
  54580. */
  54581. translucencyIntensity: number;
  54582. /**
  54583. * Defines the scattering intensity of the material.
  54584. * When scattering has been enabled, this defines how much of the "scattered light"
  54585. * is addded to the diffuse part of the material.
  54586. */
  54587. scatteringIntensity: number;
  54588. /**
  54589. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54590. */
  54591. useAlbedoToTintRefraction: boolean;
  54592. private _thicknessTexture;
  54593. /**
  54594. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54595. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54596. * 0 would mean minimumThickness
  54597. * 1 would mean maximumThickness
  54598. * The other channels might be use as a mask to vary the different effects intensity.
  54599. */
  54600. thicknessTexture: Nullable<BaseTexture>;
  54601. private _refractionTexture;
  54602. /**
  54603. * Defines the texture to use for refraction.
  54604. */
  54605. refractionTexture: Nullable<BaseTexture>;
  54606. private _indexOfRefraction;
  54607. /**
  54608. * Index of refraction of the material base layer.
  54609. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54610. *
  54611. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54612. *
  54613. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54614. */
  54615. indexOfRefraction: number;
  54616. private _volumeIndexOfRefraction;
  54617. /**
  54618. * Index of refraction of the material's volume.
  54619. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54620. *
  54621. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54622. * the volume will use the same IOR as the surface.
  54623. */
  54624. get volumeIndexOfRefraction(): number;
  54625. set volumeIndexOfRefraction(value: number);
  54626. private _invertRefractionY;
  54627. /**
  54628. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54629. */
  54630. invertRefractionY: boolean;
  54631. private _linkRefractionWithTransparency;
  54632. /**
  54633. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54634. * Materials half opaque for instance using refraction could benefit from this control.
  54635. */
  54636. linkRefractionWithTransparency: boolean;
  54637. /**
  54638. * Defines the minimum thickness stored in the thickness map.
  54639. * If no thickness map is defined, this value will be used to simulate thickness.
  54640. */
  54641. minimumThickness: number;
  54642. /**
  54643. * Defines the maximum thickness stored in the thickness map.
  54644. */
  54645. maximumThickness: number;
  54646. /**
  54647. * Defines the volume tint of the material.
  54648. * This is used for both translucency and scattering.
  54649. */
  54650. tintColor: Color3;
  54651. /**
  54652. * Defines the distance at which the tint color should be found in the media.
  54653. * This is used for refraction only.
  54654. */
  54655. tintColorAtDistance: number;
  54656. /**
  54657. * Defines how far each channel transmit through the media.
  54658. * It is defined as a color to simplify it selection.
  54659. */
  54660. diffusionDistance: Color3;
  54661. private _useMaskFromThicknessTexture;
  54662. /**
  54663. * Stores the intensity of the different subsurface effects in the thickness texture.
  54664. * * the green channel is the translucency intensity.
  54665. * * the blue channel is the scattering intensity.
  54666. * * the alpha channel is the refraction intensity.
  54667. */
  54668. useMaskFromThicknessTexture: boolean;
  54669. /** @hidden */
  54670. private _internalMarkAllSubMeshesAsTexturesDirty;
  54671. /** @hidden */
  54672. _markAllSubMeshesAsTexturesDirty(): void;
  54673. /**
  54674. * Instantiate a new istance of sub surface configuration.
  54675. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54676. */
  54677. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54678. /**
  54679. * Gets wehter the submesh is ready to be used or not.
  54680. * @param defines the list of "defines" to update.
  54681. * @param scene defines the scene the material belongs to.
  54682. * @returns - boolean indicating that the submesh is ready or not.
  54683. */
  54684. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54685. /**
  54686. * Checks to see if a texture is used in the material.
  54687. * @param defines the list of "defines" to update.
  54688. * @param scene defines the scene to the material belongs to.
  54689. */
  54690. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54691. /**
  54692. * Binds the material data.
  54693. * @param uniformBuffer defines the Uniform buffer to fill in.
  54694. * @param scene defines the scene the material belongs to.
  54695. * @param engine defines the engine the material belongs to.
  54696. * @param isFrozen defines whether the material is frozen or not.
  54697. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54698. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54699. */
  54700. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54701. /**
  54702. * Unbinds the material from the mesh.
  54703. * @param activeEffect defines the effect that should be unbound from.
  54704. * @returns true if unbound, otherwise false
  54705. */
  54706. unbind(activeEffect: Effect): boolean;
  54707. /**
  54708. * Returns the texture used for refraction or null if none is used.
  54709. * @param scene defines the scene the material belongs to.
  54710. * @returns - Refraction texture if present. If no refraction texture and refraction
  54711. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54712. */
  54713. private _getRefractionTexture;
  54714. /**
  54715. * Returns true if alpha blending should be disabled.
  54716. */
  54717. get disableAlphaBlending(): boolean;
  54718. /**
  54719. * Fills the list of render target textures.
  54720. * @param renderTargets the list of render targets to update
  54721. */
  54722. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54723. /**
  54724. * Checks to see if a texture is used in the material.
  54725. * @param texture - Base texture to use.
  54726. * @returns - Boolean specifying if a texture is used in the material.
  54727. */
  54728. hasTexture(texture: BaseTexture): boolean;
  54729. /**
  54730. * Gets a boolean indicating that current material needs to register RTT
  54731. * @returns true if this uses a render target otherwise false.
  54732. */
  54733. hasRenderTargetTextures(): boolean;
  54734. /**
  54735. * Returns an array of the actively used textures.
  54736. * @param activeTextures Array of BaseTextures
  54737. */
  54738. getActiveTextures(activeTextures: BaseTexture[]): void;
  54739. /**
  54740. * Returns the animatable textures.
  54741. * @param animatables Array of animatable textures.
  54742. */
  54743. getAnimatables(animatables: IAnimatable[]): void;
  54744. /**
  54745. * Disposes the resources of the material.
  54746. * @param forceDisposeTextures - Forces the disposal of all textures.
  54747. */
  54748. dispose(forceDisposeTextures?: boolean): void;
  54749. /**
  54750. * Get the current class name of the texture useful for serialization or dynamic coding.
  54751. * @returns "PBRSubSurfaceConfiguration"
  54752. */
  54753. getClassName(): string;
  54754. /**
  54755. * Add fallbacks to the effect fallbacks list.
  54756. * @param defines defines the Base texture to use.
  54757. * @param fallbacks defines the current fallback list.
  54758. * @param currentRank defines the current fallback rank.
  54759. * @returns the new fallback rank.
  54760. */
  54761. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54762. /**
  54763. * Add the required uniforms to the current list.
  54764. * @param uniforms defines the current uniform list.
  54765. */
  54766. static AddUniforms(uniforms: string[]): void;
  54767. /**
  54768. * Add the required samplers to the current list.
  54769. * @param samplers defines the current sampler list.
  54770. */
  54771. static AddSamplers(samplers: string[]): void;
  54772. /**
  54773. * Add the required uniforms to the current buffer.
  54774. * @param uniformBuffer defines the current uniform buffer.
  54775. */
  54776. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54777. /**
  54778. * Makes a duplicate of the current configuration into another one.
  54779. * @param configuration define the config where to copy the info
  54780. */
  54781. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54782. /**
  54783. * Serializes this Sub Surface configuration.
  54784. * @returns - An object with the serialized config.
  54785. */
  54786. serialize(): any;
  54787. /**
  54788. * Parses a anisotropy Configuration from a serialized object.
  54789. * @param source - Serialized object.
  54790. * @param scene Defines the scene we are parsing for
  54791. * @param rootUrl Defines the rootUrl to load from
  54792. */
  54793. parse(source: any, scene: Scene, rootUrl: string): void;
  54794. }
  54795. }
  54796. declare module BABYLON {
  54797. /** @hidden */
  54798. export var pbrFragmentDeclaration: {
  54799. name: string;
  54800. shader: string;
  54801. };
  54802. }
  54803. declare module BABYLON {
  54804. /** @hidden */
  54805. export var pbrUboDeclaration: {
  54806. name: string;
  54807. shader: string;
  54808. };
  54809. }
  54810. declare module BABYLON {
  54811. /** @hidden */
  54812. export var pbrFragmentExtraDeclaration: {
  54813. name: string;
  54814. shader: string;
  54815. };
  54816. }
  54817. declare module BABYLON {
  54818. /** @hidden */
  54819. export var pbrFragmentSamplersDeclaration: {
  54820. name: string;
  54821. shader: string;
  54822. };
  54823. }
  54824. declare module BABYLON {
  54825. /** @hidden */
  54826. export var importanceSampling: {
  54827. name: string;
  54828. shader: string;
  54829. };
  54830. }
  54831. declare module BABYLON {
  54832. /** @hidden */
  54833. export var pbrHelperFunctions: {
  54834. name: string;
  54835. shader: string;
  54836. };
  54837. }
  54838. declare module BABYLON {
  54839. /** @hidden */
  54840. export var harmonicsFunctions: {
  54841. name: string;
  54842. shader: string;
  54843. };
  54844. }
  54845. declare module BABYLON {
  54846. /** @hidden */
  54847. export var pbrDirectLightingSetupFunctions: {
  54848. name: string;
  54849. shader: string;
  54850. };
  54851. }
  54852. declare module BABYLON {
  54853. /** @hidden */
  54854. export var pbrDirectLightingFalloffFunctions: {
  54855. name: string;
  54856. shader: string;
  54857. };
  54858. }
  54859. declare module BABYLON {
  54860. /** @hidden */
  54861. export var pbrBRDFFunctions: {
  54862. name: string;
  54863. shader: string;
  54864. };
  54865. }
  54866. declare module BABYLON {
  54867. /** @hidden */
  54868. export var hdrFilteringFunctions: {
  54869. name: string;
  54870. shader: string;
  54871. };
  54872. }
  54873. declare module BABYLON {
  54874. /** @hidden */
  54875. export var pbrDirectLightingFunctions: {
  54876. name: string;
  54877. shader: string;
  54878. };
  54879. }
  54880. declare module BABYLON {
  54881. /** @hidden */
  54882. export var pbrIBLFunctions: {
  54883. name: string;
  54884. shader: string;
  54885. };
  54886. }
  54887. declare module BABYLON {
  54888. /** @hidden */
  54889. export var pbrBlockAlbedoOpacity: {
  54890. name: string;
  54891. shader: string;
  54892. };
  54893. }
  54894. declare module BABYLON {
  54895. /** @hidden */
  54896. export var pbrBlockReflectivity: {
  54897. name: string;
  54898. shader: string;
  54899. };
  54900. }
  54901. declare module BABYLON {
  54902. /** @hidden */
  54903. export var pbrBlockAmbientOcclusion: {
  54904. name: string;
  54905. shader: string;
  54906. };
  54907. }
  54908. declare module BABYLON {
  54909. /** @hidden */
  54910. export var pbrBlockAlphaFresnel: {
  54911. name: string;
  54912. shader: string;
  54913. };
  54914. }
  54915. declare module BABYLON {
  54916. /** @hidden */
  54917. export var pbrBlockAnisotropic: {
  54918. name: string;
  54919. shader: string;
  54920. };
  54921. }
  54922. declare module BABYLON {
  54923. /** @hidden */
  54924. export var pbrBlockReflection: {
  54925. name: string;
  54926. shader: string;
  54927. };
  54928. }
  54929. declare module BABYLON {
  54930. /** @hidden */
  54931. export var pbrBlockSheen: {
  54932. name: string;
  54933. shader: string;
  54934. };
  54935. }
  54936. declare module BABYLON {
  54937. /** @hidden */
  54938. export var pbrBlockClearcoat: {
  54939. name: string;
  54940. shader: string;
  54941. };
  54942. }
  54943. declare module BABYLON {
  54944. /** @hidden */
  54945. export var pbrBlockSubSurface: {
  54946. name: string;
  54947. shader: string;
  54948. };
  54949. }
  54950. declare module BABYLON {
  54951. /** @hidden */
  54952. export var pbrBlockNormalGeometric: {
  54953. name: string;
  54954. shader: string;
  54955. };
  54956. }
  54957. declare module BABYLON {
  54958. /** @hidden */
  54959. export var pbrBlockNormalFinal: {
  54960. name: string;
  54961. shader: string;
  54962. };
  54963. }
  54964. declare module BABYLON {
  54965. /** @hidden */
  54966. export var pbrBlockGeometryInfo: {
  54967. name: string;
  54968. shader: string;
  54969. };
  54970. }
  54971. declare module BABYLON {
  54972. /** @hidden */
  54973. export var pbrBlockReflectance0: {
  54974. name: string;
  54975. shader: string;
  54976. };
  54977. }
  54978. declare module BABYLON {
  54979. /** @hidden */
  54980. export var pbrBlockReflectance: {
  54981. name: string;
  54982. shader: string;
  54983. };
  54984. }
  54985. declare module BABYLON {
  54986. /** @hidden */
  54987. export var pbrBlockDirectLighting: {
  54988. name: string;
  54989. shader: string;
  54990. };
  54991. }
  54992. declare module BABYLON {
  54993. /** @hidden */
  54994. export var pbrBlockFinalLitComponents: {
  54995. name: string;
  54996. shader: string;
  54997. };
  54998. }
  54999. declare module BABYLON {
  55000. /** @hidden */
  55001. export var pbrBlockFinalUnlitComponents: {
  55002. name: string;
  55003. shader: string;
  55004. };
  55005. }
  55006. declare module BABYLON {
  55007. /** @hidden */
  55008. export var pbrBlockFinalColorComposition: {
  55009. name: string;
  55010. shader: string;
  55011. };
  55012. }
  55013. declare module BABYLON {
  55014. /** @hidden */
  55015. export var pbrBlockImageProcessing: {
  55016. name: string;
  55017. shader: string;
  55018. };
  55019. }
  55020. declare module BABYLON {
  55021. /** @hidden */
  55022. export var pbrDebug: {
  55023. name: string;
  55024. shader: string;
  55025. };
  55026. }
  55027. declare module BABYLON {
  55028. /** @hidden */
  55029. export var pbrPixelShader: {
  55030. name: string;
  55031. shader: string;
  55032. };
  55033. }
  55034. declare module BABYLON {
  55035. /** @hidden */
  55036. export var pbrVertexDeclaration: {
  55037. name: string;
  55038. shader: string;
  55039. };
  55040. }
  55041. declare module BABYLON {
  55042. /** @hidden */
  55043. export var pbrVertexShader: {
  55044. name: string;
  55045. shader: string;
  55046. };
  55047. }
  55048. declare module BABYLON {
  55049. /**
  55050. * Manages the defines for the PBR Material.
  55051. * @hidden
  55052. */
  55053. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  55054. PBR: boolean;
  55055. NUM_SAMPLES: string;
  55056. REALTIME_FILTERING: boolean;
  55057. MAINUV1: boolean;
  55058. MAINUV2: boolean;
  55059. UV1: boolean;
  55060. UV2: boolean;
  55061. ALBEDO: boolean;
  55062. GAMMAALBEDO: boolean;
  55063. ALBEDODIRECTUV: number;
  55064. VERTEXCOLOR: boolean;
  55065. DETAIL: boolean;
  55066. DETAILDIRECTUV: number;
  55067. DETAIL_NORMALBLENDMETHOD: number;
  55068. AMBIENT: boolean;
  55069. AMBIENTDIRECTUV: number;
  55070. AMBIENTINGRAYSCALE: boolean;
  55071. OPACITY: boolean;
  55072. VERTEXALPHA: boolean;
  55073. OPACITYDIRECTUV: number;
  55074. OPACITYRGB: boolean;
  55075. ALPHATEST: boolean;
  55076. DEPTHPREPASS: boolean;
  55077. ALPHABLEND: boolean;
  55078. ALPHAFROMALBEDO: boolean;
  55079. ALPHATESTVALUE: string;
  55080. SPECULAROVERALPHA: boolean;
  55081. RADIANCEOVERALPHA: boolean;
  55082. ALPHAFRESNEL: boolean;
  55083. LINEARALPHAFRESNEL: boolean;
  55084. PREMULTIPLYALPHA: boolean;
  55085. EMISSIVE: boolean;
  55086. EMISSIVEDIRECTUV: number;
  55087. REFLECTIVITY: boolean;
  55088. REFLECTIVITYDIRECTUV: number;
  55089. SPECULARTERM: boolean;
  55090. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  55091. MICROSURFACEAUTOMATIC: boolean;
  55092. LODBASEDMICROSFURACE: boolean;
  55093. MICROSURFACEMAP: boolean;
  55094. MICROSURFACEMAPDIRECTUV: number;
  55095. METALLICWORKFLOW: boolean;
  55096. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  55097. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  55098. METALLNESSSTOREINMETALMAPBLUE: boolean;
  55099. AOSTOREINMETALMAPRED: boolean;
  55100. METALLIC_REFLECTANCE: boolean;
  55101. METALLIC_REFLECTANCEDIRECTUV: number;
  55102. ENVIRONMENTBRDF: boolean;
  55103. ENVIRONMENTBRDF_RGBD: boolean;
  55104. NORMAL: boolean;
  55105. TANGENT: boolean;
  55106. BUMP: boolean;
  55107. BUMPDIRECTUV: number;
  55108. OBJECTSPACE_NORMALMAP: boolean;
  55109. PARALLAX: boolean;
  55110. PARALLAXOCCLUSION: boolean;
  55111. NORMALXYSCALE: boolean;
  55112. LIGHTMAP: boolean;
  55113. LIGHTMAPDIRECTUV: number;
  55114. USELIGHTMAPASSHADOWMAP: boolean;
  55115. GAMMALIGHTMAP: boolean;
  55116. RGBDLIGHTMAP: boolean;
  55117. REFLECTION: boolean;
  55118. REFLECTIONMAP_3D: boolean;
  55119. REFLECTIONMAP_SPHERICAL: boolean;
  55120. REFLECTIONMAP_PLANAR: boolean;
  55121. REFLECTIONMAP_CUBIC: boolean;
  55122. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55123. REFLECTIONMAP_PROJECTION: boolean;
  55124. REFLECTIONMAP_SKYBOX: boolean;
  55125. REFLECTIONMAP_EXPLICIT: boolean;
  55126. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55127. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55128. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55129. INVERTCUBICMAP: boolean;
  55130. USESPHERICALFROMREFLECTIONMAP: boolean;
  55131. USEIRRADIANCEMAP: boolean;
  55132. SPHERICAL_HARMONICS: boolean;
  55133. USESPHERICALINVERTEX: boolean;
  55134. REFLECTIONMAP_OPPOSITEZ: boolean;
  55135. LODINREFLECTIONALPHA: boolean;
  55136. GAMMAREFLECTION: boolean;
  55137. RGBDREFLECTION: boolean;
  55138. LINEARSPECULARREFLECTION: boolean;
  55139. RADIANCEOCCLUSION: boolean;
  55140. HORIZONOCCLUSION: boolean;
  55141. INSTANCES: boolean;
  55142. THIN_INSTANCES: boolean;
  55143. NUM_BONE_INFLUENCERS: number;
  55144. BonesPerMesh: number;
  55145. BONETEXTURE: boolean;
  55146. NONUNIFORMSCALING: boolean;
  55147. MORPHTARGETS: boolean;
  55148. MORPHTARGETS_NORMAL: boolean;
  55149. MORPHTARGETS_TANGENT: boolean;
  55150. MORPHTARGETS_UV: boolean;
  55151. NUM_MORPH_INFLUENCERS: number;
  55152. IMAGEPROCESSING: boolean;
  55153. VIGNETTE: boolean;
  55154. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55155. VIGNETTEBLENDMODEOPAQUE: boolean;
  55156. TONEMAPPING: boolean;
  55157. TONEMAPPING_ACES: boolean;
  55158. CONTRAST: boolean;
  55159. COLORCURVES: boolean;
  55160. COLORGRADING: boolean;
  55161. COLORGRADING3D: boolean;
  55162. SAMPLER3DGREENDEPTH: boolean;
  55163. SAMPLER3DBGRMAP: boolean;
  55164. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55165. EXPOSURE: boolean;
  55166. MULTIVIEW: boolean;
  55167. USEPHYSICALLIGHTFALLOFF: boolean;
  55168. USEGLTFLIGHTFALLOFF: boolean;
  55169. TWOSIDEDLIGHTING: boolean;
  55170. SHADOWFLOAT: boolean;
  55171. CLIPPLANE: boolean;
  55172. CLIPPLANE2: boolean;
  55173. CLIPPLANE3: boolean;
  55174. CLIPPLANE4: boolean;
  55175. CLIPPLANE5: boolean;
  55176. CLIPPLANE6: boolean;
  55177. POINTSIZE: boolean;
  55178. FOG: boolean;
  55179. LOGARITHMICDEPTH: boolean;
  55180. FORCENORMALFORWARD: boolean;
  55181. SPECULARAA: boolean;
  55182. CLEARCOAT: boolean;
  55183. CLEARCOAT_DEFAULTIOR: boolean;
  55184. CLEARCOAT_TEXTURE: boolean;
  55185. CLEARCOAT_TEXTUREDIRECTUV: number;
  55186. CLEARCOAT_BUMP: boolean;
  55187. CLEARCOAT_BUMPDIRECTUV: number;
  55188. CLEARCOAT_TINT: boolean;
  55189. CLEARCOAT_TINT_TEXTURE: boolean;
  55190. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55191. ANISOTROPIC: boolean;
  55192. ANISOTROPIC_TEXTURE: boolean;
  55193. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55194. BRDF_V_HEIGHT_CORRELATED: boolean;
  55195. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55196. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55197. SHEEN: boolean;
  55198. SHEEN_TEXTURE: boolean;
  55199. SHEEN_TEXTUREDIRECTUV: number;
  55200. SHEEN_LINKWITHALBEDO: boolean;
  55201. SHEEN_ROUGHNESS: boolean;
  55202. SHEEN_ALBEDOSCALING: boolean;
  55203. SUBSURFACE: boolean;
  55204. SS_REFRACTION: boolean;
  55205. SS_TRANSLUCENCY: boolean;
  55206. SS_SCATTERING: boolean;
  55207. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55208. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55209. SS_REFRACTIONMAP_3D: boolean;
  55210. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55211. SS_LODINREFRACTIONALPHA: boolean;
  55212. SS_GAMMAREFRACTION: boolean;
  55213. SS_RGBDREFRACTION: boolean;
  55214. SS_LINEARSPECULARREFRACTION: boolean;
  55215. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55216. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55217. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55218. UNLIT: boolean;
  55219. DEBUGMODE: number;
  55220. /**
  55221. * Initializes the PBR Material defines.
  55222. */
  55223. constructor();
  55224. /**
  55225. * Resets the PBR Material defines.
  55226. */
  55227. reset(): void;
  55228. }
  55229. /**
  55230. * The Physically based material base class of BJS.
  55231. *
  55232. * This offers the main features of a standard PBR material.
  55233. * For more information, please refer to the documentation :
  55234. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55235. */
  55236. export abstract class PBRBaseMaterial extends PushMaterial {
  55237. /**
  55238. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55239. */
  55240. static readonly PBRMATERIAL_OPAQUE: number;
  55241. /**
  55242. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55243. */
  55244. static readonly PBRMATERIAL_ALPHATEST: number;
  55245. /**
  55246. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55247. */
  55248. static readonly PBRMATERIAL_ALPHABLEND: number;
  55249. /**
  55250. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55251. * They are also discarded below the alpha cutoff threshold to improve performances.
  55252. */
  55253. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55254. /**
  55255. * Defines the default value of how much AO map is occluding the analytical lights
  55256. * (point spot...).
  55257. */
  55258. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55259. /**
  55260. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55261. */
  55262. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55263. /**
  55264. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55265. * to enhance interoperability with other engines.
  55266. */
  55267. static readonly LIGHTFALLOFF_GLTF: number;
  55268. /**
  55269. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55270. * to enhance interoperability with other materials.
  55271. */
  55272. static readonly LIGHTFALLOFF_STANDARD: number;
  55273. /**
  55274. * Intensity of the direct lights e.g. the four lights available in your scene.
  55275. * This impacts both the direct diffuse and specular highlights.
  55276. */
  55277. protected _directIntensity: number;
  55278. /**
  55279. * Intensity of the emissive part of the material.
  55280. * This helps controlling the emissive effect without modifying the emissive color.
  55281. */
  55282. protected _emissiveIntensity: number;
  55283. /**
  55284. * Intensity of the environment e.g. how much the environment will light the object
  55285. * either through harmonics for rough material or through the refelction for shiny ones.
  55286. */
  55287. protected _environmentIntensity: number;
  55288. /**
  55289. * This is a special control allowing the reduction of the specular highlights coming from the
  55290. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55291. */
  55292. protected _specularIntensity: number;
  55293. /**
  55294. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55295. */
  55296. private _lightingInfos;
  55297. /**
  55298. * Debug Control allowing disabling the bump map on this material.
  55299. */
  55300. protected _disableBumpMap: boolean;
  55301. /**
  55302. * AKA Diffuse Texture in standard nomenclature.
  55303. */
  55304. protected _albedoTexture: Nullable<BaseTexture>;
  55305. /**
  55306. * AKA Occlusion Texture in other nomenclature.
  55307. */
  55308. protected _ambientTexture: Nullable<BaseTexture>;
  55309. /**
  55310. * AKA Occlusion Texture Intensity in other nomenclature.
  55311. */
  55312. protected _ambientTextureStrength: number;
  55313. /**
  55314. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55315. * 1 means it completely occludes it
  55316. * 0 mean it has no impact
  55317. */
  55318. protected _ambientTextureImpactOnAnalyticalLights: number;
  55319. /**
  55320. * Stores the alpha values in a texture.
  55321. */
  55322. protected _opacityTexture: Nullable<BaseTexture>;
  55323. /**
  55324. * Stores the reflection values in a texture.
  55325. */
  55326. protected _reflectionTexture: Nullable<BaseTexture>;
  55327. /**
  55328. * Stores the emissive values in a texture.
  55329. */
  55330. protected _emissiveTexture: Nullable<BaseTexture>;
  55331. /**
  55332. * AKA Specular texture in other nomenclature.
  55333. */
  55334. protected _reflectivityTexture: Nullable<BaseTexture>;
  55335. /**
  55336. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55337. */
  55338. protected _metallicTexture: Nullable<BaseTexture>;
  55339. /**
  55340. * Specifies the metallic scalar of the metallic/roughness workflow.
  55341. * Can also be used to scale the metalness values of the metallic texture.
  55342. */
  55343. protected _metallic: Nullable<number>;
  55344. /**
  55345. * Specifies the roughness scalar of the metallic/roughness workflow.
  55346. * Can also be used to scale the roughness values of the metallic texture.
  55347. */
  55348. protected _roughness: Nullable<number>;
  55349. /**
  55350. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55351. * By default the indexOfrefraction is used to compute F0;
  55352. *
  55353. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55354. *
  55355. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55356. * F90 = metallicReflectanceColor;
  55357. */
  55358. protected _metallicF0Factor: number;
  55359. /**
  55360. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55361. * By default the F90 is always 1;
  55362. *
  55363. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55364. *
  55365. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55366. * F90 = metallicReflectanceColor;
  55367. */
  55368. protected _metallicReflectanceColor: Color3;
  55369. /**
  55370. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55371. * This is multiply against the scalar values defined in the material.
  55372. */
  55373. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55374. /**
  55375. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55376. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55377. */
  55378. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55379. /**
  55380. * Stores surface normal data used to displace a mesh in a texture.
  55381. */
  55382. protected _bumpTexture: Nullable<BaseTexture>;
  55383. /**
  55384. * Stores the pre-calculated light information of a mesh in a texture.
  55385. */
  55386. protected _lightmapTexture: Nullable<BaseTexture>;
  55387. /**
  55388. * The color of a material in ambient lighting.
  55389. */
  55390. protected _ambientColor: Color3;
  55391. /**
  55392. * AKA Diffuse Color in other nomenclature.
  55393. */
  55394. protected _albedoColor: Color3;
  55395. /**
  55396. * AKA Specular Color in other nomenclature.
  55397. */
  55398. protected _reflectivityColor: Color3;
  55399. /**
  55400. * The color applied when light is reflected from a material.
  55401. */
  55402. protected _reflectionColor: Color3;
  55403. /**
  55404. * The color applied when light is emitted from a material.
  55405. */
  55406. protected _emissiveColor: Color3;
  55407. /**
  55408. * AKA Glossiness in other nomenclature.
  55409. */
  55410. protected _microSurface: number;
  55411. /**
  55412. * Specifies that the material will use the light map as a show map.
  55413. */
  55414. protected _useLightmapAsShadowmap: boolean;
  55415. /**
  55416. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55417. * makes the reflect vector face the model (under horizon).
  55418. */
  55419. protected _useHorizonOcclusion: boolean;
  55420. /**
  55421. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55422. * too much the area relying on ambient texture to define their ambient occlusion.
  55423. */
  55424. protected _useRadianceOcclusion: boolean;
  55425. /**
  55426. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55427. */
  55428. protected _useAlphaFromAlbedoTexture: boolean;
  55429. /**
  55430. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55431. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55432. */
  55433. protected _useSpecularOverAlpha: boolean;
  55434. /**
  55435. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55436. */
  55437. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55438. /**
  55439. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55440. */
  55441. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55442. /**
  55443. * Specifies if the metallic texture contains the roughness information in its green channel.
  55444. */
  55445. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55446. /**
  55447. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55448. */
  55449. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55450. /**
  55451. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55452. */
  55453. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55454. /**
  55455. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55456. */
  55457. protected _useAmbientInGrayScale: boolean;
  55458. /**
  55459. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55460. * The material will try to infer what glossiness each pixel should be.
  55461. */
  55462. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55463. /**
  55464. * Defines the falloff type used in this material.
  55465. * It by default is Physical.
  55466. */
  55467. protected _lightFalloff: number;
  55468. /**
  55469. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55470. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55471. */
  55472. protected _useRadianceOverAlpha: boolean;
  55473. /**
  55474. * Allows using an object space normal map (instead of tangent space).
  55475. */
  55476. protected _useObjectSpaceNormalMap: boolean;
  55477. /**
  55478. * Allows using the bump map in parallax mode.
  55479. */
  55480. protected _useParallax: boolean;
  55481. /**
  55482. * Allows using the bump map in parallax occlusion mode.
  55483. */
  55484. protected _useParallaxOcclusion: boolean;
  55485. /**
  55486. * Controls the scale bias of the parallax mode.
  55487. */
  55488. protected _parallaxScaleBias: number;
  55489. /**
  55490. * If sets to true, disables all the lights affecting the material.
  55491. */
  55492. protected _disableLighting: boolean;
  55493. /**
  55494. * Number of Simultaneous lights allowed on the material.
  55495. */
  55496. protected _maxSimultaneousLights: number;
  55497. /**
  55498. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55499. */
  55500. protected _invertNormalMapX: boolean;
  55501. /**
  55502. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55503. */
  55504. protected _invertNormalMapY: boolean;
  55505. /**
  55506. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55507. */
  55508. protected _twoSidedLighting: boolean;
  55509. /**
  55510. * Defines the alpha limits in alpha test mode.
  55511. */
  55512. protected _alphaCutOff: number;
  55513. /**
  55514. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55515. */
  55516. protected _forceAlphaTest: boolean;
  55517. /**
  55518. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55519. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55520. */
  55521. protected _useAlphaFresnel: boolean;
  55522. /**
  55523. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55524. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55525. */
  55526. protected _useLinearAlphaFresnel: boolean;
  55527. /**
  55528. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55529. * from cos thetav and roughness:
  55530. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55531. */
  55532. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55533. /**
  55534. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55535. */
  55536. protected _forceIrradianceInFragment: boolean;
  55537. private _realTimeFiltering;
  55538. /**
  55539. * Enables realtime filtering on the texture.
  55540. */
  55541. get realTimeFiltering(): boolean;
  55542. set realTimeFiltering(b: boolean);
  55543. private _realTimeFilteringQuality;
  55544. /**
  55545. * Quality switch for realtime filtering
  55546. */
  55547. get realTimeFilteringQuality(): number;
  55548. set realTimeFilteringQuality(n: number);
  55549. /**
  55550. * Force normal to face away from face.
  55551. */
  55552. protected _forceNormalForward: boolean;
  55553. /**
  55554. * Enables specular anti aliasing in the PBR shader.
  55555. * It will both interacts on the Geometry for analytical and IBL lighting.
  55556. * It also prefilter the roughness map based on the bump values.
  55557. */
  55558. protected _enableSpecularAntiAliasing: boolean;
  55559. /**
  55560. * Default configuration related to image processing available in the PBR Material.
  55561. */
  55562. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55563. /**
  55564. * Keep track of the image processing observer to allow dispose and replace.
  55565. */
  55566. private _imageProcessingObserver;
  55567. /**
  55568. * Attaches a new image processing configuration to the PBR Material.
  55569. * @param configuration
  55570. */
  55571. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55572. /**
  55573. * Stores the available render targets.
  55574. */
  55575. private _renderTargets;
  55576. /**
  55577. * Sets the global ambient color for the material used in lighting calculations.
  55578. */
  55579. private _globalAmbientColor;
  55580. /**
  55581. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55582. */
  55583. private _useLogarithmicDepth;
  55584. /**
  55585. * If set to true, no lighting calculations will be applied.
  55586. */
  55587. private _unlit;
  55588. private _debugMode;
  55589. /**
  55590. * @hidden
  55591. * This is reserved for the inspector.
  55592. * Defines the material debug mode.
  55593. * It helps seeing only some components of the material while troubleshooting.
  55594. */
  55595. debugMode: number;
  55596. /**
  55597. * @hidden
  55598. * This is reserved for the inspector.
  55599. * Specify from where on screen the debug mode should start.
  55600. * The value goes from -1 (full screen) to 1 (not visible)
  55601. * It helps with side by side comparison against the final render
  55602. * This defaults to -1
  55603. */
  55604. private debugLimit;
  55605. /**
  55606. * @hidden
  55607. * This is reserved for the inspector.
  55608. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55609. * You can use the factor to better multiply the final value.
  55610. */
  55611. private debugFactor;
  55612. /**
  55613. * Defines the clear coat layer parameters for the material.
  55614. */
  55615. readonly clearCoat: PBRClearCoatConfiguration;
  55616. /**
  55617. * Defines the anisotropic parameters for the material.
  55618. */
  55619. readonly anisotropy: PBRAnisotropicConfiguration;
  55620. /**
  55621. * Defines the BRDF parameters for the material.
  55622. */
  55623. readonly brdf: PBRBRDFConfiguration;
  55624. /**
  55625. * Defines the Sheen parameters for the material.
  55626. */
  55627. readonly sheen: PBRSheenConfiguration;
  55628. /**
  55629. * Defines the SubSurface parameters for the material.
  55630. */
  55631. readonly subSurface: PBRSubSurfaceConfiguration;
  55632. /**
  55633. * Defines the detail map parameters for the material.
  55634. */
  55635. readonly detailMap: DetailMapConfiguration;
  55636. protected _rebuildInParallel: boolean;
  55637. /**
  55638. * Instantiates a new PBRMaterial instance.
  55639. *
  55640. * @param name The material name
  55641. * @param scene The scene the material will be use in.
  55642. */
  55643. constructor(name: string, scene: Scene);
  55644. /**
  55645. * Gets a boolean indicating that current material needs to register RTT
  55646. */
  55647. get hasRenderTargetTextures(): boolean;
  55648. /**
  55649. * Gets the name of the material class.
  55650. */
  55651. getClassName(): string;
  55652. /**
  55653. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55654. */
  55655. get useLogarithmicDepth(): boolean;
  55656. /**
  55657. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55658. */
  55659. set useLogarithmicDepth(value: boolean);
  55660. /**
  55661. * Returns true if alpha blending should be disabled.
  55662. */
  55663. protected get _disableAlphaBlending(): boolean;
  55664. /**
  55665. * Specifies whether or not this material should be rendered in alpha blend mode.
  55666. */
  55667. needAlphaBlending(): boolean;
  55668. /**
  55669. * Specifies whether or not this material should be rendered in alpha test mode.
  55670. */
  55671. needAlphaTesting(): boolean;
  55672. /**
  55673. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55674. */
  55675. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55676. /**
  55677. * Gets the texture used for the alpha test.
  55678. */
  55679. getAlphaTestTexture(): Nullable<BaseTexture>;
  55680. /**
  55681. * Specifies that the submesh is ready to be used.
  55682. * @param mesh - BJS mesh.
  55683. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55684. * @param useInstances - Specifies that instances should be used.
  55685. * @returns - boolean indicating that the submesh is ready or not.
  55686. */
  55687. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55688. /**
  55689. * Specifies if the material uses metallic roughness workflow.
  55690. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55691. */
  55692. isMetallicWorkflow(): boolean;
  55693. private _prepareEffect;
  55694. private _prepareDefines;
  55695. /**
  55696. * Force shader compilation
  55697. */
  55698. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55699. /**
  55700. * Initializes the uniform buffer layout for the shader.
  55701. */
  55702. buildUniformLayout(): void;
  55703. /**
  55704. * Unbinds the material from the mesh
  55705. */
  55706. unbind(): void;
  55707. /**
  55708. * Binds the submesh data.
  55709. * @param world - The world matrix.
  55710. * @param mesh - The BJS mesh.
  55711. * @param subMesh - A submesh of the BJS mesh.
  55712. */
  55713. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55714. /**
  55715. * Returns the animatable textures.
  55716. * @returns - Array of animatable textures.
  55717. */
  55718. getAnimatables(): IAnimatable[];
  55719. /**
  55720. * Returns the texture used for reflections.
  55721. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55722. */
  55723. private _getReflectionTexture;
  55724. /**
  55725. * Returns an array of the actively used textures.
  55726. * @returns - Array of BaseTextures
  55727. */
  55728. getActiveTextures(): BaseTexture[];
  55729. /**
  55730. * Checks to see if a texture is used in the material.
  55731. * @param texture - Base texture to use.
  55732. * @returns - Boolean specifying if a texture is used in the material.
  55733. */
  55734. hasTexture(texture: BaseTexture): boolean;
  55735. /**
  55736. * Disposes the resources of the material.
  55737. * @param forceDisposeEffect - Forces the disposal of effects.
  55738. * @param forceDisposeTextures - Forces the disposal of all textures.
  55739. */
  55740. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55741. }
  55742. }
  55743. declare module BABYLON {
  55744. /**
  55745. * The Physically based material of BJS.
  55746. *
  55747. * This offers the main features of a standard PBR material.
  55748. * For more information, please refer to the documentation :
  55749. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55750. */
  55751. export class PBRMaterial extends PBRBaseMaterial {
  55752. /**
  55753. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55754. */
  55755. static readonly PBRMATERIAL_OPAQUE: number;
  55756. /**
  55757. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55758. */
  55759. static readonly PBRMATERIAL_ALPHATEST: number;
  55760. /**
  55761. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55762. */
  55763. static readonly PBRMATERIAL_ALPHABLEND: number;
  55764. /**
  55765. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55766. * They are also discarded below the alpha cutoff threshold to improve performances.
  55767. */
  55768. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55769. /**
  55770. * Defines the default value of how much AO map is occluding the analytical lights
  55771. * (point spot...).
  55772. */
  55773. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55774. /**
  55775. * Intensity of the direct lights e.g. the four lights available in your scene.
  55776. * This impacts both the direct diffuse and specular highlights.
  55777. */
  55778. directIntensity: number;
  55779. /**
  55780. * Intensity of the emissive part of the material.
  55781. * This helps controlling the emissive effect without modifying the emissive color.
  55782. */
  55783. emissiveIntensity: number;
  55784. /**
  55785. * Intensity of the environment e.g. how much the environment will light the object
  55786. * either through harmonics for rough material or through the refelction for shiny ones.
  55787. */
  55788. environmentIntensity: number;
  55789. /**
  55790. * This is a special control allowing the reduction of the specular highlights coming from the
  55791. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55792. */
  55793. specularIntensity: number;
  55794. /**
  55795. * Debug Control allowing disabling the bump map on this material.
  55796. */
  55797. disableBumpMap: boolean;
  55798. /**
  55799. * AKA Diffuse Texture in standard nomenclature.
  55800. */
  55801. albedoTexture: BaseTexture;
  55802. /**
  55803. * AKA Occlusion Texture in other nomenclature.
  55804. */
  55805. ambientTexture: BaseTexture;
  55806. /**
  55807. * AKA Occlusion Texture Intensity in other nomenclature.
  55808. */
  55809. ambientTextureStrength: number;
  55810. /**
  55811. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55812. * 1 means it completely occludes it
  55813. * 0 mean it has no impact
  55814. */
  55815. ambientTextureImpactOnAnalyticalLights: number;
  55816. /**
  55817. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55818. */
  55819. opacityTexture: BaseTexture;
  55820. /**
  55821. * Stores the reflection values in a texture.
  55822. */
  55823. reflectionTexture: Nullable<BaseTexture>;
  55824. /**
  55825. * Stores the emissive values in a texture.
  55826. */
  55827. emissiveTexture: BaseTexture;
  55828. /**
  55829. * AKA Specular texture in other nomenclature.
  55830. */
  55831. reflectivityTexture: BaseTexture;
  55832. /**
  55833. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55834. */
  55835. metallicTexture: BaseTexture;
  55836. /**
  55837. * Specifies the metallic scalar of the metallic/roughness workflow.
  55838. * Can also be used to scale the metalness values of the metallic texture.
  55839. */
  55840. metallic: Nullable<number>;
  55841. /**
  55842. * Specifies the roughness scalar of the metallic/roughness workflow.
  55843. * Can also be used to scale the roughness values of the metallic texture.
  55844. */
  55845. roughness: Nullable<number>;
  55846. /**
  55847. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55848. * By default the indexOfrefraction is used to compute F0;
  55849. *
  55850. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55851. *
  55852. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55853. * F90 = metallicReflectanceColor;
  55854. */
  55855. metallicF0Factor: number;
  55856. /**
  55857. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55858. * By default the F90 is always 1;
  55859. *
  55860. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55861. *
  55862. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55863. * F90 = metallicReflectanceColor;
  55864. */
  55865. metallicReflectanceColor: Color3;
  55866. /**
  55867. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55868. * This is multiply against the scalar values defined in the material.
  55869. */
  55870. metallicReflectanceTexture: Nullable<BaseTexture>;
  55871. /**
  55872. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55873. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55874. */
  55875. microSurfaceTexture: BaseTexture;
  55876. /**
  55877. * Stores surface normal data used to displace a mesh in a texture.
  55878. */
  55879. bumpTexture: BaseTexture;
  55880. /**
  55881. * Stores the pre-calculated light information of a mesh in a texture.
  55882. */
  55883. lightmapTexture: BaseTexture;
  55884. /**
  55885. * Stores the refracted light information in a texture.
  55886. */
  55887. get refractionTexture(): Nullable<BaseTexture>;
  55888. set refractionTexture(value: Nullable<BaseTexture>);
  55889. /**
  55890. * The color of a material in ambient lighting.
  55891. */
  55892. ambientColor: Color3;
  55893. /**
  55894. * AKA Diffuse Color in other nomenclature.
  55895. */
  55896. albedoColor: Color3;
  55897. /**
  55898. * AKA Specular Color in other nomenclature.
  55899. */
  55900. reflectivityColor: Color3;
  55901. /**
  55902. * The color reflected from the material.
  55903. */
  55904. reflectionColor: Color3;
  55905. /**
  55906. * The color emitted from the material.
  55907. */
  55908. emissiveColor: Color3;
  55909. /**
  55910. * AKA Glossiness in other nomenclature.
  55911. */
  55912. microSurface: number;
  55913. /**
  55914. * Index of refraction of the material base layer.
  55915. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55916. *
  55917. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55918. *
  55919. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55920. */
  55921. get indexOfRefraction(): number;
  55922. set indexOfRefraction(value: number);
  55923. /**
  55924. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55925. */
  55926. get invertRefractionY(): boolean;
  55927. set invertRefractionY(value: boolean);
  55928. /**
  55929. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55930. * Materials half opaque for instance using refraction could benefit from this control.
  55931. */
  55932. get linkRefractionWithTransparency(): boolean;
  55933. set linkRefractionWithTransparency(value: boolean);
  55934. /**
  55935. * If true, the light map contains occlusion information instead of lighting info.
  55936. */
  55937. useLightmapAsShadowmap: boolean;
  55938. /**
  55939. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55940. */
  55941. useAlphaFromAlbedoTexture: boolean;
  55942. /**
  55943. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55944. */
  55945. forceAlphaTest: boolean;
  55946. /**
  55947. * Defines the alpha limits in alpha test mode.
  55948. */
  55949. alphaCutOff: number;
  55950. /**
  55951. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55952. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55953. */
  55954. useSpecularOverAlpha: boolean;
  55955. /**
  55956. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55957. */
  55958. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55959. /**
  55960. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55961. */
  55962. useRoughnessFromMetallicTextureAlpha: boolean;
  55963. /**
  55964. * Specifies if the metallic texture contains the roughness information in its green channel.
  55965. */
  55966. useRoughnessFromMetallicTextureGreen: boolean;
  55967. /**
  55968. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55969. */
  55970. useMetallnessFromMetallicTextureBlue: boolean;
  55971. /**
  55972. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55973. */
  55974. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55975. /**
  55976. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55977. */
  55978. useAmbientInGrayScale: boolean;
  55979. /**
  55980. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55981. * The material will try to infer what glossiness each pixel should be.
  55982. */
  55983. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55984. /**
  55985. * BJS is using an harcoded light falloff based on a manually sets up range.
  55986. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55987. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55988. */
  55989. get usePhysicalLightFalloff(): boolean;
  55990. /**
  55991. * BJS is using an harcoded light falloff based on a manually sets up range.
  55992. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55993. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55994. */
  55995. set usePhysicalLightFalloff(value: boolean);
  55996. /**
  55997. * In order to support the falloff compatibility with gltf, a special mode has been added
  55998. * to reproduce the gltf light falloff.
  55999. */
  56000. get useGLTFLightFalloff(): boolean;
  56001. /**
  56002. * In order to support the falloff compatibility with gltf, a special mode has been added
  56003. * to reproduce the gltf light falloff.
  56004. */
  56005. set useGLTFLightFalloff(value: boolean);
  56006. /**
  56007. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56008. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56009. */
  56010. useRadianceOverAlpha: boolean;
  56011. /**
  56012. * Allows using an object space normal map (instead of tangent space).
  56013. */
  56014. useObjectSpaceNormalMap: boolean;
  56015. /**
  56016. * Allows using the bump map in parallax mode.
  56017. */
  56018. useParallax: boolean;
  56019. /**
  56020. * Allows using the bump map in parallax occlusion mode.
  56021. */
  56022. useParallaxOcclusion: boolean;
  56023. /**
  56024. * Controls the scale bias of the parallax mode.
  56025. */
  56026. parallaxScaleBias: number;
  56027. /**
  56028. * If sets to true, disables all the lights affecting the material.
  56029. */
  56030. disableLighting: boolean;
  56031. /**
  56032. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56033. */
  56034. forceIrradianceInFragment: boolean;
  56035. /**
  56036. * Number of Simultaneous lights allowed on the material.
  56037. */
  56038. maxSimultaneousLights: number;
  56039. /**
  56040. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56041. */
  56042. invertNormalMapX: boolean;
  56043. /**
  56044. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56045. */
  56046. invertNormalMapY: boolean;
  56047. /**
  56048. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56049. */
  56050. twoSidedLighting: boolean;
  56051. /**
  56052. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56053. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56054. */
  56055. useAlphaFresnel: boolean;
  56056. /**
  56057. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56058. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56059. */
  56060. useLinearAlphaFresnel: boolean;
  56061. /**
  56062. * Let user defines the brdf lookup texture used for IBL.
  56063. * A default 8bit version is embedded but you could point at :
  56064. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  56065. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  56066. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  56067. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  56068. */
  56069. environmentBRDFTexture: Nullable<BaseTexture>;
  56070. /**
  56071. * Force normal to face away from face.
  56072. */
  56073. forceNormalForward: boolean;
  56074. /**
  56075. * Enables specular anti aliasing in the PBR shader.
  56076. * It will both interacts on the Geometry for analytical and IBL lighting.
  56077. * It also prefilter the roughness map based on the bump values.
  56078. */
  56079. enableSpecularAntiAliasing: boolean;
  56080. /**
  56081. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56082. * makes the reflect vector face the model (under horizon).
  56083. */
  56084. useHorizonOcclusion: boolean;
  56085. /**
  56086. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56087. * too much the area relying on ambient texture to define their ambient occlusion.
  56088. */
  56089. useRadianceOcclusion: boolean;
  56090. /**
  56091. * If set to true, no lighting calculations will be applied.
  56092. */
  56093. unlit: boolean;
  56094. /**
  56095. * Gets the image processing configuration used either in this material.
  56096. */
  56097. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56098. /**
  56099. * Sets the Default image processing configuration used either in the this material.
  56100. *
  56101. * If sets to null, the scene one is in use.
  56102. */
  56103. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56104. /**
  56105. * Gets wether the color curves effect is enabled.
  56106. */
  56107. get cameraColorCurvesEnabled(): boolean;
  56108. /**
  56109. * Sets wether the color curves effect is enabled.
  56110. */
  56111. set cameraColorCurvesEnabled(value: boolean);
  56112. /**
  56113. * Gets wether the color grading effect is enabled.
  56114. */
  56115. get cameraColorGradingEnabled(): boolean;
  56116. /**
  56117. * Gets wether the color grading effect is enabled.
  56118. */
  56119. set cameraColorGradingEnabled(value: boolean);
  56120. /**
  56121. * Gets wether tonemapping is enabled or not.
  56122. */
  56123. get cameraToneMappingEnabled(): boolean;
  56124. /**
  56125. * Sets wether tonemapping is enabled or not
  56126. */
  56127. set cameraToneMappingEnabled(value: boolean);
  56128. /**
  56129. * The camera exposure used on this material.
  56130. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56131. * This corresponds to a photographic exposure.
  56132. */
  56133. get cameraExposure(): number;
  56134. /**
  56135. * The camera exposure used on this material.
  56136. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56137. * This corresponds to a photographic exposure.
  56138. */
  56139. set cameraExposure(value: number);
  56140. /**
  56141. * Gets The camera contrast used on this material.
  56142. */
  56143. get cameraContrast(): number;
  56144. /**
  56145. * Sets The camera contrast used on this material.
  56146. */
  56147. set cameraContrast(value: number);
  56148. /**
  56149. * Gets the Color Grading 2D Lookup Texture.
  56150. */
  56151. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56152. /**
  56153. * Sets the Color Grading 2D Lookup Texture.
  56154. */
  56155. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56156. /**
  56157. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56158. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56159. * 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;
  56160. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56161. */
  56162. get cameraColorCurves(): Nullable<ColorCurves>;
  56163. /**
  56164. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56165. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56166. * 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;
  56167. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56168. */
  56169. set cameraColorCurves(value: Nullable<ColorCurves>);
  56170. /**
  56171. * Instantiates a new PBRMaterial instance.
  56172. *
  56173. * @param name The material name
  56174. * @param scene The scene the material will be use in.
  56175. */
  56176. constructor(name: string, scene: Scene);
  56177. /**
  56178. * Returns the name of this material class.
  56179. */
  56180. getClassName(): string;
  56181. /**
  56182. * Makes a duplicate of the current material.
  56183. * @param name - name to use for the new material.
  56184. */
  56185. clone(name: string): PBRMaterial;
  56186. /**
  56187. * Serializes this PBR Material.
  56188. * @returns - An object with the serialized material.
  56189. */
  56190. serialize(): any;
  56191. /**
  56192. * Parses a PBR Material from a serialized object.
  56193. * @param source - Serialized object.
  56194. * @param scene - BJS scene instance.
  56195. * @param rootUrl - url for the scene object
  56196. * @returns - PBRMaterial
  56197. */
  56198. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56199. }
  56200. }
  56201. declare module BABYLON {
  56202. /**
  56203. * Direct draw surface info
  56204. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56205. */
  56206. export interface DDSInfo {
  56207. /**
  56208. * Width of the texture
  56209. */
  56210. width: number;
  56211. /**
  56212. * Width of the texture
  56213. */
  56214. height: number;
  56215. /**
  56216. * Number of Mipmaps for the texture
  56217. * @see https://en.wikipedia.org/wiki/Mipmap
  56218. */
  56219. mipmapCount: number;
  56220. /**
  56221. * If the textures format is a known fourCC format
  56222. * @see https://www.fourcc.org/
  56223. */
  56224. isFourCC: boolean;
  56225. /**
  56226. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56227. */
  56228. isRGB: boolean;
  56229. /**
  56230. * If the texture is a lumincance format
  56231. */
  56232. isLuminance: boolean;
  56233. /**
  56234. * If this is a cube texture
  56235. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56236. */
  56237. isCube: boolean;
  56238. /**
  56239. * If the texture is a compressed format eg. FOURCC_DXT1
  56240. */
  56241. isCompressed: boolean;
  56242. /**
  56243. * The dxgiFormat of the texture
  56244. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56245. */
  56246. dxgiFormat: number;
  56247. /**
  56248. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56249. */
  56250. textureType: number;
  56251. /**
  56252. * Sphericle polynomial created for the dds texture
  56253. */
  56254. sphericalPolynomial?: SphericalPolynomial;
  56255. }
  56256. /**
  56257. * Class used to provide DDS decompression tools
  56258. */
  56259. export class DDSTools {
  56260. /**
  56261. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56262. */
  56263. static StoreLODInAlphaChannel: boolean;
  56264. /**
  56265. * Gets DDS information from an array buffer
  56266. * @param data defines the array buffer view to read data from
  56267. * @returns the DDS information
  56268. */
  56269. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56270. private static _FloatView;
  56271. private static _Int32View;
  56272. private static _ToHalfFloat;
  56273. private static _FromHalfFloat;
  56274. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56275. private static _GetHalfFloatRGBAArrayBuffer;
  56276. private static _GetFloatRGBAArrayBuffer;
  56277. private static _GetFloatAsUIntRGBAArrayBuffer;
  56278. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56279. private static _GetRGBAArrayBuffer;
  56280. private static _ExtractLongWordOrder;
  56281. private static _GetRGBArrayBuffer;
  56282. private static _GetLuminanceArrayBuffer;
  56283. /**
  56284. * Uploads DDS Levels to a Babylon Texture
  56285. * @hidden
  56286. */
  56287. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56288. }
  56289. interface ThinEngine {
  56290. /**
  56291. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56292. * @param rootUrl defines the url where the file to load is located
  56293. * @param scene defines the current scene
  56294. * @param lodScale defines scale to apply to the mip map selection
  56295. * @param lodOffset defines offset to apply to the mip map selection
  56296. * @param onLoad defines an optional callback raised when the texture is loaded
  56297. * @param onError defines an optional callback raised if there is an issue to load the texture
  56298. * @param format defines the format of the data
  56299. * @param forcedExtension defines the extension to use to pick the right loader
  56300. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56301. * @returns the cube texture as an InternalTexture
  56302. */
  56303. 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;
  56304. }
  56305. }
  56306. declare module BABYLON {
  56307. /**
  56308. * Implementation of the DDS Texture Loader.
  56309. * @hidden
  56310. */
  56311. export class _DDSTextureLoader implements IInternalTextureLoader {
  56312. /**
  56313. * Defines wether the loader supports cascade loading the different faces.
  56314. */
  56315. readonly supportCascades: boolean;
  56316. /**
  56317. * This returns if the loader support the current file information.
  56318. * @param extension defines the file extension of the file being loaded
  56319. * @returns true if the loader can load the specified file
  56320. */
  56321. canLoad(extension: string): boolean;
  56322. /**
  56323. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56324. * @param data contains the texture data
  56325. * @param texture defines the BabylonJS internal texture
  56326. * @param createPolynomials will be true if polynomials have been requested
  56327. * @param onLoad defines the callback to trigger once the texture is ready
  56328. * @param onError defines the callback to trigger in case of error
  56329. */
  56330. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56331. /**
  56332. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56333. * @param data contains the texture data
  56334. * @param texture defines the BabylonJS internal texture
  56335. * @param callback defines the method to call once ready to upload
  56336. */
  56337. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56338. }
  56339. }
  56340. declare module BABYLON {
  56341. /**
  56342. * Implementation of the ENV Texture Loader.
  56343. * @hidden
  56344. */
  56345. export class _ENVTextureLoader implements IInternalTextureLoader {
  56346. /**
  56347. * Defines wether the loader supports cascade loading the different faces.
  56348. */
  56349. readonly supportCascades: boolean;
  56350. /**
  56351. * This returns if the loader support the current file information.
  56352. * @param extension defines the file extension of the file being loaded
  56353. * @returns true if the loader can load the specified file
  56354. */
  56355. canLoad(extension: string): boolean;
  56356. /**
  56357. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56358. * @param data contains the texture data
  56359. * @param texture defines the BabylonJS internal texture
  56360. * @param createPolynomials will be true if polynomials have been requested
  56361. * @param onLoad defines the callback to trigger once the texture is ready
  56362. * @param onError defines the callback to trigger in case of error
  56363. */
  56364. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56365. /**
  56366. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56367. * @param data contains the texture data
  56368. * @param texture defines the BabylonJS internal texture
  56369. * @param callback defines the method to call once ready to upload
  56370. */
  56371. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56372. }
  56373. }
  56374. declare module BABYLON {
  56375. /**
  56376. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56377. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56378. */
  56379. export class KhronosTextureContainer {
  56380. /** contents of the KTX container file */
  56381. data: ArrayBufferView;
  56382. private static HEADER_LEN;
  56383. private static COMPRESSED_2D;
  56384. private static COMPRESSED_3D;
  56385. private static TEX_2D;
  56386. private static TEX_3D;
  56387. /**
  56388. * Gets the openGL type
  56389. */
  56390. glType: number;
  56391. /**
  56392. * Gets the openGL type size
  56393. */
  56394. glTypeSize: number;
  56395. /**
  56396. * Gets the openGL format
  56397. */
  56398. glFormat: number;
  56399. /**
  56400. * Gets the openGL internal format
  56401. */
  56402. glInternalFormat: number;
  56403. /**
  56404. * Gets the base internal format
  56405. */
  56406. glBaseInternalFormat: number;
  56407. /**
  56408. * Gets image width in pixel
  56409. */
  56410. pixelWidth: number;
  56411. /**
  56412. * Gets image height in pixel
  56413. */
  56414. pixelHeight: number;
  56415. /**
  56416. * Gets image depth in pixels
  56417. */
  56418. pixelDepth: number;
  56419. /**
  56420. * Gets the number of array elements
  56421. */
  56422. numberOfArrayElements: number;
  56423. /**
  56424. * Gets the number of faces
  56425. */
  56426. numberOfFaces: number;
  56427. /**
  56428. * Gets the number of mipmap levels
  56429. */
  56430. numberOfMipmapLevels: number;
  56431. /**
  56432. * Gets the bytes of key value data
  56433. */
  56434. bytesOfKeyValueData: number;
  56435. /**
  56436. * Gets the load type
  56437. */
  56438. loadType: number;
  56439. /**
  56440. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56441. */
  56442. isInvalid: boolean;
  56443. /**
  56444. * Creates a new KhronosTextureContainer
  56445. * @param data contents of the KTX container file
  56446. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56447. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56448. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56449. */
  56450. constructor(
  56451. /** contents of the KTX container file */
  56452. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56453. /**
  56454. * Uploads KTX content to a Babylon Texture.
  56455. * It is assumed that the texture has already been created & is currently bound
  56456. * @hidden
  56457. */
  56458. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56459. private _upload2DCompressedLevels;
  56460. /**
  56461. * Checks if the given data starts with a KTX file identifier.
  56462. * @param data the data to check
  56463. * @returns true if the data is a KTX file or false otherwise
  56464. */
  56465. static IsValid(data: ArrayBufferView): boolean;
  56466. }
  56467. }
  56468. declare module BABYLON {
  56469. /**
  56470. * Class for loading KTX2 files
  56471. * !!! Experimental Extension Subject to Changes !!!
  56472. * @hidden
  56473. */
  56474. export class KhronosTextureContainer2 {
  56475. private static _ModulePromise;
  56476. private static _TranscodeFormat;
  56477. constructor(engine: ThinEngine);
  56478. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56479. private _determineTranscodeFormat;
  56480. /**
  56481. * Checks if the given data starts with a KTX2 file identifier.
  56482. * @param data the data to check
  56483. * @returns true if the data is a KTX2 file or false otherwise
  56484. */
  56485. static IsValid(data: ArrayBufferView): boolean;
  56486. }
  56487. }
  56488. declare module BABYLON {
  56489. /**
  56490. * Implementation of the KTX Texture Loader.
  56491. * @hidden
  56492. */
  56493. export class _KTXTextureLoader implements IInternalTextureLoader {
  56494. /**
  56495. * Defines wether the loader supports cascade loading the different faces.
  56496. */
  56497. readonly supportCascades: boolean;
  56498. /**
  56499. * This returns if the loader support the current file information.
  56500. * @param extension defines the file extension of the file being loaded
  56501. * @returns true if the loader can load the specified file
  56502. */
  56503. canLoad(extension: string): boolean;
  56504. /**
  56505. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56506. * @param data contains the texture data
  56507. * @param texture defines the BabylonJS internal texture
  56508. * @param createPolynomials will be true if polynomials have been requested
  56509. * @param onLoad defines the callback to trigger once the texture is ready
  56510. * @param onError defines the callback to trigger in case of error
  56511. */
  56512. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56513. /**
  56514. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56515. * @param data contains the texture data
  56516. * @param texture defines the BabylonJS internal texture
  56517. * @param callback defines the method to call once ready to upload
  56518. */
  56519. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56520. }
  56521. }
  56522. declare module BABYLON {
  56523. /** @hidden */
  56524. export var _forceSceneHelpersToBundle: boolean;
  56525. interface Scene {
  56526. /**
  56527. * Creates a default light for the scene.
  56528. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56529. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56530. */
  56531. createDefaultLight(replace?: boolean): void;
  56532. /**
  56533. * Creates a default camera for the scene.
  56534. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56535. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56536. * @param replace has default false, when true replaces the active camera in the scene
  56537. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56538. */
  56539. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56540. /**
  56541. * Creates a default camera and a default light.
  56542. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56543. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56544. * @param replace has the default false, when true replaces the active camera/light in the scene
  56545. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56546. */
  56547. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56548. /**
  56549. * Creates a new sky box
  56550. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56551. * @param environmentTexture defines the texture to use as environment texture
  56552. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56553. * @param scale defines the overall scale of the skybox
  56554. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56555. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56556. * @returns a new mesh holding the sky box
  56557. */
  56558. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56559. /**
  56560. * Creates a new environment
  56561. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56562. * @param options defines the options you can use to configure the environment
  56563. * @returns the new EnvironmentHelper
  56564. */
  56565. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56566. /**
  56567. * Creates a new VREXperienceHelper
  56568. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56569. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56570. * @returns a new VREXperienceHelper
  56571. */
  56572. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56573. /**
  56574. * Creates a new WebXRDefaultExperience
  56575. * @see http://doc.babylonjs.com/how_to/webxr
  56576. * @param options experience options
  56577. * @returns a promise for a new WebXRDefaultExperience
  56578. */
  56579. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56580. }
  56581. }
  56582. declare module BABYLON {
  56583. /**
  56584. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56585. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56586. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56587. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56588. */
  56589. export class VideoDome extends TransformNode {
  56590. /**
  56591. * Define the video source as a Monoscopic panoramic 360 video.
  56592. */
  56593. static readonly MODE_MONOSCOPIC: number;
  56594. /**
  56595. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56596. */
  56597. static readonly MODE_TOPBOTTOM: number;
  56598. /**
  56599. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56600. */
  56601. static readonly MODE_SIDEBYSIDE: number;
  56602. private _halfDome;
  56603. private _useDirectMapping;
  56604. /**
  56605. * The video texture being displayed on the sphere
  56606. */
  56607. protected _videoTexture: VideoTexture;
  56608. /**
  56609. * Gets the video texture being displayed on the sphere
  56610. */
  56611. get videoTexture(): VideoTexture;
  56612. /**
  56613. * The skybox material
  56614. */
  56615. protected _material: BackgroundMaterial;
  56616. /**
  56617. * The surface used for the skybox
  56618. */
  56619. protected _mesh: Mesh;
  56620. /**
  56621. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56622. */
  56623. private _halfDomeMask;
  56624. /**
  56625. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56626. * Also see the options.resolution property.
  56627. */
  56628. get fovMultiplier(): number;
  56629. set fovMultiplier(value: number);
  56630. private _videoMode;
  56631. /**
  56632. * Gets or set the current video mode for the video. It can be:
  56633. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56634. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56635. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56636. */
  56637. get videoMode(): number;
  56638. set videoMode(value: number);
  56639. /**
  56640. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56641. *
  56642. */
  56643. get halfDome(): boolean;
  56644. /**
  56645. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56646. */
  56647. set halfDome(enabled: boolean);
  56648. /**
  56649. * Oberserver used in Stereoscopic VR Mode.
  56650. */
  56651. private _onBeforeCameraRenderObserver;
  56652. /**
  56653. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56654. * @param name Element's name, child elements will append suffixes for their own names.
  56655. * @param urlsOrVideo defines the url(s) or the video element to use
  56656. * @param options An object containing optional or exposed sub element properties
  56657. */
  56658. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56659. resolution?: number;
  56660. clickToPlay?: boolean;
  56661. autoPlay?: boolean;
  56662. loop?: boolean;
  56663. size?: number;
  56664. poster?: string;
  56665. faceForward?: boolean;
  56666. useDirectMapping?: boolean;
  56667. halfDomeMode?: boolean;
  56668. }, scene: Scene);
  56669. private _changeVideoMode;
  56670. /**
  56671. * Releases resources associated with this node.
  56672. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56673. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56674. */
  56675. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56676. }
  56677. }
  56678. declare module BABYLON {
  56679. /**
  56680. * This class can be used to get instrumentation data from a Babylon engine
  56681. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56682. */
  56683. export class EngineInstrumentation implements IDisposable {
  56684. /**
  56685. * Define the instrumented engine.
  56686. */
  56687. engine: Engine;
  56688. private _captureGPUFrameTime;
  56689. private _gpuFrameTimeToken;
  56690. private _gpuFrameTime;
  56691. private _captureShaderCompilationTime;
  56692. private _shaderCompilationTime;
  56693. private _onBeginFrameObserver;
  56694. private _onEndFrameObserver;
  56695. private _onBeforeShaderCompilationObserver;
  56696. private _onAfterShaderCompilationObserver;
  56697. /**
  56698. * Gets the perf counter used for GPU frame time
  56699. */
  56700. get gpuFrameTimeCounter(): PerfCounter;
  56701. /**
  56702. * Gets the GPU frame time capture status
  56703. */
  56704. get captureGPUFrameTime(): boolean;
  56705. /**
  56706. * Enable or disable the GPU frame time capture
  56707. */
  56708. set captureGPUFrameTime(value: boolean);
  56709. /**
  56710. * Gets the perf counter used for shader compilation time
  56711. */
  56712. get shaderCompilationTimeCounter(): PerfCounter;
  56713. /**
  56714. * Gets the shader compilation time capture status
  56715. */
  56716. get captureShaderCompilationTime(): boolean;
  56717. /**
  56718. * Enable or disable the shader compilation time capture
  56719. */
  56720. set captureShaderCompilationTime(value: boolean);
  56721. /**
  56722. * Instantiates a new engine instrumentation.
  56723. * This class can be used to get instrumentation data from a Babylon engine
  56724. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56725. * @param engine Defines the engine to instrument
  56726. */
  56727. constructor(
  56728. /**
  56729. * Define the instrumented engine.
  56730. */
  56731. engine: Engine);
  56732. /**
  56733. * Dispose and release associated resources.
  56734. */
  56735. dispose(): void;
  56736. }
  56737. }
  56738. declare module BABYLON {
  56739. /**
  56740. * This class can be used to get instrumentation data from a Babylon engine
  56741. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56742. */
  56743. export class SceneInstrumentation implements IDisposable {
  56744. /**
  56745. * Defines the scene to instrument
  56746. */
  56747. scene: Scene;
  56748. private _captureActiveMeshesEvaluationTime;
  56749. private _activeMeshesEvaluationTime;
  56750. private _captureRenderTargetsRenderTime;
  56751. private _renderTargetsRenderTime;
  56752. private _captureFrameTime;
  56753. private _frameTime;
  56754. private _captureRenderTime;
  56755. private _renderTime;
  56756. private _captureInterFrameTime;
  56757. private _interFrameTime;
  56758. private _captureParticlesRenderTime;
  56759. private _particlesRenderTime;
  56760. private _captureSpritesRenderTime;
  56761. private _spritesRenderTime;
  56762. private _capturePhysicsTime;
  56763. private _physicsTime;
  56764. private _captureAnimationsTime;
  56765. private _animationsTime;
  56766. private _captureCameraRenderTime;
  56767. private _cameraRenderTime;
  56768. private _onBeforeActiveMeshesEvaluationObserver;
  56769. private _onAfterActiveMeshesEvaluationObserver;
  56770. private _onBeforeRenderTargetsRenderObserver;
  56771. private _onAfterRenderTargetsRenderObserver;
  56772. private _onAfterRenderObserver;
  56773. private _onBeforeDrawPhaseObserver;
  56774. private _onAfterDrawPhaseObserver;
  56775. private _onBeforeAnimationsObserver;
  56776. private _onBeforeParticlesRenderingObserver;
  56777. private _onAfterParticlesRenderingObserver;
  56778. private _onBeforeSpritesRenderingObserver;
  56779. private _onAfterSpritesRenderingObserver;
  56780. private _onBeforePhysicsObserver;
  56781. private _onAfterPhysicsObserver;
  56782. private _onAfterAnimationsObserver;
  56783. private _onBeforeCameraRenderObserver;
  56784. private _onAfterCameraRenderObserver;
  56785. /**
  56786. * Gets the perf counter used for active meshes evaluation time
  56787. */
  56788. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56789. /**
  56790. * Gets the active meshes evaluation time capture status
  56791. */
  56792. get captureActiveMeshesEvaluationTime(): boolean;
  56793. /**
  56794. * Enable or disable the active meshes evaluation time capture
  56795. */
  56796. set captureActiveMeshesEvaluationTime(value: boolean);
  56797. /**
  56798. * Gets the perf counter used for render targets render time
  56799. */
  56800. get renderTargetsRenderTimeCounter(): PerfCounter;
  56801. /**
  56802. * Gets the render targets render time capture status
  56803. */
  56804. get captureRenderTargetsRenderTime(): boolean;
  56805. /**
  56806. * Enable or disable the render targets render time capture
  56807. */
  56808. set captureRenderTargetsRenderTime(value: boolean);
  56809. /**
  56810. * Gets the perf counter used for particles render time
  56811. */
  56812. get particlesRenderTimeCounter(): PerfCounter;
  56813. /**
  56814. * Gets the particles render time capture status
  56815. */
  56816. get captureParticlesRenderTime(): boolean;
  56817. /**
  56818. * Enable or disable the particles render time capture
  56819. */
  56820. set captureParticlesRenderTime(value: boolean);
  56821. /**
  56822. * Gets the perf counter used for sprites render time
  56823. */
  56824. get spritesRenderTimeCounter(): PerfCounter;
  56825. /**
  56826. * Gets the sprites render time capture status
  56827. */
  56828. get captureSpritesRenderTime(): boolean;
  56829. /**
  56830. * Enable or disable the sprites render time capture
  56831. */
  56832. set captureSpritesRenderTime(value: boolean);
  56833. /**
  56834. * Gets the perf counter used for physics time
  56835. */
  56836. get physicsTimeCounter(): PerfCounter;
  56837. /**
  56838. * Gets the physics time capture status
  56839. */
  56840. get capturePhysicsTime(): boolean;
  56841. /**
  56842. * Enable or disable the physics time capture
  56843. */
  56844. set capturePhysicsTime(value: boolean);
  56845. /**
  56846. * Gets the perf counter used for animations time
  56847. */
  56848. get animationsTimeCounter(): PerfCounter;
  56849. /**
  56850. * Gets the animations time capture status
  56851. */
  56852. get captureAnimationsTime(): boolean;
  56853. /**
  56854. * Enable or disable the animations time capture
  56855. */
  56856. set captureAnimationsTime(value: boolean);
  56857. /**
  56858. * Gets the perf counter used for frame time capture
  56859. */
  56860. get frameTimeCounter(): PerfCounter;
  56861. /**
  56862. * Gets the frame time capture status
  56863. */
  56864. get captureFrameTime(): boolean;
  56865. /**
  56866. * Enable or disable the frame time capture
  56867. */
  56868. set captureFrameTime(value: boolean);
  56869. /**
  56870. * Gets the perf counter used for inter-frames time capture
  56871. */
  56872. get interFrameTimeCounter(): PerfCounter;
  56873. /**
  56874. * Gets the inter-frames time capture status
  56875. */
  56876. get captureInterFrameTime(): boolean;
  56877. /**
  56878. * Enable or disable the inter-frames time capture
  56879. */
  56880. set captureInterFrameTime(value: boolean);
  56881. /**
  56882. * Gets the perf counter used for render time capture
  56883. */
  56884. get renderTimeCounter(): PerfCounter;
  56885. /**
  56886. * Gets the render time capture status
  56887. */
  56888. get captureRenderTime(): boolean;
  56889. /**
  56890. * Enable or disable the render time capture
  56891. */
  56892. set captureRenderTime(value: boolean);
  56893. /**
  56894. * Gets the perf counter used for camera render time capture
  56895. */
  56896. get cameraRenderTimeCounter(): PerfCounter;
  56897. /**
  56898. * Gets the camera render time capture status
  56899. */
  56900. get captureCameraRenderTime(): boolean;
  56901. /**
  56902. * Enable or disable the camera render time capture
  56903. */
  56904. set captureCameraRenderTime(value: boolean);
  56905. /**
  56906. * Gets the perf counter used for draw calls
  56907. */
  56908. get drawCallsCounter(): PerfCounter;
  56909. /**
  56910. * Instantiates a new scene instrumentation.
  56911. * This class can be used to get instrumentation data from a Babylon engine
  56912. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56913. * @param scene Defines the scene to instrument
  56914. */
  56915. constructor(
  56916. /**
  56917. * Defines the scene to instrument
  56918. */
  56919. scene: Scene);
  56920. /**
  56921. * Dispose and release associated resources.
  56922. */
  56923. dispose(): void;
  56924. }
  56925. }
  56926. declare module BABYLON {
  56927. /** @hidden */
  56928. export var glowMapGenerationPixelShader: {
  56929. name: string;
  56930. shader: string;
  56931. };
  56932. }
  56933. declare module BABYLON {
  56934. /** @hidden */
  56935. export var glowMapGenerationVertexShader: {
  56936. name: string;
  56937. shader: string;
  56938. };
  56939. }
  56940. declare module BABYLON {
  56941. /**
  56942. * Effect layer options. This helps customizing the behaviour
  56943. * of the effect layer.
  56944. */
  56945. export interface IEffectLayerOptions {
  56946. /**
  56947. * Multiplication factor apply to the canvas size to compute the render target size
  56948. * used to generated the objects (the smaller the faster).
  56949. */
  56950. mainTextureRatio: number;
  56951. /**
  56952. * Enforces a fixed size texture to ensure effect stability across devices.
  56953. */
  56954. mainTextureFixedSize?: number;
  56955. /**
  56956. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56957. */
  56958. alphaBlendingMode: number;
  56959. /**
  56960. * The camera attached to the layer.
  56961. */
  56962. camera: Nullable<Camera>;
  56963. /**
  56964. * The rendering group to draw the layer in.
  56965. */
  56966. renderingGroupId: number;
  56967. }
  56968. /**
  56969. * The effect layer Helps adding post process effect blended with the main pass.
  56970. *
  56971. * This can be for instance use to generate glow or higlight effects on the scene.
  56972. *
  56973. * The effect layer class can not be used directly and is intented to inherited from to be
  56974. * customized per effects.
  56975. */
  56976. export abstract class EffectLayer {
  56977. private _vertexBuffers;
  56978. private _indexBuffer;
  56979. private _cachedDefines;
  56980. private _effectLayerMapGenerationEffect;
  56981. private _effectLayerOptions;
  56982. private _mergeEffect;
  56983. protected _scene: Scene;
  56984. protected _engine: Engine;
  56985. protected _maxSize: number;
  56986. protected _mainTextureDesiredSize: ISize;
  56987. protected _mainTexture: RenderTargetTexture;
  56988. protected _shouldRender: boolean;
  56989. protected _postProcesses: PostProcess[];
  56990. protected _textures: BaseTexture[];
  56991. protected _emissiveTextureAndColor: {
  56992. texture: Nullable<BaseTexture>;
  56993. color: Color4;
  56994. };
  56995. /**
  56996. * The name of the layer
  56997. */
  56998. name: string;
  56999. /**
  57000. * The clear color of the texture used to generate the glow map.
  57001. */
  57002. neutralColor: Color4;
  57003. /**
  57004. * Specifies whether the highlight layer is enabled or not.
  57005. */
  57006. isEnabled: boolean;
  57007. /**
  57008. * Gets the camera attached to the layer.
  57009. */
  57010. get camera(): Nullable<Camera>;
  57011. /**
  57012. * Gets the rendering group id the layer should render in.
  57013. */
  57014. get renderingGroupId(): number;
  57015. set renderingGroupId(renderingGroupId: number);
  57016. /**
  57017. * An event triggered when the effect layer has been disposed.
  57018. */
  57019. onDisposeObservable: Observable<EffectLayer>;
  57020. /**
  57021. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  57022. */
  57023. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  57024. /**
  57025. * An event triggered when the generated texture is being merged in the scene.
  57026. */
  57027. onBeforeComposeObservable: Observable<EffectLayer>;
  57028. /**
  57029. * An event triggered when the mesh is rendered into the effect render target.
  57030. */
  57031. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  57032. /**
  57033. * An event triggered after the mesh has been rendered into the effect render target.
  57034. */
  57035. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  57036. /**
  57037. * An event triggered when the generated texture has been merged in the scene.
  57038. */
  57039. onAfterComposeObservable: Observable<EffectLayer>;
  57040. /**
  57041. * An event triggered when the efffect layer changes its size.
  57042. */
  57043. onSizeChangedObservable: Observable<EffectLayer>;
  57044. /** @hidden */
  57045. static _SceneComponentInitialization: (scene: Scene) => void;
  57046. /**
  57047. * Instantiates a new effect Layer and references it in the scene.
  57048. * @param name The name of the layer
  57049. * @param scene The scene to use the layer in
  57050. */
  57051. constructor(
  57052. /** The Friendly of the effect in the scene */
  57053. name: string, scene: Scene);
  57054. /**
  57055. * Get the effect name of the layer.
  57056. * @return The effect name
  57057. */
  57058. abstract getEffectName(): string;
  57059. /**
  57060. * Checks for the readiness of the element composing the layer.
  57061. * @param subMesh the mesh to check for
  57062. * @param useInstances specify whether or not to use instances to render the mesh
  57063. * @return true if ready otherwise, false
  57064. */
  57065. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57066. /**
  57067. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57068. * @returns true if the effect requires stencil during the main canvas render pass.
  57069. */
  57070. abstract needStencil(): boolean;
  57071. /**
  57072. * Create the merge effect. This is the shader use to blit the information back
  57073. * to the main canvas at the end of the scene rendering.
  57074. * @returns The effect containing the shader used to merge the effect on the main canvas
  57075. */
  57076. protected abstract _createMergeEffect(): Effect;
  57077. /**
  57078. * Creates the render target textures and post processes used in the effect layer.
  57079. */
  57080. protected abstract _createTextureAndPostProcesses(): void;
  57081. /**
  57082. * Implementation specific of rendering the generating effect on the main canvas.
  57083. * @param effect The effect used to render through
  57084. */
  57085. protected abstract _internalRender(effect: Effect): void;
  57086. /**
  57087. * Sets the required values for both the emissive texture and and the main color.
  57088. */
  57089. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57090. /**
  57091. * Free any resources and references associated to a mesh.
  57092. * Internal use
  57093. * @param mesh The mesh to free.
  57094. */
  57095. abstract _disposeMesh(mesh: Mesh): void;
  57096. /**
  57097. * Serializes this layer (Glow or Highlight for example)
  57098. * @returns a serialized layer object
  57099. */
  57100. abstract serialize?(): any;
  57101. /**
  57102. * Initializes the effect layer with the required options.
  57103. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  57104. */
  57105. protected _init(options: Partial<IEffectLayerOptions>): void;
  57106. /**
  57107. * Generates the index buffer of the full screen quad blending to the main canvas.
  57108. */
  57109. private _generateIndexBuffer;
  57110. /**
  57111. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57112. */
  57113. private _generateVertexBuffer;
  57114. /**
  57115. * Sets the main texture desired size which is the closest power of two
  57116. * of the engine canvas size.
  57117. */
  57118. private _setMainTextureSize;
  57119. /**
  57120. * Creates the main texture for the effect layer.
  57121. */
  57122. protected _createMainTexture(): void;
  57123. /**
  57124. * Adds specific effects defines.
  57125. * @param defines The defines to add specifics to.
  57126. */
  57127. protected _addCustomEffectDefines(defines: string[]): void;
  57128. /**
  57129. * Checks for the readiness of the element composing the layer.
  57130. * @param subMesh the mesh to check for
  57131. * @param useInstances specify whether or not to use instances to render the mesh
  57132. * @param emissiveTexture the associated emissive texture used to generate the glow
  57133. * @return true if ready otherwise, false
  57134. */
  57135. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57136. /**
  57137. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57138. */
  57139. render(): void;
  57140. /**
  57141. * Determine if a given mesh will be used in the current effect.
  57142. * @param mesh mesh to test
  57143. * @returns true if the mesh will be used
  57144. */
  57145. hasMesh(mesh: AbstractMesh): boolean;
  57146. /**
  57147. * Returns true if the layer contains information to display, otherwise false.
  57148. * @returns true if the glow layer should be rendered
  57149. */
  57150. shouldRender(): boolean;
  57151. /**
  57152. * Returns true if the mesh should render, otherwise false.
  57153. * @param mesh The mesh to render
  57154. * @returns true if it should render otherwise false
  57155. */
  57156. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57157. /**
  57158. * Returns true if the mesh can be rendered, otherwise false.
  57159. * @param mesh The mesh to render
  57160. * @param material The material used on the mesh
  57161. * @returns true if it can be rendered otherwise false
  57162. */
  57163. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57164. /**
  57165. * Returns true if the mesh should render, otherwise false.
  57166. * @param mesh The mesh to render
  57167. * @returns true if it should render otherwise false
  57168. */
  57169. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57170. /**
  57171. * Renders the submesh passed in parameter to the generation map.
  57172. */
  57173. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57174. /**
  57175. * Defines whether the current material of the mesh should be use to render the effect.
  57176. * @param mesh defines the current mesh to render
  57177. */
  57178. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57179. /**
  57180. * Rebuild the required buffers.
  57181. * @hidden Internal use only.
  57182. */
  57183. _rebuild(): void;
  57184. /**
  57185. * Dispose only the render target textures and post process.
  57186. */
  57187. private _disposeTextureAndPostProcesses;
  57188. /**
  57189. * Dispose the highlight layer and free resources.
  57190. */
  57191. dispose(): void;
  57192. /**
  57193. * Gets the class name of the effect layer
  57194. * @returns the string with the class name of the effect layer
  57195. */
  57196. getClassName(): string;
  57197. /**
  57198. * Creates an effect layer from parsed effect layer data
  57199. * @param parsedEffectLayer defines effect layer data
  57200. * @param scene defines the current scene
  57201. * @param rootUrl defines the root URL containing the effect layer information
  57202. * @returns a parsed effect Layer
  57203. */
  57204. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57205. }
  57206. }
  57207. declare module BABYLON {
  57208. interface AbstractScene {
  57209. /**
  57210. * The list of effect layers (highlights/glow) added to the scene
  57211. * @see http://doc.babylonjs.com/how_to/highlight_layer
  57212. * @see http://doc.babylonjs.com/how_to/glow_layer
  57213. */
  57214. effectLayers: Array<EffectLayer>;
  57215. /**
  57216. * Removes the given effect layer from this scene.
  57217. * @param toRemove defines the effect layer to remove
  57218. * @returns the index of the removed effect layer
  57219. */
  57220. removeEffectLayer(toRemove: EffectLayer): number;
  57221. /**
  57222. * Adds the given effect layer to this scene
  57223. * @param newEffectLayer defines the effect layer to add
  57224. */
  57225. addEffectLayer(newEffectLayer: EffectLayer): void;
  57226. }
  57227. /**
  57228. * Defines the layer scene component responsible to manage any effect layers
  57229. * in a given scene.
  57230. */
  57231. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57232. /**
  57233. * The component name helpfull to identify the component in the list of scene components.
  57234. */
  57235. readonly name: string;
  57236. /**
  57237. * The scene the component belongs to.
  57238. */
  57239. scene: Scene;
  57240. private _engine;
  57241. private _renderEffects;
  57242. private _needStencil;
  57243. private _previousStencilState;
  57244. /**
  57245. * Creates a new instance of the component for the given scene
  57246. * @param scene Defines the scene to register the component in
  57247. */
  57248. constructor(scene: Scene);
  57249. /**
  57250. * Registers the component in a given scene
  57251. */
  57252. register(): void;
  57253. /**
  57254. * Rebuilds the elements related to this component in case of
  57255. * context lost for instance.
  57256. */
  57257. rebuild(): void;
  57258. /**
  57259. * Serializes the component data to the specified json object
  57260. * @param serializationObject The object to serialize to
  57261. */
  57262. serialize(serializationObject: any): void;
  57263. /**
  57264. * Adds all the elements from the container to the scene
  57265. * @param container the container holding the elements
  57266. */
  57267. addFromContainer(container: AbstractScene): void;
  57268. /**
  57269. * Removes all the elements in the container from the scene
  57270. * @param container contains the elements to remove
  57271. * @param dispose if the removed element should be disposed (default: false)
  57272. */
  57273. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57274. /**
  57275. * Disposes the component and the associated ressources.
  57276. */
  57277. dispose(): void;
  57278. private _isReadyForMesh;
  57279. private _renderMainTexture;
  57280. private _setStencil;
  57281. private _setStencilBack;
  57282. private _draw;
  57283. private _drawCamera;
  57284. private _drawRenderingGroup;
  57285. }
  57286. }
  57287. declare module BABYLON {
  57288. /** @hidden */
  57289. export var glowMapMergePixelShader: {
  57290. name: string;
  57291. shader: string;
  57292. };
  57293. }
  57294. declare module BABYLON {
  57295. /** @hidden */
  57296. export var glowMapMergeVertexShader: {
  57297. name: string;
  57298. shader: string;
  57299. };
  57300. }
  57301. declare module BABYLON {
  57302. interface AbstractScene {
  57303. /**
  57304. * Return a the first highlight layer of the scene with a given name.
  57305. * @param name The name of the highlight layer to look for.
  57306. * @return The highlight layer if found otherwise null.
  57307. */
  57308. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57309. }
  57310. /**
  57311. * Glow layer options. This helps customizing the behaviour
  57312. * of the glow layer.
  57313. */
  57314. export interface IGlowLayerOptions {
  57315. /**
  57316. * Multiplication factor apply to the canvas size to compute the render target size
  57317. * used to generated the glowing objects (the smaller the faster).
  57318. */
  57319. mainTextureRatio: number;
  57320. /**
  57321. * Enforces a fixed size texture to ensure resize independant blur.
  57322. */
  57323. mainTextureFixedSize?: number;
  57324. /**
  57325. * How big is the kernel of the blur texture.
  57326. */
  57327. blurKernelSize: number;
  57328. /**
  57329. * The camera attached to the layer.
  57330. */
  57331. camera: Nullable<Camera>;
  57332. /**
  57333. * Enable MSAA by chosing the number of samples.
  57334. */
  57335. mainTextureSamples?: number;
  57336. /**
  57337. * The rendering group to draw the layer in.
  57338. */
  57339. renderingGroupId: number;
  57340. }
  57341. /**
  57342. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57343. *
  57344. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57345. *
  57346. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57347. */
  57348. export class GlowLayer extends EffectLayer {
  57349. /**
  57350. * Effect Name of the layer.
  57351. */
  57352. static readonly EffectName: string;
  57353. /**
  57354. * The default blur kernel size used for the glow.
  57355. */
  57356. static DefaultBlurKernelSize: number;
  57357. /**
  57358. * The default texture size ratio used for the glow.
  57359. */
  57360. static DefaultTextureRatio: number;
  57361. /**
  57362. * Sets the kernel size of the blur.
  57363. */
  57364. set blurKernelSize(value: number);
  57365. /**
  57366. * Gets the kernel size of the blur.
  57367. */
  57368. get blurKernelSize(): number;
  57369. /**
  57370. * Sets the glow intensity.
  57371. */
  57372. set intensity(value: number);
  57373. /**
  57374. * Gets the glow intensity.
  57375. */
  57376. get intensity(): number;
  57377. private _options;
  57378. private _intensity;
  57379. private _horizontalBlurPostprocess1;
  57380. private _verticalBlurPostprocess1;
  57381. private _horizontalBlurPostprocess2;
  57382. private _verticalBlurPostprocess2;
  57383. private _blurTexture1;
  57384. private _blurTexture2;
  57385. private _postProcesses1;
  57386. private _postProcesses2;
  57387. private _includedOnlyMeshes;
  57388. private _excludedMeshes;
  57389. private _meshesUsingTheirOwnMaterials;
  57390. /**
  57391. * Callback used to let the user override the color selection on a per mesh basis
  57392. */
  57393. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57394. /**
  57395. * Callback used to let the user override the texture selection on a per mesh basis
  57396. */
  57397. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57398. /**
  57399. * Instantiates a new glow Layer and references it to the scene.
  57400. * @param name The name of the layer
  57401. * @param scene The scene to use the layer in
  57402. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57403. */
  57404. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57405. /**
  57406. * Get the effect name of the layer.
  57407. * @return The effect name
  57408. */
  57409. getEffectName(): string;
  57410. /**
  57411. * Create the merge effect. This is the shader use to blit the information back
  57412. * to the main canvas at the end of the scene rendering.
  57413. */
  57414. protected _createMergeEffect(): Effect;
  57415. /**
  57416. * Creates the render target textures and post processes used in the glow layer.
  57417. */
  57418. protected _createTextureAndPostProcesses(): void;
  57419. /**
  57420. * Checks for the readiness of the element composing the layer.
  57421. * @param subMesh the mesh to check for
  57422. * @param useInstances specify wether or not to use instances to render the mesh
  57423. * @param emissiveTexture the associated emissive texture used to generate the glow
  57424. * @return true if ready otherwise, false
  57425. */
  57426. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57427. /**
  57428. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57429. */
  57430. needStencil(): boolean;
  57431. /**
  57432. * Returns true if the mesh can be rendered, otherwise false.
  57433. * @param mesh The mesh to render
  57434. * @param material The material used on the mesh
  57435. * @returns true if it can be rendered otherwise false
  57436. */
  57437. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57438. /**
  57439. * Implementation specific of rendering the generating effect on the main canvas.
  57440. * @param effect The effect used to render through
  57441. */
  57442. protected _internalRender(effect: Effect): void;
  57443. /**
  57444. * Sets the required values for both the emissive texture and and the main color.
  57445. */
  57446. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57447. /**
  57448. * Returns true if the mesh should render, otherwise false.
  57449. * @param mesh The mesh to render
  57450. * @returns true if it should render otherwise false
  57451. */
  57452. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57453. /**
  57454. * Adds specific effects defines.
  57455. * @param defines The defines to add specifics to.
  57456. */
  57457. protected _addCustomEffectDefines(defines: string[]): void;
  57458. /**
  57459. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57460. * @param mesh The mesh to exclude from the glow layer
  57461. */
  57462. addExcludedMesh(mesh: Mesh): void;
  57463. /**
  57464. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57465. * @param mesh The mesh to remove
  57466. */
  57467. removeExcludedMesh(mesh: Mesh): void;
  57468. /**
  57469. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57470. * @param mesh The mesh to include in the glow layer
  57471. */
  57472. addIncludedOnlyMesh(mesh: Mesh): void;
  57473. /**
  57474. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57475. * @param mesh The mesh to remove
  57476. */
  57477. removeIncludedOnlyMesh(mesh: Mesh): void;
  57478. /**
  57479. * Determine if a given mesh will be used in the glow layer
  57480. * @param mesh The mesh to test
  57481. * @returns true if the mesh will be highlighted by the current glow layer
  57482. */
  57483. hasMesh(mesh: AbstractMesh): boolean;
  57484. /**
  57485. * Defines whether the current material of the mesh should be use to render the effect.
  57486. * @param mesh defines the current mesh to render
  57487. */
  57488. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57489. /**
  57490. * Add a mesh to be rendered through its own material and not with emissive only.
  57491. * @param mesh The mesh for which we need to use its material
  57492. */
  57493. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57494. /**
  57495. * Remove a mesh from being rendered through its own material and not with emissive only.
  57496. * @param mesh The mesh for which we need to not use its material
  57497. */
  57498. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57499. /**
  57500. * Free any resources and references associated to a mesh.
  57501. * Internal use
  57502. * @param mesh The mesh to free.
  57503. * @hidden
  57504. */
  57505. _disposeMesh(mesh: Mesh): void;
  57506. /**
  57507. * Gets the class name of the effect layer
  57508. * @returns the string with the class name of the effect layer
  57509. */
  57510. getClassName(): string;
  57511. /**
  57512. * Serializes this glow layer
  57513. * @returns a serialized glow layer object
  57514. */
  57515. serialize(): any;
  57516. /**
  57517. * Creates a Glow Layer from parsed glow layer data
  57518. * @param parsedGlowLayer defines glow layer data
  57519. * @param scene defines the current scene
  57520. * @param rootUrl defines the root URL containing the glow layer information
  57521. * @returns a parsed Glow Layer
  57522. */
  57523. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57524. }
  57525. }
  57526. declare module BABYLON {
  57527. /** @hidden */
  57528. export var glowBlurPostProcessPixelShader: {
  57529. name: string;
  57530. shader: string;
  57531. };
  57532. }
  57533. declare module BABYLON {
  57534. interface AbstractScene {
  57535. /**
  57536. * Return a the first highlight layer of the scene with a given name.
  57537. * @param name The name of the highlight layer to look for.
  57538. * @return The highlight layer if found otherwise null.
  57539. */
  57540. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57541. }
  57542. /**
  57543. * Highlight layer options. This helps customizing the behaviour
  57544. * of the highlight layer.
  57545. */
  57546. export interface IHighlightLayerOptions {
  57547. /**
  57548. * Multiplication factor apply to the canvas size to compute the render target size
  57549. * used to generated the glowing objects (the smaller the faster).
  57550. */
  57551. mainTextureRatio: number;
  57552. /**
  57553. * Enforces a fixed size texture to ensure resize independant blur.
  57554. */
  57555. mainTextureFixedSize?: number;
  57556. /**
  57557. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57558. * of the picture to blur (the smaller the faster).
  57559. */
  57560. blurTextureSizeRatio: number;
  57561. /**
  57562. * How big in texel of the blur texture is the vertical blur.
  57563. */
  57564. blurVerticalSize: number;
  57565. /**
  57566. * How big in texel of the blur texture is the horizontal blur.
  57567. */
  57568. blurHorizontalSize: number;
  57569. /**
  57570. * Alpha blending mode used to apply the blur. Default is combine.
  57571. */
  57572. alphaBlendingMode: number;
  57573. /**
  57574. * The camera attached to the layer.
  57575. */
  57576. camera: Nullable<Camera>;
  57577. /**
  57578. * Should we display highlight as a solid stroke?
  57579. */
  57580. isStroke?: boolean;
  57581. /**
  57582. * The rendering group to draw the layer in.
  57583. */
  57584. renderingGroupId: number;
  57585. }
  57586. /**
  57587. * The highlight layer Helps adding a glow effect around a mesh.
  57588. *
  57589. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57590. * glowy meshes to your scene.
  57591. *
  57592. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57593. */
  57594. export class HighlightLayer extends EffectLayer {
  57595. name: string;
  57596. /**
  57597. * Effect Name of the highlight layer.
  57598. */
  57599. static readonly EffectName: string;
  57600. /**
  57601. * The neutral color used during the preparation of the glow effect.
  57602. * This is black by default as the blend operation is a blend operation.
  57603. */
  57604. static NeutralColor: Color4;
  57605. /**
  57606. * Stencil value used for glowing meshes.
  57607. */
  57608. static GlowingMeshStencilReference: number;
  57609. /**
  57610. * Stencil value used for the other meshes in the scene.
  57611. */
  57612. static NormalMeshStencilReference: number;
  57613. /**
  57614. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57615. */
  57616. innerGlow: boolean;
  57617. /**
  57618. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57619. */
  57620. outerGlow: boolean;
  57621. /**
  57622. * Specifies the horizontal size of the blur.
  57623. */
  57624. set blurHorizontalSize(value: number);
  57625. /**
  57626. * Specifies the vertical size of the blur.
  57627. */
  57628. set blurVerticalSize(value: number);
  57629. /**
  57630. * Gets the horizontal size of the blur.
  57631. */
  57632. get blurHorizontalSize(): number;
  57633. /**
  57634. * Gets the vertical size of the blur.
  57635. */
  57636. get blurVerticalSize(): number;
  57637. /**
  57638. * An event triggered when the highlight layer is being blurred.
  57639. */
  57640. onBeforeBlurObservable: Observable<HighlightLayer>;
  57641. /**
  57642. * An event triggered when the highlight layer has been blurred.
  57643. */
  57644. onAfterBlurObservable: Observable<HighlightLayer>;
  57645. private _instanceGlowingMeshStencilReference;
  57646. private _options;
  57647. private _downSamplePostprocess;
  57648. private _horizontalBlurPostprocess;
  57649. private _verticalBlurPostprocess;
  57650. private _blurTexture;
  57651. private _meshes;
  57652. private _excludedMeshes;
  57653. /**
  57654. * Instantiates a new highlight Layer and references it to the scene..
  57655. * @param name The name of the layer
  57656. * @param scene The scene to use the layer in
  57657. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57658. */
  57659. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57660. /**
  57661. * Get the effect name of the layer.
  57662. * @return The effect name
  57663. */
  57664. getEffectName(): string;
  57665. /**
  57666. * Create the merge effect. This is the shader use to blit the information back
  57667. * to the main canvas at the end of the scene rendering.
  57668. */
  57669. protected _createMergeEffect(): Effect;
  57670. /**
  57671. * Creates the render target textures and post processes used in the highlight layer.
  57672. */
  57673. protected _createTextureAndPostProcesses(): void;
  57674. /**
  57675. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57676. */
  57677. needStencil(): boolean;
  57678. /**
  57679. * Checks for the readiness of the element composing the layer.
  57680. * @param subMesh the mesh to check for
  57681. * @param useInstances specify wether or not to use instances to render the mesh
  57682. * @param emissiveTexture the associated emissive texture used to generate the glow
  57683. * @return true if ready otherwise, false
  57684. */
  57685. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57686. /**
  57687. * Implementation specific of rendering the generating effect on the main canvas.
  57688. * @param effect The effect used to render through
  57689. */
  57690. protected _internalRender(effect: Effect): void;
  57691. /**
  57692. * Returns true if the layer contains information to display, otherwise false.
  57693. */
  57694. shouldRender(): boolean;
  57695. /**
  57696. * Returns true if the mesh should render, otherwise false.
  57697. * @param mesh The mesh to render
  57698. * @returns true if it should render otherwise false
  57699. */
  57700. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57701. /**
  57702. * Returns true if the mesh can be rendered, otherwise false.
  57703. * @param mesh The mesh to render
  57704. * @param material The material used on the mesh
  57705. * @returns true if it can be rendered otherwise false
  57706. */
  57707. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57708. /**
  57709. * Adds specific effects defines.
  57710. * @param defines The defines to add specifics to.
  57711. */
  57712. protected _addCustomEffectDefines(defines: string[]): void;
  57713. /**
  57714. * Sets the required values for both the emissive texture and and the main color.
  57715. */
  57716. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57717. /**
  57718. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57719. * @param mesh The mesh to exclude from the highlight layer
  57720. */
  57721. addExcludedMesh(mesh: Mesh): void;
  57722. /**
  57723. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57724. * @param mesh The mesh to highlight
  57725. */
  57726. removeExcludedMesh(mesh: Mesh): void;
  57727. /**
  57728. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57729. * @param mesh mesh to test
  57730. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57731. */
  57732. hasMesh(mesh: AbstractMesh): boolean;
  57733. /**
  57734. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57735. * @param mesh The mesh to highlight
  57736. * @param color The color of the highlight
  57737. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57738. */
  57739. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57740. /**
  57741. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57742. * @param mesh The mesh to highlight
  57743. */
  57744. removeMesh(mesh: Mesh): void;
  57745. /**
  57746. * Remove all the meshes currently referenced in the highlight layer
  57747. */
  57748. removeAllMeshes(): void;
  57749. /**
  57750. * Force the stencil to the normal expected value for none glowing parts
  57751. */
  57752. private _defaultStencilReference;
  57753. /**
  57754. * Free any resources and references associated to a mesh.
  57755. * Internal use
  57756. * @param mesh The mesh to free.
  57757. * @hidden
  57758. */
  57759. _disposeMesh(mesh: Mesh): void;
  57760. /**
  57761. * Dispose the highlight layer and free resources.
  57762. */
  57763. dispose(): void;
  57764. /**
  57765. * Gets the class name of the effect layer
  57766. * @returns the string with the class name of the effect layer
  57767. */
  57768. getClassName(): string;
  57769. /**
  57770. * Serializes this Highlight layer
  57771. * @returns a serialized Highlight layer object
  57772. */
  57773. serialize(): any;
  57774. /**
  57775. * Creates a Highlight layer from parsed Highlight layer data
  57776. * @param parsedHightlightLayer defines the Highlight layer data
  57777. * @param scene defines the current scene
  57778. * @param rootUrl defines the root URL containing the Highlight layer information
  57779. * @returns a parsed Highlight layer
  57780. */
  57781. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57782. }
  57783. }
  57784. declare module BABYLON {
  57785. interface AbstractScene {
  57786. /**
  57787. * The list of layers (background and foreground) of the scene
  57788. */
  57789. layers: Array<Layer>;
  57790. }
  57791. /**
  57792. * Defines the layer scene component responsible to manage any layers
  57793. * in a given scene.
  57794. */
  57795. export class LayerSceneComponent implements ISceneComponent {
  57796. /**
  57797. * The component name helpfull to identify the component in the list of scene components.
  57798. */
  57799. readonly name: string;
  57800. /**
  57801. * The scene the component belongs to.
  57802. */
  57803. scene: Scene;
  57804. private _engine;
  57805. /**
  57806. * Creates a new instance of the component for the given scene
  57807. * @param scene Defines the scene to register the component in
  57808. */
  57809. constructor(scene: Scene);
  57810. /**
  57811. * Registers the component in a given scene
  57812. */
  57813. register(): void;
  57814. /**
  57815. * Rebuilds the elements related to this component in case of
  57816. * context lost for instance.
  57817. */
  57818. rebuild(): void;
  57819. /**
  57820. * Disposes the component and the associated ressources.
  57821. */
  57822. dispose(): void;
  57823. private _draw;
  57824. private _drawCameraPredicate;
  57825. private _drawCameraBackground;
  57826. private _drawCameraForeground;
  57827. private _drawRenderTargetPredicate;
  57828. private _drawRenderTargetBackground;
  57829. private _drawRenderTargetForeground;
  57830. /**
  57831. * Adds all the elements from the container to the scene
  57832. * @param container the container holding the elements
  57833. */
  57834. addFromContainer(container: AbstractScene): void;
  57835. /**
  57836. * Removes all the elements in the container from the scene
  57837. * @param container contains the elements to remove
  57838. * @param dispose if the removed element should be disposed (default: false)
  57839. */
  57840. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57841. }
  57842. }
  57843. declare module BABYLON {
  57844. /** @hidden */
  57845. export var layerPixelShader: {
  57846. name: string;
  57847. shader: string;
  57848. };
  57849. }
  57850. declare module BABYLON {
  57851. /** @hidden */
  57852. export var layerVertexShader: {
  57853. name: string;
  57854. shader: string;
  57855. };
  57856. }
  57857. declare module BABYLON {
  57858. /**
  57859. * This represents a full screen 2d layer.
  57860. * This can be useful to display a picture in the background of your scene for instance.
  57861. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57862. */
  57863. export class Layer {
  57864. /**
  57865. * Define the name of the layer.
  57866. */
  57867. name: string;
  57868. /**
  57869. * Define the texture the layer should display.
  57870. */
  57871. texture: Nullable<Texture>;
  57872. /**
  57873. * Is the layer in background or foreground.
  57874. */
  57875. isBackground: boolean;
  57876. /**
  57877. * Define the color of the layer (instead of texture).
  57878. */
  57879. color: Color4;
  57880. /**
  57881. * Define the scale of the layer in order to zoom in out of the texture.
  57882. */
  57883. scale: Vector2;
  57884. /**
  57885. * Define an offset for the layer in order to shift the texture.
  57886. */
  57887. offset: Vector2;
  57888. /**
  57889. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57890. */
  57891. alphaBlendingMode: number;
  57892. /**
  57893. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57894. * Alpha test will not mix with the background color in case of transparency.
  57895. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57896. */
  57897. alphaTest: boolean;
  57898. /**
  57899. * Define a mask to restrict the layer to only some of the scene cameras.
  57900. */
  57901. layerMask: number;
  57902. /**
  57903. * Define the list of render target the layer is visible into.
  57904. */
  57905. renderTargetTextures: RenderTargetTexture[];
  57906. /**
  57907. * Define if the layer is only used in renderTarget or if it also
  57908. * renders in the main frame buffer of the canvas.
  57909. */
  57910. renderOnlyInRenderTargetTextures: boolean;
  57911. private _scene;
  57912. private _vertexBuffers;
  57913. private _indexBuffer;
  57914. private _effect;
  57915. private _previousDefines;
  57916. /**
  57917. * An event triggered when the layer is disposed.
  57918. */
  57919. onDisposeObservable: Observable<Layer>;
  57920. private _onDisposeObserver;
  57921. /**
  57922. * Back compatibility with callback before the onDisposeObservable existed.
  57923. * The set callback will be triggered when the layer has been disposed.
  57924. */
  57925. set onDispose(callback: () => void);
  57926. /**
  57927. * An event triggered before rendering the scene
  57928. */
  57929. onBeforeRenderObservable: Observable<Layer>;
  57930. private _onBeforeRenderObserver;
  57931. /**
  57932. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57933. * The set callback will be triggered just before rendering the layer.
  57934. */
  57935. set onBeforeRender(callback: () => void);
  57936. /**
  57937. * An event triggered after rendering the scene
  57938. */
  57939. onAfterRenderObservable: Observable<Layer>;
  57940. private _onAfterRenderObserver;
  57941. /**
  57942. * Back compatibility with callback before the onAfterRenderObservable existed.
  57943. * The set callback will be triggered just after rendering the layer.
  57944. */
  57945. set onAfterRender(callback: () => void);
  57946. /**
  57947. * Instantiates a new layer.
  57948. * This represents a full screen 2d layer.
  57949. * This can be useful to display a picture in the background of your scene for instance.
  57950. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57951. * @param name Define the name of the layer in the scene
  57952. * @param imgUrl Define the url of the texture to display in the layer
  57953. * @param scene Define the scene the layer belongs to
  57954. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57955. * @param color Defines a color for the layer
  57956. */
  57957. constructor(
  57958. /**
  57959. * Define the name of the layer.
  57960. */
  57961. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57962. private _createIndexBuffer;
  57963. /** @hidden */
  57964. _rebuild(): void;
  57965. /**
  57966. * Renders the layer in the scene.
  57967. */
  57968. render(): void;
  57969. /**
  57970. * Disposes and releases the associated ressources.
  57971. */
  57972. dispose(): void;
  57973. }
  57974. }
  57975. declare module BABYLON {
  57976. /** @hidden */
  57977. export var lensFlarePixelShader: {
  57978. name: string;
  57979. shader: string;
  57980. };
  57981. }
  57982. declare module BABYLON {
  57983. /** @hidden */
  57984. export var lensFlareVertexShader: {
  57985. name: string;
  57986. shader: string;
  57987. };
  57988. }
  57989. declare module BABYLON {
  57990. /**
  57991. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57992. * It is usually composed of several `lensFlare`.
  57993. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57994. */
  57995. export class LensFlareSystem {
  57996. /**
  57997. * Define the name of the lens flare system
  57998. */
  57999. name: string;
  58000. /**
  58001. * List of lens flares used in this system.
  58002. */
  58003. lensFlares: LensFlare[];
  58004. /**
  58005. * Define a limit from the border the lens flare can be visible.
  58006. */
  58007. borderLimit: number;
  58008. /**
  58009. * Define a viewport border we do not want to see the lens flare in.
  58010. */
  58011. viewportBorder: number;
  58012. /**
  58013. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58014. */
  58015. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58016. /**
  58017. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58018. */
  58019. layerMask: number;
  58020. /**
  58021. * Define the id of the lens flare system in the scene.
  58022. * (equal to name by default)
  58023. */
  58024. id: string;
  58025. private _scene;
  58026. private _emitter;
  58027. private _vertexBuffers;
  58028. private _indexBuffer;
  58029. private _effect;
  58030. private _positionX;
  58031. private _positionY;
  58032. private _isEnabled;
  58033. /** @hidden */
  58034. static _SceneComponentInitialization: (scene: Scene) => void;
  58035. /**
  58036. * Instantiates a lens flare system.
  58037. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58038. * It is usually composed of several `lensFlare`.
  58039. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58040. * @param name Define the name of the lens flare system in the scene
  58041. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  58042. * @param scene Define the scene the lens flare system belongs to
  58043. */
  58044. constructor(
  58045. /**
  58046. * Define the name of the lens flare system
  58047. */
  58048. name: string, emitter: any, scene: Scene);
  58049. /**
  58050. * Define if the lens flare system is enabled.
  58051. */
  58052. get isEnabled(): boolean;
  58053. set isEnabled(value: boolean);
  58054. /**
  58055. * Get the scene the effects belongs to.
  58056. * @returns the scene holding the lens flare system
  58057. */
  58058. getScene(): Scene;
  58059. /**
  58060. * Get the emitter of the lens flare system.
  58061. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58062. * @returns the emitter of the lens flare system
  58063. */
  58064. getEmitter(): any;
  58065. /**
  58066. * Set the emitter of the lens flare system.
  58067. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58068. * @param newEmitter Define the new emitter of the system
  58069. */
  58070. setEmitter(newEmitter: any): void;
  58071. /**
  58072. * Get the lens flare system emitter position.
  58073. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  58074. * @returns the position
  58075. */
  58076. getEmitterPosition(): Vector3;
  58077. /**
  58078. * @hidden
  58079. */
  58080. computeEffectivePosition(globalViewport: Viewport): boolean;
  58081. /** @hidden */
  58082. _isVisible(): boolean;
  58083. /**
  58084. * @hidden
  58085. */
  58086. render(): boolean;
  58087. /**
  58088. * Dispose and release the lens flare with its associated resources.
  58089. */
  58090. dispose(): void;
  58091. /**
  58092. * Parse a lens flare system from a JSON repressentation
  58093. * @param parsedLensFlareSystem Define the JSON to parse
  58094. * @param scene Define the scene the parsed system should be instantiated in
  58095. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  58096. * @returns the parsed system
  58097. */
  58098. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  58099. /**
  58100. * Serialize the current Lens Flare System into a JSON representation.
  58101. * @returns the serialized JSON
  58102. */
  58103. serialize(): any;
  58104. }
  58105. }
  58106. declare module BABYLON {
  58107. /**
  58108. * This represents one of the lens effect in a `lensFlareSystem`.
  58109. * It controls one of the indiviual texture used in the effect.
  58110. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58111. */
  58112. export class LensFlare {
  58113. /**
  58114. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58115. */
  58116. size: number;
  58117. /**
  58118. * 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.
  58119. */
  58120. position: number;
  58121. /**
  58122. * Define the lens color.
  58123. */
  58124. color: Color3;
  58125. /**
  58126. * Define the lens texture.
  58127. */
  58128. texture: Nullable<Texture>;
  58129. /**
  58130. * Define the alpha mode to render this particular lens.
  58131. */
  58132. alphaMode: number;
  58133. private _system;
  58134. /**
  58135. * Creates a new Lens Flare.
  58136. * This represents one of the lens effect in a `lensFlareSystem`.
  58137. * It controls one of the indiviual texture used in the effect.
  58138. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58139. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58140. * @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.
  58141. * @param color Define the lens color
  58142. * @param imgUrl Define the lens texture url
  58143. * @param system Define the `lensFlareSystem` this flare is part of
  58144. * @returns The newly created Lens Flare
  58145. */
  58146. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58147. /**
  58148. * Instantiates a new Lens Flare.
  58149. * This represents one of the lens effect in a `lensFlareSystem`.
  58150. * It controls one of the indiviual texture used in the effect.
  58151. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58152. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58153. * @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.
  58154. * @param color Define the lens color
  58155. * @param imgUrl Define the lens texture url
  58156. * @param system Define the `lensFlareSystem` this flare is part of
  58157. */
  58158. constructor(
  58159. /**
  58160. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58161. */
  58162. size: number,
  58163. /**
  58164. * 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.
  58165. */
  58166. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58167. /**
  58168. * Dispose and release the lens flare with its associated resources.
  58169. */
  58170. dispose(): void;
  58171. }
  58172. }
  58173. declare module BABYLON {
  58174. interface AbstractScene {
  58175. /**
  58176. * The list of lens flare system added to the scene
  58177. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58178. */
  58179. lensFlareSystems: Array<LensFlareSystem>;
  58180. /**
  58181. * Removes the given lens flare system from this scene.
  58182. * @param toRemove The lens flare system to remove
  58183. * @returns The index of the removed lens flare system
  58184. */
  58185. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58186. /**
  58187. * Adds the given lens flare system to this scene
  58188. * @param newLensFlareSystem The lens flare system to add
  58189. */
  58190. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58191. /**
  58192. * Gets a lens flare system using its name
  58193. * @param name defines the name to look for
  58194. * @returns the lens flare system or null if not found
  58195. */
  58196. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58197. /**
  58198. * Gets a lens flare system using its id
  58199. * @param id defines the id to look for
  58200. * @returns the lens flare system or null if not found
  58201. */
  58202. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58203. }
  58204. /**
  58205. * Defines the lens flare scene component responsible to manage any lens flares
  58206. * in a given scene.
  58207. */
  58208. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58209. /**
  58210. * The component name helpfull to identify the component in the list of scene components.
  58211. */
  58212. readonly name: string;
  58213. /**
  58214. * The scene the component belongs to.
  58215. */
  58216. scene: Scene;
  58217. /**
  58218. * Creates a new instance of the component for the given scene
  58219. * @param scene Defines the scene to register the component in
  58220. */
  58221. constructor(scene: Scene);
  58222. /**
  58223. * Registers the component in a given scene
  58224. */
  58225. register(): void;
  58226. /**
  58227. * Rebuilds the elements related to this component in case of
  58228. * context lost for instance.
  58229. */
  58230. rebuild(): void;
  58231. /**
  58232. * Adds all the elements from the container to the scene
  58233. * @param container the container holding the elements
  58234. */
  58235. addFromContainer(container: AbstractScene): void;
  58236. /**
  58237. * Removes all the elements in the container from the scene
  58238. * @param container contains the elements to remove
  58239. * @param dispose if the removed element should be disposed (default: false)
  58240. */
  58241. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58242. /**
  58243. * Serializes the component data to the specified json object
  58244. * @param serializationObject The object to serialize to
  58245. */
  58246. serialize(serializationObject: any): void;
  58247. /**
  58248. * Disposes the component and the associated ressources.
  58249. */
  58250. dispose(): void;
  58251. private _draw;
  58252. }
  58253. }
  58254. declare module BABYLON {
  58255. /** @hidden */
  58256. export var depthPixelShader: {
  58257. name: string;
  58258. shader: string;
  58259. };
  58260. }
  58261. declare module BABYLON {
  58262. /** @hidden */
  58263. export var depthVertexShader: {
  58264. name: string;
  58265. shader: string;
  58266. };
  58267. }
  58268. declare module BABYLON {
  58269. /**
  58270. * This represents a depth renderer in Babylon.
  58271. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58272. */
  58273. export class DepthRenderer {
  58274. private _scene;
  58275. private _depthMap;
  58276. private _effect;
  58277. private readonly _storeNonLinearDepth;
  58278. private readonly _clearColor;
  58279. /** Get if the depth renderer is using packed depth or not */
  58280. readonly isPacked: boolean;
  58281. private _cachedDefines;
  58282. private _camera;
  58283. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58284. enabled: boolean;
  58285. /**
  58286. * Specifiess that the depth renderer will only be used within
  58287. * the camera it is created for.
  58288. * This can help forcing its rendering during the camera processing.
  58289. */
  58290. useOnlyInActiveCamera: boolean;
  58291. /** @hidden */
  58292. static _SceneComponentInitialization: (scene: Scene) => void;
  58293. /**
  58294. * Instantiates a depth renderer
  58295. * @param scene The scene the renderer belongs to
  58296. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58297. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58298. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58299. */
  58300. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58301. /**
  58302. * Creates the depth rendering effect and checks if the effect is ready.
  58303. * @param subMesh The submesh to be used to render the depth map of
  58304. * @param useInstances If multiple world instances should be used
  58305. * @returns if the depth renderer is ready to render the depth map
  58306. */
  58307. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58308. /**
  58309. * Gets the texture which the depth map will be written to.
  58310. * @returns The depth map texture
  58311. */
  58312. getDepthMap(): RenderTargetTexture;
  58313. /**
  58314. * Disposes of the depth renderer.
  58315. */
  58316. dispose(): void;
  58317. }
  58318. }
  58319. declare module BABYLON {
  58320. /** @hidden */
  58321. export var minmaxReduxPixelShader: {
  58322. name: string;
  58323. shader: string;
  58324. };
  58325. }
  58326. declare module BABYLON {
  58327. /**
  58328. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58329. * and maximum values from all values of the texture.
  58330. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58331. * The source values are read from the red channel of the texture.
  58332. */
  58333. export class MinMaxReducer {
  58334. /**
  58335. * Observable triggered when the computation has been performed
  58336. */
  58337. onAfterReductionPerformed: Observable<{
  58338. min: number;
  58339. max: number;
  58340. }>;
  58341. protected _camera: Camera;
  58342. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58343. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58344. protected _postProcessManager: PostProcessManager;
  58345. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58346. protected _forceFullscreenViewport: boolean;
  58347. /**
  58348. * Creates a min/max reducer
  58349. * @param camera The camera to use for the post processes
  58350. */
  58351. constructor(camera: Camera);
  58352. /**
  58353. * Gets the texture used to read the values from.
  58354. */
  58355. get sourceTexture(): Nullable<RenderTargetTexture>;
  58356. /**
  58357. * Sets the source texture to read the values from.
  58358. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58359. * because in such textures '1' value must not be taken into account to compute the maximum
  58360. * as this value is used to clear the texture.
  58361. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58362. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58363. * @param depthRedux Indicates if the texture is a depth texture or not
  58364. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58365. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58366. */
  58367. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58368. /**
  58369. * Defines the refresh rate of the computation.
  58370. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58371. */
  58372. get refreshRate(): number;
  58373. set refreshRate(value: number);
  58374. protected _activated: boolean;
  58375. /**
  58376. * Gets the activation status of the reducer
  58377. */
  58378. get activated(): boolean;
  58379. /**
  58380. * Activates the reduction computation.
  58381. * When activated, the observers registered in onAfterReductionPerformed are
  58382. * called after the compuation is performed
  58383. */
  58384. activate(): void;
  58385. /**
  58386. * Deactivates the reduction computation.
  58387. */
  58388. deactivate(): void;
  58389. /**
  58390. * Disposes the min/max reducer
  58391. * @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.
  58392. */
  58393. dispose(disposeAll?: boolean): void;
  58394. }
  58395. }
  58396. declare module BABYLON {
  58397. /**
  58398. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58399. */
  58400. export class DepthReducer extends MinMaxReducer {
  58401. private _depthRenderer;
  58402. private _depthRendererId;
  58403. /**
  58404. * Gets the depth renderer used for the computation.
  58405. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58406. */
  58407. get depthRenderer(): Nullable<DepthRenderer>;
  58408. /**
  58409. * Creates a depth reducer
  58410. * @param camera The camera used to render the depth texture
  58411. */
  58412. constructor(camera: Camera);
  58413. /**
  58414. * Sets the depth renderer to use to generate the depth map
  58415. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58416. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58417. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58418. */
  58419. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58420. /** @hidden */
  58421. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58422. /**
  58423. * Activates the reduction computation.
  58424. * When activated, the observers registered in onAfterReductionPerformed are
  58425. * called after the compuation is performed
  58426. */
  58427. activate(): void;
  58428. /**
  58429. * Deactivates the reduction computation.
  58430. */
  58431. deactivate(): void;
  58432. /**
  58433. * Disposes the depth reducer
  58434. * @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.
  58435. */
  58436. dispose(disposeAll?: boolean): void;
  58437. }
  58438. }
  58439. declare module BABYLON {
  58440. /**
  58441. * A CSM implementation allowing casting shadows on large scenes.
  58442. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58443. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58444. */
  58445. export class CascadedShadowGenerator extends ShadowGenerator {
  58446. private static readonly frustumCornersNDCSpace;
  58447. /**
  58448. * Name of the CSM class
  58449. */
  58450. static CLASSNAME: string;
  58451. /**
  58452. * Defines the default number of cascades used by the CSM.
  58453. */
  58454. static readonly DEFAULT_CASCADES_COUNT: number;
  58455. /**
  58456. * Defines the minimum number of cascades used by the CSM.
  58457. */
  58458. static readonly MIN_CASCADES_COUNT: number;
  58459. /**
  58460. * Defines the maximum number of cascades used by the CSM.
  58461. */
  58462. static readonly MAX_CASCADES_COUNT: number;
  58463. protected _validateFilter(filter: number): number;
  58464. /**
  58465. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58466. */
  58467. penumbraDarkness: number;
  58468. private _numCascades;
  58469. /**
  58470. * Gets or set the number of cascades used by the CSM.
  58471. */
  58472. get numCascades(): number;
  58473. set numCascades(value: number);
  58474. /**
  58475. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58476. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58477. */
  58478. stabilizeCascades: boolean;
  58479. private _freezeShadowCastersBoundingInfo;
  58480. private _freezeShadowCastersBoundingInfoObservable;
  58481. /**
  58482. * Enables or disables the shadow casters bounding info computation.
  58483. * If your shadow casters don't move, you can disable this feature.
  58484. * If it is enabled, the bounding box computation is done every frame.
  58485. */
  58486. get freezeShadowCastersBoundingInfo(): boolean;
  58487. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58488. private _scbiMin;
  58489. private _scbiMax;
  58490. protected _computeShadowCastersBoundingInfo(): void;
  58491. protected _shadowCastersBoundingInfo: BoundingInfo;
  58492. /**
  58493. * Gets or sets the shadow casters bounding info.
  58494. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58495. * so that the system won't overwrite the bounds you provide
  58496. */
  58497. get shadowCastersBoundingInfo(): BoundingInfo;
  58498. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58499. protected _breaksAreDirty: boolean;
  58500. protected _minDistance: number;
  58501. protected _maxDistance: number;
  58502. /**
  58503. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58504. *
  58505. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58506. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58507. * @param min minimal distance for the breaks (default to 0.)
  58508. * @param max maximal distance for the breaks (default to 1.)
  58509. */
  58510. setMinMaxDistance(min: number, max: number): void;
  58511. /** Gets the minimal distance used in the cascade break computation */
  58512. get minDistance(): number;
  58513. /** Gets the maximal distance used in the cascade break computation */
  58514. get maxDistance(): number;
  58515. /**
  58516. * Gets the class name of that object
  58517. * @returns "CascadedShadowGenerator"
  58518. */
  58519. getClassName(): string;
  58520. private _cascadeMinExtents;
  58521. private _cascadeMaxExtents;
  58522. /**
  58523. * Gets a cascade minimum extents
  58524. * @param cascadeIndex index of the cascade
  58525. * @returns the minimum cascade extents
  58526. */
  58527. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58528. /**
  58529. * Gets a cascade maximum extents
  58530. * @param cascadeIndex index of the cascade
  58531. * @returns the maximum cascade extents
  58532. */
  58533. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58534. private _cascades;
  58535. private _currentLayer;
  58536. private _viewSpaceFrustumsZ;
  58537. private _viewMatrices;
  58538. private _projectionMatrices;
  58539. private _transformMatrices;
  58540. private _transformMatricesAsArray;
  58541. private _frustumLengths;
  58542. private _lightSizeUVCorrection;
  58543. private _depthCorrection;
  58544. private _frustumCornersWorldSpace;
  58545. private _frustumCenter;
  58546. private _shadowCameraPos;
  58547. private _shadowMaxZ;
  58548. /**
  58549. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58550. * It defaults to camera.maxZ
  58551. */
  58552. get shadowMaxZ(): number;
  58553. /**
  58554. * Sets the shadow max z distance.
  58555. */
  58556. set shadowMaxZ(value: number);
  58557. protected _debug: boolean;
  58558. /**
  58559. * Gets or sets the debug flag.
  58560. * When enabled, the cascades are materialized by different colors on the screen.
  58561. */
  58562. get debug(): boolean;
  58563. set debug(dbg: boolean);
  58564. private _depthClamp;
  58565. /**
  58566. * Gets or sets the depth clamping value.
  58567. *
  58568. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58569. * to account for the shadow casters far away.
  58570. *
  58571. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58572. */
  58573. get depthClamp(): boolean;
  58574. set depthClamp(value: boolean);
  58575. private _cascadeBlendPercentage;
  58576. /**
  58577. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58578. * It defaults to 0.1 (10% blending).
  58579. */
  58580. get cascadeBlendPercentage(): number;
  58581. set cascadeBlendPercentage(value: number);
  58582. private _lambda;
  58583. /**
  58584. * Gets or set the lambda parameter.
  58585. * This parameter is used to split the camera frustum and create the cascades.
  58586. * 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.
  58587. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58588. */
  58589. get lambda(): number;
  58590. set lambda(value: number);
  58591. /**
  58592. * Gets the view matrix corresponding to a given cascade
  58593. * @param cascadeNum cascade to retrieve the view matrix from
  58594. * @returns the cascade view matrix
  58595. */
  58596. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58597. /**
  58598. * Gets the projection matrix corresponding to a given cascade
  58599. * @param cascadeNum cascade to retrieve the projection matrix from
  58600. * @returns the cascade projection matrix
  58601. */
  58602. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58603. /**
  58604. * Gets the transformation matrix corresponding to a given cascade
  58605. * @param cascadeNum cascade to retrieve the transformation matrix from
  58606. * @returns the cascade transformation matrix
  58607. */
  58608. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58609. private _depthRenderer;
  58610. /**
  58611. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58612. *
  58613. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58614. *
  58615. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58616. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58617. * @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
  58618. */
  58619. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58620. private _depthReducer;
  58621. private _autoCalcDepthBounds;
  58622. /**
  58623. * Gets or sets the autoCalcDepthBounds property.
  58624. *
  58625. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58626. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58627. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58628. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58629. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58630. */
  58631. get autoCalcDepthBounds(): boolean;
  58632. set autoCalcDepthBounds(value: boolean);
  58633. /**
  58634. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58635. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58636. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58637. * for setting the refresh rate on the renderer yourself!
  58638. */
  58639. get autoCalcDepthBoundsRefreshRate(): number;
  58640. set autoCalcDepthBoundsRefreshRate(value: number);
  58641. /**
  58642. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58643. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58644. * you change the camera near/far planes!
  58645. */
  58646. splitFrustum(): void;
  58647. private _splitFrustum;
  58648. private _computeMatrices;
  58649. private _computeFrustumInWorldSpace;
  58650. private _computeCascadeFrustum;
  58651. /**
  58652. * Support test.
  58653. */
  58654. static get IsSupported(): boolean;
  58655. /** @hidden */
  58656. static _SceneComponentInitialization: (scene: Scene) => void;
  58657. /**
  58658. * Creates a Cascaded Shadow Generator object.
  58659. * A ShadowGenerator is the required tool to use the shadows.
  58660. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58661. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58662. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58663. * @param light The directional light object generating the shadows.
  58664. * @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.
  58665. */
  58666. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58667. protected _initializeGenerator(): void;
  58668. protected _createTargetRenderTexture(): void;
  58669. protected _initializeShadowMap(): void;
  58670. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58671. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58672. /**
  58673. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58674. * @param defines Defines of the material we want to update
  58675. * @param lightIndex Index of the light in the enabled light list of the material
  58676. */
  58677. prepareDefines(defines: any, lightIndex: number): void;
  58678. /**
  58679. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58680. * defined in the generator but impacting the effect).
  58681. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58682. * @param effect The effect we are binfing the information for
  58683. */
  58684. bindShadowLight(lightIndex: string, effect: Effect): void;
  58685. /**
  58686. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58687. * (eq to view projection * shadow projection matrices)
  58688. * @returns The transform matrix used to create the shadow map
  58689. */
  58690. getTransformMatrix(): Matrix;
  58691. /**
  58692. * Disposes the ShadowGenerator.
  58693. * Returns nothing.
  58694. */
  58695. dispose(): void;
  58696. /**
  58697. * Serializes the shadow generator setup to a json object.
  58698. * @returns The serialized JSON object
  58699. */
  58700. serialize(): any;
  58701. /**
  58702. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58703. * @param parsedShadowGenerator The JSON object to parse
  58704. * @param scene The scene to create the shadow map for
  58705. * @returns The parsed shadow generator
  58706. */
  58707. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58708. }
  58709. }
  58710. declare module BABYLON {
  58711. /**
  58712. * Defines the shadow generator component responsible to manage any shadow generators
  58713. * in a given scene.
  58714. */
  58715. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58716. /**
  58717. * The component name helpfull to identify the component in the list of scene components.
  58718. */
  58719. readonly name: string;
  58720. /**
  58721. * The scene the component belongs to.
  58722. */
  58723. scene: Scene;
  58724. /**
  58725. * Creates a new instance of the component for the given scene
  58726. * @param scene Defines the scene to register the component in
  58727. */
  58728. constructor(scene: Scene);
  58729. /**
  58730. * Registers the component in a given scene
  58731. */
  58732. register(): void;
  58733. /**
  58734. * Rebuilds the elements related to this component in case of
  58735. * context lost for instance.
  58736. */
  58737. rebuild(): void;
  58738. /**
  58739. * Serializes the component data to the specified json object
  58740. * @param serializationObject The object to serialize to
  58741. */
  58742. serialize(serializationObject: any): void;
  58743. /**
  58744. * Adds all the elements from the container to the scene
  58745. * @param container the container holding the elements
  58746. */
  58747. addFromContainer(container: AbstractScene): void;
  58748. /**
  58749. * Removes all the elements in the container from the scene
  58750. * @param container contains the elements to remove
  58751. * @param dispose if the removed element should be disposed (default: false)
  58752. */
  58753. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58754. /**
  58755. * Rebuilds the elements related to this component in case of
  58756. * context lost for instance.
  58757. */
  58758. dispose(): void;
  58759. private _gatherRenderTargets;
  58760. }
  58761. }
  58762. declare module BABYLON {
  58763. /**
  58764. * A point light is a light defined by an unique point in world space.
  58765. * The light is emitted in every direction from this point.
  58766. * A good example of a point light is a standard light bulb.
  58767. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58768. */
  58769. export class PointLight extends ShadowLight {
  58770. private _shadowAngle;
  58771. /**
  58772. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58773. * This specifies what angle the shadow will use to be created.
  58774. *
  58775. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58776. */
  58777. get shadowAngle(): number;
  58778. /**
  58779. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58780. * This specifies what angle the shadow will use to be created.
  58781. *
  58782. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58783. */
  58784. set shadowAngle(value: number);
  58785. /**
  58786. * Gets the direction if it has been set.
  58787. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58788. */
  58789. get direction(): Vector3;
  58790. /**
  58791. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58792. */
  58793. set direction(value: Vector3);
  58794. /**
  58795. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58796. * A PointLight emits the light in every direction.
  58797. * It can cast shadows.
  58798. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58799. * ```javascript
  58800. * var pointLight = new PointLight("pl", camera.position, scene);
  58801. * ```
  58802. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58803. * @param name The light friendly name
  58804. * @param position The position of the point light in the scene
  58805. * @param scene The scene the lights belongs to
  58806. */
  58807. constructor(name: string, position: Vector3, scene: Scene);
  58808. /**
  58809. * Returns the string "PointLight"
  58810. * @returns the class name
  58811. */
  58812. getClassName(): string;
  58813. /**
  58814. * Returns the integer 0.
  58815. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58816. */
  58817. getTypeID(): number;
  58818. /**
  58819. * Specifies wether or not the shadowmap should be a cube texture.
  58820. * @returns true if the shadowmap needs to be a cube texture.
  58821. */
  58822. needCube(): boolean;
  58823. /**
  58824. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58825. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58826. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58827. */
  58828. getShadowDirection(faceIndex?: number): Vector3;
  58829. /**
  58830. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58831. * - fov = PI / 2
  58832. * - aspect ratio : 1.0
  58833. * - z-near and far equal to the active camera minZ and maxZ.
  58834. * Returns the PointLight.
  58835. */
  58836. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58837. protected _buildUniformLayout(): void;
  58838. /**
  58839. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58840. * @param effect The effect to update
  58841. * @param lightIndex The index of the light in the effect to update
  58842. * @returns The point light
  58843. */
  58844. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58845. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58846. /**
  58847. * Prepares the list of defines specific to the light type.
  58848. * @param defines the list of defines
  58849. * @param lightIndex defines the index of the light for the effect
  58850. */
  58851. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58852. }
  58853. }
  58854. declare module BABYLON {
  58855. /**
  58856. * Header information of HDR texture files.
  58857. */
  58858. export interface HDRInfo {
  58859. /**
  58860. * The height of the texture in pixels.
  58861. */
  58862. height: number;
  58863. /**
  58864. * The width of the texture in pixels.
  58865. */
  58866. width: number;
  58867. /**
  58868. * The index of the beginning of the data in the binary file.
  58869. */
  58870. dataPosition: number;
  58871. }
  58872. /**
  58873. * This groups tools to convert HDR texture to native colors array.
  58874. */
  58875. export class HDRTools {
  58876. private static Ldexp;
  58877. private static Rgbe2float;
  58878. private static readStringLine;
  58879. /**
  58880. * Reads header information from an RGBE texture stored in a native array.
  58881. * More information on this format are available here:
  58882. * https://en.wikipedia.org/wiki/RGBE_image_format
  58883. *
  58884. * @param uint8array The binary file stored in native array.
  58885. * @return The header information.
  58886. */
  58887. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58888. /**
  58889. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58890. * This RGBE texture needs to store the information as a panorama.
  58891. *
  58892. * More information on this format are available here:
  58893. * https://en.wikipedia.org/wiki/RGBE_image_format
  58894. *
  58895. * @param buffer The binary file stored in an array buffer.
  58896. * @param size The expected size of the extracted cubemap.
  58897. * @return The Cube Map information.
  58898. */
  58899. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58900. /**
  58901. * Returns the pixels data extracted from an RGBE texture.
  58902. * This pixels will be stored left to right up to down in the R G B order in one array.
  58903. *
  58904. * More information on this format are available here:
  58905. * https://en.wikipedia.org/wiki/RGBE_image_format
  58906. *
  58907. * @param uint8array The binary file stored in an array buffer.
  58908. * @param hdrInfo The header information of the file.
  58909. * @return The pixels data in RGB right to left up to down order.
  58910. */
  58911. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58912. private static RGBE_ReadPixels_RLE;
  58913. }
  58914. }
  58915. declare module BABYLON {
  58916. /**
  58917. * Effect Render Options
  58918. */
  58919. export interface IEffectRendererOptions {
  58920. /**
  58921. * Defines the vertices positions.
  58922. */
  58923. positions?: number[];
  58924. /**
  58925. * Defines the indices.
  58926. */
  58927. indices?: number[];
  58928. }
  58929. /**
  58930. * Helper class to render one or more effects.
  58931. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58932. */
  58933. export class EffectRenderer {
  58934. private engine;
  58935. private static _DefaultOptions;
  58936. private _vertexBuffers;
  58937. private _indexBuffer;
  58938. private _fullscreenViewport;
  58939. /**
  58940. * Creates an effect renderer
  58941. * @param engine the engine to use for rendering
  58942. * @param options defines the options of the effect renderer
  58943. */
  58944. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58945. /**
  58946. * Sets the current viewport in normalized coordinates 0-1
  58947. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58948. */
  58949. setViewport(viewport?: Viewport): void;
  58950. /**
  58951. * Binds the embedded attributes buffer to the effect.
  58952. * @param effect Defines the effect to bind the attributes for
  58953. */
  58954. bindBuffers(effect: Effect): void;
  58955. /**
  58956. * Sets the current effect wrapper to use during draw.
  58957. * The effect needs to be ready before calling this api.
  58958. * This also sets the default full screen position attribute.
  58959. * @param effectWrapper Defines the effect to draw with
  58960. */
  58961. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58962. /**
  58963. * Restores engine states
  58964. */
  58965. restoreStates(): void;
  58966. /**
  58967. * Draws a full screen quad.
  58968. */
  58969. draw(): void;
  58970. private isRenderTargetTexture;
  58971. /**
  58972. * renders one or more effects to a specified texture
  58973. * @param effectWrapper the effect to renderer
  58974. * @param outputTexture texture to draw to, if null it will render to the screen.
  58975. */
  58976. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58977. /**
  58978. * Disposes of the effect renderer
  58979. */
  58980. dispose(): void;
  58981. }
  58982. /**
  58983. * Options to create an EffectWrapper
  58984. */
  58985. interface EffectWrapperCreationOptions {
  58986. /**
  58987. * Engine to use to create the effect
  58988. */
  58989. engine: ThinEngine;
  58990. /**
  58991. * Fragment shader for the effect
  58992. */
  58993. fragmentShader: string;
  58994. /**
  58995. * Use the shader store instead of direct source code
  58996. */
  58997. useShaderStore?: boolean;
  58998. /**
  58999. * Vertex shader for the effect
  59000. */
  59001. vertexShader?: string;
  59002. /**
  59003. * Attributes to use in the shader
  59004. */
  59005. attributeNames?: Array<string>;
  59006. /**
  59007. * Uniforms to use in the shader
  59008. */
  59009. uniformNames?: Array<string>;
  59010. /**
  59011. * Texture sampler names to use in the shader
  59012. */
  59013. samplerNames?: Array<string>;
  59014. /**
  59015. * Defines to use in the shader
  59016. */
  59017. defines?: Array<string>;
  59018. /**
  59019. * Callback when effect is compiled
  59020. */
  59021. onCompiled?: Nullable<(effect: Effect) => void>;
  59022. /**
  59023. * The friendly name of the effect displayed in Spector.
  59024. */
  59025. name?: string;
  59026. }
  59027. /**
  59028. * Wraps an effect to be used for rendering
  59029. */
  59030. export class EffectWrapper {
  59031. /**
  59032. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59033. */
  59034. onApplyObservable: Observable<{}>;
  59035. /**
  59036. * The underlying effect
  59037. */
  59038. effect: Effect;
  59039. /**
  59040. * Creates an effect to be renderer
  59041. * @param creationOptions options to create the effect
  59042. */
  59043. constructor(creationOptions: EffectWrapperCreationOptions);
  59044. /**
  59045. * Disposes of the effect wrapper
  59046. */
  59047. dispose(): void;
  59048. }
  59049. }
  59050. declare module BABYLON {
  59051. /** @hidden */
  59052. export var hdrFilteringVertexShader: {
  59053. name: string;
  59054. shader: string;
  59055. };
  59056. }
  59057. declare module BABYLON {
  59058. /** @hidden */
  59059. export var hdrFilteringPixelShader: {
  59060. name: string;
  59061. shader: string;
  59062. };
  59063. }
  59064. declare module BABYLON {
  59065. /**
  59066. * Options for texture filtering
  59067. */
  59068. interface IHDRFilteringOptions {
  59069. /**
  59070. * Scales pixel intensity for the input HDR map.
  59071. */
  59072. hdrScale?: number;
  59073. /**
  59074. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  59075. */
  59076. quality?: number;
  59077. }
  59078. /**
  59079. * Filters HDR maps to get correct renderings of PBR reflections
  59080. */
  59081. export class HDRFiltering {
  59082. private _engine;
  59083. private _effectRenderer;
  59084. private _effectWrapper;
  59085. private _lodGenerationOffset;
  59086. private _lodGenerationScale;
  59087. /**
  59088. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  59089. * you care about baking speed.
  59090. */
  59091. quality: number;
  59092. /**
  59093. * Scales pixel intensity for the input HDR map.
  59094. */
  59095. hdrScale: number;
  59096. /**
  59097. * Instantiates HDR filter for reflection maps
  59098. *
  59099. * @param engine Thin engine
  59100. * @param options Options
  59101. */
  59102. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  59103. private _createRenderTarget;
  59104. private _prefilterInternal;
  59105. private _createEffect;
  59106. /**
  59107. * Get a value indicating if the filter is ready to be used
  59108. * @param texture Texture to filter
  59109. * @returns true if the filter is ready
  59110. */
  59111. isReady(texture: BaseTexture): boolean;
  59112. /**
  59113. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59114. * Prefiltering will be invoked at the end of next rendering pass.
  59115. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59116. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59117. * @param texture Texture to filter
  59118. * @param onFinished Callback when filtering is done
  59119. * @return Promise called when prefiltering is done
  59120. */
  59121. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59122. }
  59123. }
  59124. declare module BABYLON {
  59125. /**
  59126. * This represents a texture coming from an HDR input.
  59127. *
  59128. * The only supported format is currently panorama picture stored in RGBE format.
  59129. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59130. */
  59131. export class HDRCubeTexture extends BaseTexture {
  59132. private static _facesMapping;
  59133. private _generateHarmonics;
  59134. private _noMipmap;
  59135. private _prefilterOnLoad;
  59136. private _textureMatrix;
  59137. private _size;
  59138. private _onLoad;
  59139. private _onError;
  59140. /**
  59141. * The texture URL.
  59142. */
  59143. url: string;
  59144. /**
  59145. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59146. */
  59147. coordinatesMode: number;
  59148. protected _isBlocking: boolean;
  59149. /**
  59150. * Sets wether or not the texture is blocking during loading.
  59151. */
  59152. set isBlocking(value: boolean);
  59153. /**
  59154. * Gets wether or not the texture is blocking during loading.
  59155. */
  59156. get isBlocking(): boolean;
  59157. protected _rotationY: number;
  59158. /**
  59159. * Sets texture matrix rotation angle around Y axis in radians.
  59160. */
  59161. set rotationY(value: number);
  59162. /**
  59163. * Gets texture matrix rotation angle around Y axis radians.
  59164. */
  59165. get rotationY(): number;
  59166. /**
  59167. * Gets or sets the center of the bounding box associated with the cube texture
  59168. * It must define where the camera used to render the texture was set
  59169. */
  59170. boundingBoxPosition: Vector3;
  59171. private _boundingBoxSize;
  59172. /**
  59173. * Gets or sets the size of the bounding box associated with the cube texture
  59174. * When defined, the cubemap will switch to local mode
  59175. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59176. * @example https://www.babylonjs-playground.com/#RNASML
  59177. */
  59178. set boundingBoxSize(value: Vector3);
  59179. get boundingBoxSize(): Vector3;
  59180. /**
  59181. * Instantiates an HDRTexture from the following parameters.
  59182. *
  59183. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59184. * @param sceneOrEngine The scene or engine the texture will be used in
  59185. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59186. * @param noMipmap Forces to not generate the mipmap if true
  59187. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59188. * @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)
  59189. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59190. */
  59191. 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>);
  59192. /**
  59193. * Get the current class name of the texture useful for serialization or dynamic coding.
  59194. * @returns "HDRCubeTexture"
  59195. */
  59196. getClassName(): string;
  59197. /**
  59198. * Occurs when the file is raw .hdr file.
  59199. */
  59200. private loadTexture;
  59201. clone(): HDRCubeTexture;
  59202. delayLoad(): void;
  59203. /**
  59204. * Get the texture reflection matrix used to rotate/transform the reflection.
  59205. * @returns the reflection matrix
  59206. */
  59207. getReflectionTextureMatrix(): Matrix;
  59208. /**
  59209. * Set the texture reflection matrix used to rotate/transform the reflection.
  59210. * @param value Define the reflection matrix to set
  59211. */
  59212. setReflectionTextureMatrix(value: Matrix): void;
  59213. /**
  59214. * Parses a JSON representation of an HDR Texture in order to create the texture
  59215. * @param parsedTexture Define the JSON representation
  59216. * @param scene Define the scene the texture should be created in
  59217. * @param rootUrl Define the root url in case we need to load relative dependencies
  59218. * @returns the newly created texture after parsing
  59219. */
  59220. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59221. serialize(): any;
  59222. }
  59223. }
  59224. declare module BABYLON {
  59225. /**
  59226. * Class used to control physics engine
  59227. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59228. */
  59229. export class PhysicsEngine implements IPhysicsEngine {
  59230. private _physicsPlugin;
  59231. /**
  59232. * Global value used to control the smallest number supported by the simulation
  59233. */
  59234. static Epsilon: number;
  59235. private _impostors;
  59236. private _joints;
  59237. private _subTimeStep;
  59238. /**
  59239. * Gets the gravity vector used by the simulation
  59240. */
  59241. gravity: Vector3;
  59242. /**
  59243. * Factory used to create the default physics plugin.
  59244. * @returns The default physics plugin
  59245. */
  59246. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59247. /**
  59248. * Creates a new Physics Engine
  59249. * @param gravity defines the gravity vector used by the simulation
  59250. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59251. */
  59252. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59253. /**
  59254. * Sets the gravity vector used by the simulation
  59255. * @param gravity defines the gravity vector to use
  59256. */
  59257. setGravity(gravity: Vector3): void;
  59258. /**
  59259. * Set the time step of the physics engine.
  59260. * Default is 1/60.
  59261. * To slow it down, enter 1/600 for example.
  59262. * To speed it up, 1/30
  59263. * @param newTimeStep defines the new timestep to apply to this world.
  59264. */
  59265. setTimeStep(newTimeStep?: number): void;
  59266. /**
  59267. * Get the time step of the physics engine.
  59268. * @returns the current time step
  59269. */
  59270. getTimeStep(): number;
  59271. /**
  59272. * Set the sub time step of the physics engine.
  59273. * Default is 0 meaning there is no sub steps
  59274. * To increase physics resolution precision, set a small value (like 1 ms)
  59275. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59276. */
  59277. setSubTimeStep(subTimeStep?: number): void;
  59278. /**
  59279. * Get the sub time step of the physics engine.
  59280. * @returns the current sub time step
  59281. */
  59282. getSubTimeStep(): number;
  59283. /**
  59284. * Release all resources
  59285. */
  59286. dispose(): void;
  59287. /**
  59288. * Gets the name of the current physics plugin
  59289. * @returns the name of the plugin
  59290. */
  59291. getPhysicsPluginName(): string;
  59292. /**
  59293. * Adding a new impostor for the impostor tracking.
  59294. * This will be done by the impostor itself.
  59295. * @param impostor the impostor to add
  59296. */
  59297. addImpostor(impostor: PhysicsImpostor): void;
  59298. /**
  59299. * Remove an impostor from the engine.
  59300. * This impostor and its mesh will not longer be updated by the physics engine.
  59301. * @param impostor the impostor to remove
  59302. */
  59303. removeImpostor(impostor: PhysicsImpostor): void;
  59304. /**
  59305. * Add a joint to the physics engine
  59306. * @param mainImpostor defines the main impostor to which the joint is added.
  59307. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59308. * @param joint defines the joint that will connect both impostors.
  59309. */
  59310. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59311. /**
  59312. * Removes a joint from the simulation
  59313. * @param mainImpostor defines the impostor used with the joint
  59314. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59315. * @param joint defines the joint to remove
  59316. */
  59317. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59318. /**
  59319. * Called by the scene. No need to call it.
  59320. * @param delta defines the timespam between frames
  59321. */
  59322. _step(delta: number): void;
  59323. /**
  59324. * Gets the current plugin used to run the simulation
  59325. * @returns current plugin
  59326. */
  59327. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59328. /**
  59329. * Gets the list of physic impostors
  59330. * @returns an array of PhysicsImpostor
  59331. */
  59332. getImpostors(): Array<PhysicsImpostor>;
  59333. /**
  59334. * Gets the impostor for a physics enabled object
  59335. * @param object defines the object impersonated by the impostor
  59336. * @returns the PhysicsImpostor or null if not found
  59337. */
  59338. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59339. /**
  59340. * Gets the impostor for a physics body object
  59341. * @param body defines physics body used by the impostor
  59342. * @returns the PhysicsImpostor or null if not found
  59343. */
  59344. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59345. /**
  59346. * Does a raycast in the physics world
  59347. * @param from when should the ray start?
  59348. * @param to when should the ray end?
  59349. * @returns PhysicsRaycastResult
  59350. */
  59351. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59352. }
  59353. }
  59354. declare module BABYLON {
  59355. /** @hidden */
  59356. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59357. private _useDeltaForWorldStep;
  59358. world: any;
  59359. name: string;
  59360. private _physicsMaterials;
  59361. private _fixedTimeStep;
  59362. private _cannonRaycastResult;
  59363. private _raycastResult;
  59364. private _physicsBodysToRemoveAfterStep;
  59365. private _firstFrame;
  59366. BJSCANNON: any;
  59367. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59368. setGravity(gravity: Vector3): void;
  59369. setTimeStep(timeStep: number): void;
  59370. getTimeStep(): number;
  59371. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59372. private _removeMarkedPhysicsBodiesFromWorld;
  59373. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59374. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59375. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59376. private _processChildMeshes;
  59377. removePhysicsBody(impostor: PhysicsImpostor): void;
  59378. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59379. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59380. private _addMaterial;
  59381. private _checkWithEpsilon;
  59382. private _createShape;
  59383. private _createHeightmap;
  59384. private _minus90X;
  59385. private _plus90X;
  59386. private _tmpPosition;
  59387. private _tmpDeltaPosition;
  59388. private _tmpUnityRotation;
  59389. private _updatePhysicsBodyTransformation;
  59390. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59391. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59392. isSupported(): boolean;
  59393. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59394. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59395. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59396. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59397. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59398. getBodyMass(impostor: PhysicsImpostor): number;
  59399. getBodyFriction(impostor: PhysicsImpostor): number;
  59400. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59401. getBodyRestitution(impostor: PhysicsImpostor): number;
  59402. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59403. sleepBody(impostor: PhysicsImpostor): void;
  59404. wakeUpBody(impostor: PhysicsImpostor): void;
  59405. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59406. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59407. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59408. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59409. getRadius(impostor: PhysicsImpostor): number;
  59410. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59411. dispose(): void;
  59412. private _extendNamespace;
  59413. /**
  59414. * Does a raycast in the physics world
  59415. * @param from when should the ray start?
  59416. * @param to when should the ray end?
  59417. * @returns PhysicsRaycastResult
  59418. */
  59419. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59420. }
  59421. }
  59422. declare module BABYLON {
  59423. /** @hidden */
  59424. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59425. private _useDeltaForWorldStep;
  59426. world: any;
  59427. name: string;
  59428. BJSOIMO: any;
  59429. private _raycastResult;
  59430. private _fixedTimeStep;
  59431. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59432. setGravity(gravity: Vector3): void;
  59433. setTimeStep(timeStep: number): void;
  59434. getTimeStep(): number;
  59435. private _tmpImpostorsArray;
  59436. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59437. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59438. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59439. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59440. private _tmpPositionVector;
  59441. removePhysicsBody(impostor: PhysicsImpostor): void;
  59442. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59443. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59444. isSupported(): boolean;
  59445. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59446. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59447. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59448. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59449. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59450. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59451. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59452. getBodyMass(impostor: PhysicsImpostor): number;
  59453. getBodyFriction(impostor: PhysicsImpostor): number;
  59454. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59455. getBodyRestitution(impostor: PhysicsImpostor): number;
  59456. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59457. sleepBody(impostor: PhysicsImpostor): void;
  59458. wakeUpBody(impostor: PhysicsImpostor): void;
  59459. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59460. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59461. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59462. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59463. getRadius(impostor: PhysicsImpostor): number;
  59464. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59465. dispose(): void;
  59466. /**
  59467. * Does a raycast in the physics world
  59468. * @param from when should the ray start?
  59469. * @param to when should the ray end?
  59470. * @returns PhysicsRaycastResult
  59471. */
  59472. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59473. }
  59474. }
  59475. declare module BABYLON {
  59476. /**
  59477. * Class containing static functions to help procedurally build meshes
  59478. */
  59479. export class RibbonBuilder {
  59480. /**
  59481. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59482. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59483. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59484. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59485. * * 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
  59486. * * 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
  59487. * * 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
  59488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59489. * * 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
  59490. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59491. * * 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
  59492. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59493. * * 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
  59494. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59496. * @param name defines the name of the mesh
  59497. * @param options defines the options used to create the mesh
  59498. * @param scene defines the hosting scene
  59499. * @returns the ribbon mesh
  59500. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59502. */
  59503. static CreateRibbon(name: string, options: {
  59504. pathArray: Vector3[][];
  59505. closeArray?: boolean;
  59506. closePath?: boolean;
  59507. offset?: number;
  59508. updatable?: boolean;
  59509. sideOrientation?: number;
  59510. frontUVs?: Vector4;
  59511. backUVs?: Vector4;
  59512. instance?: Mesh;
  59513. invertUV?: boolean;
  59514. uvs?: Vector2[];
  59515. colors?: Color4[];
  59516. }, scene?: Nullable<Scene>): Mesh;
  59517. }
  59518. }
  59519. declare module BABYLON {
  59520. /**
  59521. * Class containing static functions to help procedurally build meshes
  59522. */
  59523. export class ShapeBuilder {
  59524. /**
  59525. * 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.
  59526. * * 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.
  59527. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59528. * * 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.
  59529. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59530. * * 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
  59531. * * 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
  59532. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59534. * * 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
  59535. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59537. * @param name defines the name of the mesh
  59538. * @param options defines the options used to create the mesh
  59539. * @param scene defines the hosting scene
  59540. * @returns the extruded shape mesh
  59541. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59542. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59543. */
  59544. static ExtrudeShape(name: string, options: {
  59545. shape: Vector3[];
  59546. path: Vector3[];
  59547. scale?: number;
  59548. rotation?: number;
  59549. cap?: number;
  59550. updatable?: boolean;
  59551. sideOrientation?: number;
  59552. frontUVs?: Vector4;
  59553. backUVs?: Vector4;
  59554. instance?: Mesh;
  59555. invertUV?: boolean;
  59556. }, scene?: Nullable<Scene>): Mesh;
  59557. /**
  59558. * Creates an custom extruded shape mesh.
  59559. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59560. * * 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.
  59561. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59562. * * 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
  59563. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59564. * * 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
  59565. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59566. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59567. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59568. * * 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
  59569. * * 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
  59570. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59572. * * 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
  59573. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59575. * @param name defines the name of the mesh
  59576. * @param options defines the options used to create the mesh
  59577. * @param scene defines the hosting scene
  59578. * @returns the custom extruded shape mesh
  59579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59580. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59581. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59582. */
  59583. static ExtrudeShapeCustom(name: string, options: {
  59584. shape: Vector3[];
  59585. path: Vector3[];
  59586. scaleFunction?: any;
  59587. rotationFunction?: any;
  59588. ribbonCloseArray?: boolean;
  59589. ribbonClosePath?: boolean;
  59590. cap?: number;
  59591. updatable?: boolean;
  59592. sideOrientation?: number;
  59593. frontUVs?: Vector4;
  59594. backUVs?: Vector4;
  59595. instance?: Mesh;
  59596. invertUV?: boolean;
  59597. }, scene?: Nullable<Scene>): Mesh;
  59598. private static _ExtrudeShapeGeneric;
  59599. }
  59600. }
  59601. declare module BABYLON {
  59602. /**
  59603. * AmmoJS Physics plugin
  59604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59605. * @see https://github.com/kripken/ammo.js/
  59606. */
  59607. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59608. private _useDeltaForWorldStep;
  59609. /**
  59610. * Reference to the Ammo library
  59611. */
  59612. bjsAMMO: any;
  59613. /**
  59614. * Created ammoJS world which physics bodies are added to
  59615. */
  59616. world: any;
  59617. /**
  59618. * Name of the plugin
  59619. */
  59620. name: string;
  59621. private _timeStep;
  59622. private _fixedTimeStep;
  59623. private _maxSteps;
  59624. private _tmpQuaternion;
  59625. private _tmpAmmoTransform;
  59626. private _tmpAmmoQuaternion;
  59627. private _tmpAmmoConcreteContactResultCallback;
  59628. private _collisionConfiguration;
  59629. private _dispatcher;
  59630. private _overlappingPairCache;
  59631. private _solver;
  59632. private _softBodySolver;
  59633. private _tmpAmmoVectorA;
  59634. private _tmpAmmoVectorB;
  59635. private _tmpAmmoVectorC;
  59636. private _tmpAmmoVectorD;
  59637. private _tmpContactCallbackResult;
  59638. private _tmpAmmoVectorRCA;
  59639. private _tmpAmmoVectorRCB;
  59640. private _raycastResult;
  59641. private static readonly DISABLE_COLLISION_FLAG;
  59642. private static readonly KINEMATIC_FLAG;
  59643. private static readonly DISABLE_DEACTIVATION_FLAG;
  59644. /**
  59645. * Initializes the ammoJS plugin
  59646. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59647. * @param ammoInjection can be used to inject your own ammo reference
  59648. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59649. */
  59650. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59651. /**
  59652. * Sets the gravity of the physics world (m/(s^2))
  59653. * @param gravity Gravity to set
  59654. */
  59655. setGravity(gravity: Vector3): void;
  59656. /**
  59657. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59658. * @param timeStep timestep to use in seconds
  59659. */
  59660. setTimeStep(timeStep: number): void;
  59661. /**
  59662. * 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)
  59663. * @param fixedTimeStep fixedTimeStep to use in seconds
  59664. */
  59665. setFixedTimeStep(fixedTimeStep: number): void;
  59666. /**
  59667. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59668. * @param maxSteps the maximum number of steps by the physics engine per frame
  59669. */
  59670. setMaxSteps(maxSteps: number): void;
  59671. /**
  59672. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59673. * @returns the current timestep in seconds
  59674. */
  59675. getTimeStep(): number;
  59676. /**
  59677. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59678. */
  59679. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59680. private _isImpostorInContact;
  59681. private _isImpostorPairInContact;
  59682. private _stepSimulation;
  59683. /**
  59684. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59685. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59686. * After the step the babylon meshes are set to the position of the physics imposters
  59687. * @param delta amount of time to step forward
  59688. * @param impostors array of imposters to update before/after the step
  59689. */
  59690. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59691. /**
  59692. * Update babylon mesh to match physics world object
  59693. * @param impostor imposter to match
  59694. */
  59695. private _afterSoftStep;
  59696. /**
  59697. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59698. * @param impostor imposter to match
  59699. */
  59700. private _ropeStep;
  59701. /**
  59702. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59703. * @param impostor imposter to match
  59704. */
  59705. private _softbodyOrClothStep;
  59706. private _tmpMatrix;
  59707. /**
  59708. * Applies an impulse on the imposter
  59709. * @param impostor imposter to apply impulse to
  59710. * @param force amount of force to be applied to the imposter
  59711. * @param contactPoint the location to apply the impulse on the imposter
  59712. */
  59713. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59714. /**
  59715. * Applies a force on the imposter
  59716. * @param impostor imposter to apply force
  59717. * @param force amount of force to be applied to the imposter
  59718. * @param contactPoint the location to apply the force on the imposter
  59719. */
  59720. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59721. /**
  59722. * Creates a physics body using the plugin
  59723. * @param impostor the imposter to create the physics body on
  59724. */
  59725. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59726. /**
  59727. * Removes the physics body from the imposter and disposes of the body's memory
  59728. * @param impostor imposter to remove the physics body from
  59729. */
  59730. removePhysicsBody(impostor: PhysicsImpostor): void;
  59731. /**
  59732. * Generates a joint
  59733. * @param impostorJoint the imposter joint to create the joint with
  59734. */
  59735. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59736. /**
  59737. * Removes a joint
  59738. * @param impostorJoint the imposter joint to remove the joint from
  59739. */
  59740. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59741. private _addMeshVerts;
  59742. /**
  59743. * Initialise the soft body vertices to match its object's (mesh) vertices
  59744. * Softbody vertices (nodes) are in world space and to match this
  59745. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59746. * @param impostor to create the softbody for
  59747. */
  59748. private _softVertexData;
  59749. /**
  59750. * Create an impostor's soft body
  59751. * @param impostor to create the softbody for
  59752. */
  59753. private _createSoftbody;
  59754. /**
  59755. * Create cloth for an impostor
  59756. * @param impostor to create the softbody for
  59757. */
  59758. private _createCloth;
  59759. /**
  59760. * Create rope for an impostor
  59761. * @param impostor to create the softbody for
  59762. */
  59763. private _createRope;
  59764. /**
  59765. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59766. * @param impostor to create the custom physics shape for
  59767. */
  59768. private _createCustom;
  59769. private _addHullVerts;
  59770. private _createShape;
  59771. /**
  59772. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59773. * @param impostor imposter containing the physics body and babylon object
  59774. */
  59775. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59776. /**
  59777. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59778. * @param impostor imposter containing the physics body and babylon object
  59779. * @param newPosition new position
  59780. * @param newRotation new rotation
  59781. */
  59782. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59783. /**
  59784. * If this plugin is supported
  59785. * @returns true if its supported
  59786. */
  59787. isSupported(): boolean;
  59788. /**
  59789. * Sets the linear velocity of the physics body
  59790. * @param impostor imposter to set the velocity on
  59791. * @param velocity velocity to set
  59792. */
  59793. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59794. /**
  59795. * Sets the angular velocity of the physics body
  59796. * @param impostor imposter to set the velocity on
  59797. * @param velocity velocity to set
  59798. */
  59799. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59800. /**
  59801. * gets the linear velocity
  59802. * @param impostor imposter to get linear velocity from
  59803. * @returns linear velocity
  59804. */
  59805. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59806. /**
  59807. * gets the angular velocity
  59808. * @param impostor imposter to get angular velocity from
  59809. * @returns angular velocity
  59810. */
  59811. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59812. /**
  59813. * Sets the mass of physics body
  59814. * @param impostor imposter to set the mass on
  59815. * @param mass mass to set
  59816. */
  59817. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59818. /**
  59819. * Gets the mass of the physics body
  59820. * @param impostor imposter to get the mass from
  59821. * @returns mass
  59822. */
  59823. getBodyMass(impostor: PhysicsImpostor): number;
  59824. /**
  59825. * Gets friction of the impostor
  59826. * @param impostor impostor to get friction from
  59827. * @returns friction value
  59828. */
  59829. getBodyFriction(impostor: PhysicsImpostor): number;
  59830. /**
  59831. * Sets friction of the impostor
  59832. * @param impostor impostor to set friction on
  59833. * @param friction friction value
  59834. */
  59835. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59836. /**
  59837. * Gets restitution of the impostor
  59838. * @param impostor impostor to get restitution from
  59839. * @returns restitution value
  59840. */
  59841. getBodyRestitution(impostor: PhysicsImpostor): number;
  59842. /**
  59843. * Sets resitution of the impostor
  59844. * @param impostor impostor to set resitution on
  59845. * @param restitution resitution value
  59846. */
  59847. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59848. /**
  59849. * Gets pressure inside the impostor
  59850. * @param impostor impostor to get pressure from
  59851. * @returns pressure value
  59852. */
  59853. getBodyPressure(impostor: PhysicsImpostor): number;
  59854. /**
  59855. * Sets pressure inside a soft body impostor
  59856. * Cloth and rope must remain 0 pressure
  59857. * @param impostor impostor to set pressure on
  59858. * @param pressure pressure value
  59859. */
  59860. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59861. /**
  59862. * Gets stiffness of the impostor
  59863. * @param impostor impostor to get stiffness from
  59864. * @returns pressure value
  59865. */
  59866. getBodyStiffness(impostor: PhysicsImpostor): number;
  59867. /**
  59868. * Sets stiffness of the impostor
  59869. * @param impostor impostor to set stiffness on
  59870. * @param stiffness stiffness value from 0 to 1
  59871. */
  59872. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59873. /**
  59874. * Gets velocityIterations of the impostor
  59875. * @param impostor impostor to get velocity iterations from
  59876. * @returns velocityIterations value
  59877. */
  59878. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59879. /**
  59880. * Sets velocityIterations of the impostor
  59881. * @param impostor impostor to set velocity iterations on
  59882. * @param velocityIterations velocityIterations value
  59883. */
  59884. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59885. /**
  59886. * Gets positionIterations of the impostor
  59887. * @param impostor impostor to get position iterations from
  59888. * @returns positionIterations value
  59889. */
  59890. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59891. /**
  59892. * Sets positionIterations of the impostor
  59893. * @param impostor impostor to set position on
  59894. * @param positionIterations positionIterations value
  59895. */
  59896. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59897. /**
  59898. * Append an anchor to a cloth object
  59899. * @param impostor is the cloth impostor to add anchor to
  59900. * @param otherImpostor is the rigid impostor to anchor to
  59901. * @param width ratio across width from 0 to 1
  59902. * @param height ratio up height from 0 to 1
  59903. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59904. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59905. */
  59906. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59907. /**
  59908. * Append an hook to a rope object
  59909. * @param impostor is the rope impostor to add hook to
  59910. * @param otherImpostor is the rigid impostor to hook to
  59911. * @param length ratio along the rope from 0 to 1
  59912. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59913. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59914. */
  59915. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59916. /**
  59917. * Sleeps the physics body and stops it from being active
  59918. * @param impostor impostor to sleep
  59919. */
  59920. sleepBody(impostor: PhysicsImpostor): void;
  59921. /**
  59922. * Activates the physics body
  59923. * @param impostor impostor to activate
  59924. */
  59925. wakeUpBody(impostor: PhysicsImpostor): void;
  59926. /**
  59927. * Updates the distance parameters of the joint
  59928. * @param joint joint to update
  59929. * @param maxDistance maximum distance of the joint
  59930. * @param minDistance minimum distance of the joint
  59931. */
  59932. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59933. /**
  59934. * Sets a motor on the joint
  59935. * @param joint joint to set motor on
  59936. * @param speed speed of the motor
  59937. * @param maxForce maximum force of the motor
  59938. * @param motorIndex index of the motor
  59939. */
  59940. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59941. /**
  59942. * Sets the motors limit
  59943. * @param joint joint to set limit on
  59944. * @param upperLimit upper limit
  59945. * @param lowerLimit lower limit
  59946. */
  59947. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59948. /**
  59949. * Syncs the position and rotation of a mesh with the impostor
  59950. * @param mesh mesh to sync
  59951. * @param impostor impostor to update the mesh with
  59952. */
  59953. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59954. /**
  59955. * Gets the radius of the impostor
  59956. * @param impostor impostor to get radius from
  59957. * @returns the radius
  59958. */
  59959. getRadius(impostor: PhysicsImpostor): number;
  59960. /**
  59961. * Gets the box size of the impostor
  59962. * @param impostor impostor to get box size from
  59963. * @param result the resulting box size
  59964. */
  59965. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59966. /**
  59967. * Disposes of the impostor
  59968. */
  59969. dispose(): void;
  59970. /**
  59971. * Does a raycast in the physics world
  59972. * @param from when should the ray start?
  59973. * @param to when should the ray end?
  59974. * @returns PhysicsRaycastResult
  59975. */
  59976. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59977. }
  59978. }
  59979. declare module BABYLON {
  59980. interface AbstractScene {
  59981. /**
  59982. * The list of reflection probes added to the scene
  59983. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59984. */
  59985. reflectionProbes: Array<ReflectionProbe>;
  59986. /**
  59987. * Removes the given reflection probe from this scene.
  59988. * @param toRemove The reflection probe to remove
  59989. * @returns The index of the removed reflection probe
  59990. */
  59991. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59992. /**
  59993. * Adds the given reflection probe to this scene.
  59994. * @param newReflectionProbe The reflection probe to add
  59995. */
  59996. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59997. }
  59998. /**
  59999. * Class used to generate realtime reflection / refraction cube textures
  60000. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60001. */
  60002. export class ReflectionProbe {
  60003. /** defines the name of the probe */
  60004. name: string;
  60005. private _scene;
  60006. private _renderTargetTexture;
  60007. private _projectionMatrix;
  60008. private _viewMatrix;
  60009. private _target;
  60010. private _add;
  60011. private _attachedMesh;
  60012. private _invertYAxis;
  60013. /** Gets or sets probe position (center of the cube map) */
  60014. position: Vector3;
  60015. /**
  60016. * Creates a new reflection probe
  60017. * @param name defines the name of the probe
  60018. * @param size defines the texture resolution (for each face)
  60019. * @param scene defines the hosting scene
  60020. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60021. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60022. */
  60023. constructor(
  60024. /** defines the name of the probe */
  60025. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60026. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60027. get samples(): number;
  60028. set samples(value: number);
  60029. /** Gets or sets the refresh rate to use (on every frame by default) */
  60030. get refreshRate(): number;
  60031. set refreshRate(value: number);
  60032. /**
  60033. * Gets the hosting scene
  60034. * @returns a Scene
  60035. */
  60036. getScene(): Scene;
  60037. /** Gets the internal CubeTexture used to render to */
  60038. get cubeTexture(): RenderTargetTexture;
  60039. /** Gets the list of meshes to render */
  60040. get renderList(): Nullable<AbstractMesh[]>;
  60041. /**
  60042. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60043. * @param mesh defines the mesh to attach to
  60044. */
  60045. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60046. /**
  60047. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60048. * @param renderingGroupId The rendering group id corresponding to its index
  60049. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60050. */
  60051. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60052. /**
  60053. * Clean all associated resources
  60054. */
  60055. dispose(): void;
  60056. /**
  60057. * Converts the reflection probe information to a readable string for debug purpose.
  60058. * @param fullDetails Supports for multiple levels of logging within scene loading
  60059. * @returns the human readable reflection probe info
  60060. */
  60061. toString(fullDetails?: boolean): string;
  60062. /**
  60063. * Get the class name of the relfection probe.
  60064. * @returns "ReflectionProbe"
  60065. */
  60066. getClassName(): string;
  60067. /**
  60068. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60069. * @returns The JSON representation of the texture
  60070. */
  60071. serialize(): any;
  60072. /**
  60073. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60074. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60075. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60076. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60077. * @returns The parsed reflection probe if successful
  60078. */
  60079. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60080. }
  60081. }
  60082. declare module BABYLON {
  60083. /** @hidden */
  60084. export var _BabylonLoaderRegistered: boolean;
  60085. /**
  60086. * Helps setting up some configuration for the babylon file loader.
  60087. */
  60088. export class BabylonFileLoaderConfiguration {
  60089. /**
  60090. * The loader does not allow injecting custom physix engine into the plugins.
  60091. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60092. * So you could set this variable to your engine import to make it work.
  60093. */
  60094. static LoaderInjectedPhysicsEngine: any;
  60095. }
  60096. }
  60097. declare module BABYLON {
  60098. /**
  60099. * The Physically based simple base material of BJS.
  60100. *
  60101. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60102. * It is used as the base class for both the specGloss and metalRough conventions.
  60103. */
  60104. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60105. /**
  60106. * Number of Simultaneous lights allowed on the material.
  60107. */
  60108. maxSimultaneousLights: number;
  60109. /**
  60110. * If sets to true, disables all the lights affecting the material.
  60111. */
  60112. disableLighting: boolean;
  60113. /**
  60114. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60115. */
  60116. environmentTexture: BaseTexture;
  60117. /**
  60118. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60119. */
  60120. invertNormalMapX: boolean;
  60121. /**
  60122. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60123. */
  60124. invertNormalMapY: boolean;
  60125. /**
  60126. * Normal map used in the model.
  60127. */
  60128. normalTexture: BaseTexture;
  60129. /**
  60130. * Emissivie color used to self-illuminate the model.
  60131. */
  60132. emissiveColor: Color3;
  60133. /**
  60134. * Emissivie texture used to self-illuminate the model.
  60135. */
  60136. emissiveTexture: BaseTexture;
  60137. /**
  60138. * Occlusion Channel Strenght.
  60139. */
  60140. occlusionStrength: number;
  60141. /**
  60142. * Occlusion Texture of the material (adding extra occlusion effects).
  60143. */
  60144. occlusionTexture: BaseTexture;
  60145. /**
  60146. * Defines the alpha limits in alpha test mode.
  60147. */
  60148. alphaCutOff: number;
  60149. /**
  60150. * Gets the current double sided mode.
  60151. */
  60152. get doubleSided(): boolean;
  60153. /**
  60154. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60155. */
  60156. set doubleSided(value: boolean);
  60157. /**
  60158. * Stores the pre-calculated light information of a mesh in a texture.
  60159. */
  60160. lightmapTexture: BaseTexture;
  60161. /**
  60162. * If true, the light map contains occlusion information instead of lighting info.
  60163. */
  60164. useLightmapAsShadowmap: boolean;
  60165. /**
  60166. * Instantiates a new PBRMaterial instance.
  60167. *
  60168. * @param name The material name
  60169. * @param scene The scene the material will be use in.
  60170. */
  60171. constructor(name: string, scene: Scene);
  60172. getClassName(): string;
  60173. }
  60174. }
  60175. declare module BABYLON {
  60176. /**
  60177. * The PBR material of BJS following the metal roughness convention.
  60178. *
  60179. * This fits to the PBR convention in the GLTF definition:
  60180. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60181. */
  60182. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60183. /**
  60184. * The base color has two different interpretations depending on the value of metalness.
  60185. * When the material is a metal, the base color is the specific measured reflectance value
  60186. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60187. * of the material.
  60188. */
  60189. baseColor: Color3;
  60190. /**
  60191. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60192. * well as opacity information in the alpha channel.
  60193. */
  60194. baseTexture: BaseTexture;
  60195. /**
  60196. * Specifies the metallic scalar value of the material.
  60197. * Can also be used to scale the metalness values of the metallic texture.
  60198. */
  60199. metallic: number;
  60200. /**
  60201. * Specifies the roughness scalar value of the material.
  60202. * Can also be used to scale the roughness values of the metallic texture.
  60203. */
  60204. roughness: number;
  60205. /**
  60206. * Texture containing both the metallic value in the B channel and the
  60207. * roughness value in the G channel to keep better precision.
  60208. */
  60209. metallicRoughnessTexture: BaseTexture;
  60210. /**
  60211. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60212. *
  60213. * @param name The material name
  60214. * @param scene The scene the material will be use in.
  60215. */
  60216. constructor(name: string, scene: Scene);
  60217. /**
  60218. * Return the currrent class name of the material.
  60219. */
  60220. getClassName(): string;
  60221. /**
  60222. * Makes a duplicate of the current material.
  60223. * @param name - name to use for the new material.
  60224. */
  60225. clone(name: string): PBRMetallicRoughnessMaterial;
  60226. /**
  60227. * Serialize the material to a parsable JSON object.
  60228. */
  60229. serialize(): any;
  60230. /**
  60231. * Parses a JSON object correponding to the serialize function.
  60232. */
  60233. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60234. }
  60235. }
  60236. declare module BABYLON {
  60237. /**
  60238. * The PBR material of BJS following the specular glossiness convention.
  60239. *
  60240. * This fits to the PBR convention in the GLTF definition:
  60241. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60242. */
  60243. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60244. /**
  60245. * Specifies the diffuse color of the material.
  60246. */
  60247. diffuseColor: Color3;
  60248. /**
  60249. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60250. * channel.
  60251. */
  60252. diffuseTexture: BaseTexture;
  60253. /**
  60254. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60255. */
  60256. specularColor: Color3;
  60257. /**
  60258. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60259. */
  60260. glossiness: number;
  60261. /**
  60262. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60263. */
  60264. specularGlossinessTexture: BaseTexture;
  60265. /**
  60266. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60267. *
  60268. * @param name The material name
  60269. * @param scene The scene the material will be use in.
  60270. */
  60271. constructor(name: string, scene: Scene);
  60272. /**
  60273. * Return the currrent class name of the material.
  60274. */
  60275. getClassName(): string;
  60276. /**
  60277. * Makes a duplicate of the current material.
  60278. * @param name - name to use for the new material.
  60279. */
  60280. clone(name: string): PBRSpecularGlossinessMaterial;
  60281. /**
  60282. * Serialize the material to a parsable JSON object.
  60283. */
  60284. serialize(): any;
  60285. /**
  60286. * Parses a JSON object correponding to the serialize function.
  60287. */
  60288. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60289. }
  60290. }
  60291. declare module BABYLON {
  60292. /**
  60293. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60294. * It can help converting any input color in a desired output one. This can then be used to create effects
  60295. * from sepia, black and white to sixties or futuristic rendering...
  60296. *
  60297. * The only supported format is currently 3dl.
  60298. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60299. */
  60300. export class ColorGradingTexture extends BaseTexture {
  60301. /**
  60302. * The texture URL.
  60303. */
  60304. url: string;
  60305. /**
  60306. * Empty line regex stored for GC.
  60307. */
  60308. private static _noneEmptyLineRegex;
  60309. private _textureMatrix;
  60310. private _onLoad;
  60311. /**
  60312. * Instantiates a ColorGradingTexture from the following parameters.
  60313. *
  60314. * @param url The location of the color gradind data (currently only supporting 3dl)
  60315. * @param sceneOrEngine The scene or engine the texture will be used in
  60316. * @param onLoad defines a callback triggered when the texture has been loaded
  60317. */
  60318. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60319. /**
  60320. * Fires the onload event from the constructor if requested.
  60321. */
  60322. private _triggerOnLoad;
  60323. /**
  60324. * Returns the texture matrix used in most of the material.
  60325. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60326. */
  60327. getTextureMatrix(): Matrix;
  60328. /**
  60329. * Occurs when the file being loaded is a .3dl LUT file.
  60330. */
  60331. private load3dlTexture;
  60332. /**
  60333. * Starts the loading process of the texture.
  60334. */
  60335. private loadTexture;
  60336. /**
  60337. * Clones the color gradind texture.
  60338. */
  60339. clone(): ColorGradingTexture;
  60340. /**
  60341. * Called during delayed load for textures.
  60342. */
  60343. delayLoad(): void;
  60344. /**
  60345. * Parses a color grading texture serialized by Babylon.
  60346. * @param parsedTexture The texture information being parsedTexture
  60347. * @param scene The scene to load the texture in
  60348. * @param rootUrl The root url of the data assets to load
  60349. * @return A color gradind texture
  60350. */
  60351. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60352. /**
  60353. * Serializes the LUT texture to json format.
  60354. */
  60355. serialize(): any;
  60356. }
  60357. }
  60358. declare module BABYLON {
  60359. /**
  60360. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60361. */
  60362. export class EquiRectangularCubeTexture extends BaseTexture {
  60363. /** The six faces of the cube. */
  60364. private static _FacesMapping;
  60365. private _noMipmap;
  60366. private _onLoad;
  60367. private _onError;
  60368. /** The size of the cubemap. */
  60369. private _size;
  60370. /** The buffer of the image. */
  60371. private _buffer;
  60372. /** The width of the input image. */
  60373. private _width;
  60374. /** The height of the input image. */
  60375. private _height;
  60376. /** The URL to the image. */
  60377. url: string;
  60378. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60379. coordinatesMode: number;
  60380. /**
  60381. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60382. * @param url The location of the image
  60383. * @param scene The scene the texture will be used in
  60384. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60385. * @param noMipmap Forces to not generate the mipmap if true
  60386. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60387. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60388. * @param onLoad — defines a callback called when texture is loaded
  60389. * @param onError — defines a callback called if there is an error
  60390. */
  60391. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60392. /**
  60393. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60394. */
  60395. private loadImage;
  60396. /**
  60397. * Convert the image buffer into a cubemap and create a CubeTexture.
  60398. */
  60399. private loadTexture;
  60400. /**
  60401. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60402. * @param buffer The ArrayBuffer that should be converted.
  60403. * @returns The buffer as Float32Array.
  60404. */
  60405. private getFloat32ArrayFromArrayBuffer;
  60406. /**
  60407. * Get the current class name of the texture useful for serialization or dynamic coding.
  60408. * @returns "EquiRectangularCubeTexture"
  60409. */
  60410. getClassName(): string;
  60411. /**
  60412. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60413. * @returns A clone of the current EquiRectangularCubeTexture.
  60414. */
  60415. clone(): EquiRectangularCubeTexture;
  60416. }
  60417. }
  60418. declare module BABYLON {
  60419. /**
  60420. * Defines the options related to the creation of an HtmlElementTexture
  60421. */
  60422. export interface IHtmlElementTextureOptions {
  60423. /**
  60424. * Defines wether mip maps should be created or not.
  60425. */
  60426. generateMipMaps?: boolean;
  60427. /**
  60428. * Defines the sampling mode of the texture.
  60429. */
  60430. samplingMode?: number;
  60431. /**
  60432. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60433. */
  60434. engine: Nullable<ThinEngine>;
  60435. /**
  60436. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60437. */
  60438. scene: Nullable<Scene>;
  60439. }
  60440. /**
  60441. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60442. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60443. * is automatically managed.
  60444. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60445. * in your application.
  60446. *
  60447. * As the update is not automatic, you need to call them manually.
  60448. */
  60449. export class HtmlElementTexture extends BaseTexture {
  60450. /**
  60451. * The texture URL.
  60452. */
  60453. element: HTMLVideoElement | HTMLCanvasElement;
  60454. private static readonly DefaultOptions;
  60455. private _textureMatrix;
  60456. private _isVideo;
  60457. private _generateMipMaps;
  60458. private _samplingMode;
  60459. /**
  60460. * Instantiates a HtmlElementTexture from the following parameters.
  60461. *
  60462. * @param name Defines the name of the texture
  60463. * @param element Defines the video or canvas the texture is filled with
  60464. * @param options Defines the other none mandatory texture creation options
  60465. */
  60466. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60467. private _createInternalTexture;
  60468. /**
  60469. * Returns the texture matrix used in most of the material.
  60470. */
  60471. getTextureMatrix(): Matrix;
  60472. /**
  60473. * Updates the content of the texture.
  60474. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60475. */
  60476. update(invertY?: Nullable<boolean>): void;
  60477. }
  60478. }
  60479. declare module BABYLON {
  60480. /**
  60481. * Based on jsTGALoader - Javascript loader for TGA file
  60482. * By Vincent Thibault
  60483. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60484. */
  60485. export class TGATools {
  60486. private static _TYPE_INDEXED;
  60487. private static _TYPE_RGB;
  60488. private static _TYPE_GREY;
  60489. private static _TYPE_RLE_INDEXED;
  60490. private static _TYPE_RLE_RGB;
  60491. private static _TYPE_RLE_GREY;
  60492. private static _ORIGIN_MASK;
  60493. private static _ORIGIN_SHIFT;
  60494. private static _ORIGIN_BL;
  60495. private static _ORIGIN_BR;
  60496. private static _ORIGIN_UL;
  60497. private static _ORIGIN_UR;
  60498. /**
  60499. * Gets the header of a TGA file
  60500. * @param data defines the TGA data
  60501. * @returns the header
  60502. */
  60503. static GetTGAHeader(data: Uint8Array): any;
  60504. /**
  60505. * Uploads TGA content to a Babylon Texture
  60506. * @hidden
  60507. */
  60508. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60509. /** @hidden */
  60510. 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;
  60511. /** @hidden */
  60512. 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;
  60513. /** @hidden */
  60514. 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;
  60515. /** @hidden */
  60516. 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;
  60517. /** @hidden */
  60518. 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;
  60519. /** @hidden */
  60520. 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;
  60521. }
  60522. }
  60523. declare module BABYLON {
  60524. /**
  60525. * Implementation of the TGA Texture Loader.
  60526. * @hidden
  60527. */
  60528. export class _TGATextureLoader implements IInternalTextureLoader {
  60529. /**
  60530. * Defines wether the loader supports cascade loading the different faces.
  60531. */
  60532. readonly supportCascades: boolean;
  60533. /**
  60534. * This returns if the loader support the current file information.
  60535. * @param extension defines the file extension of the file being loaded
  60536. * @returns true if the loader can load the specified file
  60537. */
  60538. canLoad(extension: string): boolean;
  60539. /**
  60540. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60541. * @param data contains the texture data
  60542. * @param texture defines the BabylonJS internal texture
  60543. * @param createPolynomials will be true if polynomials have been requested
  60544. * @param onLoad defines the callback to trigger once the texture is ready
  60545. * @param onError defines the callback to trigger in case of error
  60546. */
  60547. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60548. /**
  60549. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60550. * @param data contains the texture data
  60551. * @param texture defines the BabylonJS internal texture
  60552. * @param callback defines the method to call once ready to upload
  60553. */
  60554. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60555. }
  60556. }
  60557. declare module BABYLON {
  60558. /**
  60559. * Info about the .basis files
  60560. */
  60561. class BasisFileInfo {
  60562. /**
  60563. * If the file has alpha
  60564. */
  60565. hasAlpha: boolean;
  60566. /**
  60567. * Info about each image of the basis file
  60568. */
  60569. images: Array<{
  60570. levels: Array<{
  60571. width: number;
  60572. height: number;
  60573. transcodedPixels: ArrayBufferView;
  60574. }>;
  60575. }>;
  60576. }
  60577. /**
  60578. * Result of transcoding a basis file
  60579. */
  60580. class TranscodeResult {
  60581. /**
  60582. * Info about the .basis file
  60583. */
  60584. fileInfo: BasisFileInfo;
  60585. /**
  60586. * Format to use when loading the file
  60587. */
  60588. format: number;
  60589. }
  60590. /**
  60591. * Configuration options for the Basis transcoder
  60592. */
  60593. export class BasisTranscodeConfiguration {
  60594. /**
  60595. * Supported compression formats used to determine the supported output format of the transcoder
  60596. */
  60597. supportedCompressionFormats?: {
  60598. /**
  60599. * etc1 compression format
  60600. */
  60601. etc1?: boolean;
  60602. /**
  60603. * s3tc compression format
  60604. */
  60605. s3tc?: boolean;
  60606. /**
  60607. * pvrtc compression format
  60608. */
  60609. pvrtc?: boolean;
  60610. /**
  60611. * etc2 compression format
  60612. */
  60613. etc2?: boolean;
  60614. };
  60615. /**
  60616. * If mipmap levels should be loaded for transcoded images (Default: true)
  60617. */
  60618. loadMipmapLevels?: boolean;
  60619. /**
  60620. * Index of a single image to load (Default: all images)
  60621. */
  60622. loadSingleImage?: number;
  60623. }
  60624. /**
  60625. * Used to load .Basis files
  60626. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60627. */
  60628. export class BasisTools {
  60629. private static _IgnoreSupportedFormats;
  60630. /**
  60631. * URL to use when loading the basis transcoder
  60632. */
  60633. static JSModuleURL: string;
  60634. /**
  60635. * URL to use when loading the wasm module for the transcoder
  60636. */
  60637. static WasmModuleURL: string;
  60638. /**
  60639. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60640. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60641. * @returns internal format corresponding to the Basis format
  60642. */
  60643. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60644. private static _WorkerPromise;
  60645. private static _Worker;
  60646. private static _actionId;
  60647. private static _CreateWorkerAsync;
  60648. /**
  60649. * Transcodes a loaded image file to compressed pixel data
  60650. * @param data image data to transcode
  60651. * @param config configuration options for the transcoding
  60652. * @returns a promise resulting in the transcoded image
  60653. */
  60654. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60655. /**
  60656. * Loads a texture from the transcode result
  60657. * @param texture texture load to
  60658. * @param transcodeResult the result of transcoding the basis file to load from
  60659. */
  60660. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60661. }
  60662. }
  60663. declare module BABYLON {
  60664. /**
  60665. * Loader for .basis file format
  60666. */
  60667. export class _BasisTextureLoader implements IInternalTextureLoader {
  60668. /**
  60669. * Defines whether the loader supports cascade loading the different faces.
  60670. */
  60671. readonly supportCascades: boolean;
  60672. /**
  60673. * This returns if the loader support the current file information.
  60674. * @param extension defines the file extension of the file being loaded
  60675. * @returns true if the loader can load the specified file
  60676. */
  60677. canLoad(extension: string): boolean;
  60678. /**
  60679. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60680. * @param data contains the texture data
  60681. * @param texture defines the BabylonJS internal texture
  60682. * @param createPolynomials will be true if polynomials have been requested
  60683. * @param onLoad defines the callback to trigger once the texture is ready
  60684. * @param onError defines the callback to trigger in case of error
  60685. */
  60686. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60687. /**
  60688. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60689. * @param data contains the texture data
  60690. * @param texture defines the BabylonJS internal texture
  60691. * @param callback defines the method to call once ready to upload
  60692. */
  60693. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60694. }
  60695. }
  60696. declare module BABYLON {
  60697. /**
  60698. * Defines the basic options interface of a TexturePacker Frame
  60699. */
  60700. export interface ITexturePackerFrame {
  60701. /**
  60702. * The frame ID
  60703. */
  60704. id: number;
  60705. /**
  60706. * The frames Scale
  60707. */
  60708. scale: Vector2;
  60709. /**
  60710. * The Frames offset
  60711. */
  60712. offset: Vector2;
  60713. }
  60714. /**
  60715. * This is a support class for frame Data on texture packer sets.
  60716. */
  60717. export class TexturePackerFrame implements ITexturePackerFrame {
  60718. /**
  60719. * The frame ID
  60720. */
  60721. id: number;
  60722. /**
  60723. * The frames Scale
  60724. */
  60725. scale: Vector2;
  60726. /**
  60727. * The Frames offset
  60728. */
  60729. offset: Vector2;
  60730. /**
  60731. * Initializes a texture package frame.
  60732. * @param id The numerical frame identifier
  60733. * @param scale Scalar Vector2 for UV frame
  60734. * @param offset Vector2 for the frame position in UV units.
  60735. * @returns TexturePackerFrame
  60736. */
  60737. constructor(id: number, scale: Vector2, offset: Vector2);
  60738. }
  60739. }
  60740. declare module BABYLON {
  60741. /**
  60742. * Defines the basic options interface of a TexturePacker
  60743. */
  60744. export interface ITexturePackerOptions {
  60745. /**
  60746. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60747. */
  60748. map?: string[];
  60749. /**
  60750. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60751. */
  60752. uvsIn?: string;
  60753. /**
  60754. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60755. */
  60756. uvsOut?: string;
  60757. /**
  60758. * number representing the layout style. Defaults to LAYOUT_STRIP
  60759. */
  60760. layout?: number;
  60761. /**
  60762. * number of columns if using custom column count layout(2). This defaults to 4.
  60763. */
  60764. colnum?: number;
  60765. /**
  60766. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60767. */
  60768. updateInputMeshes?: boolean;
  60769. /**
  60770. * boolean flag to dispose all the source textures. Defaults to true.
  60771. */
  60772. disposeSources?: boolean;
  60773. /**
  60774. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60775. */
  60776. fillBlanks?: boolean;
  60777. /**
  60778. * string value representing the context fill style color. Defaults to 'black'.
  60779. */
  60780. customFillColor?: string;
  60781. /**
  60782. * Width and Height Value of each Frame in the TexturePacker Sets
  60783. */
  60784. frameSize?: number;
  60785. /**
  60786. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60787. */
  60788. paddingRatio?: number;
  60789. /**
  60790. * Number that declares the fill method for the padding gutter.
  60791. */
  60792. paddingMode?: number;
  60793. /**
  60794. * If in SUBUV_COLOR padding mode what color to use.
  60795. */
  60796. paddingColor?: Color3 | Color4;
  60797. }
  60798. /**
  60799. * Defines the basic interface of a TexturePacker JSON File
  60800. */
  60801. export interface ITexturePackerJSON {
  60802. /**
  60803. * The frame ID
  60804. */
  60805. name: string;
  60806. /**
  60807. * The base64 channel data
  60808. */
  60809. sets: any;
  60810. /**
  60811. * The options of the Packer
  60812. */
  60813. options: ITexturePackerOptions;
  60814. /**
  60815. * The frame data of the Packer
  60816. */
  60817. frames: Array<number>;
  60818. }
  60819. /**
  60820. * This is a support class that generates a series of packed texture sets.
  60821. * @see https://doc.babylonjs.com/babylon101/materials
  60822. */
  60823. export class TexturePacker {
  60824. /** Packer Layout Constant 0 */
  60825. static readonly LAYOUT_STRIP: number;
  60826. /** Packer Layout Constant 1 */
  60827. static readonly LAYOUT_POWER2: number;
  60828. /** Packer Layout Constant 2 */
  60829. static readonly LAYOUT_COLNUM: number;
  60830. /** Packer Layout Constant 0 */
  60831. static readonly SUBUV_WRAP: number;
  60832. /** Packer Layout Constant 1 */
  60833. static readonly SUBUV_EXTEND: number;
  60834. /** Packer Layout Constant 2 */
  60835. static readonly SUBUV_COLOR: number;
  60836. /** The Name of the Texture Package */
  60837. name: string;
  60838. /** The scene scope of the TexturePacker */
  60839. scene: Scene;
  60840. /** The Meshes to target */
  60841. meshes: AbstractMesh[];
  60842. /** Arguments passed with the Constructor */
  60843. options: ITexturePackerOptions;
  60844. /** The promise that is started upon initialization */
  60845. promise: Nullable<Promise<TexturePacker | string>>;
  60846. /** The Container object for the channel sets that are generated */
  60847. sets: object;
  60848. /** The Container array for the frames that are generated */
  60849. frames: TexturePackerFrame[];
  60850. /** The expected number of textures the system is parsing. */
  60851. private _expecting;
  60852. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60853. private _paddingValue;
  60854. /**
  60855. * Initializes a texture package series from an array of meshes or a single mesh.
  60856. * @param name The name of the package
  60857. * @param meshes The target meshes to compose the package from
  60858. * @param options The arguments that texture packer should follow while building.
  60859. * @param scene The scene which the textures are scoped to.
  60860. * @returns TexturePacker
  60861. */
  60862. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60863. /**
  60864. * Starts the package process
  60865. * @param resolve The promises resolution function
  60866. * @returns TexturePacker
  60867. */
  60868. private _createFrames;
  60869. /**
  60870. * Calculates the Size of the Channel Sets
  60871. * @returns Vector2
  60872. */
  60873. private _calculateSize;
  60874. /**
  60875. * Calculates the UV data for the frames.
  60876. * @param baseSize the base frameSize
  60877. * @param padding the base frame padding
  60878. * @param dtSize size of the Dynamic Texture for that channel
  60879. * @param dtUnits is 1/dtSize
  60880. * @param update flag to update the input meshes
  60881. */
  60882. private _calculateMeshUVFrames;
  60883. /**
  60884. * Calculates the frames Offset.
  60885. * @param index of the frame
  60886. * @returns Vector2
  60887. */
  60888. private _getFrameOffset;
  60889. /**
  60890. * Updates a Mesh to the frame data
  60891. * @param mesh that is the target
  60892. * @param frameID or the frame index
  60893. */
  60894. private _updateMeshUV;
  60895. /**
  60896. * Updates a Meshes materials to use the texture packer channels
  60897. * @param m is the mesh to target
  60898. * @param force all channels on the packer to be set.
  60899. */
  60900. private _updateTextureReferences;
  60901. /**
  60902. * Public method to set a Mesh to a frame
  60903. * @param m that is the target
  60904. * @param frameID or the frame index
  60905. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60906. */
  60907. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60908. /**
  60909. * Starts the async promise to compile the texture packer.
  60910. * @returns Promise<void>
  60911. */
  60912. processAsync(): Promise<void>;
  60913. /**
  60914. * Disposes all textures associated with this packer
  60915. */
  60916. dispose(): void;
  60917. /**
  60918. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60919. * @param imageType is the image type to use.
  60920. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60921. */
  60922. download(imageType?: string, quality?: number): void;
  60923. /**
  60924. * Public method to load a texturePacker JSON file.
  60925. * @param data of the JSON file in string format.
  60926. */
  60927. updateFromJSON(data: string): void;
  60928. }
  60929. }
  60930. declare module BABYLON {
  60931. /**
  60932. * 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.
  60933. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60934. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60935. */
  60936. export class CustomProceduralTexture extends ProceduralTexture {
  60937. private _animate;
  60938. private _time;
  60939. private _config;
  60940. private _texturePath;
  60941. /**
  60942. * Instantiates a new Custom Procedural Texture.
  60943. * 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.
  60944. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60945. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60946. * @param name Define the name of the texture
  60947. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60948. * @param size Define the size of the texture to create
  60949. * @param scene Define the scene the texture belongs to
  60950. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60951. * @param generateMipMaps Define if the texture should creates mip maps or not
  60952. */
  60953. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60954. private _loadJson;
  60955. /**
  60956. * Is the texture ready to be used ? (rendered at least once)
  60957. * @returns true if ready, otherwise, false.
  60958. */
  60959. isReady(): boolean;
  60960. /**
  60961. * Render the texture to its associated render target.
  60962. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60963. */
  60964. render(useCameraPostProcess?: boolean): void;
  60965. /**
  60966. * Update the list of dependant textures samplers in the shader.
  60967. */
  60968. updateTextures(): void;
  60969. /**
  60970. * Update the uniform values of the procedural texture in the shader.
  60971. */
  60972. updateShaderUniforms(): void;
  60973. /**
  60974. * Define if the texture animates or not.
  60975. */
  60976. get animate(): boolean;
  60977. set animate(value: boolean);
  60978. }
  60979. }
  60980. declare module BABYLON {
  60981. /** @hidden */
  60982. export var noisePixelShader: {
  60983. name: string;
  60984. shader: string;
  60985. };
  60986. }
  60987. declare module BABYLON {
  60988. /**
  60989. * Class used to generate noise procedural textures
  60990. */
  60991. export class NoiseProceduralTexture extends ProceduralTexture {
  60992. private _time;
  60993. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60994. brightness: number;
  60995. /** Defines the number of octaves to process */
  60996. octaves: number;
  60997. /** Defines the level of persistence (0.8 by default) */
  60998. persistence: number;
  60999. /** Gets or sets animation speed factor (default is 1) */
  61000. animationSpeedFactor: number;
  61001. /**
  61002. * Creates a new NoiseProceduralTexture
  61003. * @param name defines the name fo the texture
  61004. * @param size defines the size of the texture (default is 256)
  61005. * @param scene defines the hosting scene
  61006. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61007. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61008. */
  61009. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61010. private _updateShaderUniforms;
  61011. protected _getDefines(): string;
  61012. /** Generate the current state of the procedural texture */
  61013. render(useCameraPostProcess?: boolean): void;
  61014. /**
  61015. * Serializes this noise procedural texture
  61016. * @returns a serialized noise procedural texture object
  61017. */
  61018. serialize(): any;
  61019. /**
  61020. * Clone the texture.
  61021. * @returns the cloned texture
  61022. */
  61023. clone(): NoiseProceduralTexture;
  61024. /**
  61025. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61026. * @param parsedTexture defines parsed texture data
  61027. * @param scene defines the current scene
  61028. * @param rootUrl defines the root URL containing noise procedural texture information
  61029. * @returns a parsed NoiseProceduralTexture
  61030. */
  61031. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61032. }
  61033. }
  61034. declare module BABYLON {
  61035. /**
  61036. * Raw cube texture where the raw buffers are passed in
  61037. */
  61038. export class RawCubeTexture extends CubeTexture {
  61039. /**
  61040. * Creates a cube texture where the raw buffers are passed in.
  61041. * @param scene defines the scene the texture is attached to
  61042. * @param data defines the array of data to use to create each face
  61043. * @param size defines the size of the textures
  61044. * @param format defines the format of the data
  61045. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61046. * @param generateMipMaps defines if the engine should generate the mip levels
  61047. * @param invertY defines if data must be stored with Y axis inverted
  61048. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61049. * @param compression defines the compression used (null by default)
  61050. */
  61051. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61052. /**
  61053. * Updates the raw cube texture.
  61054. * @param data defines the data to store
  61055. * @param format defines the data format
  61056. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61057. * @param invertY defines if data must be stored with Y axis inverted
  61058. * @param compression defines the compression used (null by default)
  61059. * @param level defines which level of the texture to update
  61060. */
  61061. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61062. /**
  61063. * Updates a raw cube texture with RGBD encoded data.
  61064. * @param data defines the array of data [mipmap][face] to use to create each face
  61065. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61066. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61067. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61068. * @returns a promsie that resolves when the operation is complete
  61069. */
  61070. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61071. /**
  61072. * Clones the raw cube texture.
  61073. * @return a new cube texture
  61074. */
  61075. clone(): CubeTexture;
  61076. /** @hidden */
  61077. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61078. }
  61079. }
  61080. declare module BABYLON {
  61081. /**
  61082. * Class used to store 2D array textures containing user data
  61083. */
  61084. export class RawTexture2DArray extends Texture {
  61085. /** Gets or sets the texture format to use */
  61086. format: number;
  61087. /**
  61088. * Create a new RawTexture2DArray
  61089. * @param data defines the data of the texture
  61090. * @param width defines the width of the texture
  61091. * @param height defines the height of the texture
  61092. * @param depth defines the number of layers of the texture
  61093. * @param format defines the texture format to use
  61094. * @param scene defines the hosting scene
  61095. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61096. * @param invertY defines if texture must be stored with Y axis inverted
  61097. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61098. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61099. */
  61100. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61101. /** Gets or sets the texture format to use */
  61102. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61103. /**
  61104. * Update the texture with new data
  61105. * @param data defines the data to store in the texture
  61106. */
  61107. update(data: ArrayBufferView): void;
  61108. }
  61109. }
  61110. declare module BABYLON {
  61111. /**
  61112. * Class used to store 3D textures containing user data
  61113. */
  61114. export class RawTexture3D extends Texture {
  61115. /** Gets or sets the texture format to use */
  61116. format: number;
  61117. /**
  61118. * Create a new RawTexture3D
  61119. * @param data defines the data of the texture
  61120. * @param width defines the width of the texture
  61121. * @param height defines the height of the texture
  61122. * @param depth defines the depth of the texture
  61123. * @param format defines the texture format to use
  61124. * @param scene defines the hosting scene
  61125. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61126. * @param invertY defines if texture must be stored with Y axis inverted
  61127. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61128. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61129. */
  61130. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61131. /** Gets or sets the texture format to use */
  61132. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61133. /**
  61134. * Update the texture with new data
  61135. * @param data defines the data to store in the texture
  61136. */
  61137. update(data: ArrayBufferView): void;
  61138. }
  61139. }
  61140. declare module BABYLON {
  61141. /**
  61142. * Creates a refraction texture used by refraction channel of the standard material.
  61143. * It is like a mirror but to see through a material.
  61144. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61145. */
  61146. export class RefractionTexture extends RenderTargetTexture {
  61147. /**
  61148. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61149. * 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.
  61150. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61151. */
  61152. refractionPlane: Plane;
  61153. /**
  61154. * Define how deep under the surface we should see.
  61155. */
  61156. depth: number;
  61157. /**
  61158. * Creates a refraction texture used by refraction channel of the standard material.
  61159. * It is like a mirror but to see through a material.
  61160. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61161. * @param name Define the texture name
  61162. * @param size Define the size of the underlying texture
  61163. * @param scene Define the scene the refraction belongs to
  61164. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61165. */
  61166. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61167. /**
  61168. * Clone the refraction texture.
  61169. * @returns the cloned texture
  61170. */
  61171. clone(): RefractionTexture;
  61172. /**
  61173. * Serialize the texture to a JSON representation you could use in Parse later on
  61174. * @returns the serialized JSON representation
  61175. */
  61176. serialize(): any;
  61177. }
  61178. }
  61179. declare module BABYLON {
  61180. /**
  61181. * Block used to add support for vertex skinning (bones)
  61182. */
  61183. export class BonesBlock extends NodeMaterialBlock {
  61184. /**
  61185. * Creates a new BonesBlock
  61186. * @param name defines the block name
  61187. */
  61188. constructor(name: string);
  61189. /**
  61190. * Initialize the block and prepare the context for build
  61191. * @param state defines the state that will be used for the build
  61192. */
  61193. initialize(state: NodeMaterialBuildState): void;
  61194. /**
  61195. * Gets the current class name
  61196. * @returns the class name
  61197. */
  61198. getClassName(): string;
  61199. /**
  61200. * Gets the matrix indices input component
  61201. */
  61202. get matricesIndices(): NodeMaterialConnectionPoint;
  61203. /**
  61204. * Gets the matrix weights input component
  61205. */
  61206. get matricesWeights(): NodeMaterialConnectionPoint;
  61207. /**
  61208. * Gets the extra matrix indices input component
  61209. */
  61210. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61211. /**
  61212. * Gets the extra matrix weights input component
  61213. */
  61214. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61215. /**
  61216. * Gets the world input component
  61217. */
  61218. get world(): NodeMaterialConnectionPoint;
  61219. /**
  61220. * Gets the output component
  61221. */
  61222. get output(): NodeMaterialConnectionPoint;
  61223. autoConfigure(material: NodeMaterial): void;
  61224. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61226. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61227. protected _buildBlock(state: NodeMaterialBuildState): this;
  61228. }
  61229. }
  61230. declare module BABYLON {
  61231. /**
  61232. * Block used to add support for instances
  61233. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61234. */
  61235. export class InstancesBlock extends NodeMaterialBlock {
  61236. /**
  61237. * Creates a new InstancesBlock
  61238. * @param name defines the block name
  61239. */
  61240. constructor(name: string);
  61241. /**
  61242. * Gets the current class name
  61243. * @returns the class name
  61244. */
  61245. getClassName(): string;
  61246. /**
  61247. * Gets the first world row input component
  61248. */
  61249. get world0(): NodeMaterialConnectionPoint;
  61250. /**
  61251. * Gets the second world row input component
  61252. */
  61253. get world1(): NodeMaterialConnectionPoint;
  61254. /**
  61255. * Gets the third world row input component
  61256. */
  61257. get world2(): NodeMaterialConnectionPoint;
  61258. /**
  61259. * Gets the forth world row input component
  61260. */
  61261. get world3(): NodeMaterialConnectionPoint;
  61262. /**
  61263. * Gets the world input component
  61264. */
  61265. get world(): NodeMaterialConnectionPoint;
  61266. /**
  61267. * Gets the output component
  61268. */
  61269. get output(): NodeMaterialConnectionPoint;
  61270. /**
  61271. * Gets the isntanceID component
  61272. */
  61273. get instanceID(): NodeMaterialConnectionPoint;
  61274. autoConfigure(material: NodeMaterial): void;
  61275. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61276. protected _buildBlock(state: NodeMaterialBuildState): this;
  61277. }
  61278. }
  61279. declare module BABYLON {
  61280. /**
  61281. * Block used to add morph targets support to vertex shader
  61282. */
  61283. export class MorphTargetsBlock extends NodeMaterialBlock {
  61284. private _repeatableContentAnchor;
  61285. /**
  61286. * Create a new MorphTargetsBlock
  61287. * @param name defines the block name
  61288. */
  61289. constructor(name: string);
  61290. /**
  61291. * Gets the current class name
  61292. * @returns the class name
  61293. */
  61294. getClassName(): string;
  61295. /**
  61296. * Gets the position input component
  61297. */
  61298. get position(): NodeMaterialConnectionPoint;
  61299. /**
  61300. * Gets the normal input component
  61301. */
  61302. get normal(): NodeMaterialConnectionPoint;
  61303. /**
  61304. * Gets the tangent input component
  61305. */
  61306. get tangent(): NodeMaterialConnectionPoint;
  61307. /**
  61308. * Gets the tangent input component
  61309. */
  61310. get uv(): NodeMaterialConnectionPoint;
  61311. /**
  61312. * Gets the position output component
  61313. */
  61314. get positionOutput(): NodeMaterialConnectionPoint;
  61315. /**
  61316. * Gets the normal output component
  61317. */
  61318. get normalOutput(): NodeMaterialConnectionPoint;
  61319. /**
  61320. * Gets the tangent output component
  61321. */
  61322. get tangentOutput(): NodeMaterialConnectionPoint;
  61323. /**
  61324. * Gets the tangent output component
  61325. */
  61326. get uvOutput(): NodeMaterialConnectionPoint;
  61327. initialize(state: NodeMaterialBuildState): void;
  61328. autoConfigure(material: NodeMaterial): void;
  61329. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61330. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61331. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61332. protected _buildBlock(state: NodeMaterialBuildState): this;
  61333. }
  61334. }
  61335. declare module BABYLON {
  61336. /**
  61337. * Block used to get data information from a light
  61338. */
  61339. export class LightInformationBlock extends NodeMaterialBlock {
  61340. private _lightDataUniformName;
  61341. private _lightColorUniformName;
  61342. private _lightTypeDefineName;
  61343. /**
  61344. * Gets or sets the light associated with this block
  61345. */
  61346. light: Nullable<Light>;
  61347. /**
  61348. * Creates a new LightInformationBlock
  61349. * @param name defines the block name
  61350. */
  61351. constructor(name: string);
  61352. /**
  61353. * Gets the current class name
  61354. * @returns the class name
  61355. */
  61356. getClassName(): string;
  61357. /**
  61358. * Gets the world position input component
  61359. */
  61360. get worldPosition(): NodeMaterialConnectionPoint;
  61361. /**
  61362. * Gets the direction output component
  61363. */
  61364. get direction(): NodeMaterialConnectionPoint;
  61365. /**
  61366. * Gets the direction output component
  61367. */
  61368. get color(): NodeMaterialConnectionPoint;
  61369. /**
  61370. * Gets the direction output component
  61371. */
  61372. get intensity(): NodeMaterialConnectionPoint;
  61373. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61374. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61375. protected _buildBlock(state: NodeMaterialBuildState): this;
  61376. serialize(): any;
  61377. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61378. }
  61379. }
  61380. declare module BABYLON {
  61381. /**
  61382. * Block used to add image processing support to fragment shader
  61383. */
  61384. export class ImageProcessingBlock extends NodeMaterialBlock {
  61385. /**
  61386. * Create a new ImageProcessingBlock
  61387. * @param name defines the block name
  61388. */
  61389. constructor(name: string);
  61390. /**
  61391. * Gets the current class name
  61392. * @returns the class name
  61393. */
  61394. getClassName(): string;
  61395. /**
  61396. * Gets the color input component
  61397. */
  61398. get color(): NodeMaterialConnectionPoint;
  61399. /**
  61400. * Gets the output component
  61401. */
  61402. get output(): NodeMaterialConnectionPoint;
  61403. /**
  61404. * Initialize the block and prepare the context for build
  61405. * @param state defines the state that will be used for the build
  61406. */
  61407. initialize(state: NodeMaterialBuildState): void;
  61408. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61409. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61410. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61411. protected _buildBlock(state: NodeMaterialBuildState): this;
  61412. }
  61413. }
  61414. declare module BABYLON {
  61415. /**
  61416. * Block used to pertub normals based on a normal map
  61417. */
  61418. export class PerturbNormalBlock extends NodeMaterialBlock {
  61419. private _tangentSpaceParameterName;
  61420. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61421. invertX: boolean;
  61422. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61423. invertY: boolean;
  61424. /**
  61425. * Create a new PerturbNormalBlock
  61426. * @param name defines the block name
  61427. */
  61428. constructor(name: string);
  61429. /**
  61430. * Gets the current class name
  61431. * @returns the class name
  61432. */
  61433. getClassName(): string;
  61434. /**
  61435. * Gets the world position input component
  61436. */
  61437. get worldPosition(): NodeMaterialConnectionPoint;
  61438. /**
  61439. * Gets the world normal input component
  61440. */
  61441. get worldNormal(): NodeMaterialConnectionPoint;
  61442. /**
  61443. * Gets the world tangent input component
  61444. */
  61445. get worldTangent(): NodeMaterialConnectionPoint;
  61446. /**
  61447. * Gets the uv input component
  61448. */
  61449. get uv(): NodeMaterialConnectionPoint;
  61450. /**
  61451. * Gets the normal map color input component
  61452. */
  61453. get normalMapColor(): NodeMaterialConnectionPoint;
  61454. /**
  61455. * Gets the strength input component
  61456. */
  61457. get strength(): NodeMaterialConnectionPoint;
  61458. /**
  61459. * Gets the output component
  61460. */
  61461. get output(): NodeMaterialConnectionPoint;
  61462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61463. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61464. autoConfigure(material: NodeMaterial): void;
  61465. protected _buildBlock(state: NodeMaterialBuildState): this;
  61466. protected _dumpPropertiesCode(): string;
  61467. serialize(): any;
  61468. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61469. }
  61470. }
  61471. declare module BABYLON {
  61472. /**
  61473. * Block used to discard a pixel if a value is smaller than a cutoff
  61474. */
  61475. export class DiscardBlock extends NodeMaterialBlock {
  61476. /**
  61477. * Create a new DiscardBlock
  61478. * @param name defines the block name
  61479. */
  61480. constructor(name: string);
  61481. /**
  61482. * Gets the current class name
  61483. * @returns the class name
  61484. */
  61485. getClassName(): string;
  61486. /**
  61487. * Gets the color input component
  61488. */
  61489. get value(): NodeMaterialConnectionPoint;
  61490. /**
  61491. * Gets the cutoff input component
  61492. */
  61493. get cutoff(): NodeMaterialConnectionPoint;
  61494. protected _buildBlock(state: NodeMaterialBuildState): this;
  61495. }
  61496. }
  61497. declare module BABYLON {
  61498. /**
  61499. * Block used to test if the fragment shader is front facing
  61500. */
  61501. export class FrontFacingBlock extends NodeMaterialBlock {
  61502. /**
  61503. * Creates a new FrontFacingBlock
  61504. * @param name defines the block name
  61505. */
  61506. constructor(name: string);
  61507. /**
  61508. * Gets the current class name
  61509. * @returns the class name
  61510. */
  61511. getClassName(): string;
  61512. /**
  61513. * Gets the output component
  61514. */
  61515. get output(): NodeMaterialConnectionPoint;
  61516. protected _buildBlock(state: NodeMaterialBuildState): this;
  61517. }
  61518. }
  61519. declare module BABYLON {
  61520. /**
  61521. * Block used to get the derivative value on x and y of a given input
  61522. */
  61523. export class DerivativeBlock extends NodeMaterialBlock {
  61524. /**
  61525. * Create a new DerivativeBlock
  61526. * @param name defines the block name
  61527. */
  61528. constructor(name: string);
  61529. /**
  61530. * Gets the current class name
  61531. * @returns the class name
  61532. */
  61533. getClassName(): string;
  61534. /**
  61535. * Gets the input component
  61536. */
  61537. get input(): NodeMaterialConnectionPoint;
  61538. /**
  61539. * Gets the derivative output on x
  61540. */
  61541. get dx(): NodeMaterialConnectionPoint;
  61542. /**
  61543. * Gets the derivative output on y
  61544. */
  61545. get dy(): NodeMaterialConnectionPoint;
  61546. protected _buildBlock(state: NodeMaterialBuildState): this;
  61547. }
  61548. }
  61549. declare module BABYLON {
  61550. /**
  61551. * Block used to make gl_FragCoord available
  61552. */
  61553. export class FragCoordBlock extends NodeMaterialBlock {
  61554. /**
  61555. * Creates a new FragCoordBlock
  61556. * @param name defines the block name
  61557. */
  61558. constructor(name: string);
  61559. /**
  61560. * Gets the current class name
  61561. * @returns the class name
  61562. */
  61563. getClassName(): string;
  61564. /**
  61565. * Gets the xy component
  61566. */
  61567. get xy(): NodeMaterialConnectionPoint;
  61568. /**
  61569. * Gets the xyz component
  61570. */
  61571. get xyz(): NodeMaterialConnectionPoint;
  61572. /**
  61573. * Gets the xyzw component
  61574. */
  61575. get xyzw(): NodeMaterialConnectionPoint;
  61576. /**
  61577. * Gets the x component
  61578. */
  61579. get x(): NodeMaterialConnectionPoint;
  61580. /**
  61581. * Gets the y component
  61582. */
  61583. get y(): NodeMaterialConnectionPoint;
  61584. /**
  61585. * Gets the z component
  61586. */
  61587. get z(): NodeMaterialConnectionPoint;
  61588. /**
  61589. * Gets the w component
  61590. */
  61591. get output(): NodeMaterialConnectionPoint;
  61592. protected writeOutputs(state: NodeMaterialBuildState): string;
  61593. protected _buildBlock(state: NodeMaterialBuildState): this;
  61594. }
  61595. }
  61596. declare module BABYLON {
  61597. /**
  61598. * Block used to get the screen sizes
  61599. */
  61600. export class ScreenSizeBlock extends NodeMaterialBlock {
  61601. private _varName;
  61602. private _scene;
  61603. /**
  61604. * Creates a new ScreenSizeBlock
  61605. * @param name defines the block name
  61606. */
  61607. constructor(name: string);
  61608. /**
  61609. * Gets the current class name
  61610. * @returns the class name
  61611. */
  61612. getClassName(): string;
  61613. /**
  61614. * Gets the xy component
  61615. */
  61616. get xy(): NodeMaterialConnectionPoint;
  61617. /**
  61618. * Gets the x component
  61619. */
  61620. get x(): NodeMaterialConnectionPoint;
  61621. /**
  61622. * Gets the y component
  61623. */
  61624. get y(): NodeMaterialConnectionPoint;
  61625. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61626. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61627. protected _buildBlock(state: NodeMaterialBuildState): this;
  61628. }
  61629. }
  61630. declare module BABYLON {
  61631. /**
  61632. * Block used to add support for scene fog
  61633. */
  61634. export class FogBlock extends NodeMaterialBlock {
  61635. private _fogDistanceName;
  61636. private _fogParameters;
  61637. /**
  61638. * Create a new FogBlock
  61639. * @param name defines the block name
  61640. */
  61641. constructor(name: string);
  61642. /**
  61643. * Gets the current class name
  61644. * @returns the class name
  61645. */
  61646. getClassName(): string;
  61647. /**
  61648. * Gets the world position input component
  61649. */
  61650. get worldPosition(): NodeMaterialConnectionPoint;
  61651. /**
  61652. * Gets the view input component
  61653. */
  61654. get view(): NodeMaterialConnectionPoint;
  61655. /**
  61656. * Gets the color input component
  61657. */
  61658. get input(): NodeMaterialConnectionPoint;
  61659. /**
  61660. * Gets the fog color input component
  61661. */
  61662. get fogColor(): NodeMaterialConnectionPoint;
  61663. /**
  61664. * Gets the output component
  61665. */
  61666. get output(): NodeMaterialConnectionPoint;
  61667. autoConfigure(material: NodeMaterial): void;
  61668. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61669. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61670. protected _buildBlock(state: NodeMaterialBuildState): this;
  61671. }
  61672. }
  61673. declare module BABYLON {
  61674. /**
  61675. * Block used to add light in the fragment shader
  61676. */
  61677. export class LightBlock extends NodeMaterialBlock {
  61678. private _lightId;
  61679. /**
  61680. * Gets or sets the light associated with this block
  61681. */
  61682. light: Nullable<Light>;
  61683. /**
  61684. * Create a new LightBlock
  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 world position input component
  61695. */
  61696. get worldPosition(): NodeMaterialConnectionPoint;
  61697. /**
  61698. * Gets the world normal input component
  61699. */
  61700. get worldNormal(): NodeMaterialConnectionPoint;
  61701. /**
  61702. * Gets the camera (or eye) position component
  61703. */
  61704. get cameraPosition(): NodeMaterialConnectionPoint;
  61705. /**
  61706. * Gets the glossiness component
  61707. */
  61708. get glossiness(): NodeMaterialConnectionPoint;
  61709. /**
  61710. * Gets the glossinness power component
  61711. */
  61712. get glossPower(): NodeMaterialConnectionPoint;
  61713. /**
  61714. * Gets the diffuse color component
  61715. */
  61716. get diffuseColor(): NodeMaterialConnectionPoint;
  61717. /**
  61718. * Gets the specular color component
  61719. */
  61720. get specularColor(): NodeMaterialConnectionPoint;
  61721. /**
  61722. * Gets the diffuse output component
  61723. */
  61724. get diffuseOutput(): NodeMaterialConnectionPoint;
  61725. /**
  61726. * Gets the specular output component
  61727. */
  61728. get specularOutput(): NodeMaterialConnectionPoint;
  61729. /**
  61730. * Gets the shadow output component
  61731. */
  61732. get shadow(): NodeMaterialConnectionPoint;
  61733. autoConfigure(material: NodeMaterial): void;
  61734. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61735. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61736. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61737. private _injectVertexCode;
  61738. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61739. serialize(): any;
  61740. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61741. }
  61742. }
  61743. declare module BABYLON {
  61744. /**
  61745. * Block used to read a reflection texture from a sampler
  61746. */
  61747. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61748. /**
  61749. * Create a new ReflectionTextureBlock
  61750. * @param name defines the block name
  61751. */
  61752. constructor(name: string);
  61753. /**
  61754. * Gets the current class name
  61755. * @returns the class name
  61756. */
  61757. getClassName(): string;
  61758. /**
  61759. * Gets the world position input component
  61760. */
  61761. get position(): NodeMaterialConnectionPoint;
  61762. /**
  61763. * Gets the world position input component
  61764. */
  61765. get worldPosition(): NodeMaterialConnectionPoint;
  61766. /**
  61767. * Gets the world normal input component
  61768. */
  61769. get worldNormal(): NodeMaterialConnectionPoint;
  61770. /**
  61771. * Gets the world input component
  61772. */
  61773. get world(): NodeMaterialConnectionPoint;
  61774. /**
  61775. * Gets the camera (or eye) position component
  61776. */
  61777. get cameraPosition(): NodeMaterialConnectionPoint;
  61778. /**
  61779. * Gets the view input component
  61780. */
  61781. get view(): NodeMaterialConnectionPoint;
  61782. /**
  61783. * Gets the rgb output component
  61784. */
  61785. get rgb(): NodeMaterialConnectionPoint;
  61786. /**
  61787. * Gets the rgba output component
  61788. */
  61789. get rgba(): NodeMaterialConnectionPoint;
  61790. /**
  61791. * Gets the r output component
  61792. */
  61793. get r(): NodeMaterialConnectionPoint;
  61794. /**
  61795. * Gets the g output component
  61796. */
  61797. get g(): NodeMaterialConnectionPoint;
  61798. /**
  61799. * Gets the b output component
  61800. */
  61801. get b(): NodeMaterialConnectionPoint;
  61802. /**
  61803. * Gets the a output component
  61804. */
  61805. get a(): NodeMaterialConnectionPoint;
  61806. autoConfigure(material: NodeMaterial): void;
  61807. protected _buildBlock(state: NodeMaterialBuildState): this;
  61808. }
  61809. }
  61810. declare module BABYLON {
  61811. /**
  61812. * Block used to add 2 vectors
  61813. */
  61814. export class AddBlock extends NodeMaterialBlock {
  61815. /**
  61816. * Creates a new AddBlock
  61817. * @param name defines the block name
  61818. */
  61819. constructor(name: string);
  61820. /**
  61821. * Gets the current class name
  61822. * @returns the class name
  61823. */
  61824. getClassName(): string;
  61825. /**
  61826. * Gets the left operand input component
  61827. */
  61828. get left(): NodeMaterialConnectionPoint;
  61829. /**
  61830. * Gets the right operand input component
  61831. */
  61832. get right(): NodeMaterialConnectionPoint;
  61833. /**
  61834. * Gets the output component
  61835. */
  61836. get output(): NodeMaterialConnectionPoint;
  61837. protected _buildBlock(state: NodeMaterialBuildState): this;
  61838. }
  61839. }
  61840. declare module BABYLON {
  61841. /**
  61842. * Block used to scale a vector by a float
  61843. */
  61844. export class ScaleBlock extends NodeMaterialBlock {
  61845. /**
  61846. * Creates a new ScaleBlock
  61847. * @param name defines the block name
  61848. */
  61849. constructor(name: string);
  61850. /**
  61851. * Gets the current class name
  61852. * @returns the class name
  61853. */
  61854. getClassName(): string;
  61855. /**
  61856. * Gets the input component
  61857. */
  61858. get input(): NodeMaterialConnectionPoint;
  61859. /**
  61860. * Gets the factor input component
  61861. */
  61862. get factor(): NodeMaterialConnectionPoint;
  61863. /**
  61864. * Gets the output component
  61865. */
  61866. get output(): NodeMaterialConnectionPoint;
  61867. protected _buildBlock(state: NodeMaterialBuildState): this;
  61868. }
  61869. }
  61870. declare module BABYLON {
  61871. /**
  61872. * Block used to clamp a float
  61873. */
  61874. export class ClampBlock extends NodeMaterialBlock {
  61875. /** Gets or sets the minimum range */
  61876. minimum: number;
  61877. /** Gets or sets the maximum range */
  61878. maximum: number;
  61879. /**
  61880. * Creates a new ClampBlock
  61881. * @param name defines the block name
  61882. */
  61883. constructor(name: string);
  61884. /**
  61885. * Gets the current class name
  61886. * @returns the class name
  61887. */
  61888. getClassName(): string;
  61889. /**
  61890. * Gets the value input component
  61891. */
  61892. get value(): NodeMaterialConnectionPoint;
  61893. /**
  61894. * Gets the output component
  61895. */
  61896. get output(): NodeMaterialConnectionPoint;
  61897. protected _buildBlock(state: NodeMaterialBuildState): this;
  61898. protected _dumpPropertiesCode(): string;
  61899. serialize(): any;
  61900. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61901. }
  61902. }
  61903. declare module BABYLON {
  61904. /**
  61905. * Block used to apply a cross product between 2 vectors
  61906. */
  61907. export class CrossBlock extends NodeMaterialBlock {
  61908. /**
  61909. * Creates a new CrossBlock
  61910. * @param name defines the block name
  61911. */
  61912. constructor(name: string);
  61913. /**
  61914. * Gets the current class name
  61915. * @returns the class name
  61916. */
  61917. getClassName(): string;
  61918. /**
  61919. * Gets the left operand input component
  61920. */
  61921. get left(): NodeMaterialConnectionPoint;
  61922. /**
  61923. * Gets the right operand input component
  61924. */
  61925. get right(): NodeMaterialConnectionPoint;
  61926. /**
  61927. * Gets the output component
  61928. */
  61929. get output(): NodeMaterialConnectionPoint;
  61930. protected _buildBlock(state: NodeMaterialBuildState): this;
  61931. }
  61932. }
  61933. declare module BABYLON {
  61934. /**
  61935. * Block used to apply a dot product between 2 vectors
  61936. */
  61937. export class DotBlock extends NodeMaterialBlock {
  61938. /**
  61939. * Creates a new DotBlock
  61940. * @param name defines the block name
  61941. */
  61942. constructor(name: string);
  61943. /**
  61944. * Gets the current class name
  61945. * @returns the class name
  61946. */
  61947. getClassName(): string;
  61948. /**
  61949. * Gets the left operand input component
  61950. */
  61951. get left(): NodeMaterialConnectionPoint;
  61952. /**
  61953. * Gets the right operand input component
  61954. */
  61955. get right(): NodeMaterialConnectionPoint;
  61956. /**
  61957. * Gets the output component
  61958. */
  61959. get output(): NodeMaterialConnectionPoint;
  61960. protected _buildBlock(state: NodeMaterialBuildState): this;
  61961. }
  61962. }
  61963. declare module BABYLON {
  61964. /**
  61965. * Block used to normalize a vector
  61966. */
  61967. export class NormalizeBlock extends NodeMaterialBlock {
  61968. /**
  61969. * Creates a new NormalizeBlock
  61970. * @param name defines the block name
  61971. */
  61972. constructor(name: string);
  61973. /**
  61974. * Gets the current class name
  61975. * @returns the class name
  61976. */
  61977. getClassName(): string;
  61978. /**
  61979. * Gets the input component
  61980. */
  61981. get input(): NodeMaterialConnectionPoint;
  61982. /**
  61983. * Gets the output component
  61984. */
  61985. get output(): NodeMaterialConnectionPoint;
  61986. protected _buildBlock(state: NodeMaterialBuildState): this;
  61987. }
  61988. }
  61989. declare module BABYLON {
  61990. /**
  61991. * Operations supported by the Trigonometry block
  61992. */
  61993. export enum TrigonometryBlockOperations {
  61994. /** Cos */
  61995. Cos = 0,
  61996. /** Sin */
  61997. Sin = 1,
  61998. /** Abs */
  61999. Abs = 2,
  62000. /** Exp */
  62001. Exp = 3,
  62002. /** Exp2 */
  62003. Exp2 = 4,
  62004. /** Round */
  62005. Round = 5,
  62006. /** Floor */
  62007. Floor = 6,
  62008. /** Ceiling */
  62009. Ceiling = 7,
  62010. /** Square root */
  62011. Sqrt = 8,
  62012. /** Log */
  62013. Log = 9,
  62014. /** Tangent */
  62015. Tan = 10,
  62016. /** Arc tangent */
  62017. ArcTan = 11,
  62018. /** Arc cosinus */
  62019. ArcCos = 12,
  62020. /** Arc sinus */
  62021. ArcSin = 13,
  62022. /** Fraction */
  62023. Fract = 14,
  62024. /** Sign */
  62025. Sign = 15,
  62026. /** To radians (from degrees) */
  62027. Radians = 16,
  62028. /** To degrees (from radians) */
  62029. Degrees = 17
  62030. }
  62031. /**
  62032. * Block used to apply trigonometry operation to floats
  62033. */
  62034. export class TrigonometryBlock extends NodeMaterialBlock {
  62035. /**
  62036. * Gets or sets the operation applied by the block
  62037. */
  62038. operation: TrigonometryBlockOperations;
  62039. /**
  62040. * Creates a new TrigonometryBlock
  62041. * @param name defines the block name
  62042. */
  62043. constructor(name: string);
  62044. /**
  62045. * Gets the current class name
  62046. * @returns the class name
  62047. */
  62048. getClassName(): string;
  62049. /**
  62050. * Gets the input component
  62051. */
  62052. get input(): NodeMaterialConnectionPoint;
  62053. /**
  62054. * Gets the output component
  62055. */
  62056. get output(): NodeMaterialConnectionPoint;
  62057. protected _buildBlock(state: NodeMaterialBuildState): this;
  62058. serialize(): any;
  62059. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62060. protected _dumpPropertiesCode(): string;
  62061. }
  62062. }
  62063. declare module BABYLON {
  62064. /**
  62065. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62066. */
  62067. export class ColorMergerBlock extends NodeMaterialBlock {
  62068. /**
  62069. * Create a new ColorMergerBlock
  62070. * @param name defines the block name
  62071. */
  62072. constructor(name: string);
  62073. /**
  62074. * Gets the current class name
  62075. * @returns the class name
  62076. */
  62077. getClassName(): string;
  62078. /**
  62079. * Gets the rgb component (input)
  62080. */
  62081. get rgbIn(): NodeMaterialConnectionPoint;
  62082. /**
  62083. * Gets the r component (input)
  62084. */
  62085. get r(): NodeMaterialConnectionPoint;
  62086. /**
  62087. * Gets the g component (input)
  62088. */
  62089. get g(): NodeMaterialConnectionPoint;
  62090. /**
  62091. * Gets the b component (input)
  62092. */
  62093. get b(): NodeMaterialConnectionPoint;
  62094. /**
  62095. * Gets the a component (input)
  62096. */
  62097. get a(): NodeMaterialConnectionPoint;
  62098. /**
  62099. * Gets the rgba component (output)
  62100. */
  62101. get rgba(): NodeMaterialConnectionPoint;
  62102. /**
  62103. * Gets the rgb component (output)
  62104. */
  62105. get rgbOut(): NodeMaterialConnectionPoint;
  62106. /**
  62107. * Gets the rgb component (output)
  62108. * @deprecated Please use rgbOut instead.
  62109. */
  62110. get rgb(): NodeMaterialConnectionPoint;
  62111. protected _buildBlock(state: NodeMaterialBuildState): this;
  62112. }
  62113. }
  62114. declare module BABYLON {
  62115. /**
  62116. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62117. */
  62118. export class VectorSplitterBlock extends NodeMaterialBlock {
  62119. /**
  62120. * Create a new VectorSplitterBlock
  62121. * @param name defines the block name
  62122. */
  62123. constructor(name: string);
  62124. /**
  62125. * Gets the current class name
  62126. * @returns the class name
  62127. */
  62128. getClassName(): string;
  62129. /**
  62130. * Gets the xyzw component (input)
  62131. */
  62132. get xyzw(): NodeMaterialConnectionPoint;
  62133. /**
  62134. * Gets the xyz component (input)
  62135. */
  62136. get xyzIn(): NodeMaterialConnectionPoint;
  62137. /**
  62138. * Gets the xy component (input)
  62139. */
  62140. get xyIn(): NodeMaterialConnectionPoint;
  62141. /**
  62142. * Gets the xyz component (output)
  62143. */
  62144. get xyzOut(): NodeMaterialConnectionPoint;
  62145. /**
  62146. * Gets the xy component (output)
  62147. */
  62148. get xyOut(): NodeMaterialConnectionPoint;
  62149. /**
  62150. * Gets the x component (output)
  62151. */
  62152. get x(): NodeMaterialConnectionPoint;
  62153. /**
  62154. * Gets the y component (output)
  62155. */
  62156. get y(): NodeMaterialConnectionPoint;
  62157. /**
  62158. * Gets the z component (output)
  62159. */
  62160. get z(): NodeMaterialConnectionPoint;
  62161. /**
  62162. * Gets the w component (output)
  62163. */
  62164. get w(): NodeMaterialConnectionPoint;
  62165. protected _inputRename(name: string): string;
  62166. protected _outputRename(name: string): string;
  62167. protected _buildBlock(state: NodeMaterialBuildState): this;
  62168. }
  62169. }
  62170. declare module BABYLON {
  62171. /**
  62172. * Block used to lerp between 2 values
  62173. */
  62174. export class LerpBlock extends NodeMaterialBlock {
  62175. /**
  62176. * Creates a new LerpBlock
  62177. * @param name defines the block name
  62178. */
  62179. constructor(name: string);
  62180. /**
  62181. * Gets the current class name
  62182. * @returns the class name
  62183. */
  62184. getClassName(): string;
  62185. /**
  62186. * Gets the left operand input component
  62187. */
  62188. get left(): NodeMaterialConnectionPoint;
  62189. /**
  62190. * Gets the right operand input component
  62191. */
  62192. get right(): NodeMaterialConnectionPoint;
  62193. /**
  62194. * Gets the gradient operand input component
  62195. */
  62196. get gradient(): NodeMaterialConnectionPoint;
  62197. /**
  62198. * Gets the output component
  62199. */
  62200. get output(): NodeMaterialConnectionPoint;
  62201. protected _buildBlock(state: NodeMaterialBuildState): this;
  62202. }
  62203. }
  62204. declare module BABYLON {
  62205. /**
  62206. * Block used to divide 2 vectors
  62207. */
  62208. export class DivideBlock extends NodeMaterialBlock {
  62209. /**
  62210. * Creates a new DivideBlock
  62211. * @param name defines the block name
  62212. */
  62213. constructor(name: string);
  62214. /**
  62215. * Gets the current class name
  62216. * @returns the class name
  62217. */
  62218. getClassName(): string;
  62219. /**
  62220. * Gets the left operand input component
  62221. */
  62222. get left(): NodeMaterialConnectionPoint;
  62223. /**
  62224. * Gets the right operand input component
  62225. */
  62226. get right(): NodeMaterialConnectionPoint;
  62227. /**
  62228. * Gets the output component
  62229. */
  62230. get output(): NodeMaterialConnectionPoint;
  62231. protected _buildBlock(state: NodeMaterialBuildState): this;
  62232. }
  62233. }
  62234. declare module BABYLON {
  62235. /**
  62236. * Block used to subtract 2 vectors
  62237. */
  62238. export class SubtractBlock extends NodeMaterialBlock {
  62239. /**
  62240. * Creates a new SubtractBlock
  62241. * @param name defines the block name
  62242. */
  62243. constructor(name: string);
  62244. /**
  62245. * Gets the current class name
  62246. * @returns the class name
  62247. */
  62248. getClassName(): string;
  62249. /**
  62250. * Gets the left operand input component
  62251. */
  62252. get left(): NodeMaterialConnectionPoint;
  62253. /**
  62254. * Gets the right operand input component
  62255. */
  62256. get right(): NodeMaterialConnectionPoint;
  62257. /**
  62258. * Gets the output component
  62259. */
  62260. get output(): NodeMaterialConnectionPoint;
  62261. protected _buildBlock(state: NodeMaterialBuildState): this;
  62262. }
  62263. }
  62264. declare module BABYLON {
  62265. /**
  62266. * Block used to step a value
  62267. */
  62268. export class StepBlock extends NodeMaterialBlock {
  62269. /**
  62270. * Creates a new StepBlock
  62271. * @param name defines the block name
  62272. */
  62273. constructor(name: string);
  62274. /**
  62275. * Gets the current class name
  62276. * @returns the class name
  62277. */
  62278. getClassName(): string;
  62279. /**
  62280. * Gets the value operand input component
  62281. */
  62282. get value(): NodeMaterialConnectionPoint;
  62283. /**
  62284. * Gets the edge operand input component
  62285. */
  62286. get edge(): NodeMaterialConnectionPoint;
  62287. /**
  62288. * Gets the output component
  62289. */
  62290. get output(): NodeMaterialConnectionPoint;
  62291. protected _buildBlock(state: NodeMaterialBuildState): this;
  62292. }
  62293. }
  62294. declare module BABYLON {
  62295. /**
  62296. * Block used to get the opposite (1 - x) of a value
  62297. */
  62298. export class OneMinusBlock extends NodeMaterialBlock {
  62299. /**
  62300. * Creates a new OneMinusBlock
  62301. * @param name defines the block name
  62302. */
  62303. constructor(name: string);
  62304. /**
  62305. * Gets the current class name
  62306. * @returns the class name
  62307. */
  62308. getClassName(): string;
  62309. /**
  62310. * Gets the input component
  62311. */
  62312. get input(): NodeMaterialConnectionPoint;
  62313. /**
  62314. * Gets the output component
  62315. */
  62316. get output(): NodeMaterialConnectionPoint;
  62317. protected _buildBlock(state: NodeMaterialBuildState): this;
  62318. }
  62319. }
  62320. declare module BABYLON {
  62321. /**
  62322. * Block used to get the view direction
  62323. */
  62324. export class ViewDirectionBlock extends NodeMaterialBlock {
  62325. /**
  62326. * Creates a new ViewDirectionBlock
  62327. * @param name defines the block name
  62328. */
  62329. constructor(name: string);
  62330. /**
  62331. * Gets the current class name
  62332. * @returns the class name
  62333. */
  62334. getClassName(): string;
  62335. /**
  62336. * Gets the world position component
  62337. */
  62338. get worldPosition(): NodeMaterialConnectionPoint;
  62339. /**
  62340. * Gets the camera position component
  62341. */
  62342. get cameraPosition(): NodeMaterialConnectionPoint;
  62343. /**
  62344. * Gets the output component
  62345. */
  62346. get output(): NodeMaterialConnectionPoint;
  62347. autoConfigure(material: NodeMaterial): void;
  62348. protected _buildBlock(state: NodeMaterialBuildState): this;
  62349. }
  62350. }
  62351. declare module BABYLON {
  62352. /**
  62353. * Block used to compute fresnel value
  62354. */
  62355. export class FresnelBlock extends NodeMaterialBlock {
  62356. /**
  62357. * Create a new FresnelBlock
  62358. * @param name defines the block name
  62359. */
  62360. constructor(name: string);
  62361. /**
  62362. * Gets the current class name
  62363. * @returns the class name
  62364. */
  62365. getClassName(): string;
  62366. /**
  62367. * Gets the world normal input component
  62368. */
  62369. get worldNormal(): NodeMaterialConnectionPoint;
  62370. /**
  62371. * Gets the view direction input component
  62372. */
  62373. get viewDirection(): NodeMaterialConnectionPoint;
  62374. /**
  62375. * Gets the bias input component
  62376. */
  62377. get bias(): NodeMaterialConnectionPoint;
  62378. /**
  62379. * Gets the camera (or eye) position component
  62380. */
  62381. get power(): NodeMaterialConnectionPoint;
  62382. /**
  62383. * Gets the fresnel output component
  62384. */
  62385. get fresnel(): NodeMaterialConnectionPoint;
  62386. autoConfigure(material: NodeMaterial): void;
  62387. protected _buildBlock(state: NodeMaterialBuildState): this;
  62388. }
  62389. }
  62390. declare module BABYLON {
  62391. /**
  62392. * Block used to get the max of 2 values
  62393. */
  62394. export class MaxBlock extends NodeMaterialBlock {
  62395. /**
  62396. * Creates a new MaxBlock
  62397. * @param name defines the block name
  62398. */
  62399. constructor(name: string);
  62400. /**
  62401. * Gets the current class name
  62402. * @returns the class name
  62403. */
  62404. getClassName(): string;
  62405. /**
  62406. * Gets the left operand input component
  62407. */
  62408. get left(): NodeMaterialConnectionPoint;
  62409. /**
  62410. * Gets the right operand input component
  62411. */
  62412. get right(): NodeMaterialConnectionPoint;
  62413. /**
  62414. * Gets the output component
  62415. */
  62416. get output(): NodeMaterialConnectionPoint;
  62417. protected _buildBlock(state: NodeMaterialBuildState): this;
  62418. }
  62419. }
  62420. declare module BABYLON {
  62421. /**
  62422. * Block used to get the min of 2 values
  62423. */
  62424. export class MinBlock extends NodeMaterialBlock {
  62425. /**
  62426. * Creates a new MinBlock
  62427. * @param name defines the block name
  62428. */
  62429. constructor(name: string);
  62430. /**
  62431. * Gets the current class name
  62432. * @returns the class name
  62433. */
  62434. getClassName(): string;
  62435. /**
  62436. * Gets the left operand input component
  62437. */
  62438. get left(): NodeMaterialConnectionPoint;
  62439. /**
  62440. * Gets the right operand input component
  62441. */
  62442. get right(): NodeMaterialConnectionPoint;
  62443. /**
  62444. * Gets the output component
  62445. */
  62446. get output(): NodeMaterialConnectionPoint;
  62447. protected _buildBlock(state: NodeMaterialBuildState): this;
  62448. }
  62449. }
  62450. declare module BABYLON {
  62451. /**
  62452. * Block used to get the distance between 2 values
  62453. */
  62454. export class DistanceBlock extends NodeMaterialBlock {
  62455. /**
  62456. * Creates a new DistanceBlock
  62457. * @param name defines the block name
  62458. */
  62459. constructor(name: string);
  62460. /**
  62461. * Gets the current class name
  62462. * @returns the class name
  62463. */
  62464. getClassName(): string;
  62465. /**
  62466. * Gets the left operand input component
  62467. */
  62468. get left(): NodeMaterialConnectionPoint;
  62469. /**
  62470. * Gets the right operand input component
  62471. */
  62472. get right(): NodeMaterialConnectionPoint;
  62473. /**
  62474. * Gets the output component
  62475. */
  62476. get output(): NodeMaterialConnectionPoint;
  62477. protected _buildBlock(state: NodeMaterialBuildState): this;
  62478. }
  62479. }
  62480. declare module BABYLON {
  62481. /**
  62482. * Block used to get the length of a vector
  62483. */
  62484. export class LengthBlock extends NodeMaterialBlock {
  62485. /**
  62486. * Creates a new LengthBlock
  62487. * @param name defines the block name
  62488. */
  62489. constructor(name: string);
  62490. /**
  62491. * Gets the current class name
  62492. * @returns the class name
  62493. */
  62494. getClassName(): string;
  62495. /**
  62496. * Gets the value input component
  62497. */
  62498. get value(): NodeMaterialConnectionPoint;
  62499. /**
  62500. * Gets the output component
  62501. */
  62502. get output(): NodeMaterialConnectionPoint;
  62503. protected _buildBlock(state: NodeMaterialBuildState): this;
  62504. }
  62505. }
  62506. declare module BABYLON {
  62507. /**
  62508. * Block used to get negative version of a value (i.e. x * -1)
  62509. */
  62510. export class NegateBlock extends NodeMaterialBlock {
  62511. /**
  62512. * Creates a new NegateBlock
  62513. * @param name defines the block name
  62514. */
  62515. constructor(name: string);
  62516. /**
  62517. * Gets the current class name
  62518. * @returns the class name
  62519. */
  62520. getClassName(): string;
  62521. /**
  62522. * Gets the value input component
  62523. */
  62524. get value(): NodeMaterialConnectionPoint;
  62525. /**
  62526. * Gets the output component
  62527. */
  62528. get output(): NodeMaterialConnectionPoint;
  62529. protected _buildBlock(state: NodeMaterialBuildState): this;
  62530. }
  62531. }
  62532. declare module BABYLON {
  62533. /**
  62534. * Block used to get the value of the first parameter raised to the power of the second
  62535. */
  62536. export class PowBlock extends NodeMaterialBlock {
  62537. /**
  62538. * Creates a new PowBlock
  62539. * @param name defines the block name
  62540. */
  62541. constructor(name: string);
  62542. /**
  62543. * Gets the current class name
  62544. * @returns the class name
  62545. */
  62546. getClassName(): string;
  62547. /**
  62548. * Gets the value operand input component
  62549. */
  62550. get value(): NodeMaterialConnectionPoint;
  62551. /**
  62552. * Gets the power operand input component
  62553. */
  62554. get power(): NodeMaterialConnectionPoint;
  62555. /**
  62556. * Gets the output component
  62557. */
  62558. get output(): NodeMaterialConnectionPoint;
  62559. protected _buildBlock(state: NodeMaterialBuildState): this;
  62560. }
  62561. }
  62562. declare module BABYLON {
  62563. /**
  62564. * Block used to get a random number
  62565. */
  62566. export class RandomNumberBlock extends NodeMaterialBlock {
  62567. /**
  62568. * Creates a new RandomNumberBlock
  62569. * @param name defines the block name
  62570. */
  62571. constructor(name: string);
  62572. /**
  62573. * Gets the current class name
  62574. * @returns the class name
  62575. */
  62576. getClassName(): string;
  62577. /**
  62578. * Gets the seed input component
  62579. */
  62580. get seed(): NodeMaterialConnectionPoint;
  62581. /**
  62582. * Gets the output component
  62583. */
  62584. get output(): NodeMaterialConnectionPoint;
  62585. protected _buildBlock(state: NodeMaterialBuildState): this;
  62586. }
  62587. }
  62588. declare module BABYLON {
  62589. /**
  62590. * Block used to compute arc tangent of 2 values
  62591. */
  62592. export class ArcTan2Block extends NodeMaterialBlock {
  62593. /**
  62594. * Creates a new ArcTan2Block
  62595. * @param name defines the block name
  62596. */
  62597. constructor(name: string);
  62598. /**
  62599. * Gets the current class name
  62600. * @returns the class name
  62601. */
  62602. getClassName(): string;
  62603. /**
  62604. * Gets the x operand input component
  62605. */
  62606. get x(): NodeMaterialConnectionPoint;
  62607. /**
  62608. * Gets the y operand input component
  62609. */
  62610. get y(): NodeMaterialConnectionPoint;
  62611. /**
  62612. * Gets the output component
  62613. */
  62614. get output(): NodeMaterialConnectionPoint;
  62615. protected _buildBlock(state: NodeMaterialBuildState): this;
  62616. }
  62617. }
  62618. declare module BABYLON {
  62619. /**
  62620. * Block used to smooth step a value
  62621. */
  62622. export class SmoothStepBlock extends NodeMaterialBlock {
  62623. /**
  62624. * Creates a new SmoothStepBlock
  62625. * @param name defines the block name
  62626. */
  62627. constructor(name: string);
  62628. /**
  62629. * Gets the current class name
  62630. * @returns the class name
  62631. */
  62632. getClassName(): string;
  62633. /**
  62634. * Gets the value operand input component
  62635. */
  62636. get value(): NodeMaterialConnectionPoint;
  62637. /**
  62638. * Gets the first edge operand input component
  62639. */
  62640. get edge0(): NodeMaterialConnectionPoint;
  62641. /**
  62642. * Gets the second edge operand input component
  62643. */
  62644. get edge1(): NodeMaterialConnectionPoint;
  62645. /**
  62646. * Gets the output component
  62647. */
  62648. get output(): NodeMaterialConnectionPoint;
  62649. protected _buildBlock(state: NodeMaterialBuildState): this;
  62650. }
  62651. }
  62652. declare module BABYLON {
  62653. /**
  62654. * Block used to get the reciprocal (1 / x) of a value
  62655. */
  62656. export class ReciprocalBlock extends NodeMaterialBlock {
  62657. /**
  62658. * Creates a new ReciprocalBlock
  62659. * @param name defines the block name
  62660. */
  62661. constructor(name: string);
  62662. /**
  62663. * Gets the current class name
  62664. * @returns the class name
  62665. */
  62666. getClassName(): string;
  62667. /**
  62668. * Gets the input component
  62669. */
  62670. get input(): NodeMaterialConnectionPoint;
  62671. /**
  62672. * Gets the output component
  62673. */
  62674. get output(): NodeMaterialConnectionPoint;
  62675. protected _buildBlock(state: NodeMaterialBuildState): this;
  62676. }
  62677. }
  62678. declare module BABYLON {
  62679. /**
  62680. * Block used to replace a color by another one
  62681. */
  62682. export class ReplaceColorBlock extends NodeMaterialBlock {
  62683. /**
  62684. * Creates a new ReplaceColorBlock
  62685. * @param name defines the block name
  62686. */
  62687. constructor(name: string);
  62688. /**
  62689. * Gets the current class name
  62690. * @returns the class name
  62691. */
  62692. getClassName(): string;
  62693. /**
  62694. * Gets the value input component
  62695. */
  62696. get value(): NodeMaterialConnectionPoint;
  62697. /**
  62698. * Gets the reference input component
  62699. */
  62700. get reference(): NodeMaterialConnectionPoint;
  62701. /**
  62702. * Gets the distance input component
  62703. */
  62704. get distance(): NodeMaterialConnectionPoint;
  62705. /**
  62706. * Gets the replacement input component
  62707. */
  62708. get replacement(): NodeMaterialConnectionPoint;
  62709. /**
  62710. * Gets the output component
  62711. */
  62712. get output(): NodeMaterialConnectionPoint;
  62713. protected _buildBlock(state: NodeMaterialBuildState): this;
  62714. }
  62715. }
  62716. declare module BABYLON {
  62717. /**
  62718. * Block used to posterize a value
  62719. * @see https://en.wikipedia.org/wiki/Posterization
  62720. */
  62721. export class PosterizeBlock extends NodeMaterialBlock {
  62722. /**
  62723. * Creates a new PosterizeBlock
  62724. * @param name defines the block name
  62725. */
  62726. constructor(name: string);
  62727. /**
  62728. * Gets the current class name
  62729. * @returns the class name
  62730. */
  62731. getClassName(): string;
  62732. /**
  62733. * Gets the value input component
  62734. */
  62735. get value(): NodeMaterialConnectionPoint;
  62736. /**
  62737. * Gets the steps input component
  62738. */
  62739. get steps(): NodeMaterialConnectionPoint;
  62740. /**
  62741. * Gets the output component
  62742. */
  62743. get output(): NodeMaterialConnectionPoint;
  62744. protected _buildBlock(state: NodeMaterialBuildState): this;
  62745. }
  62746. }
  62747. declare module BABYLON {
  62748. /**
  62749. * Operations supported by the Wave block
  62750. */
  62751. export enum WaveBlockKind {
  62752. /** SawTooth */
  62753. SawTooth = 0,
  62754. /** Square */
  62755. Square = 1,
  62756. /** Triangle */
  62757. Triangle = 2
  62758. }
  62759. /**
  62760. * Block used to apply wave operation to floats
  62761. */
  62762. export class WaveBlock extends NodeMaterialBlock {
  62763. /**
  62764. * Gets or sets the kibnd of wave to be applied by the block
  62765. */
  62766. kind: WaveBlockKind;
  62767. /**
  62768. * Creates a new WaveBlock
  62769. * @param name defines the block name
  62770. */
  62771. constructor(name: string);
  62772. /**
  62773. * Gets the current class name
  62774. * @returns the class name
  62775. */
  62776. getClassName(): string;
  62777. /**
  62778. * Gets the input component
  62779. */
  62780. get input(): NodeMaterialConnectionPoint;
  62781. /**
  62782. * Gets the output component
  62783. */
  62784. get output(): NodeMaterialConnectionPoint;
  62785. protected _buildBlock(state: NodeMaterialBuildState): this;
  62786. serialize(): any;
  62787. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62788. }
  62789. }
  62790. declare module BABYLON {
  62791. /**
  62792. * Class used to store a color step for the GradientBlock
  62793. */
  62794. export class GradientBlockColorStep {
  62795. /**
  62796. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62797. */
  62798. step: number;
  62799. /**
  62800. * Gets or sets the color associated with this step
  62801. */
  62802. color: Color3;
  62803. /**
  62804. * Creates a new GradientBlockColorStep
  62805. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62806. * @param color defines the color associated with this step
  62807. */
  62808. constructor(
  62809. /**
  62810. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62811. */
  62812. step: number,
  62813. /**
  62814. * Gets or sets the color associated with this step
  62815. */
  62816. color: Color3);
  62817. }
  62818. /**
  62819. * Block used to return a color from a gradient based on an input value between 0 and 1
  62820. */
  62821. export class GradientBlock extends NodeMaterialBlock {
  62822. /**
  62823. * Gets or sets the list of color steps
  62824. */
  62825. colorSteps: GradientBlockColorStep[];
  62826. /**
  62827. * Creates a new GradientBlock
  62828. * @param name defines the block name
  62829. */
  62830. constructor(name: string);
  62831. /**
  62832. * Gets the current class name
  62833. * @returns the class name
  62834. */
  62835. getClassName(): string;
  62836. /**
  62837. * Gets the gradient input component
  62838. */
  62839. get gradient(): NodeMaterialConnectionPoint;
  62840. /**
  62841. * Gets the output component
  62842. */
  62843. get output(): NodeMaterialConnectionPoint;
  62844. private _writeColorConstant;
  62845. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62846. serialize(): any;
  62847. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62848. protected _dumpPropertiesCode(): string;
  62849. }
  62850. }
  62851. declare module BABYLON {
  62852. /**
  62853. * Block used to normalize lerp between 2 values
  62854. */
  62855. export class NLerpBlock extends NodeMaterialBlock {
  62856. /**
  62857. * Creates a new NLerpBlock
  62858. * @param name defines the block name
  62859. */
  62860. constructor(name: string);
  62861. /**
  62862. * Gets the current class name
  62863. * @returns the class name
  62864. */
  62865. getClassName(): string;
  62866. /**
  62867. * Gets the left operand input component
  62868. */
  62869. get left(): NodeMaterialConnectionPoint;
  62870. /**
  62871. * Gets the right operand input component
  62872. */
  62873. get right(): NodeMaterialConnectionPoint;
  62874. /**
  62875. * Gets the gradient operand input component
  62876. */
  62877. get gradient(): NodeMaterialConnectionPoint;
  62878. /**
  62879. * Gets the output component
  62880. */
  62881. get output(): NodeMaterialConnectionPoint;
  62882. protected _buildBlock(state: NodeMaterialBuildState): this;
  62883. }
  62884. }
  62885. declare module BABYLON {
  62886. /**
  62887. * block used to Generate a Worley Noise 3D Noise Pattern
  62888. */
  62889. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62890. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62891. manhattanDistance: boolean;
  62892. /**
  62893. * Creates a new WorleyNoise3DBlock
  62894. * @param name defines the block name
  62895. */
  62896. constructor(name: string);
  62897. /**
  62898. * Gets the current class name
  62899. * @returns the class name
  62900. */
  62901. getClassName(): string;
  62902. /**
  62903. * Gets the seed input component
  62904. */
  62905. get seed(): NodeMaterialConnectionPoint;
  62906. /**
  62907. * Gets the jitter input component
  62908. */
  62909. get jitter(): NodeMaterialConnectionPoint;
  62910. /**
  62911. * Gets the output component
  62912. */
  62913. get output(): NodeMaterialConnectionPoint;
  62914. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62915. /**
  62916. * Exposes the properties to the UI?
  62917. */
  62918. protected _dumpPropertiesCode(): string;
  62919. /**
  62920. * Exposes the properties to the Seralize?
  62921. */
  62922. serialize(): any;
  62923. /**
  62924. * Exposes the properties to the deseralize?
  62925. */
  62926. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62927. }
  62928. }
  62929. declare module BABYLON {
  62930. /**
  62931. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62932. */
  62933. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62934. /**
  62935. * Creates a new SimplexPerlin3DBlock
  62936. * @param name defines the block name
  62937. */
  62938. constructor(name: string);
  62939. /**
  62940. * Gets the current class name
  62941. * @returns the class name
  62942. */
  62943. getClassName(): string;
  62944. /**
  62945. * Gets the seed operand input component
  62946. */
  62947. get seed(): NodeMaterialConnectionPoint;
  62948. /**
  62949. * Gets the output component
  62950. */
  62951. get output(): NodeMaterialConnectionPoint;
  62952. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62953. }
  62954. }
  62955. declare module BABYLON {
  62956. /**
  62957. * Block used to blend normals
  62958. */
  62959. export class NormalBlendBlock extends NodeMaterialBlock {
  62960. /**
  62961. * Creates a new NormalBlendBlock
  62962. * @param name defines the block name
  62963. */
  62964. constructor(name: string);
  62965. /**
  62966. * Gets the current class name
  62967. * @returns the class name
  62968. */
  62969. getClassName(): string;
  62970. /**
  62971. * Gets the first input component
  62972. */
  62973. get normalMap0(): NodeMaterialConnectionPoint;
  62974. /**
  62975. * Gets the second input component
  62976. */
  62977. get normalMap1(): NodeMaterialConnectionPoint;
  62978. /**
  62979. * Gets the output component
  62980. */
  62981. get output(): NodeMaterialConnectionPoint;
  62982. protected _buildBlock(state: NodeMaterialBuildState): this;
  62983. }
  62984. }
  62985. declare module BABYLON {
  62986. /**
  62987. * Block used to rotate a 2d vector by a given angle
  62988. */
  62989. export class Rotate2dBlock extends NodeMaterialBlock {
  62990. /**
  62991. * Creates a new Rotate2dBlock
  62992. * @param name defines the block name
  62993. */
  62994. constructor(name: string);
  62995. /**
  62996. * Gets the current class name
  62997. * @returns the class name
  62998. */
  62999. getClassName(): string;
  63000. /**
  63001. * Gets the input vector
  63002. */
  63003. get input(): NodeMaterialConnectionPoint;
  63004. /**
  63005. * Gets the input angle
  63006. */
  63007. get angle(): NodeMaterialConnectionPoint;
  63008. /**
  63009. * Gets the output component
  63010. */
  63011. get output(): NodeMaterialConnectionPoint;
  63012. autoConfigure(material: NodeMaterial): void;
  63013. protected _buildBlock(state: NodeMaterialBuildState): this;
  63014. }
  63015. }
  63016. declare module BABYLON {
  63017. /**
  63018. * Block used to get the reflected vector from a direction and a normal
  63019. */
  63020. export class ReflectBlock extends NodeMaterialBlock {
  63021. /**
  63022. * Creates a new ReflectBlock
  63023. * @param name defines the block name
  63024. */
  63025. constructor(name: string);
  63026. /**
  63027. * Gets the current class name
  63028. * @returns the class name
  63029. */
  63030. getClassName(): string;
  63031. /**
  63032. * Gets the incident component
  63033. */
  63034. get incident(): NodeMaterialConnectionPoint;
  63035. /**
  63036. * Gets the normal component
  63037. */
  63038. get normal(): NodeMaterialConnectionPoint;
  63039. /**
  63040. * Gets the output component
  63041. */
  63042. get output(): NodeMaterialConnectionPoint;
  63043. protected _buildBlock(state: NodeMaterialBuildState): this;
  63044. }
  63045. }
  63046. declare module BABYLON {
  63047. /**
  63048. * Block used to get the refracted vector from a direction and a normal
  63049. */
  63050. export class RefractBlock extends NodeMaterialBlock {
  63051. /**
  63052. * Creates a new RefractBlock
  63053. * @param name defines the block name
  63054. */
  63055. constructor(name: string);
  63056. /**
  63057. * Gets the current class name
  63058. * @returns the class name
  63059. */
  63060. getClassName(): string;
  63061. /**
  63062. * Gets the incident component
  63063. */
  63064. get incident(): NodeMaterialConnectionPoint;
  63065. /**
  63066. * Gets the normal component
  63067. */
  63068. get normal(): NodeMaterialConnectionPoint;
  63069. /**
  63070. * Gets the index of refraction component
  63071. */
  63072. get ior(): NodeMaterialConnectionPoint;
  63073. /**
  63074. * Gets the output component
  63075. */
  63076. get output(): NodeMaterialConnectionPoint;
  63077. protected _buildBlock(state: NodeMaterialBuildState): this;
  63078. }
  63079. }
  63080. declare module BABYLON {
  63081. /**
  63082. * Block used to desaturate a color
  63083. */
  63084. export class DesaturateBlock extends NodeMaterialBlock {
  63085. /**
  63086. * Creates a new DesaturateBlock
  63087. * @param name defines the block name
  63088. */
  63089. constructor(name: string);
  63090. /**
  63091. * Gets the current class name
  63092. * @returns the class name
  63093. */
  63094. getClassName(): string;
  63095. /**
  63096. * Gets the color operand input component
  63097. */
  63098. get color(): NodeMaterialConnectionPoint;
  63099. /**
  63100. * Gets the level operand input component
  63101. */
  63102. get level(): NodeMaterialConnectionPoint;
  63103. /**
  63104. * Gets the output component
  63105. */
  63106. get output(): NodeMaterialConnectionPoint;
  63107. protected _buildBlock(state: NodeMaterialBuildState): this;
  63108. }
  63109. }
  63110. declare module BABYLON {
  63111. /**
  63112. * Block used to implement the ambient occlusion module of the PBR material
  63113. */
  63114. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63115. /**
  63116. * Create a new AmbientOcclusionBlock
  63117. * @param name defines the block name
  63118. */
  63119. constructor(name: string);
  63120. /**
  63121. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63122. */
  63123. useAmbientInGrayScale: boolean;
  63124. /**
  63125. * Initialize the block and prepare the context for build
  63126. * @param state defines the state that will be used for the build
  63127. */
  63128. initialize(state: NodeMaterialBuildState): void;
  63129. /**
  63130. * Gets the current class name
  63131. * @returns the class name
  63132. */
  63133. getClassName(): string;
  63134. /**
  63135. * Gets the texture input component
  63136. */
  63137. get texture(): NodeMaterialConnectionPoint;
  63138. /**
  63139. * Gets the texture intensity component
  63140. */
  63141. get intensity(): NodeMaterialConnectionPoint;
  63142. /**
  63143. * Gets the direct light intensity input component
  63144. */
  63145. get directLightIntensity(): NodeMaterialConnectionPoint;
  63146. /**
  63147. * Gets the ambient occlusion object output component
  63148. */
  63149. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63150. /**
  63151. * Gets the main code of the block (fragment side)
  63152. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63153. * @returns the shader code
  63154. */
  63155. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63156. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63157. protected _buildBlock(state: NodeMaterialBuildState): this;
  63158. protected _dumpPropertiesCode(): string;
  63159. serialize(): any;
  63160. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63161. }
  63162. }
  63163. declare module BABYLON {
  63164. /**
  63165. * Block used to implement the reflection module of the PBR material
  63166. */
  63167. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63168. /** @hidden */
  63169. _defineLODReflectionAlpha: string;
  63170. /** @hidden */
  63171. _defineLinearSpecularReflection: string;
  63172. private _vEnvironmentIrradianceName;
  63173. /** @hidden */
  63174. _vReflectionMicrosurfaceInfosName: string;
  63175. /** @hidden */
  63176. _vReflectionInfosName: string;
  63177. /** @hidden */
  63178. _vReflectionFilteringInfoName: string;
  63179. private _scene;
  63180. /**
  63181. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63182. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63183. * It's less burden on the user side in the editor part.
  63184. */
  63185. /** @hidden */
  63186. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63187. /** @hidden */
  63188. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63189. /** @hidden */
  63190. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63191. /**
  63192. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63193. * diffuse part of the IBL.
  63194. */
  63195. useSphericalHarmonics: boolean;
  63196. /**
  63197. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63198. */
  63199. forceIrradianceInFragment: boolean;
  63200. /**
  63201. * Create a new ReflectionBlock
  63202. * @param name defines the block name
  63203. */
  63204. constructor(name: string);
  63205. /**
  63206. * Gets the current class name
  63207. * @returns the class name
  63208. */
  63209. getClassName(): string;
  63210. /**
  63211. * Gets the position input component
  63212. */
  63213. get position(): NodeMaterialConnectionPoint;
  63214. /**
  63215. * Gets the world position input component
  63216. */
  63217. get worldPosition(): NodeMaterialConnectionPoint;
  63218. /**
  63219. * Gets the world normal input component
  63220. */
  63221. get worldNormal(): NodeMaterialConnectionPoint;
  63222. /**
  63223. * Gets the world input component
  63224. */
  63225. get world(): NodeMaterialConnectionPoint;
  63226. /**
  63227. * Gets the camera (or eye) position component
  63228. */
  63229. get cameraPosition(): NodeMaterialConnectionPoint;
  63230. /**
  63231. * Gets the view input component
  63232. */
  63233. get view(): NodeMaterialConnectionPoint;
  63234. /**
  63235. * Gets the color input component
  63236. */
  63237. get color(): NodeMaterialConnectionPoint;
  63238. /**
  63239. * Gets the reflection object output component
  63240. */
  63241. get reflection(): NodeMaterialConnectionPoint;
  63242. /**
  63243. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63244. */
  63245. get hasTexture(): boolean;
  63246. /**
  63247. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63248. */
  63249. get reflectionColor(): string;
  63250. protected _getTexture(): Nullable<BaseTexture>;
  63251. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63252. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63253. /**
  63254. * Gets the code to inject in the vertex shader
  63255. * @param state current state of the node material building
  63256. * @returns the shader code
  63257. */
  63258. handleVertexSide(state: NodeMaterialBuildState): string;
  63259. /**
  63260. * Gets the main code of the block (fragment side)
  63261. * @param state current state of the node material building
  63262. * @param normalVarName name of the existing variable corresponding to the normal
  63263. * @returns the shader code
  63264. */
  63265. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63266. protected _buildBlock(state: NodeMaterialBuildState): this;
  63267. protected _dumpPropertiesCode(): string;
  63268. serialize(): any;
  63269. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63270. }
  63271. }
  63272. declare module BABYLON {
  63273. /**
  63274. * Block used to implement the sheen module of the PBR material
  63275. */
  63276. export class SheenBlock extends NodeMaterialBlock {
  63277. /**
  63278. * Create a new SheenBlock
  63279. * @param name defines the block name
  63280. */
  63281. constructor(name: string);
  63282. /**
  63283. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63284. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63285. * making it easier to setup and tweak the effect
  63286. */
  63287. albedoScaling: boolean;
  63288. /**
  63289. * Defines if the sheen is linked to the sheen color.
  63290. */
  63291. linkSheenWithAlbedo: boolean;
  63292. /**
  63293. * Initialize the block and prepare the context for build
  63294. * @param state defines the state that will be used for the build
  63295. */
  63296. initialize(state: NodeMaterialBuildState): void;
  63297. /**
  63298. * Gets the current class name
  63299. * @returns the class name
  63300. */
  63301. getClassName(): string;
  63302. /**
  63303. * Gets the intensity input component
  63304. */
  63305. get intensity(): NodeMaterialConnectionPoint;
  63306. /**
  63307. * Gets the color input component
  63308. */
  63309. get color(): NodeMaterialConnectionPoint;
  63310. /**
  63311. * Gets the roughness input component
  63312. */
  63313. get roughness(): NodeMaterialConnectionPoint;
  63314. /**
  63315. * Gets the sheen object output component
  63316. */
  63317. get sheen(): NodeMaterialConnectionPoint;
  63318. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63319. /**
  63320. * Gets the main code of the block (fragment side)
  63321. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63322. * @returns the shader code
  63323. */
  63324. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63325. protected _buildBlock(state: NodeMaterialBuildState): this;
  63326. protected _dumpPropertiesCode(): string;
  63327. serialize(): any;
  63328. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63329. }
  63330. }
  63331. declare module BABYLON {
  63332. /**
  63333. * Block used to implement the reflectivity module of the PBR material
  63334. */
  63335. export class ReflectivityBlock extends NodeMaterialBlock {
  63336. private _metallicReflectanceColor;
  63337. private _metallicF0Factor;
  63338. /** @hidden */
  63339. _vMetallicReflectanceFactorsName: string;
  63340. /**
  63341. * The property below is set by the main PBR block prior to calling methods of this class.
  63342. */
  63343. /** @hidden */
  63344. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63345. /**
  63346. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63347. */
  63348. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63349. /**
  63350. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63351. */
  63352. useMetallnessFromMetallicTextureBlue: boolean;
  63353. /**
  63354. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63355. */
  63356. useRoughnessFromMetallicTextureAlpha: boolean;
  63357. /**
  63358. * Specifies if the metallic texture contains the roughness information in its green channel.
  63359. */
  63360. useRoughnessFromMetallicTextureGreen: boolean;
  63361. /**
  63362. * Create a new ReflectivityBlock
  63363. * @param name defines the block name
  63364. */
  63365. constructor(name: string);
  63366. /**
  63367. * Initialize the block and prepare the context for build
  63368. * @param state defines the state that will be used for the build
  63369. */
  63370. initialize(state: NodeMaterialBuildState): void;
  63371. /**
  63372. * Gets the current class name
  63373. * @returns the class name
  63374. */
  63375. getClassName(): string;
  63376. /**
  63377. * Gets the metallic input component
  63378. */
  63379. get metallic(): NodeMaterialConnectionPoint;
  63380. /**
  63381. * Gets the roughness input component
  63382. */
  63383. get roughness(): NodeMaterialConnectionPoint;
  63384. /**
  63385. * Gets the texture input component
  63386. */
  63387. get texture(): NodeMaterialConnectionPoint;
  63388. /**
  63389. * Gets the reflectivity object output component
  63390. */
  63391. get reflectivity(): NodeMaterialConnectionPoint;
  63392. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63393. /**
  63394. * Gets the main code of the block (fragment side)
  63395. * @param state current state of the node material building
  63396. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63397. * @returns the shader code
  63398. */
  63399. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63400. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63401. protected _buildBlock(state: NodeMaterialBuildState): this;
  63402. protected _dumpPropertiesCode(): string;
  63403. serialize(): any;
  63404. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63405. }
  63406. }
  63407. declare module BABYLON {
  63408. /**
  63409. * Block used to implement the anisotropy module of the PBR material
  63410. */
  63411. export class AnisotropyBlock extends NodeMaterialBlock {
  63412. /**
  63413. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63414. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63415. * It's less burden on the user side in the editor part.
  63416. */
  63417. /** @hidden */
  63418. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63419. /** @hidden */
  63420. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63421. /**
  63422. * Create a new AnisotropyBlock
  63423. * @param name defines the block name
  63424. */
  63425. constructor(name: string);
  63426. /**
  63427. * Initialize the block and prepare the context for build
  63428. * @param state defines the state that will be used for the build
  63429. */
  63430. initialize(state: NodeMaterialBuildState): void;
  63431. /**
  63432. * Gets the current class name
  63433. * @returns the class name
  63434. */
  63435. getClassName(): string;
  63436. /**
  63437. * Gets the intensity input component
  63438. */
  63439. get intensity(): NodeMaterialConnectionPoint;
  63440. /**
  63441. * Gets the direction input component
  63442. */
  63443. get direction(): NodeMaterialConnectionPoint;
  63444. /**
  63445. * Gets the texture input component
  63446. */
  63447. get texture(): NodeMaterialConnectionPoint;
  63448. /**
  63449. * Gets the uv input component
  63450. */
  63451. get uv(): NodeMaterialConnectionPoint;
  63452. /**
  63453. * Gets the worldTangent input component
  63454. */
  63455. get worldTangent(): NodeMaterialConnectionPoint;
  63456. /**
  63457. * Gets the anisotropy object output component
  63458. */
  63459. get anisotropy(): NodeMaterialConnectionPoint;
  63460. private _generateTBNSpace;
  63461. /**
  63462. * Gets the main code of the block (fragment side)
  63463. * @param state current state of the node material building
  63464. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63465. * @returns the shader code
  63466. */
  63467. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63468. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63469. protected _buildBlock(state: NodeMaterialBuildState): this;
  63470. }
  63471. }
  63472. declare module BABYLON {
  63473. /**
  63474. * Block used to implement the clear coat module of the PBR material
  63475. */
  63476. export class ClearCoatBlock extends NodeMaterialBlock {
  63477. private _scene;
  63478. /**
  63479. * Create a new ClearCoatBlock
  63480. * @param name defines the block name
  63481. */
  63482. constructor(name: string);
  63483. /**
  63484. * Initialize the block and prepare the context for build
  63485. * @param state defines the state that will be used for the build
  63486. */
  63487. initialize(state: NodeMaterialBuildState): void;
  63488. /**
  63489. * Gets the current class name
  63490. * @returns the class name
  63491. */
  63492. getClassName(): string;
  63493. /**
  63494. * Gets the intensity input component
  63495. */
  63496. get intensity(): NodeMaterialConnectionPoint;
  63497. /**
  63498. * Gets the roughness input component
  63499. */
  63500. get roughness(): NodeMaterialConnectionPoint;
  63501. /**
  63502. * Gets the ior input component
  63503. */
  63504. get ior(): NodeMaterialConnectionPoint;
  63505. /**
  63506. * Gets the texture input component
  63507. */
  63508. get texture(): NodeMaterialConnectionPoint;
  63509. /**
  63510. * Gets the bump texture input component
  63511. */
  63512. get bumpTexture(): NodeMaterialConnectionPoint;
  63513. /**
  63514. * Gets the uv input component
  63515. */
  63516. get uv(): NodeMaterialConnectionPoint;
  63517. /**
  63518. * Gets the tint color input component
  63519. */
  63520. get tintColor(): NodeMaterialConnectionPoint;
  63521. /**
  63522. * Gets the tint "at distance" input component
  63523. */
  63524. get tintAtDistance(): NodeMaterialConnectionPoint;
  63525. /**
  63526. * Gets the tint thickness input component
  63527. */
  63528. get tintThickness(): NodeMaterialConnectionPoint;
  63529. /**
  63530. * Gets the world tangent input component
  63531. */
  63532. get worldTangent(): NodeMaterialConnectionPoint;
  63533. /**
  63534. * Gets the clear coat object output component
  63535. */
  63536. get clearcoat(): NodeMaterialConnectionPoint;
  63537. autoConfigure(material: NodeMaterial): void;
  63538. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63539. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63540. private _generateTBNSpace;
  63541. /**
  63542. * Gets the main code of the block (fragment side)
  63543. * @param state current state of the node material building
  63544. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63545. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63546. * @param worldPosVarName name of the variable holding the world position
  63547. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63548. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63549. * @param worldNormalVarName name of the variable holding the world normal
  63550. * @returns the shader code
  63551. */
  63552. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63553. protected _buildBlock(state: NodeMaterialBuildState): this;
  63554. }
  63555. }
  63556. declare module BABYLON {
  63557. /**
  63558. * Block used to implement the sub surface module of the PBR material
  63559. */
  63560. export class SubSurfaceBlock extends NodeMaterialBlock {
  63561. /**
  63562. * Create a new SubSurfaceBlock
  63563. * @param name defines the block name
  63564. */
  63565. constructor(name: string);
  63566. /**
  63567. * Stores the intensity of the different subsurface effects in the thickness texture.
  63568. * * the green channel is the translucency intensity.
  63569. * * the blue channel is the scattering intensity.
  63570. * * the alpha channel is the refraction intensity.
  63571. */
  63572. useMaskFromThicknessTexture: boolean;
  63573. /**
  63574. * Initialize the block and prepare the context for build
  63575. * @param state defines the state that will be used for the build
  63576. */
  63577. initialize(state: NodeMaterialBuildState): void;
  63578. /**
  63579. * Gets the current class name
  63580. * @returns the class name
  63581. */
  63582. getClassName(): string;
  63583. /**
  63584. * Gets the min thickness input component
  63585. */
  63586. get minThickness(): NodeMaterialConnectionPoint;
  63587. /**
  63588. * Gets the max thickness input component
  63589. */
  63590. get maxThickness(): NodeMaterialConnectionPoint;
  63591. /**
  63592. * Gets the thickness texture component
  63593. */
  63594. get thicknessTexture(): NodeMaterialConnectionPoint;
  63595. /**
  63596. * Gets the tint color input component
  63597. */
  63598. get tintColor(): NodeMaterialConnectionPoint;
  63599. /**
  63600. * Gets the translucency intensity input component
  63601. */
  63602. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63603. /**
  63604. * Gets the translucency diffusion distance input component
  63605. */
  63606. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63607. /**
  63608. * Gets the refraction object parameters
  63609. */
  63610. get refraction(): NodeMaterialConnectionPoint;
  63611. /**
  63612. * Gets the sub surface object output component
  63613. */
  63614. get subsurface(): NodeMaterialConnectionPoint;
  63615. autoConfigure(material: NodeMaterial): void;
  63616. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63617. /**
  63618. * Gets the main code of the block (fragment side)
  63619. * @param state current state of the node material building
  63620. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63621. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63622. * @param worldPosVarName name of the variable holding the world position
  63623. * @returns the shader code
  63624. */
  63625. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63626. protected _buildBlock(state: NodeMaterialBuildState): this;
  63627. }
  63628. }
  63629. declare module BABYLON {
  63630. /**
  63631. * Block used to implement the PBR metallic/roughness model
  63632. */
  63633. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63634. /**
  63635. * Gets or sets the light associated with this block
  63636. */
  63637. light: Nullable<Light>;
  63638. private _lightId;
  63639. private _scene;
  63640. private _environmentBRDFTexture;
  63641. private _environmentBrdfSamplerName;
  63642. private _vNormalWName;
  63643. private _invertNormalName;
  63644. /**
  63645. * Create a new ReflectionBlock
  63646. * @param name defines the block name
  63647. */
  63648. constructor(name: string);
  63649. /**
  63650. * Intensity of the direct lights e.g. the four lights available in your scene.
  63651. * This impacts both the direct diffuse and specular highlights.
  63652. */
  63653. directIntensity: number;
  63654. /**
  63655. * Intensity of the environment e.g. how much the environment will light the object
  63656. * either through harmonics for rough material or through the refelction for shiny ones.
  63657. */
  63658. environmentIntensity: number;
  63659. /**
  63660. * This is a special control allowing the reduction of the specular highlights coming from the
  63661. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63662. */
  63663. specularIntensity: number;
  63664. /**
  63665. * Defines the falloff type used in this material.
  63666. * It by default is Physical.
  63667. */
  63668. lightFalloff: number;
  63669. /**
  63670. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63671. */
  63672. useAlphaFromAlbedoTexture: boolean;
  63673. /**
  63674. * Specifies that alpha test should be used
  63675. */
  63676. useAlphaTest: boolean;
  63677. /**
  63678. * Defines the alpha limits in alpha test mode.
  63679. */
  63680. alphaTestCutoff: number;
  63681. /**
  63682. * Specifies that alpha blending should be used
  63683. */
  63684. useAlphaBlending: boolean;
  63685. /**
  63686. * Defines if the alpha value should be determined via the rgb values.
  63687. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63688. */
  63689. opacityRGB: boolean;
  63690. /**
  63691. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63692. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63693. */
  63694. useRadianceOverAlpha: boolean;
  63695. /**
  63696. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63697. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63698. */
  63699. useSpecularOverAlpha: boolean;
  63700. /**
  63701. * Enables specular anti aliasing in the PBR shader.
  63702. * It will both interacts on the Geometry for analytical and IBL lighting.
  63703. * It also prefilter the roughness map based on the bump values.
  63704. */
  63705. enableSpecularAntiAliasing: boolean;
  63706. /**
  63707. * Enables realtime filtering on the texture.
  63708. */
  63709. realTimeFiltering: boolean;
  63710. /**
  63711. * Quality switch for realtime filtering
  63712. */
  63713. realTimeFilteringQuality: number;
  63714. /**
  63715. * Defines if the material uses energy conservation.
  63716. */
  63717. useEnergyConservation: boolean;
  63718. /**
  63719. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63720. * too much the area relying on ambient texture to define their ambient occlusion.
  63721. */
  63722. useRadianceOcclusion: boolean;
  63723. /**
  63724. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63725. * makes the reflect vector face the model (under horizon).
  63726. */
  63727. useHorizonOcclusion: boolean;
  63728. /**
  63729. * If set to true, no lighting calculations will be applied.
  63730. */
  63731. unlit: boolean;
  63732. /**
  63733. * Force normal to face away from face.
  63734. */
  63735. forceNormalForward: boolean;
  63736. /**
  63737. * Defines the material debug mode.
  63738. * It helps seeing only some components of the material while troubleshooting.
  63739. */
  63740. debugMode: number;
  63741. /**
  63742. * Specify from where on screen the debug mode should start.
  63743. * The value goes from -1 (full screen) to 1 (not visible)
  63744. * It helps with side by side comparison against the final render
  63745. * This defaults to 0
  63746. */
  63747. debugLimit: number;
  63748. /**
  63749. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63750. * You can use the factor to better multiply the final value.
  63751. */
  63752. debugFactor: number;
  63753. /**
  63754. * Initialize the block and prepare the context for build
  63755. * @param state defines the state that will be used for the build
  63756. */
  63757. initialize(state: NodeMaterialBuildState): void;
  63758. /**
  63759. * Gets the current class name
  63760. * @returns the class name
  63761. */
  63762. getClassName(): string;
  63763. /**
  63764. * Gets the world position input component
  63765. */
  63766. get worldPosition(): NodeMaterialConnectionPoint;
  63767. /**
  63768. * Gets the world normal input component
  63769. */
  63770. get worldNormal(): NodeMaterialConnectionPoint;
  63771. /**
  63772. * Gets the perturbed normal input component
  63773. */
  63774. get perturbedNormal(): NodeMaterialConnectionPoint;
  63775. /**
  63776. * Gets the camera position input component
  63777. */
  63778. get cameraPosition(): NodeMaterialConnectionPoint;
  63779. /**
  63780. * Gets the base color input component
  63781. */
  63782. get baseColor(): NodeMaterialConnectionPoint;
  63783. /**
  63784. * Gets the opacity texture input component
  63785. */
  63786. get opacityTexture(): NodeMaterialConnectionPoint;
  63787. /**
  63788. * Gets the ambient color input component
  63789. */
  63790. get ambientColor(): NodeMaterialConnectionPoint;
  63791. /**
  63792. * Gets the reflectivity object parameters
  63793. */
  63794. get reflectivity(): NodeMaterialConnectionPoint;
  63795. /**
  63796. * Gets the ambient occlusion object parameters
  63797. */
  63798. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63799. /**
  63800. * Gets the reflection object parameters
  63801. */
  63802. get reflection(): NodeMaterialConnectionPoint;
  63803. /**
  63804. * Gets the sheen object parameters
  63805. */
  63806. get sheen(): NodeMaterialConnectionPoint;
  63807. /**
  63808. * Gets the clear coat object parameters
  63809. */
  63810. get clearcoat(): NodeMaterialConnectionPoint;
  63811. /**
  63812. * Gets the sub surface object parameters
  63813. */
  63814. get subsurface(): NodeMaterialConnectionPoint;
  63815. /**
  63816. * Gets the anisotropy object parameters
  63817. */
  63818. get anisotropy(): NodeMaterialConnectionPoint;
  63819. /**
  63820. * Gets the ambient output component
  63821. */
  63822. get ambient(): NodeMaterialConnectionPoint;
  63823. /**
  63824. * Gets the diffuse output component
  63825. */
  63826. get diffuse(): NodeMaterialConnectionPoint;
  63827. /**
  63828. * Gets the specular output component
  63829. */
  63830. get specular(): NodeMaterialConnectionPoint;
  63831. /**
  63832. * Gets the sheen output component
  63833. */
  63834. get sheenDir(): NodeMaterialConnectionPoint;
  63835. /**
  63836. * Gets the clear coat output component
  63837. */
  63838. get clearcoatDir(): NodeMaterialConnectionPoint;
  63839. /**
  63840. * Gets the indirect diffuse output component
  63841. */
  63842. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63843. /**
  63844. * Gets the indirect specular output component
  63845. */
  63846. get specularIndirect(): NodeMaterialConnectionPoint;
  63847. /**
  63848. * Gets the indirect sheen output component
  63849. */
  63850. get sheenIndirect(): NodeMaterialConnectionPoint;
  63851. /**
  63852. * Gets the indirect clear coat output component
  63853. */
  63854. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63855. /**
  63856. * Gets the refraction output component
  63857. */
  63858. get refraction(): NodeMaterialConnectionPoint;
  63859. /**
  63860. * Gets the global lighting output component
  63861. */
  63862. get lighting(): NodeMaterialConnectionPoint;
  63863. /**
  63864. * Gets the shadow output component
  63865. */
  63866. get shadow(): NodeMaterialConnectionPoint;
  63867. /**
  63868. * Gets the alpha output component
  63869. */
  63870. get alpha(): NodeMaterialConnectionPoint;
  63871. autoConfigure(material: NodeMaterial): void;
  63872. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63873. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63874. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63875. private _injectVertexCode;
  63876. /**
  63877. * Gets the code corresponding to the albedo/opacity module
  63878. * @returns the shader code
  63879. */
  63880. getAlbedoOpacityCode(): string;
  63881. protected _buildBlock(state: NodeMaterialBuildState): this;
  63882. protected _dumpPropertiesCode(): string;
  63883. serialize(): any;
  63884. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63885. }
  63886. }
  63887. declare module BABYLON {
  63888. /**
  63889. * Block used to compute value of one parameter modulo another
  63890. */
  63891. export class ModBlock extends NodeMaterialBlock {
  63892. /**
  63893. * Creates a new ModBlock
  63894. * @param name defines the block name
  63895. */
  63896. constructor(name: string);
  63897. /**
  63898. * Gets the current class name
  63899. * @returns the class name
  63900. */
  63901. getClassName(): string;
  63902. /**
  63903. * Gets the left operand input component
  63904. */
  63905. get left(): NodeMaterialConnectionPoint;
  63906. /**
  63907. * Gets the right operand input component
  63908. */
  63909. get right(): NodeMaterialConnectionPoint;
  63910. /**
  63911. * Gets the output component
  63912. */
  63913. get output(): NodeMaterialConnectionPoint;
  63914. protected _buildBlock(state: NodeMaterialBuildState): this;
  63915. }
  63916. }
  63917. declare module BABYLON {
  63918. /**
  63919. * Helper class to push actions to a pool of workers.
  63920. */
  63921. export class WorkerPool implements IDisposable {
  63922. private _workerInfos;
  63923. private _pendingActions;
  63924. /**
  63925. * Constructor
  63926. * @param workers Array of workers to use for actions
  63927. */
  63928. constructor(workers: Array<Worker>);
  63929. /**
  63930. * Terminates all workers and clears any pending actions.
  63931. */
  63932. dispose(): void;
  63933. /**
  63934. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63935. * pended until a worker has completed its action.
  63936. * @param action The action to perform. Call onComplete when the action is complete.
  63937. */
  63938. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63939. private _execute;
  63940. }
  63941. }
  63942. declare module BABYLON {
  63943. /**
  63944. * Configuration for Draco compression
  63945. */
  63946. export interface IDracoCompressionConfiguration {
  63947. /**
  63948. * Configuration for the decoder.
  63949. */
  63950. decoder: {
  63951. /**
  63952. * The url to the WebAssembly module.
  63953. */
  63954. wasmUrl?: string;
  63955. /**
  63956. * The url to the WebAssembly binary.
  63957. */
  63958. wasmBinaryUrl?: string;
  63959. /**
  63960. * The url to the fallback JavaScript module.
  63961. */
  63962. fallbackUrl?: string;
  63963. };
  63964. }
  63965. /**
  63966. * Draco compression (https://google.github.io/draco/)
  63967. *
  63968. * This class wraps the Draco module.
  63969. *
  63970. * **Encoder**
  63971. *
  63972. * The encoder is not currently implemented.
  63973. *
  63974. * **Decoder**
  63975. *
  63976. * 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.
  63977. *
  63978. * To update the configuration, use the following code:
  63979. * ```javascript
  63980. * DracoCompression.Configuration = {
  63981. * decoder: {
  63982. * wasmUrl: "<url to the WebAssembly library>",
  63983. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63984. * fallbackUrl: "<url to the fallback JavaScript library>",
  63985. * }
  63986. * };
  63987. * ```
  63988. *
  63989. * 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.
  63990. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63991. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63992. *
  63993. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63994. * ```javascript
  63995. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63996. * ```
  63997. *
  63998. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63999. */
  64000. export class DracoCompression implements IDisposable {
  64001. private _workerPoolPromise?;
  64002. private _decoderModulePromise?;
  64003. /**
  64004. * The configuration. Defaults to the following urls:
  64005. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64006. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64007. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64008. */
  64009. static Configuration: IDracoCompressionConfiguration;
  64010. /**
  64011. * Returns true if the decoder configuration is available.
  64012. */
  64013. static get DecoderAvailable(): boolean;
  64014. /**
  64015. * Default number of workers to create when creating the draco compression object.
  64016. */
  64017. static DefaultNumWorkers: number;
  64018. private static GetDefaultNumWorkers;
  64019. private static _Default;
  64020. /**
  64021. * Default instance for the draco compression object.
  64022. */
  64023. static get Default(): DracoCompression;
  64024. /**
  64025. * Constructor
  64026. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64027. */
  64028. constructor(numWorkers?: number);
  64029. /**
  64030. * Stop all async operations and release resources.
  64031. */
  64032. dispose(): void;
  64033. /**
  64034. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64035. * @returns a promise that resolves when ready
  64036. */
  64037. whenReadyAsync(): Promise<void>;
  64038. /**
  64039. * Decode Draco compressed mesh data to vertex data.
  64040. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64041. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64042. * @returns A promise that resolves with the decoded vertex data
  64043. */
  64044. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64045. [kind: string]: number;
  64046. }): Promise<VertexData>;
  64047. }
  64048. }
  64049. declare module BABYLON {
  64050. /**
  64051. * Class for building Constructive Solid Geometry
  64052. */
  64053. export class CSG {
  64054. private polygons;
  64055. /**
  64056. * The world matrix
  64057. */
  64058. matrix: Matrix;
  64059. /**
  64060. * Stores the position
  64061. */
  64062. position: Vector3;
  64063. /**
  64064. * Stores the rotation
  64065. */
  64066. rotation: Vector3;
  64067. /**
  64068. * Stores the rotation quaternion
  64069. */
  64070. rotationQuaternion: Nullable<Quaternion>;
  64071. /**
  64072. * Stores the scaling vector
  64073. */
  64074. scaling: Vector3;
  64075. /**
  64076. * Convert the Mesh to CSG
  64077. * @param mesh The Mesh to convert to CSG
  64078. * @returns A new CSG from the Mesh
  64079. */
  64080. static FromMesh(mesh: Mesh): CSG;
  64081. /**
  64082. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64083. * @param polygons Polygons used to construct a CSG solid
  64084. */
  64085. private static FromPolygons;
  64086. /**
  64087. * Clones, or makes a deep copy, of the CSG
  64088. * @returns A new CSG
  64089. */
  64090. clone(): CSG;
  64091. /**
  64092. * Unions this CSG with another CSG
  64093. * @param csg The CSG to union against this CSG
  64094. * @returns The unioned CSG
  64095. */
  64096. union(csg: CSG): CSG;
  64097. /**
  64098. * Unions this CSG with another CSG in place
  64099. * @param csg The CSG to union against this CSG
  64100. */
  64101. unionInPlace(csg: CSG): void;
  64102. /**
  64103. * Subtracts this CSG with another CSG
  64104. * @param csg The CSG to subtract against this CSG
  64105. * @returns A new CSG
  64106. */
  64107. subtract(csg: CSG): CSG;
  64108. /**
  64109. * Subtracts this CSG with another CSG in place
  64110. * @param csg The CSG to subtact against this CSG
  64111. */
  64112. subtractInPlace(csg: CSG): void;
  64113. /**
  64114. * Intersect this CSG with another CSG
  64115. * @param csg The CSG to intersect against this CSG
  64116. * @returns A new CSG
  64117. */
  64118. intersect(csg: CSG): CSG;
  64119. /**
  64120. * Intersects this CSG with another CSG in place
  64121. * @param csg The CSG to intersect against this CSG
  64122. */
  64123. intersectInPlace(csg: CSG): void;
  64124. /**
  64125. * Return a new CSG solid with solid and empty space switched. This solid is
  64126. * not modified.
  64127. * @returns A new CSG solid with solid and empty space switched
  64128. */
  64129. inverse(): CSG;
  64130. /**
  64131. * Inverses the CSG in place
  64132. */
  64133. inverseInPlace(): void;
  64134. /**
  64135. * This is used to keep meshes transformations so they can be restored
  64136. * when we build back a Babylon Mesh
  64137. * NB : All CSG operations are performed in world coordinates
  64138. * @param csg The CSG to copy the transform attributes from
  64139. * @returns This CSG
  64140. */
  64141. copyTransformAttributes(csg: CSG): CSG;
  64142. /**
  64143. * Build Raw mesh from CSG
  64144. * Coordinates here are in world space
  64145. * @param name The name of the mesh geometry
  64146. * @param scene The Scene
  64147. * @param keepSubMeshes Specifies if the submeshes should be kept
  64148. * @returns A new Mesh
  64149. */
  64150. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64151. /**
  64152. * Build Mesh from CSG taking material and transforms into account
  64153. * @param name The name of the Mesh
  64154. * @param material The material of the Mesh
  64155. * @param scene The Scene
  64156. * @param keepSubMeshes Specifies if submeshes should be kept
  64157. * @returns The new Mesh
  64158. */
  64159. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64160. }
  64161. }
  64162. declare module BABYLON {
  64163. /**
  64164. * Class used to create a trail following a mesh
  64165. */
  64166. export class TrailMesh extends Mesh {
  64167. private _generator;
  64168. private _autoStart;
  64169. private _running;
  64170. private _diameter;
  64171. private _length;
  64172. private _sectionPolygonPointsCount;
  64173. private _sectionVectors;
  64174. private _sectionNormalVectors;
  64175. private _beforeRenderObserver;
  64176. /**
  64177. * @constructor
  64178. * @param name The value used by scene.getMeshByName() to do a lookup.
  64179. * @param generator The mesh or transform node to generate a trail.
  64180. * @param scene The scene to add this mesh to.
  64181. * @param diameter Diameter of trailing mesh. Default is 1.
  64182. * @param length Length of trailing mesh. Default is 60.
  64183. * @param autoStart Automatically start trailing mesh. Default true.
  64184. */
  64185. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64186. /**
  64187. * "TrailMesh"
  64188. * @returns "TrailMesh"
  64189. */
  64190. getClassName(): string;
  64191. private _createMesh;
  64192. /**
  64193. * Start trailing mesh.
  64194. */
  64195. start(): void;
  64196. /**
  64197. * Stop trailing mesh.
  64198. */
  64199. stop(): void;
  64200. /**
  64201. * Update trailing mesh geometry.
  64202. */
  64203. update(): void;
  64204. /**
  64205. * Returns a new TrailMesh object.
  64206. * @param name is a string, the name given to the new mesh
  64207. * @param newGenerator use new generator object for cloned trail mesh
  64208. * @returns a new mesh
  64209. */
  64210. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64211. /**
  64212. * Serializes this trail mesh
  64213. * @param serializationObject object to write serialization to
  64214. */
  64215. serialize(serializationObject: any): void;
  64216. /**
  64217. * Parses a serialized trail mesh
  64218. * @param parsedMesh the serialized mesh
  64219. * @param scene the scene to create the trail mesh in
  64220. * @returns the created trail mesh
  64221. */
  64222. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64223. }
  64224. }
  64225. declare module BABYLON {
  64226. /**
  64227. * Class containing static functions to help procedurally build meshes
  64228. */
  64229. export class TiledBoxBuilder {
  64230. /**
  64231. * Creates a box mesh
  64232. * 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)
  64233. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64235. * * 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
  64236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64237. * @param name defines the name of the mesh
  64238. * @param options defines the options used to create the mesh
  64239. * @param scene defines the hosting scene
  64240. * @returns the box mesh
  64241. */
  64242. static CreateTiledBox(name: string, options: {
  64243. pattern?: number;
  64244. width?: number;
  64245. height?: number;
  64246. depth?: number;
  64247. tileSize?: number;
  64248. tileWidth?: number;
  64249. tileHeight?: number;
  64250. alignHorizontal?: number;
  64251. alignVertical?: number;
  64252. faceUV?: Vector4[];
  64253. faceColors?: Color4[];
  64254. sideOrientation?: number;
  64255. updatable?: boolean;
  64256. }, scene?: Nullable<Scene>): Mesh;
  64257. }
  64258. }
  64259. declare module BABYLON {
  64260. /**
  64261. * Class containing static functions to help procedurally build meshes
  64262. */
  64263. export class TorusKnotBuilder {
  64264. /**
  64265. * Creates a torus knot mesh
  64266. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64267. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64268. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64269. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64271. * * 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
  64272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64273. * @param name defines the name of the mesh
  64274. * @param options defines the options used to create the mesh
  64275. * @param scene defines the hosting scene
  64276. * @returns the torus knot mesh
  64277. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64278. */
  64279. static CreateTorusKnot(name: string, options: {
  64280. radius?: number;
  64281. tube?: number;
  64282. radialSegments?: number;
  64283. tubularSegments?: number;
  64284. p?: number;
  64285. q?: number;
  64286. updatable?: boolean;
  64287. sideOrientation?: number;
  64288. frontUVs?: Vector4;
  64289. backUVs?: Vector4;
  64290. }, scene: any): Mesh;
  64291. }
  64292. }
  64293. declare module BABYLON {
  64294. /**
  64295. * Polygon
  64296. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64297. */
  64298. export class Polygon {
  64299. /**
  64300. * Creates a rectangle
  64301. * @param xmin bottom X coord
  64302. * @param ymin bottom Y coord
  64303. * @param xmax top X coord
  64304. * @param ymax top Y coord
  64305. * @returns points that make the resulting rectation
  64306. */
  64307. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64308. /**
  64309. * Creates a circle
  64310. * @param radius radius of circle
  64311. * @param cx scale in x
  64312. * @param cy scale in y
  64313. * @param numberOfSides number of sides that make up the circle
  64314. * @returns points that make the resulting circle
  64315. */
  64316. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64317. /**
  64318. * Creates a polygon from input string
  64319. * @param input Input polygon data
  64320. * @returns the parsed points
  64321. */
  64322. static Parse(input: string): Vector2[];
  64323. /**
  64324. * Starts building a polygon from x and y coordinates
  64325. * @param x x coordinate
  64326. * @param y y coordinate
  64327. * @returns the started path2
  64328. */
  64329. static StartingAt(x: number, y: number): Path2;
  64330. }
  64331. /**
  64332. * Builds a polygon
  64333. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64334. */
  64335. export class PolygonMeshBuilder {
  64336. private _points;
  64337. private _outlinepoints;
  64338. private _holes;
  64339. private _name;
  64340. private _scene;
  64341. private _epoints;
  64342. private _eholes;
  64343. private _addToepoint;
  64344. /**
  64345. * Babylon reference to the earcut plugin.
  64346. */
  64347. bjsEarcut: any;
  64348. /**
  64349. * Creates a PolygonMeshBuilder
  64350. * @param name name of the builder
  64351. * @param contours Path of the polygon
  64352. * @param scene scene to add to when creating the mesh
  64353. * @param earcutInjection can be used to inject your own earcut reference
  64354. */
  64355. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64356. /**
  64357. * Adds a whole within the polygon
  64358. * @param hole Array of points defining the hole
  64359. * @returns this
  64360. */
  64361. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64362. /**
  64363. * Creates the polygon
  64364. * @param updatable If the mesh should be updatable
  64365. * @param depth The depth of the mesh created
  64366. * @returns the created mesh
  64367. */
  64368. build(updatable?: boolean, depth?: number): Mesh;
  64369. /**
  64370. * Creates the polygon
  64371. * @param depth The depth of the mesh created
  64372. * @returns the created VertexData
  64373. */
  64374. buildVertexData(depth?: number): VertexData;
  64375. /**
  64376. * Adds a side to the polygon
  64377. * @param positions points that make the polygon
  64378. * @param normals normals of the polygon
  64379. * @param uvs uvs of the polygon
  64380. * @param indices indices of the polygon
  64381. * @param bounds bounds of the polygon
  64382. * @param points points of the polygon
  64383. * @param depth depth of the polygon
  64384. * @param flip flip of the polygon
  64385. */
  64386. private addSide;
  64387. }
  64388. }
  64389. declare module BABYLON {
  64390. /**
  64391. * Class containing static functions to help procedurally build meshes
  64392. */
  64393. export class PolygonBuilder {
  64394. /**
  64395. * Creates a polygon mesh
  64396. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64397. * * 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
  64398. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64400. * * 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)
  64401. * * Remember you can only change the shape positions, not their number when updating a polygon
  64402. * @param name defines the name of the mesh
  64403. * @param options defines the options used to create the mesh
  64404. * @param scene defines the hosting scene
  64405. * @param earcutInjection can be used to inject your own earcut reference
  64406. * @returns the polygon mesh
  64407. */
  64408. static CreatePolygon(name: string, options: {
  64409. shape: Vector3[];
  64410. holes?: Vector3[][];
  64411. depth?: number;
  64412. faceUV?: Vector4[];
  64413. faceColors?: Color4[];
  64414. updatable?: boolean;
  64415. sideOrientation?: number;
  64416. frontUVs?: Vector4;
  64417. backUVs?: Vector4;
  64418. wrap?: boolean;
  64419. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64420. /**
  64421. * Creates an extruded polygon mesh, with depth in the Y direction.
  64422. * * 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)
  64423. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64424. * @param name defines the name of the mesh
  64425. * @param options defines the options used to create the mesh
  64426. * @param scene defines the hosting scene
  64427. * @param earcutInjection can be used to inject your own earcut reference
  64428. * @returns the polygon mesh
  64429. */
  64430. static ExtrudePolygon(name: string, options: {
  64431. shape: Vector3[];
  64432. holes?: Vector3[][];
  64433. depth?: number;
  64434. faceUV?: Vector4[];
  64435. faceColors?: Color4[];
  64436. updatable?: boolean;
  64437. sideOrientation?: number;
  64438. frontUVs?: Vector4;
  64439. backUVs?: Vector4;
  64440. wrap?: boolean;
  64441. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64442. }
  64443. }
  64444. declare module BABYLON {
  64445. /**
  64446. * Class containing static functions to help procedurally build meshes
  64447. */
  64448. export class LatheBuilder {
  64449. /**
  64450. * Creates lathe mesh.
  64451. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64452. * * 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
  64453. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64454. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64455. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64456. * * 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
  64457. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64458. * * 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
  64459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64460. * * 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
  64461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64463. * @param name defines the name of the mesh
  64464. * @param options defines the options used to create the mesh
  64465. * @param scene defines the hosting scene
  64466. * @returns the lathe mesh
  64467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64468. */
  64469. static CreateLathe(name: string, options: {
  64470. shape: Vector3[];
  64471. radius?: number;
  64472. tessellation?: number;
  64473. clip?: number;
  64474. arc?: number;
  64475. closed?: boolean;
  64476. updatable?: boolean;
  64477. sideOrientation?: number;
  64478. frontUVs?: Vector4;
  64479. backUVs?: Vector4;
  64480. cap?: number;
  64481. invertUV?: boolean;
  64482. }, scene?: Nullable<Scene>): Mesh;
  64483. }
  64484. }
  64485. declare module BABYLON {
  64486. /**
  64487. * Class containing static functions to help procedurally build meshes
  64488. */
  64489. export class TiledPlaneBuilder {
  64490. /**
  64491. * Creates a tiled plane mesh
  64492. * * The parameter `pattern` will, depending on value, do nothing or
  64493. * * * flip (reflect about central vertical) alternate tiles across and up
  64494. * * * flip every tile on alternate rows
  64495. * * * rotate (180 degs) alternate tiles across and up
  64496. * * * rotate every tile on alternate rows
  64497. * * * flip and rotate alternate tiles across and up
  64498. * * * flip and rotate every tile on alternate rows
  64499. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64500. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64501. * * 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
  64502. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64503. * * 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)
  64504. * * 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)
  64505. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64506. * @param name defines the name of the mesh
  64507. * @param options defines the options used to create the mesh
  64508. * @param scene defines the hosting scene
  64509. * @returns the box mesh
  64510. */
  64511. static CreateTiledPlane(name: string, options: {
  64512. pattern?: number;
  64513. tileSize?: number;
  64514. tileWidth?: number;
  64515. tileHeight?: number;
  64516. size?: number;
  64517. width?: number;
  64518. height?: number;
  64519. alignHorizontal?: number;
  64520. alignVertical?: number;
  64521. sideOrientation?: number;
  64522. frontUVs?: Vector4;
  64523. backUVs?: Vector4;
  64524. updatable?: boolean;
  64525. }, scene?: Nullable<Scene>): Mesh;
  64526. }
  64527. }
  64528. declare module BABYLON {
  64529. /**
  64530. * Class containing static functions to help procedurally build meshes
  64531. */
  64532. export class TubeBuilder {
  64533. /**
  64534. * Creates a tube mesh.
  64535. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64536. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64537. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64538. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64539. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64540. * * 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)
  64541. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64542. * * 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
  64543. * * 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
  64544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64545. * * 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
  64546. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64548. * @param name defines the name of the mesh
  64549. * @param options defines the options used to create the mesh
  64550. * @param scene defines the hosting scene
  64551. * @returns the tube mesh
  64552. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64553. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64554. */
  64555. static CreateTube(name: string, options: {
  64556. path: Vector3[];
  64557. radius?: number;
  64558. tessellation?: number;
  64559. radiusFunction?: {
  64560. (i: number, distance: number): number;
  64561. };
  64562. cap?: number;
  64563. arc?: number;
  64564. updatable?: boolean;
  64565. sideOrientation?: number;
  64566. frontUVs?: Vector4;
  64567. backUVs?: Vector4;
  64568. instance?: Mesh;
  64569. invertUV?: boolean;
  64570. }, scene?: Nullable<Scene>): Mesh;
  64571. }
  64572. }
  64573. declare module BABYLON {
  64574. /**
  64575. * Class containing static functions to help procedurally build meshes
  64576. */
  64577. export class IcoSphereBuilder {
  64578. /**
  64579. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64580. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64581. * * 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`)
  64582. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64583. * * 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
  64584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64585. * * 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
  64586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64587. * @param name defines the name of the mesh
  64588. * @param options defines the options used to create the mesh
  64589. * @param scene defines the hosting scene
  64590. * @returns the icosahedron mesh
  64591. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64592. */
  64593. static CreateIcoSphere(name: string, options: {
  64594. radius?: number;
  64595. radiusX?: number;
  64596. radiusY?: number;
  64597. radiusZ?: number;
  64598. flat?: boolean;
  64599. subdivisions?: number;
  64600. sideOrientation?: number;
  64601. frontUVs?: Vector4;
  64602. backUVs?: Vector4;
  64603. updatable?: boolean;
  64604. }, scene?: Nullable<Scene>): Mesh;
  64605. }
  64606. }
  64607. declare module BABYLON {
  64608. /**
  64609. * Class containing static functions to help procedurally build meshes
  64610. */
  64611. export class DecalBuilder {
  64612. /**
  64613. * Creates a decal mesh.
  64614. * 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
  64615. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64616. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64617. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64618. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64619. * @param name defines the name of the mesh
  64620. * @param sourceMesh defines the mesh where the decal must be applied
  64621. * @param options defines the options used to create the mesh
  64622. * @param scene defines the hosting scene
  64623. * @returns the decal mesh
  64624. * @see https://doc.babylonjs.com/how_to/decals
  64625. */
  64626. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64627. position?: Vector3;
  64628. normal?: Vector3;
  64629. size?: Vector3;
  64630. angle?: number;
  64631. }): Mesh;
  64632. }
  64633. }
  64634. declare module BABYLON {
  64635. /**
  64636. * Class containing static functions to help procedurally build meshes
  64637. */
  64638. export class MeshBuilder {
  64639. /**
  64640. * Creates a box mesh
  64641. * * The parameter `size` sets the size (float) of each box side (default 1)
  64642. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64643. * * 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)
  64644. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64646. * * 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
  64647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64648. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64649. * @param name defines the name of the mesh
  64650. * @param options defines the options used to create the mesh
  64651. * @param scene defines the hosting scene
  64652. * @returns the box mesh
  64653. */
  64654. static CreateBox(name: string, options: {
  64655. size?: number;
  64656. width?: number;
  64657. height?: number;
  64658. depth?: number;
  64659. faceUV?: Vector4[];
  64660. faceColors?: Color4[];
  64661. sideOrientation?: number;
  64662. frontUVs?: Vector4;
  64663. backUVs?: Vector4;
  64664. wrap?: boolean;
  64665. topBaseAt?: number;
  64666. bottomBaseAt?: number;
  64667. updatable?: boolean;
  64668. }, scene?: Nullable<Scene>): Mesh;
  64669. /**
  64670. * Creates a tiled box mesh
  64671. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64673. * @param name defines the name of the mesh
  64674. * @param options defines the options used to create the mesh
  64675. * @param scene defines the hosting scene
  64676. * @returns the tiled box mesh
  64677. */
  64678. static CreateTiledBox(name: string, options: {
  64679. pattern?: number;
  64680. size?: number;
  64681. width?: number;
  64682. height?: number;
  64683. depth: number;
  64684. tileSize?: number;
  64685. tileWidth?: number;
  64686. tileHeight?: number;
  64687. faceUV?: Vector4[];
  64688. faceColors?: Color4[];
  64689. alignHorizontal?: number;
  64690. alignVertical?: number;
  64691. sideOrientation?: number;
  64692. updatable?: boolean;
  64693. }, scene?: Nullable<Scene>): Mesh;
  64694. /**
  64695. * Creates a sphere mesh
  64696. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64697. * * 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`)
  64698. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64699. * * 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
  64700. * * 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)
  64701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64704. * @param name defines the name of the mesh
  64705. * @param options defines the options used to create the mesh
  64706. * @param scene defines the hosting scene
  64707. * @returns the sphere mesh
  64708. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64709. */
  64710. static CreateSphere(name: string, options: {
  64711. segments?: number;
  64712. diameter?: number;
  64713. diameterX?: number;
  64714. diameterY?: number;
  64715. diameterZ?: number;
  64716. arc?: number;
  64717. slice?: number;
  64718. sideOrientation?: number;
  64719. frontUVs?: Vector4;
  64720. backUVs?: Vector4;
  64721. updatable?: boolean;
  64722. }, scene?: Nullable<Scene>): Mesh;
  64723. /**
  64724. * Creates a plane polygonal mesh. By default, this is a disc
  64725. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64726. * * 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
  64727. * * 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
  64728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64729. * * 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
  64730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64731. * @param name defines the name of the mesh
  64732. * @param options defines the options used to create the mesh
  64733. * @param scene defines the hosting scene
  64734. * @returns the plane polygonal mesh
  64735. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64736. */
  64737. static CreateDisc(name: string, options: {
  64738. radius?: number;
  64739. tessellation?: number;
  64740. arc?: number;
  64741. updatable?: boolean;
  64742. sideOrientation?: number;
  64743. frontUVs?: Vector4;
  64744. backUVs?: Vector4;
  64745. }, scene?: Nullable<Scene>): Mesh;
  64746. /**
  64747. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64748. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64749. * * 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`)
  64750. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64751. * * 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
  64752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64753. * * 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
  64754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64755. * @param name defines the name of the mesh
  64756. * @param options defines the options used to create the mesh
  64757. * @param scene defines the hosting scene
  64758. * @returns the icosahedron mesh
  64759. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64760. */
  64761. static CreateIcoSphere(name: string, options: {
  64762. radius?: number;
  64763. radiusX?: number;
  64764. radiusY?: number;
  64765. radiusZ?: number;
  64766. flat?: boolean;
  64767. subdivisions?: number;
  64768. sideOrientation?: number;
  64769. frontUVs?: Vector4;
  64770. backUVs?: Vector4;
  64771. updatable?: boolean;
  64772. }, scene?: Nullable<Scene>): Mesh;
  64773. /**
  64774. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64775. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64776. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64777. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64778. * * 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
  64779. * * 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
  64780. * * 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
  64781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64782. * * 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
  64783. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64784. * * 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
  64785. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64786. * * 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
  64787. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64789. * @param name defines the name of the mesh
  64790. * @param options defines the options used to create the mesh
  64791. * @param scene defines the hosting scene
  64792. * @returns the ribbon mesh
  64793. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64794. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64795. */
  64796. static CreateRibbon(name: string, options: {
  64797. pathArray: Vector3[][];
  64798. closeArray?: boolean;
  64799. closePath?: boolean;
  64800. offset?: number;
  64801. updatable?: boolean;
  64802. sideOrientation?: number;
  64803. frontUVs?: Vector4;
  64804. backUVs?: Vector4;
  64805. instance?: Mesh;
  64806. invertUV?: boolean;
  64807. uvs?: Vector2[];
  64808. colors?: Color4[];
  64809. }, scene?: Nullable<Scene>): Mesh;
  64810. /**
  64811. * Creates a cylinder or a cone mesh
  64812. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64813. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64814. * * 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.
  64815. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64816. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64817. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64818. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64819. * * 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).
  64820. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64821. * * 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).
  64822. * * 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
  64823. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64824. * * 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
  64825. * * 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.
  64826. * * If `enclose` is false, a ring surface is one element.
  64827. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64828. * * 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
  64829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64830. * * 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
  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 cylinder mesh
  64836. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64837. */
  64838. static CreateCylinder(name: string, options: {
  64839. height?: number;
  64840. diameterTop?: number;
  64841. diameterBottom?: number;
  64842. diameter?: number;
  64843. tessellation?: number;
  64844. subdivisions?: number;
  64845. arc?: number;
  64846. faceColors?: Color4[];
  64847. faceUV?: Vector4[];
  64848. updatable?: boolean;
  64849. hasRings?: boolean;
  64850. enclose?: boolean;
  64851. cap?: number;
  64852. sideOrientation?: number;
  64853. frontUVs?: Vector4;
  64854. backUVs?: Vector4;
  64855. }, scene?: Nullable<Scene>): Mesh;
  64856. /**
  64857. * Creates a torus mesh
  64858. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64859. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64860. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64862. * * 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
  64863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64864. * @param name defines the name of the mesh
  64865. * @param options defines the options used to create the mesh
  64866. * @param scene defines the hosting scene
  64867. * @returns the torus mesh
  64868. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64869. */
  64870. static CreateTorus(name: string, options: {
  64871. diameter?: number;
  64872. thickness?: number;
  64873. tessellation?: number;
  64874. updatable?: boolean;
  64875. sideOrientation?: number;
  64876. frontUVs?: Vector4;
  64877. backUVs?: Vector4;
  64878. }, scene?: Nullable<Scene>): Mesh;
  64879. /**
  64880. * Creates a torus knot mesh
  64881. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64882. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64883. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64884. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64886. * * 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
  64887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64888. * @param name defines the name of the mesh
  64889. * @param options defines the options used to create the mesh
  64890. * @param scene defines the hosting scene
  64891. * @returns the torus knot mesh
  64892. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64893. */
  64894. static CreateTorusKnot(name: string, options: {
  64895. radius?: number;
  64896. tube?: number;
  64897. radialSegments?: number;
  64898. tubularSegments?: number;
  64899. p?: number;
  64900. q?: number;
  64901. updatable?: boolean;
  64902. sideOrientation?: number;
  64903. frontUVs?: Vector4;
  64904. backUVs?: Vector4;
  64905. }, scene?: Nullable<Scene>): Mesh;
  64906. /**
  64907. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64908. * * 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
  64909. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64910. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64911. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64912. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64913. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64914. * * 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
  64915. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64918. * @param name defines the name of the new line system
  64919. * @param options defines the options used to create the line system
  64920. * @param scene defines the hosting scene
  64921. * @returns a new line system mesh
  64922. */
  64923. static CreateLineSystem(name: string, options: {
  64924. lines: Vector3[][];
  64925. updatable?: boolean;
  64926. instance?: Nullable<LinesMesh>;
  64927. colors?: Nullable<Color4[][]>;
  64928. useVertexAlpha?: boolean;
  64929. }, scene: Nullable<Scene>): LinesMesh;
  64930. /**
  64931. * Creates a line mesh
  64932. * 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
  64933. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64934. * * The parameter `points` is an array successive Vector3
  64935. * * 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
  64936. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64937. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64938. * * When updating an instance, remember that only point positions can change, not the number of points
  64939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64940. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64941. * @param name defines the name of the new line system
  64942. * @param options defines the options used to create the line system
  64943. * @param scene defines the hosting scene
  64944. * @returns a new line mesh
  64945. */
  64946. static CreateLines(name: string, options: {
  64947. points: Vector3[];
  64948. updatable?: boolean;
  64949. instance?: Nullable<LinesMesh>;
  64950. colors?: Color4[];
  64951. useVertexAlpha?: boolean;
  64952. }, scene?: Nullable<Scene>): LinesMesh;
  64953. /**
  64954. * Creates a dashed line mesh
  64955. * * 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
  64956. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64957. * * The parameter `points` is an array successive Vector3
  64958. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64959. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64960. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64961. * * 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
  64962. * * When updating an instance, remember that only point positions can change, not the number of points
  64963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64964. * @param name defines the name of the mesh
  64965. * @param options defines the options used to create the mesh
  64966. * @param scene defines the hosting scene
  64967. * @returns the dashed line mesh
  64968. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64969. */
  64970. static CreateDashedLines(name: string, options: {
  64971. points: Vector3[];
  64972. dashSize?: number;
  64973. gapSize?: number;
  64974. dashNb?: number;
  64975. updatable?: boolean;
  64976. instance?: LinesMesh;
  64977. }, scene?: Nullable<Scene>): LinesMesh;
  64978. /**
  64979. * 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.
  64980. * * 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.
  64981. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64982. * * 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.
  64983. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64984. * * 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
  64985. * * 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
  64986. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64988. * * 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
  64989. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64991. * @param name defines the name of the mesh
  64992. * @param options defines the options used to create the mesh
  64993. * @param scene defines the hosting scene
  64994. * @returns the extruded shape mesh
  64995. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64996. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64997. */
  64998. static ExtrudeShape(name: string, options: {
  64999. shape: Vector3[];
  65000. path: Vector3[];
  65001. scale?: number;
  65002. rotation?: number;
  65003. cap?: number;
  65004. updatable?: boolean;
  65005. sideOrientation?: number;
  65006. frontUVs?: Vector4;
  65007. backUVs?: Vector4;
  65008. instance?: Mesh;
  65009. invertUV?: boolean;
  65010. }, scene?: Nullable<Scene>): Mesh;
  65011. /**
  65012. * Creates an custom extruded shape mesh.
  65013. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65014. * * 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.
  65015. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65016. * * 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
  65017. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65018. * * 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
  65019. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65020. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65021. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65022. * * 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
  65023. * * 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
  65024. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65026. * * 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
  65027. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65029. * @param name defines the name of the mesh
  65030. * @param options defines the options used to create the mesh
  65031. * @param scene defines the hosting scene
  65032. * @returns the custom extruded shape mesh
  65033. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65034. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65035. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65036. */
  65037. static ExtrudeShapeCustom(name: string, options: {
  65038. shape: Vector3[];
  65039. path: Vector3[];
  65040. scaleFunction?: any;
  65041. rotationFunction?: any;
  65042. ribbonCloseArray?: boolean;
  65043. ribbonClosePath?: boolean;
  65044. cap?: number;
  65045. updatable?: boolean;
  65046. sideOrientation?: number;
  65047. frontUVs?: Vector4;
  65048. backUVs?: Vector4;
  65049. instance?: Mesh;
  65050. invertUV?: boolean;
  65051. }, scene?: Nullable<Scene>): Mesh;
  65052. /**
  65053. * Creates lathe mesh.
  65054. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65055. * * 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
  65056. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65057. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65058. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65059. * * 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
  65060. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65061. * * 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
  65062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65063. * * 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
  65064. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65066. * @param name defines the name of the mesh
  65067. * @param options defines the options used to create the mesh
  65068. * @param scene defines the hosting scene
  65069. * @returns the lathe mesh
  65070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65071. */
  65072. static CreateLathe(name: string, options: {
  65073. shape: Vector3[];
  65074. radius?: number;
  65075. tessellation?: number;
  65076. clip?: number;
  65077. arc?: number;
  65078. closed?: boolean;
  65079. updatable?: boolean;
  65080. sideOrientation?: number;
  65081. frontUVs?: Vector4;
  65082. backUVs?: Vector4;
  65083. cap?: number;
  65084. invertUV?: boolean;
  65085. }, scene?: Nullable<Scene>): Mesh;
  65086. /**
  65087. * Creates a tiled plane mesh
  65088. * * You can set a limited pattern arrangement with the tiles
  65089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65090. * * 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
  65091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65092. * @param name defines the name of the mesh
  65093. * @param options defines the options used to create the mesh
  65094. * @param scene defines the hosting scene
  65095. * @returns the plane mesh
  65096. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65097. */
  65098. static CreateTiledPlane(name: string, options: {
  65099. pattern?: number;
  65100. tileSize?: number;
  65101. tileWidth?: number;
  65102. tileHeight?: number;
  65103. size?: number;
  65104. width?: number;
  65105. height?: number;
  65106. alignHorizontal?: number;
  65107. alignVertical?: number;
  65108. sideOrientation?: number;
  65109. frontUVs?: Vector4;
  65110. backUVs?: Vector4;
  65111. updatable?: boolean;
  65112. }, scene?: Nullable<Scene>): Mesh;
  65113. /**
  65114. * Creates a plane mesh
  65115. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65116. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65117. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65119. * * 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
  65120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65121. * @param name defines the name of the mesh
  65122. * @param options defines the options used to create the mesh
  65123. * @param scene defines the hosting scene
  65124. * @returns the plane mesh
  65125. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65126. */
  65127. static CreatePlane(name: string, options: {
  65128. size?: number;
  65129. width?: number;
  65130. height?: number;
  65131. sideOrientation?: number;
  65132. frontUVs?: Vector4;
  65133. backUVs?: Vector4;
  65134. updatable?: boolean;
  65135. sourcePlane?: Plane;
  65136. }, scene?: Nullable<Scene>): Mesh;
  65137. /**
  65138. * Creates a ground mesh
  65139. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65140. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65142. * @param name defines the name of the mesh
  65143. * @param options defines the options used to create the mesh
  65144. * @param scene defines the hosting scene
  65145. * @returns the ground mesh
  65146. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65147. */
  65148. static CreateGround(name: string, options: {
  65149. width?: number;
  65150. height?: number;
  65151. subdivisions?: number;
  65152. subdivisionsX?: number;
  65153. subdivisionsY?: number;
  65154. updatable?: boolean;
  65155. }, scene?: Nullable<Scene>): Mesh;
  65156. /**
  65157. * Creates a tiled ground mesh
  65158. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65159. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65160. * * 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
  65161. * * 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
  65162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65163. * @param name defines the name of the mesh
  65164. * @param options defines the options used to create the mesh
  65165. * @param scene defines the hosting scene
  65166. * @returns the tiled ground mesh
  65167. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65168. */
  65169. static CreateTiledGround(name: string, options: {
  65170. xmin: number;
  65171. zmin: number;
  65172. xmax: number;
  65173. zmax: number;
  65174. subdivisions?: {
  65175. w: number;
  65176. h: number;
  65177. };
  65178. precision?: {
  65179. w: number;
  65180. h: number;
  65181. };
  65182. updatable?: boolean;
  65183. }, scene?: Nullable<Scene>): Mesh;
  65184. /**
  65185. * Creates a ground mesh from a height map
  65186. * * The parameter `url` sets the URL of the height map image resource.
  65187. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65188. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65189. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65190. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65191. * * 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.
  65192. * * 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).
  65193. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65195. * @param name defines the name of the mesh
  65196. * @param url defines the url to the height map
  65197. * @param options defines the options used to create the mesh
  65198. * @param scene defines the hosting scene
  65199. * @returns the ground mesh
  65200. * @see https://doc.babylonjs.com/babylon101/height_map
  65201. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65202. */
  65203. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65204. width?: number;
  65205. height?: number;
  65206. subdivisions?: number;
  65207. minHeight?: number;
  65208. maxHeight?: number;
  65209. colorFilter?: Color3;
  65210. alphaFilter?: number;
  65211. updatable?: boolean;
  65212. onReady?: (mesh: GroundMesh) => void;
  65213. }, scene?: Nullable<Scene>): GroundMesh;
  65214. /**
  65215. * Creates a polygon mesh
  65216. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65217. * * 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
  65218. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65220. * * 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)
  65221. * * Remember you can only change the shape positions, not their number when updating a polygon
  65222. * @param name defines the name of the mesh
  65223. * @param options defines the options used to create the mesh
  65224. * @param scene defines the hosting scene
  65225. * @param earcutInjection can be used to inject your own earcut reference
  65226. * @returns the polygon mesh
  65227. */
  65228. static CreatePolygon(name: string, options: {
  65229. shape: Vector3[];
  65230. holes?: Vector3[][];
  65231. depth?: number;
  65232. faceUV?: Vector4[];
  65233. faceColors?: Color4[];
  65234. updatable?: boolean;
  65235. sideOrientation?: number;
  65236. frontUVs?: Vector4;
  65237. backUVs?: Vector4;
  65238. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65239. /**
  65240. * Creates an extruded polygon mesh, with depth in the Y direction.
  65241. * * 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)
  65242. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65243. * @param name defines the name of the mesh
  65244. * @param options defines the options used to create the mesh
  65245. * @param scene defines the hosting scene
  65246. * @param earcutInjection can be used to inject your own earcut reference
  65247. * @returns the polygon mesh
  65248. */
  65249. static ExtrudePolygon(name: string, options: {
  65250. shape: Vector3[];
  65251. holes?: Vector3[][];
  65252. depth?: number;
  65253. faceUV?: Vector4[];
  65254. faceColors?: Color4[];
  65255. updatable?: boolean;
  65256. sideOrientation?: number;
  65257. frontUVs?: Vector4;
  65258. backUVs?: Vector4;
  65259. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65260. /**
  65261. * Creates a tube mesh.
  65262. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65263. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65264. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65265. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65266. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65267. * * 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)
  65268. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65269. * * 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
  65270. * * 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
  65271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65272. * * 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
  65273. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65275. * @param name defines the name of the mesh
  65276. * @param options defines the options used to create the mesh
  65277. * @param scene defines the hosting scene
  65278. * @returns the tube mesh
  65279. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65280. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65281. */
  65282. static CreateTube(name: string, options: {
  65283. path: Vector3[];
  65284. radius?: number;
  65285. tessellation?: number;
  65286. radiusFunction?: {
  65287. (i: number, distance: number): number;
  65288. };
  65289. cap?: number;
  65290. arc?: number;
  65291. updatable?: boolean;
  65292. sideOrientation?: number;
  65293. frontUVs?: Vector4;
  65294. backUVs?: Vector4;
  65295. instance?: Mesh;
  65296. invertUV?: boolean;
  65297. }, scene?: Nullable<Scene>): Mesh;
  65298. /**
  65299. * Creates a polyhedron mesh
  65300. * * 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
  65301. * * The parameter `size` (positive float, default 1) sets the polygon size
  65302. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65303. * * 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`
  65304. * * 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
  65305. * * 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)`)
  65306. * * 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
  65307. * * 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
  65308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65309. * * 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
  65310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65311. * @param name defines the name of the mesh
  65312. * @param options defines the options used to create the mesh
  65313. * @param scene defines the hosting scene
  65314. * @returns the polyhedron mesh
  65315. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65316. */
  65317. static CreatePolyhedron(name: string, options: {
  65318. type?: number;
  65319. size?: number;
  65320. sizeX?: number;
  65321. sizeY?: number;
  65322. sizeZ?: number;
  65323. custom?: any;
  65324. faceUV?: Vector4[];
  65325. faceColors?: Color4[];
  65326. flat?: boolean;
  65327. updatable?: boolean;
  65328. sideOrientation?: number;
  65329. frontUVs?: Vector4;
  65330. backUVs?: Vector4;
  65331. }, scene?: Nullable<Scene>): Mesh;
  65332. /**
  65333. * Creates a decal mesh.
  65334. * 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
  65335. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65336. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65337. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65338. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65339. * @param name defines the name of the mesh
  65340. * @param sourceMesh defines the mesh where the decal must be applied
  65341. * @param options defines the options used to create the mesh
  65342. * @param scene defines the hosting scene
  65343. * @returns the decal mesh
  65344. * @see https://doc.babylonjs.com/how_to/decals
  65345. */
  65346. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65347. position?: Vector3;
  65348. normal?: Vector3;
  65349. size?: Vector3;
  65350. angle?: number;
  65351. }): Mesh;
  65352. }
  65353. }
  65354. declare module BABYLON {
  65355. /**
  65356. * A simplifier interface for future simplification implementations
  65357. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65358. */
  65359. export interface ISimplifier {
  65360. /**
  65361. * Simplification of a given mesh according to the given settings.
  65362. * Since this requires computation, it is assumed that the function runs async.
  65363. * @param settings The settings of the simplification, including quality and distance
  65364. * @param successCallback A callback that will be called after the mesh was simplified.
  65365. * @param errorCallback in case of an error, this callback will be called. optional.
  65366. */
  65367. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65368. }
  65369. /**
  65370. * Expected simplification settings.
  65371. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65372. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65373. */
  65374. export interface ISimplificationSettings {
  65375. /**
  65376. * Gets or sets the expected quality
  65377. */
  65378. quality: number;
  65379. /**
  65380. * Gets or sets the distance when this optimized version should be used
  65381. */
  65382. distance: number;
  65383. /**
  65384. * Gets an already optimized mesh
  65385. */
  65386. optimizeMesh?: boolean;
  65387. }
  65388. /**
  65389. * Class used to specify simplification options
  65390. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65391. */
  65392. export class SimplificationSettings implements ISimplificationSettings {
  65393. /** expected quality */
  65394. quality: number;
  65395. /** distance when this optimized version should be used */
  65396. distance: number;
  65397. /** already optimized mesh */
  65398. optimizeMesh?: boolean | undefined;
  65399. /**
  65400. * Creates a SimplificationSettings
  65401. * @param quality expected quality
  65402. * @param distance distance when this optimized version should be used
  65403. * @param optimizeMesh already optimized mesh
  65404. */
  65405. constructor(
  65406. /** expected quality */
  65407. quality: number,
  65408. /** distance when this optimized version should be used */
  65409. distance: number,
  65410. /** already optimized mesh */
  65411. optimizeMesh?: boolean | undefined);
  65412. }
  65413. /**
  65414. * Interface used to define a simplification task
  65415. */
  65416. export interface ISimplificationTask {
  65417. /**
  65418. * Array of settings
  65419. */
  65420. settings: Array<ISimplificationSettings>;
  65421. /**
  65422. * Simplification type
  65423. */
  65424. simplificationType: SimplificationType;
  65425. /**
  65426. * Mesh to simplify
  65427. */
  65428. mesh: Mesh;
  65429. /**
  65430. * Callback called on success
  65431. */
  65432. successCallback?: () => void;
  65433. /**
  65434. * Defines if parallel processing can be used
  65435. */
  65436. parallelProcessing: boolean;
  65437. }
  65438. /**
  65439. * Queue used to order the simplification tasks
  65440. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65441. */
  65442. export class SimplificationQueue {
  65443. private _simplificationArray;
  65444. /**
  65445. * Gets a boolean indicating that the process is still running
  65446. */
  65447. running: boolean;
  65448. /**
  65449. * Creates a new queue
  65450. */
  65451. constructor();
  65452. /**
  65453. * Adds a new simplification task
  65454. * @param task defines a task to add
  65455. */
  65456. addTask(task: ISimplificationTask): void;
  65457. /**
  65458. * Execute next task
  65459. */
  65460. executeNext(): void;
  65461. /**
  65462. * Execute a simplification task
  65463. * @param task defines the task to run
  65464. */
  65465. runSimplification(task: ISimplificationTask): void;
  65466. private getSimplifier;
  65467. }
  65468. /**
  65469. * The implemented types of simplification
  65470. * At the moment only Quadratic Error Decimation is implemented
  65471. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65472. */
  65473. export enum SimplificationType {
  65474. /** Quadratic error decimation */
  65475. QUADRATIC = 0
  65476. }
  65477. /**
  65478. * An implementation of the Quadratic Error simplification algorithm.
  65479. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65480. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65481. * @author RaananW
  65482. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65483. */
  65484. export class QuadraticErrorSimplification implements ISimplifier {
  65485. private _mesh;
  65486. private triangles;
  65487. private vertices;
  65488. private references;
  65489. private _reconstructedMesh;
  65490. /** Gets or sets the number pf sync interations */
  65491. syncIterations: number;
  65492. /** Gets or sets the aggressiveness of the simplifier */
  65493. aggressiveness: number;
  65494. /** Gets or sets the number of allowed iterations for decimation */
  65495. decimationIterations: number;
  65496. /** Gets or sets the espilon to use for bounding box computation */
  65497. boundingBoxEpsilon: number;
  65498. /**
  65499. * Creates a new QuadraticErrorSimplification
  65500. * @param _mesh defines the target mesh
  65501. */
  65502. constructor(_mesh: Mesh);
  65503. /**
  65504. * Simplification of a given mesh according to the given settings.
  65505. * Since this requires computation, it is assumed that the function runs async.
  65506. * @param settings The settings of the simplification, including quality and distance
  65507. * @param successCallback A callback that will be called after the mesh was simplified.
  65508. */
  65509. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65510. private runDecimation;
  65511. private initWithMesh;
  65512. private init;
  65513. private reconstructMesh;
  65514. private initDecimatedMesh;
  65515. private isFlipped;
  65516. private updateTriangles;
  65517. private identifyBorder;
  65518. private updateMesh;
  65519. private vertexError;
  65520. private calculateError;
  65521. }
  65522. }
  65523. declare module BABYLON {
  65524. interface Scene {
  65525. /** @hidden (Backing field) */
  65526. _simplificationQueue: SimplificationQueue;
  65527. /**
  65528. * Gets or sets the simplification queue attached to the scene
  65529. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65530. */
  65531. simplificationQueue: SimplificationQueue;
  65532. }
  65533. interface Mesh {
  65534. /**
  65535. * Simplify the mesh according to the given array of settings.
  65536. * Function will return immediately and will simplify async
  65537. * @param settings a collection of simplification settings
  65538. * @param parallelProcessing should all levels calculate parallel or one after the other
  65539. * @param simplificationType the type of simplification to run
  65540. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65541. * @returns the current mesh
  65542. */
  65543. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65544. }
  65545. /**
  65546. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65547. * created in a scene
  65548. */
  65549. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65550. /**
  65551. * The component name helpfull to identify the component in the list of scene components.
  65552. */
  65553. readonly name: string;
  65554. /**
  65555. * The scene the component belongs to.
  65556. */
  65557. scene: Scene;
  65558. /**
  65559. * Creates a new instance of the component for the given scene
  65560. * @param scene Defines the scene to register the component in
  65561. */
  65562. constructor(scene: Scene);
  65563. /**
  65564. * Registers the component in a given scene
  65565. */
  65566. register(): void;
  65567. /**
  65568. * Rebuilds the elements related to this component in case of
  65569. * context lost for instance.
  65570. */
  65571. rebuild(): void;
  65572. /**
  65573. * Disposes the component and the associated ressources
  65574. */
  65575. dispose(): void;
  65576. private _beforeCameraUpdate;
  65577. }
  65578. }
  65579. declare module BABYLON {
  65580. interface Mesh {
  65581. /**
  65582. * Creates a new thin instance
  65583. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65584. * @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
  65585. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65586. */
  65587. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65588. /**
  65589. * Adds the transformation (matrix) of the current mesh as a thin instance
  65590. * @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
  65591. * @returns the thin instance index number
  65592. */
  65593. thinInstanceAddSelf(refresh: boolean): number;
  65594. /**
  65595. * Registers a custom attribute to be used with thin instances
  65596. * @param kind name of the attribute
  65597. * @param stride size in floats of the attribute
  65598. */
  65599. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65600. /**
  65601. * Sets the matrix of a thin instance
  65602. * @param index index of the thin instance
  65603. * @param matrix matrix to set
  65604. * @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
  65605. */
  65606. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65607. /**
  65608. * Sets the value of a custom attribute for a thin instance
  65609. * @param kind name of the attribute
  65610. * @param index index of the thin instance
  65611. * @param value value to set
  65612. * @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
  65613. */
  65614. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65615. /**
  65616. * 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.
  65617. */
  65618. thinInstanceCount: number;
  65619. /**
  65620. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65621. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65622. * @param buffer buffer to set
  65623. * @param stride size in floats of each value of the buffer
  65624. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65625. */
  65626. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65627. /**
  65628. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65629. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65630. */
  65631. thinInstanceBufferUpdated(kind: string): void;
  65632. /**
  65633. * Refreshes the bounding info, taking into account all the thin instances defined
  65634. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65635. */
  65636. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65637. /** @hidden */
  65638. _thinInstanceInitializeUserStorage(): void;
  65639. /** @hidden */
  65640. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65641. /** @hidden */
  65642. _userThinInstanceBuffersStorage: {
  65643. data: {
  65644. [key: string]: Float32Array;
  65645. };
  65646. sizes: {
  65647. [key: string]: number;
  65648. };
  65649. vertexBuffers: {
  65650. [key: string]: Nullable<VertexBuffer>;
  65651. };
  65652. strides: {
  65653. [key: string]: number;
  65654. };
  65655. };
  65656. }
  65657. }
  65658. declare module BABYLON {
  65659. /**
  65660. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65661. */
  65662. export interface INavigationEnginePlugin {
  65663. /**
  65664. * plugin name
  65665. */
  65666. name: string;
  65667. /**
  65668. * Creates a navigation mesh
  65669. * @param meshes array of all the geometry used to compute the navigatio mesh
  65670. * @param parameters bunch of parameters used to filter geometry
  65671. */
  65672. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65673. /**
  65674. * Create a navigation mesh debug mesh
  65675. * @param scene is where the mesh will be added
  65676. * @returns debug display mesh
  65677. */
  65678. createDebugNavMesh(scene: Scene): Mesh;
  65679. /**
  65680. * Get a navigation mesh constrained position, closest to the parameter position
  65681. * @param position world position
  65682. * @returns the closest point to position constrained by the navigation mesh
  65683. */
  65684. getClosestPoint(position: Vector3): Vector3;
  65685. /**
  65686. * Get a navigation mesh constrained position, closest to the parameter position
  65687. * @param position world position
  65688. * @param result output the closest point to position constrained by the navigation mesh
  65689. */
  65690. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65691. /**
  65692. * Get a navigation mesh constrained position, within a particular radius
  65693. * @param position world position
  65694. * @param maxRadius the maximum distance to the constrained world position
  65695. * @returns the closest point to position constrained by the navigation mesh
  65696. */
  65697. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65698. /**
  65699. * Get a navigation mesh constrained position, within a particular radius
  65700. * @param position world position
  65701. * @param maxRadius the maximum distance to the constrained world position
  65702. * @param result output the closest point to position constrained by the navigation mesh
  65703. */
  65704. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65705. /**
  65706. * Compute the final position from a segment made of destination-position
  65707. * @param position world position
  65708. * @param destination world position
  65709. * @returns the resulting point along the navmesh
  65710. */
  65711. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65712. /**
  65713. * Compute the final position from a segment made of destination-position
  65714. * @param position world position
  65715. * @param destination world position
  65716. * @param result output the resulting point along the navmesh
  65717. */
  65718. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65719. /**
  65720. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65721. * @param start world position
  65722. * @param end world position
  65723. * @returns array containing world position composing the path
  65724. */
  65725. computePath(start: Vector3, end: Vector3): Vector3[];
  65726. /**
  65727. * If this plugin is supported
  65728. * @returns true if plugin is supported
  65729. */
  65730. isSupported(): boolean;
  65731. /**
  65732. * Create a new Crowd so you can add agents
  65733. * @param maxAgents the maximum agent count in the crowd
  65734. * @param maxAgentRadius the maximum radius an agent can have
  65735. * @param scene to attach the crowd to
  65736. * @returns the crowd you can add agents to
  65737. */
  65738. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65739. /**
  65740. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65741. * The queries will try to find a solution within those bounds
  65742. * default is (1,1,1)
  65743. * @param extent x,y,z value that define the extent around the queries point of reference
  65744. */
  65745. setDefaultQueryExtent(extent: Vector3): void;
  65746. /**
  65747. * Get the Bounding box extent specified by setDefaultQueryExtent
  65748. * @returns the box extent values
  65749. */
  65750. getDefaultQueryExtent(): Vector3;
  65751. /**
  65752. * build the navmesh from a previously saved state using getNavmeshData
  65753. * @param data the Uint8Array returned by getNavmeshData
  65754. */
  65755. buildFromNavmeshData(data: Uint8Array): void;
  65756. /**
  65757. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65758. * @returns data the Uint8Array that can be saved and reused
  65759. */
  65760. getNavmeshData(): Uint8Array;
  65761. /**
  65762. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65763. * @param result output the box extent values
  65764. */
  65765. getDefaultQueryExtentToRef(result: Vector3): void;
  65766. /**
  65767. * Release all resources
  65768. */
  65769. dispose(): void;
  65770. }
  65771. /**
  65772. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65773. */
  65774. export interface ICrowd {
  65775. /**
  65776. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65777. * You can attach anything to that node. The node position is updated in the scene update tick.
  65778. * @param pos world position that will be constrained by the navigation mesh
  65779. * @param parameters agent parameters
  65780. * @param transform hooked to the agent that will be update by the scene
  65781. * @returns agent index
  65782. */
  65783. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65784. /**
  65785. * Returns the agent position in world space
  65786. * @param index agent index returned by addAgent
  65787. * @returns world space position
  65788. */
  65789. getAgentPosition(index: number): Vector3;
  65790. /**
  65791. * Gets the agent position result in world space
  65792. * @param index agent index returned by addAgent
  65793. * @param result output world space position
  65794. */
  65795. getAgentPositionToRef(index: number, result: Vector3): void;
  65796. /**
  65797. * Gets the agent velocity in world space
  65798. * @param index agent index returned by addAgent
  65799. * @returns world space velocity
  65800. */
  65801. getAgentVelocity(index: number): Vector3;
  65802. /**
  65803. * Gets the agent velocity result in world space
  65804. * @param index agent index returned by addAgent
  65805. * @param result output world space velocity
  65806. */
  65807. getAgentVelocityToRef(index: number, result: Vector3): void;
  65808. /**
  65809. * remove a particular agent previously created
  65810. * @param index agent index returned by addAgent
  65811. */
  65812. removeAgent(index: number): void;
  65813. /**
  65814. * get the list of all agents attached to this crowd
  65815. * @returns list of agent indices
  65816. */
  65817. getAgents(): number[];
  65818. /**
  65819. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65820. * @param deltaTime in seconds
  65821. */
  65822. update(deltaTime: number): void;
  65823. /**
  65824. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65825. * @param index agent index returned by addAgent
  65826. * @param destination targeted world position
  65827. */
  65828. agentGoto(index: number, destination: Vector3): void;
  65829. /**
  65830. * Teleport the agent to a new position
  65831. * @param index agent index returned by addAgent
  65832. * @param destination targeted world position
  65833. */
  65834. agentTeleport(index: number, destination: Vector3): void;
  65835. /**
  65836. * Update agent parameters
  65837. * @param index agent index returned by addAgent
  65838. * @param parameters agent parameters
  65839. */
  65840. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65841. /**
  65842. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65843. * The queries will try to find a solution within those bounds
  65844. * default is (1,1,1)
  65845. * @param extent x,y,z value that define the extent around the queries point of reference
  65846. */
  65847. setDefaultQueryExtent(extent: Vector3): void;
  65848. /**
  65849. * Get the Bounding box extent specified by setDefaultQueryExtent
  65850. * @returns the box extent values
  65851. */
  65852. getDefaultQueryExtent(): Vector3;
  65853. /**
  65854. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65855. * @param result output the box extent values
  65856. */
  65857. getDefaultQueryExtentToRef(result: Vector3): void;
  65858. /**
  65859. * Release all resources
  65860. */
  65861. dispose(): void;
  65862. }
  65863. /**
  65864. * Configures an agent
  65865. */
  65866. export interface IAgentParameters {
  65867. /**
  65868. * Agent radius. [Limit: >= 0]
  65869. */
  65870. radius: number;
  65871. /**
  65872. * Agent height. [Limit: > 0]
  65873. */
  65874. height: number;
  65875. /**
  65876. * Maximum allowed acceleration. [Limit: >= 0]
  65877. */
  65878. maxAcceleration: number;
  65879. /**
  65880. * Maximum allowed speed. [Limit: >= 0]
  65881. */
  65882. maxSpeed: number;
  65883. /**
  65884. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65885. */
  65886. collisionQueryRange: number;
  65887. /**
  65888. * The path visibility optimization range. [Limit: > 0]
  65889. */
  65890. pathOptimizationRange: number;
  65891. /**
  65892. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65893. */
  65894. separationWeight: number;
  65895. }
  65896. /**
  65897. * Configures the navigation mesh creation
  65898. */
  65899. export interface INavMeshParameters {
  65900. /**
  65901. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65902. */
  65903. cs: number;
  65904. /**
  65905. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65906. */
  65907. ch: number;
  65908. /**
  65909. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65910. */
  65911. walkableSlopeAngle: number;
  65912. /**
  65913. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65914. * be considered walkable. [Limit: >= 3] [Units: vx]
  65915. */
  65916. walkableHeight: number;
  65917. /**
  65918. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65919. */
  65920. walkableClimb: number;
  65921. /**
  65922. * The distance to erode/shrink the walkable area of the heightfield away from
  65923. * obstructions. [Limit: >=0] [Units: vx]
  65924. */
  65925. walkableRadius: number;
  65926. /**
  65927. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65928. */
  65929. maxEdgeLen: number;
  65930. /**
  65931. * The maximum distance a simplfied contour's border edges should deviate
  65932. * the original raw contour. [Limit: >=0] [Units: vx]
  65933. */
  65934. maxSimplificationError: number;
  65935. /**
  65936. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65937. */
  65938. minRegionArea: number;
  65939. /**
  65940. * Any regions with a span count smaller than this value will, if possible,
  65941. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65942. */
  65943. mergeRegionArea: number;
  65944. /**
  65945. * The maximum number of vertices allowed for polygons generated during the
  65946. * contour to polygon conversion process. [Limit: >= 3]
  65947. */
  65948. maxVertsPerPoly: number;
  65949. /**
  65950. * Sets the sampling distance to use when generating the detail mesh.
  65951. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65952. */
  65953. detailSampleDist: number;
  65954. /**
  65955. * The maximum distance the detail mesh surface should deviate from heightfield
  65956. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65957. */
  65958. detailSampleMaxError: number;
  65959. }
  65960. }
  65961. declare module BABYLON {
  65962. /**
  65963. * RecastJS navigation plugin
  65964. */
  65965. export class RecastJSPlugin implements INavigationEnginePlugin {
  65966. /**
  65967. * Reference to the Recast library
  65968. */
  65969. bjsRECAST: any;
  65970. /**
  65971. * plugin name
  65972. */
  65973. name: string;
  65974. /**
  65975. * the first navmesh created. We might extend this to support multiple navmeshes
  65976. */
  65977. navMesh: any;
  65978. /**
  65979. * Initializes the recastJS plugin
  65980. * @param recastInjection can be used to inject your own recast reference
  65981. */
  65982. constructor(recastInjection?: any);
  65983. /**
  65984. * Creates a navigation mesh
  65985. * @param meshes array of all the geometry used to compute the navigatio mesh
  65986. * @param parameters bunch of parameters used to filter geometry
  65987. */
  65988. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65989. /**
  65990. * Create a navigation mesh debug mesh
  65991. * @param scene is where the mesh will be added
  65992. * @returns debug display mesh
  65993. */
  65994. createDebugNavMesh(scene: Scene): Mesh;
  65995. /**
  65996. * Get a navigation mesh constrained position, closest to the parameter position
  65997. * @param position world position
  65998. * @returns the closest point to position constrained by the navigation mesh
  65999. */
  66000. getClosestPoint(position: Vector3): Vector3;
  66001. /**
  66002. * Get a navigation mesh constrained position, closest to the parameter position
  66003. * @param position world position
  66004. * @param result output the closest point to position constrained by the navigation mesh
  66005. */
  66006. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66007. /**
  66008. * Get a navigation mesh constrained position, within a particular radius
  66009. * @param position world position
  66010. * @param maxRadius the maximum distance to the constrained world position
  66011. * @returns the closest point to position constrained by the navigation mesh
  66012. */
  66013. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66014. /**
  66015. * Get a navigation mesh constrained position, within a particular radius
  66016. * @param position world position
  66017. * @param maxRadius the maximum distance to the constrained world position
  66018. * @param result output the closest point to position constrained by the navigation mesh
  66019. */
  66020. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66021. /**
  66022. * Compute the final position from a segment made of destination-position
  66023. * @param position world position
  66024. * @param destination world position
  66025. * @returns the resulting point along the navmesh
  66026. */
  66027. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66028. /**
  66029. * Compute the final position from a segment made of destination-position
  66030. * @param position world position
  66031. * @param destination world position
  66032. * @param result output the resulting point along the navmesh
  66033. */
  66034. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66035. /**
  66036. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66037. * @param start world position
  66038. * @param end world position
  66039. * @returns array containing world position composing the path
  66040. */
  66041. computePath(start: Vector3, end: Vector3): Vector3[];
  66042. /**
  66043. * Create a new Crowd so you can add agents
  66044. * @param maxAgents the maximum agent count in the crowd
  66045. * @param maxAgentRadius the maximum radius an agent can have
  66046. * @param scene to attach the crowd to
  66047. * @returns the crowd you can add agents to
  66048. */
  66049. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66050. /**
  66051. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66052. * The queries will try to find a solution within those bounds
  66053. * default is (1,1,1)
  66054. * @param extent x,y,z value that define the extent around the queries point of reference
  66055. */
  66056. setDefaultQueryExtent(extent: Vector3): void;
  66057. /**
  66058. * Get the Bounding box extent specified by setDefaultQueryExtent
  66059. * @returns the box extent values
  66060. */
  66061. getDefaultQueryExtent(): Vector3;
  66062. /**
  66063. * build the navmesh from a previously saved state using getNavmeshData
  66064. * @param data the Uint8Array returned by getNavmeshData
  66065. */
  66066. buildFromNavmeshData(data: Uint8Array): void;
  66067. /**
  66068. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66069. * @returns data the Uint8Array that can be saved and reused
  66070. */
  66071. getNavmeshData(): Uint8Array;
  66072. /**
  66073. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66074. * @param result output the box extent values
  66075. */
  66076. getDefaultQueryExtentToRef(result: Vector3): void;
  66077. /**
  66078. * Disposes
  66079. */
  66080. dispose(): void;
  66081. /**
  66082. * If this plugin is supported
  66083. * @returns true if plugin is supported
  66084. */
  66085. isSupported(): boolean;
  66086. }
  66087. /**
  66088. * Recast detour crowd implementation
  66089. */
  66090. export class RecastJSCrowd implements ICrowd {
  66091. /**
  66092. * Recast/detour plugin
  66093. */
  66094. bjsRECASTPlugin: RecastJSPlugin;
  66095. /**
  66096. * Link to the detour crowd
  66097. */
  66098. recastCrowd: any;
  66099. /**
  66100. * One transform per agent
  66101. */
  66102. transforms: TransformNode[];
  66103. /**
  66104. * All agents created
  66105. */
  66106. agents: number[];
  66107. /**
  66108. * Link to the scene is kept to unregister the crowd from the scene
  66109. */
  66110. private _scene;
  66111. /**
  66112. * Observer for crowd updates
  66113. */
  66114. private _onBeforeAnimationsObserver;
  66115. /**
  66116. * Constructor
  66117. * @param plugin recastJS plugin
  66118. * @param maxAgents the maximum agent count in the crowd
  66119. * @param maxAgentRadius the maximum radius an agent can have
  66120. * @param scene to attach the crowd to
  66121. * @returns the crowd you can add agents to
  66122. */
  66123. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66124. /**
  66125. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66126. * You can attach anything to that node. The node position is updated in the scene update tick.
  66127. * @param pos world position that will be constrained by the navigation mesh
  66128. * @param parameters agent parameters
  66129. * @param transform hooked to the agent that will be update by the scene
  66130. * @returns agent index
  66131. */
  66132. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66133. /**
  66134. * Returns the agent position in world space
  66135. * @param index agent index returned by addAgent
  66136. * @returns world space position
  66137. */
  66138. getAgentPosition(index: number): Vector3;
  66139. /**
  66140. * Returns the agent position result in world space
  66141. * @param index agent index returned by addAgent
  66142. * @param result output world space position
  66143. */
  66144. getAgentPositionToRef(index: number, result: Vector3): void;
  66145. /**
  66146. * Returns the agent velocity in world space
  66147. * @param index agent index returned by addAgent
  66148. * @returns world space velocity
  66149. */
  66150. getAgentVelocity(index: number): Vector3;
  66151. /**
  66152. * Returns the agent velocity result in world space
  66153. * @param index agent index returned by addAgent
  66154. * @param result output world space velocity
  66155. */
  66156. getAgentVelocityToRef(index: number, result: Vector3): void;
  66157. /**
  66158. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66159. * @param index agent index returned by addAgent
  66160. * @param destination targeted world position
  66161. */
  66162. agentGoto(index: number, destination: Vector3): void;
  66163. /**
  66164. * Teleport the agent to a new position
  66165. * @param index agent index returned by addAgent
  66166. * @param destination targeted world position
  66167. */
  66168. agentTeleport(index: number, destination: Vector3): void;
  66169. /**
  66170. * Update agent parameters
  66171. * @param index agent index returned by addAgent
  66172. * @param parameters agent parameters
  66173. */
  66174. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66175. /**
  66176. * remove a particular agent previously created
  66177. * @param index agent index returned by addAgent
  66178. */
  66179. removeAgent(index: number): void;
  66180. /**
  66181. * get the list of all agents attached to this crowd
  66182. * @returns list of agent indices
  66183. */
  66184. getAgents(): number[];
  66185. /**
  66186. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66187. * @param deltaTime in seconds
  66188. */
  66189. update(deltaTime: number): void;
  66190. /**
  66191. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66192. * The queries will try to find a solution within those bounds
  66193. * default is (1,1,1)
  66194. * @param extent x,y,z value that define the extent around the queries point of reference
  66195. */
  66196. setDefaultQueryExtent(extent: Vector3): void;
  66197. /**
  66198. * Get the Bounding box extent specified by setDefaultQueryExtent
  66199. * @returns the box extent values
  66200. */
  66201. getDefaultQueryExtent(): Vector3;
  66202. /**
  66203. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66204. * @param result output the box extent values
  66205. */
  66206. getDefaultQueryExtentToRef(result: Vector3): void;
  66207. /**
  66208. * Release all resources
  66209. */
  66210. dispose(): void;
  66211. }
  66212. }
  66213. declare module BABYLON {
  66214. /**
  66215. * Class used to enable access to IndexedDB
  66216. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66217. */
  66218. export class Database implements IOfflineProvider {
  66219. private _callbackManifestChecked;
  66220. private _currentSceneUrl;
  66221. private _db;
  66222. private _enableSceneOffline;
  66223. private _enableTexturesOffline;
  66224. private _manifestVersionFound;
  66225. private _mustUpdateRessources;
  66226. private _hasReachedQuota;
  66227. private _isSupported;
  66228. private _idbFactory;
  66229. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66230. private static IsUASupportingBlobStorage;
  66231. /**
  66232. * Gets a boolean indicating if Database storate is enabled (off by default)
  66233. */
  66234. static IDBStorageEnabled: boolean;
  66235. /**
  66236. * Gets a boolean indicating if scene must be saved in the database
  66237. */
  66238. get enableSceneOffline(): boolean;
  66239. /**
  66240. * Gets a boolean indicating if textures must be saved in the database
  66241. */
  66242. get enableTexturesOffline(): boolean;
  66243. /**
  66244. * Creates a new Database
  66245. * @param urlToScene defines the url to load the scene
  66246. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66247. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66248. */
  66249. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66250. private static _ParseURL;
  66251. private static _ReturnFullUrlLocation;
  66252. private _checkManifestFile;
  66253. /**
  66254. * Open the database and make it available
  66255. * @param successCallback defines the callback to call on success
  66256. * @param errorCallback defines the callback to call on error
  66257. */
  66258. open(successCallback: () => void, errorCallback: () => void): void;
  66259. /**
  66260. * Loads an image from the database
  66261. * @param url defines the url to load from
  66262. * @param image defines the target DOM image
  66263. */
  66264. loadImage(url: string, image: HTMLImageElement): void;
  66265. private _loadImageFromDBAsync;
  66266. private _saveImageIntoDBAsync;
  66267. private _checkVersionFromDB;
  66268. private _loadVersionFromDBAsync;
  66269. private _saveVersionIntoDBAsync;
  66270. /**
  66271. * Loads a file from database
  66272. * @param url defines the URL to load from
  66273. * @param sceneLoaded defines a callback to call on success
  66274. * @param progressCallBack defines a callback to call when progress changed
  66275. * @param errorCallback defines a callback to call on error
  66276. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66277. */
  66278. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66279. private _loadFileAsync;
  66280. private _saveFileAsync;
  66281. /**
  66282. * Validates if xhr data is correct
  66283. * @param xhr defines the request to validate
  66284. * @param dataType defines the expected data type
  66285. * @returns true if data is correct
  66286. */
  66287. private static _ValidateXHRData;
  66288. }
  66289. }
  66290. declare module BABYLON {
  66291. /** @hidden */
  66292. export var gpuUpdateParticlesPixelShader: {
  66293. name: string;
  66294. shader: string;
  66295. };
  66296. }
  66297. declare module BABYLON {
  66298. /** @hidden */
  66299. export var gpuUpdateParticlesVertexShader: {
  66300. name: string;
  66301. shader: string;
  66302. };
  66303. }
  66304. declare module BABYLON {
  66305. /** @hidden */
  66306. export var clipPlaneFragmentDeclaration2: {
  66307. name: string;
  66308. shader: string;
  66309. };
  66310. }
  66311. declare module BABYLON {
  66312. /** @hidden */
  66313. export var gpuRenderParticlesPixelShader: {
  66314. name: string;
  66315. shader: string;
  66316. };
  66317. }
  66318. declare module BABYLON {
  66319. /** @hidden */
  66320. export var clipPlaneVertexDeclaration2: {
  66321. name: string;
  66322. shader: string;
  66323. };
  66324. }
  66325. declare module BABYLON {
  66326. /** @hidden */
  66327. export var gpuRenderParticlesVertexShader: {
  66328. name: string;
  66329. shader: string;
  66330. };
  66331. }
  66332. declare module BABYLON {
  66333. /**
  66334. * This represents a GPU particle system in Babylon
  66335. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66336. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66337. */
  66338. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66339. /**
  66340. * The layer mask we are rendering the particles through.
  66341. */
  66342. layerMask: number;
  66343. private _capacity;
  66344. private _activeCount;
  66345. private _currentActiveCount;
  66346. private _accumulatedCount;
  66347. private _renderEffect;
  66348. private _updateEffect;
  66349. private _buffer0;
  66350. private _buffer1;
  66351. private _spriteBuffer;
  66352. private _updateVAO;
  66353. private _renderVAO;
  66354. private _targetIndex;
  66355. private _sourceBuffer;
  66356. private _targetBuffer;
  66357. private _engine;
  66358. private _currentRenderId;
  66359. private _started;
  66360. private _stopped;
  66361. private _timeDelta;
  66362. private _randomTexture;
  66363. private _randomTexture2;
  66364. private _attributesStrideSize;
  66365. private _updateEffectOptions;
  66366. private _randomTextureSize;
  66367. private _actualFrame;
  66368. private _customEffect;
  66369. private readonly _rawTextureWidth;
  66370. /**
  66371. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66372. */
  66373. static get IsSupported(): boolean;
  66374. /**
  66375. * An event triggered when the system is disposed.
  66376. */
  66377. onDisposeObservable: Observable<IParticleSystem>;
  66378. /**
  66379. * Gets the maximum number of particles active at the same time.
  66380. * @returns The max number of active particles.
  66381. */
  66382. getCapacity(): number;
  66383. /**
  66384. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66385. * to override the particles.
  66386. */
  66387. forceDepthWrite: boolean;
  66388. /**
  66389. * Gets or set the number of active particles
  66390. */
  66391. get activeParticleCount(): number;
  66392. set activeParticleCount(value: number);
  66393. private _preWarmDone;
  66394. /**
  66395. * Specifies if the particles are updated in emitter local space or world space.
  66396. */
  66397. isLocal: boolean;
  66398. /**
  66399. * Is this system ready to be used/rendered
  66400. * @return true if the system is ready
  66401. */
  66402. isReady(): boolean;
  66403. /**
  66404. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66405. * @returns True if it has been started, otherwise false.
  66406. */
  66407. isStarted(): boolean;
  66408. /**
  66409. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66410. * @returns True if it has been stopped, otherwise false.
  66411. */
  66412. isStopped(): boolean;
  66413. /**
  66414. * Gets a boolean indicating that the system is stopping
  66415. * @returns true if the system is currently stopping
  66416. */
  66417. isStopping(): boolean;
  66418. /**
  66419. * Gets the number of particles active at the same time.
  66420. * @returns The number of active particles.
  66421. */
  66422. getActiveCount(): number;
  66423. /**
  66424. * Starts the particle system and begins to emit
  66425. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66426. */
  66427. start(delay?: number): void;
  66428. /**
  66429. * Stops the particle system.
  66430. */
  66431. stop(): void;
  66432. /**
  66433. * Remove all active particles
  66434. */
  66435. reset(): void;
  66436. /**
  66437. * Returns the string "GPUParticleSystem"
  66438. * @returns a string containing the class name
  66439. */
  66440. getClassName(): string;
  66441. /**
  66442. * Gets the custom effect used to render the particles
  66443. * @param blendMode Blend mode for which the effect should be retrieved
  66444. * @returns The effect
  66445. */
  66446. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66447. /**
  66448. * Sets the custom effect used to render the particles
  66449. * @param effect The effect to set
  66450. * @param blendMode Blend mode for which the effect should be set
  66451. */
  66452. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66453. /** @hidden */
  66454. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66455. /**
  66456. * Observable that will be called just before the particles are drawn
  66457. */
  66458. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66459. /**
  66460. * Gets the name of the particle vertex shader
  66461. */
  66462. get vertexShaderName(): string;
  66463. private _colorGradientsTexture;
  66464. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66465. /**
  66466. * Adds a new color gradient
  66467. * @param gradient defines the gradient to use (between 0 and 1)
  66468. * @param color1 defines the color to affect to the specified gradient
  66469. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66470. * @returns the current particle system
  66471. */
  66472. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66473. private _refreshColorGradient;
  66474. /** Force the system to rebuild all gradients that need to be resync */
  66475. forceRefreshGradients(): void;
  66476. /**
  66477. * Remove a specific color gradient
  66478. * @param gradient defines the gradient to remove
  66479. * @returns the current particle system
  66480. */
  66481. removeColorGradient(gradient: number): GPUParticleSystem;
  66482. private _angularSpeedGradientsTexture;
  66483. private _sizeGradientsTexture;
  66484. private _velocityGradientsTexture;
  66485. private _limitVelocityGradientsTexture;
  66486. private _dragGradientsTexture;
  66487. private _addFactorGradient;
  66488. /**
  66489. * Adds a new size gradient
  66490. * @param gradient defines the gradient to use (between 0 and 1)
  66491. * @param factor defines the size factor to affect to the specified gradient
  66492. * @returns the current particle system
  66493. */
  66494. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66495. /**
  66496. * Remove a specific size gradient
  66497. * @param gradient defines the gradient to remove
  66498. * @returns the current particle system
  66499. */
  66500. removeSizeGradient(gradient: number): GPUParticleSystem;
  66501. private _refreshFactorGradient;
  66502. /**
  66503. * Adds a new angular speed gradient
  66504. * @param gradient defines the gradient to use (between 0 and 1)
  66505. * @param factor defines the angular speed to affect to the specified gradient
  66506. * @returns the current particle system
  66507. */
  66508. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66509. /**
  66510. * Remove a specific angular speed gradient
  66511. * @param gradient defines the gradient to remove
  66512. * @returns the current particle system
  66513. */
  66514. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66515. /**
  66516. * Adds a new velocity gradient
  66517. * @param gradient defines the gradient to use (between 0 and 1)
  66518. * @param factor defines the velocity to affect to the specified gradient
  66519. * @returns the current particle system
  66520. */
  66521. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66522. /**
  66523. * Remove a specific velocity gradient
  66524. * @param gradient defines the gradient to remove
  66525. * @returns the current particle system
  66526. */
  66527. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66528. /**
  66529. * Adds a new limit velocity gradient
  66530. * @param gradient defines the gradient to use (between 0 and 1)
  66531. * @param factor defines the limit velocity value to affect to the specified gradient
  66532. * @returns the current particle system
  66533. */
  66534. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66535. /**
  66536. * Remove a specific limit velocity gradient
  66537. * @param gradient defines the gradient to remove
  66538. * @returns the current particle system
  66539. */
  66540. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66541. /**
  66542. * Adds a new drag gradient
  66543. * @param gradient defines the gradient to use (between 0 and 1)
  66544. * @param factor defines the drag value to affect to the specified gradient
  66545. * @returns the current particle system
  66546. */
  66547. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66548. /**
  66549. * Remove a specific drag gradient
  66550. * @param gradient defines the gradient to remove
  66551. * @returns the current particle system
  66552. */
  66553. removeDragGradient(gradient: number): GPUParticleSystem;
  66554. /**
  66555. * Not supported by GPUParticleSystem
  66556. * @param gradient defines the gradient to use (between 0 and 1)
  66557. * @param factor defines the emit rate value to affect to the specified gradient
  66558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66559. * @returns the current particle system
  66560. */
  66561. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66562. /**
  66563. * Not supported by GPUParticleSystem
  66564. * @param gradient defines the gradient to remove
  66565. * @returns the current particle system
  66566. */
  66567. removeEmitRateGradient(gradient: number): IParticleSystem;
  66568. /**
  66569. * Not supported by GPUParticleSystem
  66570. * @param gradient defines the gradient to use (between 0 and 1)
  66571. * @param factor defines the start size value to affect to the specified gradient
  66572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66573. * @returns the current particle system
  66574. */
  66575. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66576. /**
  66577. * Not supported by GPUParticleSystem
  66578. * @param gradient defines the gradient to remove
  66579. * @returns the current particle system
  66580. */
  66581. removeStartSizeGradient(gradient: number): IParticleSystem;
  66582. /**
  66583. * Not supported by GPUParticleSystem
  66584. * @param gradient defines the gradient to use (between 0 and 1)
  66585. * @param min defines the color remap minimal range
  66586. * @param max defines the color remap maximal range
  66587. * @returns the current particle system
  66588. */
  66589. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66590. /**
  66591. * Not supported by GPUParticleSystem
  66592. * @param gradient defines the gradient to remove
  66593. * @returns the current particle system
  66594. */
  66595. removeColorRemapGradient(): IParticleSystem;
  66596. /**
  66597. * Not supported by GPUParticleSystem
  66598. * @param gradient defines the gradient to use (between 0 and 1)
  66599. * @param min defines the alpha remap minimal range
  66600. * @param max defines the alpha remap maximal range
  66601. * @returns the current particle system
  66602. */
  66603. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66604. /**
  66605. * Not supported by GPUParticleSystem
  66606. * @param gradient defines the gradient to remove
  66607. * @returns the current particle system
  66608. */
  66609. removeAlphaRemapGradient(): IParticleSystem;
  66610. /**
  66611. * Not supported by GPUParticleSystem
  66612. * @param gradient defines the gradient to use (between 0 and 1)
  66613. * @param color defines the color to affect to the specified gradient
  66614. * @returns the current particle system
  66615. */
  66616. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66617. /**
  66618. * Not supported by GPUParticleSystem
  66619. * @param gradient defines the gradient to remove
  66620. * @returns the current particle system
  66621. */
  66622. removeRampGradient(): IParticleSystem;
  66623. /**
  66624. * Not supported by GPUParticleSystem
  66625. * @returns the list of ramp gradients
  66626. */
  66627. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66628. /**
  66629. * Not supported by GPUParticleSystem
  66630. * Gets or sets a boolean indicating that ramp gradients must be used
  66631. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66632. */
  66633. get useRampGradients(): boolean;
  66634. set useRampGradients(value: boolean);
  66635. /**
  66636. * Not supported by GPUParticleSystem
  66637. * @param gradient defines the gradient to use (between 0 and 1)
  66638. * @param factor defines the life time factor to affect to the specified gradient
  66639. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66640. * @returns the current particle system
  66641. */
  66642. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66643. /**
  66644. * Not supported by GPUParticleSystem
  66645. * @param gradient defines the gradient to remove
  66646. * @returns the current particle system
  66647. */
  66648. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66649. /**
  66650. * Instantiates a GPU particle system.
  66651. * 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.
  66652. * @param name The name of the particle system
  66653. * @param options The options used to create the system
  66654. * @param scene The scene the particle system belongs to
  66655. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66656. * @param customEffect a custom effect used to change the way particles are rendered by default
  66657. */
  66658. constructor(name: string, options: Partial<{
  66659. capacity: number;
  66660. randomTextureSize: number;
  66661. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66662. protected _reset(): void;
  66663. private _createUpdateVAO;
  66664. private _createRenderVAO;
  66665. private _initialize;
  66666. /** @hidden */
  66667. _recreateUpdateEffect(): void;
  66668. private _getEffect;
  66669. /**
  66670. * Fill the defines array according to the current settings of the particle system
  66671. * @param defines Array to be updated
  66672. * @param blendMode blend mode to take into account when updating the array
  66673. */
  66674. fillDefines(defines: Array<string>, blendMode?: number): void;
  66675. /**
  66676. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66677. * @param uniforms Uniforms array to fill
  66678. * @param attributes Attributes array to fill
  66679. * @param samplers Samplers array to fill
  66680. */
  66681. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66682. /** @hidden */
  66683. _recreateRenderEffect(): Effect;
  66684. /**
  66685. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66686. * @param preWarm defines if we are in the pre-warmimg phase
  66687. */
  66688. animate(preWarm?: boolean): void;
  66689. private _createFactorGradientTexture;
  66690. private _createSizeGradientTexture;
  66691. private _createAngularSpeedGradientTexture;
  66692. private _createVelocityGradientTexture;
  66693. private _createLimitVelocityGradientTexture;
  66694. private _createDragGradientTexture;
  66695. private _createColorGradientTexture;
  66696. /**
  66697. * Renders the particle system in its current state
  66698. * @param preWarm defines if the system should only update the particles but not render them
  66699. * @returns the current number of particles
  66700. */
  66701. render(preWarm?: boolean): number;
  66702. /**
  66703. * Rebuilds the particle system
  66704. */
  66705. rebuild(): void;
  66706. private _releaseBuffers;
  66707. private _releaseVAOs;
  66708. /**
  66709. * Disposes the particle system and free the associated resources
  66710. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66711. */
  66712. dispose(disposeTexture?: boolean): void;
  66713. /**
  66714. * Clones the particle system.
  66715. * @param name The name of the cloned object
  66716. * @param newEmitter The new emitter to use
  66717. * @returns the cloned particle system
  66718. */
  66719. clone(name: string, newEmitter: any): GPUParticleSystem;
  66720. /**
  66721. * Serializes the particle system to a JSON object
  66722. * @param serializeTexture defines if the texture must be serialized as well
  66723. * @returns the JSON object
  66724. */
  66725. serialize(serializeTexture?: boolean): any;
  66726. /**
  66727. * Parses a JSON object to create a GPU particle system.
  66728. * @param parsedParticleSystem The JSON object to parse
  66729. * @param scene The scene to create the particle system in
  66730. * @param rootUrl The root url to use to load external dependencies like texture
  66731. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66732. * @returns the parsed GPU particle system
  66733. */
  66734. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66735. }
  66736. }
  66737. declare module BABYLON {
  66738. /**
  66739. * Represents a set of particle systems working together to create a specific effect
  66740. */
  66741. export class ParticleSystemSet implements IDisposable {
  66742. /**
  66743. * Gets or sets base Assets URL
  66744. */
  66745. static BaseAssetsUrl: string;
  66746. private _emitterCreationOptions;
  66747. private _emitterNode;
  66748. /**
  66749. * Gets the particle system list
  66750. */
  66751. systems: IParticleSystem[];
  66752. /**
  66753. * Gets the emitter node used with this set
  66754. */
  66755. get emitterNode(): Nullable<TransformNode>;
  66756. /**
  66757. * Creates a new emitter mesh as a sphere
  66758. * @param options defines the options used to create the sphere
  66759. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66760. * @param scene defines the hosting scene
  66761. */
  66762. setEmitterAsSphere(options: {
  66763. diameter: number;
  66764. segments: number;
  66765. color: Color3;
  66766. }, renderingGroupId: number, scene: Scene): void;
  66767. /**
  66768. * Starts all particle systems of the set
  66769. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66770. */
  66771. start(emitter?: AbstractMesh): void;
  66772. /**
  66773. * Release all associated resources
  66774. */
  66775. dispose(): void;
  66776. /**
  66777. * Serialize the set into a JSON compatible object
  66778. * @param serializeTexture defines if the texture must be serialized as well
  66779. * @returns a JSON compatible representation of the set
  66780. */
  66781. serialize(serializeTexture?: boolean): any;
  66782. /**
  66783. * Parse a new ParticleSystemSet from a serialized source
  66784. * @param data defines a JSON compatible representation of the set
  66785. * @param scene defines the hosting scene
  66786. * @param gpu defines if we want GPU particles or CPU particles
  66787. * @returns a new ParticleSystemSet
  66788. */
  66789. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66790. }
  66791. }
  66792. declare module BABYLON {
  66793. /**
  66794. * This class is made for on one-liner static method to help creating particle system set.
  66795. */
  66796. export class ParticleHelper {
  66797. /**
  66798. * Gets or sets base Assets URL
  66799. */
  66800. static BaseAssetsUrl: string;
  66801. /** Define the Url to load snippets */
  66802. static SnippetUrl: string;
  66803. /**
  66804. * Create a default particle system that you can tweak
  66805. * @param emitter defines the emitter to use
  66806. * @param capacity defines the system capacity (default is 500 particles)
  66807. * @param scene defines the hosting scene
  66808. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66809. * @returns the new Particle system
  66810. */
  66811. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66812. /**
  66813. * This is the main static method (one-liner) of this helper to create different particle systems
  66814. * @param type This string represents the type to the particle system to create
  66815. * @param scene The scene where the particle system should live
  66816. * @param gpu If the system will use gpu
  66817. * @returns the ParticleSystemSet created
  66818. */
  66819. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66820. /**
  66821. * Static function used to export a particle system to a ParticleSystemSet variable.
  66822. * Please note that the emitter shape is not exported
  66823. * @param systems defines the particle systems to export
  66824. * @returns the created particle system set
  66825. */
  66826. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66827. /**
  66828. * Creates a particle system from a snippet saved in a remote file
  66829. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66830. * @param url defines the url to load from
  66831. * @param scene defines the hosting scene
  66832. * @param gpu If the system will use gpu
  66833. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66834. * @returns a promise that will resolve to the new particle system
  66835. */
  66836. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66837. /**
  66838. * Creates a particle system from a snippet saved by the particle system editor
  66839. * @param snippetId defines the snippet to load
  66840. * @param scene defines the hosting scene
  66841. * @param gpu If the system will use gpu
  66842. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66843. * @returns a promise that will resolve to the new particle system
  66844. */
  66845. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66846. }
  66847. }
  66848. declare module BABYLON {
  66849. interface Engine {
  66850. /**
  66851. * Create an effect to use with particle systems.
  66852. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66853. * the particle system for which you want to create a custom effect in the last parameter
  66854. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66855. * @param uniformsNames defines a list of attribute names
  66856. * @param samplers defines an array of string used to represent textures
  66857. * @param defines defines the string containing the defines to use to compile the shaders
  66858. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66859. * @param onCompiled defines a function to call when the effect creation is successful
  66860. * @param onError defines a function to call when the effect creation has failed
  66861. * @param particleSystem the particle system you want to create the effect for
  66862. * @returns the new Effect
  66863. */
  66864. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66865. }
  66866. interface Mesh {
  66867. /**
  66868. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66869. * @returns an array of IParticleSystem
  66870. */
  66871. getEmittedParticleSystems(): IParticleSystem[];
  66872. /**
  66873. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66874. * @returns an array of IParticleSystem
  66875. */
  66876. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66877. }
  66878. }
  66879. declare module BABYLON {
  66880. /** Defines the 4 color options */
  66881. export enum PointColor {
  66882. /** color value */
  66883. Color = 2,
  66884. /** uv value */
  66885. UV = 1,
  66886. /** random value */
  66887. Random = 0,
  66888. /** stated value */
  66889. Stated = 3
  66890. }
  66891. /**
  66892. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66893. * 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.
  66894. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66895. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66896. *
  66897. * Full documentation here : TO BE ENTERED
  66898. */
  66899. export class PointsCloudSystem implements IDisposable {
  66900. /**
  66901. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66902. * Example : var p = SPS.particles[i];
  66903. */
  66904. particles: CloudPoint[];
  66905. /**
  66906. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66907. */
  66908. nbParticles: number;
  66909. /**
  66910. * This a counter for your own usage. It's not set by any SPS functions.
  66911. */
  66912. counter: number;
  66913. /**
  66914. * The PCS name. This name is also given to the underlying mesh.
  66915. */
  66916. name: string;
  66917. /**
  66918. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66919. */
  66920. mesh: Mesh;
  66921. /**
  66922. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66923. * Please read :
  66924. */
  66925. vars: any;
  66926. /**
  66927. * @hidden
  66928. */
  66929. _size: number;
  66930. private _scene;
  66931. private _promises;
  66932. private _positions;
  66933. private _indices;
  66934. private _normals;
  66935. private _colors;
  66936. private _uvs;
  66937. private _indices32;
  66938. private _positions32;
  66939. private _colors32;
  66940. private _uvs32;
  66941. private _updatable;
  66942. private _isVisibilityBoxLocked;
  66943. private _alwaysVisible;
  66944. private _groups;
  66945. private _groupCounter;
  66946. private _computeParticleColor;
  66947. private _computeParticleTexture;
  66948. private _computeParticleRotation;
  66949. private _computeBoundingBox;
  66950. private _isReady;
  66951. /**
  66952. * Creates a PCS (Points Cloud System) object
  66953. * @param name (String) is the PCS name, this will be the underlying mesh name
  66954. * @param pointSize (number) is the size for each point
  66955. * @param scene (Scene) is the scene in which the PCS is added
  66956. * @param options defines the options of the PCS e.g.
  66957. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66958. */
  66959. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66960. updatable?: boolean;
  66961. });
  66962. /**
  66963. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66964. * If no points were added to the PCS, the returned mesh is just a single point.
  66965. * @returns a promise for the created mesh
  66966. */
  66967. buildMeshAsync(): Promise<Mesh>;
  66968. /**
  66969. * @hidden
  66970. */
  66971. private _buildMesh;
  66972. private _addParticle;
  66973. private _randomUnitVector;
  66974. private _getColorIndicesForCoord;
  66975. private _setPointsColorOrUV;
  66976. private _colorFromTexture;
  66977. private _calculateDensity;
  66978. /**
  66979. * Adds points to the PCS in random positions within a unit sphere
  66980. * @param nb (positive integer) the number of particles to be created from this model
  66981. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66982. * @returns the number of groups in the system
  66983. */
  66984. addPoints(nb: number, pointFunction?: any): number;
  66985. /**
  66986. * Adds points to the PCS from the surface of the model shape
  66987. * @param mesh is any Mesh object that will be used as a surface model for the points
  66988. * @param nb (positive integer) the number of particles to be created from this model
  66989. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66990. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66991. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66992. * @returns the number of groups in the system
  66993. */
  66994. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66995. /**
  66996. * Adds points to the PCS inside the model shape
  66997. * @param mesh is any Mesh object that will be used as a surface model for the points
  66998. * @param nb (positive integer) the number of particles to be created from this model
  66999. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67000. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67001. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67002. * @returns the number of groups in the system
  67003. */
  67004. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67005. /**
  67006. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67007. * This method calls `updateParticle()` for each particle of the SPS.
  67008. * For an animated SPS, it is usually called within the render loop.
  67009. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67010. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67011. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67012. * @returns the PCS.
  67013. */
  67014. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67015. /**
  67016. * Disposes the PCS.
  67017. */
  67018. dispose(): void;
  67019. /**
  67020. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67021. * doc :
  67022. * @returns the PCS.
  67023. */
  67024. refreshVisibleSize(): PointsCloudSystem;
  67025. /**
  67026. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67027. * @param size the size (float) of the visibility box
  67028. * note : this doesn't lock the PCS mesh bounding box.
  67029. * doc :
  67030. */
  67031. setVisibilityBox(size: number): void;
  67032. /**
  67033. * Gets whether the PCS is always visible or not
  67034. * doc :
  67035. */
  67036. get isAlwaysVisible(): boolean;
  67037. /**
  67038. * Sets the PCS as always visible or not
  67039. * doc :
  67040. */
  67041. set isAlwaysVisible(val: boolean);
  67042. /**
  67043. * Tells to `setParticles()` to compute the particle rotations or not
  67044. * Default value : false. The PCS is faster when it's set to false
  67045. * Note : particle rotations are only applied to parent particles
  67046. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67047. */
  67048. set computeParticleRotation(val: boolean);
  67049. /**
  67050. * Tells to `setParticles()` to compute the particle colors or not.
  67051. * Default value : true. The PCS is faster when it's set to false.
  67052. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67053. */
  67054. set computeParticleColor(val: boolean);
  67055. set computeParticleTexture(val: boolean);
  67056. /**
  67057. * Gets if `setParticles()` computes the particle colors or not.
  67058. * Default value : false. The PCS is faster when it's set to false.
  67059. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67060. */
  67061. get computeParticleColor(): boolean;
  67062. /**
  67063. * Gets if `setParticles()` computes the particle textures or not.
  67064. * Default value : false. The PCS is faster when it's set to false.
  67065. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67066. */
  67067. get computeParticleTexture(): boolean;
  67068. /**
  67069. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67070. */
  67071. set computeBoundingBox(val: boolean);
  67072. /**
  67073. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67074. */
  67075. get computeBoundingBox(): boolean;
  67076. /**
  67077. * This function does nothing. It may be overwritten to set all the particle first values.
  67078. * The PCS doesn't call this function, you may have to call it by your own.
  67079. * doc :
  67080. */
  67081. initParticles(): void;
  67082. /**
  67083. * This function does nothing. It may be overwritten to recycle a particle
  67084. * The PCS doesn't call this function, you can to call it
  67085. * doc :
  67086. * @param particle The particle to recycle
  67087. * @returns the recycled particle
  67088. */
  67089. recycleParticle(particle: CloudPoint): CloudPoint;
  67090. /**
  67091. * Updates a particle : this function should be overwritten by the user.
  67092. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67093. * doc :
  67094. * @example : just set a particle position or velocity and recycle conditions
  67095. * @param particle The particle to update
  67096. * @returns the updated particle
  67097. */
  67098. updateParticle(particle: CloudPoint): CloudPoint;
  67099. /**
  67100. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67101. * This does nothing and may be overwritten by the user.
  67102. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67103. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67104. * @param update the boolean update value actually passed to setParticles()
  67105. */
  67106. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67107. /**
  67108. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67109. * This will be passed three parameters.
  67110. * This does nothing and may be overwritten by the user.
  67111. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67112. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67113. * @param update the boolean update value actually passed to setParticles()
  67114. */
  67115. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67116. }
  67117. }
  67118. declare module BABYLON {
  67119. /**
  67120. * Represents one particle of a points cloud system.
  67121. */
  67122. export class CloudPoint {
  67123. /**
  67124. * particle global index
  67125. */
  67126. idx: number;
  67127. /**
  67128. * The color of the particle
  67129. */
  67130. color: Nullable<Color4>;
  67131. /**
  67132. * The world space position of the particle.
  67133. */
  67134. position: Vector3;
  67135. /**
  67136. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67137. */
  67138. rotation: Vector3;
  67139. /**
  67140. * The world space rotation quaternion of the particle.
  67141. */
  67142. rotationQuaternion: Nullable<Quaternion>;
  67143. /**
  67144. * The uv of the particle.
  67145. */
  67146. uv: Nullable<Vector2>;
  67147. /**
  67148. * The current speed of the particle.
  67149. */
  67150. velocity: Vector3;
  67151. /**
  67152. * The pivot point in the particle local space.
  67153. */
  67154. pivot: Vector3;
  67155. /**
  67156. * Must the particle be translated from its pivot point in its local space ?
  67157. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67158. * Default : false
  67159. */
  67160. translateFromPivot: boolean;
  67161. /**
  67162. * Index of this particle in the global "positions" array (Internal use)
  67163. * @hidden
  67164. */
  67165. _pos: number;
  67166. /**
  67167. * @hidden Index of this particle in the global "indices" array (Internal use)
  67168. */
  67169. _ind: number;
  67170. /**
  67171. * Group this particle belongs to
  67172. */
  67173. _group: PointsGroup;
  67174. /**
  67175. * Group id of this particle
  67176. */
  67177. groupId: number;
  67178. /**
  67179. * Index of the particle in its group id (Internal use)
  67180. */
  67181. idxInGroup: number;
  67182. /**
  67183. * @hidden Particle BoundingInfo object (Internal use)
  67184. */
  67185. _boundingInfo: BoundingInfo;
  67186. /**
  67187. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67188. */
  67189. _pcs: PointsCloudSystem;
  67190. /**
  67191. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67192. */
  67193. _stillInvisible: boolean;
  67194. /**
  67195. * @hidden Last computed particle rotation matrix
  67196. */
  67197. _rotationMatrix: number[];
  67198. /**
  67199. * Parent particle Id, if any.
  67200. * Default null.
  67201. */
  67202. parentId: Nullable<number>;
  67203. /**
  67204. * @hidden Internal global position in the PCS.
  67205. */
  67206. _globalPosition: Vector3;
  67207. /**
  67208. * Creates a Point Cloud object.
  67209. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67210. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67211. * @param group (PointsGroup) is the group the particle belongs to
  67212. * @param groupId (integer) is the group identifier in the PCS.
  67213. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67214. * @param pcs defines the PCS it is associated to
  67215. */
  67216. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67217. /**
  67218. * get point size
  67219. */
  67220. get size(): Vector3;
  67221. /**
  67222. * Set point size
  67223. */
  67224. set size(scale: Vector3);
  67225. /**
  67226. * Legacy support, changed quaternion to rotationQuaternion
  67227. */
  67228. get quaternion(): Nullable<Quaternion>;
  67229. /**
  67230. * Legacy support, changed quaternion to rotationQuaternion
  67231. */
  67232. set quaternion(q: Nullable<Quaternion>);
  67233. /**
  67234. * Returns a boolean. True if the particle intersects a mesh, else false
  67235. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67236. * @param target is the object (point or mesh) what the intersection is computed against
  67237. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67238. * @returns true if it intersects
  67239. */
  67240. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67241. /**
  67242. * get the rotation matrix of the particle
  67243. * @hidden
  67244. */
  67245. getRotationMatrix(m: Matrix): void;
  67246. }
  67247. /**
  67248. * Represents a group of points in a points cloud system
  67249. * * PCS internal tool, don't use it manually.
  67250. */
  67251. export class PointsGroup {
  67252. /**
  67253. * The group id
  67254. * @hidden
  67255. */
  67256. groupID: number;
  67257. /**
  67258. * image data for group (internal use)
  67259. * @hidden
  67260. */
  67261. _groupImageData: Nullable<ArrayBufferView>;
  67262. /**
  67263. * Image Width (internal use)
  67264. * @hidden
  67265. */
  67266. _groupImgWidth: number;
  67267. /**
  67268. * Image Height (internal use)
  67269. * @hidden
  67270. */
  67271. _groupImgHeight: number;
  67272. /**
  67273. * Custom position function (internal use)
  67274. * @hidden
  67275. */
  67276. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67277. /**
  67278. * density per facet for surface points
  67279. * @hidden
  67280. */
  67281. _groupDensity: number[];
  67282. /**
  67283. * Only when points are colored by texture carries pointer to texture list array
  67284. * @hidden
  67285. */
  67286. _textureNb: number;
  67287. /**
  67288. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67289. * PCS internal tool, don't use it manually.
  67290. * @hidden
  67291. */
  67292. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67293. }
  67294. }
  67295. declare module BABYLON {
  67296. interface Scene {
  67297. /** @hidden (Backing field) */
  67298. _physicsEngine: Nullable<IPhysicsEngine>;
  67299. /** @hidden */
  67300. _physicsTimeAccumulator: number;
  67301. /**
  67302. * Gets the current physics engine
  67303. * @returns a IPhysicsEngine or null if none attached
  67304. */
  67305. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67306. /**
  67307. * Enables physics to the current scene
  67308. * @param gravity defines the scene's gravity for the physics engine
  67309. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67310. * @return a boolean indicating if the physics engine was initialized
  67311. */
  67312. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67313. /**
  67314. * Disables and disposes the physics engine associated with the scene
  67315. */
  67316. disablePhysicsEngine(): void;
  67317. /**
  67318. * Gets a boolean indicating if there is an active physics engine
  67319. * @returns a boolean indicating if there is an active physics engine
  67320. */
  67321. isPhysicsEnabled(): boolean;
  67322. /**
  67323. * Deletes a physics compound impostor
  67324. * @param compound defines the compound to delete
  67325. */
  67326. deleteCompoundImpostor(compound: any): void;
  67327. /**
  67328. * An event triggered when physic simulation is about to be run
  67329. */
  67330. onBeforePhysicsObservable: Observable<Scene>;
  67331. /**
  67332. * An event triggered when physic simulation has been done
  67333. */
  67334. onAfterPhysicsObservable: Observable<Scene>;
  67335. }
  67336. interface AbstractMesh {
  67337. /** @hidden */
  67338. _physicsImpostor: Nullable<PhysicsImpostor>;
  67339. /**
  67340. * Gets or sets impostor used for physic simulation
  67341. * @see http://doc.babylonjs.com/features/physics_engine
  67342. */
  67343. physicsImpostor: Nullable<PhysicsImpostor>;
  67344. /**
  67345. * Gets the current physics impostor
  67346. * @see http://doc.babylonjs.com/features/physics_engine
  67347. * @returns a physics impostor or null
  67348. */
  67349. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67350. /** Apply a physic impulse to the mesh
  67351. * @param force defines the force to apply
  67352. * @param contactPoint defines where to apply the force
  67353. * @returns the current mesh
  67354. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67355. */
  67356. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67357. /**
  67358. * Creates a physic joint between two meshes
  67359. * @param otherMesh defines the other mesh to use
  67360. * @param pivot1 defines the pivot to use on this mesh
  67361. * @param pivot2 defines the pivot to use on the other mesh
  67362. * @param options defines additional options (can be plugin dependent)
  67363. * @returns the current mesh
  67364. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67365. */
  67366. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67367. /** @hidden */
  67368. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67369. }
  67370. /**
  67371. * Defines the physics engine scene component responsible to manage a physics engine
  67372. */
  67373. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67374. /**
  67375. * The component name helpful to identify the component in the list of scene components.
  67376. */
  67377. readonly name: string;
  67378. /**
  67379. * The scene the component belongs to.
  67380. */
  67381. scene: Scene;
  67382. /**
  67383. * Creates a new instance of the component for the given scene
  67384. * @param scene Defines the scene to register the component in
  67385. */
  67386. constructor(scene: Scene);
  67387. /**
  67388. * Registers the component in a given scene
  67389. */
  67390. register(): void;
  67391. /**
  67392. * Rebuilds the elements related to this component in case of
  67393. * context lost for instance.
  67394. */
  67395. rebuild(): void;
  67396. /**
  67397. * Disposes the component and the associated ressources
  67398. */
  67399. dispose(): void;
  67400. }
  67401. }
  67402. declare module BABYLON {
  67403. /**
  67404. * A helper for physics simulations
  67405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67406. */
  67407. export class PhysicsHelper {
  67408. private _scene;
  67409. private _physicsEngine;
  67410. /**
  67411. * Initializes the Physics helper
  67412. * @param scene Babylon.js scene
  67413. */
  67414. constructor(scene: Scene);
  67415. /**
  67416. * Applies a radial explosion impulse
  67417. * @param origin the origin of the explosion
  67418. * @param radiusOrEventOptions the radius or the options of radial explosion
  67419. * @param strength the explosion strength
  67420. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67421. * @returns A physics radial explosion event, or null
  67422. */
  67423. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67424. /**
  67425. * Applies a radial explosion force
  67426. * @param origin the origin of the explosion
  67427. * @param radiusOrEventOptions the radius or the options of radial explosion
  67428. * @param strength the explosion strength
  67429. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67430. * @returns A physics radial explosion event, or null
  67431. */
  67432. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67433. /**
  67434. * Creates a gravitational field
  67435. * @param origin the origin of the explosion
  67436. * @param radiusOrEventOptions the radius or the options of radial explosion
  67437. * @param strength the explosion strength
  67438. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67439. * @returns A physics gravitational field event, or null
  67440. */
  67441. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67442. /**
  67443. * Creates a physics updraft event
  67444. * @param origin the origin of the updraft
  67445. * @param radiusOrEventOptions the radius or the options of the updraft
  67446. * @param strength the strength of the updraft
  67447. * @param height the height of the updraft
  67448. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67449. * @returns A physics updraft event, or null
  67450. */
  67451. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67452. /**
  67453. * Creates a physics vortex event
  67454. * @param origin the of the vortex
  67455. * @param radiusOrEventOptions the radius or the options of the vortex
  67456. * @param strength the strength of the vortex
  67457. * @param height the height of the vortex
  67458. * @returns a Physics vortex event, or null
  67459. * A physics vortex event or null
  67460. */
  67461. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67462. }
  67463. /**
  67464. * Represents a physics radial explosion event
  67465. */
  67466. class PhysicsRadialExplosionEvent {
  67467. private _scene;
  67468. private _options;
  67469. private _sphere;
  67470. private _dataFetched;
  67471. /**
  67472. * Initializes a radial explosioin event
  67473. * @param _scene BabylonJS scene
  67474. * @param _options The options for the vortex event
  67475. */
  67476. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67477. /**
  67478. * Returns the data related to the radial explosion event (sphere).
  67479. * @returns The radial explosion event data
  67480. */
  67481. getData(): PhysicsRadialExplosionEventData;
  67482. /**
  67483. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67484. * @param impostor A physics imposter
  67485. * @param origin the origin of the explosion
  67486. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67487. */
  67488. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67489. /**
  67490. * Triggers affecterd impostors callbacks
  67491. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67492. */
  67493. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67494. /**
  67495. * Disposes the sphere.
  67496. * @param force Specifies if the sphere should be disposed by force
  67497. */
  67498. dispose(force?: boolean): void;
  67499. /*** Helpers ***/
  67500. private _prepareSphere;
  67501. private _intersectsWithSphere;
  67502. }
  67503. /**
  67504. * Represents a gravitational field event
  67505. */
  67506. class PhysicsGravitationalFieldEvent {
  67507. private _physicsHelper;
  67508. private _scene;
  67509. private _origin;
  67510. private _options;
  67511. private _tickCallback;
  67512. private _sphere;
  67513. private _dataFetched;
  67514. /**
  67515. * Initializes the physics gravitational field event
  67516. * @param _physicsHelper A physics helper
  67517. * @param _scene BabylonJS scene
  67518. * @param _origin The origin position of the gravitational field event
  67519. * @param _options The options for the vortex event
  67520. */
  67521. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67522. /**
  67523. * Returns the data related to the gravitational field event (sphere).
  67524. * @returns A gravitational field event
  67525. */
  67526. getData(): PhysicsGravitationalFieldEventData;
  67527. /**
  67528. * Enables the gravitational field.
  67529. */
  67530. enable(): void;
  67531. /**
  67532. * Disables the gravitational field.
  67533. */
  67534. disable(): void;
  67535. /**
  67536. * Disposes the sphere.
  67537. * @param force The force to dispose from the gravitational field event
  67538. */
  67539. dispose(force?: boolean): void;
  67540. private _tick;
  67541. }
  67542. /**
  67543. * Represents a physics updraft event
  67544. */
  67545. class PhysicsUpdraftEvent {
  67546. private _scene;
  67547. private _origin;
  67548. private _options;
  67549. private _physicsEngine;
  67550. private _originTop;
  67551. private _originDirection;
  67552. private _tickCallback;
  67553. private _cylinder;
  67554. private _cylinderPosition;
  67555. private _dataFetched;
  67556. /**
  67557. * Initializes the physics updraft event
  67558. * @param _scene BabylonJS scene
  67559. * @param _origin The origin position of the updraft
  67560. * @param _options The options for the updraft event
  67561. */
  67562. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67563. /**
  67564. * Returns the data related to the updraft event (cylinder).
  67565. * @returns A physics updraft event
  67566. */
  67567. getData(): PhysicsUpdraftEventData;
  67568. /**
  67569. * Enables the updraft.
  67570. */
  67571. enable(): void;
  67572. /**
  67573. * Disables the updraft.
  67574. */
  67575. disable(): void;
  67576. /**
  67577. * Disposes the cylinder.
  67578. * @param force Specifies if the updraft should be disposed by force
  67579. */
  67580. dispose(force?: boolean): void;
  67581. private getImpostorHitData;
  67582. private _tick;
  67583. /*** Helpers ***/
  67584. private _prepareCylinder;
  67585. private _intersectsWithCylinder;
  67586. }
  67587. /**
  67588. * Represents a physics vortex event
  67589. */
  67590. class PhysicsVortexEvent {
  67591. private _scene;
  67592. private _origin;
  67593. private _options;
  67594. private _physicsEngine;
  67595. private _originTop;
  67596. private _tickCallback;
  67597. private _cylinder;
  67598. private _cylinderPosition;
  67599. private _dataFetched;
  67600. /**
  67601. * Initializes the physics vortex event
  67602. * @param _scene The BabylonJS scene
  67603. * @param _origin The origin position of the vortex
  67604. * @param _options The options for the vortex event
  67605. */
  67606. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67607. /**
  67608. * Returns the data related to the vortex event (cylinder).
  67609. * @returns The physics vortex event data
  67610. */
  67611. getData(): PhysicsVortexEventData;
  67612. /**
  67613. * Enables the vortex.
  67614. */
  67615. enable(): void;
  67616. /**
  67617. * Disables the cortex.
  67618. */
  67619. disable(): void;
  67620. /**
  67621. * Disposes the sphere.
  67622. * @param force
  67623. */
  67624. dispose(force?: boolean): void;
  67625. private getImpostorHitData;
  67626. private _tick;
  67627. /*** Helpers ***/
  67628. private _prepareCylinder;
  67629. private _intersectsWithCylinder;
  67630. }
  67631. /**
  67632. * Options fot the radial explosion event
  67633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67634. */
  67635. export class PhysicsRadialExplosionEventOptions {
  67636. /**
  67637. * The radius of the sphere for the radial explosion.
  67638. */
  67639. radius: number;
  67640. /**
  67641. * The strenth of the explosion.
  67642. */
  67643. strength: number;
  67644. /**
  67645. * The strenght of the force in correspondence to the distance of the affected object
  67646. */
  67647. falloff: PhysicsRadialImpulseFalloff;
  67648. /**
  67649. * Sphere options for the radial explosion.
  67650. */
  67651. sphere: {
  67652. segments: number;
  67653. diameter: number;
  67654. };
  67655. /**
  67656. * Sphere options for the radial explosion.
  67657. */
  67658. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67659. }
  67660. /**
  67661. * Options fot the updraft event
  67662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67663. */
  67664. export class PhysicsUpdraftEventOptions {
  67665. /**
  67666. * The radius of the cylinder for the vortex
  67667. */
  67668. radius: number;
  67669. /**
  67670. * The strenth of the updraft.
  67671. */
  67672. strength: number;
  67673. /**
  67674. * The height of the cylinder for the updraft.
  67675. */
  67676. height: number;
  67677. /**
  67678. * The mode for the the updraft.
  67679. */
  67680. updraftMode: PhysicsUpdraftMode;
  67681. }
  67682. /**
  67683. * Options fot the vortex event
  67684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67685. */
  67686. export class PhysicsVortexEventOptions {
  67687. /**
  67688. * The radius of the cylinder for the vortex
  67689. */
  67690. radius: number;
  67691. /**
  67692. * The strenth of the vortex.
  67693. */
  67694. strength: number;
  67695. /**
  67696. * The height of the cylinder for the vortex.
  67697. */
  67698. height: number;
  67699. /**
  67700. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67701. */
  67702. centripetalForceThreshold: number;
  67703. /**
  67704. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67705. */
  67706. centripetalForceMultiplier: number;
  67707. /**
  67708. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67709. */
  67710. centrifugalForceMultiplier: number;
  67711. /**
  67712. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67713. */
  67714. updraftForceMultiplier: number;
  67715. }
  67716. /**
  67717. * The strenght of the force in correspondence to the distance of the affected object
  67718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67719. */
  67720. export enum PhysicsRadialImpulseFalloff {
  67721. /** Defines that impulse is constant in strength across it's whole radius */
  67722. Constant = 0,
  67723. /** Defines that impulse gets weaker if it's further from the origin */
  67724. Linear = 1
  67725. }
  67726. /**
  67727. * The strength of the force in correspondence to the distance of the affected object
  67728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67729. */
  67730. export enum PhysicsUpdraftMode {
  67731. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67732. Center = 0,
  67733. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67734. Perpendicular = 1
  67735. }
  67736. /**
  67737. * Interface for a physics hit data
  67738. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67739. */
  67740. export interface PhysicsHitData {
  67741. /**
  67742. * The force applied at the contact point
  67743. */
  67744. force: Vector3;
  67745. /**
  67746. * The contact point
  67747. */
  67748. contactPoint: Vector3;
  67749. /**
  67750. * The distance from the origin to the contact point
  67751. */
  67752. distanceFromOrigin: number;
  67753. }
  67754. /**
  67755. * Interface for radial explosion event data
  67756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67757. */
  67758. export interface PhysicsRadialExplosionEventData {
  67759. /**
  67760. * A sphere used for the radial explosion event
  67761. */
  67762. sphere: Mesh;
  67763. }
  67764. /**
  67765. * Interface for gravitational field event data
  67766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67767. */
  67768. export interface PhysicsGravitationalFieldEventData {
  67769. /**
  67770. * A sphere mesh used for the gravitational field event
  67771. */
  67772. sphere: Mesh;
  67773. }
  67774. /**
  67775. * Interface for updraft event data
  67776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67777. */
  67778. export interface PhysicsUpdraftEventData {
  67779. /**
  67780. * A cylinder used for the updraft event
  67781. */
  67782. cylinder: Mesh;
  67783. }
  67784. /**
  67785. * Interface for vortex event data
  67786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67787. */
  67788. export interface PhysicsVortexEventData {
  67789. /**
  67790. * A cylinder used for the vortex event
  67791. */
  67792. cylinder: Mesh;
  67793. }
  67794. /**
  67795. * Interface for an affected physics impostor
  67796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67797. */
  67798. export interface PhysicsAffectedImpostorWithData {
  67799. /**
  67800. * The impostor affected by the effect
  67801. */
  67802. impostor: PhysicsImpostor;
  67803. /**
  67804. * The data about the hit/horce from the explosion
  67805. */
  67806. hitData: PhysicsHitData;
  67807. }
  67808. }
  67809. declare module BABYLON {
  67810. /** @hidden */
  67811. export var blackAndWhitePixelShader: {
  67812. name: string;
  67813. shader: string;
  67814. };
  67815. }
  67816. declare module BABYLON {
  67817. /**
  67818. * Post process used to render in black and white
  67819. */
  67820. export class BlackAndWhitePostProcess extends PostProcess {
  67821. /**
  67822. * Linear about to convert he result to black and white (default: 1)
  67823. */
  67824. degree: number;
  67825. /**
  67826. * Creates a black and white post process
  67827. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67828. * @param name The name of the effect.
  67829. * @param options The required width/height ratio to downsize to before computing the render pass.
  67830. * @param camera The camera to apply the render pass to.
  67831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67832. * @param engine The engine which the post process will be applied. (default: current engine)
  67833. * @param reusable If the post process can be reused on the same frame. (default: false)
  67834. */
  67835. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67836. }
  67837. }
  67838. declare module BABYLON {
  67839. /**
  67840. * This represents a set of one or more post processes in Babylon.
  67841. * A post process can be used to apply a shader to a texture after it is rendered.
  67842. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67843. */
  67844. export class PostProcessRenderEffect {
  67845. private _postProcesses;
  67846. private _getPostProcesses;
  67847. private _singleInstance;
  67848. private _cameras;
  67849. private _indicesForCamera;
  67850. /**
  67851. * Name of the effect
  67852. * @hidden
  67853. */
  67854. _name: string;
  67855. /**
  67856. * Instantiates a post process render effect.
  67857. * A post process can be used to apply a shader to a texture after it is rendered.
  67858. * @param engine The engine the effect is tied to
  67859. * @param name The name of the effect
  67860. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67861. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67862. */
  67863. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67864. /**
  67865. * Checks if all the post processes in the effect are supported.
  67866. */
  67867. get isSupported(): boolean;
  67868. /**
  67869. * Updates the current state of the effect
  67870. * @hidden
  67871. */
  67872. _update(): void;
  67873. /**
  67874. * Attaches the effect on cameras
  67875. * @param cameras The camera to attach to.
  67876. * @hidden
  67877. */
  67878. _attachCameras(cameras: Camera): void;
  67879. /**
  67880. * Attaches the effect on cameras
  67881. * @param cameras The camera to attach to.
  67882. * @hidden
  67883. */
  67884. _attachCameras(cameras: Camera[]): void;
  67885. /**
  67886. * Detaches the effect on cameras
  67887. * @param cameras The camera to detatch from.
  67888. * @hidden
  67889. */
  67890. _detachCameras(cameras: Camera): void;
  67891. /**
  67892. * Detatches the effect on cameras
  67893. * @param cameras The camera to detatch from.
  67894. * @hidden
  67895. */
  67896. _detachCameras(cameras: Camera[]): void;
  67897. /**
  67898. * Enables the effect on given cameras
  67899. * @param cameras The camera to enable.
  67900. * @hidden
  67901. */
  67902. _enable(cameras: Camera): void;
  67903. /**
  67904. * Enables the effect on given cameras
  67905. * @param cameras The camera to enable.
  67906. * @hidden
  67907. */
  67908. _enable(cameras: Nullable<Camera[]>): void;
  67909. /**
  67910. * Disables the effect on the given cameras
  67911. * @param cameras The camera to disable.
  67912. * @hidden
  67913. */
  67914. _disable(cameras: Camera): void;
  67915. /**
  67916. * Disables the effect on the given cameras
  67917. * @param cameras The camera to disable.
  67918. * @hidden
  67919. */
  67920. _disable(cameras: Nullable<Camera[]>): void;
  67921. /**
  67922. * Gets a list of the post processes contained in the effect.
  67923. * @param camera The camera to get the post processes on.
  67924. * @returns The list of the post processes in the effect.
  67925. */
  67926. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67927. }
  67928. }
  67929. declare module BABYLON {
  67930. /** @hidden */
  67931. export var extractHighlightsPixelShader: {
  67932. name: string;
  67933. shader: string;
  67934. };
  67935. }
  67936. declare module BABYLON {
  67937. /**
  67938. * 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.
  67939. */
  67940. export class ExtractHighlightsPostProcess extends PostProcess {
  67941. /**
  67942. * The luminance threshold, pixels below this value will be set to black.
  67943. */
  67944. threshold: number;
  67945. /** @hidden */
  67946. _exposure: number;
  67947. /**
  67948. * Post process which has the input texture to be used when performing highlight extraction
  67949. * @hidden
  67950. */
  67951. _inputPostProcess: Nullable<PostProcess>;
  67952. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67953. }
  67954. }
  67955. declare module BABYLON {
  67956. /** @hidden */
  67957. export var bloomMergePixelShader: {
  67958. name: string;
  67959. shader: string;
  67960. };
  67961. }
  67962. declare module BABYLON {
  67963. /**
  67964. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67965. */
  67966. export class BloomMergePostProcess extends PostProcess {
  67967. /** Weight of the bloom to be added to the original input. */
  67968. weight: number;
  67969. /**
  67970. * Creates a new instance of @see BloomMergePostProcess
  67971. * @param name The name of the effect.
  67972. * @param originalFromInput Post process which's input will be used for the merge.
  67973. * @param blurred Blurred highlights post process which's output will be used.
  67974. * @param weight Weight of the bloom to be added to the original input.
  67975. * @param options The required width/height ratio to downsize to before computing the render pass.
  67976. * @param camera The camera to apply the render pass to.
  67977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67978. * @param engine The engine which the post process will be applied. (default: current engine)
  67979. * @param reusable If the post process can be reused on the same frame. (default: false)
  67980. * @param textureType Type of textures used when performing the post process. (default: 0)
  67981. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  67982. */
  67983. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67984. /** Weight of the bloom to be added to the original input. */
  67985. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67986. }
  67987. }
  67988. declare module BABYLON {
  67989. /**
  67990. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67991. */
  67992. export class BloomEffect extends PostProcessRenderEffect {
  67993. private bloomScale;
  67994. /**
  67995. * @hidden Internal
  67996. */
  67997. _effects: Array<PostProcess>;
  67998. /**
  67999. * @hidden Internal
  68000. */
  68001. _downscale: ExtractHighlightsPostProcess;
  68002. private _blurX;
  68003. private _blurY;
  68004. private _merge;
  68005. /**
  68006. * The luminance threshold to find bright areas of the image to bloom.
  68007. */
  68008. get threshold(): number;
  68009. set threshold(value: number);
  68010. /**
  68011. * The strength of the bloom.
  68012. */
  68013. get weight(): number;
  68014. set weight(value: number);
  68015. /**
  68016. * Specifies the size of the bloom blur kernel, relative to the final output size
  68017. */
  68018. get kernel(): number;
  68019. set kernel(value: number);
  68020. /**
  68021. * Creates a new instance of @see BloomEffect
  68022. * @param scene The scene the effect belongs to.
  68023. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68024. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68025. * @param bloomWeight The the strength of bloom.
  68026. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68027. * @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)
  68028. */
  68029. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68030. /**
  68031. * Disposes each of the internal effects for a given camera.
  68032. * @param camera The camera to dispose the effect on.
  68033. */
  68034. disposeEffects(camera: Camera): void;
  68035. /**
  68036. * @hidden Internal
  68037. */
  68038. _updateEffects(): void;
  68039. /**
  68040. * Internal
  68041. * @returns if all the contained post processes are ready.
  68042. * @hidden
  68043. */
  68044. _isReady(): boolean;
  68045. }
  68046. }
  68047. declare module BABYLON {
  68048. /** @hidden */
  68049. export var chromaticAberrationPixelShader: {
  68050. name: string;
  68051. shader: string;
  68052. };
  68053. }
  68054. declare module BABYLON {
  68055. /**
  68056. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68057. */
  68058. export class ChromaticAberrationPostProcess extends PostProcess {
  68059. /**
  68060. * The amount of seperation of rgb channels (default: 30)
  68061. */
  68062. aberrationAmount: number;
  68063. /**
  68064. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68065. */
  68066. radialIntensity: number;
  68067. /**
  68068. * 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))
  68069. */
  68070. direction: Vector2;
  68071. /**
  68072. * 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))
  68073. */
  68074. centerPosition: Vector2;
  68075. /**
  68076. * Creates a new instance ChromaticAberrationPostProcess
  68077. * @param name The name of the effect.
  68078. * @param screenWidth The width of the screen to apply the effect on.
  68079. * @param screenHeight The height of the screen to apply the effect on.
  68080. * @param options The required width/height ratio to downsize to before computing the render pass.
  68081. * @param camera The camera to apply the render pass to.
  68082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68083. * @param engine The engine which the post process will be applied. (default: current engine)
  68084. * @param reusable If the post process can be reused on the same frame. (default: false)
  68085. * @param textureType Type of textures used when performing the post process. (default: 0)
  68086. * @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)
  68087. */
  68088. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68089. }
  68090. }
  68091. declare module BABYLON {
  68092. /** @hidden */
  68093. export var circleOfConfusionPixelShader: {
  68094. name: string;
  68095. shader: string;
  68096. };
  68097. }
  68098. declare module BABYLON {
  68099. /**
  68100. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68101. */
  68102. export class CircleOfConfusionPostProcess extends PostProcess {
  68103. /**
  68104. * 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.
  68105. */
  68106. lensSize: number;
  68107. /**
  68108. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68109. */
  68110. fStop: number;
  68111. /**
  68112. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68113. */
  68114. focusDistance: number;
  68115. /**
  68116. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68117. */
  68118. focalLength: number;
  68119. private _depthTexture;
  68120. /**
  68121. * Creates a new instance CircleOfConfusionPostProcess
  68122. * @param name The name of the effect.
  68123. * @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.
  68124. * @param options The required width/height ratio to downsize to before computing the render pass.
  68125. * @param camera The camera to apply the render pass to.
  68126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68127. * @param engine The engine which the post process will be applied. (default: current engine)
  68128. * @param reusable If the post process can be reused on the same frame. (default: false)
  68129. * @param textureType Type of textures used when performing the post process. (default: 0)
  68130. * @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)
  68131. */
  68132. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68133. /**
  68134. * 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.
  68135. */
  68136. set depthTexture(value: RenderTargetTexture);
  68137. }
  68138. }
  68139. declare module BABYLON {
  68140. /** @hidden */
  68141. export var colorCorrectionPixelShader: {
  68142. name: string;
  68143. shader: string;
  68144. };
  68145. }
  68146. declare module BABYLON {
  68147. /**
  68148. *
  68149. * This post-process allows the modification of rendered colors by using
  68150. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68151. *
  68152. * The object needs to be provided an url to a texture containing the color
  68153. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68154. * Use an image editing software to tweak the LUT to match your needs.
  68155. *
  68156. * For an example of a color LUT, see here:
  68157. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68158. * For explanations on color grading, see here:
  68159. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68160. *
  68161. */
  68162. export class ColorCorrectionPostProcess extends PostProcess {
  68163. private _colorTableTexture;
  68164. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68165. }
  68166. }
  68167. declare module BABYLON {
  68168. /** @hidden */
  68169. export var convolutionPixelShader: {
  68170. name: string;
  68171. shader: string;
  68172. };
  68173. }
  68174. declare module BABYLON {
  68175. /**
  68176. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68177. * input texture to perform effects such as edge detection or sharpening
  68178. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68179. */
  68180. export class ConvolutionPostProcess extends PostProcess {
  68181. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68182. kernel: number[];
  68183. /**
  68184. * Creates a new instance ConvolutionPostProcess
  68185. * @param name The name of the effect.
  68186. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68187. * @param options The required width/height ratio to downsize to before computing the render pass.
  68188. * @param camera The camera to apply the render pass to.
  68189. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68190. * @param engine The engine which the post process will be applied. (default: current engine)
  68191. * @param reusable If the post process can be reused on the same frame. (default: false)
  68192. * @param textureType Type of textures used when performing the post process. (default: 0)
  68193. */
  68194. constructor(name: string,
  68195. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68196. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68197. /**
  68198. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68199. */
  68200. static EdgeDetect0Kernel: number[];
  68201. /**
  68202. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68203. */
  68204. static EdgeDetect1Kernel: number[];
  68205. /**
  68206. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68207. */
  68208. static EdgeDetect2Kernel: number[];
  68209. /**
  68210. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68211. */
  68212. static SharpenKernel: number[];
  68213. /**
  68214. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68215. */
  68216. static EmbossKernel: number[];
  68217. /**
  68218. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68219. */
  68220. static GaussianKernel: number[];
  68221. }
  68222. }
  68223. declare module BABYLON {
  68224. /**
  68225. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68226. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68227. * based on samples that have a large difference in distance than the center pixel.
  68228. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68229. */
  68230. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68231. direction: Vector2;
  68232. /**
  68233. * Creates a new instance CircleOfConfusionPostProcess
  68234. * @param name The name of the effect.
  68235. * @param scene The scene the effect belongs to.
  68236. * @param direction The direction the blur should be applied.
  68237. * @param kernel The size of the kernel used to blur.
  68238. * @param options The required width/height ratio to downsize to before computing the render pass.
  68239. * @param camera The camera to apply the render pass to.
  68240. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68241. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68243. * @param engine The engine which the post process will be applied. (default: current engine)
  68244. * @param reusable If the post process can be reused on the same frame. (default: false)
  68245. * @param textureType Type of textures used when performing the post process. (default: 0)
  68246. * @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)
  68247. */
  68248. 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);
  68249. }
  68250. }
  68251. declare module BABYLON {
  68252. /** @hidden */
  68253. export var depthOfFieldMergePixelShader: {
  68254. name: string;
  68255. shader: string;
  68256. };
  68257. }
  68258. declare module BABYLON {
  68259. /**
  68260. * Options to be set when merging outputs from the default pipeline.
  68261. */
  68262. export class DepthOfFieldMergePostProcessOptions {
  68263. /**
  68264. * The original image to merge on top of
  68265. */
  68266. originalFromInput: PostProcess;
  68267. /**
  68268. * Parameters to perform the merge of the depth of field effect
  68269. */
  68270. depthOfField?: {
  68271. circleOfConfusion: PostProcess;
  68272. blurSteps: Array<PostProcess>;
  68273. };
  68274. /**
  68275. * Parameters to perform the merge of bloom effect
  68276. */
  68277. bloom?: {
  68278. blurred: PostProcess;
  68279. weight: number;
  68280. };
  68281. }
  68282. /**
  68283. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68284. */
  68285. export class DepthOfFieldMergePostProcess extends PostProcess {
  68286. private blurSteps;
  68287. /**
  68288. * Creates a new instance of DepthOfFieldMergePostProcess
  68289. * @param name The name of the effect.
  68290. * @param originalFromInput Post process which's input will be used for the merge.
  68291. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68292. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68293. * @param options The required width/height ratio to downsize to before computing the render pass.
  68294. * @param camera The camera to apply the render pass to.
  68295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68296. * @param engine The engine which the post process will be applied. (default: current engine)
  68297. * @param reusable If the post process can be reused on the same frame. (default: false)
  68298. * @param textureType Type of textures used when performing the post process. (default: 0)
  68299. * @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)
  68300. */
  68301. 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);
  68302. /**
  68303. * Updates the effect with the current post process compile time values and recompiles the shader.
  68304. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68305. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68306. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68307. * @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
  68308. * @param onCompiled Called when the shader has been compiled.
  68309. * @param onError Called if there is an error when compiling a shader.
  68310. */
  68311. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68312. }
  68313. }
  68314. declare module BABYLON {
  68315. /**
  68316. * Specifies the level of max blur that should be applied when using the depth of field effect
  68317. */
  68318. export enum DepthOfFieldEffectBlurLevel {
  68319. /**
  68320. * Subtle blur
  68321. */
  68322. Low = 0,
  68323. /**
  68324. * Medium blur
  68325. */
  68326. Medium = 1,
  68327. /**
  68328. * Large blur
  68329. */
  68330. High = 2
  68331. }
  68332. /**
  68333. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68334. */
  68335. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68336. private _circleOfConfusion;
  68337. /**
  68338. * @hidden Internal, blurs from high to low
  68339. */
  68340. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68341. private _depthOfFieldBlurY;
  68342. private _dofMerge;
  68343. /**
  68344. * @hidden Internal post processes in depth of field effect
  68345. */
  68346. _effects: Array<PostProcess>;
  68347. /**
  68348. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68349. */
  68350. set focalLength(value: number);
  68351. get focalLength(): number;
  68352. /**
  68353. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68354. */
  68355. set fStop(value: number);
  68356. get fStop(): number;
  68357. /**
  68358. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68359. */
  68360. set focusDistance(value: number);
  68361. get focusDistance(): number;
  68362. /**
  68363. * 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.
  68364. */
  68365. set lensSize(value: number);
  68366. get lensSize(): number;
  68367. /**
  68368. * Creates a new instance DepthOfFieldEffect
  68369. * @param scene The scene the effect belongs to.
  68370. * @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.
  68371. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68372. * @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)
  68373. */
  68374. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68375. /**
  68376. * Get the current class name of the current effet
  68377. * @returns "DepthOfFieldEffect"
  68378. */
  68379. getClassName(): string;
  68380. /**
  68381. * 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.
  68382. */
  68383. set depthTexture(value: RenderTargetTexture);
  68384. /**
  68385. * Disposes each of the internal effects for a given camera.
  68386. * @param camera The camera to dispose the effect on.
  68387. */
  68388. disposeEffects(camera: Camera): void;
  68389. /**
  68390. * @hidden Internal
  68391. */
  68392. _updateEffects(): void;
  68393. /**
  68394. * Internal
  68395. * @returns if all the contained post processes are ready.
  68396. * @hidden
  68397. */
  68398. _isReady(): boolean;
  68399. }
  68400. }
  68401. declare module BABYLON {
  68402. /** @hidden */
  68403. export var displayPassPixelShader: {
  68404. name: string;
  68405. shader: string;
  68406. };
  68407. }
  68408. declare module BABYLON {
  68409. /**
  68410. * DisplayPassPostProcess which produces an output the same as it's input
  68411. */
  68412. export class DisplayPassPostProcess extends PostProcess {
  68413. /**
  68414. * Creates the DisplayPassPostProcess
  68415. * @param name The name of the effect.
  68416. * @param options The required width/height ratio to downsize to before computing the render pass.
  68417. * @param camera The camera to apply the render pass to.
  68418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68419. * @param engine The engine which the post process will be applied. (default: current engine)
  68420. * @param reusable If the post process can be reused on the same frame. (default: false)
  68421. */
  68422. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68423. }
  68424. }
  68425. declare module BABYLON {
  68426. /** @hidden */
  68427. export var filterPixelShader: {
  68428. name: string;
  68429. shader: string;
  68430. };
  68431. }
  68432. declare module BABYLON {
  68433. /**
  68434. * Applies a kernel filter to the image
  68435. */
  68436. export class FilterPostProcess extends PostProcess {
  68437. /** The matrix to be applied to the image */
  68438. kernelMatrix: Matrix;
  68439. /**
  68440. *
  68441. * @param name The name of the effect.
  68442. * @param kernelMatrix The matrix to be applied to the image
  68443. * @param options The required width/height ratio to downsize to before computing the render pass.
  68444. * @param camera The camera to apply the render pass to.
  68445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68446. * @param engine The engine which the post process will be applied. (default: current engine)
  68447. * @param reusable If the post process can be reused on the same frame. (default: false)
  68448. */
  68449. constructor(name: string,
  68450. /** The matrix to be applied to the image */
  68451. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68452. }
  68453. }
  68454. declare module BABYLON {
  68455. /** @hidden */
  68456. export var fxaaPixelShader: {
  68457. name: string;
  68458. shader: string;
  68459. };
  68460. }
  68461. declare module BABYLON {
  68462. /** @hidden */
  68463. export var fxaaVertexShader: {
  68464. name: string;
  68465. shader: string;
  68466. };
  68467. }
  68468. declare module BABYLON {
  68469. /**
  68470. * Fxaa post process
  68471. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68472. */
  68473. export class FxaaPostProcess extends PostProcess {
  68474. /** @hidden */
  68475. texelWidth: number;
  68476. /** @hidden */
  68477. texelHeight: number;
  68478. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68479. private _getDefines;
  68480. }
  68481. }
  68482. declare module BABYLON {
  68483. /** @hidden */
  68484. export var grainPixelShader: {
  68485. name: string;
  68486. shader: string;
  68487. };
  68488. }
  68489. declare module BABYLON {
  68490. /**
  68491. * The GrainPostProcess adds noise to the image at mid luminance levels
  68492. */
  68493. export class GrainPostProcess extends PostProcess {
  68494. /**
  68495. * The intensity of the grain added (default: 30)
  68496. */
  68497. intensity: number;
  68498. /**
  68499. * If the grain should be randomized on every frame
  68500. */
  68501. animated: boolean;
  68502. /**
  68503. * Creates a new instance of @see GrainPostProcess
  68504. * @param name The name of the effect.
  68505. * @param options The required width/height ratio to downsize to before computing the render pass.
  68506. * @param camera The camera to apply the render pass to.
  68507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68508. * @param engine The engine which the post process will be applied. (default: current engine)
  68509. * @param reusable If the post process can be reused on the same frame. (default: false)
  68510. * @param textureType Type of textures used when performing the post process. (default: 0)
  68511. * @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)
  68512. */
  68513. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68514. }
  68515. }
  68516. declare module BABYLON {
  68517. /** @hidden */
  68518. export var highlightsPixelShader: {
  68519. name: string;
  68520. shader: string;
  68521. };
  68522. }
  68523. declare module BABYLON {
  68524. /**
  68525. * Extracts highlights from the image
  68526. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68527. */
  68528. export class HighlightsPostProcess extends PostProcess {
  68529. /**
  68530. * Extracts highlights from the image
  68531. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68532. * @param name The name of the effect.
  68533. * @param options The required width/height ratio to downsize to before computing the render pass.
  68534. * @param camera The camera to apply the render pass to.
  68535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68536. * @param engine The engine which the post process will be applied. (default: current engine)
  68537. * @param reusable If the post process can be reused on the same frame. (default: false)
  68538. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68539. */
  68540. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68541. }
  68542. }
  68543. declare module BABYLON {
  68544. /** @hidden */
  68545. export var mrtFragmentDeclaration: {
  68546. name: string;
  68547. shader: string;
  68548. };
  68549. }
  68550. declare module BABYLON {
  68551. /** @hidden */
  68552. export var geometryPixelShader: {
  68553. name: string;
  68554. shader: string;
  68555. };
  68556. }
  68557. declare module BABYLON {
  68558. /** @hidden */
  68559. export var geometryVertexShader: {
  68560. name: string;
  68561. shader: string;
  68562. };
  68563. }
  68564. declare module BABYLON {
  68565. /** @hidden */
  68566. interface ISavedTransformationMatrix {
  68567. world: Matrix;
  68568. viewProjection: Matrix;
  68569. }
  68570. /**
  68571. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68572. */
  68573. export class GeometryBufferRenderer {
  68574. /**
  68575. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68576. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68577. */
  68578. static readonly POSITION_TEXTURE_TYPE: number;
  68579. /**
  68580. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68581. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68582. */
  68583. static readonly VELOCITY_TEXTURE_TYPE: number;
  68584. /**
  68585. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68586. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68587. */
  68588. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68589. /**
  68590. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68591. * in order to compute objects velocities when enableVelocity is set to "true"
  68592. * @hidden
  68593. */
  68594. _previousTransformationMatrices: {
  68595. [index: number]: ISavedTransformationMatrix;
  68596. };
  68597. /**
  68598. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68599. * in order to compute objects velocities when enableVelocity is set to "true"
  68600. * @hidden
  68601. */
  68602. _previousBonesTransformationMatrices: {
  68603. [index: number]: Float32Array;
  68604. };
  68605. /**
  68606. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68607. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68608. */
  68609. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68610. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68611. renderTransparentMeshes: boolean;
  68612. private _scene;
  68613. private _multiRenderTarget;
  68614. private _ratio;
  68615. private _enablePosition;
  68616. private _enableVelocity;
  68617. private _enableReflectivity;
  68618. private _positionIndex;
  68619. private _velocityIndex;
  68620. private _reflectivityIndex;
  68621. protected _effect: Effect;
  68622. protected _cachedDefines: string;
  68623. /**
  68624. * Set the render list (meshes to be rendered) used in the G buffer.
  68625. */
  68626. set renderList(meshes: Mesh[]);
  68627. /**
  68628. * Gets wether or not G buffer are supported by the running hardware.
  68629. * This requires draw buffer supports
  68630. */
  68631. get isSupported(): boolean;
  68632. /**
  68633. * Returns the index of the given texture type in the G-Buffer textures array
  68634. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68635. * @returns the index of the given texture type in the G-Buffer textures array
  68636. */
  68637. getTextureIndex(textureType: number): number;
  68638. /**
  68639. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68640. */
  68641. get enablePosition(): boolean;
  68642. /**
  68643. * Sets whether or not objects positions are enabled for the G buffer.
  68644. */
  68645. set enablePosition(enable: boolean);
  68646. /**
  68647. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68648. */
  68649. get enableVelocity(): boolean;
  68650. /**
  68651. * Sets wether or not objects velocities are enabled for the G buffer.
  68652. */
  68653. set enableVelocity(enable: boolean);
  68654. /**
  68655. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68656. */
  68657. get enableReflectivity(): boolean;
  68658. /**
  68659. * Sets wether or not objects roughness are enabled for the G buffer.
  68660. */
  68661. set enableReflectivity(enable: boolean);
  68662. /**
  68663. * Gets the scene associated with the buffer.
  68664. */
  68665. get scene(): Scene;
  68666. /**
  68667. * Gets the ratio used by the buffer during its creation.
  68668. * How big is the buffer related to the main canvas.
  68669. */
  68670. get ratio(): number;
  68671. /** @hidden */
  68672. static _SceneComponentInitialization: (scene: Scene) => void;
  68673. /**
  68674. * Creates a new G Buffer for the scene
  68675. * @param scene The scene the buffer belongs to
  68676. * @param ratio How big is the buffer related to the main canvas.
  68677. */
  68678. constructor(scene: Scene, ratio?: number);
  68679. /**
  68680. * Checks wether everything is ready to render a submesh to the G buffer.
  68681. * @param subMesh the submesh to check readiness for
  68682. * @param useInstances is the mesh drawn using instance or not
  68683. * @returns true if ready otherwise false
  68684. */
  68685. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68686. /**
  68687. * Gets the current underlying G Buffer.
  68688. * @returns the buffer
  68689. */
  68690. getGBuffer(): MultiRenderTarget;
  68691. /**
  68692. * Gets the number of samples used to render the buffer (anti aliasing).
  68693. */
  68694. get samples(): number;
  68695. /**
  68696. * Sets the number of samples used to render the buffer (anti aliasing).
  68697. */
  68698. set samples(value: number);
  68699. /**
  68700. * Disposes the renderer and frees up associated resources.
  68701. */
  68702. dispose(): void;
  68703. protected _createRenderTargets(): void;
  68704. private _copyBonesTransformationMatrices;
  68705. }
  68706. }
  68707. declare module BABYLON {
  68708. interface Scene {
  68709. /** @hidden (Backing field) */
  68710. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68711. /**
  68712. * Gets or Sets the current geometry buffer associated to the scene.
  68713. */
  68714. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68715. /**
  68716. * Enables a GeometryBufferRender and associates it with the scene
  68717. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68718. * @returns the GeometryBufferRenderer
  68719. */
  68720. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68721. /**
  68722. * Disables the GeometryBufferRender associated with the scene
  68723. */
  68724. disableGeometryBufferRenderer(): void;
  68725. }
  68726. /**
  68727. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68728. * in several rendering techniques.
  68729. */
  68730. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68731. /**
  68732. * The component name helpful to identify the component in the list of scene components.
  68733. */
  68734. readonly name: string;
  68735. /**
  68736. * The scene the component belongs to.
  68737. */
  68738. scene: Scene;
  68739. /**
  68740. * Creates a new instance of the component for the given scene
  68741. * @param scene Defines the scene to register the component in
  68742. */
  68743. constructor(scene: Scene);
  68744. /**
  68745. * Registers the component in a given scene
  68746. */
  68747. register(): void;
  68748. /**
  68749. * Rebuilds the elements related to this component in case of
  68750. * context lost for instance.
  68751. */
  68752. rebuild(): void;
  68753. /**
  68754. * Disposes the component and the associated ressources
  68755. */
  68756. dispose(): void;
  68757. private _gatherRenderTargets;
  68758. }
  68759. }
  68760. declare module BABYLON {
  68761. /** @hidden */
  68762. export var motionBlurPixelShader: {
  68763. name: string;
  68764. shader: string;
  68765. };
  68766. }
  68767. declare module BABYLON {
  68768. /**
  68769. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68770. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68771. * As an example, all you have to do is to create the post-process:
  68772. * var mb = new BABYLON.MotionBlurPostProcess(
  68773. * 'mb', // The name of the effect.
  68774. * scene, // The scene containing the objects to blur according to their velocity.
  68775. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68776. * camera // The camera to apply the render pass to.
  68777. * );
  68778. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68779. */
  68780. export class MotionBlurPostProcess extends PostProcess {
  68781. /**
  68782. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68783. */
  68784. motionStrength: number;
  68785. /**
  68786. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68787. */
  68788. get motionBlurSamples(): number;
  68789. /**
  68790. * Sets the number of iterations to be used for motion blur quality
  68791. */
  68792. set motionBlurSamples(samples: number);
  68793. private _motionBlurSamples;
  68794. private _geometryBufferRenderer;
  68795. /**
  68796. * Creates a new instance MotionBlurPostProcess
  68797. * @param name The name of the effect.
  68798. * @param scene The scene containing the objects to blur according to their velocity.
  68799. * @param options The required width/height ratio to downsize to before computing the render pass.
  68800. * @param camera The camera to apply the render pass to.
  68801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68802. * @param engine The engine which the post process will be applied. (default: current engine)
  68803. * @param reusable If the post process can be reused on the same frame. (default: false)
  68804. * @param textureType Type of textures used when performing the post process. (default: 0)
  68805. * @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)
  68806. */
  68807. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68808. /**
  68809. * Excludes the given skinned mesh from computing bones velocities.
  68810. * 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.
  68811. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68812. */
  68813. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68814. /**
  68815. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68816. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68817. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68818. */
  68819. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68820. /**
  68821. * Disposes the post process.
  68822. * @param camera The camera to dispose the post process on.
  68823. */
  68824. dispose(camera?: Camera): void;
  68825. }
  68826. }
  68827. declare module BABYLON {
  68828. /** @hidden */
  68829. export var refractionPixelShader: {
  68830. name: string;
  68831. shader: string;
  68832. };
  68833. }
  68834. declare module BABYLON {
  68835. /**
  68836. * Post process which applies a refractin texture
  68837. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68838. */
  68839. export class RefractionPostProcess extends PostProcess {
  68840. /** the base color of the refraction (used to taint the rendering) */
  68841. color: Color3;
  68842. /** simulated refraction depth */
  68843. depth: number;
  68844. /** the coefficient of the base color (0 to remove base color tainting) */
  68845. colorLevel: number;
  68846. private _refTexture;
  68847. private _ownRefractionTexture;
  68848. /**
  68849. * Gets or sets the refraction texture
  68850. * Please note that you are responsible for disposing the texture if you set it manually
  68851. */
  68852. get refractionTexture(): Texture;
  68853. set refractionTexture(value: Texture);
  68854. /**
  68855. * Initializes the RefractionPostProcess
  68856. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68857. * @param name The name of the effect.
  68858. * @param refractionTextureUrl Url of the refraction texture to use
  68859. * @param color the base color of the refraction (used to taint the rendering)
  68860. * @param depth simulated refraction depth
  68861. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68862. * @param camera The camera to apply the render pass to.
  68863. * @param options The required width/height ratio to downsize to before computing the render pass.
  68864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68865. * @param engine The engine which the post process will be applied. (default: current engine)
  68866. * @param reusable If the post process can be reused on the same frame. (default: false)
  68867. */
  68868. constructor(name: string, refractionTextureUrl: string,
  68869. /** the base color of the refraction (used to taint the rendering) */
  68870. color: Color3,
  68871. /** simulated refraction depth */
  68872. depth: number,
  68873. /** the coefficient of the base color (0 to remove base color tainting) */
  68874. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68875. /**
  68876. * Disposes of the post process
  68877. * @param camera Camera to dispose post process on
  68878. */
  68879. dispose(camera: Camera): void;
  68880. }
  68881. }
  68882. declare module BABYLON {
  68883. /** @hidden */
  68884. export var sharpenPixelShader: {
  68885. name: string;
  68886. shader: string;
  68887. };
  68888. }
  68889. declare module BABYLON {
  68890. /**
  68891. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68892. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68893. */
  68894. export class SharpenPostProcess extends PostProcess {
  68895. /**
  68896. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68897. */
  68898. colorAmount: number;
  68899. /**
  68900. * How much sharpness should be applied (default: 0.3)
  68901. */
  68902. edgeAmount: number;
  68903. /**
  68904. * Creates a new instance ConvolutionPostProcess
  68905. * @param name The name of the effect.
  68906. * @param options The required width/height ratio to downsize to before computing the render pass.
  68907. * @param camera The camera to apply the render pass to.
  68908. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68909. * @param engine The engine which the post process will be applied. (default: current engine)
  68910. * @param reusable If the post process can be reused on the same frame. (default: false)
  68911. * @param textureType Type of textures used when performing the post process. (default: 0)
  68912. * @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)
  68913. */
  68914. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68915. }
  68916. }
  68917. declare module BABYLON {
  68918. /**
  68919. * PostProcessRenderPipeline
  68920. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68921. */
  68922. export class PostProcessRenderPipeline {
  68923. private engine;
  68924. private _renderEffects;
  68925. private _renderEffectsForIsolatedPass;
  68926. /**
  68927. * List of inspectable custom properties (used by the Inspector)
  68928. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68929. */
  68930. inspectableCustomProperties: IInspectable[];
  68931. /**
  68932. * @hidden
  68933. */
  68934. protected _cameras: Camera[];
  68935. /** @hidden */
  68936. _name: string;
  68937. /**
  68938. * Gets pipeline name
  68939. */
  68940. get name(): string;
  68941. /** Gets the list of attached cameras */
  68942. get cameras(): Camera[];
  68943. /**
  68944. * Initializes a PostProcessRenderPipeline
  68945. * @param engine engine to add the pipeline to
  68946. * @param name name of the pipeline
  68947. */
  68948. constructor(engine: Engine, name: string);
  68949. /**
  68950. * Gets the class name
  68951. * @returns "PostProcessRenderPipeline"
  68952. */
  68953. getClassName(): string;
  68954. /**
  68955. * If all the render effects in the pipeline are supported
  68956. */
  68957. get isSupported(): boolean;
  68958. /**
  68959. * Adds an effect to the pipeline
  68960. * @param renderEffect the effect to add
  68961. */
  68962. addEffect(renderEffect: PostProcessRenderEffect): void;
  68963. /** @hidden */
  68964. _rebuild(): void;
  68965. /** @hidden */
  68966. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68967. /** @hidden */
  68968. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68969. /** @hidden */
  68970. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68971. /** @hidden */
  68972. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68973. /** @hidden */
  68974. _attachCameras(cameras: Camera, unique: boolean): void;
  68975. /** @hidden */
  68976. _attachCameras(cameras: Camera[], unique: boolean): void;
  68977. /** @hidden */
  68978. _detachCameras(cameras: Camera): void;
  68979. /** @hidden */
  68980. _detachCameras(cameras: Nullable<Camera[]>): void;
  68981. /** @hidden */
  68982. _update(): void;
  68983. /** @hidden */
  68984. _reset(): void;
  68985. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68986. /**
  68987. * Disposes of the pipeline
  68988. */
  68989. dispose(): void;
  68990. }
  68991. }
  68992. declare module BABYLON {
  68993. /**
  68994. * PostProcessRenderPipelineManager class
  68995. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68996. */
  68997. export class PostProcessRenderPipelineManager {
  68998. private _renderPipelines;
  68999. /**
  69000. * Initializes a PostProcessRenderPipelineManager
  69001. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69002. */
  69003. constructor();
  69004. /**
  69005. * Gets the list of supported render pipelines
  69006. */
  69007. get supportedPipelines(): PostProcessRenderPipeline[];
  69008. /**
  69009. * Adds a pipeline to the manager
  69010. * @param renderPipeline The pipeline to add
  69011. */
  69012. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69013. /**
  69014. * Attaches a camera to the pipeline
  69015. * @param renderPipelineName The name of the pipeline to attach to
  69016. * @param cameras the camera to attach
  69017. * @param unique if the camera can be attached multiple times to the pipeline
  69018. */
  69019. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69020. /**
  69021. * Detaches a camera from the pipeline
  69022. * @param renderPipelineName The name of the pipeline to detach from
  69023. * @param cameras the camera to detach
  69024. */
  69025. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69026. /**
  69027. * Enables an effect by name on a pipeline
  69028. * @param renderPipelineName the name of the pipeline to enable the effect in
  69029. * @param renderEffectName the name of the effect to enable
  69030. * @param cameras the cameras that the effect should be enabled on
  69031. */
  69032. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69033. /**
  69034. * Disables an effect by name on a pipeline
  69035. * @param renderPipelineName the name of the pipeline to disable the effect in
  69036. * @param renderEffectName the name of the effect to disable
  69037. * @param cameras the cameras that the effect should be disabled on
  69038. */
  69039. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69040. /**
  69041. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69042. */
  69043. update(): void;
  69044. /** @hidden */
  69045. _rebuild(): void;
  69046. /**
  69047. * Disposes of the manager and pipelines
  69048. */
  69049. dispose(): void;
  69050. }
  69051. }
  69052. declare module BABYLON {
  69053. interface Scene {
  69054. /** @hidden (Backing field) */
  69055. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69056. /**
  69057. * Gets the postprocess render pipeline manager
  69058. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69059. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69060. */
  69061. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69062. }
  69063. /**
  69064. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69065. */
  69066. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69067. /**
  69068. * The component name helpfull to identify the component in the list of scene components.
  69069. */
  69070. readonly name: string;
  69071. /**
  69072. * The scene the component belongs to.
  69073. */
  69074. scene: Scene;
  69075. /**
  69076. * Creates a new instance of the component for the given scene
  69077. * @param scene Defines the scene to register the component in
  69078. */
  69079. constructor(scene: Scene);
  69080. /**
  69081. * Registers the component in a given scene
  69082. */
  69083. register(): void;
  69084. /**
  69085. * Rebuilds the elements related to this component in case of
  69086. * context lost for instance.
  69087. */
  69088. rebuild(): void;
  69089. /**
  69090. * Disposes the component and the associated ressources
  69091. */
  69092. dispose(): void;
  69093. private _gatherRenderTargets;
  69094. }
  69095. }
  69096. declare module BABYLON {
  69097. /**
  69098. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69099. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69100. */
  69101. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69102. private _scene;
  69103. private _camerasToBeAttached;
  69104. /**
  69105. * ID of the sharpen post process,
  69106. */
  69107. private readonly SharpenPostProcessId;
  69108. /**
  69109. * @ignore
  69110. * ID of the image processing post process;
  69111. */
  69112. readonly ImageProcessingPostProcessId: string;
  69113. /**
  69114. * @ignore
  69115. * ID of the Fast Approximate Anti-Aliasing post process;
  69116. */
  69117. readonly FxaaPostProcessId: string;
  69118. /**
  69119. * ID of the chromatic aberration post process,
  69120. */
  69121. private readonly ChromaticAberrationPostProcessId;
  69122. /**
  69123. * ID of the grain post process
  69124. */
  69125. private readonly GrainPostProcessId;
  69126. /**
  69127. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69128. */
  69129. sharpen: SharpenPostProcess;
  69130. private _sharpenEffect;
  69131. private bloom;
  69132. /**
  69133. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69134. */
  69135. depthOfField: DepthOfFieldEffect;
  69136. /**
  69137. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69138. */
  69139. fxaa: FxaaPostProcess;
  69140. /**
  69141. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69142. */
  69143. imageProcessing: ImageProcessingPostProcess;
  69144. /**
  69145. * Chromatic aberration post process which will shift rgb colors in the image
  69146. */
  69147. chromaticAberration: ChromaticAberrationPostProcess;
  69148. private _chromaticAberrationEffect;
  69149. /**
  69150. * Grain post process which add noise to the image
  69151. */
  69152. grain: GrainPostProcess;
  69153. private _grainEffect;
  69154. /**
  69155. * Glow post process which adds a glow to emissive areas of the image
  69156. */
  69157. private _glowLayer;
  69158. /**
  69159. * Animations which can be used to tweak settings over a period of time
  69160. */
  69161. animations: Animation[];
  69162. private _imageProcessingConfigurationObserver;
  69163. private _sharpenEnabled;
  69164. private _bloomEnabled;
  69165. private _depthOfFieldEnabled;
  69166. private _depthOfFieldBlurLevel;
  69167. private _fxaaEnabled;
  69168. private _imageProcessingEnabled;
  69169. private _defaultPipelineTextureType;
  69170. private _bloomScale;
  69171. private _chromaticAberrationEnabled;
  69172. private _grainEnabled;
  69173. private _buildAllowed;
  69174. /**
  69175. * Gets active scene
  69176. */
  69177. get scene(): Scene;
  69178. /**
  69179. * Enable or disable the sharpen process from the pipeline
  69180. */
  69181. set sharpenEnabled(enabled: boolean);
  69182. get sharpenEnabled(): boolean;
  69183. private _resizeObserver;
  69184. private _hardwareScaleLevel;
  69185. private _bloomKernel;
  69186. /**
  69187. * Specifies the size of the bloom blur kernel, relative to the final output size
  69188. */
  69189. get bloomKernel(): number;
  69190. set bloomKernel(value: number);
  69191. /**
  69192. * Specifies the weight of the bloom in the final rendering
  69193. */
  69194. private _bloomWeight;
  69195. /**
  69196. * Specifies the luma threshold for the area that will be blurred by the bloom
  69197. */
  69198. private _bloomThreshold;
  69199. private _hdr;
  69200. /**
  69201. * The strength of the bloom.
  69202. */
  69203. set bloomWeight(value: number);
  69204. get bloomWeight(): number;
  69205. /**
  69206. * The strength of the bloom.
  69207. */
  69208. set bloomThreshold(value: number);
  69209. get bloomThreshold(): number;
  69210. /**
  69211. * The scale of the bloom, lower value will provide better performance.
  69212. */
  69213. set bloomScale(value: number);
  69214. get bloomScale(): number;
  69215. /**
  69216. * Enable or disable the bloom from the pipeline
  69217. */
  69218. set bloomEnabled(enabled: boolean);
  69219. get bloomEnabled(): boolean;
  69220. private _rebuildBloom;
  69221. /**
  69222. * If the depth of field is enabled.
  69223. */
  69224. get depthOfFieldEnabled(): boolean;
  69225. set depthOfFieldEnabled(enabled: boolean);
  69226. /**
  69227. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69228. */
  69229. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69230. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69231. /**
  69232. * If the anti aliasing is enabled.
  69233. */
  69234. set fxaaEnabled(enabled: boolean);
  69235. get fxaaEnabled(): boolean;
  69236. private _samples;
  69237. /**
  69238. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69239. */
  69240. set samples(sampleCount: number);
  69241. get samples(): number;
  69242. /**
  69243. * If image processing is enabled.
  69244. */
  69245. set imageProcessingEnabled(enabled: boolean);
  69246. get imageProcessingEnabled(): boolean;
  69247. /**
  69248. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69249. */
  69250. set glowLayerEnabled(enabled: boolean);
  69251. get glowLayerEnabled(): boolean;
  69252. /**
  69253. * Gets the glow layer (or null if not defined)
  69254. */
  69255. get glowLayer(): Nullable<GlowLayer>;
  69256. /**
  69257. * Enable or disable the chromaticAberration process from the pipeline
  69258. */
  69259. set chromaticAberrationEnabled(enabled: boolean);
  69260. get chromaticAberrationEnabled(): boolean;
  69261. /**
  69262. * Enable or disable the grain process from the pipeline
  69263. */
  69264. set grainEnabled(enabled: boolean);
  69265. get grainEnabled(): boolean;
  69266. /**
  69267. * @constructor
  69268. * @param name - The rendering pipeline name (default: "")
  69269. * @param hdr - If high dynamic range textures should be used (default: true)
  69270. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69271. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69272. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69273. */
  69274. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69275. /**
  69276. * Get the class name
  69277. * @returns "DefaultRenderingPipeline"
  69278. */
  69279. getClassName(): string;
  69280. /**
  69281. * Force the compilation of the entire pipeline.
  69282. */
  69283. prepare(): void;
  69284. private _hasCleared;
  69285. private _prevPostProcess;
  69286. private _prevPrevPostProcess;
  69287. private _setAutoClearAndTextureSharing;
  69288. private _depthOfFieldSceneObserver;
  69289. private _buildPipeline;
  69290. private _disposePostProcesses;
  69291. /**
  69292. * Adds a camera to the pipeline
  69293. * @param camera the camera to be added
  69294. */
  69295. addCamera(camera: Camera): void;
  69296. /**
  69297. * Removes a camera from the pipeline
  69298. * @param camera the camera to remove
  69299. */
  69300. removeCamera(camera: Camera): void;
  69301. /**
  69302. * Dispose of the pipeline and stop all post processes
  69303. */
  69304. dispose(): void;
  69305. /**
  69306. * Serialize the rendering pipeline (Used when exporting)
  69307. * @returns the serialized object
  69308. */
  69309. serialize(): any;
  69310. /**
  69311. * Parse the serialized pipeline
  69312. * @param source Source pipeline.
  69313. * @param scene The scene to load the pipeline to.
  69314. * @param rootUrl The URL of the serialized pipeline.
  69315. * @returns An instantiated pipeline from the serialized object.
  69316. */
  69317. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69318. }
  69319. }
  69320. declare module BABYLON {
  69321. /** @hidden */
  69322. export var lensHighlightsPixelShader: {
  69323. name: string;
  69324. shader: string;
  69325. };
  69326. }
  69327. declare module BABYLON {
  69328. /** @hidden */
  69329. export var depthOfFieldPixelShader: {
  69330. name: string;
  69331. shader: string;
  69332. };
  69333. }
  69334. declare module BABYLON {
  69335. /**
  69336. * BABYLON.JS Chromatic Aberration GLSL Shader
  69337. * Author: Olivier Guyot
  69338. * Separates very slightly R, G and B colors on the edges of the screen
  69339. * Inspired by Francois Tarlier & Martins Upitis
  69340. */
  69341. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69342. /**
  69343. * @ignore
  69344. * The chromatic aberration PostProcess id in the pipeline
  69345. */
  69346. LensChromaticAberrationEffect: string;
  69347. /**
  69348. * @ignore
  69349. * The highlights enhancing PostProcess id in the pipeline
  69350. */
  69351. HighlightsEnhancingEffect: string;
  69352. /**
  69353. * @ignore
  69354. * The depth-of-field PostProcess id in the pipeline
  69355. */
  69356. LensDepthOfFieldEffect: string;
  69357. private _scene;
  69358. private _depthTexture;
  69359. private _grainTexture;
  69360. private _chromaticAberrationPostProcess;
  69361. private _highlightsPostProcess;
  69362. private _depthOfFieldPostProcess;
  69363. private _edgeBlur;
  69364. private _grainAmount;
  69365. private _chromaticAberration;
  69366. private _distortion;
  69367. private _highlightsGain;
  69368. private _highlightsThreshold;
  69369. private _dofDistance;
  69370. private _dofAperture;
  69371. private _dofDarken;
  69372. private _dofPentagon;
  69373. private _blurNoise;
  69374. /**
  69375. * @constructor
  69376. *
  69377. * Effect parameters are as follow:
  69378. * {
  69379. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69380. * edge_blur: number; // from 0 to x (1 for realism)
  69381. * distortion: number; // from 0 to x (1 for realism)
  69382. * grain_amount: number; // from 0 to 1
  69383. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69384. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69385. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69386. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69387. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69388. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69389. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69390. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69391. * }
  69392. * Note: if an effect parameter is unset, effect is disabled
  69393. *
  69394. * @param name The rendering pipeline name
  69395. * @param parameters - An object containing all parameters (see above)
  69396. * @param scene The scene linked to this pipeline
  69397. * @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)
  69398. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69399. */
  69400. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69401. /**
  69402. * Get the class name
  69403. * @returns "LensRenderingPipeline"
  69404. */
  69405. getClassName(): string;
  69406. /**
  69407. * Gets associated scene
  69408. */
  69409. get scene(): Scene;
  69410. /**
  69411. * Gets or sets the edge blur
  69412. */
  69413. get edgeBlur(): number;
  69414. set edgeBlur(value: number);
  69415. /**
  69416. * Gets or sets the grain amount
  69417. */
  69418. get grainAmount(): number;
  69419. set grainAmount(value: number);
  69420. /**
  69421. * Gets or sets the chromatic aberration amount
  69422. */
  69423. get chromaticAberration(): number;
  69424. set chromaticAberration(value: number);
  69425. /**
  69426. * Gets or sets the depth of field aperture
  69427. */
  69428. get dofAperture(): number;
  69429. set dofAperture(value: number);
  69430. /**
  69431. * Gets or sets the edge distortion
  69432. */
  69433. get edgeDistortion(): number;
  69434. set edgeDistortion(value: number);
  69435. /**
  69436. * Gets or sets the depth of field distortion
  69437. */
  69438. get dofDistortion(): number;
  69439. set dofDistortion(value: number);
  69440. /**
  69441. * Gets or sets the darken out of focus amount
  69442. */
  69443. get darkenOutOfFocus(): number;
  69444. set darkenOutOfFocus(value: number);
  69445. /**
  69446. * Gets or sets a boolean indicating if blur noise is enabled
  69447. */
  69448. get blurNoise(): boolean;
  69449. set blurNoise(value: boolean);
  69450. /**
  69451. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69452. */
  69453. get pentagonBokeh(): boolean;
  69454. set pentagonBokeh(value: boolean);
  69455. /**
  69456. * Gets or sets the highlight grain amount
  69457. */
  69458. get highlightsGain(): number;
  69459. set highlightsGain(value: number);
  69460. /**
  69461. * Gets or sets the highlight threshold
  69462. */
  69463. get highlightsThreshold(): number;
  69464. set highlightsThreshold(value: number);
  69465. /**
  69466. * Sets the amount of blur at the edges
  69467. * @param amount blur amount
  69468. */
  69469. setEdgeBlur(amount: number): void;
  69470. /**
  69471. * Sets edge blur to 0
  69472. */
  69473. disableEdgeBlur(): void;
  69474. /**
  69475. * Sets the amout of grain
  69476. * @param amount Amount of grain
  69477. */
  69478. setGrainAmount(amount: number): void;
  69479. /**
  69480. * Set grain amount to 0
  69481. */
  69482. disableGrain(): void;
  69483. /**
  69484. * Sets the chromatic aberration amount
  69485. * @param amount amount of chromatic aberration
  69486. */
  69487. setChromaticAberration(amount: number): void;
  69488. /**
  69489. * Sets chromatic aberration amount to 0
  69490. */
  69491. disableChromaticAberration(): void;
  69492. /**
  69493. * Sets the EdgeDistortion amount
  69494. * @param amount amount of EdgeDistortion
  69495. */
  69496. setEdgeDistortion(amount: number): void;
  69497. /**
  69498. * Sets edge distortion to 0
  69499. */
  69500. disableEdgeDistortion(): void;
  69501. /**
  69502. * Sets the FocusDistance amount
  69503. * @param amount amount of FocusDistance
  69504. */
  69505. setFocusDistance(amount: number): void;
  69506. /**
  69507. * Disables depth of field
  69508. */
  69509. disableDepthOfField(): void;
  69510. /**
  69511. * Sets the Aperture amount
  69512. * @param amount amount of Aperture
  69513. */
  69514. setAperture(amount: number): void;
  69515. /**
  69516. * Sets the DarkenOutOfFocus amount
  69517. * @param amount amount of DarkenOutOfFocus
  69518. */
  69519. setDarkenOutOfFocus(amount: number): void;
  69520. private _pentagonBokehIsEnabled;
  69521. /**
  69522. * Creates a pentagon bokeh effect
  69523. */
  69524. enablePentagonBokeh(): void;
  69525. /**
  69526. * Disables the pentagon bokeh effect
  69527. */
  69528. disablePentagonBokeh(): void;
  69529. /**
  69530. * Enables noise blur
  69531. */
  69532. enableNoiseBlur(): void;
  69533. /**
  69534. * Disables noise blur
  69535. */
  69536. disableNoiseBlur(): void;
  69537. /**
  69538. * Sets the HighlightsGain amount
  69539. * @param amount amount of HighlightsGain
  69540. */
  69541. setHighlightsGain(amount: number): void;
  69542. /**
  69543. * Sets the HighlightsThreshold amount
  69544. * @param amount amount of HighlightsThreshold
  69545. */
  69546. setHighlightsThreshold(amount: number): void;
  69547. /**
  69548. * Disables highlights
  69549. */
  69550. disableHighlights(): void;
  69551. /**
  69552. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69553. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69554. */
  69555. dispose(disableDepthRender?: boolean): void;
  69556. private _createChromaticAberrationPostProcess;
  69557. private _createHighlightsPostProcess;
  69558. private _createDepthOfFieldPostProcess;
  69559. private _createGrainTexture;
  69560. }
  69561. }
  69562. declare module BABYLON {
  69563. /** @hidden */
  69564. export var ssao2PixelShader: {
  69565. name: string;
  69566. shader: string;
  69567. };
  69568. }
  69569. declare module BABYLON {
  69570. /** @hidden */
  69571. export var ssaoCombinePixelShader: {
  69572. name: string;
  69573. shader: string;
  69574. };
  69575. }
  69576. declare module BABYLON {
  69577. /**
  69578. * Render pipeline to produce ssao effect
  69579. */
  69580. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69581. /**
  69582. * @ignore
  69583. * The PassPostProcess id in the pipeline that contains the original scene color
  69584. */
  69585. SSAOOriginalSceneColorEffect: string;
  69586. /**
  69587. * @ignore
  69588. * The SSAO PostProcess id in the pipeline
  69589. */
  69590. SSAORenderEffect: string;
  69591. /**
  69592. * @ignore
  69593. * The horizontal blur PostProcess id in the pipeline
  69594. */
  69595. SSAOBlurHRenderEffect: string;
  69596. /**
  69597. * @ignore
  69598. * The vertical blur PostProcess id in the pipeline
  69599. */
  69600. SSAOBlurVRenderEffect: string;
  69601. /**
  69602. * @ignore
  69603. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69604. */
  69605. SSAOCombineRenderEffect: string;
  69606. /**
  69607. * The output strength of the SSAO post-process. Default value is 1.0.
  69608. */
  69609. totalStrength: number;
  69610. /**
  69611. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69612. */
  69613. maxZ: number;
  69614. /**
  69615. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69616. */
  69617. minZAspect: number;
  69618. private _samples;
  69619. /**
  69620. * Number of samples used for the SSAO calculations. Default value is 8
  69621. */
  69622. set samples(n: number);
  69623. get samples(): number;
  69624. private _textureSamples;
  69625. /**
  69626. * Number of samples to use for antialiasing
  69627. */
  69628. set textureSamples(n: number);
  69629. get textureSamples(): number;
  69630. /**
  69631. * Ratio object used for SSAO ratio and blur ratio
  69632. */
  69633. private _ratio;
  69634. /**
  69635. * Dynamically generated sphere sampler.
  69636. */
  69637. private _sampleSphere;
  69638. /**
  69639. * Blur filter offsets
  69640. */
  69641. private _samplerOffsets;
  69642. private _expensiveBlur;
  69643. /**
  69644. * If bilateral blur should be used
  69645. */
  69646. set expensiveBlur(b: boolean);
  69647. get expensiveBlur(): boolean;
  69648. /**
  69649. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69650. */
  69651. radius: number;
  69652. /**
  69653. * The base color of the SSAO post-process
  69654. * The final result is "base + ssao" between [0, 1]
  69655. */
  69656. base: number;
  69657. /**
  69658. * Support test.
  69659. */
  69660. static get IsSupported(): boolean;
  69661. private _scene;
  69662. private _depthTexture;
  69663. private _normalTexture;
  69664. private _randomTexture;
  69665. private _originalColorPostProcess;
  69666. private _ssaoPostProcess;
  69667. private _blurHPostProcess;
  69668. private _blurVPostProcess;
  69669. private _ssaoCombinePostProcess;
  69670. /**
  69671. * Gets active scene
  69672. */
  69673. get scene(): Scene;
  69674. /**
  69675. * @constructor
  69676. * @param name The rendering pipeline name
  69677. * @param scene The scene linked to this pipeline
  69678. * @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 }
  69679. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69680. */
  69681. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69682. /**
  69683. * Get the class name
  69684. * @returns "SSAO2RenderingPipeline"
  69685. */
  69686. getClassName(): string;
  69687. /**
  69688. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69689. */
  69690. dispose(disableGeometryBufferRenderer?: boolean): void;
  69691. private _createBlurPostProcess;
  69692. /** @hidden */
  69693. _rebuild(): void;
  69694. private _bits;
  69695. private _radicalInverse_VdC;
  69696. private _hammersley;
  69697. private _hemisphereSample_uniform;
  69698. private _generateHemisphere;
  69699. private _createSSAOPostProcess;
  69700. private _createSSAOCombinePostProcess;
  69701. private _createRandomTexture;
  69702. /**
  69703. * Serialize the rendering pipeline (Used when exporting)
  69704. * @returns the serialized object
  69705. */
  69706. serialize(): any;
  69707. /**
  69708. * Parse the serialized pipeline
  69709. * @param source Source pipeline.
  69710. * @param scene The scene to load the pipeline to.
  69711. * @param rootUrl The URL of the serialized pipeline.
  69712. * @returns An instantiated pipeline from the serialized object.
  69713. */
  69714. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69715. }
  69716. }
  69717. declare module BABYLON {
  69718. /** @hidden */
  69719. export var ssaoPixelShader: {
  69720. name: string;
  69721. shader: string;
  69722. };
  69723. }
  69724. declare module BABYLON {
  69725. /**
  69726. * Render pipeline to produce ssao effect
  69727. */
  69728. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69729. /**
  69730. * @ignore
  69731. * The PassPostProcess id in the pipeline that contains the original scene color
  69732. */
  69733. SSAOOriginalSceneColorEffect: string;
  69734. /**
  69735. * @ignore
  69736. * The SSAO PostProcess id in the pipeline
  69737. */
  69738. SSAORenderEffect: string;
  69739. /**
  69740. * @ignore
  69741. * The horizontal blur PostProcess id in the pipeline
  69742. */
  69743. SSAOBlurHRenderEffect: string;
  69744. /**
  69745. * @ignore
  69746. * The vertical blur PostProcess id in the pipeline
  69747. */
  69748. SSAOBlurVRenderEffect: string;
  69749. /**
  69750. * @ignore
  69751. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69752. */
  69753. SSAOCombineRenderEffect: string;
  69754. /**
  69755. * The output strength of the SSAO post-process. Default value is 1.0.
  69756. */
  69757. totalStrength: number;
  69758. /**
  69759. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69760. */
  69761. radius: number;
  69762. /**
  69763. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69764. * Must not be equal to fallOff and superior to fallOff.
  69765. * Default value is 0.0075
  69766. */
  69767. area: number;
  69768. /**
  69769. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69770. * Must not be equal to area and inferior to area.
  69771. * Default value is 0.000001
  69772. */
  69773. fallOff: number;
  69774. /**
  69775. * The base color of the SSAO post-process
  69776. * The final result is "base + ssao" between [0, 1]
  69777. */
  69778. base: number;
  69779. private _scene;
  69780. private _depthTexture;
  69781. private _randomTexture;
  69782. private _originalColorPostProcess;
  69783. private _ssaoPostProcess;
  69784. private _blurHPostProcess;
  69785. private _blurVPostProcess;
  69786. private _ssaoCombinePostProcess;
  69787. private _firstUpdate;
  69788. /**
  69789. * Gets active scene
  69790. */
  69791. get scene(): Scene;
  69792. /**
  69793. * @constructor
  69794. * @param name - The rendering pipeline name
  69795. * @param scene - The scene linked to this pipeline
  69796. * @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 }
  69797. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69798. */
  69799. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69800. /**
  69801. * Get the class name
  69802. * @returns "SSAORenderingPipeline"
  69803. */
  69804. getClassName(): string;
  69805. /**
  69806. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69807. */
  69808. dispose(disableDepthRender?: boolean): void;
  69809. private _createBlurPostProcess;
  69810. /** @hidden */
  69811. _rebuild(): void;
  69812. private _createSSAOPostProcess;
  69813. private _createSSAOCombinePostProcess;
  69814. private _createRandomTexture;
  69815. }
  69816. }
  69817. declare module BABYLON {
  69818. /** @hidden */
  69819. export var screenSpaceReflectionPixelShader: {
  69820. name: string;
  69821. shader: string;
  69822. };
  69823. }
  69824. declare module BABYLON {
  69825. /**
  69826. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69827. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69828. */
  69829. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69830. /**
  69831. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69832. */
  69833. threshold: number;
  69834. /**
  69835. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69836. */
  69837. strength: number;
  69838. /**
  69839. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69840. */
  69841. reflectionSpecularFalloffExponent: number;
  69842. /**
  69843. * 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]
  69844. */
  69845. step: number;
  69846. /**
  69847. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69848. */
  69849. roughnessFactor: number;
  69850. private _geometryBufferRenderer;
  69851. private _enableSmoothReflections;
  69852. private _reflectionSamples;
  69853. private _smoothSteps;
  69854. /**
  69855. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69856. * @param name The name of the effect.
  69857. * @param scene The scene containing the objects to calculate reflections.
  69858. * @param options The required width/height ratio to downsize to before computing the render pass.
  69859. * @param camera The camera to apply the render pass to.
  69860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69861. * @param engine The engine which the post process will be applied. (default: current engine)
  69862. * @param reusable If the post process can be reused on the same frame. (default: false)
  69863. * @param textureType Type of textures used when performing the post process. (default: 0)
  69864. * @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)
  69865. */
  69866. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69867. /**
  69868. * Gets wether or not smoothing reflections is enabled.
  69869. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69870. */
  69871. get enableSmoothReflections(): boolean;
  69872. /**
  69873. * Sets wether or not smoothing reflections is enabled.
  69874. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69875. */
  69876. set enableSmoothReflections(enabled: boolean);
  69877. /**
  69878. * Gets the number of samples taken while computing reflections. More samples count is high,
  69879. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69880. */
  69881. get reflectionSamples(): number;
  69882. /**
  69883. * Sets the number of samples taken while computing reflections. More samples count is high,
  69884. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69885. */
  69886. set reflectionSamples(samples: number);
  69887. /**
  69888. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69889. * more the post-process will require GPU power and can generate a drop in FPS.
  69890. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69891. */
  69892. get smoothSteps(): number;
  69893. set smoothSteps(steps: number);
  69894. private _updateEffectDefines;
  69895. }
  69896. }
  69897. declare module BABYLON {
  69898. /** @hidden */
  69899. export var standardPixelShader: {
  69900. name: string;
  69901. shader: string;
  69902. };
  69903. }
  69904. declare module BABYLON {
  69905. /**
  69906. * Standard rendering pipeline
  69907. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69908. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69909. */
  69910. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69911. /**
  69912. * Public members
  69913. */
  69914. /**
  69915. * Post-process which contains the original scene color before the pipeline applies all the effects
  69916. */
  69917. originalPostProcess: Nullable<PostProcess>;
  69918. /**
  69919. * Post-process used to down scale an image x4
  69920. */
  69921. downSampleX4PostProcess: Nullable<PostProcess>;
  69922. /**
  69923. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69924. */
  69925. brightPassPostProcess: Nullable<PostProcess>;
  69926. /**
  69927. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69928. */
  69929. blurHPostProcesses: PostProcess[];
  69930. /**
  69931. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69932. */
  69933. blurVPostProcesses: PostProcess[];
  69934. /**
  69935. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69936. */
  69937. textureAdderPostProcess: Nullable<PostProcess>;
  69938. /**
  69939. * Post-process used to create volumetric lighting effect
  69940. */
  69941. volumetricLightPostProcess: Nullable<PostProcess>;
  69942. /**
  69943. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69944. */
  69945. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69946. /**
  69947. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69948. */
  69949. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69950. /**
  69951. * Post-process used to merge the volumetric light effect and the real scene color
  69952. */
  69953. volumetricLightMergePostProces: Nullable<PostProcess>;
  69954. /**
  69955. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69956. */
  69957. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69958. /**
  69959. * Base post-process used to calculate the average luminance of the final image for HDR
  69960. */
  69961. luminancePostProcess: Nullable<PostProcess>;
  69962. /**
  69963. * Post-processes used to create down sample post-processes in order to get
  69964. * the average luminance of the final image for HDR
  69965. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69966. */
  69967. luminanceDownSamplePostProcesses: PostProcess[];
  69968. /**
  69969. * Post-process used to create a HDR effect (light adaptation)
  69970. */
  69971. hdrPostProcess: Nullable<PostProcess>;
  69972. /**
  69973. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69974. */
  69975. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69976. /**
  69977. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69978. */
  69979. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69980. /**
  69981. * Post-process used to merge the final HDR post-process and the real scene color
  69982. */
  69983. hdrFinalPostProcess: Nullable<PostProcess>;
  69984. /**
  69985. * Post-process used to create a lens flare effect
  69986. */
  69987. lensFlarePostProcess: Nullable<PostProcess>;
  69988. /**
  69989. * Post-process that merges the result of the lens flare post-process and the real scene color
  69990. */
  69991. lensFlareComposePostProcess: Nullable<PostProcess>;
  69992. /**
  69993. * Post-process used to create a motion blur effect
  69994. */
  69995. motionBlurPostProcess: Nullable<PostProcess>;
  69996. /**
  69997. * Post-process used to create a depth of field effect
  69998. */
  69999. depthOfFieldPostProcess: Nullable<PostProcess>;
  70000. /**
  70001. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70002. */
  70003. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70004. /**
  70005. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70006. */
  70007. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70008. /**
  70009. * Represents the brightness threshold in order to configure the illuminated surfaces
  70010. */
  70011. brightThreshold: number;
  70012. /**
  70013. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70014. */
  70015. blurWidth: number;
  70016. /**
  70017. * Sets if the blur for highlighted surfaces must be only horizontal
  70018. */
  70019. horizontalBlur: boolean;
  70020. /**
  70021. * Gets the overall exposure used by the pipeline
  70022. */
  70023. get exposure(): number;
  70024. /**
  70025. * Sets the overall exposure used by the pipeline
  70026. */
  70027. set exposure(value: number);
  70028. /**
  70029. * Texture used typically to simulate "dirty" on camera lens
  70030. */
  70031. lensTexture: Nullable<Texture>;
  70032. /**
  70033. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70034. */
  70035. volumetricLightCoefficient: number;
  70036. /**
  70037. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70038. */
  70039. volumetricLightPower: number;
  70040. /**
  70041. * Used the set the blur intensity to smooth the volumetric lights
  70042. */
  70043. volumetricLightBlurScale: number;
  70044. /**
  70045. * Light (spot or directional) used to generate the volumetric lights rays
  70046. * The source light must have a shadow generate so the pipeline can get its
  70047. * depth map
  70048. */
  70049. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70050. /**
  70051. * For eye adaptation, represents the minimum luminance the eye can see
  70052. */
  70053. hdrMinimumLuminance: number;
  70054. /**
  70055. * For eye adaptation, represents the decrease luminance speed
  70056. */
  70057. hdrDecreaseRate: number;
  70058. /**
  70059. * For eye adaptation, represents the increase luminance speed
  70060. */
  70061. hdrIncreaseRate: number;
  70062. /**
  70063. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70064. */
  70065. get hdrAutoExposure(): boolean;
  70066. /**
  70067. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70068. */
  70069. set hdrAutoExposure(value: boolean);
  70070. /**
  70071. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70072. */
  70073. lensColorTexture: Nullable<Texture>;
  70074. /**
  70075. * The overall strengh for the lens flare effect
  70076. */
  70077. lensFlareStrength: number;
  70078. /**
  70079. * Dispersion coefficient for lens flare ghosts
  70080. */
  70081. lensFlareGhostDispersal: number;
  70082. /**
  70083. * Main lens flare halo width
  70084. */
  70085. lensFlareHaloWidth: number;
  70086. /**
  70087. * Based on the lens distortion effect, defines how much the lens flare result
  70088. * is distorted
  70089. */
  70090. lensFlareDistortionStrength: number;
  70091. /**
  70092. * Configures the blur intensity used for for lens flare (halo)
  70093. */
  70094. lensFlareBlurWidth: number;
  70095. /**
  70096. * Lens star texture must be used to simulate rays on the flares and is available
  70097. * in the documentation
  70098. */
  70099. lensStarTexture: Nullable<Texture>;
  70100. /**
  70101. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70102. * flare effect by taking account of the dirt texture
  70103. */
  70104. lensFlareDirtTexture: Nullable<Texture>;
  70105. /**
  70106. * Represents the focal length for the depth of field effect
  70107. */
  70108. depthOfFieldDistance: number;
  70109. /**
  70110. * Represents the blur intensity for the blurred part of the depth of field effect
  70111. */
  70112. depthOfFieldBlurWidth: number;
  70113. /**
  70114. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70115. */
  70116. get motionStrength(): number;
  70117. /**
  70118. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70119. */
  70120. set motionStrength(strength: number);
  70121. /**
  70122. * Gets wether or not the motion blur post-process is object based or screen based.
  70123. */
  70124. get objectBasedMotionBlur(): boolean;
  70125. /**
  70126. * Sets wether or not the motion blur post-process should be object based or screen based
  70127. */
  70128. set objectBasedMotionBlur(value: boolean);
  70129. /**
  70130. * List of animations for the pipeline (IAnimatable implementation)
  70131. */
  70132. animations: Animation[];
  70133. /**
  70134. * Private members
  70135. */
  70136. private _scene;
  70137. private _currentDepthOfFieldSource;
  70138. private _basePostProcess;
  70139. private _fixedExposure;
  70140. private _currentExposure;
  70141. private _hdrAutoExposure;
  70142. private _hdrCurrentLuminance;
  70143. private _motionStrength;
  70144. private _isObjectBasedMotionBlur;
  70145. private _floatTextureType;
  70146. private _camerasToBeAttached;
  70147. private _ratio;
  70148. private _bloomEnabled;
  70149. private _depthOfFieldEnabled;
  70150. private _vlsEnabled;
  70151. private _lensFlareEnabled;
  70152. private _hdrEnabled;
  70153. private _motionBlurEnabled;
  70154. private _fxaaEnabled;
  70155. private _screenSpaceReflectionsEnabled;
  70156. private _motionBlurSamples;
  70157. private _volumetricLightStepsCount;
  70158. private _samples;
  70159. /**
  70160. * @ignore
  70161. * Specifies if the bloom pipeline is enabled
  70162. */
  70163. get BloomEnabled(): boolean;
  70164. set BloomEnabled(enabled: boolean);
  70165. /**
  70166. * @ignore
  70167. * Specifies if the depth of field pipeline is enabed
  70168. */
  70169. get DepthOfFieldEnabled(): boolean;
  70170. set DepthOfFieldEnabled(enabled: boolean);
  70171. /**
  70172. * @ignore
  70173. * Specifies if the lens flare pipeline is enabed
  70174. */
  70175. get LensFlareEnabled(): boolean;
  70176. set LensFlareEnabled(enabled: boolean);
  70177. /**
  70178. * @ignore
  70179. * Specifies if the HDR pipeline is enabled
  70180. */
  70181. get HDREnabled(): boolean;
  70182. set HDREnabled(enabled: boolean);
  70183. /**
  70184. * @ignore
  70185. * Specifies if the volumetric lights scattering effect is enabled
  70186. */
  70187. get VLSEnabled(): boolean;
  70188. set VLSEnabled(enabled: boolean);
  70189. /**
  70190. * @ignore
  70191. * Specifies if the motion blur effect is enabled
  70192. */
  70193. get MotionBlurEnabled(): boolean;
  70194. set MotionBlurEnabled(enabled: boolean);
  70195. /**
  70196. * Specifies if anti-aliasing is enabled
  70197. */
  70198. get fxaaEnabled(): boolean;
  70199. set fxaaEnabled(enabled: boolean);
  70200. /**
  70201. * Specifies if screen space reflections are enabled.
  70202. */
  70203. get screenSpaceReflectionsEnabled(): boolean;
  70204. set screenSpaceReflectionsEnabled(enabled: boolean);
  70205. /**
  70206. * Specifies the number of steps used to calculate the volumetric lights
  70207. * Typically in interval [50, 200]
  70208. */
  70209. get volumetricLightStepsCount(): number;
  70210. set volumetricLightStepsCount(count: number);
  70211. /**
  70212. * Specifies the number of samples used for the motion blur effect
  70213. * Typically in interval [16, 64]
  70214. */
  70215. get motionBlurSamples(): number;
  70216. set motionBlurSamples(samples: number);
  70217. /**
  70218. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70219. */
  70220. get samples(): number;
  70221. set samples(sampleCount: number);
  70222. /**
  70223. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70224. * @constructor
  70225. * @param name The rendering pipeline name
  70226. * @param scene The scene linked to this pipeline
  70227. * @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)
  70228. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70229. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70230. */
  70231. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70232. private _buildPipeline;
  70233. private _createDownSampleX4PostProcess;
  70234. private _createBrightPassPostProcess;
  70235. private _createBlurPostProcesses;
  70236. private _createTextureAdderPostProcess;
  70237. private _createVolumetricLightPostProcess;
  70238. private _createLuminancePostProcesses;
  70239. private _createHdrPostProcess;
  70240. private _createLensFlarePostProcess;
  70241. private _createDepthOfFieldPostProcess;
  70242. private _createMotionBlurPostProcess;
  70243. private _getDepthTexture;
  70244. private _disposePostProcesses;
  70245. /**
  70246. * Dispose of the pipeline and stop all post processes
  70247. */
  70248. dispose(): void;
  70249. /**
  70250. * Serialize the rendering pipeline (Used when exporting)
  70251. * @returns the serialized object
  70252. */
  70253. serialize(): any;
  70254. /**
  70255. * Parse the serialized pipeline
  70256. * @param source Source pipeline.
  70257. * @param scene The scene to load the pipeline to.
  70258. * @param rootUrl The URL of the serialized pipeline.
  70259. * @returns An instantiated pipeline from the serialized object.
  70260. */
  70261. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70262. /**
  70263. * Luminance steps
  70264. */
  70265. static LuminanceSteps: number;
  70266. }
  70267. }
  70268. declare module BABYLON {
  70269. /** @hidden */
  70270. export var stereoscopicInterlacePixelShader: {
  70271. name: string;
  70272. shader: string;
  70273. };
  70274. }
  70275. declare module BABYLON {
  70276. /**
  70277. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70278. */
  70279. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70280. private _stepSize;
  70281. private _passedProcess;
  70282. /**
  70283. * Initializes a StereoscopicInterlacePostProcessI
  70284. * @param name The name of the effect.
  70285. * @param rigCameras The rig cameras to be appled to the post process
  70286. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70287. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70289. * @param engine The engine which the post process will be applied. (default: current engine)
  70290. * @param reusable If the post process can be reused on the same frame. (default: false)
  70291. */
  70292. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70293. }
  70294. /**
  70295. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70296. */
  70297. export class StereoscopicInterlacePostProcess extends PostProcess {
  70298. private _stepSize;
  70299. private _passedProcess;
  70300. /**
  70301. * Initializes a StereoscopicInterlacePostProcess
  70302. * @param name The name of the effect.
  70303. * @param rigCameras The rig cameras to be appled to the post process
  70304. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70306. * @param engine The engine which the post process will be applied. (default: current engine)
  70307. * @param reusable If the post process can be reused on the same frame. (default: false)
  70308. */
  70309. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70310. }
  70311. }
  70312. declare module BABYLON {
  70313. /** @hidden */
  70314. export var tonemapPixelShader: {
  70315. name: string;
  70316. shader: string;
  70317. };
  70318. }
  70319. declare module BABYLON {
  70320. /** Defines operator used for tonemapping */
  70321. export enum TonemappingOperator {
  70322. /** Hable */
  70323. Hable = 0,
  70324. /** Reinhard */
  70325. Reinhard = 1,
  70326. /** HejiDawson */
  70327. HejiDawson = 2,
  70328. /** Photographic */
  70329. Photographic = 3
  70330. }
  70331. /**
  70332. * Defines a post process to apply tone mapping
  70333. */
  70334. export class TonemapPostProcess extends PostProcess {
  70335. private _operator;
  70336. /** Defines the required exposure adjustement */
  70337. exposureAdjustment: number;
  70338. /**
  70339. * Creates a new TonemapPostProcess
  70340. * @param name defines the name of the postprocess
  70341. * @param _operator defines the operator to use
  70342. * @param exposureAdjustment defines the required exposure adjustement
  70343. * @param camera defines the camera to use (can be null)
  70344. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70345. * @param engine defines the hosting engine (can be ignore if camera is set)
  70346. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70347. */
  70348. constructor(name: string, _operator: TonemappingOperator,
  70349. /** Defines the required exposure adjustement */
  70350. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70351. }
  70352. }
  70353. declare module BABYLON {
  70354. /** @hidden */
  70355. export var volumetricLightScatteringPixelShader: {
  70356. name: string;
  70357. shader: string;
  70358. };
  70359. }
  70360. declare module BABYLON {
  70361. /** @hidden */
  70362. export var volumetricLightScatteringPassVertexShader: {
  70363. name: string;
  70364. shader: string;
  70365. };
  70366. }
  70367. declare module BABYLON {
  70368. /** @hidden */
  70369. export var volumetricLightScatteringPassPixelShader: {
  70370. name: string;
  70371. shader: string;
  70372. };
  70373. }
  70374. declare module BABYLON {
  70375. /**
  70376. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70377. */
  70378. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70379. private _volumetricLightScatteringPass;
  70380. private _volumetricLightScatteringRTT;
  70381. private _viewPort;
  70382. private _screenCoordinates;
  70383. private _cachedDefines;
  70384. /**
  70385. * If not undefined, the mesh position is computed from the attached node position
  70386. */
  70387. attachedNode: {
  70388. position: Vector3;
  70389. };
  70390. /**
  70391. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70392. */
  70393. customMeshPosition: Vector3;
  70394. /**
  70395. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70396. */
  70397. useCustomMeshPosition: boolean;
  70398. /**
  70399. * If the post-process should inverse the light scattering direction
  70400. */
  70401. invert: boolean;
  70402. /**
  70403. * The internal mesh used by the post-process
  70404. */
  70405. mesh: Mesh;
  70406. /**
  70407. * @hidden
  70408. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70409. */
  70410. get useDiffuseColor(): boolean;
  70411. set useDiffuseColor(useDiffuseColor: boolean);
  70412. /**
  70413. * Array containing the excluded meshes not rendered in the internal pass
  70414. */
  70415. excludedMeshes: AbstractMesh[];
  70416. /**
  70417. * Controls the overall intensity of the post-process
  70418. */
  70419. exposure: number;
  70420. /**
  70421. * Dissipates each sample's contribution in range [0, 1]
  70422. */
  70423. decay: number;
  70424. /**
  70425. * Controls the overall intensity of each sample
  70426. */
  70427. weight: number;
  70428. /**
  70429. * Controls the density of each sample
  70430. */
  70431. density: number;
  70432. /**
  70433. * @constructor
  70434. * @param name The post-process name
  70435. * @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)
  70436. * @param camera The camera that the post-process will be attached to
  70437. * @param mesh The mesh used to create the light scattering
  70438. * @param samples The post-process quality, default 100
  70439. * @param samplingModeThe post-process filtering mode
  70440. * @param engine The babylon engine
  70441. * @param reusable If the post-process is reusable
  70442. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70443. */
  70444. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70445. /**
  70446. * Returns the string "VolumetricLightScatteringPostProcess"
  70447. * @returns "VolumetricLightScatteringPostProcess"
  70448. */
  70449. getClassName(): string;
  70450. private _isReady;
  70451. /**
  70452. * Sets the new light position for light scattering effect
  70453. * @param position The new custom light position
  70454. */
  70455. setCustomMeshPosition(position: Vector3): void;
  70456. /**
  70457. * Returns the light position for light scattering effect
  70458. * @return Vector3 The custom light position
  70459. */
  70460. getCustomMeshPosition(): Vector3;
  70461. /**
  70462. * Disposes the internal assets and detaches the post-process from the camera
  70463. */
  70464. dispose(camera: Camera): void;
  70465. /**
  70466. * Returns the render target texture used by the post-process
  70467. * @return the render target texture used by the post-process
  70468. */
  70469. getPass(): RenderTargetTexture;
  70470. private _meshExcluded;
  70471. private _createPass;
  70472. private _updateMeshScreenCoordinates;
  70473. /**
  70474. * Creates a default mesh for the Volumeric Light Scattering post-process
  70475. * @param name The mesh name
  70476. * @param scene The scene where to create the mesh
  70477. * @return the default mesh
  70478. */
  70479. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70480. }
  70481. }
  70482. declare module BABYLON {
  70483. interface Scene {
  70484. /** @hidden (Backing field) */
  70485. _boundingBoxRenderer: BoundingBoxRenderer;
  70486. /** @hidden (Backing field) */
  70487. _forceShowBoundingBoxes: boolean;
  70488. /**
  70489. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70490. */
  70491. forceShowBoundingBoxes: boolean;
  70492. /**
  70493. * Gets the bounding box renderer associated with the scene
  70494. * @returns a BoundingBoxRenderer
  70495. */
  70496. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70497. }
  70498. interface AbstractMesh {
  70499. /** @hidden (Backing field) */
  70500. _showBoundingBox: boolean;
  70501. /**
  70502. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70503. */
  70504. showBoundingBox: boolean;
  70505. }
  70506. /**
  70507. * Component responsible of rendering the bounding box of the meshes in a scene.
  70508. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70509. */
  70510. export class BoundingBoxRenderer implements ISceneComponent {
  70511. /**
  70512. * The component name helpfull to identify the component in the list of scene components.
  70513. */
  70514. readonly name: string;
  70515. /**
  70516. * The scene the component belongs to.
  70517. */
  70518. scene: Scene;
  70519. /**
  70520. * Color of the bounding box lines placed in front of an object
  70521. */
  70522. frontColor: Color3;
  70523. /**
  70524. * Color of the bounding box lines placed behind an object
  70525. */
  70526. backColor: Color3;
  70527. /**
  70528. * Defines if the renderer should show the back lines or not
  70529. */
  70530. showBackLines: boolean;
  70531. /**
  70532. * Observable raised before rendering a bounding box
  70533. */
  70534. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70535. /**
  70536. * Observable raised after rendering a bounding box
  70537. */
  70538. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70539. /**
  70540. * @hidden
  70541. */
  70542. renderList: SmartArray<BoundingBox>;
  70543. private _colorShader;
  70544. private _vertexBuffers;
  70545. private _indexBuffer;
  70546. private _fillIndexBuffer;
  70547. private _fillIndexData;
  70548. /**
  70549. * Instantiates a new bounding box renderer in a scene.
  70550. * @param scene the scene the renderer renders in
  70551. */
  70552. constructor(scene: Scene);
  70553. /**
  70554. * Registers the component in a given scene
  70555. */
  70556. register(): void;
  70557. private _evaluateSubMesh;
  70558. private _activeMesh;
  70559. private _prepareRessources;
  70560. private _createIndexBuffer;
  70561. /**
  70562. * Rebuilds the elements related to this component in case of
  70563. * context lost for instance.
  70564. */
  70565. rebuild(): void;
  70566. /**
  70567. * @hidden
  70568. */
  70569. reset(): void;
  70570. /**
  70571. * Render the bounding boxes of a specific rendering group
  70572. * @param renderingGroupId defines the rendering group to render
  70573. */
  70574. render(renderingGroupId: number): void;
  70575. /**
  70576. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70577. * @param mesh Define the mesh to render the occlusion bounding box for
  70578. */
  70579. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70580. /**
  70581. * Dispose and release the resources attached to this renderer.
  70582. */
  70583. dispose(): void;
  70584. }
  70585. }
  70586. declare module BABYLON {
  70587. interface Scene {
  70588. /** @hidden (Backing field) */
  70589. _depthRenderer: {
  70590. [id: string]: DepthRenderer;
  70591. };
  70592. /**
  70593. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70594. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70595. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70596. * @returns the created depth renderer
  70597. */
  70598. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70599. /**
  70600. * Disables a depth renderer for a given camera
  70601. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70602. */
  70603. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70604. }
  70605. /**
  70606. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70607. * in several rendering techniques.
  70608. */
  70609. export class DepthRendererSceneComponent implements ISceneComponent {
  70610. /**
  70611. * The component name helpfull to identify the component in the list of scene components.
  70612. */
  70613. readonly name: string;
  70614. /**
  70615. * The scene the component belongs to.
  70616. */
  70617. scene: Scene;
  70618. /**
  70619. * Creates a new instance of the component for the given scene
  70620. * @param scene Defines the scene to register the component in
  70621. */
  70622. constructor(scene: Scene);
  70623. /**
  70624. * Registers the component in a given scene
  70625. */
  70626. register(): void;
  70627. /**
  70628. * Rebuilds the elements related to this component in case of
  70629. * context lost for instance.
  70630. */
  70631. rebuild(): void;
  70632. /**
  70633. * Disposes the component and the associated ressources
  70634. */
  70635. dispose(): void;
  70636. private _gatherRenderTargets;
  70637. private _gatherActiveCameraRenderTargets;
  70638. }
  70639. }
  70640. declare module BABYLON {
  70641. /** @hidden */
  70642. export var outlinePixelShader: {
  70643. name: string;
  70644. shader: string;
  70645. };
  70646. }
  70647. declare module BABYLON {
  70648. /** @hidden */
  70649. export var outlineVertexShader: {
  70650. name: string;
  70651. shader: string;
  70652. };
  70653. }
  70654. declare module BABYLON {
  70655. interface Scene {
  70656. /** @hidden */
  70657. _outlineRenderer: OutlineRenderer;
  70658. /**
  70659. * Gets the outline renderer associated with the scene
  70660. * @returns a OutlineRenderer
  70661. */
  70662. getOutlineRenderer(): OutlineRenderer;
  70663. }
  70664. interface AbstractMesh {
  70665. /** @hidden (Backing field) */
  70666. _renderOutline: boolean;
  70667. /**
  70668. * Gets or sets a boolean indicating if the outline must be rendered as well
  70669. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70670. */
  70671. renderOutline: boolean;
  70672. /** @hidden (Backing field) */
  70673. _renderOverlay: boolean;
  70674. /**
  70675. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70676. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70677. */
  70678. renderOverlay: boolean;
  70679. }
  70680. /**
  70681. * This class is responsible to draw bothe outline/overlay of meshes.
  70682. * It should not be used directly but through the available method on mesh.
  70683. */
  70684. export class OutlineRenderer implements ISceneComponent {
  70685. /**
  70686. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70687. */
  70688. private static _StencilReference;
  70689. /**
  70690. * The name of the component. Each component must have a unique name.
  70691. */
  70692. name: string;
  70693. /**
  70694. * The scene the component belongs to.
  70695. */
  70696. scene: Scene;
  70697. /**
  70698. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70699. */
  70700. zOffset: number;
  70701. private _engine;
  70702. private _effect;
  70703. private _cachedDefines;
  70704. private _savedDepthWrite;
  70705. /**
  70706. * Instantiates a new outline renderer. (There could be only one per scene).
  70707. * @param scene Defines the scene it belongs to
  70708. */
  70709. constructor(scene: Scene);
  70710. /**
  70711. * Register the component to one instance of a scene.
  70712. */
  70713. register(): void;
  70714. /**
  70715. * Rebuilds the elements related to this component in case of
  70716. * context lost for instance.
  70717. */
  70718. rebuild(): void;
  70719. /**
  70720. * Disposes the component and the associated ressources.
  70721. */
  70722. dispose(): void;
  70723. /**
  70724. * Renders the outline in the canvas.
  70725. * @param subMesh Defines the sumesh to render
  70726. * @param batch Defines the batch of meshes in case of instances
  70727. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70728. */
  70729. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70730. /**
  70731. * Returns whether or not the outline renderer is ready for a given submesh.
  70732. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70733. * @param subMesh Defines the submesh to check readyness for
  70734. * @param useInstances Defines wheter wee are trying to render instances or not
  70735. * @returns true if ready otherwise false
  70736. */
  70737. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70738. private _beforeRenderingMesh;
  70739. private _afterRenderingMesh;
  70740. }
  70741. }
  70742. declare module BABYLON {
  70743. /**
  70744. * Defines the basic options interface of a Sprite Frame Source Size.
  70745. */
  70746. export interface ISpriteJSONSpriteSourceSize {
  70747. /**
  70748. * number of the original width of the Frame
  70749. */
  70750. w: number;
  70751. /**
  70752. * number of the original height of the Frame
  70753. */
  70754. h: number;
  70755. }
  70756. /**
  70757. * Defines the basic options interface of a Sprite Frame Data.
  70758. */
  70759. export interface ISpriteJSONSpriteFrameData {
  70760. /**
  70761. * number of the x offset of the Frame
  70762. */
  70763. x: number;
  70764. /**
  70765. * number of the y offset of the Frame
  70766. */
  70767. y: number;
  70768. /**
  70769. * number of the width of the Frame
  70770. */
  70771. w: number;
  70772. /**
  70773. * number of the height of the Frame
  70774. */
  70775. h: number;
  70776. }
  70777. /**
  70778. * Defines the basic options interface of a JSON Sprite.
  70779. */
  70780. export interface ISpriteJSONSprite {
  70781. /**
  70782. * string name of the Frame
  70783. */
  70784. filename: string;
  70785. /**
  70786. * ISpriteJSONSpriteFrame basic object of the frame data
  70787. */
  70788. frame: ISpriteJSONSpriteFrameData;
  70789. /**
  70790. * boolean to flag is the frame was rotated.
  70791. */
  70792. rotated: boolean;
  70793. /**
  70794. * boolean to flag is the frame was trimmed.
  70795. */
  70796. trimmed: boolean;
  70797. /**
  70798. * ISpriteJSONSpriteFrame basic object of the source data
  70799. */
  70800. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70801. /**
  70802. * ISpriteJSONSpriteFrame basic object of the source data
  70803. */
  70804. sourceSize: ISpriteJSONSpriteSourceSize;
  70805. }
  70806. /**
  70807. * Defines the basic options interface of a JSON atlas.
  70808. */
  70809. export interface ISpriteJSONAtlas {
  70810. /**
  70811. * Array of objects that contain the frame data.
  70812. */
  70813. frames: Array<ISpriteJSONSprite>;
  70814. /**
  70815. * object basic object containing the sprite meta data.
  70816. */
  70817. meta?: object;
  70818. }
  70819. }
  70820. declare module BABYLON {
  70821. /** @hidden */
  70822. export var spriteMapPixelShader: {
  70823. name: string;
  70824. shader: string;
  70825. };
  70826. }
  70827. declare module BABYLON {
  70828. /** @hidden */
  70829. export var spriteMapVertexShader: {
  70830. name: string;
  70831. shader: string;
  70832. };
  70833. }
  70834. declare module BABYLON {
  70835. /**
  70836. * Defines the basic options interface of a SpriteMap
  70837. */
  70838. export interface ISpriteMapOptions {
  70839. /**
  70840. * Vector2 of the number of cells in the grid.
  70841. */
  70842. stageSize?: Vector2;
  70843. /**
  70844. * Vector2 of the size of the output plane in World Units.
  70845. */
  70846. outputSize?: Vector2;
  70847. /**
  70848. * Vector3 of the position of the output plane in World Units.
  70849. */
  70850. outputPosition?: Vector3;
  70851. /**
  70852. * Vector3 of the rotation of the output plane.
  70853. */
  70854. outputRotation?: Vector3;
  70855. /**
  70856. * number of layers that the system will reserve in resources.
  70857. */
  70858. layerCount?: number;
  70859. /**
  70860. * number of max animation frames a single cell will reserve in resources.
  70861. */
  70862. maxAnimationFrames?: number;
  70863. /**
  70864. * number cell index of the base tile when the system compiles.
  70865. */
  70866. baseTile?: number;
  70867. /**
  70868. * boolean flip the sprite after its been repositioned by the framing data.
  70869. */
  70870. flipU?: boolean;
  70871. /**
  70872. * Vector3 scalar of the global RGB values of the SpriteMap.
  70873. */
  70874. colorMultiply?: Vector3;
  70875. }
  70876. /**
  70877. * Defines the IDisposable interface in order to be cleanable from resources.
  70878. */
  70879. export interface ISpriteMap extends IDisposable {
  70880. /**
  70881. * String name of the SpriteMap.
  70882. */
  70883. name: string;
  70884. /**
  70885. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70886. */
  70887. atlasJSON: ISpriteJSONAtlas;
  70888. /**
  70889. * Texture of the SpriteMap.
  70890. */
  70891. spriteSheet: Texture;
  70892. /**
  70893. * The parameters to initialize the SpriteMap with.
  70894. */
  70895. options: ISpriteMapOptions;
  70896. }
  70897. /**
  70898. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70899. */
  70900. export class SpriteMap implements ISpriteMap {
  70901. /** The Name of the spriteMap */
  70902. name: string;
  70903. /** The JSON file with the frame and meta data */
  70904. atlasJSON: ISpriteJSONAtlas;
  70905. /** The systems Sprite Sheet Texture */
  70906. spriteSheet: Texture;
  70907. /** Arguments passed with the Constructor */
  70908. options: ISpriteMapOptions;
  70909. /** Public Sprite Storage array, parsed from atlasJSON */
  70910. sprites: Array<ISpriteJSONSprite>;
  70911. /** Returns the Number of Sprites in the System */
  70912. get spriteCount(): number;
  70913. /** Returns the Position of Output Plane*/
  70914. get position(): Vector3;
  70915. /** Returns the Position of Output Plane*/
  70916. set position(v: Vector3);
  70917. /** Returns the Rotation of Output Plane*/
  70918. get rotation(): Vector3;
  70919. /** Returns the Rotation of Output Plane*/
  70920. set rotation(v: Vector3);
  70921. /** Sets the AnimationMap*/
  70922. get animationMap(): RawTexture;
  70923. /** Sets the AnimationMap*/
  70924. set animationMap(v: RawTexture);
  70925. /** Scene that the SpriteMap was created in */
  70926. private _scene;
  70927. /** Texture Buffer of Float32 that holds tile frame data*/
  70928. private _frameMap;
  70929. /** Texture Buffers of Float32 that holds tileMap data*/
  70930. private _tileMaps;
  70931. /** Texture Buffer of Float32 that holds Animation Data*/
  70932. private _animationMap;
  70933. /** Custom ShaderMaterial Central to the System*/
  70934. private _material;
  70935. /** Custom ShaderMaterial Central to the System*/
  70936. private _output;
  70937. /** Systems Time Ticker*/
  70938. private _time;
  70939. /**
  70940. * Creates a new SpriteMap
  70941. * @param name defines the SpriteMaps Name
  70942. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70943. * @param spriteSheet is the Texture that the Sprites are on.
  70944. * @param options a basic deployment configuration
  70945. * @param scene The Scene that the map is deployed on
  70946. */
  70947. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70948. /**
  70949. * Returns tileID location
  70950. * @returns Vector2 the cell position ID
  70951. */
  70952. getTileID(): Vector2;
  70953. /**
  70954. * Gets the UV location of the mouse over the SpriteMap.
  70955. * @returns Vector2 the UV position of the mouse interaction
  70956. */
  70957. getMousePosition(): Vector2;
  70958. /**
  70959. * Creates the "frame" texture Buffer
  70960. * -------------------------------------
  70961. * Structure of frames
  70962. * "filename": "Falling-Water-2.png",
  70963. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70964. * "rotated": true,
  70965. * "trimmed": true,
  70966. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70967. * "sourceSize": {"w":32,"h":32}
  70968. * @returns RawTexture of the frameMap
  70969. */
  70970. private _createFrameBuffer;
  70971. /**
  70972. * Creates the tileMap texture Buffer
  70973. * @param buffer normally and array of numbers, or a false to generate from scratch
  70974. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70975. * @returns RawTexture of the tileMap
  70976. */
  70977. private _createTileBuffer;
  70978. /**
  70979. * Modifies the data of the tileMaps
  70980. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70981. * @param pos is the iVector2 Coordinates of the Tile
  70982. * @param tile The SpriteIndex of the new Tile
  70983. */
  70984. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70985. /**
  70986. * Creates the animationMap texture Buffer
  70987. * @param buffer normally and array of numbers, or a false to generate from scratch
  70988. * @returns RawTexture of the animationMap
  70989. */
  70990. private _createTileAnimationBuffer;
  70991. /**
  70992. * Modifies the data of the animationMap
  70993. * @param cellID is the Index of the Sprite
  70994. * @param _frame is the target Animation frame
  70995. * @param toCell is the Target Index of the next frame of the animation
  70996. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70997. * @param speed is a global scalar of the time variable on the map.
  70998. */
  70999. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71000. /**
  71001. * Exports the .tilemaps file
  71002. */
  71003. saveTileMaps(): void;
  71004. /**
  71005. * Imports the .tilemaps file
  71006. * @param url of the .tilemaps file
  71007. */
  71008. loadTileMaps(url: string): void;
  71009. /**
  71010. * Release associated resources
  71011. */
  71012. dispose(): void;
  71013. }
  71014. }
  71015. declare module BABYLON {
  71016. /**
  71017. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71018. * @see http://doc.babylonjs.com/babylon101/sprites
  71019. */
  71020. export class SpritePackedManager extends SpriteManager {
  71021. /** defines the packed manager's name */
  71022. name: string;
  71023. /**
  71024. * Creates a new sprite manager from a packed sprite sheet
  71025. * @param name defines the manager's name
  71026. * @param imgUrl defines the sprite sheet url
  71027. * @param capacity defines the maximum allowed number of sprites
  71028. * @param scene defines the hosting scene
  71029. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71030. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71031. * @param samplingMode defines the smapling mode to use with spritesheet
  71032. * @param fromPacked set to true; do not alter
  71033. */
  71034. constructor(
  71035. /** defines the packed manager's name */
  71036. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71037. }
  71038. }
  71039. declare module BABYLON {
  71040. /**
  71041. * Defines the list of states available for a task inside a AssetsManager
  71042. */
  71043. export enum AssetTaskState {
  71044. /**
  71045. * Initialization
  71046. */
  71047. INIT = 0,
  71048. /**
  71049. * Running
  71050. */
  71051. RUNNING = 1,
  71052. /**
  71053. * Done
  71054. */
  71055. DONE = 2,
  71056. /**
  71057. * Error
  71058. */
  71059. ERROR = 3
  71060. }
  71061. /**
  71062. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71063. */
  71064. export abstract class AbstractAssetTask {
  71065. /**
  71066. * Task name
  71067. */ name: string;
  71068. /**
  71069. * Callback called when the task is successful
  71070. */
  71071. onSuccess: (task: any) => void;
  71072. /**
  71073. * Callback called when the task is not successful
  71074. */
  71075. onError: (task: any, message?: string, exception?: any) => void;
  71076. /**
  71077. * Creates a new AssetsManager
  71078. * @param name defines the name of the task
  71079. */
  71080. constructor(
  71081. /**
  71082. * Task name
  71083. */ name: string);
  71084. private _isCompleted;
  71085. private _taskState;
  71086. private _errorObject;
  71087. /**
  71088. * Get if the task is completed
  71089. */
  71090. get isCompleted(): boolean;
  71091. /**
  71092. * Gets the current state of the task
  71093. */
  71094. get taskState(): AssetTaskState;
  71095. /**
  71096. * Gets the current error object (if task is in error)
  71097. */
  71098. get errorObject(): {
  71099. message?: string;
  71100. exception?: any;
  71101. };
  71102. /**
  71103. * Internal only
  71104. * @hidden
  71105. */
  71106. _setErrorObject(message?: string, exception?: any): void;
  71107. /**
  71108. * Execute the current task
  71109. * @param scene defines the scene where you want your assets to be loaded
  71110. * @param onSuccess is a callback called when the task is successfully executed
  71111. * @param onError is a callback called if an error occurs
  71112. */
  71113. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71114. /**
  71115. * Execute the current task
  71116. * @param scene defines the scene where you want your assets to be loaded
  71117. * @param onSuccess is a callback called when the task is successfully executed
  71118. * @param onError is a callback called if an error occurs
  71119. */
  71120. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71121. /**
  71122. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71123. * This can be used with failed tasks that have the reason for failure fixed.
  71124. */
  71125. reset(): void;
  71126. private onErrorCallback;
  71127. private onDoneCallback;
  71128. }
  71129. /**
  71130. * Define the interface used by progress events raised during assets loading
  71131. */
  71132. export interface IAssetsProgressEvent {
  71133. /**
  71134. * Defines the number of remaining tasks to process
  71135. */
  71136. remainingCount: number;
  71137. /**
  71138. * Defines the total number of tasks
  71139. */
  71140. totalCount: number;
  71141. /**
  71142. * Defines the task that was just processed
  71143. */
  71144. task: AbstractAssetTask;
  71145. }
  71146. /**
  71147. * Class used to share progress information about assets loading
  71148. */
  71149. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71150. /**
  71151. * Defines the number of remaining tasks to process
  71152. */
  71153. remainingCount: number;
  71154. /**
  71155. * Defines the total number of tasks
  71156. */
  71157. totalCount: number;
  71158. /**
  71159. * Defines the task that was just processed
  71160. */
  71161. task: AbstractAssetTask;
  71162. /**
  71163. * Creates a AssetsProgressEvent
  71164. * @param remainingCount defines the number of remaining tasks to process
  71165. * @param totalCount defines the total number of tasks
  71166. * @param task defines the task that was just processed
  71167. */
  71168. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71169. }
  71170. /**
  71171. * Define a task used by AssetsManager to load meshes
  71172. */
  71173. export class MeshAssetTask extends AbstractAssetTask {
  71174. /**
  71175. * Defines the name of the task
  71176. */
  71177. name: string;
  71178. /**
  71179. * Defines the list of mesh's names you want to load
  71180. */
  71181. meshesNames: any;
  71182. /**
  71183. * Defines the root url to use as a base to load your meshes and associated resources
  71184. */
  71185. rootUrl: string;
  71186. /**
  71187. * Defines the filename or File of the scene to load from
  71188. */
  71189. sceneFilename: string | File;
  71190. /**
  71191. * Gets the list of loaded meshes
  71192. */
  71193. loadedMeshes: Array<AbstractMesh>;
  71194. /**
  71195. * Gets the list of loaded particle systems
  71196. */
  71197. loadedParticleSystems: Array<IParticleSystem>;
  71198. /**
  71199. * Gets the list of loaded skeletons
  71200. */
  71201. loadedSkeletons: Array<Skeleton>;
  71202. /**
  71203. * Gets the list of loaded animation groups
  71204. */
  71205. loadedAnimationGroups: Array<AnimationGroup>;
  71206. /**
  71207. * Callback called when the task is successful
  71208. */
  71209. onSuccess: (task: MeshAssetTask) => void;
  71210. /**
  71211. * Callback called when the task is successful
  71212. */
  71213. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71214. /**
  71215. * Creates a new MeshAssetTask
  71216. * @param name defines the name of the task
  71217. * @param meshesNames defines the list of mesh's names you want to load
  71218. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71219. * @param sceneFilename defines the filename or File of the scene to load from
  71220. */
  71221. constructor(
  71222. /**
  71223. * Defines the name of the task
  71224. */
  71225. name: string,
  71226. /**
  71227. * Defines the list of mesh's names you want to load
  71228. */
  71229. meshesNames: any,
  71230. /**
  71231. * Defines the root url to use as a base to load your meshes and associated resources
  71232. */
  71233. rootUrl: string,
  71234. /**
  71235. * Defines the filename or File of the scene to load from
  71236. */
  71237. sceneFilename: string | File);
  71238. /**
  71239. * Execute the current task
  71240. * @param scene defines the scene where you want your assets to be loaded
  71241. * @param onSuccess is a callback called when the task is successfully executed
  71242. * @param onError is a callback called if an error occurs
  71243. */
  71244. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71245. }
  71246. /**
  71247. * Define a task used by AssetsManager to load text content
  71248. */
  71249. export class TextFileAssetTask extends AbstractAssetTask {
  71250. /**
  71251. * Defines the name of the task
  71252. */
  71253. name: string;
  71254. /**
  71255. * Defines the location of the file to load
  71256. */
  71257. url: string;
  71258. /**
  71259. * Gets the loaded text string
  71260. */
  71261. text: string;
  71262. /**
  71263. * Callback called when the task is successful
  71264. */
  71265. onSuccess: (task: TextFileAssetTask) => void;
  71266. /**
  71267. * Callback called when the task is successful
  71268. */
  71269. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71270. /**
  71271. * Creates a new TextFileAssetTask object
  71272. * @param name defines the name of the task
  71273. * @param url defines the location of the file to load
  71274. */
  71275. constructor(
  71276. /**
  71277. * Defines the name of the task
  71278. */
  71279. name: string,
  71280. /**
  71281. * Defines the location of the file to load
  71282. */
  71283. url: string);
  71284. /**
  71285. * Execute the current task
  71286. * @param scene defines the scene where you want your assets to be loaded
  71287. * @param onSuccess is a callback called when the task is successfully executed
  71288. * @param onError is a callback called if an error occurs
  71289. */
  71290. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71291. }
  71292. /**
  71293. * Define a task used by AssetsManager to load binary data
  71294. */
  71295. export class BinaryFileAssetTask extends AbstractAssetTask {
  71296. /**
  71297. * Defines the name of the task
  71298. */
  71299. name: string;
  71300. /**
  71301. * Defines the location of the file to load
  71302. */
  71303. url: string;
  71304. /**
  71305. * Gets the lodaded data (as an array buffer)
  71306. */
  71307. data: ArrayBuffer;
  71308. /**
  71309. * Callback called when the task is successful
  71310. */
  71311. onSuccess: (task: BinaryFileAssetTask) => void;
  71312. /**
  71313. * Callback called when the task is successful
  71314. */
  71315. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71316. /**
  71317. * Creates a new BinaryFileAssetTask object
  71318. * @param name defines the name of the new task
  71319. * @param url defines the location of the file to load
  71320. */
  71321. constructor(
  71322. /**
  71323. * Defines the name of the task
  71324. */
  71325. name: string,
  71326. /**
  71327. * Defines the location of the file to load
  71328. */
  71329. url: string);
  71330. /**
  71331. * Execute the current task
  71332. * @param scene defines the scene where you want your assets to be loaded
  71333. * @param onSuccess is a callback called when the task is successfully executed
  71334. * @param onError is a callback called if an error occurs
  71335. */
  71336. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71337. }
  71338. /**
  71339. * Define a task used by AssetsManager to load images
  71340. */
  71341. export class ImageAssetTask extends AbstractAssetTask {
  71342. /**
  71343. * Defines the name of the task
  71344. */
  71345. name: string;
  71346. /**
  71347. * Defines the location of the image to load
  71348. */
  71349. url: string;
  71350. /**
  71351. * Gets the loaded images
  71352. */
  71353. image: HTMLImageElement;
  71354. /**
  71355. * Callback called when the task is successful
  71356. */
  71357. onSuccess: (task: ImageAssetTask) => void;
  71358. /**
  71359. * Callback called when the task is successful
  71360. */
  71361. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71362. /**
  71363. * Creates a new ImageAssetTask
  71364. * @param name defines the name of the task
  71365. * @param url defines the location of the image to load
  71366. */
  71367. constructor(
  71368. /**
  71369. * Defines the name of the task
  71370. */
  71371. name: string,
  71372. /**
  71373. * Defines the location of the image to load
  71374. */
  71375. url: string);
  71376. /**
  71377. * Execute the current task
  71378. * @param scene defines the scene where you want your assets to be loaded
  71379. * @param onSuccess is a callback called when the task is successfully executed
  71380. * @param onError is a callback called if an error occurs
  71381. */
  71382. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71383. }
  71384. /**
  71385. * Defines the interface used by texture loading tasks
  71386. */
  71387. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71388. /**
  71389. * Gets the loaded texture
  71390. */
  71391. texture: TEX;
  71392. }
  71393. /**
  71394. * Define a task used by AssetsManager to load 2D textures
  71395. */
  71396. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71397. /**
  71398. * Defines the name of the task
  71399. */
  71400. name: string;
  71401. /**
  71402. * Defines the location of the file to load
  71403. */
  71404. url: string;
  71405. /**
  71406. * Defines if mipmap should not be generated (default is false)
  71407. */
  71408. noMipmap?: boolean | undefined;
  71409. /**
  71410. * Defines if texture must be inverted on Y axis (default is true)
  71411. */
  71412. invertY: boolean;
  71413. /**
  71414. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71415. */
  71416. samplingMode: number;
  71417. /**
  71418. * Gets the loaded texture
  71419. */
  71420. texture: Texture;
  71421. /**
  71422. * Callback called when the task is successful
  71423. */
  71424. onSuccess: (task: TextureAssetTask) => void;
  71425. /**
  71426. * Callback called when the task is successful
  71427. */
  71428. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71429. /**
  71430. * Creates a new TextureAssetTask object
  71431. * @param name defines the name of the task
  71432. * @param url defines the location of the file to load
  71433. * @param noMipmap defines if mipmap should not be generated (default is false)
  71434. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71435. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71436. */
  71437. constructor(
  71438. /**
  71439. * Defines the name of the task
  71440. */
  71441. name: string,
  71442. /**
  71443. * Defines the location of the file to load
  71444. */
  71445. url: string,
  71446. /**
  71447. * Defines if mipmap should not be generated (default is false)
  71448. */
  71449. noMipmap?: boolean | undefined,
  71450. /**
  71451. * Defines if texture must be inverted on Y axis (default is true)
  71452. */
  71453. invertY?: boolean,
  71454. /**
  71455. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71456. */
  71457. samplingMode?: number);
  71458. /**
  71459. * Execute the current task
  71460. * @param scene defines the scene where you want your assets to be loaded
  71461. * @param onSuccess is a callback called when the task is successfully executed
  71462. * @param onError is a callback called if an error occurs
  71463. */
  71464. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71465. }
  71466. /**
  71467. * Define a task used by AssetsManager to load cube textures
  71468. */
  71469. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71470. /**
  71471. * Defines the name of the task
  71472. */
  71473. name: string;
  71474. /**
  71475. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71476. */
  71477. url: string;
  71478. /**
  71479. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71480. */
  71481. extensions?: string[] | undefined;
  71482. /**
  71483. * Defines if mipmaps should not be generated (default is false)
  71484. */
  71485. noMipmap?: boolean | undefined;
  71486. /**
  71487. * Defines the explicit list of files (undefined by default)
  71488. */
  71489. files?: string[] | undefined;
  71490. /**
  71491. * Gets the loaded texture
  71492. */
  71493. texture: CubeTexture;
  71494. /**
  71495. * Callback called when the task is successful
  71496. */
  71497. onSuccess: (task: CubeTextureAssetTask) => void;
  71498. /**
  71499. * Callback called when the task is successful
  71500. */
  71501. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71502. /**
  71503. * Creates a new CubeTextureAssetTask
  71504. * @param name defines the name of the task
  71505. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71506. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71507. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71508. * @param files defines the explicit list of files (undefined by default)
  71509. */
  71510. constructor(
  71511. /**
  71512. * Defines the name of the task
  71513. */
  71514. name: string,
  71515. /**
  71516. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71517. */
  71518. url: string,
  71519. /**
  71520. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71521. */
  71522. extensions?: string[] | undefined,
  71523. /**
  71524. * Defines if mipmaps should not be generated (default is false)
  71525. */
  71526. noMipmap?: boolean | undefined,
  71527. /**
  71528. * Defines the explicit list of files (undefined by default)
  71529. */
  71530. files?: string[] | undefined);
  71531. /**
  71532. * Execute the current task
  71533. * @param scene defines the scene where you want your assets to be loaded
  71534. * @param onSuccess is a callback called when the task is successfully executed
  71535. * @param onError is a callback called if an error occurs
  71536. */
  71537. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71538. }
  71539. /**
  71540. * Define a task used by AssetsManager to load HDR cube textures
  71541. */
  71542. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71543. /**
  71544. * Defines the name of the task
  71545. */
  71546. name: string;
  71547. /**
  71548. * Defines the location of the file to load
  71549. */
  71550. url: string;
  71551. /**
  71552. * Defines the desired size (the more it increases the longer the generation will be)
  71553. */
  71554. size: number;
  71555. /**
  71556. * Defines if mipmaps should not be generated (default is false)
  71557. */
  71558. noMipmap: boolean;
  71559. /**
  71560. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71561. */
  71562. generateHarmonics: boolean;
  71563. /**
  71564. * 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)
  71565. */
  71566. gammaSpace: boolean;
  71567. /**
  71568. * Internal Use Only
  71569. */
  71570. reserved: boolean;
  71571. /**
  71572. * Gets the loaded texture
  71573. */
  71574. texture: HDRCubeTexture;
  71575. /**
  71576. * Callback called when the task is successful
  71577. */
  71578. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71579. /**
  71580. * Callback called when the task is successful
  71581. */
  71582. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71583. /**
  71584. * Creates a new HDRCubeTextureAssetTask object
  71585. * @param name defines the name of the task
  71586. * @param url defines the location of the file to load
  71587. * @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.
  71588. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71589. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71590. * @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)
  71591. * @param reserved Internal use only
  71592. */
  71593. constructor(
  71594. /**
  71595. * Defines the name of the task
  71596. */
  71597. name: string,
  71598. /**
  71599. * Defines the location of the file to load
  71600. */
  71601. url: string,
  71602. /**
  71603. * Defines the desired size (the more it increases the longer the generation will be)
  71604. */
  71605. size: number,
  71606. /**
  71607. * Defines if mipmaps should not be generated (default is false)
  71608. */
  71609. noMipmap?: boolean,
  71610. /**
  71611. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71612. */
  71613. generateHarmonics?: boolean,
  71614. /**
  71615. * 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)
  71616. */
  71617. gammaSpace?: boolean,
  71618. /**
  71619. * Internal Use Only
  71620. */
  71621. reserved?: boolean);
  71622. /**
  71623. * Execute the current task
  71624. * @param scene defines the scene where you want your assets to be loaded
  71625. * @param onSuccess is a callback called when the task is successfully executed
  71626. * @param onError is a callback called if an error occurs
  71627. */
  71628. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71629. }
  71630. /**
  71631. * Define a task used by AssetsManager to load Equirectangular cube textures
  71632. */
  71633. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71634. /**
  71635. * Defines the name of the task
  71636. */
  71637. name: string;
  71638. /**
  71639. * Defines the location of the file to load
  71640. */
  71641. url: string;
  71642. /**
  71643. * Defines the desired size (the more it increases the longer the generation will be)
  71644. */
  71645. size: number;
  71646. /**
  71647. * Defines if mipmaps should not be generated (default is false)
  71648. */
  71649. noMipmap: boolean;
  71650. /**
  71651. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71652. * but the standard material would require them in Gamma space) (default is true)
  71653. */
  71654. gammaSpace: boolean;
  71655. /**
  71656. * Gets the loaded texture
  71657. */
  71658. texture: EquiRectangularCubeTexture;
  71659. /**
  71660. * Callback called when the task is successful
  71661. */
  71662. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71663. /**
  71664. * Callback called when the task is successful
  71665. */
  71666. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71667. /**
  71668. * Creates a new EquiRectangularCubeTextureAssetTask object
  71669. * @param name defines the name of the task
  71670. * @param url defines the location of the file to load
  71671. * @param size defines the desired size (the more it increases the longer the generation will be)
  71672. * If the size is omitted this implies you are using a preprocessed cubemap.
  71673. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71674. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71675. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71676. * (default is true)
  71677. */
  71678. constructor(
  71679. /**
  71680. * Defines the name of the task
  71681. */
  71682. name: string,
  71683. /**
  71684. * Defines the location of the file to load
  71685. */
  71686. url: string,
  71687. /**
  71688. * Defines the desired size (the more it increases the longer the generation will be)
  71689. */
  71690. size: number,
  71691. /**
  71692. * Defines if mipmaps should not be generated (default is false)
  71693. */
  71694. noMipmap?: boolean,
  71695. /**
  71696. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71697. * but the standard material would require them in Gamma space) (default is true)
  71698. */
  71699. gammaSpace?: boolean);
  71700. /**
  71701. * Execute the current task
  71702. * @param scene defines the scene where you want your assets to be loaded
  71703. * @param onSuccess is a callback called when the task is successfully executed
  71704. * @param onError is a callback called if an error occurs
  71705. */
  71706. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71707. }
  71708. /**
  71709. * This class can be used to easily import assets into a scene
  71710. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71711. */
  71712. export class AssetsManager {
  71713. private _scene;
  71714. private _isLoading;
  71715. protected _tasks: AbstractAssetTask[];
  71716. protected _waitingTasksCount: number;
  71717. protected _totalTasksCount: number;
  71718. /**
  71719. * Callback called when all tasks are processed
  71720. */
  71721. onFinish: (tasks: AbstractAssetTask[]) => void;
  71722. /**
  71723. * Callback called when a task is successful
  71724. */
  71725. onTaskSuccess: (task: AbstractAssetTask) => void;
  71726. /**
  71727. * Callback called when a task had an error
  71728. */
  71729. onTaskError: (task: AbstractAssetTask) => void;
  71730. /**
  71731. * Callback called when a task is done (whatever the result is)
  71732. */
  71733. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71734. /**
  71735. * Observable called when all tasks are processed
  71736. */
  71737. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71738. /**
  71739. * Observable called when a task had an error
  71740. */
  71741. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71742. /**
  71743. * Observable called when all tasks were executed
  71744. */
  71745. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71746. /**
  71747. * Observable called when a task is done (whatever the result is)
  71748. */
  71749. onProgressObservable: Observable<IAssetsProgressEvent>;
  71750. /**
  71751. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71752. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71753. */
  71754. useDefaultLoadingScreen: boolean;
  71755. /**
  71756. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71757. * when all assets have been downloaded.
  71758. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71759. */
  71760. autoHideLoadingUI: boolean;
  71761. /**
  71762. * Creates a new AssetsManager
  71763. * @param scene defines the scene to work on
  71764. */
  71765. constructor(scene: Scene);
  71766. /**
  71767. * Add a MeshAssetTask to the list of active tasks
  71768. * @param taskName defines the name of the new task
  71769. * @param meshesNames defines the name of meshes to load
  71770. * @param rootUrl defines the root url to use to locate files
  71771. * @param sceneFilename defines the filename of the scene file
  71772. * @returns a new MeshAssetTask object
  71773. */
  71774. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71775. /**
  71776. * Add a TextFileAssetTask to the list of active tasks
  71777. * @param taskName defines the name of the new task
  71778. * @param url defines the url of the file to load
  71779. * @returns a new TextFileAssetTask object
  71780. */
  71781. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71782. /**
  71783. * Add a BinaryFileAssetTask to the list of active tasks
  71784. * @param taskName defines the name of the new task
  71785. * @param url defines the url of the file to load
  71786. * @returns a new BinaryFileAssetTask object
  71787. */
  71788. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71789. /**
  71790. * Add a ImageAssetTask to the list of active tasks
  71791. * @param taskName defines the name of the new task
  71792. * @param url defines the url of the file to load
  71793. * @returns a new ImageAssetTask object
  71794. */
  71795. addImageTask(taskName: string, url: string): ImageAssetTask;
  71796. /**
  71797. * Add a TextureAssetTask to the list of active tasks
  71798. * @param taskName defines the name of the new task
  71799. * @param url defines the url of the file to load
  71800. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71801. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71802. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71803. * @returns a new TextureAssetTask object
  71804. */
  71805. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71806. /**
  71807. * Add a CubeTextureAssetTask to the list of active tasks
  71808. * @param taskName defines the name of the new task
  71809. * @param url defines the url of the file to load
  71810. * @param extensions defines the extension to use to load the cube map (can be null)
  71811. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71812. * @param files defines the list of files to load (can be null)
  71813. * @returns a new CubeTextureAssetTask object
  71814. */
  71815. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71816. /**
  71817. *
  71818. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71819. * @param taskName defines the name of the new task
  71820. * @param url defines the url of the file to load
  71821. * @param size defines the size you want for the cubemap (can be null)
  71822. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71823. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71824. * @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)
  71825. * @param reserved Internal use only
  71826. * @returns a new HDRCubeTextureAssetTask object
  71827. */
  71828. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71829. /**
  71830. *
  71831. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71832. * @param taskName defines the name of the new task
  71833. * @param url defines the url of the file to load
  71834. * @param size defines the size you want for the cubemap (can be null)
  71835. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71836. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71837. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71838. * @returns a new EquiRectangularCubeTextureAssetTask object
  71839. */
  71840. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71841. /**
  71842. * Remove a task from the assets manager.
  71843. * @param task the task to remove
  71844. */
  71845. removeTask(task: AbstractAssetTask): void;
  71846. private _decreaseWaitingTasksCount;
  71847. private _runTask;
  71848. /**
  71849. * Reset the AssetsManager and remove all tasks
  71850. * @return the current instance of the AssetsManager
  71851. */
  71852. reset(): AssetsManager;
  71853. /**
  71854. * Start the loading process
  71855. * @return the current instance of the AssetsManager
  71856. */
  71857. load(): AssetsManager;
  71858. /**
  71859. * Start the loading process as an async operation
  71860. * @return a promise returning the list of failed tasks
  71861. */
  71862. loadAsync(): Promise<void>;
  71863. }
  71864. }
  71865. declare module BABYLON {
  71866. /**
  71867. * Wrapper class for promise with external resolve and reject.
  71868. */
  71869. export class Deferred<T> {
  71870. /**
  71871. * The promise associated with this deferred object.
  71872. */
  71873. readonly promise: Promise<T>;
  71874. private _resolve;
  71875. private _reject;
  71876. /**
  71877. * The resolve method of the promise associated with this deferred object.
  71878. */
  71879. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71880. /**
  71881. * The reject method of the promise associated with this deferred object.
  71882. */
  71883. get reject(): (reason?: any) => void;
  71884. /**
  71885. * Constructor for this deferred object.
  71886. */
  71887. constructor();
  71888. }
  71889. }
  71890. declare module BABYLON {
  71891. /**
  71892. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71893. */
  71894. export class MeshExploder {
  71895. private _centerMesh;
  71896. private _meshes;
  71897. private _meshesOrigins;
  71898. private _toCenterVectors;
  71899. private _scaledDirection;
  71900. private _newPosition;
  71901. private _centerPosition;
  71902. /**
  71903. * Explodes meshes from a center mesh.
  71904. * @param meshes The meshes to explode.
  71905. * @param centerMesh The mesh to be center of explosion.
  71906. */
  71907. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71908. private _setCenterMesh;
  71909. /**
  71910. * Get class name
  71911. * @returns "MeshExploder"
  71912. */
  71913. getClassName(): string;
  71914. /**
  71915. * "Exploded meshes"
  71916. * @returns Array of meshes with the centerMesh at index 0.
  71917. */
  71918. getMeshes(): Array<Mesh>;
  71919. /**
  71920. * Explodes meshes giving a specific direction
  71921. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71922. */
  71923. explode(direction?: number): void;
  71924. }
  71925. }
  71926. declare module BABYLON {
  71927. /**
  71928. * Class used to help managing file picking and drag'n'drop
  71929. */
  71930. export class FilesInput {
  71931. /**
  71932. * List of files ready to be loaded
  71933. */
  71934. static get FilesToLoad(): {
  71935. [key: string]: File;
  71936. };
  71937. /**
  71938. * Callback called when a file is processed
  71939. */
  71940. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71941. private _engine;
  71942. private _currentScene;
  71943. private _sceneLoadedCallback;
  71944. private _progressCallback;
  71945. private _additionalRenderLoopLogicCallback;
  71946. private _textureLoadingCallback;
  71947. private _startingProcessingFilesCallback;
  71948. private _onReloadCallback;
  71949. private _errorCallback;
  71950. private _elementToMonitor;
  71951. private _sceneFileToLoad;
  71952. private _filesToLoad;
  71953. /**
  71954. * Creates a new FilesInput
  71955. * @param engine defines the rendering engine
  71956. * @param scene defines the hosting scene
  71957. * @param sceneLoadedCallback callback called when scene is loaded
  71958. * @param progressCallback callback called to track progress
  71959. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71960. * @param textureLoadingCallback callback called when a texture is loading
  71961. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71962. * @param onReloadCallback callback called when a reload is requested
  71963. * @param errorCallback callback call if an error occurs
  71964. */
  71965. 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);
  71966. private _dragEnterHandler;
  71967. private _dragOverHandler;
  71968. private _dropHandler;
  71969. /**
  71970. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71971. * @param elementToMonitor defines the DOM element to track
  71972. */
  71973. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71974. /**
  71975. * Release all associated resources
  71976. */
  71977. dispose(): void;
  71978. private renderFunction;
  71979. private drag;
  71980. private drop;
  71981. private _traverseFolder;
  71982. private _processFiles;
  71983. /**
  71984. * Load files from a drop event
  71985. * @param event defines the drop event to use as source
  71986. */
  71987. loadFiles(event: any): void;
  71988. private _processReload;
  71989. /**
  71990. * Reload the current scene from the loaded files
  71991. */
  71992. reload(): void;
  71993. }
  71994. }
  71995. declare module BABYLON {
  71996. /**
  71997. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71998. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71999. */
  72000. export class SceneOptimization {
  72001. /**
  72002. * Defines the priority of this optimization (0 by default which means first in the list)
  72003. */
  72004. priority: number;
  72005. /**
  72006. * Gets a string describing the action executed by the current optimization
  72007. * @returns description string
  72008. */
  72009. getDescription(): string;
  72010. /**
  72011. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72012. * @param scene defines the current scene where to apply this optimization
  72013. * @param optimizer defines the current optimizer
  72014. * @returns true if everything that can be done was applied
  72015. */
  72016. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72017. /**
  72018. * Creates the SceneOptimization object
  72019. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72020. * @param desc defines the description associated with the optimization
  72021. */
  72022. constructor(
  72023. /**
  72024. * Defines the priority of this optimization (0 by default which means first in the list)
  72025. */
  72026. priority?: number);
  72027. }
  72028. /**
  72029. * Defines an optimization used to reduce the size of render target textures
  72030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72031. */
  72032. export class TextureOptimization extends SceneOptimization {
  72033. /**
  72034. * Defines the priority of this optimization (0 by default which means first in the list)
  72035. */
  72036. priority: number;
  72037. /**
  72038. * 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
  72039. */
  72040. maximumSize: number;
  72041. /**
  72042. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72043. */
  72044. step: number;
  72045. /**
  72046. * Gets a string describing the action executed by the current optimization
  72047. * @returns description string
  72048. */
  72049. getDescription(): string;
  72050. /**
  72051. * Creates the TextureOptimization object
  72052. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72053. * @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
  72054. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72055. */
  72056. constructor(
  72057. /**
  72058. * Defines the priority of this optimization (0 by default which means first in the list)
  72059. */
  72060. priority?: number,
  72061. /**
  72062. * 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
  72063. */
  72064. maximumSize?: number,
  72065. /**
  72066. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72067. */
  72068. step?: number);
  72069. /**
  72070. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72071. * @param scene defines the current scene where to apply this optimization
  72072. * @param optimizer defines the current optimizer
  72073. * @returns true if everything that can be done was applied
  72074. */
  72075. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72076. }
  72077. /**
  72078. * Defines an optimization used to increase or decrease the rendering resolution
  72079. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72080. */
  72081. export class HardwareScalingOptimization extends SceneOptimization {
  72082. /**
  72083. * Defines the priority of this optimization (0 by default which means first in the list)
  72084. */
  72085. priority: number;
  72086. /**
  72087. * Defines the maximum scale to use (2 by default)
  72088. */
  72089. maximumScale: number;
  72090. /**
  72091. * Defines the step to use between two passes (0.5 by default)
  72092. */
  72093. step: number;
  72094. private _currentScale;
  72095. private _directionOffset;
  72096. /**
  72097. * Gets a string describing the action executed by the current optimization
  72098. * @return description string
  72099. */
  72100. getDescription(): string;
  72101. /**
  72102. * Creates the HardwareScalingOptimization object
  72103. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72104. * @param maximumScale defines the maximum scale to use (2 by default)
  72105. * @param step defines the step to use between two passes (0.5 by default)
  72106. */
  72107. constructor(
  72108. /**
  72109. * Defines the priority of this optimization (0 by default which means first in the list)
  72110. */
  72111. priority?: number,
  72112. /**
  72113. * Defines the maximum scale to use (2 by default)
  72114. */
  72115. maximumScale?: number,
  72116. /**
  72117. * Defines the step to use between two passes (0.5 by default)
  72118. */
  72119. step?: number);
  72120. /**
  72121. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72122. * @param scene defines the current scene where to apply this optimization
  72123. * @param optimizer defines the current optimizer
  72124. * @returns true if everything that can be done was applied
  72125. */
  72126. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72127. }
  72128. /**
  72129. * Defines an optimization used to remove shadows
  72130. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72131. */
  72132. export class ShadowsOptimization extends SceneOptimization {
  72133. /**
  72134. * Gets a string describing the action executed by the current optimization
  72135. * @return description string
  72136. */
  72137. getDescription(): string;
  72138. /**
  72139. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72140. * @param scene defines the current scene where to apply this optimization
  72141. * @param optimizer defines the current optimizer
  72142. * @returns true if everything that can be done was applied
  72143. */
  72144. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72145. }
  72146. /**
  72147. * Defines an optimization used to turn post-processes off
  72148. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72149. */
  72150. export class PostProcessesOptimization extends SceneOptimization {
  72151. /**
  72152. * Gets a string describing the action executed by the current optimization
  72153. * @return description string
  72154. */
  72155. getDescription(): string;
  72156. /**
  72157. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72158. * @param scene defines the current scene where to apply this optimization
  72159. * @param optimizer defines the current optimizer
  72160. * @returns true if everything that can be done was applied
  72161. */
  72162. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72163. }
  72164. /**
  72165. * Defines an optimization used to turn lens flares off
  72166. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72167. */
  72168. export class LensFlaresOptimization extends SceneOptimization {
  72169. /**
  72170. * Gets a string describing the action executed by the current optimization
  72171. * @return description string
  72172. */
  72173. getDescription(): string;
  72174. /**
  72175. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72176. * @param scene defines the current scene where to apply this optimization
  72177. * @param optimizer defines the current optimizer
  72178. * @returns true if everything that can be done was applied
  72179. */
  72180. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72181. }
  72182. /**
  72183. * Defines an optimization based on user defined callback.
  72184. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72185. */
  72186. export class CustomOptimization extends SceneOptimization {
  72187. /**
  72188. * Callback called to apply the custom optimization.
  72189. */
  72190. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72191. /**
  72192. * Callback called to get custom description
  72193. */
  72194. onGetDescription: () => string;
  72195. /**
  72196. * Gets a string describing the action executed by the current optimization
  72197. * @returns description string
  72198. */
  72199. getDescription(): string;
  72200. /**
  72201. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72202. * @param scene defines the current scene where to apply this optimization
  72203. * @param optimizer defines the current optimizer
  72204. * @returns true if everything that can be done was applied
  72205. */
  72206. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72207. }
  72208. /**
  72209. * Defines an optimization used to turn particles off
  72210. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72211. */
  72212. export class ParticlesOptimization extends SceneOptimization {
  72213. /**
  72214. * Gets a string describing the action executed by the current optimization
  72215. * @return description string
  72216. */
  72217. getDescription(): string;
  72218. /**
  72219. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72220. * @param scene defines the current scene where to apply this optimization
  72221. * @param optimizer defines the current optimizer
  72222. * @returns true if everything that can be done was applied
  72223. */
  72224. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72225. }
  72226. /**
  72227. * Defines an optimization used to turn render targets off
  72228. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72229. */
  72230. export class RenderTargetsOptimization extends SceneOptimization {
  72231. /**
  72232. * Gets a string describing the action executed by the current optimization
  72233. * @return description string
  72234. */
  72235. getDescription(): string;
  72236. /**
  72237. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72238. * @param scene defines the current scene where to apply this optimization
  72239. * @param optimizer defines the current optimizer
  72240. * @returns true if everything that can be done was applied
  72241. */
  72242. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72243. }
  72244. /**
  72245. * Defines an optimization used to merge meshes with compatible materials
  72246. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72247. */
  72248. export class MergeMeshesOptimization extends SceneOptimization {
  72249. private static _UpdateSelectionTree;
  72250. /**
  72251. * Gets or sets a boolean which defines if optimization octree has to be updated
  72252. */
  72253. static get UpdateSelectionTree(): boolean;
  72254. /**
  72255. * Gets or sets a boolean which defines if optimization octree has to be updated
  72256. */
  72257. static set UpdateSelectionTree(value: boolean);
  72258. /**
  72259. * Gets a string describing the action executed by the current optimization
  72260. * @return description string
  72261. */
  72262. getDescription(): string;
  72263. private _canBeMerged;
  72264. /**
  72265. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72266. * @param scene defines the current scene where to apply this optimization
  72267. * @param optimizer defines the current optimizer
  72268. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72269. * @returns true if everything that can be done was applied
  72270. */
  72271. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72272. }
  72273. /**
  72274. * Defines a list of options used by SceneOptimizer
  72275. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72276. */
  72277. export class SceneOptimizerOptions {
  72278. /**
  72279. * Defines the target frame rate to reach (60 by default)
  72280. */
  72281. targetFrameRate: number;
  72282. /**
  72283. * Defines the interval between two checkes (2000ms by default)
  72284. */
  72285. trackerDuration: number;
  72286. /**
  72287. * Gets the list of optimizations to apply
  72288. */
  72289. optimizations: SceneOptimization[];
  72290. /**
  72291. * Creates a new list of options used by SceneOptimizer
  72292. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72293. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72294. */
  72295. constructor(
  72296. /**
  72297. * Defines the target frame rate to reach (60 by default)
  72298. */
  72299. targetFrameRate?: number,
  72300. /**
  72301. * Defines the interval between two checkes (2000ms by default)
  72302. */
  72303. trackerDuration?: number);
  72304. /**
  72305. * Add a new optimization
  72306. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72307. * @returns the current SceneOptimizerOptions
  72308. */
  72309. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72310. /**
  72311. * Add a new custom optimization
  72312. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72313. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72314. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72315. * @returns the current SceneOptimizerOptions
  72316. */
  72317. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72318. /**
  72319. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72320. * @param targetFrameRate defines the target frame rate (60 by default)
  72321. * @returns a SceneOptimizerOptions object
  72322. */
  72323. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72324. /**
  72325. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72326. * @param targetFrameRate defines the target frame rate (60 by default)
  72327. * @returns a SceneOptimizerOptions object
  72328. */
  72329. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72330. /**
  72331. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72332. * @param targetFrameRate defines the target frame rate (60 by default)
  72333. * @returns a SceneOptimizerOptions object
  72334. */
  72335. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72336. }
  72337. /**
  72338. * Class used to run optimizations in order to reach a target frame rate
  72339. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72340. */
  72341. export class SceneOptimizer implements IDisposable {
  72342. private _isRunning;
  72343. private _options;
  72344. private _scene;
  72345. private _currentPriorityLevel;
  72346. private _targetFrameRate;
  72347. private _trackerDuration;
  72348. private _currentFrameRate;
  72349. private _sceneDisposeObserver;
  72350. private _improvementMode;
  72351. /**
  72352. * Defines an observable called when the optimizer reaches the target frame rate
  72353. */
  72354. onSuccessObservable: Observable<SceneOptimizer>;
  72355. /**
  72356. * Defines an observable called when the optimizer enables an optimization
  72357. */
  72358. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72359. /**
  72360. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72361. */
  72362. onFailureObservable: Observable<SceneOptimizer>;
  72363. /**
  72364. * Gets a boolean indicating if the optimizer is in improvement mode
  72365. */
  72366. get isInImprovementMode(): boolean;
  72367. /**
  72368. * Gets the current priority level (0 at start)
  72369. */
  72370. get currentPriorityLevel(): number;
  72371. /**
  72372. * Gets the current frame rate checked by the SceneOptimizer
  72373. */
  72374. get currentFrameRate(): number;
  72375. /**
  72376. * Gets or sets the current target frame rate (60 by default)
  72377. */
  72378. get targetFrameRate(): number;
  72379. /**
  72380. * Gets or sets the current target frame rate (60 by default)
  72381. */
  72382. set targetFrameRate(value: number);
  72383. /**
  72384. * Gets or sets the current interval between two checks (every 2000ms by default)
  72385. */
  72386. get trackerDuration(): number;
  72387. /**
  72388. * Gets or sets the current interval between two checks (every 2000ms by default)
  72389. */
  72390. set trackerDuration(value: number);
  72391. /**
  72392. * Gets the list of active optimizations
  72393. */
  72394. get optimizations(): SceneOptimization[];
  72395. /**
  72396. * Creates a new SceneOptimizer
  72397. * @param scene defines the scene to work on
  72398. * @param options defines the options to use with the SceneOptimizer
  72399. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72400. * @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)
  72401. */
  72402. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72403. /**
  72404. * Stops the current optimizer
  72405. */
  72406. stop(): void;
  72407. /**
  72408. * Reset the optimizer to initial step (current priority level = 0)
  72409. */
  72410. reset(): void;
  72411. /**
  72412. * Start the optimizer. By default it will try to reach a specific framerate
  72413. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72414. */
  72415. start(): void;
  72416. private _checkCurrentState;
  72417. /**
  72418. * Release all resources
  72419. */
  72420. dispose(): void;
  72421. /**
  72422. * Helper function to create a SceneOptimizer with one single line of code
  72423. * @param scene defines the scene to work on
  72424. * @param options defines the options to use with the SceneOptimizer
  72425. * @param onSuccess defines a callback to call on success
  72426. * @param onFailure defines a callback to call on failure
  72427. * @returns the new SceneOptimizer object
  72428. */
  72429. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72430. }
  72431. }
  72432. declare module BABYLON {
  72433. /**
  72434. * Class used to serialize a scene into a string
  72435. */
  72436. export class SceneSerializer {
  72437. /**
  72438. * Clear cache used by a previous serialization
  72439. */
  72440. static ClearCache(): void;
  72441. /**
  72442. * Serialize a scene into a JSON compatible object
  72443. * @param scene defines the scene to serialize
  72444. * @returns a JSON compatible object
  72445. */
  72446. static Serialize(scene: Scene): any;
  72447. /**
  72448. * Serialize a mesh into a JSON compatible object
  72449. * @param toSerialize defines the mesh to serialize
  72450. * @param withParents defines if parents must be serialized as well
  72451. * @param withChildren defines if children must be serialized as well
  72452. * @returns a JSON compatible object
  72453. */
  72454. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72455. }
  72456. }
  72457. declare module BABYLON {
  72458. /**
  72459. * Class used to host texture specific utilities
  72460. */
  72461. export class TextureTools {
  72462. /**
  72463. * Uses the GPU to create a copy texture rescaled at a given size
  72464. * @param texture Texture to copy from
  72465. * @param width defines the desired width
  72466. * @param height defines the desired height
  72467. * @param useBilinearMode defines if bilinear mode has to be used
  72468. * @return the generated texture
  72469. */
  72470. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72471. }
  72472. }
  72473. declare module BABYLON {
  72474. /**
  72475. * This represents the different options available for the video capture.
  72476. */
  72477. export interface VideoRecorderOptions {
  72478. /** Defines the mime type of the video. */
  72479. mimeType: string;
  72480. /** Defines the FPS the video should be recorded at. */
  72481. fps: number;
  72482. /** Defines the chunk size for the recording data. */
  72483. recordChunckSize: number;
  72484. /** The audio tracks to attach to the recording. */
  72485. audioTracks?: MediaStreamTrack[];
  72486. }
  72487. /**
  72488. * This can help with recording videos from BabylonJS.
  72489. * This is based on the available WebRTC functionalities of the browser.
  72490. *
  72491. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72492. */
  72493. export class VideoRecorder {
  72494. private static readonly _defaultOptions;
  72495. /**
  72496. * Returns whether or not the VideoRecorder is available in your browser.
  72497. * @param engine Defines the Babylon Engine.
  72498. * @returns true if supported otherwise false.
  72499. */
  72500. static IsSupported(engine: Engine): boolean;
  72501. private readonly _options;
  72502. private _canvas;
  72503. private _mediaRecorder;
  72504. private _recordedChunks;
  72505. private _fileName;
  72506. private _resolve;
  72507. private _reject;
  72508. /**
  72509. * True when a recording is already in progress.
  72510. */
  72511. get isRecording(): boolean;
  72512. /**
  72513. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72514. * @param engine Defines the BabylonJS Engine you wish to record.
  72515. * @param options Defines options that can be used to customize the capture.
  72516. */
  72517. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72518. /**
  72519. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72520. */
  72521. stopRecording(): void;
  72522. /**
  72523. * Starts recording the canvas for a max duration specified in parameters.
  72524. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72525. * If null no automatic download will start and you can rely on the promise to get the data back.
  72526. * @param maxDuration Defines the maximum recording time in seconds.
  72527. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72528. * @return A promise callback at the end of the recording with the video data in Blob.
  72529. */
  72530. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72531. /**
  72532. * Releases internal resources used during the recording.
  72533. */
  72534. dispose(): void;
  72535. private _handleDataAvailable;
  72536. private _handleError;
  72537. private _handleStop;
  72538. }
  72539. }
  72540. declare module BABYLON {
  72541. /**
  72542. * Class containing a set of static utilities functions for screenshots
  72543. */
  72544. export class ScreenshotTools {
  72545. /**
  72546. * Captures a screenshot of the current rendering
  72547. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72548. * @param engine defines the rendering engine
  72549. * @param camera defines the source camera
  72550. * @param size This parameter can be set to a single number or to an object with the
  72551. * following (optional) properties: precision, width, height. If a single number is passed,
  72552. * it will be used for both width and height. If an object is passed, the screenshot size
  72553. * will be derived from the parameters. The precision property is a multiplier allowing
  72554. * rendering at a higher or lower resolution
  72555. * @param successCallback defines the callback receives a single parameter which contains the
  72556. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72557. * src parameter of an <img> to display it
  72558. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72559. * Check your browser for supported MIME types
  72560. */
  72561. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72562. /**
  72563. * Captures a screenshot of the current rendering
  72564. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72565. * @param engine defines the rendering engine
  72566. * @param camera defines the source camera
  72567. * @param size This parameter can be set to a single number or to an object with the
  72568. * following (optional) properties: precision, width, height. If a single number is passed,
  72569. * it will be used for both width and height. If an object is passed, the screenshot size
  72570. * will be derived from the parameters. The precision property is a multiplier allowing
  72571. * rendering at a higher or lower resolution
  72572. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72573. * Check your browser for supported MIME types
  72574. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72575. * to the src parameter of an <img> to display it
  72576. */
  72577. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72578. /**
  72579. * Generates an image screenshot from the specified camera.
  72580. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72581. * @param engine The engine to use for rendering
  72582. * @param camera The camera to use for rendering
  72583. * @param size This parameter can be set to a single number or to an object with the
  72584. * following (optional) properties: precision, width, height. If a single number is passed,
  72585. * it will be used for both width and height. If an object is passed, the screenshot size
  72586. * will be derived from the parameters. The precision property is a multiplier allowing
  72587. * rendering at a higher or lower resolution
  72588. * @param successCallback The callback receives a single parameter which contains the
  72589. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72590. * src parameter of an <img> to display it
  72591. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72592. * Check your browser for supported MIME types
  72593. * @param samples Texture samples (default: 1)
  72594. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72595. * @param fileName A name for for the downloaded file.
  72596. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72597. */
  72598. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72599. /**
  72600. * Generates an image screenshot from the specified camera.
  72601. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72602. * @param engine The engine to use for rendering
  72603. * @param camera The camera to use for rendering
  72604. * @param size This parameter can be set to a single number or to an object with the
  72605. * following (optional) properties: precision, width, height. If a single number is passed,
  72606. * it will be used for both width and height. If an object is passed, the screenshot size
  72607. * will be derived from the parameters. The precision property is a multiplier allowing
  72608. * rendering at a higher or lower resolution
  72609. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72610. * Check your browser for supported MIME types
  72611. * @param samples Texture samples (default: 1)
  72612. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72613. * @param fileName A name for for the downloaded file.
  72614. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72615. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72616. * to the src parameter of an <img> to display it
  72617. */
  72618. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72619. /**
  72620. * Gets height and width for screenshot size
  72621. * @private
  72622. */
  72623. private static _getScreenshotSize;
  72624. }
  72625. }
  72626. declare module BABYLON {
  72627. /**
  72628. * Interface for a data buffer
  72629. */
  72630. export interface IDataBuffer {
  72631. /**
  72632. * Reads bytes from the data buffer.
  72633. * @param byteOffset The byte offset to read
  72634. * @param byteLength The byte length to read
  72635. * @returns A promise that resolves when the bytes are read
  72636. */
  72637. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72638. /**
  72639. * The byte length of the buffer.
  72640. */
  72641. readonly byteLength: number;
  72642. }
  72643. /**
  72644. * Utility class for reading from a data buffer
  72645. */
  72646. export class DataReader {
  72647. /**
  72648. * The data buffer associated with this data reader.
  72649. */
  72650. readonly buffer: IDataBuffer;
  72651. /**
  72652. * The current byte offset from the beginning of the data buffer.
  72653. */
  72654. byteOffset: number;
  72655. private _dataView;
  72656. private _dataByteOffset;
  72657. /**
  72658. * Constructor
  72659. * @param buffer The buffer to read
  72660. */
  72661. constructor(buffer: IDataBuffer);
  72662. /**
  72663. * Loads the given byte length.
  72664. * @param byteLength The byte length to load
  72665. * @returns A promise that resolves when the load is complete
  72666. */
  72667. loadAsync(byteLength: number): Promise<void>;
  72668. /**
  72669. * Read a unsigned 32-bit integer from the currently loaded data range.
  72670. * @returns The 32-bit integer read
  72671. */
  72672. readUint32(): number;
  72673. /**
  72674. * Read a byte array from the currently loaded data range.
  72675. * @param byteLength The byte length to read
  72676. * @returns The byte array read
  72677. */
  72678. readUint8Array(byteLength: number): Uint8Array;
  72679. /**
  72680. * Read a string from the currently loaded data range.
  72681. * @param byteLength The byte length to read
  72682. * @returns The string read
  72683. */
  72684. readString(byteLength: number): string;
  72685. /**
  72686. * Skips the given byte length the currently loaded data range.
  72687. * @param byteLength The byte length to skip
  72688. */
  72689. skipBytes(byteLength: number): void;
  72690. }
  72691. }
  72692. declare module BABYLON {
  72693. /**
  72694. * Class for storing data to local storage if available or in-memory storage otherwise
  72695. */
  72696. export class DataStorage {
  72697. private static _Storage;
  72698. private static _GetStorage;
  72699. /**
  72700. * Reads a string from the data storage
  72701. * @param key The key to read
  72702. * @param defaultValue The value if the key doesn't exist
  72703. * @returns The string value
  72704. */
  72705. static ReadString(key: string, defaultValue: string): string;
  72706. /**
  72707. * Writes a string to the data storage
  72708. * @param key The key to write
  72709. * @param value The value to write
  72710. */
  72711. static WriteString(key: string, value: string): void;
  72712. /**
  72713. * Reads a boolean from the data storage
  72714. * @param key The key to read
  72715. * @param defaultValue The value if the key doesn't exist
  72716. * @returns The boolean value
  72717. */
  72718. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72719. /**
  72720. * Writes a boolean to the data storage
  72721. * @param key The key to write
  72722. * @param value The value to write
  72723. */
  72724. static WriteBoolean(key: string, value: boolean): void;
  72725. /**
  72726. * Reads a number from the data storage
  72727. * @param key The key to read
  72728. * @param defaultValue The value if the key doesn't exist
  72729. * @returns The number value
  72730. */
  72731. static ReadNumber(key: string, defaultValue: number): number;
  72732. /**
  72733. * Writes a number to the data storage
  72734. * @param key The key to write
  72735. * @param value The value to write
  72736. */
  72737. static WriteNumber(key: string, value: number): void;
  72738. }
  72739. }
  72740. declare module BABYLON {
  72741. /**
  72742. * An interface for all Hit test features
  72743. */
  72744. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72745. /**
  72746. * Triggered when new babylon (transformed) hit test results are available
  72747. */
  72748. onHitTestResultObservable: Observable<T[]>;
  72749. }
  72750. /**
  72751. * Options used for hit testing
  72752. */
  72753. export interface IWebXRLegacyHitTestOptions {
  72754. /**
  72755. * Only test when user interacted with the scene. Default - hit test every frame
  72756. */
  72757. testOnPointerDownOnly?: boolean;
  72758. /**
  72759. * The node to use to transform the local results to world coordinates
  72760. */
  72761. worldParentNode?: TransformNode;
  72762. }
  72763. /**
  72764. * Interface defining the babylon result of raycasting/hit-test
  72765. */
  72766. export interface IWebXRLegacyHitResult {
  72767. /**
  72768. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72769. */
  72770. transformationMatrix: Matrix;
  72771. /**
  72772. * The native hit test result
  72773. */
  72774. xrHitResult: XRHitResult | XRHitTestResult;
  72775. }
  72776. /**
  72777. * The currently-working hit-test module.
  72778. * Hit test (or Ray-casting) is used to interact with the real world.
  72779. * For further information read here - https://github.com/immersive-web/hit-test
  72780. */
  72781. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72782. /**
  72783. * options to use when constructing this feature
  72784. */
  72785. readonly options: IWebXRLegacyHitTestOptions;
  72786. private _direction;
  72787. private _mat;
  72788. private _onSelectEnabled;
  72789. private _origin;
  72790. /**
  72791. * The module's name
  72792. */
  72793. static readonly Name: string;
  72794. /**
  72795. * The (Babylon) version of this module.
  72796. * This is an integer representing the implementation version.
  72797. * This number does not correspond to the WebXR specs version
  72798. */
  72799. static readonly Version: number;
  72800. /**
  72801. * Populated with the last native XR Hit Results
  72802. */
  72803. lastNativeXRHitResults: XRHitResult[];
  72804. /**
  72805. * Triggered when new babylon (transformed) hit test results are available
  72806. */
  72807. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72808. /**
  72809. * Creates a new instance of the (legacy version) hit test feature
  72810. * @param _xrSessionManager an instance of WebXRSessionManager
  72811. * @param options options to use when constructing this feature
  72812. */
  72813. constructor(_xrSessionManager: WebXRSessionManager,
  72814. /**
  72815. * options to use when constructing this feature
  72816. */
  72817. options?: IWebXRLegacyHitTestOptions);
  72818. /**
  72819. * execute a hit test with an XR Ray
  72820. *
  72821. * @param xrSession a native xrSession that will execute this hit test
  72822. * @param xrRay the ray (position and direction) to use for ray-casting
  72823. * @param referenceSpace native XR reference space to use for the hit-test
  72824. * @param filter filter function that will filter the results
  72825. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72826. */
  72827. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72828. /**
  72829. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72830. * @param event the (select) event to use to select with
  72831. * @param referenceSpace the reference space to use for this hit test
  72832. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72833. */
  72834. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72835. /**
  72836. * attach this feature
  72837. * Will usually be called by the features manager
  72838. *
  72839. * @returns true if successful.
  72840. */
  72841. attach(): boolean;
  72842. /**
  72843. * detach this feature.
  72844. * Will usually be called by the features manager
  72845. *
  72846. * @returns true if successful.
  72847. */
  72848. detach(): boolean;
  72849. /**
  72850. * Dispose this feature and all of the resources attached
  72851. */
  72852. dispose(): void;
  72853. protected _onXRFrame(frame: XRFrame): void;
  72854. private _onHitTestResults;
  72855. private _onSelect;
  72856. }
  72857. }
  72858. declare module BABYLON {
  72859. /**
  72860. * Options used for hit testing (version 2)
  72861. */
  72862. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72863. /**
  72864. * Do not create a permanent hit test. Will usually be used when only
  72865. * transient inputs are needed.
  72866. */
  72867. disablePermanentHitTest?: boolean;
  72868. /**
  72869. * Enable transient (for example touch-based) hit test inspections
  72870. */
  72871. enableTransientHitTest?: boolean;
  72872. /**
  72873. * Offset ray for the permanent hit test
  72874. */
  72875. offsetRay?: Vector3;
  72876. /**
  72877. * Offset ray for the transient hit test
  72878. */
  72879. transientOffsetRay?: Vector3;
  72880. /**
  72881. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72882. */
  72883. useReferenceSpace?: boolean;
  72884. }
  72885. /**
  72886. * Interface defining the babylon result of hit-test
  72887. */
  72888. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72889. /**
  72890. * The input source that generated this hit test (if transient)
  72891. */
  72892. inputSource?: XRInputSource;
  72893. /**
  72894. * Is this a transient hit test
  72895. */
  72896. isTransient?: boolean;
  72897. /**
  72898. * Position of the hit test result
  72899. */
  72900. position: Vector3;
  72901. /**
  72902. * Rotation of the hit test result
  72903. */
  72904. rotationQuaternion: Quaternion;
  72905. /**
  72906. * The native hit test result
  72907. */
  72908. xrHitResult: XRHitTestResult;
  72909. }
  72910. /**
  72911. * The currently-working hit-test module.
  72912. * Hit test (or Ray-casting) is used to interact with the real world.
  72913. * For further information read here - https://github.com/immersive-web/hit-test
  72914. *
  72915. * Tested on chrome (mobile) 80.
  72916. */
  72917. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72918. /**
  72919. * options to use when constructing this feature
  72920. */
  72921. readonly options: IWebXRHitTestOptions;
  72922. private _tmpMat;
  72923. private _tmpPos;
  72924. private _tmpQuat;
  72925. private _transientXrHitTestSource;
  72926. private _xrHitTestSource;
  72927. private initHitTestSource;
  72928. /**
  72929. * The module's name
  72930. */
  72931. static readonly Name: string;
  72932. /**
  72933. * The (Babylon) version of this module.
  72934. * This is an integer representing the implementation version.
  72935. * This number does not correspond to the WebXR specs version
  72936. */
  72937. static readonly Version: number;
  72938. /**
  72939. * When set to true, each hit test will have its own position/rotation objects
  72940. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72941. * the developers will clone them or copy them as they see fit.
  72942. */
  72943. autoCloneTransformation: boolean;
  72944. /**
  72945. * Triggered when new babylon (transformed) hit test results are available
  72946. */
  72947. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72948. /**
  72949. * Use this to temporarily pause hit test checks.
  72950. */
  72951. paused: boolean;
  72952. /**
  72953. * Creates a new instance of the hit test feature
  72954. * @param _xrSessionManager an instance of WebXRSessionManager
  72955. * @param options options to use when constructing this feature
  72956. */
  72957. constructor(_xrSessionManager: WebXRSessionManager,
  72958. /**
  72959. * options to use when constructing this feature
  72960. */
  72961. options?: IWebXRHitTestOptions);
  72962. /**
  72963. * attach this feature
  72964. * Will usually be called by the features manager
  72965. *
  72966. * @returns true if successful.
  72967. */
  72968. attach(): boolean;
  72969. /**
  72970. * detach this feature.
  72971. * Will usually be called by the features manager
  72972. *
  72973. * @returns true if successful.
  72974. */
  72975. detach(): boolean;
  72976. /**
  72977. * Dispose this feature and all of the resources attached
  72978. */
  72979. dispose(): void;
  72980. protected _onXRFrame(frame: XRFrame): void;
  72981. private _processWebXRHitTestResult;
  72982. }
  72983. }
  72984. declare module BABYLON {
  72985. /**
  72986. * Configuration options of the anchor system
  72987. */
  72988. export interface IWebXRAnchorSystemOptions {
  72989. /**
  72990. * a node that will be used to convert local to world coordinates
  72991. */
  72992. worldParentNode?: TransformNode;
  72993. /**
  72994. * If set to true a reference of the created anchors will be kept until the next session starts
  72995. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72996. */
  72997. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72998. }
  72999. /**
  73000. * A babylon container for an XR Anchor
  73001. */
  73002. export interface IWebXRAnchor {
  73003. /**
  73004. * A babylon-assigned ID for this anchor
  73005. */
  73006. id: number;
  73007. /**
  73008. * Transformation matrix to apply to an object attached to this anchor
  73009. */
  73010. transformationMatrix: Matrix;
  73011. /**
  73012. * The native anchor object
  73013. */
  73014. xrAnchor: XRAnchor;
  73015. /**
  73016. * if defined, this object will be constantly updated by the anchor's position and rotation
  73017. */
  73018. attachedNode?: TransformNode;
  73019. }
  73020. /**
  73021. * An implementation of the anchor system for WebXR.
  73022. * For further information see https://github.com/immersive-web/anchors/
  73023. */
  73024. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73025. private _options;
  73026. private _lastFrameDetected;
  73027. private _trackedAnchors;
  73028. private _referenceSpaceForFrameAnchors;
  73029. private _futureAnchors;
  73030. /**
  73031. * The module's name
  73032. */
  73033. static readonly Name: string;
  73034. /**
  73035. * The (Babylon) version of this module.
  73036. * This is an integer representing the implementation version.
  73037. * This number does not correspond to the WebXR specs version
  73038. */
  73039. static readonly Version: number;
  73040. /**
  73041. * Observers registered here will be executed when a new anchor was added to the session
  73042. */
  73043. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73044. /**
  73045. * Observers registered here will be executed when an anchor was removed from the session
  73046. */
  73047. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73048. /**
  73049. * Observers registered here will be executed when an existing anchor updates
  73050. * This can execute N times every frame
  73051. */
  73052. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73053. /**
  73054. * Set the reference space to use for anchor creation, when not using a hit test.
  73055. * Will default to the session's reference space if not defined
  73056. */
  73057. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  73058. /**
  73059. * constructs a new anchor system
  73060. * @param _xrSessionManager an instance of WebXRSessionManager
  73061. * @param _options configuration object for this feature
  73062. */
  73063. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73064. private _tmpVector;
  73065. private _tmpQuaternion;
  73066. private _populateTmpTransformation;
  73067. /**
  73068. * Create a new anchor point using a hit test result at a specific point in the scene
  73069. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73070. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73071. *
  73072. * @param hitTestResult The hit test result to use for this anchor creation
  73073. * @param position an optional position offset for this anchor
  73074. * @param rotationQuaternion an optional rotation offset for this anchor
  73075. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73076. */
  73077. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  73078. /**
  73079. * Add a new anchor at a specific position and rotation
  73080. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  73081. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  73082. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73083. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73084. *
  73085. * @param position the position in which to add an anchor
  73086. * @param rotationQuaternion an optional rotation for the anchor transformation
  73087. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  73088. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73089. */
  73090. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  73091. /**
  73092. * detach this feature.
  73093. * Will usually be called by the features manager
  73094. *
  73095. * @returns true if successful.
  73096. */
  73097. detach(): boolean;
  73098. /**
  73099. * Dispose this feature and all of the resources attached
  73100. */
  73101. dispose(): void;
  73102. protected _onXRFrame(frame: XRFrame): void;
  73103. /**
  73104. * avoiding using Array.find for global support.
  73105. * @param xrAnchor the plane to find in the array
  73106. */
  73107. private _findIndexInAnchorArray;
  73108. private _updateAnchorWithXRFrame;
  73109. private _createAnchorAtTransformation;
  73110. }
  73111. }
  73112. declare module BABYLON {
  73113. /**
  73114. * Options used in the plane detector module
  73115. */
  73116. export interface IWebXRPlaneDetectorOptions {
  73117. /**
  73118. * The node to use to transform the local results to world coordinates
  73119. */
  73120. worldParentNode?: TransformNode;
  73121. /**
  73122. * If set to true a reference of the created planes will be kept until the next session starts
  73123. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  73124. */
  73125. doNotRemovePlanesOnSessionEnded?: boolean;
  73126. }
  73127. /**
  73128. * A babylon interface for a WebXR plane.
  73129. * A Plane is actually a polygon, built from N points in space
  73130. *
  73131. * Supported in chrome 79, not supported in canary 81 ATM
  73132. */
  73133. export interface IWebXRPlane {
  73134. /**
  73135. * a babylon-assigned ID for this polygon
  73136. */
  73137. id: number;
  73138. /**
  73139. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73140. */
  73141. polygonDefinition: Array<Vector3>;
  73142. /**
  73143. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73144. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73145. */
  73146. transformationMatrix: Matrix;
  73147. /**
  73148. * the native xr-plane object
  73149. */
  73150. xrPlane: XRPlane;
  73151. }
  73152. /**
  73153. * The plane detector is used to detect planes in the real world when in AR
  73154. * For more information see https://github.com/immersive-web/real-world-geometry/
  73155. */
  73156. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73157. private _options;
  73158. private _detectedPlanes;
  73159. private _enabled;
  73160. private _lastFrameDetected;
  73161. /**
  73162. * The module's name
  73163. */
  73164. static readonly Name: string;
  73165. /**
  73166. * The (Babylon) version of this module.
  73167. * This is an integer representing the implementation version.
  73168. * This number does not correspond to the WebXR specs version
  73169. */
  73170. static readonly Version: number;
  73171. /**
  73172. * Observers registered here will be executed when a new plane was added to the session
  73173. */
  73174. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73175. /**
  73176. * Observers registered here will be executed when a plane is no longer detected in the session
  73177. */
  73178. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73179. /**
  73180. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73181. * This can execute N times every frame
  73182. */
  73183. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73184. /**
  73185. * construct a new Plane Detector
  73186. * @param _xrSessionManager an instance of xr Session manager
  73187. * @param _options configuration to use when constructing this feature
  73188. */
  73189. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73190. /**
  73191. * detach this feature.
  73192. * Will usually be called by the features manager
  73193. *
  73194. * @returns true if successful.
  73195. */
  73196. detach(): boolean;
  73197. /**
  73198. * Dispose this feature and all of the resources attached
  73199. */
  73200. dispose(): void;
  73201. protected _onXRFrame(frame: XRFrame): void;
  73202. private _init;
  73203. private _updatePlaneWithXRPlane;
  73204. /**
  73205. * avoiding using Array.find for global support.
  73206. * @param xrPlane the plane to find in the array
  73207. */
  73208. private findIndexInPlaneArray;
  73209. }
  73210. }
  73211. declare module BABYLON {
  73212. /**
  73213. * Options interface for the background remover plugin
  73214. */
  73215. export interface IWebXRBackgroundRemoverOptions {
  73216. /**
  73217. * Further background meshes to disable when entering AR
  73218. */
  73219. backgroundMeshes?: AbstractMesh[];
  73220. /**
  73221. * flags to configure the removal of the environment helper.
  73222. * If not set, the entire background will be removed. If set, flags should be set as well.
  73223. */
  73224. environmentHelperRemovalFlags?: {
  73225. /**
  73226. * Should the skybox be removed (default false)
  73227. */
  73228. skyBox?: boolean;
  73229. /**
  73230. * Should the ground be removed (default false)
  73231. */
  73232. ground?: boolean;
  73233. };
  73234. /**
  73235. * don't disable the environment helper
  73236. */
  73237. ignoreEnvironmentHelper?: boolean;
  73238. }
  73239. /**
  73240. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73241. */
  73242. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73243. /**
  73244. * read-only options to be used in this module
  73245. */
  73246. readonly options: IWebXRBackgroundRemoverOptions;
  73247. /**
  73248. * The module's name
  73249. */
  73250. static readonly Name: string;
  73251. /**
  73252. * The (Babylon) version of this module.
  73253. * This is an integer representing the implementation version.
  73254. * This number does not correspond to the WebXR specs version
  73255. */
  73256. static readonly Version: number;
  73257. /**
  73258. * registered observers will be triggered when the background state changes
  73259. */
  73260. onBackgroundStateChangedObservable: Observable<boolean>;
  73261. /**
  73262. * constructs a new background remover module
  73263. * @param _xrSessionManager the session manager for this module
  73264. * @param options read-only options to be used in this module
  73265. */
  73266. constructor(_xrSessionManager: WebXRSessionManager,
  73267. /**
  73268. * read-only options to be used in this module
  73269. */
  73270. options?: IWebXRBackgroundRemoverOptions);
  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. * Dispose this feature and all of the resources attached
  73287. */
  73288. dispose(): void;
  73289. protected _onXRFrame(_xrFrame: XRFrame): void;
  73290. private _setBackgroundState;
  73291. }
  73292. }
  73293. declare module BABYLON {
  73294. /**
  73295. * Options for the controller physics feature
  73296. */
  73297. export class IWebXRControllerPhysicsOptions {
  73298. /**
  73299. * Should the headset get its own impostor
  73300. */
  73301. enableHeadsetImpostor?: boolean;
  73302. /**
  73303. * Optional parameters for the headset impostor
  73304. */
  73305. headsetImpostorParams?: {
  73306. /**
  73307. * The type of impostor to create. Default is sphere
  73308. */
  73309. impostorType: number;
  73310. /**
  73311. * the size of the impostor. Defaults to 10cm
  73312. */
  73313. impostorSize?: number | {
  73314. width: number;
  73315. height: number;
  73316. depth: number;
  73317. };
  73318. /**
  73319. * Friction definitions
  73320. */
  73321. friction?: number;
  73322. /**
  73323. * Restitution
  73324. */
  73325. restitution?: number;
  73326. };
  73327. /**
  73328. * The physics properties of the future impostors
  73329. */
  73330. physicsProperties?: {
  73331. /**
  73332. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73333. * Note that this requires a physics engine that supports mesh impostors!
  73334. */
  73335. useControllerMesh?: boolean;
  73336. /**
  73337. * The type of impostor to create. Default is sphere
  73338. */
  73339. impostorType?: number;
  73340. /**
  73341. * the size of the impostor. Defaults to 10cm
  73342. */
  73343. impostorSize?: number | {
  73344. width: number;
  73345. height: number;
  73346. depth: number;
  73347. };
  73348. /**
  73349. * Friction definitions
  73350. */
  73351. friction?: number;
  73352. /**
  73353. * Restitution
  73354. */
  73355. restitution?: number;
  73356. };
  73357. /**
  73358. * the xr input to use with this pointer selection
  73359. */
  73360. xrInput: WebXRInput;
  73361. }
  73362. /**
  73363. * Add physics impostor to your webxr controllers,
  73364. * including naive calculation of their linear and angular velocity
  73365. */
  73366. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73367. private readonly _options;
  73368. private _attachController;
  73369. private _controllers;
  73370. private _debugMode;
  73371. private _delta;
  73372. private _headsetImpostor?;
  73373. private _headsetMesh?;
  73374. private _lastTimestamp;
  73375. private _tmpQuaternion;
  73376. private _tmpVector;
  73377. /**
  73378. * The module's name
  73379. */
  73380. static readonly Name: string;
  73381. /**
  73382. * The (Babylon) version of this module.
  73383. * This is an integer representing the implementation version.
  73384. * This number does not correspond to the webxr specs version
  73385. */
  73386. static readonly Version: number;
  73387. /**
  73388. * Construct a new Controller Physics Feature
  73389. * @param _xrSessionManager the corresponding xr session manager
  73390. * @param _options options to create this feature with
  73391. */
  73392. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73393. /**
  73394. * @hidden
  73395. * enable debugging - will show console outputs and the impostor mesh
  73396. */
  73397. _enablePhysicsDebug(): void;
  73398. /**
  73399. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73400. * @param xrController the controller to add
  73401. */
  73402. addController(xrController: WebXRInputSource): void;
  73403. /**
  73404. * attach this feature
  73405. * Will usually be called by the features manager
  73406. *
  73407. * @returns true if successful.
  73408. */
  73409. attach(): boolean;
  73410. /**
  73411. * detach this feature.
  73412. * Will usually be called by the features manager
  73413. *
  73414. * @returns true if successful.
  73415. */
  73416. detach(): boolean;
  73417. /**
  73418. * Get the headset impostor, if enabled
  73419. * @returns the impostor
  73420. */
  73421. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73422. /**
  73423. * Get the physics impostor of a specific controller.
  73424. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73425. * @param controller the controller or the controller id of which to get the impostor
  73426. * @returns the impostor or null
  73427. */
  73428. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73429. /**
  73430. * Update the physics properties provided in the constructor
  73431. * @param newProperties the new properties object
  73432. */
  73433. setPhysicsProperties(newProperties: {
  73434. impostorType?: number;
  73435. impostorSize?: number | {
  73436. width: number;
  73437. height: number;
  73438. depth: number;
  73439. };
  73440. friction?: number;
  73441. restitution?: number;
  73442. }): void;
  73443. protected _onXRFrame(_xrFrame: any): void;
  73444. private _detachController;
  73445. }
  73446. }
  73447. declare module BABYLON {
  73448. /**
  73449. * The motion controller class for all microsoft mixed reality controllers
  73450. */
  73451. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73452. protected readonly _mapping: {
  73453. defaultButton: {
  73454. valueNodeName: string;
  73455. unpressedNodeName: string;
  73456. pressedNodeName: string;
  73457. };
  73458. defaultAxis: {
  73459. valueNodeName: string;
  73460. minNodeName: string;
  73461. maxNodeName: string;
  73462. };
  73463. buttons: {
  73464. "xr-standard-trigger": {
  73465. rootNodeName: string;
  73466. componentProperty: string;
  73467. states: string[];
  73468. };
  73469. "xr-standard-squeeze": {
  73470. rootNodeName: string;
  73471. componentProperty: string;
  73472. states: string[];
  73473. };
  73474. "xr-standard-touchpad": {
  73475. rootNodeName: string;
  73476. labelAnchorNodeName: string;
  73477. touchPointNodeName: string;
  73478. };
  73479. "xr-standard-thumbstick": {
  73480. rootNodeName: string;
  73481. componentProperty: string;
  73482. states: string[];
  73483. };
  73484. };
  73485. axes: {
  73486. "xr-standard-touchpad": {
  73487. "x-axis": {
  73488. rootNodeName: string;
  73489. };
  73490. "y-axis": {
  73491. rootNodeName: string;
  73492. };
  73493. };
  73494. "xr-standard-thumbstick": {
  73495. "x-axis": {
  73496. rootNodeName: string;
  73497. };
  73498. "y-axis": {
  73499. rootNodeName: string;
  73500. };
  73501. };
  73502. };
  73503. };
  73504. /**
  73505. * The base url used to load the left and right controller models
  73506. */
  73507. static MODEL_BASE_URL: string;
  73508. /**
  73509. * The name of the left controller model file
  73510. */
  73511. static MODEL_LEFT_FILENAME: string;
  73512. /**
  73513. * The name of the right controller model file
  73514. */
  73515. static MODEL_RIGHT_FILENAME: string;
  73516. profileId: string;
  73517. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73518. protected _getFilenameAndPath(): {
  73519. filename: string;
  73520. path: string;
  73521. };
  73522. protected _getModelLoadingConstraints(): boolean;
  73523. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73524. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73525. protected _updateModel(): void;
  73526. }
  73527. }
  73528. declare module BABYLON {
  73529. /**
  73530. * The motion controller class for oculus touch (quest, rift).
  73531. * This class supports legacy mapping as well the standard xr mapping
  73532. */
  73533. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73534. private _forceLegacyControllers;
  73535. private _modelRootNode;
  73536. /**
  73537. * The base url used to load the left and right controller models
  73538. */
  73539. static MODEL_BASE_URL: string;
  73540. /**
  73541. * The name of the left controller model file
  73542. */
  73543. static MODEL_LEFT_FILENAME: string;
  73544. /**
  73545. * The name of the right controller model file
  73546. */
  73547. static MODEL_RIGHT_FILENAME: string;
  73548. /**
  73549. * Base Url for the Quest controller model.
  73550. */
  73551. static QUEST_MODEL_BASE_URL: string;
  73552. profileId: string;
  73553. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73554. protected _getFilenameAndPath(): {
  73555. filename: string;
  73556. path: string;
  73557. };
  73558. protected _getModelLoadingConstraints(): boolean;
  73559. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73560. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73561. protected _updateModel(): void;
  73562. /**
  73563. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73564. * between the touch and touch 2.
  73565. */
  73566. private _isQuest;
  73567. }
  73568. }
  73569. declare module BABYLON {
  73570. /**
  73571. * The motion controller class for the standard HTC-Vive controllers
  73572. */
  73573. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73574. private _modelRootNode;
  73575. /**
  73576. * The base url used to load the left and right controller models
  73577. */
  73578. static MODEL_BASE_URL: string;
  73579. /**
  73580. * File name for the controller model.
  73581. */
  73582. static MODEL_FILENAME: string;
  73583. profileId: string;
  73584. /**
  73585. * Create a new Vive motion controller object
  73586. * @param scene the scene to use to create this controller
  73587. * @param gamepadObject the corresponding gamepad object
  73588. * @param handedness the handedness of the controller
  73589. */
  73590. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73591. protected _getFilenameAndPath(): {
  73592. filename: string;
  73593. path: string;
  73594. };
  73595. protected _getModelLoadingConstraints(): boolean;
  73596. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73597. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73598. protected _updateModel(): void;
  73599. }
  73600. }
  73601. declare module BABYLON {
  73602. /**
  73603. * A cursor which tracks a point on a path
  73604. */
  73605. export class PathCursor {
  73606. private path;
  73607. /**
  73608. * Stores path cursor callbacks for when an onchange event is triggered
  73609. */
  73610. private _onchange;
  73611. /**
  73612. * The value of the path cursor
  73613. */
  73614. value: number;
  73615. /**
  73616. * The animation array of the path cursor
  73617. */
  73618. animations: Animation[];
  73619. /**
  73620. * Initializes the path cursor
  73621. * @param path The path to track
  73622. */
  73623. constructor(path: Path2);
  73624. /**
  73625. * Gets the cursor point on the path
  73626. * @returns A point on the path cursor at the cursor location
  73627. */
  73628. getPoint(): Vector3;
  73629. /**
  73630. * Moves the cursor ahead by the step amount
  73631. * @param step The amount to move the cursor forward
  73632. * @returns This path cursor
  73633. */
  73634. moveAhead(step?: number): PathCursor;
  73635. /**
  73636. * Moves the cursor behind by the step amount
  73637. * @param step The amount to move the cursor back
  73638. * @returns This path cursor
  73639. */
  73640. moveBack(step?: number): PathCursor;
  73641. /**
  73642. * Moves the cursor by the step amount
  73643. * If the step amount is greater than one, an exception is thrown
  73644. * @param step The amount to move the cursor
  73645. * @returns This path cursor
  73646. */
  73647. move(step: number): PathCursor;
  73648. /**
  73649. * Ensures that the value is limited between zero and one
  73650. * @returns This path cursor
  73651. */
  73652. private ensureLimits;
  73653. /**
  73654. * Runs onchange callbacks on change (used by the animation engine)
  73655. * @returns This path cursor
  73656. */
  73657. private raiseOnChange;
  73658. /**
  73659. * Executes a function on change
  73660. * @param f A path cursor onchange callback
  73661. * @returns This path cursor
  73662. */
  73663. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73664. }
  73665. }
  73666. declare module BABYLON {
  73667. /** @hidden */
  73668. export var blurPixelShader: {
  73669. name: string;
  73670. shader: string;
  73671. };
  73672. }
  73673. declare module BABYLON {
  73674. /** @hidden */
  73675. export var pointCloudVertexDeclaration: {
  73676. name: string;
  73677. shader: string;
  73678. };
  73679. }
  73680. // Mixins
  73681. interface Window {
  73682. mozIndexedDB: IDBFactory;
  73683. webkitIndexedDB: IDBFactory;
  73684. msIndexedDB: IDBFactory;
  73685. webkitURL: typeof URL;
  73686. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73687. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73688. WebGLRenderingContext: WebGLRenderingContext;
  73689. MSGesture: MSGesture;
  73690. CANNON: any;
  73691. AudioContext: AudioContext;
  73692. webkitAudioContext: AudioContext;
  73693. PointerEvent: any;
  73694. Math: Math;
  73695. Uint8Array: Uint8ArrayConstructor;
  73696. Float32Array: Float32ArrayConstructor;
  73697. mozURL: typeof URL;
  73698. msURL: typeof URL;
  73699. VRFrameData: any; // WebVR, from specs 1.1
  73700. DracoDecoderModule: any;
  73701. setImmediate(handler: (...args: any[]) => void): number;
  73702. }
  73703. interface HTMLCanvasElement {
  73704. requestPointerLock(): void;
  73705. msRequestPointerLock?(): void;
  73706. mozRequestPointerLock?(): void;
  73707. webkitRequestPointerLock?(): void;
  73708. /** Track wether a record is in progress */
  73709. isRecording: boolean;
  73710. /** Capture Stream method defined by some browsers */
  73711. captureStream(fps?: number): MediaStream;
  73712. }
  73713. interface CanvasRenderingContext2D {
  73714. msImageSmoothingEnabled: boolean;
  73715. }
  73716. interface MouseEvent {
  73717. mozMovementX: number;
  73718. mozMovementY: number;
  73719. webkitMovementX: number;
  73720. webkitMovementY: number;
  73721. msMovementX: number;
  73722. msMovementY: number;
  73723. }
  73724. interface Navigator {
  73725. mozGetVRDevices: (any: any) => any;
  73726. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73727. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73728. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73729. webkitGetGamepads(): Gamepad[];
  73730. msGetGamepads(): Gamepad[];
  73731. webkitGamepads(): Gamepad[];
  73732. }
  73733. interface HTMLVideoElement {
  73734. mozSrcObject: any;
  73735. }
  73736. interface Math {
  73737. fround(x: number): number;
  73738. imul(a: number, b: number): number;
  73739. }
  73740. interface WebGLRenderingContext {
  73741. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73742. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73743. vertexAttribDivisor(index: number, divisor: number): void;
  73744. createVertexArray(): any;
  73745. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73746. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73747. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73748. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73749. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73750. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73751. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73752. // Queries
  73753. createQuery(): WebGLQuery;
  73754. deleteQuery(query: WebGLQuery): void;
  73755. beginQuery(target: number, query: WebGLQuery): void;
  73756. endQuery(target: number): void;
  73757. getQueryParameter(query: WebGLQuery, pname: number): any;
  73758. getQuery(target: number, pname: number): any;
  73759. MAX_SAMPLES: number;
  73760. RGBA8: number;
  73761. READ_FRAMEBUFFER: number;
  73762. DRAW_FRAMEBUFFER: number;
  73763. UNIFORM_BUFFER: number;
  73764. HALF_FLOAT_OES: number;
  73765. RGBA16F: number;
  73766. RGBA32F: number;
  73767. R32F: number;
  73768. RG32F: number;
  73769. RGB32F: number;
  73770. R16F: number;
  73771. RG16F: number;
  73772. RGB16F: number;
  73773. RED: number;
  73774. RG: number;
  73775. R8: number;
  73776. RG8: number;
  73777. UNSIGNED_INT_24_8: number;
  73778. DEPTH24_STENCIL8: number;
  73779. MIN: number;
  73780. MAX: number;
  73781. /* Multiple Render Targets */
  73782. drawBuffers(buffers: number[]): void;
  73783. readBuffer(src: number): void;
  73784. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73785. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73786. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73787. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73788. // Occlusion Query
  73789. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73790. ANY_SAMPLES_PASSED: number;
  73791. QUERY_RESULT_AVAILABLE: number;
  73792. QUERY_RESULT: number;
  73793. }
  73794. interface WebGLProgram {
  73795. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73796. }
  73797. interface EXT_disjoint_timer_query {
  73798. QUERY_COUNTER_BITS_EXT: number;
  73799. TIME_ELAPSED_EXT: number;
  73800. TIMESTAMP_EXT: number;
  73801. GPU_DISJOINT_EXT: number;
  73802. QUERY_RESULT_EXT: number;
  73803. QUERY_RESULT_AVAILABLE_EXT: number;
  73804. queryCounterEXT(query: WebGLQuery, target: number): void;
  73805. createQueryEXT(): WebGLQuery;
  73806. beginQueryEXT(target: number, query: WebGLQuery): void;
  73807. endQueryEXT(target: number): void;
  73808. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73809. deleteQueryEXT(query: WebGLQuery): void;
  73810. }
  73811. interface WebGLUniformLocation {
  73812. _currentState: any;
  73813. }
  73814. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73815. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73816. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73817. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73818. interface WebGLRenderingContext {
  73819. readonly RASTERIZER_DISCARD: number;
  73820. readonly DEPTH_COMPONENT24: number;
  73821. readonly TEXTURE_3D: number;
  73822. readonly TEXTURE_2D_ARRAY: number;
  73823. readonly TEXTURE_COMPARE_FUNC: number;
  73824. readonly TEXTURE_COMPARE_MODE: number;
  73825. readonly COMPARE_REF_TO_TEXTURE: number;
  73826. readonly TEXTURE_WRAP_R: number;
  73827. readonly HALF_FLOAT: number;
  73828. readonly RGB8: number;
  73829. readonly RED_INTEGER: number;
  73830. readonly RG_INTEGER: number;
  73831. readonly RGB_INTEGER: number;
  73832. readonly RGBA_INTEGER: number;
  73833. readonly R8_SNORM: number;
  73834. readonly RG8_SNORM: number;
  73835. readonly RGB8_SNORM: number;
  73836. readonly RGBA8_SNORM: number;
  73837. readonly R8I: number;
  73838. readonly RG8I: number;
  73839. readonly RGB8I: number;
  73840. readonly RGBA8I: number;
  73841. readonly R8UI: number;
  73842. readonly RG8UI: number;
  73843. readonly RGB8UI: number;
  73844. readonly RGBA8UI: number;
  73845. readonly R16I: number;
  73846. readonly RG16I: number;
  73847. readonly RGB16I: number;
  73848. readonly RGBA16I: number;
  73849. readonly R16UI: number;
  73850. readonly RG16UI: number;
  73851. readonly RGB16UI: number;
  73852. readonly RGBA16UI: number;
  73853. readonly R32I: number;
  73854. readonly RG32I: number;
  73855. readonly RGB32I: number;
  73856. readonly RGBA32I: number;
  73857. readonly R32UI: number;
  73858. readonly RG32UI: number;
  73859. readonly RGB32UI: number;
  73860. readonly RGBA32UI: number;
  73861. readonly RGB10_A2UI: number;
  73862. readonly R11F_G11F_B10F: number;
  73863. readonly RGB9_E5: number;
  73864. readonly RGB10_A2: number;
  73865. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73866. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73867. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73868. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73869. readonly DEPTH_COMPONENT32F: number;
  73870. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73871. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73872. 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;
  73873. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73874. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73875. readonly TRANSFORM_FEEDBACK: number;
  73876. readonly INTERLEAVED_ATTRIBS: number;
  73877. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73878. createTransformFeedback(): WebGLTransformFeedback;
  73879. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73880. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73881. beginTransformFeedback(primitiveMode: number): void;
  73882. endTransformFeedback(): void;
  73883. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73884. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73885. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73886. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73887. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73888. }
  73889. interface ImageBitmap {
  73890. readonly width: number;
  73891. readonly height: number;
  73892. close(): void;
  73893. }
  73894. interface WebGLQuery extends WebGLObject {
  73895. }
  73896. declare var WebGLQuery: {
  73897. prototype: WebGLQuery;
  73898. new(): WebGLQuery;
  73899. };
  73900. interface WebGLSampler extends WebGLObject {
  73901. }
  73902. declare var WebGLSampler: {
  73903. prototype: WebGLSampler;
  73904. new(): WebGLSampler;
  73905. };
  73906. interface WebGLSync extends WebGLObject {
  73907. }
  73908. declare var WebGLSync: {
  73909. prototype: WebGLSync;
  73910. new(): WebGLSync;
  73911. };
  73912. interface WebGLTransformFeedback extends WebGLObject {
  73913. }
  73914. declare var WebGLTransformFeedback: {
  73915. prototype: WebGLTransformFeedback;
  73916. new(): WebGLTransformFeedback;
  73917. };
  73918. interface WebGLVertexArrayObject extends WebGLObject {
  73919. }
  73920. declare var WebGLVertexArrayObject: {
  73921. prototype: WebGLVertexArrayObject;
  73922. new(): WebGLVertexArrayObject;
  73923. };
  73924. // Type definitions for WebVR API
  73925. // Project: https://w3c.github.io/webvr/
  73926. // Definitions by: six a <https://github.com/lostfictions>
  73927. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73928. interface VRDisplay extends EventTarget {
  73929. /**
  73930. * Dictionary of capabilities describing the VRDisplay.
  73931. */
  73932. readonly capabilities: VRDisplayCapabilities;
  73933. /**
  73934. * z-depth defining the far plane of the eye view frustum
  73935. * enables mapping of values in the render target depth
  73936. * attachment to scene coordinates. Initially set to 10000.0.
  73937. */
  73938. depthFar: number;
  73939. /**
  73940. * z-depth defining the near plane of the eye view frustum
  73941. * enables mapping of values in the render target depth
  73942. * attachment to scene coordinates. Initially set to 0.01.
  73943. */
  73944. depthNear: number;
  73945. /**
  73946. * An identifier for this distinct VRDisplay. Used as an
  73947. * association point in the Gamepad API.
  73948. */
  73949. readonly displayId: number;
  73950. /**
  73951. * A display name, a user-readable name identifying it.
  73952. */
  73953. readonly displayName: string;
  73954. readonly isConnected: boolean;
  73955. readonly isPresenting: boolean;
  73956. /**
  73957. * If this VRDisplay supports room-scale experiences, the optional
  73958. * stage attribute contains details on the room-scale parameters.
  73959. */
  73960. readonly stageParameters: VRStageParameters | null;
  73961. /**
  73962. * Passing the value returned by `requestAnimationFrame` to
  73963. * `cancelAnimationFrame` will unregister the callback.
  73964. * @param handle Define the hanle of the request to cancel
  73965. */
  73966. cancelAnimationFrame(handle: number): void;
  73967. /**
  73968. * Stops presenting to the VRDisplay.
  73969. * @returns a promise to know when it stopped
  73970. */
  73971. exitPresent(): Promise<void>;
  73972. /**
  73973. * Return the current VREyeParameters for the given eye.
  73974. * @param whichEye Define the eye we want the parameter for
  73975. * @returns the eye parameters
  73976. */
  73977. getEyeParameters(whichEye: string): VREyeParameters;
  73978. /**
  73979. * Populates the passed VRFrameData with the information required to render
  73980. * the current frame.
  73981. * @param frameData Define the data structure to populate
  73982. * @returns true if ok otherwise false
  73983. */
  73984. getFrameData(frameData: VRFrameData): boolean;
  73985. /**
  73986. * Get the layers currently being presented.
  73987. * @returns the list of VR layers
  73988. */
  73989. getLayers(): VRLayer[];
  73990. /**
  73991. * Return a VRPose containing the future predicted pose of the VRDisplay
  73992. * when the current frame will be presented. The value returned will not
  73993. * change until JavaScript has returned control to the browser.
  73994. *
  73995. * The VRPose will contain the position, orientation, velocity,
  73996. * and acceleration of each of these properties.
  73997. * @returns the pose object
  73998. */
  73999. getPose(): VRPose;
  74000. /**
  74001. * Return the current instantaneous pose of the VRDisplay, with no
  74002. * prediction applied.
  74003. * @returns the current instantaneous pose
  74004. */
  74005. getImmediatePose(): VRPose;
  74006. /**
  74007. * The callback passed to `requestAnimationFrame` will be called
  74008. * any time a new frame should be rendered. When the VRDisplay is
  74009. * presenting the callback will be called at the native refresh
  74010. * rate of the HMD. When not presenting this function acts
  74011. * identically to how window.requestAnimationFrame acts. Content should
  74012. * make no assumptions of frame rate or vsync behavior as the HMD runs
  74013. * asynchronously from other displays and at differing refresh rates.
  74014. * @param callback Define the eaction to run next frame
  74015. * @returns the request handle it
  74016. */
  74017. requestAnimationFrame(callback: FrameRequestCallback): number;
  74018. /**
  74019. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  74020. * Repeat calls while already presenting will update the VRLayers being displayed.
  74021. * @param layers Define the list of layer to present
  74022. * @returns a promise to know when the request has been fulfilled
  74023. */
  74024. requestPresent(layers: VRLayer[]): Promise<void>;
  74025. /**
  74026. * Reset the pose for this display, treating its current position and
  74027. * orientation as the "origin/zero" values. VRPose.position,
  74028. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  74029. * updated when calling resetPose(). This should be called in only
  74030. * sitting-space experiences.
  74031. */
  74032. resetPose(): void;
  74033. /**
  74034. * The VRLayer provided to the VRDisplay will be captured and presented
  74035. * in the HMD. Calling this function has the same effect on the source
  74036. * canvas as any other operation that uses its source image, and canvases
  74037. * created without preserveDrawingBuffer set to true will be cleared.
  74038. * @param pose Define the pose to submit
  74039. */
  74040. submitFrame(pose?: VRPose): void;
  74041. }
  74042. declare var VRDisplay: {
  74043. prototype: VRDisplay;
  74044. new(): VRDisplay;
  74045. };
  74046. interface VRLayer {
  74047. leftBounds?: number[] | Float32Array | null;
  74048. rightBounds?: number[] | Float32Array | null;
  74049. source?: HTMLCanvasElement | null;
  74050. }
  74051. interface VRDisplayCapabilities {
  74052. readonly canPresent: boolean;
  74053. readonly hasExternalDisplay: boolean;
  74054. readonly hasOrientation: boolean;
  74055. readonly hasPosition: boolean;
  74056. readonly maxLayers: number;
  74057. }
  74058. interface VREyeParameters {
  74059. /** @deprecated */
  74060. readonly fieldOfView: VRFieldOfView;
  74061. readonly offset: Float32Array;
  74062. readonly renderHeight: number;
  74063. readonly renderWidth: number;
  74064. }
  74065. interface VRFieldOfView {
  74066. readonly downDegrees: number;
  74067. readonly leftDegrees: number;
  74068. readonly rightDegrees: number;
  74069. readonly upDegrees: number;
  74070. }
  74071. interface VRFrameData {
  74072. readonly leftProjectionMatrix: Float32Array;
  74073. readonly leftViewMatrix: Float32Array;
  74074. readonly pose: VRPose;
  74075. readonly rightProjectionMatrix: Float32Array;
  74076. readonly rightViewMatrix: Float32Array;
  74077. readonly timestamp: number;
  74078. }
  74079. interface VRPose {
  74080. readonly angularAcceleration: Float32Array | null;
  74081. readonly angularVelocity: Float32Array | null;
  74082. readonly linearAcceleration: Float32Array | null;
  74083. readonly linearVelocity: Float32Array | null;
  74084. readonly orientation: Float32Array | null;
  74085. readonly position: Float32Array | null;
  74086. readonly timestamp: number;
  74087. }
  74088. interface VRStageParameters {
  74089. sittingToStandingTransform?: Float32Array;
  74090. sizeX?: number;
  74091. sizeY?: number;
  74092. }
  74093. interface Navigator {
  74094. getVRDisplays(): Promise<VRDisplay[]>;
  74095. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  74096. }
  74097. interface Window {
  74098. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  74099. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  74100. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  74101. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74102. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74103. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  74104. }
  74105. interface Gamepad {
  74106. readonly displayId: number;
  74107. }
  74108. type XRSessionMode =
  74109. | "inline"
  74110. | "immersive-vr"
  74111. | "immersive-ar";
  74112. type XRReferenceSpaceType =
  74113. | "viewer"
  74114. | "local"
  74115. | "local-floor"
  74116. | "bounded-floor"
  74117. | "unbounded";
  74118. type XREnvironmentBlendMode =
  74119. | "opaque"
  74120. | "additive"
  74121. | "alpha-blend";
  74122. type XRVisibilityState =
  74123. | "visible"
  74124. | "visible-blurred"
  74125. | "hidden";
  74126. type XRHandedness =
  74127. | "none"
  74128. | "left"
  74129. | "right";
  74130. type XRTargetRayMode =
  74131. | "gaze"
  74132. | "tracked-pointer"
  74133. | "screen";
  74134. type XREye =
  74135. | "none"
  74136. | "left"
  74137. | "right";
  74138. type XREventType =
  74139. | "devicechange"
  74140. | "visibilitychange"
  74141. | "end"
  74142. | "inputsourceschange"
  74143. | "select"
  74144. | "selectstart"
  74145. | "selectend"
  74146. | "squeeze"
  74147. | "squeezestart"
  74148. | "squeezeend"
  74149. | "reset";
  74150. interface XRSpace extends EventTarget {
  74151. }
  74152. interface XRRenderState {
  74153. depthNear?: number;
  74154. depthFar?: number;
  74155. inlineVerticalFieldOfView?: number;
  74156. baseLayer?: XRWebGLLayer;
  74157. }
  74158. interface XRInputSource {
  74159. handedness: XRHandedness;
  74160. targetRayMode: XRTargetRayMode;
  74161. targetRaySpace: XRSpace;
  74162. gripSpace: XRSpace | undefined;
  74163. gamepad: Gamepad | undefined;
  74164. profiles: Array<string>;
  74165. }
  74166. interface XRSessionInit {
  74167. optionalFeatures?: string[];
  74168. requiredFeatures?: string[];
  74169. }
  74170. interface XRSession {
  74171. addEventListener: Function;
  74172. removeEventListener: Function;
  74173. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74174. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74175. requestAnimationFrame: Function;
  74176. end(): Promise<void>;
  74177. renderState: XRRenderState;
  74178. inputSources: Array<XRInputSource>;
  74179. // hit test
  74180. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74181. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74182. // legacy AR hit test
  74183. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74184. // legacy plane detection
  74185. updateWorldTrackingState(options: {
  74186. planeDetectionState?: { enabled: boolean; }
  74187. }): void;
  74188. }
  74189. interface XRReferenceSpace extends XRSpace {
  74190. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74191. onreset: any;
  74192. }
  74193. type XRPlaneSet = Set<XRPlane>;
  74194. type XRAnchorSet = Set<XRAnchor>;
  74195. interface XRFrame {
  74196. session: XRSession;
  74197. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74198. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74199. // AR
  74200. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74201. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74202. // Anchors
  74203. trackedAnchors?: XRAnchorSet;
  74204. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74205. // Planes
  74206. worldInformation: {
  74207. detectedPlanes?: XRPlaneSet;
  74208. };
  74209. }
  74210. interface XRViewerPose extends XRPose {
  74211. views: Array<XRView>;
  74212. }
  74213. interface XRPose {
  74214. transform: XRRigidTransform;
  74215. emulatedPosition: boolean;
  74216. }
  74217. interface XRWebGLLayerOptions {
  74218. antialias?: boolean;
  74219. depth?: boolean;
  74220. stencil?: boolean;
  74221. alpha?: boolean;
  74222. multiview?: boolean;
  74223. framebufferScaleFactor?: number;
  74224. }
  74225. declare var XRWebGLLayer: {
  74226. prototype: XRWebGLLayer;
  74227. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74228. };
  74229. interface XRWebGLLayer {
  74230. framebuffer: WebGLFramebuffer;
  74231. framebufferWidth: number;
  74232. framebufferHeight: number;
  74233. getViewport: Function;
  74234. }
  74235. declare class XRRigidTransform {
  74236. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74237. position: DOMPointReadOnly;
  74238. orientation: DOMPointReadOnly;
  74239. matrix: Float32Array;
  74240. inverse: XRRigidTransform;
  74241. }
  74242. interface XRView {
  74243. eye: XREye;
  74244. projectionMatrix: Float32Array;
  74245. transform: XRRigidTransform;
  74246. }
  74247. interface XRInputSourceChangeEvent {
  74248. session: XRSession;
  74249. removed: Array<XRInputSource>;
  74250. added: Array<XRInputSource>;
  74251. }
  74252. interface XRInputSourceEvent extends Event {
  74253. readonly frame: XRFrame;
  74254. readonly inputSource: XRInputSource;
  74255. }
  74256. // Experimental(er) features
  74257. declare class XRRay {
  74258. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74259. origin: DOMPointReadOnly;
  74260. direction: DOMPointReadOnly;
  74261. matrix: Float32Array;
  74262. }
  74263. declare enum XRHitTestTrackableType {
  74264. "point",
  74265. "plane"
  74266. }
  74267. interface XRHitResult {
  74268. hitMatrix: Float32Array;
  74269. }
  74270. interface XRTransientInputHitTestResult {
  74271. readonly inputSource: XRInputSource;
  74272. readonly results: Array<XRHitTestResult>;
  74273. }
  74274. interface XRHitTestResult {
  74275. getPose(baseSpace: XRSpace): XRPose | undefined;
  74276. // When anchor system is enabled
  74277. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74278. }
  74279. interface XRHitTestSource {
  74280. cancel(): void;
  74281. }
  74282. interface XRTransientInputHitTestSource {
  74283. cancel(): void;
  74284. }
  74285. interface XRHitTestOptionsInit {
  74286. space: XRSpace;
  74287. entityTypes?: Array<XRHitTestTrackableType>;
  74288. offsetRay?: XRRay;
  74289. }
  74290. interface XRTransientInputHitTestOptionsInit {
  74291. profile: string;
  74292. entityTypes?: Array<XRHitTestTrackableType>;
  74293. offsetRay?: XRRay;
  74294. }
  74295. interface XRAnchor {
  74296. anchorSpace: XRSpace;
  74297. delete(): void;
  74298. }
  74299. interface XRPlane {
  74300. orientation: "Horizontal" | "Vertical";
  74301. planeSpace: XRSpace;
  74302. polygon: Array<DOMPointReadOnly>;
  74303. lastChangedTime: number;
  74304. }
  74305. /**
  74306. * @ignore
  74307. */
  74308. declare module BABYLON.GLTF2.Exporter {
  74309. }
  74310. /**
  74311. * @ignore
  74312. */
  74313. declare module BABYLON.GLTF1 {
  74314. }
  74315. declare module BABYLON.GUI {
  74316. /**
  74317. * Class used to specific a value and its associated unit
  74318. */
  74319. export class ValueAndUnit {
  74320. /** defines the unit to store */
  74321. unit: number;
  74322. /** defines a boolean indicating if the value can be negative */
  74323. negativeValueAllowed: boolean;
  74324. private _value;
  74325. private _originalUnit;
  74326. /**
  74327. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74328. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74329. */
  74330. ignoreAdaptiveScaling: boolean;
  74331. /**
  74332. * Creates a new ValueAndUnit
  74333. * @param value defines the value to store
  74334. * @param unit defines the unit to store
  74335. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74336. */
  74337. constructor(value: number,
  74338. /** defines the unit to store */
  74339. unit?: number,
  74340. /** defines a boolean indicating if the value can be negative */
  74341. negativeValueAllowed?: boolean);
  74342. /** Gets a boolean indicating if the value is a percentage */
  74343. get isPercentage(): boolean;
  74344. /** Gets a boolean indicating if the value is store as pixel */
  74345. get isPixel(): boolean;
  74346. /** Gets direct internal value */
  74347. get internalValue(): number;
  74348. /**
  74349. * Gets value as pixel
  74350. * @param host defines the root host
  74351. * @param refValue defines the reference value for percentages
  74352. * @returns the value as pixel
  74353. */
  74354. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74355. /**
  74356. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74357. * @param value defines the value to store
  74358. * @param unit defines the unit to store
  74359. * @returns the current ValueAndUnit
  74360. */
  74361. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74362. /**
  74363. * Gets the value accordingly to its unit
  74364. * @param host defines the root host
  74365. * @returns the value
  74366. */
  74367. getValue(host: AdvancedDynamicTexture): number;
  74368. /**
  74369. * Gets a string representation of the value
  74370. * @param host defines the root host
  74371. * @param decimals defines an optional number of decimals to display
  74372. * @returns a string
  74373. */
  74374. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74375. /**
  74376. * Store a value parsed from a string
  74377. * @param source defines the source string
  74378. * @returns true if the value was successfully parsed
  74379. */
  74380. fromString(source: string | number): boolean;
  74381. private static _Regex;
  74382. private static _UNITMODE_PERCENTAGE;
  74383. private static _UNITMODE_PIXEL;
  74384. /** UNITMODE_PERCENTAGE */
  74385. static get UNITMODE_PERCENTAGE(): number;
  74386. /** UNITMODE_PIXEL */
  74387. static get UNITMODE_PIXEL(): number;
  74388. }
  74389. }
  74390. declare module BABYLON.GUI {
  74391. /**
  74392. * Define a style used by control to automatically setup properties based on a template.
  74393. * Only support font related properties so far
  74394. */
  74395. export class Style implements BABYLON.IDisposable {
  74396. private _fontFamily;
  74397. private _fontStyle;
  74398. private _fontWeight;
  74399. /** @hidden */
  74400. _host: AdvancedDynamicTexture;
  74401. /** @hidden */
  74402. _fontSize: ValueAndUnit;
  74403. /**
  74404. * BABYLON.Observable raised when the style values are changed
  74405. */
  74406. onChangedObservable: BABYLON.Observable<Style>;
  74407. /**
  74408. * Creates a new style object
  74409. * @param host defines the AdvancedDynamicTexture which hosts this style
  74410. */
  74411. constructor(host: AdvancedDynamicTexture);
  74412. /**
  74413. * Gets or sets the font size
  74414. */
  74415. get fontSize(): string | number;
  74416. set fontSize(value: string | number);
  74417. /**
  74418. * Gets or sets the font family
  74419. */
  74420. get fontFamily(): string;
  74421. set fontFamily(value: string);
  74422. /**
  74423. * Gets or sets the font style
  74424. */
  74425. get fontStyle(): string;
  74426. set fontStyle(value: string);
  74427. /** Gets or sets font weight */
  74428. get fontWeight(): string;
  74429. set fontWeight(value: string);
  74430. /** Dispose all associated resources */
  74431. dispose(): void;
  74432. }
  74433. }
  74434. declare module BABYLON.GUI {
  74435. /**
  74436. * Class used to transport BABYLON.Vector2 information for pointer events
  74437. */
  74438. export class Vector2WithInfo extends BABYLON.Vector2 {
  74439. /** defines the current mouse button index */
  74440. buttonIndex: number;
  74441. /**
  74442. * Creates a new Vector2WithInfo
  74443. * @param source defines the vector2 data to transport
  74444. * @param buttonIndex defines the current mouse button index
  74445. */
  74446. constructor(source: BABYLON.Vector2,
  74447. /** defines the current mouse button index */
  74448. buttonIndex?: number);
  74449. }
  74450. /** Class used to provide 2D matrix features */
  74451. export class Matrix2D {
  74452. /** Gets the internal array of 6 floats used to store matrix data */
  74453. m: Float32Array;
  74454. /**
  74455. * Creates a new matrix
  74456. * @param m00 defines value for (0, 0)
  74457. * @param m01 defines value for (0, 1)
  74458. * @param m10 defines value for (1, 0)
  74459. * @param m11 defines value for (1, 1)
  74460. * @param m20 defines value for (2, 0)
  74461. * @param m21 defines value for (2, 1)
  74462. */
  74463. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74464. /**
  74465. * Fills the matrix from direct values
  74466. * @param m00 defines value for (0, 0)
  74467. * @param m01 defines value for (0, 1)
  74468. * @param m10 defines value for (1, 0)
  74469. * @param m11 defines value for (1, 1)
  74470. * @param m20 defines value for (2, 0)
  74471. * @param m21 defines value for (2, 1)
  74472. * @returns the current modified matrix
  74473. */
  74474. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74475. /**
  74476. * Gets matrix determinant
  74477. * @returns the determinant
  74478. */
  74479. determinant(): number;
  74480. /**
  74481. * Inverses the matrix and stores it in a target matrix
  74482. * @param result defines the target matrix
  74483. * @returns the current matrix
  74484. */
  74485. invertToRef(result: Matrix2D): Matrix2D;
  74486. /**
  74487. * Multiplies the current matrix with another one
  74488. * @param other defines the second operand
  74489. * @param result defines the target matrix
  74490. * @returns the current matrix
  74491. */
  74492. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74493. /**
  74494. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74495. * @param x defines the x coordinate to transform
  74496. * @param y defines the x coordinate to transform
  74497. * @param result defines the target vector2
  74498. * @returns the current matrix
  74499. */
  74500. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74501. /**
  74502. * Creates an identity matrix
  74503. * @returns a new matrix
  74504. */
  74505. static Identity(): Matrix2D;
  74506. /**
  74507. * Creates a translation matrix and stores it in a target matrix
  74508. * @param x defines the x coordinate of the translation
  74509. * @param y defines the y coordinate of the translation
  74510. * @param result defines the target matrix
  74511. */
  74512. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74513. /**
  74514. * Creates a scaling matrix and stores it in a target matrix
  74515. * @param x defines the x coordinate of the scaling
  74516. * @param y defines the y coordinate of the scaling
  74517. * @param result defines the target matrix
  74518. */
  74519. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74520. /**
  74521. * Creates a rotation matrix and stores it in a target matrix
  74522. * @param angle defines the rotation angle
  74523. * @param result defines the target matrix
  74524. */
  74525. static RotationToRef(angle: number, result: Matrix2D): void;
  74526. private static _TempPreTranslationMatrix;
  74527. private static _TempPostTranslationMatrix;
  74528. private static _TempRotationMatrix;
  74529. private static _TempScalingMatrix;
  74530. private static _TempCompose0;
  74531. private static _TempCompose1;
  74532. private static _TempCompose2;
  74533. /**
  74534. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  74535. * @param tx defines the x coordinate of the translation
  74536. * @param ty defines the y coordinate of the translation
  74537. * @param angle defines the rotation angle
  74538. * @param scaleX defines the x coordinate of the scaling
  74539. * @param scaleY defines the y coordinate of the scaling
  74540. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  74541. * @param result defines the target matrix
  74542. */
  74543. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  74544. }
  74545. }
  74546. declare module BABYLON.GUI {
  74547. /**
  74548. * Class used to store 2D control sizes
  74549. */
  74550. export class Measure {
  74551. /** defines left coordinate */
  74552. left: number;
  74553. /** defines top coordinate */
  74554. top: number;
  74555. /** defines width dimension */
  74556. width: number;
  74557. /** defines height dimension */
  74558. height: number;
  74559. /**
  74560. * Creates a new measure
  74561. * @param left defines left coordinate
  74562. * @param top defines top coordinate
  74563. * @param width defines width dimension
  74564. * @param height defines height dimension
  74565. */
  74566. constructor(
  74567. /** defines left coordinate */
  74568. left: number,
  74569. /** defines top coordinate */
  74570. top: number,
  74571. /** defines width dimension */
  74572. width: number,
  74573. /** defines height dimension */
  74574. height: number);
  74575. /**
  74576. * Copy from another measure
  74577. * @param other defines the other measure to copy from
  74578. */
  74579. copyFrom(other: Measure): void;
  74580. /**
  74581. * Copy from a group of 4 floats
  74582. * @param left defines left coordinate
  74583. * @param top defines top coordinate
  74584. * @param width defines width dimension
  74585. * @param height defines height dimension
  74586. */
  74587. copyFromFloats(left: number, top: number, width: number, height: number): void;
  74588. /**
  74589. * Computes the axis aligned bounding box measure for two given measures
  74590. * @param a Input measure
  74591. * @param b Input measure
  74592. * @param result the resulting bounding measure
  74593. */
  74594. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  74595. /**
  74596. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  74597. * @param transform the matrix to transform the measure before computing the AABB
  74598. * @param result the resulting AABB
  74599. */
  74600. transformToRef(transform: Matrix2D, result: Measure): void;
  74601. /**
  74602. * Check equality between this measure and another one
  74603. * @param other defines the other measures
  74604. * @returns true if both measures are equals
  74605. */
  74606. isEqualsTo(other: Measure): boolean;
  74607. /**
  74608. * Creates an empty measure
  74609. * @returns a new measure
  74610. */
  74611. static Empty(): Measure;
  74612. }
  74613. }
  74614. declare module BABYLON.GUI {
  74615. /**
  74616. * Interface used to define a control that can receive focus
  74617. */
  74618. export interface IFocusableControl {
  74619. /**
  74620. * Function called when the control receives the focus
  74621. */
  74622. onFocus(): void;
  74623. /**
  74624. * Function called when the control loses the focus
  74625. */
  74626. onBlur(): void;
  74627. /**
  74628. * Function called to let the control handle keyboard events
  74629. * @param evt defines the current keyboard event
  74630. */
  74631. processKeyboard(evt: KeyboardEvent): void;
  74632. /**
  74633. * Function called to get the list of controls that should not steal the focus from this control
  74634. * @returns an array of controls
  74635. */
  74636. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74637. }
  74638. /**
  74639. * Class used to create texture to support 2D GUI elements
  74640. * @see http://doc.babylonjs.com/how_to/gui
  74641. */
  74642. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74643. private _isDirty;
  74644. private _renderObserver;
  74645. private _resizeObserver;
  74646. private _preKeyboardObserver;
  74647. private _pointerMoveObserver;
  74648. private _pointerObserver;
  74649. private _canvasPointerOutObserver;
  74650. private _background;
  74651. /** @hidden */
  74652. _rootContainer: Container;
  74653. /** @hidden */
  74654. _lastPickedControl: Control;
  74655. /** @hidden */
  74656. _lastControlOver: {
  74657. [pointerId: number]: Control;
  74658. };
  74659. /** @hidden */
  74660. _lastControlDown: {
  74661. [pointerId: number]: Control;
  74662. };
  74663. /** @hidden */
  74664. _capturingControl: {
  74665. [pointerId: number]: Control;
  74666. };
  74667. /** @hidden */
  74668. _shouldBlockPointer: boolean;
  74669. /** @hidden */
  74670. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  74671. /** @hidden */
  74672. _linkedControls: Control[];
  74673. private _isFullscreen;
  74674. private _fullscreenViewport;
  74675. private _idealWidth;
  74676. private _idealHeight;
  74677. private _useSmallestIdeal;
  74678. private _renderAtIdealSize;
  74679. private _focusedControl;
  74680. private _blockNextFocusCheck;
  74681. private _renderScale;
  74682. private _rootElement;
  74683. private _cursorChanged;
  74684. private _defaultMousePointerId;
  74685. /** @hidden */
  74686. _numLayoutCalls: number;
  74687. /** Gets the number of layout calls made the last time the ADT has been rendered */
  74688. get numLayoutCalls(): number;
  74689. /** @hidden */
  74690. _numRenderCalls: number;
  74691. /** Gets the number of render calls made the last time the ADT has been rendered */
  74692. get numRenderCalls(): number;
  74693. /**
  74694. * Define type to string to ensure compatibility across browsers
  74695. * Safari doesn't support DataTransfer constructor
  74696. */
  74697. private _clipboardData;
  74698. /**
  74699. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  74700. */
  74701. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  74702. /**
  74703. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  74704. */
  74705. onControlPickedObservable: BABYLON.Observable<Control>;
  74706. /**
  74707. * BABYLON.Observable event triggered before layout is evaluated
  74708. */
  74709. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74710. /**
  74711. * BABYLON.Observable event triggered after the layout was evaluated
  74712. */
  74713. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74714. /**
  74715. * BABYLON.Observable event triggered before the texture is rendered
  74716. */
  74717. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74718. /**
  74719. * BABYLON.Observable event triggered after the texture was rendered
  74720. */
  74721. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74722. /**
  74723. * Gets or sets a boolean defining if alpha is stored as premultiplied
  74724. */
  74725. premulAlpha: boolean;
  74726. /**
  74727. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  74728. * Useful when you want more antialiasing
  74729. */
  74730. get renderScale(): number;
  74731. set renderScale(value: number);
  74732. /** Gets or sets the background color */
  74733. get background(): string;
  74734. set background(value: string);
  74735. /**
  74736. * Gets or sets the ideal width used to design controls.
  74737. * The GUI will then rescale everything accordingly
  74738. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74739. */
  74740. get idealWidth(): number;
  74741. set idealWidth(value: number);
  74742. /**
  74743. * Gets or sets the ideal height used to design controls.
  74744. * The GUI will then rescale everything accordingly
  74745. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74746. */
  74747. get idealHeight(): number;
  74748. set idealHeight(value: number);
  74749. /**
  74750. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  74751. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74752. */
  74753. get useSmallestIdeal(): boolean;
  74754. set useSmallestIdeal(value: boolean);
  74755. /**
  74756. * Gets or sets a boolean indicating if adaptive scaling must be used
  74757. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74758. */
  74759. get renderAtIdealSize(): boolean;
  74760. set renderAtIdealSize(value: boolean);
  74761. /**
  74762. * Gets the ratio used when in "ideal mode"
  74763. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74764. * */
  74765. get idealRatio(): number;
  74766. /**
  74767. * Gets the underlying layer used to render the texture when in fullscreen mode
  74768. */
  74769. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  74770. /**
  74771. * Gets the root container control
  74772. */
  74773. get rootContainer(): Container;
  74774. /**
  74775. * Returns an array containing the root container.
  74776. * This is mostly used to let the Inspector introspects the ADT
  74777. * @returns an array containing the rootContainer
  74778. */
  74779. getChildren(): Array<Container>;
  74780. /**
  74781. * Will return all controls that are inside this texture
  74782. * @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
  74783. * @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
  74784. * @return all child controls
  74785. */
  74786. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74787. /**
  74788. * Gets or sets the current focused control
  74789. */
  74790. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74791. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74792. /**
  74793. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74794. */
  74795. get isForeground(): boolean;
  74796. set isForeground(value: boolean);
  74797. /**
  74798. * Gets or set information about clipboardData
  74799. */
  74800. get clipboardData(): string;
  74801. set clipboardData(value: string);
  74802. /**
  74803. * Creates a new AdvancedDynamicTexture
  74804. * @param name defines the name of the texture
  74805. * @param width defines the width of the texture
  74806. * @param height defines the height of the texture
  74807. * @param scene defines the hosting scene
  74808. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74809. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74810. */
  74811. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74812. /**
  74813. * Get the current class name of the texture useful for serialization or dynamic coding.
  74814. * @returns "AdvancedDynamicTexture"
  74815. */
  74816. getClassName(): string;
  74817. /**
  74818. * Function used to execute a function on all controls
  74819. * @param func defines the function to execute
  74820. * @param container defines the container where controls belong. If null the root container will be used
  74821. */
  74822. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74823. private _useInvalidateRectOptimization;
  74824. /**
  74825. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74826. */
  74827. get useInvalidateRectOptimization(): boolean;
  74828. set useInvalidateRectOptimization(value: boolean);
  74829. private _invalidatedRectangle;
  74830. /**
  74831. * Invalidates a rectangle area on the gui texture
  74832. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74833. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74834. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74835. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74836. */
  74837. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74838. /**
  74839. * Marks the texture as dirty forcing a complete update
  74840. */
  74841. markAsDirty(): void;
  74842. /**
  74843. * Helper function used to create a new style
  74844. * @returns a new style
  74845. * @see http://doc.babylonjs.com/how_to/gui#styles
  74846. */
  74847. createStyle(): Style;
  74848. /**
  74849. * Adds a new control to the root container
  74850. * @param control defines the control to add
  74851. * @returns the current texture
  74852. */
  74853. addControl(control: Control): AdvancedDynamicTexture;
  74854. /**
  74855. * Removes a control from the root container
  74856. * @param control defines the control to remove
  74857. * @returns the current texture
  74858. */
  74859. removeControl(control: Control): AdvancedDynamicTexture;
  74860. /**
  74861. * Release all resources
  74862. */
  74863. dispose(): void;
  74864. private _onResize;
  74865. /** @hidden */
  74866. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74867. /**
  74868. * Get screen coordinates for a vector3
  74869. * @param position defines the position to project
  74870. * @param worldMatrix defines the world matrix to use
  74871. * @returns the projected position
  74872. */
  74873. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74874. private _checkUpdate;
  74875. private _clearMeasure;
  74876. private _render;
  74877. /** @hidden */
  74878. _changeCursor(cursor: string): void;
  74879. /** @hidden */
  74880. _registerLastControlDown(control: Control, pointerId: number): void;
  74881. private _doPicking;
  74882. /** @hidden */
  74883. _cleanControlAfterRemovalFromList(list: {
  74884. [pointerId: number]: Control;
  74885. }, control: Control): void;
  74886. /** @hidden */
  74887. _cleanControlAfterRemoval(control: Control): void;
  74888. /** Attach to all scene events required to support pointer events */
  74889. attach(): void;
  74890. /** @hidden */
  74891. private onClipboardCopy;
  74892. /** @hidden */
  74893. private onClipboardCut;
  74894. /** @hidden */
  74895. private onClipboardPaste;
  74896. /**
  74897. * Register the clipboard Events onto the canvas
  74898. */
  74899. registerClipboardEvents(): void;
  74900. /**
  74901. * Unregister the clipboard Events from the canvas
  74902. */
  74903. unRegisterClipboardEvents(): void;
  74904. /**
  74905. * Connect the texture to a hosting mesh to enable interactions
  74906. * @param mesh defines the mesh to attach to
  74907. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74908. */
  74909. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74910. /**
  74911. * Move the focus to a specific control
  74912. * @param control defines the control which will receive the focus
  74913. */
  74914. moveFocusToControl(control: IFocusableControl): void;
  74915. private _manageFocus;
  74916. private _attachToOnPointerOut;
  74917. /**
  74918. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74919. * @param mesh defines the mesh which will receive the texture
  74920. * @param width defines the texture width (1024 by default)
  74921. * @param height defines the texture height (1024 by default)
  74922. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74923. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74924. * @returns a new AdvancedDynamicTexture
  74925. */
  74926. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74927. /**
  74928. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74929. * In this mode the texture will rely on a layer for its rendering.
  74930. * This allows it to be treated like any other layer.
  74931. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74932. * LayerMask is set through advancedTexture.layer.layerMask
  74933. * @param name defines name for the texture
  74934. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74935. * @param scene defines the hsoting scene
  74936. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74937. * @returns a new AdvancedDynamicTexture
  74938. */
  74939. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74940. }
  74941. }
  74942. declare module BABYLON.GUI {
  74943. /**
  74944. * Root class used for all 2D controls
  74945. * @see http://doc.babylonjs.com/how_to/gui#controls
  74946. */
  74947. export class Control {
  74948. /** defines the name of the control */
  74949. name?: string | undefined;
  74950. /**
  74951. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74952. */
  74953. static AllowAlphaInheritance: boolean;
  74954. private _alpha;
  74955. private _alphaSet;
  74956. private _zIndex;
  74957. /** @hidden */
  74958. _host: AdvancedDynamicTexture;
  74959. /** Gets or sets the control parent */
  74960. parent: BABYLON.Nullable<Container>;
  74961. /** @hidden */
  74962. _currentMeasure: Measure;
  74963. private _fontFamily;
  74964. private _fontStyle;
  74965. private _fontWeight;
  74966. private _fontSize;
  74967. private _font;
  74968. /** @hidden */
  74969. _width: ValueAndUnit;
  74970. /** @hidden */
  74971. _height: ValueAndUnit;
  74972. /** @hidden */
  74973. protected _fontOffset: {
  74974. ascent: number;
  74975. height: number;
  74976. descent: number;
  74977. };
  74978. private _color;
  74979. private _style;
  74980. private _styleObserver;
  74981. /** @hidden */
  74982. protected _horizontalAlignment: number;
  74983. /** @hidden */
  74984. protected _verticalAlignment: number;
  74985. /** @hidden */
  74986. protected _isDirty: boolean;
  74987. /** @hidden */
  74988. protected _wasDirty: boolean;
  74989. /** @hidden */
  74990. _tempParentMeasure: Measure;
  74991. /** @hidden */
  74992. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74993. /** @hidden */
  74994. protected _cachedParentMeasure: Measure;
  74995. private _paddingLeft;
  74996. private _paddingRight;
  74997. private _paddingTop;
  74998. private _paddingBottom;
  74999. /** @hidden */
  75000. _left: ValueAndUnit;
  75001. /** @hidden */
  75002. _top: ValueAndUnit;
  75003. private _scaleX;
  75004. private _scaleY;
  75005. private _rotation;
  75006. private _transformCenterX;
  75007. private _transformCenterY;
  75008. /** @hidden */
  75009. _transformMatrix: Matrix2D;
  75010. /** @hidden */
  75011. protected _invertTransformMatrix: Matrix2D;
  75012. /** @hidden */
  75013. protected _transformedPosition: BABYLON.Vector2;
  75014. private _isMatrixDirty;
  75015. private _cachedOffsetX;
  75016. private _cachedOffsetY;
  75017. private _isVisible;
  75018. private _isHighlighted;
  75019. /** @hidden */
  75020. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  75021. private _fontSet;
  75022. private _dummyVector2;
  75023. private _downCount;
  75024. private _enterCount;
  75025. private _doNotRender;
  75026. private _downPointerIds;
  75027. protected _isEnabled: boolean;
  75028. protected _disabledColor: string;
  75029. protected _disabledColorItem: string;
  75030. /** @hidden */
  75031. protected _rebuildLayout: boolean;
  75032. /** @hidden */
  75033. _customData: any;
  75034. /** @hidden */
  75035. _isClipped: boolean;
  75036. /** @hidden */
  75037. _automaticSize: boolean;
  75038. /** @hidden */
  75039. _tag: any;
  75040. /**
  75041. * 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
  75042. */
  75043. uniqueId: number;
  75044. /**
  75045. * Gets or sets an object used to store user defined information for the node
  75046. */
  75047. metadata: any;
  75048. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  75049. isHitTestVisible: boolean;
  75050. /** Gets or sets a boolean indicating if the control can block pointer events */
  75051. isPointerBlocker: boolean;
  75052. /** Gets or sets a boolean indicating if the control can be focusable */
  75053. isFocusInvisible: boolean;
  75054. /**
  75055. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  75056. * 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
  75057. */
  75058. clipChildren: boolean;
  75059. /**
  75060. * Gets or sets a boolean indicating that control content must be clipped
  75061. * 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
  75062. */
  75063. clipContent: boolean;
  75064. /**
  75065. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  75066. */
  75067. useBitmapCache: boolean;
  75068. private _cacheData;
  75069. private _shadowOffsetX;
  75070. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  75071. get shadowOffsetX(): number;
  75072. set shadowOffsetX(value: number);
  75073. private _shadowOffsetY;
  75074. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  75075. get shadowOffsetY(): number;
  75076. set shadowOffsetY(value: number);
  75077. private _shadowBlur;
  75078. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  75079. get shadowBlur(): number;
  75080. set shadowBlur(value: number);
  75081. private _shadowColor;
  75082. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  75083. get shadowColor(): string;
  75084. set shadowColor(value: string);
  75085. /** Gets or sets the cursor to use when the control is hovered */
  75086. hoverCursor: string;
  75087. /** @hidden */
  75088. protected _linkOffsetX: ValueAndUnit;
  75089. /** @hidden */
  75090. protected _linkOffsetY: ValueAndUnit;
  75091. /** Gets the control type name */
  75092. get typeName(): string;
  75093. /**
  75094. * Get the current class name of the control.
  75095. * @returns current class name
  75096. */
  75097. getClassName(): string;
  75098. /**
  75099. * An event triggered when pointer wheel is scrolled
  75100. */
  75101. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  75102. /**
  75103. * An event triggered when the pointer move over the control.
  75104. */
  75105. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  75106. /**
  75107. * An event triggered when the pointer move out of the control.
  75108. */
  75109. onPointerOutObservable: BABYLON.Observable<Control>;
  75110. /**
  75111. * An event triggered when the pointer taps the control
  75112. */
  75113. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  75114. /**
  75115. * An event triggered when pointer up
  75116. */
  75117. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  75118. /**
  75119. * An event triggered when a control is clicked on
  75120. */
  75121. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  75122. /**
  75123. * An event triggered when pointer enters the control
  75124. */
  75125. onPointerEnterObservable: BABYLON.Observable<Control>;
  75126. /**
  75127. * An event triggered when the control is marked as dirty
  75128. */
  75129. onDirtyObservable: BABYLON.Observable<Control>;
  75130. /**
  75131. * An event triggered before drawing the control
  75132. */
  75133. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75134. /**
  75135. * An event triggered after the control was drawn
  75136. */
  75137. onAfterDrawObservable: BABYLON.Observable<Control>;
  75138. /**
  75139. * An event triggered when the control has been disposed
  75140. */
  75141. onDisposeObservable: BABYLON.Observable<Control>;
  75142. /**
  75143. * Get the hosting AdvancedDynamicTexture
  75144. */
  75145. get host(): AdvancedDynamicTexture;
  75146. /** Gets or set information about font offsets (used to render and align text) */
  75147. get fontOffset(): {
  75148. ascent: number;
  75149. height: number;
  75150. descent: number;
  75151. };
  75152. set fontOffset(offset: {
  75153. ascent: number;
  75154. height: number;
  75155. descent: number;
  75156. });
  75157. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75158. get alpha(): number;
  75159. set alpha(value: number);
  75160. /**
  75161. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75162. */
  75163. get isHighlighted(): boolean;
  75164. set isHighlighted(value: boolean);
  75165. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75166. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75167. */
  75168. get scaleX(): number;
  75169. set scaleX(value: number);
  75170. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75171. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75172. */
  75173. get scaleY(): number;
  75174. set scaleY(value: number);
  75175. /** Gets or sets the rotation angle (0 by default)
  75176. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75177. */
  75178. get rotation(): number;
  75179. set rotation(value: number);
  75180. /** Gets or sets the transformation center on Y axis (0 by default)
  75181. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75182. */
  75183. get transformCenterY(): number;
  75184. set transformCenterY(value: number);
  75185. /** Gets or sets the transformation center on X axis (0 by default)
  75186. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75187. */
  75188. get transformCenterX(): number;
  75189. set transformCenterX(value: number);
  75190. /**
  75191. * Gets or sets the horizontal alignment
  75192. * @see http://doc.babylonjs.com/how_to/gui#alignments
  75193. */
  75194. get horizontalAlignment(): number;
  75195. set horizontalAlignment(value: number);
  75196. /**
  75197. * Gets or sets the vertical alignment
  75198. * @see http://doc.babylonjs.com/how_to/gui#alignments
  75199. */
  75200. get verticalAlignment(): number;
  75201. set verticalAlignment(value: number);
  75202. /**
  75203. * Gets or sets control width
  75204. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75205. */
  75206. get width(): string | number;
  75207. set width(value: string | number);
  75208. /**
  75209. * Gets or sets the control width in pixel
  75210. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75211. */
  75212. get widthInPixels(): number;
  75213. set widthInPixels(value: number);
  75214. /**
  75215. * Gets or sets control height
  75216. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75217. */
  75218. get height(): string | number;
  75219. set height(value: string | number);
  75220. /**
  75221. * Gets or sets control height in pixel
  75222. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75223. */
  75224. get heightInPixels(): number;
  75225. set heightInPixels(value: number);
  75226. /** Gets or set font family */
  75227. get fontFamily(): string;
  75228. set fontFamily(value: string);
  75229. /** Gets or sets font style */
  75230. get fontStyle(): string;
  75231. set fontStyle(value: string);
  75232. /** Gets or sets font weight */
  75233. get fontWeight(): string;
  75234. set fontWeight(value: string);
  75235. /**
  75236. * Gets or sets style
  75237. * @see http://doc.babylonjs.com/how_to/gui#styles
  75238. */
  75239. get style(): BABYLON.Nullable<Style>;
  75240. set style(value: BABYLON.Nullable<Style>);
  75241. /** @hidden */
  75242. get _isFontSizeInPercentage(): boolean;
  75243. /** Gets or sets font size in pixels */
  75244. get fontSizeInPixels(): number;
  75245. set fontSizeInPixels(value: number);
  75246. /** Gets or sets font size */
  75247. get fontSize(): string | number;
  75248. set fontSize(value: string | number);
  75249. /** Gets or sets foreground color */
  75250. get color(): string;
  75251. set color(value: string);
  75252. /** Gets or sets z index which is used to reorder controls on the z axis */
  75253. get zIndex(): number;
  75254. set zIndex(value: number);
  75255. /** Gets or sets a boolean indicating if the control can be rendered */
  75256. get notRenderable(): boolean;
  75257. set notRenderable(value: boolean);
  75258. /** Gets or sets a boolean indicating if the control is visible */
  75259. get isVisible(): boolean;
  75260. set isVisible(value: boolean);
  75261. /** Gets a boolean indicating that the control needs to update its rendering */
  75262. get isDirty(): boolean;
  75263. /**
  75264. * Gets the current linked mesh (or null if none)
  75265. */
  75266. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75267. /**
  75268. * Gets or sets a value indicating the padding to use on the left of the control
  75269. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75270. */
  75271. get paddingLeft(): string | number;
  75272. set paddingLeft(value: string | number);
  75273. /**
  75274. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75275. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75276. */
  75277. get paddingLeftInPixels(): number;
  75278. set paddingLeftInPixels(value: number);
  75279. /**
  75280. * Gets or sets a value indicating the padding to use on the right of the control
  75281. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75282. */
  75283. get paddingRight(): string | number;
  75284. set paddingRight(value: string | number);
  75285. /**
  75286. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75287. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75288. */
  75289. get paddingRightInPixels(): number;
  75290. set paddingRightInPixels(value: number);
  75291. /**
  75292. * Gets or sets a value indicating the padding to use on the top of the control
  75293. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75294. */
  75295. get paddingTop(): string | number;
  75296. set paddingTop(value: string | number);
  75297. /**
  75298. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75299. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75300. */
  75301. get paddingTopInPixels(): number;
  75302. set paddingTopInPixels(value: number);
  75303. /**
  75304. * Gets or sets a value indicating the padding to use on the bottom of the control
  75305. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75306. */
  75307. get paddingBottom(): string | number;
  75308. set paddingBottom(value: string | number);
  75309. /**
  75310. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75311. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75312. */
  75313. get paddingBottomInPixels(): number;
  75314. set paddingBottomInPixels(value: number);
  75315. /**
  75316. * Gets or sets a value indicating the left coordinate of the control
  75317. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75318. */
  75319. get left(): string | number;
  75320. set left(value: string | number);
  75321. /**
  75322. * Gets or sets a value indicating the left coordinate in pixels of the control
  75323. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75324. */
  75325. get leftInPixels(): number;
  75326. set leftInPixels(value: number);
  75327. /**
  75328. * Gets or sets a value indicating the top coordinate of the control
  75329. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75330. */
  75331. get top(): string | number;
  75332. set top(value: string | number);
  75333. /**
  75334. * Gets or sets a value indicating the top coordinate in pixels of the control
  75335. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75336. */
  75337. get topInPixels(): number;
  75338. set topInPixels(value: number);
  75339. /**
  75340. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75341. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75342. */
  75343. get linkOffsetX(): string | number;
  75344. set linkOffsetX(value: string | number);
  75345. /**
  75346. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75347. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75348. */
  75349. get linkOffsetXInPixels(): number;
  75350. set linkOffsetXInPixels(value: number);
  75351. /**
  75352. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75353. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75354. */
  75355. get linkOffsetY(): string | number;
  75356. set linkOffsetY(value: string | number);
  75357. /**
  75358. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75359. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75360. */
  75361. get linkOffsetYInPixels(): number;
  75362. set linkOffsetYInPixels(value: number);
  75363. /** Gets the center coordinate on X axis */
  75364. get centerX(): number;
  75365. /** Gets the center coordinate on Y axis */
  75366. get centerY(): number;
  75367. /** Gets or sets if control is Enabled*/
  75368. get isEnabled(): boolean;
  75369. set isEnabled(value: boolean);
  75370. /** Gets or sets background color of control if it's disabled*/
  75371. get disabledColor(): string;
  75372. set disabledColor(value: string);
  75373. /** Gets or sets front color of control if it's disabled*/
  75374. get disabledColorItem(): string;
  75375. set disabledColorItem(value: string);
  75376. /**
  75377. * Creates a new control
  75378. * @param name defines the name of the control
  75379. */
  75380. constructor(
  75381. /** defines the name of the control */
  75382. name?: string | undefined);
  75383. /** @hidden */
  75384. protected _getTypeName(): string;
  75385. /**
  75386. * Gets the first ascendant in the hierarchy of the given type
  75387. * @param className defines the required type
  75388. * @returns the ascendant or null if not found
  75389. */
  75390. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75391. /** @hidden */
  75392. _resetFontCache(): void;
  75393. /**
  75394. * Determines if a container is an ascendant of the current control
  75395. * @param container defines the container to look for
  75396. * @returns true if the container is one of the ascendant of the control
  75397. */
  75398. isAscendant(container: Control): boolean;
  75399. /**
  75400. * Gets coordinates in local control space
  75401. * @param globalCoordinates defines the coordinates to transform
  75402. * @returns the new coordinates in local space
  75403. */
  75404. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75405. /**
  75406. * Gets coordinates in local control space
  75407. * @param globalCoordinates defines the coordinates to transform
  75408. * @param result defines the target vector2 where to store the result
  75409. * @returns the current control
  75410. */
  75411. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75412. /**
  75413. * Gets coordinates in parent local control space
  75414. * @param globalCoordinates defines the coordinates to transform
  75415. * @returns the new coordinates in parent local space
  75416. */
  75417. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75418. /**
  75419. * Move the current control to a vector3 position projected onto the screen.
  75420. * @param position defines the target position
  75421. * @param scene defines the hosting scene
  75422. */
  75423. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75424. /**
  75425. * Will store all controls that have this control as ascendant in a given array
  75426. * @param results defines the array where to store the descendants
  75427. * @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
  75428. * @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
  75429. */
  75430. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75431. /**
  75432. * Will return all controls that have this control as ascendant
  75433. * @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
  75434. * @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
  75435. * @return all child controls
  75436. */
  75437. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75438. /**
  75439. * Link current control with a target mesh
  75440. * @param mesh defines the mesh to link with
  75441. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75442. */
  75443. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75444. /** @hidden */
  75445. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75446. /** @hidden */
  75447. _offsetLeft(offset: number): void;
  75448. /** @hidden */
  75449. _offsetTop(offset: number): void;
  75450. /** @hidden */
  75451. _markMatrixAsDirty(): void;
  75452. /** @hidden */
  75453. _flagDescendantsAsMatrixDirty(): void;
  75454. /** @hidden */
  75455. _intersectsRect(rect: Measure): boolean;
  75456. /** @hidden */
  75457. protected invalidateRect(): void;
  75458. /** @hidden */
  75459. _markAsDirty(force?: boolean): void;
  75460. /** @hidden */
  75461. _markAllAsDirty(): void;
  75462. /** @hidden */
  75463. _link(host: AdvancedDynamicTexture): void;
  75464. /** @hidden */
  75465. protected _transform(context?: CanvasRenderingContext2D): void;
  75466. /** @hidden */
  75467. _renderHighlight(context: CanvasRenderingContext2D): void;
  75468. /** @hidden */
  75469. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75470. /** @hidden */
  75471. protected _applyStates(context: CanvasRenderingContext2D): void;
  75472. /** @hidden */
  75473. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75474. /** @hidden */
  75475. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75476. protected _evaluateClippingState(parentMeasure: Measure): void;
  75477. /** @hidden */
  75478. _measure(): void;
  75479. /** @hidden */
  75480. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75481. /** @hidden */
  75482. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75483. /** @hidden */
  75484. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75485. /** @hidden */
  75486. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75487. private static _ClipMeasure;
  75488. private _tmpMeasureA;
  75489. private _clip;
  75490. /** @hidden */
  75491. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75492. /** @hidden */
  75493. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75494. /**
  75495. * Tests if a given coordinates belong to the current control
  75496. * @param x defines x coordinate to test
  75497. * @param y defines y coordinate to test
  75498. * @returns true if the coordinates are inside the control
  75499. */
  75500. contains(x: number, y: number): boolean;
  75501. /** @hidden */
  75502. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75503. /** @hidden */
  75504. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75505. /** @hidden */
  75506. _onPointerEnter(target: Control): boolean;
  75507. /** @hidden */
  75508. _onPointerOut(target: Control, force?: boolean): void;
  75509. /** @hidden */
  75510. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75511. /** @hidden */
  75512. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75513. /** @hidden */
  75514. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75515. /** @hidden */
  75516. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75517. /** @hidden */
  75518. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75519. private _prepareFont;
  75520. /** Releases associated resources */
  75521. dispose(): void;
  75522. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75523. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75524. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75525. private static _VERTICAL_ALIGNMENT_TOP;
  75526. private static _VERTICAL_ALIGNMENT_BOTTOM;
  75527. private static _VERTICAL_ALIGNMENT_CENTER;
  75528. /** HORIZONTAL_ALIGNMENT_LEFT */
  75529. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  75530. /** HORIZONTAL_ALIGNMENT_RIGHT */
  75531. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  75532. /** HORIZONTAL_ALIGNMENT_CENTER */
  75533. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  75534. /** VERTICAL_ALIGNMENT_TOP */
  75535. static get VERTICAL_ALIGNMENT_TOP(): number;
  75536. /** VERTICAL_ALIGNMENT_BOTTOM */
  75537. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  75538. /** VERTICAL_ALIGNMENT_CENTER */
  75539. static get VERTICAL_ALIGNMENT_CENTER(): number;
  75540. private static _FontHeightSizes;
  75541. /** @hidden */
  75542. static _GetFontOffset(font: string): {
  75543. ascent: number;
  75544. height: number;
  75545. descent: number;
  75546. };
  75547. /**
  75548. * Creates a stack panel that can be used to render headers
  75549. * @param control defines the control to associate with the header
  75550. * @param text defines the text of the header
  75551. * @param size defines the size of the header
  75552. * @param options defines options used to configure the header
  75553. * @returns a new StackPanel
  75554. * @ignore
  75555. * @hidden
  75556. */
  75557. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75558. isHorizontal: boolean;
  75559. controlFirst: boolean;
  75560. }) => any;
  75561. /** @hidden */
  75562. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75563. }
  75564. }
  75565. declare module BABYLON.GUI {
  75566. /**
  75567. * Root class for 2D containers
  75568. * @see http://doc.babylonjs.com/how_to/gui#containers
  75569. */
  75570. export class Container extends Control {
  75571. name?: string | undefined;
  75572. /** @hidden */
  75573. _children: Control[];
  75574. /** @hidden */
  75575. protected _measureForChildren: Measure;
  75576. /** @hidden */
  75577. protected _background: string;
  75578. /** @hidden */
  75579. protected _adaptWidthToChildren: boolean;
  75580. /** @hidden */
  75581. protected _adaptHeightToChildren: boolean;
  75582. /**
  75583. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  75584. */
  75585. logLayoutCycleErrors: boolean;
  75586. /**
  75587. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  75588. */
  75589. maxLayoutCycle: number;
  75590. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  75591. get adaptHeightToChildren(): boolean;
  75592. set adaptHeightToChildren(value: boolean);
  75593. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  75594. get adaptWidthToChildren(): boolean;
  75595. set adaptWidthToChildren(value: boolean);
  75596. /** Gets or sets background color */
  75597. get background(): string;
  75598. set background(value: string);
  75599. /** Gets the list of children */
  75600. get children(): Control[];
  75601. /**
  75602. * Creates a new Container
  75603. * @param name defines the name of the container
  75604. */
  75605. constructor(name?: string | undefined);
  75606. protected _getTypeName(): string;
  75607. _flagDescendantsAsMatrixDirty(): void;
  75608. /**
  75609. * Gets a child using its name
  75610. * @param name defines the child name to look for
  75611. * @returns the child control if found
  75612. */
  75613. getChildByName(name: string): BABYLON.Nullable<Control>;
  75614. /**
  75615. * Gets a child using its type and its name
  75616. * @param name defines the child name to look for
  75617. * @param type defines the child type to look for
  75618. * @returns the child control if found
  75619. */
  75620. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  75621. /**
  75622. * Search for a specific control in children
  75623. * @param control defines the control to look for
  75624. * @returns true if the control is in child list
  75625. */
  75626. containsControl(control: Control): boolean;
  75627. /**
  75628. * Adds a new control to the current container
  75629. * @param control defines the control to add
  75630. * @returns the current container
  75631. */
  75632. addControl(control: BABYLON.Nullable<Control>): Container;
  75633. /**
  75634. * Removes all controls from the current container
  75635. * @returns the current container
  75636. */
  75637. clearControls(): Container;
  75638. /**
  75639. * Removes a control from the current container
  75640. * @param control defines the control to remove
  75641. * @returns the current container
  75642. */
  75643. removeControl(control: Control): Container;
  75644. /** @hidden */
  75645. _reOrderControl(control: Control): void;
  75646. /** @hidden */
  75647. _offsetLeft(offset: number): void;
  75648. /** @hidden */
  75649. _offsetTop(offset: number): void;
  75650. /** @hidden */
  75651. _markAllAsDirty(): void;
  75652. /** @hidden */
  75653. protected _localDraw(context: CanvasRenderingContext2D): void;
  75654. /** @hidden */
  75655. _link(host: AdvancedDynamicTexture): void;
  75656. /** @hidden */
  75657. protected _beforeLayout(): void;
  75658. /** @hidden */
  75659. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75660. /** @hidden */
  75661. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75662. protected _postMeasure(): void;
  75663. /** @hidden */
  75664. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75665. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75666. /** @hidden */
  75667. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75668. /** @hidden */
  75669. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75670. /** Releases associated resources */
  75671. dispose(): void;
  75672. }
  75673. }
  75674. declare module BABYLON.GUI {
  75675. /** Class used to create rectangle container */
  75676. export class Rectangle extends Container {
  75677. name?: string | undefined;
  75678. private _thickness;
  75679. private _cornerRadius;
  75680. /** Gets or sets border thickness */
  75681. get thickness(): number;
  75682. set thickness(value: number);
  75683. /** Gets or sets the corner radius angle */
  75684. get cornerRadius(): number;
  75685. set cornerRadius(value: number);
  75686. /**
  75687. * Creates a new Rectangle
  75688. * @param name defines the control name
  75689. */
  75690. constructor(name?: string | undefined);
  75691. protected _getTypeName(): string;
  75692. protected _localDraw(context: CanvasRenderingContext2D): void;
  75693. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75694. private _drawRoundedRect;
  75695. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75696. }
  75697. }
  75698. declare module BABYLON.GUI {
  75699. /**
  75700. * Enum that determines the text-wrapping mode to use.
  75701. */
  75702. export enum TextWrapping {
  75703. /**
  75704. * Clip the text when it's larger than Control.width; this is the default mode.
  75705. */
  75706. Clip = 0,
  75707. /**
  75708. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  75709. */
  75710. WordWrap = 1,
  75711. /**
  75712. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  75713. */
  75714. Ellipsis = 2
  75715. }
  75716. /**
  75717. * Class used to create text block control
  75718. */
  75719. export class TextBlock extends Control {
  75720. /**
  75721. * Defines the name of the control
  75722. */
  75723. name?: string | undefined;
  75724. private _text;
  75725. private _textWrapping;
  75726. private _textHorizontalAlignment;
  75727. private _textVerticalAlignment;
  75728. private _lines;
  75729. private _resizeToFit;
  75730. private _lineSpacing;
  75731. private _outlineWidth;
  75732. private _outlineColor;
  75733. /**
  75734. * An event triggered after the text is changed
  75735. */
  75736. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  75737. /**
  75738. * An event triggered after the text was broken up into lines
  75739. */
  75740. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  75741. /**
  75742. * Function used to split a string into words. By default, a string is split at each space character found
  75743. */
  75744. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  75745. /**
  75746. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  75747. */
  75748. get lines(): any[];
  75749. /**
  75750. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75751. */
  75752. get resizeToFit(): boolean;
  75753. /**
  75754. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75755. */
  75756. set resizeToFit(value: boolean);
  75757. /**
  75758. * Gets or sets a boolean indicating if text must be wrapped
  75759. */
  75760. get textWrapping(): TextWrapping | boolean;
  75761. /**
  75762. * Gets or sets a boolean indicating if text must be wrapped
  75763. */
  75764. set textWrapping(value: TextWrapping | boolean);
  75765. /**
  75766. * Gets or sets text to display
  75767. */
  75768. get text(): string;
  75769. /**
  75770. * Gets or sets text to display
  75771. */
  75772. set text(value: string);
  75773. /**
  75774. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75775. */
  75776. get textHorizontalAlignment(): number;
  75777. /**
  75778. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75779. */
  75780. set textHorizontalAlignment(value: number);
  75781. /**
  75782. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75783. */
  75784. get textVerticalAlignment(): number;
  75785. /**
  75786. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75787. */
  75788. set textVerticalAlignment(value: number);
  75789. /**
  75790. * Gets or sets line spacing value
  75791. */
  75792. set lineSpacing(value: string | number);
  75793. /**
  75794. * Gets or sets line spacing value
  75795. */
  75796. get lineSpacing(): string | number;
  75797. /**
  75798. * Gets or sets outlineWidth of the text to display
  75799. */
  75800. get outlineWidth(): number;
  75801. /**
  75802. * Gets or sets outlineWidth of the text to display
  75803. */
  75804. set outlineWidth(value: number);
  75805. /**
  75806. * Gets or sets outlineColor of the text to display
  75807. */
  75808. get outlineColor(): string;
  75809. /**
  75810. * Gets or sets outlineColor of the text to display
  75811. */
  75812. set outlineColor(value: string);
  75813. /**
  75814. * Creates a new TextBlock object
  75815. * @param name defines the name of the control
  75816. * @param text defines the text to display (emptry string by default)
  75817. */
  75818. constructor(
  75819. /**
  75820. * Defines the name of the control
  75821. */
  75822. name?: string | undefined, text?: string);
  75823. protected _getTypeName(): string;
  75824. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75825. private _drawText;
  75826. /** @hidden */
  75827. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75828. protected _applyStates(context: CanvasRenderingContext2D): void;
  75829. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75830. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75831. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75832. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75833. protected _renderLines(context: CanvasRenderingContext2D): void;
  75834. /**
  75835. * Given a width constraint applied on the text block, find the expected height
  75836. * @returns expected height
  75837. */
  75838. computeExpectedHeight(): number;
  75839. dispose(): void;
  75840. }
  75841. }
  75842. declare module BABYLON.GUI {
  75843. /**
  75844. * Class used to create 2D images
  75845. */
  75846. export class Image extends Control {
  75847. name?: string | undefined;
  75848. private _workingCanvas;
  75849. private _domImage;
  75850. private _imageWidth;
  75851. private _imageHeight;
  75852. private _loaded;
  75853. private _stretch;
  75854. private _source;
  75855. private _autoScale;
  75856. private _sourceLeft;
  75857. private _sourceTop;
  75858. private _sourceWidth;
  75859. private _sourceHeight;
  75860. private _svgAttributesComputationCompleted;
  75861. private _isSVG;
  75862. private _cellWidth;
  75863. private _cellHeight;
  75864. private _cellId;
  75865. private _populateNinePatchSlicesFromImage;
  75866. private _sliceLeft;
  75867. private _sliceRight;
  75868. private _sliceTop;
  75869. private _sliceBottom;
  75870. private _detectPointerOnOpaqueOnly;
  75871. /**
  75872. * BABYLON.Observable notified when the content is loaded
  75873. */
  75874. onImageLoadedObservable: BABYLON.Observable<Image>;
  75875. /**
  75876. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75877. */
  75878. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75879. /**
  75880. * Gets a boolean indicating that the content is loaded
  75881. */
  75882. get isLoaded(): boolean;
  75883. /**
  75884. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75885. */
  75886. get populateNinePatchSlicesFromImage(): boolean;
  75887. set populateNinePatchSlicesFromImage(value: boolean);
  75888. /**
  75889. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75890. * Beware using this as this will comsume more memory as the image has to be stored twice
  75891. */
  75892. get detectPointerOnOpaqueOnly(): boolean;
  75893. set detectPointerOnOpaqueOnly(value: boolean);
  75894. /**
  75895. * Gets or sets the left value for slicing (9-patch)
  75896. */
  75897. get sliceLeft(): number;
  75898. set sliceLeft(value: number);
  75899. /**
  75900. * Gets or sets the right value for slicing (9-patch)
  75901. */
  75902. get sliceRight(): number;
  75903. set sliceRight(value: number);
  75904. /**
  75905. * Gets or sets the top value for slicing (9-patch)
  75906. */
  75907. get sliceTop(): number;
  75908. set sliceTop(value: number);
  75909. /**
  75910. * Gets or sets the bottom value for slicing (9-patch)
  75911. */
  75912. get sliceBottom(): number;
  75913. set sliceBottom(value: number);
  75914. /**
  75915. * Gets or sets the left coordinate in the source image
  75916. */
  75917. get sourceLeft(): number;
  75918. set sourceLeft(value: number);
  75919. /**
  75920. * Gets or sets the top coordinate in the source image
  75921. */
  75922. get sourceTop(): number;
  75923. set sourceTop(value: number);
  75924. /**
  75925. * Gets or sets the width to capture in the source image
  75926. */
  75927. get sourceWidth(): number;
  75928. set sourceWidth(value: number);
  75929. /**
  75930. * Gets or sets the height to capture in the source image
  75931. */
  75932. get sourceHeight(): number;
  75933. set sourceHeight(value: number);
  75934. /** Indicates if the format of the image is SVG */
  75935. get isSVG(): boolean;
  75936. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75937. get svgAttributesComputationCompleted(): boolean;
  75938. /**
  75939. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75940. * @see http://doc.babylonjs.com/how_to/gui#image
  75941. */
  75942. get autoScale(): boolean;
  75943. set autoScale(value: boolean);
  75944. /** Gets or sets the streching mode used by the image */
  75945. get stretch(): number;
  75946. set stretch(value: number);
  75947. /** @hidden */
  75948. _rotate90(n: number, preserveProperties?: boolean): Image;
  75949. private _handleRotationForSVGImage;
  75950. private _rotate90SourceProperties;
  75951. /**
  75952. * Gets or sets the internal DOM image used to render the control
  75953. */
  75954. set domImage(value: HTMLImageElement);
  75955. get domImage(): HTMLImageElement;
  75956. private _onImageLoaded;
  75957. private _extractNinePatchSliceDataFromImage;
  75958. /**
  75959. * Gets or sets image source url
  75960. */
  75961. set source(value: BABYLON.Nullable<string>);
  75962. /**
  75963. * Checks for svg document with icon id present
  75964. */
  75965. private _svgCheck;
  75966. /**
  75967. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75968. * given external svg file and icon id
  75969. */
  75970. private _getSVGAttribs;
  75971. /**
  75972. * Gets or sets the cell width to use when animation sheet is enabled
  75973. * @see http://doc.babylonjs.com/how_to/gui#image
  75974. */
  75975. get cellWidth(): number;
  75976. set cellWidth(value: number);
  75977. /**
  75978. * Gets or sets the cell height to use when animation sheet is enabled
  75979. * @see http://doc.babylonjs.com/how_to/gui#image
  75980. */
  75981. get cellHeight(): number;
  75982. set cellHeight(value: number);
  75983. /**
  75984. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75985. * @see http://doc.babylonjs.com/how_to/gui#image
  75986. */
  75987. get cellId(): number;
  75988. set cellId(value: number);
  75989. /**
  75990. * Creates a new Image
  75991. * @param name defines the control name
  75992. * @param url defines the image url
  75993. */
  75994. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75995. /**
  75996. * Tests if a given coordinates belong to the current control
  75997. * @param x defines x coordinate to test
  75998. * @param y defines y coordinate to test
  75999. * @returns true if the coordinates are inside the control
  76000. */
  76001. contains(x: number, y: number): boolean;
  76002. protected _getTypeName(): string;
  76003. /** Force the control to synchronize with its content */
  76004. synchronizeSizeWithContent(): void;
  76005. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76006. private _prepareWorkingCanvasForOpaqueDetection;
  76007. private _drawImage;
  76008. _draw(context: CanvasRenderingContext2D): void;
  76009. private _renderCornerPatch;
  76010. private _renderNinePatch;
  76011. dispose(): void;
  76012. /** STRETCH_NONE */
  76013. static readonly STRETCH_NONE: number;
  76014. /** STRETCH_FILL */
  76015. static readonly STRETCH_FILL: number;
  76016. /** STRETCH_UNIFORM */
  76017. static readonly STRETCH_UNIFORM: number;
  76018. /** STRETCH_EXTEND */
  76019. static readonly STRETCH_EXTEND: number;
  76020. /** NINE_PATCH */
  76021. static readonly STRETCH_NINE_PATCH: number;
  76022. }
  76023. }
  76024. declare module BABYLON.GUI {
  76025. /**
  76026. * Class used to create 2D buttons
  76027. */
  76028. export class Button extends Rectangle {
  76029. name?: string | undefined;
  76030. /**
  76031. * Function called to generate a pointer enter animation
  76032. */
  76033. pointerEnterAnimation: () => void;
  76034. /**
  76035. * Function called to generate a pointer out animation
  76036. */
  76037. pointerOutAnimation: () => void;
  76038. /**
  76039. * Function called to generate a pointer down animation
  76040. */
  76041. pointerDownAnimation: () => void;
  76042. /**
  76043. * Function called to generate a pointer up animation
  76044. */
  76045. pointerUpAnimation: () => void;
  76046. /**
  76047. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  76048. */
  76049. delegatePickingToChildren: boolean;
  76050. private _image;
  76051. /**
  76052. * Returns the image part of the button (if any)
  76053. */
  76054. get image(): BABYLON.Nullable<Image>;
  76055. private _textBlock;
  76056. /**
  76057. * Returns the image part of the button (if any)
  76058. */
  76059. get textBlock(): BABYLON.Nullable<TextBlock>;
  76060. /**
  76061. * Creates a new Button
  76062. * @param name defines the name of the button
  76063. */
  76064. constructor(name?: string | undefined);
  76065. protected _getTypeName(): string;
  76066. /** @hidden */
  76067. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76068. /** @hidden */
  76069. _onPointerEnter(target: Control): boolean;
  76070. /** @hidden */
  76071. _onPointerOut(target: Control, force?: boolean): void;
  76072. /** @hidden */
  76073. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76074. /** @hidden */
  76075. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76076. /**
  76077. * Creates a new button made with an image and a text
  76078. * @param name defines the name of the button
  76079. * @param text defines the text of the button
  76080. * @param imageUrl defines the url of the image
  76081. * @returns a new Button
  76082. */
  76083. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  76084. /**
  76085. * Creates a new button made with an image
  76086. * @param name defines the name of the button
  76087. * @param imageUrl defines the url of the image
  76088. * @returns a new Button
  76089. */
  76090. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  76091. /**
  76092. * Creates a new button made with a text
  76093. * @param name defines the name of the button
  76094. * @param text defines the text of the button
  76095. * @returns a new Button
  76096. */
  76097. static CreateSimpleButton(name: string, text: string): Button;
  76098. /**
  76099. * Creates a new button made with an image and a centered text
  76100. * @param name defines the name of the button
  76101. * @param text defines the text of the button
  76102. * @param imageUrl defines the url of the image
  76103. * @returns a new Button
  76104. */
  76105. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  76106. }
  76107. }
  76108. declare module BABYLON.GUI {
  76109. /**
  76110. * Class used to create a 2D stack panel container
  76111. */
  76112. export class StackPanel extends Container {
  76113. name?: string | undefined;
  76114. private _isVertical;
  76115. private _manualWidth;
  76116. private _manualHeight;
  76117. private _doNotTrackManualChanges;
  76118. /**
  76119. * Gets or sets a boolean indicating that layou warnings should be ignored
  76120. */
  76121. ignoreLayoutWarnings: boolean;
  76122. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  76123. get isVertical(): boolean;
  76124. set isVertical(value: boolean);
  76125. /**
  76126. * Gets or sets panel width.
  76127. * This value should not be set when in horizontal mode as it will be computed automatically
  76128. */
  76129. set width(value: string | number);
  76130. get width(): string | number;
  76131. /**
  76132. * Gets or sets panel height.
  76133. * This value should not be set when in vertical mode as it will be computed automatically
  76134. */
  76135. set height(value: string | number);
  76136. get height(): string | number;
  76137. /**
  76138. * Creates a new StackPanel
  76139. * @param name defines control name
  76140. */
  76141. constructor(name?: string | undefined);
  76142. protected _getTypeName(): string;
  76143. /** @hidden */
  76144. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76145. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76146. protected _postMeasure(): void;
  76147. }
  76148. }
  76149. declare module BABYLON.GUI {
  76150. /**
  76151. * Class used to represent a 2D checkbox
  76152. */
  76153. export class Checkbox extends Control {
  76154. name?: string | undefined;
  76155. private _isChecked;
  76156. private _background;
  76157. private _checkSizeRatio;
  76158. private _thickness;
  76159. /** Gets or sets border thickness */
  76160. get thickness(): number;
  76161. set thickness(value: number);
  76162. /**
  76163. * BABYLON.Observable raised when isChecked property changes
  76164. */
  76165. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76166. /** Gets or sets a value indicating the ratio between overall size and check size */
  76167. get checkSizeRatio(): number;
  76168. set checkSizeRatio(value: number);
  76169. /** Gets or sets background color */
  76170. get background(): string;
  76171. set background(value: string);
  76172. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76173. get isChecked(): boolean;
  76174. set isChecked(value: boolean);
  76175. /**
  76176. * Creates a new CheckBox
  76177. * @param name defines the control name
  76178. */
  76179. constructor(name?: string | undefined);
  76180. protected _getTypeName(): string;
  76181. /** @hidden */
  76182. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76183. /** @hidden */
  76184. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76185. /**
  76186. * Utility function to easily create a checkbox with a header
  76187. * @param title defines the label to use for the header
  76188. * @param onValueChanged defines the callback to call when value changes
  76189. * @returns a StackPanel containing the checkbox and a textBlock
  76190. */
  76191. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76192. }
  76193. }
  76194. declare module BABYLON.GUI {
  76195. /**
  76196. * Class used to store key control properties
  76197. */
  76198. export class KeyPropertySet {
  76199. /** Width */
  76200. width?: string;
  76201. /** Height */
  76202. height?: string;
  76203. /** Left padding */
  76204. paddingLeft?: string;
  76205. /** Right padding */
  76206. paddingRight?: string;
  76207. /** Top padding */
  76208. paddingTop?: string;
  76209. /** Bottom padding */
  76210. paddingBottom?: string;
  76211. /** Foreground color */
  76212. color?: string;
  76213. /** Background color */
  76214. background?: string;
  76215. }
  76216. /**
  76217. * Class used to create virtual keyboard
  76218. */
  76219. export class VirtualKeyboard extends StackPanel {
  76220. /** BABYLON.Observable raised when a key is pressed */
  76221. onKeyPressObservable: BABYLON.Observable<string>;
  76222. /** Gets or sets default key button width */
  76223. defaultButtonWidth: string;
  76224. /** Gets or sets default key button height */
  76225. defaultButtonHeight: string;
  76226. /** Gets or sets default key button left padding */
  76227. defaultButtonPaddingLeft: string;
  76228. /** Gets or sets default key button right padding */
  76229. defaultButtonPaddingRight: string;
  76230. /** Gets or sets default key button top padding */
  76231. defaultButtonPaddingTop: string;
  76232. /** Gets or sets default key button bottom padding */
  76233. defaultButtonPaddingBottom: string;
  76234. /** Gets or sets default key button foreground color */
  76235. defaultButtonColor: string;
  76236. /** Gets or sets default key button background color */
  76237. defaultButtonBackground: string;
  76238. /** Gets or sets shift button foreground color */
  76239. shiftButtonColor: string;
  76240. /** Gets or sets shift button thickness*/
  76241. selectedShiftThickness: number;
  76242. /** Gets shift key state */
  76243. shiftState: number;
  76244. protected _getTypeName(): string;
  76245. private _createKey;
  76246. /**
  76247. * Adds a new row of keys
  76248. * @param keys defines the list of keys to add
  76249. * @param propertySets defines the associated property sets
  76250. */
  76251. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76252. /**
  76253. * Set the shift key to a specific state
  76254. * @param shiftState defines the new shift state
  76255. */
  76256. applyShiftState(shiftState: number): void;
  76257. private _currentlyConnectedInputText;
  76258. private _connectedInputTexts;
  76259. private _onKeyPressObserver;
  76260. /** Gets the input text control currently attached to the keyboard */
  76261. get connectedInputText(): BABYLON.Nullable<InputText>;
  76262. /**
  76263. * Connects the keyboard with an input text control
  76264. *
  76265. * @param input defines the target control
  76266. */
  76267. connect(input: InputText): void;
  76268. /**
  76269. * Disconnects the keyboard from connected InputText controls
  76270. *
  76271. * @param input optionally defines a target control, otherwise all are disconnected
  76272. */
  76273. disconnect(input?: InputText): void;
  76274. private _removeConnectedInputObservables;
  76275. /**
  76276. * Release all resources
  76277. */
  76278. dispose(): void;
  76279. /**
  76280. * Creates a new keyboard using a default layout
  76281. *
  76282. * @param name defines control name
  76283. * @returns a new VirtualKeyboard
  76284. */
  76285. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76286. }
  76287. }
  76288. declare module BABYLON.GUI {
  76289. /**
  76290. * Class used to create input text control
  76291. */
  76292. export class InputText extends Control implements IFocusableControl {
  76293. name?: string | undefined;
  76294. private _text;
  76295. private _placeholderText;
  76296. private _background;
  76297. private _focusedBackground;
  76298. private _focusedColor;
  76299. private _placeholderColor;
  76300. private _thickness;
  76301. private _margin;
  76302. private _autoStretchWidth;
  76303. private _maxWidth;
  76304. private _isFocused;
  76305. private _blinkTimeout;
  76306. private _blinkIsEven;
  76307. private _cursorOffset;
  76308. private _scrollLeft;
  76309. private _textWidth;
  76310. private _clickedCoordinate;
  76311. private _deadKey;
  76312. private _addKey;
  76313. private _currentKey;
  76314. private _isTextHighlightOn;
  76315. private _textHighlightColor;
  76316. private _highligherOpacity;
  76317. private _highlightedText;
  76318. private _startHighlightIndex;
  76319. private _endHighlightIndex;
  76320. private _cursorIndex;
  76321. private _onFocusSelectAll;
  76322. private _isPointerDown;
  76323. private _onClipboardObserver;
  76324. private _onPointerDblTapObserver;
  76325. /** @hidden */
  76326. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76327. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76328. promptMessage: string;
  76329. /** Force disable prompt on mobile device */
  76330. disableMobilePrompt: boolean;
  76331. /** BABYLON.Observable raised when the text changes */
  76332. onTextChangedObservable: BABYLON.Observable<InputText>;
  76333. /** BABYLON.Observable raised just before an entered character is to be added */
  76334. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76335. /** BABYLON.Observable raised when the control gets the focus */
  76336. onFocusObservable: BABYLON.Observable<InputText>;
  76337. /** BABYLON.Observable raised when the control loses the focus */
  76338. onBlurObservable: BABYLON.Observable<InputText>;
  76339. /**Observable raised when the text is highlighted */
  76340. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76341. /**Observable raised when copy event is triggered */
  76342. onTextCopyObservable: BABYLON.Observable<InputText>;
  76343. /** BABYLON.Observable raised when cut event is triggered */
  76344. onTextCutObservable: BABYLON.Observable<InputText>;
  76345. /** BABYLON.Observable raised when paste event is triggered */
  76346. onTextPasteObservable: BABYLON.Observable<InputText>;
  76347. /** BABYLON.Observable raised when a key event was processed */
  76348. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76349. /** Gets or sets the maximum width allowed by the control */
  76350. get maxWidth(): string | number;
  76351. /** Gets the maximum width allowed by the control in pixels */
  76352. get maxWidthInPixels(): number;
  76353. set maxWidth(value: string | number);
  76354. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76355. get highligherOpacity(): number;
  76356. set highligherOpacity(value: number);
  76357. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76358. get onFocusSelectAll(): boolean;
  76359. set onFocusSelectAll(value: boolean);
  76360. /** Gets or sets the text hightlight color */
  76361. get textHighlightColor(): string;
  76362. set textHighlightColor(value: string);
  76363. /** Gets or sets control margin */
  76364. get margin(): string;
  76365. /** Gets control margin in pixels */
  76366. get marginInPixels(): number;
  76367. set margin(value: string);
  76368. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76369. get autoStretchWidth(): boolean;
  76370. set autoStretchWidth(value: boolean);
  76371. /** Gets or sets border thickness */
  76372. get thickness(): number;
  76373. set thickness(value: number);
  76374. /** Gets or sets the background color when focused */
  76375. get focusedBackground(): string;
  76376. set focusedBackground(value: string);
  76377. /** Gets or sets the background color when focused */
  76378. get focusedColor(): string;
  76379. set focusedColor(value: string);
  76380. /** Gets or sets the background color */
  76381. get background(): string;
  76382. set background(value: string);
  76383. /** Gets or sets the placeholder color */
  76384. get placeholderColor(): string;
  76385. set placeholderColor(value: string);
  76386. /** Gets or sets the text displayed when the control is empty */
  76387. get placeholderText(): string;
  76388. set placeholderText(value: string);
  76389. /** Gets or sets the dead key flag */
  76390. get deadKey(): boolean;
  76391. set deadKey(flag: boolean);
  76392. /** Gets or sets the highlight text */
  76393. get highlightedText(): string;
  76394. set highlightedText(text: string);
  76395. /** Gets or sets if the current key should be added */
  76396. get addKey(): boolean;
  76397. set addKey(flag: boolean);
  76398. /** Gets or sets the value of the current key being entered */
  76399. get currentKey(): string;
  76400. set currentKey(key: string);
  76401. /** Gets or sets the text displayed in the control */
  76402. get text(): string;
  76403. set text(value: string);
  76404. /** Gets or sets control width */
  76405. get width(): string | number;
  76406. set width(value: string | number);
  76407. /**
  76408. * Creates a new InputText
  76409. * @param name defines the control name
  76410. * @param text defines the text of the control
  76411. */
  76412. constructor(name?: string | undefined, text?: string);
  76413. /** @hidden */
  76414. onBlur(): void;
  76415. /** @hidden */
  76416. onFocus(): void;
  76417. protected _getTypeName(): string;
  76418. /**
  76419. * Function called to get the list of controls that should not steal the focus from this control
  76420. * @returns an array of controls
  76421. */
  76422. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76423. /** @hidden */
  76424. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76425. /** @hidden */
  76426. private _updateValueFromCursorIndex;
  76427. /** @hidden */
  76428. private _processDblClick;
  76429. /** @hidden */
  76430. private _selectAllText;
  76431. /**
  76432. * Handles the keyboard event
  76433. * @param evt Defines the KeyboardEvent
  76434. */
  76435. processKeyboard(evt: KeyboardEvent): void;
  76436. /** @hidden */
  76437. private _onCopyText;
  76438. /** @hidden */
  76439. private _onCutText;
  76440. /** @hidden */
  76441. private _onPasteText;
  76442. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76443. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76444. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76445. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76446. protected _beforeRenderText(text: string): string;
  76447. dispose(): void;
  76448. }
  76449. }
  76450. declare module BABYLON.GUI {
  76451. /**
  76452. * Class used to create a 2D grid container
  76453. */
  76454. export class Grid extends Container {
  76455. name?: string | undefined;
  76456. private _rowDefinitions;
  76457. private _columnDefinitions;
  76458. private _cells;
  76459. private _childControls;
  76460. /**
  76461. * Gets the number of columns
  76462. */
  76463. get columnCount(): number;
  76464. /**
  76465. * Gets the number of rows
  76466. */
  76467. get rowCount(): number;
  76468. /** Gets the list of children */
  76469. get children(): Control[];
  76470. /** Gets the list of cells (e.g. the containers) */
  76471. get cells(): {
  76472. [key: string]: Container;
  76473. };
  76474. /**
  76475. * Gets the definition of a specific row
  76476. * @param index defines the index of the row
  76477. * @returns the row definition
  76478. */
  76479. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76480. /**
  76481. * Gets the definition of a specific column
  76482. * @param index defines the index of the column
  76483. * @returns the column definition
  76484. */
  76485. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76486. /**
  76487. * Adds a new row to the grid
  76488. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76489. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76490. * @returns the current grid
  76491. */
  76492. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76493. /**
  76494. * Adds a new column to the grid
  76495. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76496. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76497. * @returns the current grid
  76498. */
  76499. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76500. /**
  76501. * Update a row definition
  76502. * @param index defines the index of the row to update
  76503. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76504. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76505. * @returns the current grid
  76506. */
  76507. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76508. /**
  76509. * Update a column definition
  76510. * @param index defines the index of the column to update
  76511. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76512. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76513. * @returns the current grid
  76514. */
  76515. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76516. /**
  76517. * Gets the list of children stored in a specific cell
  76518. * @param row defines the row to check
  76519. * @param column defines the column to check
  76520. * @returns the list of controls
  76521. */
  76522. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76523. /**
  76524. * Gets a string representing the child cell info (row x column)
  76525. * @param child defines the control to get info from
  76526. * @returns a string containing the child cell info (row x column)
  76527. */
  76528. getChildCellInfo(child: Control): string;
  76529. private _removeCell;
  76530. private _offsetCell;
  76531. /**
  76532. * Remove a column definition at specified index
  76533. * @param index defines the index of the column to remove
  76534. * @returns the current grid
  76535. */
  76536. removeColumnDefinition(index: number): Grid;
  76537. /**
  76538. * Remove a row definition at specified index
  76539. * @param index defines the index of the row to remove
  76540. * @returns the current grid
  76541. */
  76542. removeRowDefinition(index: number): Grid;
  76543. /**
  76544. * Adds a new control to the current grid
  76545. * @param control defines the control to add
  76546. * @param row defines the row where to add the control (0 by default)
  76547. * @param column defines the column where to add the control (0 by default)
  76548. * @returns the current grid
  76549. */
  76550. addControl(control: Control, row?: number, column?: number): Grid;
  76551. /**
  76552. * Removes a control from the current container
  76553. * @param control defines the control to remove
  76554. * @returns the current container
  76555. */
  76556. removeControl(control: Control): Container;
  76557. /**
  76558. * Creates a new Grid
  76559. * @param name defines control name
  76560. */
  76561. constructor(name?: string | undefined);
  76562. protected _getTypeName(): string;
  76563. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76564. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76565. _flagDescendantsAsMatrixDirty(): void;
  76566. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76567. /** Releases associated resources */
  76568. dispose(): void;
  76569. }
  76570. }
  76571. declare module BABYLON.GUI {
  76572. /** Class used to create color pickers */
  76573. export class ColorPicker extends Control {
  76574. name?: string | undefined;
  76575. private static _Epsilon;
  76576. private _colorWheelCanvas;
  76577. private _value;
  76578. private _tmpColor;
  76579. private _pointerStartedOnSquare;
  76580. private _pointerStartedOnWheel;
  76581. private _squareLeft;
  76582. private _squareTop;
  76583. private _squareSize;
  76584. private _h;
  76585. private _s;
  76586. private _v;
  76587. private _lastPointerDownID;
  76588. /**
  76589. * BABYLON.Observable raised when the value changes
  76590. */
  76591. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  76592. /** Gets or sets the color of the color picker */
  76593. get value(): BABYLON.Color3;
  76594. set value(value: BABYLON.Color3);
  76595. /**
  76596. * Gets or sets control width
  76597. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76598. */
  76599. get width(): string | number;
  76600. set width(value: string | number);
  76601. /**
  76602. * Gets or sets control height
  76603. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76604. */
  76605. get height(): string | number;
  76606. /** Gets or sets control height */
  76607. set height(value: string | number);
  76608. /** Gets or sets control size */
  76609. get size(): string | number;
  76610. set size(value: string | number);
  76611. /**
  76612. * Creates a new ColorPicker
  76613. * @param name defines the control name
  76614. */
  76615. constructor(name?: string | undefined);
  76616. protected _getTypeName(): string;
  76617. /** @hidden */
  76618. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76619. private _updateSquareProps;
  76620. private _drawGradientSquare;
  76621. private _drawCircle;
  76622. private _createColorWheelCanvas;
  76623. /** @hidden */
  76624. _draw(context: CanvasRenderingContext2D): void;
  76625. private _pointerIsDown;
  76626. private _updateValueFromPointer;
  76627. private _isPointOnSquare;
  76628. private _isPointOnWheel;
  76629. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76630. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76631. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76632. /**
  76633. * This function expands the color picker by creating a color picker dialog with manual
  76634. * color value input and the ability to save colors into an array to be used later in
  76635. * subsequent launches of the dialogue.
  76636. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  76637. * @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.
  76638. * @returns picked color as a hex string and the saved colors array as hex strings.
  76639. */
  76640. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76641. pickerWidth?: string;
  76642. pickerHeight?: string;
  76643. headerHeight?: string;
  76644. lastColor?: string;
  76645. swatchLimit?: number;
  76646. numSwatchesPerLine?: number;
  76647. savedColors?: Array<string>;
  76648. }): Promise<{
  76649. savedColors?: string[];
  76650. pickedColor: string;
  76651. }>;
  76652. }
  76653. }
  76654. declare module BABYLON.GUI {
  76655. /** Class used to create 2D ellipse containers */
  76656. export class Ellipse extends Container {
  76657. name?: string | undefined;
  76658. private _thickness;
  76659. /** Gets or sets border thickness */
  76660. get thickness(): number;
  76661. set thickness(value: number);
  76662. /**
  76663. * Creates a new Ellipse
  76664. * @param name defines the control name
  76665. */
  76666. constructor(name?: string | undefined);
  76667. protected _getTypeName(): string;
  76668. protected _localDraw(context: CanvasRenderingContext2D): void;
  76669. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76670. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76671. }
  76672. }
  76673. declare module BABYLON.GUI {
  76674. /**
  76675. * Class used to create a password control
  76676. */
  76677. export class InputPassword extends InputText {
  76678. protected _beforeRenderText(text: string): string;
  76679. }
  76680. }
  76681. declare module BABYLON.GUI {
  76682. /** Class used to render 2D lines */
  76683. export class Line extends Control {
  76684. name?: string | undefined;
  76685. private _lineWidth;
  76686. private _x1;
  76687. private _y1;
  76688. private _x2;
  76689. private _y2;
  76690. private _dash;
  76691. private _connectedControl;
  76692. private _connectedControlDirtyObserver;
  76693. /** Gets or sets the dash pattern */
  76694. get dash(): Array<number>;
  76695. set dash(value: Array<number>);
  76696. /** Gets or sets the control connected with the line end */
  76697. get connectedControl(): Control;
  76698. set connectedControl(value: Control);
  76699. /** Gets or sets start coordinates on X axis */
  76700. get x1(): string | number;
  76701. set x1(value: string | number);
  76702. /** Gets or sets start coordinates on Y axis */
  76703. get y1(): string | number;
  76704. set y1(value: string | number);
  76705. /** Gets or sets end coordinates on X axis */
  76706. get x2(): string | number;
  76707. set x2(value: string | number);
  76708. /** Gets or sets end coordinates on Y axis */
  76709. get y2(): string | number;
  76710. set y2(value: string | number);
  76711. /** Gets or sets line width */
  76712. get lineWidth(): number;
  76713. set lineWidth(value: number);
  76714. /** Gets or sets horizontal alignment */
  76715. set horizontalAlignment(value: number);
  76716. /** Gets or sets vertical alignment */
  76717. set verticalAlignment(value: number);
  76718. private get _effectiveX2();
  76719. private get _effectiveY2();
  76720. /**
  76721. * Creates a new Line
  76722. * @param name defines the control name
  76723. */
  76724. constructor(name?: string | undefined);
  76725. protected _getTypeName(): string;
  76726. _draw(context: CanvasRenderingContext2D): void;
  76727. _measure(): void;
  76728. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76729. /**
  76730. * Move one end of the line given 3D cartesian coordinates.
  76731. * @param position Targeted world position
  76732. * @param scene BABYLON.Scene
  76733. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76734. */
  76735. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  76736. /**
  76737. * Move one end of the line to a position in screen absolute space.
  76738. * @param projectedPosition Position in screen absolute space (X, Y)
  76739. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76740. */
  76741. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  76742. }
  76743. }
  76744. declare module BABYLON.GUI {
  76745. /**
  76746. * Class used to store a point for a MultiLine object.
  76747. * The point can be pure 2D coordinates, a mesh or a control
  76748. */
  76749. export class MultiLinePoint {
  76750. private _multiLine;
  76751. private _x;
  76752. private _y;
  76753. private _control;
  76754. private _mesh;
  76755. private _controlObserver;
  76756. private _meshObserver;
  76757. /** @hidden */
  76758. _point: BABYLON.Vector2;
  76759. /**
  76760. * Creates a new MultiLinePoint
  76761. * @param multiLine defines the source MultiLine object
  76762. */
  76763. constructor(multiLine: MultiLine);
  76764. /** Gets or sets x coordinate */
  76765. get x(): string | number;
  76766. set x(value: string | number);
  76767. /** Gets or sets y coordinate */
  76768. get y(): string | number;
  76769. set y(value: string | number);
  76770. /** Gets or sets the control associated with this point */
  76771. get control(): BABYLON.Nullable<Control>;
  76772. set control(value: BABYLON.Nullable<Control>);
  76773. /** Gets or sets the mesh associated with this point */
  76774. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76775. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  76776. /** Resets links */
  76777. resetLinks(): void;
  76778. /**
  76779. * Gets a translation vector
  76780. * @returns the translation vector
  76781. */
  76782. translate(): BABYLON.Vector2;
  76783. private _translatePoint;
  76784. /** Release associated resources */
  76785. dispose(): void;
  76786. }
  76787. }
  76788. declare module BABYLON.GUI {
  76789. /**
  76790. * Class used to create multi line control
  76791. */
  76792. export class MultiLine extends Control {
  76793. name?: string | undefined;
  76794. private _lineWidth;
  76795. private _dash;
  76796. private _points;
  76797. private _minX;
  76798. private _minY;
  76799. private _maxX;
  76800. private _maxY;
  76801. /**
  76802. * Creates a new MultiLine
  76803. * @param name defines the control name
  76804. */
  76805. constructor(name?: string | undefined);
  76806. /** Gets or sets dash pattern */
  76807. get dash(): Array<number>;
  76808. set dash(value: Array<number>);
  76809. /**
  76810. * Gets point stored at specified index
  76811. * @param index defines the index to look for
  76812. * @returns the requested point if found
  76813. */
  76814. getAt(index: number): MultiLinePoint;
  76815. /** Function called when a point is updated */
  76816. onPointUpdate: () => void;
  76817. /**
  76818. * Adds new points to the point collection
  76819. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76820. * @returns the list of created MultiLinePoint
  76821. */
  76822. add(...items: (AbstractMesh | Control | {
  76823. x: string | number;
  76824. y: string | number;
  76825. })[]): MultiLinePoint[];
  76826. /**
  76827. * Adds a new point to the point collection
  76828. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76829. * @returns the created MultiLinePoint
  76830. */
  76831. push(item?: (AbstractMesh | Control | {
  76832. x: string | number;
  76833. y: string | number;
  76834. })): MultiLinePoint;
  76835. /**
  76836. * Remove a specific value or point from the active point collection
  76837. * @param value defines the value or point to remove
  76838. */
  76839. remove(value: number | MultiLinePoint): void;
  76840. /**
  76841. * Resets this object to initial state (no point)
  76842. */
  76843. reset(): void;
  76844. /**
  76845. * Resets all links
  76846. */
  76847. resetLinks(): void;
  76848. /** Gets or sets line width */
  76849. get lineWidth(): number;
  76850. set lineWidth(value: number);
  76851. set horizontalAlignment(value: number);
  76852. set verticalAlignment(value: number);
  76853. protected _getTypeName(): string;
  76854. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76855. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76856. _measure(): void;
  76857. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76858. dispose(): void;
  76859. }
  76860. }
  76861. declare module BABYLON.GUI {
  76862. /**
  76863. * Class used to create radio button controls
  76864. */
  76865. export class RadioButton extends Control {
  76866. name?: string | undefined;
  76867. private _isChecked;
  76868. private _background;
  76869. private _checkSizeRatio;
  76870. private _thickness;
  76871. /** Gets or sets border thickness */
  76872. get thickness(): number;
  76873. set thickness(value: number);
  76874. /** Gets or sets group name */
  76875. group: string;
  76876. /** BABYLON.Observable raised when isChecked is changed */
  76877. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76878. /** Gets or sets a value indicating the ratio between overall size and check size */
  76879. get checkSizeRatio(): number;
  76880. set checkSizeRatio(value: number);
  76881. /** Gets or sets background color */
  76882. get background(): string;
  76883. set background(value: string);
  76884. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76885. get isChecked(): boolean;
  76886. set isChecked(value: boolean);
  76887. /**
  76888. * Creates a new RadioButton
  76889. * @param name defines the control name
  76890. */
  76891. constructor(name?: string | undefined);
  76892. protected _getTypeName(): string;
  76893. _draw(context: CanvasRenderingContext2D): void;
  76894. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76895. /**
  76896. * Utility function to easily create a radio button with a header
  76897. * @param title defines the label to use for the header
  76898. * @param group defines the group to use for the radio button
  76899. * @param isChecked defines the initial state of the radio button
  76900. * @param onValueChanged defines the callback to call when value changes
  76901. * @returns a StackPanel containing the radio button and a textBlock
  76902. */
  76903. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76904. }
  76905. }
  76906. declare module BABYLON.GUI {
  76907. /**
  76908. * Class used to create slider controls
  76909. */
  76910. export class BaseSlider extends Control {
  76911. name?: string | undefined;
  76912. protected _thumbWidth: ValueAndUnit;
  76913. private _minimum;
  76914. private _maximum;
  76915. private _value;
  76916. private _isVertical;
  76917. protected _barOffset: ValueAndUnit;
  76918. private _isThumbClamped;
  76919. protected _displayThumb: boolean;
  76920. private _step;
  76921. private _lastPointerDownID;
  76922. protected _effectiveBarOffset: number;
  76923. protected _renderLeft: number;
  76924. protected _renderTop: number;
  76925. protected _renderWidth: number;
  76926. protected _renderHeight: number;
  76927. protected _backgroundBoxLength: number;
  76928. protected _backgroundBoxThickness: number;
  76929. protected _effectiveThumbThickness: number;
  76930. /** BABYLON.Observable raised when the sldier value changes */
  76931. onValueChangedObservable: BABYLON.Observable<number>;
  76932. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76933. get displayThumb(): boolean;
  76934. set displayThumb(value: boolean);
  76935. /** Gets or sets a step to apply to values (0 by default) */
  76936. get step(): number;
  76937. set step(value: number);
  76938. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76939. get barOffset(): string | number;
  76940. /** Gets main bar offset in pixels*/
  76941. get barOffsetInPixels(): number;
  76942. set barOffset(value: string | number);
  76943. /** Gets or sets thumb width */
  76944. get thumbWidth(): string | number;
  76945. /** Gets thumb width in pixels */
  76946. get thumbWidthInPixels(): number;
  76947. set thumbWidth(value: string | number);
  76948. /** Gets or sets minimum value */
  76949. get minimum(): number;
  76950. set minimum(value: number);
  76951. /** Gets or sets maximum value */
  76952. get maximum(): number;
  76953. set maximum(value: number);
  76954. /** Gets or sets current value */
  76955. get value(): number;
  76956. set value(value: number);
  76957. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76958. get isVertical(): boolean;
  76959. set isVertical(value: boolean);
  76960. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76961. get isThumbClamped(): boolean;
  76962. set isThumbClamped(value: boolean);
  76963. /**
  76964. * Creates a new BaseSlider
  76965. * @param name defines the control name
  76966. */
  76967. constructor(name?: string | undefined);
  76968. protected _getTypeName(): string;
  76969. protected _getThumbPosition(): number;
  76970. protected _getThumbThickness(type: string): number;
  76971. protected _prepareRenderingData(type: string): void;
  76972. private _pointerIsDown;
  76973. /** @hidden */
  76974. protected _updateValueFromPointer(x: number, y: number): void;
  76975. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76976. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76977. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76978. }
  76979. }
  76980. declare module BABYLON.GUI {
  76981. /**
  76982. * Class used to create slider controls
  76983. */
  76984. export class Slider extends BaseSlider {
  76985. name?: string | undefined;
  76986. private _background;
  76987. private _borderColor;
  76988. private _isThumbCircle;
  76989. protected _displayValueBar: boolean;
  76990. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76991. get displayValueBar(): boolean;
  76992. set displayValueBar(value: boolean);
  76993. /** Gets or sets border color */
  76994. get borderColor(): string;
  76995. set borderColor(value: string);
  76996. /** Gets or sets background color */
  76997. get background(): string;
  76998. set background(value: string);
  76999. /** Gets or sets a boolean indicating if the thumb should be round or square */
  77000. get isThumbCircle(): boolean;
  77001. set isThumbCircle(value: boolean);
  77002. /**
  77003. * Creates a new Slider
  77004. * @param name defines the control name
  77005. */
  77006. constructor(name?: string | undefined);
  77007. protected _getTypeName(): string;
  77008. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77009. }
  77010. }
  77011. declare module BABYLON.GUI {
  77012. /** Class used to create a RadioGroup
  77013. * which contains groups of radio buttons
  77014. */
  77015. export class SelectorGroup {
  77016. /** name of SelectorGroup */
  77017. name: string;
  77018. private _groupPanel;
  77019. private _selectors;
  77020. private _groupHeader;
  77021. /**
  77022. * Creates a new SelectorGroup
  77023. * @param name of group, used as a group heading
  77024. */
  77025. constructor(
  77026. /** name of SelectorGroup */
  77027. name: string);
  77028. /** Gets the groupPanel of the SelectorGroup */
  77029. get groupPanel(): StackPanel;
  77030. /** Gets the selectors array */
  77031. get selectors(): StackPanel[];
  77032. /** Gets and sets the group header */
  77033. get header(): string;
  77034. set header(label: string);
  77035. /** @hidden */
  77036. private _addGroupHeader;
  77037. /** @hidden*/
  77038. _getSelector(selectorNb: number): StackPanel | undefined;
  77039. /** Removes the selector at the given position
  77040. * @param selectorNb the position of the selector within the group
  77041. */
  77042. removeSelector(selectorNb: number): void;
  77043. }
  77044. /** Class used to create a CheckboxGroup
  77045. * which contains groups of checkbox buttons
  77046. */
  77047. export class CheckboxGroup extends SelectorGroup {
  77048. /** Adds a checkbox as a control
  77049. * @param text is the label for the selector
  77050. * @param func is the function called when the Selector is checked
  77051. * @param checked is true when Selector is checked
  77052. */
  77053. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  77054. /** @hidden */
  77055. _setSelectorLabel(selectorNb: number, label: string): void;
  77056. /** @hidden */
  77057. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77058. /** @hidden */
  77059. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77060. /** @hidden */
  77061. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77062. }
  77063. /** Class used to create a RadioGroup
  77064. * which contains groups of radio buttons
  77065. */
  77066. export class RadioGroup extends SelectorGroup {
  77067. private _selectNb;
  77068. /** Adds a radio button as a control
  77069. * @param label is the label for the selector
  77070. * @param func is the function called when the Selector is checked
  77071. * @param checked is true when Selector is checked
  77072. */
  77073. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  77074. /** @hidden */
  77075. _setSelectorLabel(selectorNb: number, label: string): void;
  77076. /** @hidden */
  77077. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77078. /** @hidden */
  77079. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77080. /** @hidden */
  77081. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77082. }
  77083. /** Class used to create a SliderGroup
  77084. * which contains groups of slider buttons
  77085. */
  77086. export class SliderGroup extends SelectorGroup {
  77087. /**
  77088. * Adds a slider to the SelectorGroup
  77089. * @param label is the label for the SliderBar
  77090. * @param func is the function called when the Slider moves
  77091. * @param unit is a string describing the units used, eg degrees or metres
  77092. * @param min is the minimum value for the Slider
  77093. * @param max is the maximum value for the Slider
  77094. * @param value is the start value for the Slider between min and max
  77095. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  77096. */
  77097. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  77098. /** @hidden */
  77099. _setSelectorLabel(selectorNb: number, label: string): void;
  77100. /** @hidden */
  77101. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77102. /** @hidden */
  77103. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77104. /** @hidden */
  77105. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77106. }
  77107. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  77108. * @see http://doc.babylonjs.com/how_to/selector
  77109. */
  77110. export class SelectionPanel extends Rectangle {
  77111. /** name of SelectionPanel */
  77112. name: string;
  77113. /** an array of SelectionGroups */
  77114. groups: SelectorGroup[];
  77115. private _panel;
  77116. private _buttonColor;
  77117. private _buttonBackground;
  77118. private _headerColor;
  77119. private _barColor;
  77120. private _barHeight;
  77121. private _spacerHeight;
  77122. private _labelColor;
  77123. private _groups;
  77124. private _bars;
  77125. /**
  77126. * Creates a new SelectionPanel
  77127. * @param name of SelectionPanel
  77128. * @param groups is an array of SelectionGroups
  77129. */
  77130. constructor(
  77131. /** name of SelectionPanel */
  77132. name: string,
  77133. /** an array of SelectionGroups */
  77134. groups?: SelectorGroup[]);
  77135. protected _getTypeName(): string;
  77136. /** Gets or sets the headerColor */
  77137. get headerColor(): string;
  77138. set headerColor(color: string);
  77139. private _setHeaderColor;
  77140. /** Gets or sets the button color */
  77141. get buttonColor(): string;
  77142. set buttonColor(color: string);
  77143. private _setbuttonColor;
  77144. /** Gets or sets the label color */
  77145. get labelColor(): string;
  77146. set labelColor(color: string);
  77147. private _setLabelColor;
  77148. /** Gets or sets the button background */
  77149. get buttonBackground(): string;
  77150. set buttonBackground(color: string);
  77151. private _setButtonBackground;
  77152. /** Gets or sets the color of separator bar */
  77153. get barColor(): string;
  77154. set barColor(color: string);
  77155. private _setBarColor;
  77156. /** Gets or sets the height of separator bar */
  77157. get barHeight(): string;
  77158. set barHeight(value: string);
  77159. private _setBarHeight;
  77160. /** Gets or sets the height of spacers*/
  77161. get spacerHeight(): string;
  77162. set spacerHeight(value: string);
  77163. private _setSpacerHeight;
  77164. /** Adds a bar between groups */
  77165. private _addSpacer;
  77166. /** Add a group to the selection panel
  77167. * @param group is the selector group to add
  77168. */
  77169. addGroup(group: SelectorGroup): void;
  77170. /** Remove the group from the given position
  77171. * @param groupNb is the position of the group in the list
  77172. */
  77173. removeGroup(groupNb: number): void;
  77174. /** Change a group header label
  77175. * @param label is the new group header label
  77176. * @param groupNb is the number of the group to relabel
  77177. * */
  77178. setHeaderName(label: string, groupNb: number): void;
  77179. /** Change selector label to the one given
  77180. * @param label is the new selector label
  77181. * @param groupNb is the number of the groupcontaining the selector
  77182. * @param selectorNb is the number of the selector within a group to relabel
  77183. * */
  77184. relabel(label: string, groupNb: number, selectorNb: number): void;
  77185. /** For a given group position remove the selector at the given position
  77186. * @param groupNb is the number of the group to remove the selector from
  77187. * @param selectorNb is the number of the selector within the group
  77188. */
  77189. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77190. /** For a given group position of correct type add a checkbox button
  77191. * @param groupNb is the number of the group to remove the selector from
  77192. * @param label is the label for the selector
  77193. * @param func is the function called when the Selector is checked
  77194. * @param checked is true when Selector is checked
  77195. */
  77196. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77197. /** For a given group position of correct type add a radio button
  77198. * @param groupNb is the number of the group to remove the selector from
  77199. * @param label is the label for the selector
  77200. * @param func is the function called when the Selector is checked
  77201. * @param checked is true when Selector is checked
  77202. */
  77203. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77204. /**
  77205. * For a given slider group add a slider
  77206. * @param groupNb is the number of the group to add the slider to
  77207. * @param label is the label for the Slider
  77208. * @param func is the function called when the Slider moves
  77209. * @param unit is a string describing the units used, eg degrees or metres
  77210. * @param min is the minimum value for the Slider
  77211. * @param max is the maximum value for the Slider
  77212. * @param value is the start value for the Slider between min and max
  77213. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77214. */
  77215. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77216. }
  77217. }
  77218. declare module BABYLON.GUI {
  77219. /**
  77220. * Class used to hold a the container for ScrollViewer
  77221. * @hidden
  77222. */
  77223. export class _ScrollViewerWindow extends Container {
  77224. parentClientWidth: number;
  77225. parentClientHeight: number;
  77226. private _freezeControls;
  77227. private _parentMeasure;
  77228. private _oldLeft;
  77229. private _oldTop;
  77230. get freezeControls(): boolean;
  77231. set freezeControls(value: boolean);
  77232. private _bucketWidth;
  77233. private _bucketHeight;
  77234. private _buckets;
  77235. private _bucketLen;
  77236. get bucketWidth(): number;
  77237. get bucketHeight(): number;
  77238. setBucketSizes(width: number, height: number): void;
  77239. private _useBuckets;
  77240. private _makeBuckets;
  77241. private _dispatchInBuckets;
  77242. private _updateMeasures;
  77243. private _updateChildrenMeasures;
  77244. private _restoreMeasures;
  77245. /**
  77246. * Creates a new ScrollViewerWindow
  77247. * @param name of ScrollViewerWindow
  77248. */
  77249. constructor(name?: string);
  77250. protected _getTypeName(): string;
  77251. /** @hidden */
  77252. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77253. /** @hidden */
  77254. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77255. private _scrollChildren;
  77256. private _scrollChildrenWithBuckets;
  77257. /** @hidden */
  77258. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77259. protected _postMeasure(): void;
  77260. }
  77261. }
  77262. declare module BABYLON.GUI {
  77263. /**
  77264. * Class used to create slider controls
  77265. */
  77266. export class ScrollBar extends BaseSlider {
  77267. name?: string | undefined;
  77268. private _background;
  77269. private _borderColor;
  77270. private _tempMeasure;
  77271. /** Gets or sets border color */
  77272. get borderColor(): string;
  77273. set borderColor(value: string);
  77274. /** Gets or sets background color */
  77275. get background(): string;
  77276. set background(value: string);
  77277. /**
  77278. * Creates a new Slider
  77279. * @param name defines the control name
  77280. */
  77281. constructor(name?: string | undefined);
  77282. protected _getTypeName(): string;
  77283. protected _getThumbThickness(): number;
  77284. _draw(context: CanvasRenderingContext2D): void;
  77285. private _first;
  77286. private _originX;
  77287. private _originY;
  77288. /** @hidden */
  77289. protected _updateValueFromPointer(x: number, y: number): void;
  77290. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77291. }
  77292. }
  77293. declare module BABYLON.GUI {
  77294. /**
  77295. * Class used to create slider controls
  77296. */
  77297. export class ImageScrollBar extends BaseSlider {
  77298. name?: string | undefined;
  77299. private _backgroundBaseImage;
  77300. private _backgroundImage;
  77301. private _thumbImage;
  77302. private _thumbBaseImage;
  77303. private _thumbLength;
  77304. private _thumbHeight;
  77305. private _barImageHeight;
  77306. private _tempMeasure;
  77307. /** Number of 90° rotation to apply on the images when in vertical mode */
  77308. num90RotationInVerticalMode: number;
  77309. /**
  77310. * Gets or sets the image used to render the background for horizontal bar
  77311. */
  77312. get backgroundImage(): Image;
  77313. set backgroundImage(value: Image);
  77314. /**
  77315. * Gets or sets the image used to render the thumb
  77316. */
  77317. get thumbImage(): Image;
  77318. set thumbImage(value: Image);
  77319. /**
  77320. * Gets or sets the length of the thumb
  77321. */
  77322. get thumbLength(): number;
  77323. set thumbLength(value: number);
  77324. /**
  77325. * Gets or sets the height of the thumb
  77326. */
  77327. get thumbHeight(): number;
  77328. set thumbHeight(value: number);
  77329. /**
  77330. * Gets or sets the height of the bar image
  77331. */
  77332. get barImageHeight(): number;
  77333. set barImageHeight(value: number);
  77334. /**
  77335. * Creates a new ImageScrollBar
  77336. * @param name defines the control name
  77337. */
  77338. constructor(name?: string | undefined);
  77339. protected _getTypeName(): string;
  77340. protected _getThumbThickness(): number;
  77341. _draw(context: CanvasRenderingContext2D): void;
  77342. private _first;
  77343. private _originX;
  77344. private _originY;
  77345. /** @hidden */
  77346. protected _updateValueFromPointer(x: number, y: number): void;
  77347. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77348. }
  77349. }
  77350. declare module BABYLON.GUI {
  77351. /**
  77352. * Class used to hold a viewer window and sliders in a grid
  77353. */
  77354. export class ScrollViewer extends Rectangle {
  77355. private _grid;
  77356. private _horizontalBarSpace;
  77357. private _verticalBarSpace;
  77358. private _dragSpace;
  77359. private _horizontalBar;
  77360. private _verticalBar;
  77361. private _barColor;
  77362. private _barBackground;
  77363. private _barImage;
  77364. private _horizontalBarImage;
  77365. private _verticalBarImage;
  77366. private _barBackgroundImage;
  77367. private _horizontalBarBackgroundImage;
  77368. private _verticalBarBackgroundImage;
  77369. private _barSize;
  77370. private _window;
  77371. private _pointerIsOver;
  77372. private _wheelPrecision;
  77373. private _onWheelObserver;
  77374. private _clientWidth;
  77375. private _clientHeight;
  77376. private _useImageBar;
  77377. private _thumbLength;
  77378. private _thumbHeight;
  77379. private _barImageHeight;
  77380. private _horizontalBarImageHeight;
  77381. private _verticalBarImageHeight;
  77382. private _oldWindowContentsWidth;
  77383. private _oldWindowContentsHeight;
  77384. /**
  77385. * Gets the horizontal scrollbar
  77386. */
  77387. get horizontalBar(): ScrollBar | ImageScrollBar;
  77388. /**
  77389. * Gets the vertical scrollbar
  77390. */
  77391. get verticalBar(): ScrollBar | ImageScrollBar;
  77392. /**
  77393. * Adds a new control to the current container
  77394. * @param control defines the control to add
  77395. * @returns the current container
  77396. */
  77397. addControl(control: BABYLON.Nullable<Control>): Container;
  77398. /**
  77399. * Removes a control from the current container
  77400. * @param control defines the control to remove
  77401. * @returns the current container
  77402. */
  77403. removeControl(control: Control): Container;
  77404. /** Gets the list of children */
  77405. get children(): Control[];
  77406. _flagDescendantsAsMatrixDirty(): void;
  77407. /**
  77408. * Freezes or unfreezes the controls in the window.
  77409. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77410. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77411. */
  77412. get freezeControls(): boolean;
  77413. set freezeControls(value: boolean);
  77414. /** Gets the bucket width */
  77415. get bucketWidth(): number;
  77416. /** Gets the bucket height */
  77417. get bucketHeight(): number;
  77418. /**
  77419. * Sets the bucket sizes.
  77420. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77421. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77422. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77423. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77424. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77425. * used), that's why it is not enabled by default.
  77426. * @param width width of the bucket
  77427. * @param height height of the bucket
  77428. */
  77429. setBucketSizes(width: number, height: number): void;
  77430. private _forceHorizontalBar;
  77431. private _forceVerticalBar;
  77432. /**
  77433. * Forces the horizontal scroll bar to be displayed
  77434. */
  77435. get forceHorizontalBar(): boolean;
  77436. set forceHorizontalBar(value: boolean);
  77437. /**
  77438. * Forces the vertical scroll bar to be displayed
  77439. */
  77440. get forceVerticalBar(): boolean;
  77441. set forceVerticalBar(value: boolean);
  77442. /**
  77443. * Creates a new ScrollViewer
  77444. * @param name of ScrollViewer
  77445. */
  77446. constructor(name?: string, isImageBased?: boolean);
  77447. /** Reset the scroll viewer window to initial size */
  77448. resetWindow(): void;
  77449. protected _getTypeName(): string;
  77450. private _buildClientSizes;
  77451. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77452. protected _postMeasure(): void;
  77453. /**
  77454. * Gets or sets the mouse wheel precision
  77455. * from 0 to 1 with a default value of 0.05
  77456. * */
  77457. get wheelPrecision(): number;
  77458. set wheelPrecision(value: number);
  77459. /** Gets or sets the scroll bar container background color */
  77460. get scrollBackground(): string;
  77461. set scrollBackground(color: string);
  77462. /** Gets or sets the bar color */
  77463. get barColor(): string;
  77464. set barColor(color: string);
  77465. /** Gets or sets the bar image */
  77466. get thumbImage(): Image;
  77467. set thumbImage(value: Image);
  77468. /** Gets or sets the horizontal bar image */
  77469. get horizontalThumbImage(): Image;
  77470. set horizontalThumbImage(value: Image);
  77471. /** Gets or sets the vertical bar image */
  77472. get verticalThumbImage(): Image;
  77473. set verticalThumbImage(value: Image);
  77474. /** Gets or sets the size of the bar */
  77475. get barSize(): number;
  77476. set barSize(value: number);
  77477. /** Gets or sets the length of the thumb */
  77478. get thumbLength(): number;
  77479. set thumbLength(value: number);
  77480. /** Gets or sets the height of the thumb */
  77481. get thumbHeight(): number;
  77482. set thumbHeight(value: number);
  77483. /** Gets or sets the height of the bar image */
  77484. get barImageHeight(): number;
  77485. set barImageHeight(value: number);
  77486. /** Gets or sets the height of the horizontal bar image */
  77487. get horizontalBarImageHeight(): number;
  77488. set horizontalBarImageHeight(value: number);
  77489. /** Gets or sets the height of the vertical bar image */
  77490. get verticalBarImageHeight(): number;
  77491. set verticalBarImageHeight(value: number);
  77492. /** Gets or sets the bar background */
  77493. get barBackground(): string;
  77494. set barBackground(color: string);
  77495. /** Gets or sets the bar background image */
  77496. get barImage(): Image;
  77497. set barImage(value: Image);
  77498. /** Gets or sets the horizontal bar background image */
  77499. get horizontalBarImage(): Image;
  77500. set horizontalBarImage(value: Image);
  77501. /** Gets or sets the vertical bar background image */
  77502. get verticalBarImage(): Image;
  77503. set verticalBarImage(value: Image);
  77504. private _setWindowPosition;
  77505. /** @hidden */
  77506. private _updateScroller;
  77507. _link(host: AdvancedDynamicTexture): void;
  77508. /** @hidden */
  77509. private _addBar;
  77510. /** @hidden */
  77511. private _attachWheel;
  77512. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77513. /** Releases associated resources */
  77514. dispose(): void;
  77515. }
  77516. }
  77517. declare module BABYLON.GUI {
  77518. /** Class used to render a grid */
  77519. export class DisplayGrid extends Control {
  77520. name?: string | undefined;
  77521. private _cellWidth;
  77522. private _cellHeight;
  77523. private _minorLineTickness;
  77524. private _minorLineColor;
  77525. private _majorLineTickness;
  77526. private _majorLineColor;
  77527. private _majorLineFrequency;
  77528. private _background;
  77529. private _displayMajorLines;
  77530. private _displayMinorLines;
  77531. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  77532. get displayMinorLines(): boolean;
  77533. set displayMinorLines(value: boolean);
  77534. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  77535. get displayMajorLines(): boolean;
  77536. set displayMajorLines(value: boolean);
  77537. /** Gets or sets background color (Black by default) */
  77538. get background(): string;
  77539. set background(value: string);
  77540. /** Gets or sets the width of each cell (20 by default) */
  77541. get cellWidth(): number;
  77542. set cellWidth(value: number);
  77543. /** Gets or sets the height of each cell (20 by default) */
  77544. get cellHeight(): number;
  77545. set cellHeight(value: number);
  77546. /** Gets or sets the tickness of minor lines (1 by default) */
  77547. get minorLineTickness(): number;
  77548. set minorLineTickness(value: number);
  77549. /** Gets or sets the color of minor lines (DarkGray by default) */
  77550. get minorLineColor(): string;
  77551. set minorLineColor(value: string);
  77552. /** Gets or sets the tickness of major lines (2 by default) */
  77553. get majorLineTickness(): number;
  77554. set majorLineTickness(value: number);
  77555. /** Gets or sets the color of major lines (White by default) */
  77556. get majorLineColor(): string;
  77557. set majorLineColor(value: string);
  77558. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77559. get majorLineFrequency(): number;
  77560. set majorLineFrequency(value: number);
  77561. /**
  77562. * Creates a new GridDisplayRectangle
  77563. * @param name defines the control name
  77564. */
  77565. constructor(name?: string | undefined);
  77566. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77567. protected _getTypeName(): string;
  77568. }
  77569. }
  77570. declare module BABYLON.GUI {
  77571. /**
  77572. * Class used to create slider controls based on images
  77573. */
  77574. export class ImageBasedSlider extends BaseSlider {
  77575. name?: string | undefined;
  77576. private _backgroundImage;
  77577. private _thumbImage;
  77578. private _valueBarImage;
  77579. private _tempMeasure;
  77580. get displayThumb(): boolean;
  77581. set displayThumb(value: boolean);
  77582. /**
  77583. * Gets or sets the image used to render the background
  77584. */
  77585. get backgroundImage(): Image;
  77586. set backgroundImage(value: Image);
  77587. /**
  77588. * Gets or sets the image used to render the value bar
  77589. */
  77590. get valueBarImage(): Image;
  77591. set valueBarImage(value: Image);
  77592. /**
  77593. * Gets or sets the image used to render the thumb
  77594. */
  77595. get thumbImage(): Image;
  77596. set thumbImage(value: Image);
  77597. /**
  77598. * Creates a new ImageBasedSlider
  77599. * @param name defines the control name
  77600. */
  77601. constructor(name?: string | undefined);
  77602. protected _getTypeName(): string;
  77603. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77604. }
  77605. }
  77606. declare module BABYLON.GUI {
  77607. /**
  77608. * Forcing an export so that this code will execute
  77609. * @hidden
  77610. */
  77611. const name = "Statics";
  77612. }
  77613. declare module BABYLON.GUI {
  77614. /**
  77615. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  77616. */
  77617. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  77618. /**
  77619. * Define the instrumented AdvancedDynamicTexture.
  77620. */
  77621. texture: AdvancedDynamicTexture;
  77622. private _captureRenderTime;
  77623. private _renderTime;
  77624. private _captureLayoutTime;
  77625. private _layoutTime;
  77626. private _onBeginRenderObserver;
  77627. private _onEndRenderObserver;
  77628. private _onBeginLayoutObserver;
  77629. private _onEndLayoutObserver;
  77630. /**
  77631. * Gets the perf counter used to capture render time
  77632. */
  77633. get renderTimeCounter(): BABYLON.PerfCounter;
  77634. /**
  77635. * Gets the perf counter used to capture layout time
  77636. */
  77637. get layoutTimeCounter(): BABYLON.PerfCounter;
  77638. /**
  77639. * Enable or disable the render time capture
  77640. */
  77641. get captureRenderTime(): boolean;
  77642. set captureRenderTime(value: boolean);
  77643. /**
  77644. * Enable or disable the layout time capture
  77645. */
  77646. get captureLayoutTime(): boolean;
  77647. set captureLayoutTime(value: boolean);
  77648. /**
  77649. * Instantiates a new advanced dynamic texture instrumentation.
  77650. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77651. * @param texture Defines the AdvancedDynamicTexture to instrument
  77652. */
  77653. constructor(
  77654. /**
  77655. * Define the instrumented AdvancedDynamicTexture.
  77656. */
  77657. texture: AdvancedDynamicTexture);
  77658. /**
  77659. * Dispose and release associated resources.
  77660. */
  77661. dispose(): void;
  77662. }
  77663. }
  77664. declare module BABYLON.GUI {
  77665. /**
  77666. * Class used to load GUI via XML.
  77667. */
  77668. export class XmlLoader {
  77669. private _nodes;
  77670. private _nodeTypes;
  77671. private _isLoaded;
  77672. private _objectAttributes;
  77673. private _parentClass;
  77674. /**
  77675. * Create a new xml loader
  77676. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  77677. */
  77678. constructor(parentClass?: null);
  77679. private _getChainElement;
  77680. private _getClassAttribute;
  77681. private _createGuiElement;
  77682. private _parseGrid;
  77683. private _parseElement;
  77684. private _prepareSourceElement;
  77685. private _parseElementsFromSource;
  77686. private _parseXml;
  77687. /**
  77688. * Gets if the loading has finished.
  77689. * @returns whether the loading has finished or not
  77690. */
  77691. isLoaded(): boolean;
  77692. /**
  77693. * Gets a loaded node / control by id.
  77694. * @param id the Controls id set in the xml
  77695. * @returns element of type Control
  77696. */
  77697. getNodeById(id: string): any;
  77698. /**
  77699. * Gets all loaded nodes / controls
  77700. * @returns Array of controls
  77701. */
  77702. getNodes(): any;
  77703. /**
  77704. * Initiates the xml layout loading
  77705. * @param xmlFile defines the xml layout to load
  77706. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  77707. * @param callback defines the callback called on layout load.
  77708. */
  77709. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  77710. }
  77711. }
  77712. declare module BABYLON.GUI {
  77713. /**
  77714. * Class used to create containers for controls
  77715. */
  77716. export class Container3D extends Control3D {
  77717. private _blockLayout;
  77718. /**
  77719. * Gets the list of child controls
  77720. */
  77721. protected _children: Control3D[];
  77722. /**
  77723. * Gets the list of child controls
  77724. */
  77725. get children(): Array<Control3D>;
  77726. /**
  77727. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  77728. * This is helpful to optimize layout operation when adding multiple children in a row
  77729. */
  77730. get blockLayout(): boolean;
  77731. set blockLayout(value: boolean);
  77732. /**
  77733. * Creates a new container
  77734. * @param name defines the container name
  77735. */
  77736. constructor(name?: string);
  77737. /**
  77738. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  77739. * @returns the current container
  77740. */
  77741. updateLayout(): Container3D;
  77742. /**
  77743. * Gets a boolean indicating if the given control is in the children of this control
  77744. * @param control defines the control to check
  77745. * @returns true if the control is in the child list
  77746. */
  77747. containsControl(control: Control3D): boolean;
  77748. /**
  77749. * Adds a control to the children of this control
  77750. * @param control defines the control to add
  77751. * @returns the current container
  77752. */
  77753. addControl(control: Control3D): Container3D;
  77754. /**
  77755. * This function will be called everytime a new control is added
  77756. */
  77757. protected _arrangeChildren(): void;
  77758. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77759. /**
  77760. * Removes a control from the children of this control
  77761. * @param control defines the control to remove
  77762. * @returns the current container
  77763. */
  77764. removeControl(control: Control3D): Container3D;
  77765. protected _getTypeName(): string;
  77766. /**
  77767. * Releases all associated resources
  77768. */
  77769. dispose(): void;
  77770. /** Control rotation will remain unchanged */
  77771. static readonly UNSET_ORIENTATION: number;
  77772. /** Control will rotate to make it look at sphere central axis */
  77773. static readonly FACEORIGIN_ORIENTATION: number;
  77774. /** Control will rotate to make it look back at sphere central axis */
  77775. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  77776. /** Control will rotate to look at z axis (0, 0, 1) */
  77777. static readonly FACEFORWARD_ORIENTATION: number;
  77778. /** Control will rotate to look at negative z axis (0, 0, -1) */
  77779. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  77780. }
  77781. }
  77782. declare module BABYLON.GUI {
  77783. /**
  77784. * Class used to manage 3D user interface
  77785. * @see http://doc.babylonjs.com/how_to/gui3d
  77786. */
  77787. export class GUI3DManager implements BABYLON.IDisposable {
  77788. private _scene;
  77789. private _sceneDisposeObserver;
  77790. private _utilityLayer;
  77791. private _rootContainer;
  77792. private _pointerObserver;
  77793. private _pointerOutObserver;
  77794. /** @hidden */
  77795. _lastPickedControl: Control3D;
  77796. /** @hidden */
  77797. _lastControlOver: {
  77798. [pointerId: number]: Control3D;
  77799. };
  77800. /** @hidden */
  77801. _lastControlDown: {
  77802. [pointerId: number]: Control3D;
  77803. };
  77804. /**
  77805. * BABYLON.Observable raised when the point picked by the pointer events changed
  77806. */
  77807. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77808. /** @hidden */
  77809. _sharedMaterials: {
  77810. [key: string]: BABYLON.Material;
  77811. };
  77812. /** Gets the hosting scene */
  77813. get scene(): BABYLON.Scene;
  77814. /** Gets associated utility layer */
  77815. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77816. /**
  77817. * Creates a new GUI3DManager
  77818. * @param scene
  77819. */
  77820. constructor(scene?: BABYLON.Scene);
  77821. private _handlePointerOut;
  77822. private _doPicking;
  77823. /**
  77824. * Gets the root container
  77825. */
  77826. get rootContainer(): Container3D;
  77827. /**
  77828. * Gets a boolean indicating if the given control is in the root child list
  77829. * @param control defines the control to check
  77830. * @returns true if the control is in the root child list
  77831. */
  77832. containsControl(control: Control3D): boolean;
  77833. /**
  77834. * Adds a control to the root child list
  77835. * @param control defines the control to add
  77836. * @returns the current manager
  77837. */
  77838. addControl(control: Control3D): GUI3DManager;
  77839. /**
  77840. * Removes a control from the root child list
  77841. * @param control defines the control to remove
  77842. * @returns the current container
  77843. */
  77844. removeControl(control: Control3D): GUI3DManager;
  77845. /**
  77846. * Releases all associated resources
  77847. */
  77848. dispose(): void;
  77849. }
  77850. }
  77851. declare module BABYLON.GUI {
  77852. /**
  77853. * Class used to transport BABYLON.Vector3 information for pointer events
  77854. */
  77855. export class Vector3WithInfo extends BABYLON.Vector3 {
  77856. /** defines the current mouse button index */
  77857. buttonIndex: number;
  77858. /**
  77859. * Creates a new Vector3WithInfo
  77860. * @param source defines the vector3 data to transport
  77861. * @param buttonIndex defines the current mouse button index
  77862. */
  77863. constructor(source: BABYLON.Vector3,
  77864. /** defines the current mouse button index */
  77865. buttonIndex?: number);
  77866. }
  77867. }
  77868. declare module BABYLON.GUI {
  77869. /**
  77870. * Class used as base class for controls
  77871. */
  77872. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77873. /** Defines the control name */
  77874. name?: string | undefined;
  77875. /** @hidden */
  77876. _host: GUI3DManager;
  77877. private _node;
  77878. private _downCount;
  77879. private _enterCount;
  77880. private _downPointerIds;
  77881. private _isVisible;
  77882. /** Gets or sets the control position in world space */
  77883. get position(): BABYLON.Vector3;
  77884. set position(value: BABYLON.Vector3);
  77885. /** Gets or sets the control scaling in world space */
  77886. get scaling(): BABYLON.Vector3;
  77887. set scaling(value: BABYLON.Vector3);
  77888. /** Callback used to start pointer enter animation */
  77889. pointerEnterAnimation: () => void;
  77890. /** Callback used to start pointer out animation */
  77891. pointerOutAnimation: () => void;
  77892. /** Callback used to start pointer down animation */
  77893. pointerDownAnimation: () => void;
  77894. /** Callback used to start pointer up animation */
  77895. pointerUpAnimation: () => void;
  77896. /**
  77897. * An event triggered when the pointer move over the control
  77898. */
  77899. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77900. /**
  77901. * An event triggered when the pointer move out of the control
  77902. */
  77903. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77904. /**
  77905. * An event triggered when the pointer taps the control
  77906. */
  77907. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77908. /**
  77909. * An event triggered when pointer is up
  77910. */
  77911. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77912. /**
  77913. * An event triggered when a control is clicked on (with a mouse)
  77914. */
  77915. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77916. /**
  77917. * An event triggered when pointer enters the control
  77918. */
  77919. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77920. /**
  77921. * Gets or sets the parent container
  77922. */
  77923. parent: BABYLON.Nullable<Container3D>;
  77924. private _behaviors;
  77925. /**
  77926. * Gets the list of attached behaviors
  77927. * @see http://doc.babylonjs.com/features/behaviour
  77928. */
  77929. get behaviors(): BABYLON.Behavior<Control3D>[];
  77930. /**
  77931. * Attach a behavior to the control
  77932. * @see http://doc.babylonjs.com/features/behaviour
  77933. * @param behavior defines the behavior to attach
  77934. * @returns the current control
  77935. */
  77936. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77937. /**
  77938. * Remove an attached behavior
  77939. * @see http://doc.babylonjs.com/features/behaviour
  77940. * @param behavior defines the behavior to attach
  77941. * @returns the current control
  77942. */
  77943. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77944. /**
  77945. * Gets an attached behavior by name
  77946. * @param name defines the name of the behavior to look for
  77947. * @see http://doc.babylonjs.com/features/behaviour
  77948. * @returns null if behavior was not found else the requested behavior
  77949. */
  77950. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77951. /** Gets or sets a boolean indicating if the control is visible */
  77952. get isVisible(): boolean;
  77953. set isVisible(value: boolean);
  77954. /**
  77955. * Creates a new control
  77956. * @param name defines the control name
  77957. */
  77958. constructor(
  77959. /** Defines the control name */
  77960. name?: string | undefined);
  77961. /**
  77962. * Gets a string representing the class name
  77963. */
  77964. get typeName(): string;
  77965. /**
  77966. * Get the current class name of the control.
  77967. * @returns current class name
  77968. */
  77969. getClassName(): string;
  77970. protected _getTypeName(): string;
  77971. /**
  77972. * Gets the transform node used by this control
  77973. */
  77974. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77975. /**
  77976. * Gets the mesh used to render this control
  77977. */
  77978. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77979. /**
  77980. * Link the control as child of the given node
  77981. * @param node defines the node to link to. Use null to unlink the control
  77982. * @returns the current control
  77983. */
  77984. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77985. /** @hidden **/
  77986. _prepareNode(scene: BABYLON.Scene): void;
  77987. /**
  77988. * Node creation.
  77989. * Can be overriden by children
  77990. * @param scene defines the scene where the node must be attached
  77991. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77992. */
  77993. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77994. /**
  77995. * Affect a material to the given mesh
  77996. * @param mesh defines the mesh which will represent the control
  77997. */
  77998. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77999. /** @hidden */
  78000. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  78001. /** @hidden */
  78002. _onPointerEnter(target: Control3D): boolean;
  78003. /** @hidden */
  78004. _onPointerOut(target: Control3D): void;
  78005. /** @hidden */
  78006. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78007. /** @hidden */
  78008. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78009. /** @hidden */
  78010. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78011. /** @hidden */
  78012. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78013. /** @hidden */
  78014. _disposeNode(): void;
  78015. /**
  78016. * Releases all associated resources
  78017. */
  78018. dispose(): void;
  78019. }
  78020. }
  78021. declare module BABYLON.GUI {
  78022. /**
  78023. * Class used as a root to all buttons
  78024. */
  78025. export class AbstractButton3D extends Control3D {
  78026. /**
  78027. * Creates a new button
  78028. * @param name defines the control name
  78029. */
  78030. constructor(name?: string);
  78031. protected _getTypeName(): string;
  78032. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78033. }
  78034. }
  78035. declare module BABYLON.GUI {
  78036. /**
  78037. * Class used to create a button in 3D
  78038. */
  78039. export class Button3D extends AbstractButton3D {
  78040. /** @hidden */
  78041. protected _currentMaterial: BABYLON.Material;
  78042. private _facadeTexture;
  78043. private _content;
  78044. private _contentResolution;
  78045. private _contentScaleRatio;
  78046. /**
  78047. * Gets or sets the texture resolution used to render content (512 by default)
  78048. */
  78049. get contentResolution(): BABYLON.int;
  78050. set contentResolution(value: BABYLON.int);
  78051. /**
  78052. * Gets or sets the texture scale ratio used to render content (2 by default)
  78053. */
  78054. get contentScaleRatio(): number;
  78055. set contentScaleRatio(value: number);
  78056. protected _disposeFacadeTexture(): void;
  78057. protected _resetContent(): void;
  78058. /**
  78059. * Creates a new button
  78060. * @param name defines the control name
  78061. */
  78062. constructor(name?: string);
  78063. /**
  78064. * Gets or sets the GUI 2D content used to display the button's facade
  78065. */
  78066. get content(): Control;
  78067. set content(value: Control);
  78068. /**
  78069. * Apply the facade texture (created from the content property).
  78070. * This function can be overloaded by child classes
  78071. * @param facadeTexture defines the AdvancedDynamicTexture to use
  78072. */
  78073. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78074. protected _getTypeName(): string;
  78075. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78076. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78077. /**
  78078. * Releases all associated resources
  78079. */
  78080. dispose(): void;
  78081. }
  78082. }
  78083. declare module BABYLON.GUI {
  78084. /**
  78085. * Abstract class used to create a container panel deployed on the surface of a volume
  78086. */
  78087. export abstract class VolumeBasedPanel extends Container3D {
  78088. private _columns;
  78089. private _rows;
  78090. private _rowThenColum;
  78091. private _orientation;
  78092. protected _cellWidth: number;
  78093. protected _cellHeight: number;
  78094. /**
  78095. * Gets or sets the distance between elements
  78096. */
  78097. margin: number;
  78098. /**
  78099. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  78100. * | Value | Type | Description |
  78101. * | ----- | ----------------------------------- | ----------- |
  78102. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  78103. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  78104. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  78105. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  78106. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  78107. */
  78108. get orientation(): number;
  78109. set orientation(value: number);
  78110. /**
  78111. * Gets or sets the number of columns requested (10 by default).
  78112. * The panel will automatically compute the number of rows based on number of child controls.
  78113. */
  78114. get columns(): BABYLON.int;
  78115. set columns(value: BABYLON.int);
  78116. /**
  78117. * Gets or sets a the number of rows requested.
  78118. * The panel will automatically compute the number of columns based on number of child controls.
  78119. */
  78120. get rows(): BABYLON.int;
  78121. set rows(value: BABYLON.int);
  78122. /**
  78123. * Creates new VolumeBasedPanel
  78124. */
  78125. constructor();
  78126. protected _arrangeChildren(): void;
  78127. /** Child classes must implement this function to provide correct control positioning */
  78128. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78129. /** Child classes can implement this function to provide additional processing */
  78130. protected _finalProcessing(): void;
  78131. }
  78132. }
  78133. declare module BABYLON.GUI {
  78134. /**
  78135. * Class used to create a container panel deployed on the surface of a cylinder
  78136. */
  78137. export class CylinderPanel extends VolumeBasedPanel {
  78138. private _radius;
  78139. /**
  78140. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78141. */
  78142. get radius(): BABYLON.float;
  78143. set radius(value: BABYLON.float);
  78144. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78145. private _cylindricalMapping;
  78146. }
  78147. }
  78148. declare module BABYLON.GUI {
  78149. /** @hidden */
  78150. export var fluentVertexShader: {
  78151. name: string;
  78152. shader: string;
  78153. };
  78154. }
  78155. declare module BABYLON.GUI {
  78156. /** @hidden */
  78157. export var fluentPixelShader: {
  78158. name: string;
  78159. shader: string;
  78160. };
  78161. }
  78162. declare module BABYLON.GUI {
  78163. /** @hidden */
  78164. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78165. INNERGLOW: boolean;
  78166. BORDER: boolean;
  78167. HOVERLIGHT: boolean;
  78168. TEXTURE: boolean;
  78169. constructor();
  78170. }
  78171. /**
  78172. * Class used to render controls with fluent desgin
  78173. */
  78174. export class FluentMaterial extends BABYLON.PushMaterial {
  78175. /**
  78176. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78177. */
  78178. innerGlowColorIntensity: number;
  78179. /**
  78180. * Gets or sets the inner glow color (white by default)
  78181. */
  78182. innerGlowColor: BABYLON.Color3;
  78183. /**
  78184. * Gets or sets alpha value (default is 1.0)
  78185. */
  78186. alpha: number;
  78187. /**
  78188. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78189. */
  78190. albedoColor: BABYLON.Color3;
  78191. /**
  78192. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78193. */
  78194. renderBorders: boolean;
  78195. /**
  78196. * Gets or sets border width (default is 0.5)
  78197. */
  78198. borderWidth: number;
  78199. /**
  78200. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78201. */
  78202. edgeSmoothingValue: number;
  78203. /**
  78204. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78205. */
  78206. borderMinValue: number;
  78207. /**
  78208. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78209. */
  78210. renderHoverLight: boolean;
  78211. /**
  78212. * Gets or sets the radius used to render the hover light (default is 1.0)
  78213. */
  78214. hoverRadius: number;
  78215. /**
  78216. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78217. */
  78218. hoverColor: BABYLON.Color4;
  78219. /**
  78220. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78221. */
  78222. hoverPosition: BABYLON.Vector3;
  78223. private _albedoTexture;
  78224. /** Gets or sets the texture to use for albedo color */
  78225. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78226. /**
  78227. * Creates a new Fluent material
  78228. * @param name defines the name of the material
  78229. * @param scene defines the hosting scene
  78230. */
  78231. constructor(name: string, scene: BABYLON.Scene);
  78232. needAlphaBlending(): boolean;
  78233. needAlphaTesting(): boolean;
  78234. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78235. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78236. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78237. getActiveTextures(): BABYLON.BaseTexture[];
  78238. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78239. dispose(forceDisposeEffect?: boolean): void;
  78240. clone(name: string): FluentMaterial;
  78241. serialize(): any;
  78242. getClassName(): string;
  78243. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78244. }
  78245. }
  78246. declare module BABYLON.GUI {
  78247. /**
  78248. * Class used to create a holographic button in 3D
  78249. */
  78250. export class HolographicButton extends Button3D {
  78251. private _backPlate;
  78252. private _textPlate;
  78253. private _frontPlate;
  78254. private _text;
  78255. private _imageUrl;
  78256. private _shareMaterials;
  78257. private _frontMaterial;
  78258. private _backMaterial;
  78259. private _plateMaterial;
  78260. private _pickedPointObserver;
  78261. private _tooltipFade;
  78262. private _tooltipTextBlock;
  78263. private _tooltipTexture;
  78264. private _tooltipMesh;
  78265. private _tooltipHoverObserver;
  78266. private _tooltipOutObserver;
  78267. private _disposeTooltip;
  78268. /**
  78269. * Rendering ground id of all the mesh in the button
  78270. */
  78271. set renderingGroupId(id: number);
  78272. get renderingGroupId(): number;
  78273. /**
  78274. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78275. */
  78276. set tooltipText(text: BABYLON.Nullable<string>);
  78277. get tooltipText(): BABYLON.Nullable<string>;
  78278. /**
  78279. * Gets or sets text for the button
  78280. */
  78281. get text(): string;
  78282. set text(value: string);
  78283. /**
  78284. * Gets or sets the image url for the button
  78285. */
  78286. get imageUrl(): string;
  78287. set imageUrl(value: string);
  78288. /**
  78289. * Gets the back material used by this button
  78290. */
  78291. get backMaterial(): FluentMaterial;
  78292. /**
  78293. * Gets the front material used by this button
  78294. */
  78295. get frontMaterial(): FluentMaterial;
  78296. /**
  78297. * Gets the plate material used by this button
  78298. */
  78299. get plateMaterial(): BABYLON.StandardMaterial;
  78300. /**
  78301. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78302. */
  78303. get shareMaterials(): boolean;
  78304. /**
  78305. * Creates a new button
  78306. * @param name defines the control name
  78307. */
  78308. constructor(name?: string, shareMaterials?: boolean);
  78309. protected _getTypeName(): string;
  78310. private _rebuildContent;
  78311. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78312. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78313. private _createBackMaterial;
  78314. private _createFrontMaterial;
  78315. private _createPlateMaterial;
  78316. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78317. /**
  78318. * Releases all associated resources
  78319. */
  78320. dispose(): void;
  78321. }
  78322. }
  78323. declare module BABYLON.GUI {
  78324. /**
  78325. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78326. */
  78327. export class MeshButton3D extends Button3D {
  78328. /** @hidden */
  78329. protected _currentMesh: BABYLON.Mesh;
  78330. /**
  78331. * Creates a new 3D button based on a mesh
  78332. * @param mesh mesh to become a 3D button
  78333. * @param name defines the control name
  78334. */
  78335. constructor(mesh: BABYLON.Mesh, name?: string);
  78336. protected _getTypeName(): string;
  78337. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78338. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78339. }
  78340. }
  78341. declare module BABYLON.GUI {
  78342. /**
  78343. * Class used to create a container panel deployed on the surface of a plane
  78344. */
  78345. export class PlanePanel extends VolumeBasedPanel {
  78346. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78347. }
  78348. }
  78349. declare module BABYLON.GUI {
  78350. /**
  78351. * Class used to create a container panel where items get randomized planar mapping
  78352. */
  78353. export class ScatterPanel extends VolumeBasedPanel {
  78354. private _iteration;
  78355. /**
  78356. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78357. */
  78358. get iteration(): BABYLON.float;
  78359. set iteration(value: BABYLON.float);
  78360. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78361. private _scatterMapping;
  78362. protected _finalProcessing(): void;
  78363. }
  78364. }
  78365. declare module BABYLON.GUI {
  78366. /**
  78367. * Class used to create a container panel deployed on the surface of a sphere
  78368. */
  78369. export class SpherePanel extends VolumeBasedPanel {
  78370. private _radius;
  78371. /**
  78372. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78373. */
  78374. get radius(): BABYLON.float;
  78375. set radius(value: BABYLON.float);
  78376. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78377. private _sphericalMapping;
  78378. }
  78379. }
  78380. declare module BABYLON.GUI {
  78381. /**
  78382. * Class used to create a stack panel in 3D on XY plane
  78383. */
  78384. export class StackPanel3D extends Container3D {
  78385. private _isVertical;
  78386. /**
  78387. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78388. */
  78389. get isVertical(): boolean;
  78390. set isVertical(value: boolean);
  78391. /**
  78392. * Gets or sets the distance between elements
  78393. */
  78394. margin: number;
  78395. /**
  78396. * Creates new StackPanel
  78397. * @param isVertical
  78398. */
  78399. constructor(isVertical?: boolean);
  78400. protected _arrangeChildren(): void;
  78401. }
  78402. }
  78403. declare module BABYLON {
  78404. /**
  78405. * Configuration for glTF validation
  78406. */
  78407. export interface IGLTFValidationConfiguration {
  78408. /**
  78409. * The url of the glTF validator.
  78410. */
  78411. url: string;
  78412. }
  78413. /**
  78414. * glTF validation
  78415. */
  78416. export class GLTFValidation {
  78417. /**
  78418. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78419. */
  78420. static Configuration: IGLTFValidationConfiguration;
  78421. private static _LoadScriptPromise;
  78422. /**
  78423. * Validate a glTF asset using the glTF-Validator.
  78424. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78425. * @param rootUrl The root url for the glTF
  78426. * @param fileName The file name for the glTF
  78427. * @param getExternalResource The callback to get external resources for the glTF validator
  78428. * @returns A promise that resolves with the glTF validation results once complete
  78429. */
  78430. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78431. }
  78432. }
  78433. declare module BABYLON {
  78434. /**
  78435. * Mode that determines the coordinate system to use.
  78436. */
  78437. export enum GLTFLoaderCoordinateSystemMode {
  78438. /**
  78439. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78440. */
  78441. AUTO = 0,
  78442. /**
  78443. * Sets the useRightHandedSystem flag on the scene.
  78444. */
  78445. FORCE_RIGHT_HANDED = 1
  78446. }
  78447. /**
  78448. * Mode that determines what animations will start.
  78449. */
  78450. export enum GLTFLoaderAnimationStartMode {
  78451. /**
  78452. * No animation will start.
  78453. */
  78454. NONE = 0,
  78455. /**
  78456. * The first animation will start.
  78457. */
  78458. FIRST = 1,
  78459. /**
  78460. * All animations will start.
  78461. */
  78462. ALL = 2
  78463. }
  78464. /**
  78465. * Interface that contains the data for the glTF asset.
  78466. */
  78467. export interface IGLTFLoaderData {
  78468. /**
  78469. * The object that represents the glTF JSON.
  78470. */
  78471. json: Object;
  78472. /**
  78473. * The BIN chunk of a binary glTF.
  78474. */
  78475. bin: Nullable<IDataBuffer>;
  78476. }
  78477. /**
  78478. * Interface for extending the loader.
  78479. */
  78480. export interface IGLTFLoaderExtension {
  78481. /**
  78482. * The name of this extension.
  78483. */
  78484. readonly name: string;
  78485. /**
  78486. * Defines whether this extension is enabled.
  78487. */
  78488. enabled: boolean;
  78489. /**
  78490. * Defines the order of this extension.
  78491. * The loader sorts the extensions using these values when loading.
  78492. */
  78493. order?: number;
  78494. }
  78495. /**
  78496. * Loader state.
  78497. */
  78498. export enum GLTFLoaderState {
  78499. /**
  78500. * The asset is loading.
  78501. */
  78502. LOADING = 0,
  78503. /**
  78504. * The asset is ready for rendering.
  78505. */
  78506. READY = 1,
  78507. /**
  78508. * The asset is completely loaded.
  78509. */
  78510. COMPLETE = 2
  78511. }
  78512. /** @hidden */
  78513. export interface IImportMeshAsyncOutput {
  78514. meshes: AbstractMesh[];
  78515. particleSystems: IParticleSystem[];
  78516. skeletons: Skeleton[];
  78517. animationGroups: AnimationGroup[];
  78518. lights: Light[];
  78519. transformNodes: TransformNode[];
  78520. }
  78521. /** @hidden */
  78522. export interface IGLTFLoader extends IDisposable {
  78523. readonly state: Nullable<GLTFLoaderState>;
  78524. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78525. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  78526. }
  78527. /**
  78528. * File loader for loading glTF files into a scene.
  78529. */
  78530. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78531. /** @hidden */
  78532. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78533. /** @hidden */
  78534. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78535. /**
  78536. * Raised when the asset has been parsed
  78537. */
  78538. onParsedObservable: Observable<IGLTFLoaderData>;
  78539. private _onParsedObserver;
  78540. /**
  78541. * Raised when the asset has been parsed
  78542. */
  78543. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  78544. /**
  78545. * 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.
  78546. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  78547. * Defaults to true.
  78548. * @hidden
  78549. */
  78550. static IncrementalLoading: boolean;
  78551. /**
  78552. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78553. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78554. * @hidden
  78555. */
  78556. static HomogeneousCoordinates: boolean;
  78557. /**
  78558. * The coordinate system mode. Defaults to AUTO.
  78559. */
  78560. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78561. /**
  78562. * The animation start mode. Defaults to FIRST.
  78563. */
  78564. animationStartMode: GLTFLoaderAnimationStartMode;
  78565. /**
  78566. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78567. */
  78568. compileMaterials: boolean;
  78569. /**
  78570. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78571. */
  78572. useClipPlane: boolean;
  78573. /**
  78574. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  78575. */
  78576. compileShadowGenerators: boolean;
  78577. /**
  78578. * Defines if the Alpha blended materials are only applied as coverage.
  78579. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  78580. * If true, no extra effects are applied to transparent pixels.
  78581. */
  78582. transparencyAsCoverage: boolean;
  78583. /**
  78584. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  78585. * Enabling will disable offline support and glTF validator.
  78586. * Defaults to false.
  78587. */
  78588. useRangeRequests: boolean;
  78589. /**
  78590. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  78591. */
  78592. createInstances: boolean;
  78593. /**
  78594. * Function called before loading a url referenced by the asset.
  78595. */
  78596. preprocessUrlAsync: (url: string) => Promise<string>;
  78597. /**
  78598. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78599. */
  78600. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  78601. private _onMeshLoadedObserver;
  78602. /**
  78603. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78604. */
  78605. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  78606. /**
  78607. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  78608. */
  78609. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  78610. private _onTextureLoadedObserver;
  78611. /**
  78612. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  78613. */
  78614. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  78615. /**
  78616. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  78617. */
  78618. readonly onMaterialLoadedObservable: Observable<Material>;
  78619. private _onMaterialLoadedObserver;
  78620. /**
  78621. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  78622. */
  78623. set onMaterialLoaded(callback: (material: Material) => void);
  78624. /**
  78625. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  78626. */
  78627. readonly onCameraLoadedObservable: Observable<Camera>;
  78628. private _onCameraLoadedObserver;
  78629. /**
  78630. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  78631. */
  78632. set onCameraLoaded(callback: (camera: Camera) => void);
  78633. /**
  78634. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  78635. * For assets with LODs, raised when all of the LODs are complete.
  78636. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78637. */
  78638. readonly onCompleteObservable: Observable<void>;
  78639. private _onCompleteObserver;
  78640. /**
  78641. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78642. * For assets with LODs, raised when all of the LODs are complete.
  78643. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78644. */
  78645. set onComplete(callback: () => void);
  78646. /**
  78647. * Observable raised when an error occurs.
  78648. */
  78649. readonly onErrorObservable: Observable<any>;
  78650. private _onErrorObserver;
  78651. /**
  78652. * Callback raised when an error occurs.
  78653. */
  78654. set onError(callback: (reason: any) => void);
  78655. /**
  78656. * Observable raised after the loader is disposed.
  78657. */
  78658. readonly onDisposeObservable: Observable<void>;
  78659. private _onDisposeObserver;
  78660. /**
  78661. * Callback raised after the loader is disposed.
  78662. */
  78663. set onDispose(callback: () => void);
  78664. /**
  78665. * Observable raised after a loader extension is created.
  78666. * Set additional options for a loader extension in this event.
  78667. */
  78668. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  78669. private _onExtensionLoadedObserver;
  78670. /**
  78671. * Callback raised after a loader extension is created.
  78672. */
  78673. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  78674. /**
  78675. * Defines if the loader logging is enabled.
  78676. */
  78677. get loggingEnabled(): boolean;
  78678. set loggingEnabled(value: boolean);
  78679. /**
  78680. * Defines if the loader should capture performance counters.
  78681. */
  78682. get capturePerformanceCounters(): boolean;
  78683. set capturePerformanceCounters(value: boolean);
  78684. /**
  78685. * Defines if the loader should validate the asset.
  78686. */
  78687. validate: boolean;
  78688. /**
  78689. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  78690. */
  78691. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  78692. private _onValidatedObserver;
  78693. /**
  78694. * Callback raised after a loader extension is created.
  78695. */
  78696. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  78697. private _loader;
  78698. private _progressCallback?;
  78699. private _requests;
  78700. /**
  78701. * Name of the loader ("gltf")
  78702. */
  78703. name: string;
  78704. /** @hidden */
  78705. extensions: ISceneLoaderPluginExtensions;
  78706. /**
  78707. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  78708. */
  78709. dispose(): void;
  78710. /** @hidden */
  78711. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78712. /** @hidden */
  78713. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78714. /** @hidden */
  78715. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78716. meshes: AbstractMesh[];
  78717. particleSystems: IParticleSystem[];
  78718. skeletons: Skeleton[];
  78719. animationGroups: AnimationGroup[];
  78720. }>;
  78721. /** @hidden */
  78722. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78723. /** @hidden */
  78724. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78725. /** @hidden */
  78726. canDirectLoad(data: string): boolean;
  78727. /** @hidden */
  78728. directLoad(scene: Scene, data: string): any;
  78729. /**
  78730. * The callback that allows custom handling of the root url based on the response url.
  78731. * @param rootUrl the original root url
  78732. * @param responseURL the response url if available
  78733. * @returns the new root url
  78734. */
  78735. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  78736. /** @hidden */
  78737. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  78738. /**
  78739. * The loader state or null if the loader is not active.
  78740. */
  78741. get loaderState(): Nullable<GLTFLoaderState>;
  78742. /**
  78743. * Returns a promise that resolves when the asset is completely loaded.
  78744. * @returns a promise that resolves when the asset is completely loaded.
  78745. */
  78746. whenCompleteAsync(): Promise<void>;
  78747. /** @hidden */
  78748. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  78749. /** @hidden */
  78750. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  78751. private _onProgress;
  78752. private _validate;
  78753. private _getLoader;
  78754. private _parseJson;
  78755. private _unpackBinaryAsync;
  78756. private _unpackBinaryV1Async;
  78757. private _unpackBinaryV2Async;
  78758. private static _parseVersion;
  78759. private static _compareVersion;
  78760. private static readonly _logSpaces;
  78761. private _logIndentLevel;
  78762. private _loggingEnabled;
  78763. /** @hidden */
  78764. _log: (message: string) => void;
  78765. /** @hidden */
  78766. _logOpen(message: string): void;
  78767. /** @hidden */
  78768. _logClose(): void;
  78769. private _logEnabled;
  78770. private _logDisabled;
  78771. private _capturePerformanceCounters;
  78772. /** @hidden */
  78773. _startPerformanceCounter: (counterName: string) => void;
  78774. /** @hidden */
  78775. _endPerformanceCounter: (counterName: string) => void;
  78776. private _startPerformanceCounterEnabled;
  78777. private _startPerformanceCounterDisabled;
  78778. private _endPerformanceCounterEnabled;
  78779. private _endPerformanceCounterDisabled;
  78780. }
  78781. }
  78782. declare module BABYLON.GLTF1 {
  78783. /**
  78784. * Enums
  78785. * @hidden
  78786. */
  78787. export enum EComponentType {
  78788. BYTE = 5120,
  78789. UNSIGNED_BYTE = 5121,
  78790. SHORT = 5122,
  78791. UNSIGNED_SHORT = 5123,
  78792. FLOAT = 5126
  78793. }
  78794. /** @hidden */
  78795. export enum EShaderType {
  78796. FRAGMENT = 35632,
  78797. VERTEX = 35633
  78798. }
  78799. /** @hidden */
  78800. export enum EParameterType {
  78801. BYTE = 5120,
  78802. UNSIGNED_BYTE = 5121,
  78803. SHORT = 5122,
  78804. UNSIGNED_SHORT = 5123,
  78805. INT = 5124,
  78806. UNSIGNED_INT = 5125,
  78807. FLOAT = 5126,
  78808. FLOAT_VEC2 = 35664,
  78809. FLOAT_VEC3 = 35665,
  78810. FLOAT_VEC4 = 35666,
  78811. INT_VEC2 = 35667,
  78812. INT_VEC3 = 35668,
  78813. INT_VEC4 = 35669,
  78814. BOOL = 35670,
  78815. BOOL_VEC2 = 35671,
  78816. BOOL_VEC3 = 35672,
  78817. BOOL_VEC4 = 35673,
  78818. FLOAT_MAT2 = 35674,
  78819. FLOAT_MAT3 = 35675,
  78820. FLOAT_MAT4 = 35676,
  78821. SAMPLER_2D = 35678
  78822. }
  78823. /** @hidden */
  78824. export enum ETextureWrapMode {
  78825. CLAMP_TO_EDGE = 33071,
  78826. MIRRORED_REPEAT = 33648,
  78827. REPEAT = 10497
  78828. }
  78829. /** @hidden */
  78830. export enum ETextureFilterType {
  78831. NEAREST = 9728,
  78832. LINEAR = 9728,
  78833. NEAREST_MIPMAP_NEAREST = 9984,
  78834. LINEAR_MIPMAP_NEAREST = 9985,
  78835. NEAREST_MIPMAP_LINEAR = 9986,
  78836. LINEAR_MIPMAP_LINEAR = 9987
  78837. }
  78838. /** @hidden */
  78839. export enum ETextureFormat {
  78840. ALPHA = 6406,
  78841. RGB = 6407,
  78842. RGBA = 6408,
  78843. LUMINANCE = 6409,
  78844. LUMINANCE_ALPHA = 6410
  78845. }
  78846. /** @hidden */
  78847. export enum ECullingType {
  78848. FRONT = 1028,
  78849. BACK = 1029,
  78850. FRONT_AND_BACK = 1032
  78851. }
  78852. /** @hidden */
  78853. export enum EBlendingFunction {
  78854. ZERO = 0,
  78855. ONE = 1,
  78856. SRC_COLOR = 768,
  78857. ONE_MINUS_SRC_COLOR = 769,
  78858. DST_COLOR = 774,
  78859. ONE_MINUS_DST_COLOR = 775,
  78860. SRC_ALPHA = 770,
  78861. ONE_MINUS_SRC_ALPHA = 771,
  78862. DST_ALPHA = 772,
  78863. ONE_MINUS_DST_ALPHA = 773,
  78864. CONSTANT_COLOR = 32769,
  78865. ONE_MINUS_CONSTANT_COLOR = 32770,
  78866. CONSTANT_ALPHA = 32771,
  78867. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78868. SRC_ALPHA_SATURATE = 776
  78869. }
  78870. /** @hidden */
  78871. export interface IGLTFProperty {
  78872. extensions?: {
  78873. [key: string]: any;
  78874. };
  78875. extras?: Object;
  78876. }
  78877. /** @hidden */
  78878. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78879. name?: string;
  78880. }
  78881. /** @hidden */
  78882. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78883. bufferView: string;
  78884. byteOffset: number;
  78885. byteStride: number;
  78886. count: number;
  78887. type: string;
  78888. componentType: EComponentType;
  78889. max?: number[];
  78890. min?: number[];
  78891. name?: string;
  78892. }
  78893. /** @hidden */
  78894. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78895. buffer: string;
  78896. byteOffset: number;
  78897. byteLength: number;
  78898. byteStride: number;
  78899. target?: number;
  78900. }
  78901. /** @hidden */
  78902. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78903. uri: string;
  78904. byteLength?: number;
  78905. type?: string;
  78906. }
  78907. /** @hidden */
  78908. export interface IGLTFShader extends IGLTFChildRootProperty {
  78909. uri: string;
  78910. type: EShaderType;
  78911. }
  78912. /** @hidden */
  78913. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78914. attributes: string[];
  78915. fragmentShader: string;
  78916. vertexShader: string;
  78917. }
  78918. /** @hidden */
  78919. export interface IGLTFTechniqueParameter {
  78920. type: number;
  78921. count?: number;
  78922. semantic?: string;
  78923. node?: string;
  78924. value?: number | boolean | string | Array<any>;
  78925. source?: string;
  78926. babylonValue?: any;
  78927. }
  78928. /** @hidden */
  78929. export interface IGLTFTechniqueCommonProfile {
  78930. lightingModel: string;
  78931. texcoordBindings: Object;
  78932. parameters?: Array<any>;
  78933. }
  78934. /** @hidden */
  78935. export interface IGLTFTechniqueStatesFunctions {
  78936. blendColor?: number[];
  78937. blendEquationSeparate?: number[];
  78938. blendFuncSeparate?: number[];
  78939. colorMask: boolean[];
  78940. cullFace: number[];
  78941. }
  78942. /** @hidden */
  78943. export interface IGLTFTechniqueStates {
  78944. enable: number[];
  78945. functions: IGLTFTechniqueStatesFunctions;
  78946. }
  78947. /** @hidden */
  78948. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78949. parameters: {
  78950. [key: string]: IGLTFTechniqueParameter;
  78951. };
  78952. program: string;
  78953. attributes: {
  78954. [key: string]: string;
  78955. };
  78956. uniforms: {
  78957. [key: string]: string;
  78958. };
  78959. states: IGLTFTechniqueStates;
  78960. }
  78961. /** @hidden */
  78962. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78963. technique?: string;
  78964. values: string[];
  78965. }
  78966. /** @hidden */
  78967. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78968. attributes: {
  78969. [key: string]: string;
  78970. };
  78971. indices: string;
  78972. material: string;
  78973. mode?: number;
  78974. }
  78975. /** @hidden */
  78976. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78977. primitives: IGLTFMeshPrimitive[];
  78978. }
  78979. /** @hidden */
  78980. export interface IGLTFImage extends IGLTFChildRootProperty {
  78981. uri: string;
  78982. }
  78983. /** @hidden */
  78984. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78985. magFilter?: number;
  78986. minFilter?: number;
  78987. wrapS?: number;
  78988. wrapT?: number;
  78989. }
  78990. /** @hidden */
  78991. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78992. sampler: string;
  78993. source: string;
  78994. format?: ETextureFormat;
  78995. internalFormat?: ETextureFormat;
  78996. target?: number;
  78997. type?: number;
  78998. babylonTexture?: Texture;
  78999. }
  79000. /** @hidden */
  79001. export interface IGLTFAmbienLight {
  79002. color?: number[];
  79003. }
  79004. /** @hidden */
  79005. export interface IGLTFDirectionalLight {
  79006. color?: number[];
  79007. }
  79008. /** @hidden */
  79009. export interface IGLTFPointLight {
  79010. color?: number[];
  79011. constantAttenuation?: number;
  79012. linearAttenuation?: number;
  79013. quadraticAttenuation?: number;
  79014. }
  79015. /** @hidden */
  79016. export interface IGLTFSpotLight {
  79017. color?: number[];
  79018. constantAttenuation?: number;
  79019. fallOfAngle?: number;
  79020. fallOffExponent?: number;
  79021. linearAttenuation?: number;
  79022. quadraticAttenuation?: number;
  79023. }
  79024. /** @hidden */
  79025. export interface IGLTFLight extends IGLTFChildRootProperty {
  79026. type: string;
  79027. }
  79028. /** @hidden */
  79029. export interface IGLTFCameraOrthographic {
  79030. xmag: number;
  79031. ymag: number;
  79032. zfar: number;
  79033. znear: number;
  79034. }
  79035. /** @hidden */
  79036. export interface IGLTFCameraPerspective {
  79037. aspectRatio: number;
  79038. yfov: number;
  79039. zfar: number;
  79040. znear: number;
  79041. }
  79042. /** @hidden */
  79043. export interface IGLTFCamera extends IGLTFChildRootProperty {
  79044. type: string;
  79045. }
  79046. /** @hidden */
  79047. export interface IGLTFAnimationChannelTarget {
  79048. id: string;
  79049. path: string;
  79050. }
  79051. /** @hidden */
  79052. export interface IGLTFAnimationChannel {
  79053. sampler: string;
  79054. target: IGLTFAnimationChannelTarget;
  79055. }
  79056. /** @hidden */
  79057. export interface IGLTFAnimationSampler {
  79058. input: string;
  79059. output: string;
  79060. interpolation?: string;
  79061. }
  79062. /** @hidden */
  79063. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  79064. channels?: IGLTFAnimationChannel[];
  79065. parameters?: {
  79066. [key: string]: string;
  79067. };
  79068. samplers?: {
  79069. [key: string]: IGLTFAnimationSampler;
  79070. };
  79071. }
  79072. /** @hidden */
  79073. export interface IGLTFNodeInstanceSkin {
  79074. skeletons: string[];
  79075. skin: string;
  79076. meshes: string[];
  79077. }
  79078. /** @hidden */
  79079. export interface IGLTFSkins extends IGLTFChildRootProperty {
  79080. bindShapeMatrix: number[];
  79081. inverseBindMatrices: string;
  79082. jointNames: string[];
  79083. babylonSkeleton?: Skeleton;
  79084. }
  79085. /** @hidden */
  79086. export interface IGLTFNode extends IGLTFChildRootProperty {
  79087. camera?: string;
  79088. children: string[];
  79089. skin?: string;
  79090. jointName?: string;
  79091. light?: string;
  79092. matrix: number[];
  79093. mesh?: string;
  79094. meshes?: string[];
  79095. rotation?: number[];
  79096. scale?: number[];
  79097. translation?: number[];
  79098. babylonNode?: Node;
  79099. }
  79100. /** @hidden */
  79101. export interface IGLTFScene extends IGLTFChildRootProperty {
  79102. nodes: string[];
  79103. }
  79104. /** @hidden */
  79105. export interface IGLTFRuntime {
  79106. extensions: {
  79107. [key: string]: any;
  79108. };
  79109. accessors: {
  79110. [key: string]: IGLTFAccessor;
  79111. };
  79112. buffers: {
  79113. [key: string]: IGLTFBuffer;
  79114. };
  79115. bufferViews: {
  79116. [key: string]: IGLTFBufferView;
  79117. };
  79118. meshes: {
  79119. [key: string]: IGLTFMesh;
  79120. };
  79121. lights: {
  79122. [key: string]: IGLTFLight;
  79123. };
  79124. cameras: {
  79125. [key: string]: IGLTFCamera;
  79126. };
  79127. nodes: {
  79128. [key: string]: IGLTFNode;
  79129. };
  79130. images: {
  79131. [key: string]: IGLTFImage;
  79132. };
  79133. textures: {
  79134. [key: string]: IGLTFTexture;
  79135. };
  79136. shaders: {
  79137. [key: string]: IGLTFShader;
  79138. };
  79139. programs: {
  79140. [key: string]: IGLTFProgram;
  79141. };
  79142. samplers: {
  79143. [key: string]: IGLTFSampler;
  79144. };
  79145. techniques: {
  79146. [key: string]: IGLTFTechnique;
  79147. };
  79148. materials: {
  79149. [key: string]: IGLTFMaterial;
  79150. };
  79151. animations: {
  79152. [key: string]: IGLTFAnimation;
  79153. };
  79154. skins: {
  79155. [key: string]: IGLTFSkins;
  79156. };
  79157. currentScene?: Object;
  79158. scenes: {
  79159. [key: string]: IGLTFScene;
  79160. };
  79161. extensionsUsed: string[];
  79162. extensionsRequired?: string[];
  79163. buffersCount: number;
  79164. shaderscount: number;
  79165. scene: Scene;
  79166. rootUrl: string;
  79167. loadedBufferCount: number;
  79168. loadedBufferViews: {
  79169. [name: string]: ArrayBufferView;
  79170. };
  79171. loadedShaderCount: number;
  79172. importOnlyMeshes: boolean;
  79173. importMeshesNames?: string[];
  79174. dummyNodes: Node[];
  79175. forAssetContainer: boolean;
  79176. }
  79177. /** @hidden */
  79178. export interface INodeToRoot {
  79179. bone: Bone;
  79180. node: IGLTFNode;
  79181. id: string;
  79182. }
  79183. /** @hidden */
  79184. export interface IJointNode {
  79185. node: IGLTFNode;
  79186. id: string;
  79187. }
  79188. }
  79189. declare module BABYLON.GLTF1 {
  79190. /**
  79191. * Utils functions for GLTF
  79192. * @hidden
  79193. */
  79194. export class GLTFUtils {
  79195. /**
  79196. * Sets the given "parameter" matrix
  79197. * @param scene: the Scene object
  79198. * @param source: the source node where to pick the matrix
  79199. * @param parameter: the GLTF technique parameter
  79200. * @param uniformName: the name of the shader's uniform
  79201. * @param shaderMaterial: the shader material
  79202. */
  79203. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79204. /**
  79205. * Sets the given "parameter" matrix
  79206. * @param shaderMaterial: the shader material
  79207. * @param uniform: the name of the shader's uniform
  79208. * @param value: the value of the uniform
  79209. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79210. */
  79211. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79212. /**
  79213. * Returns the wrap mode of the texture
  79214. * @param mode: the mode value
  79215. */
  79216. static GetWrapMode(mode: number): number;
  79217. /**
  79218. * Returns the byte stride giving an accessor
  79219. * @param accessor: the GLTF accessor objet
  79220. */
  79221. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79222. /**
  79223. * Returns the texture filter mode giving a mode value
  79224. * @param mode: the filter mode value
  79225. */
  79226. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79227. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79228. /**
  79229. * Returns a buffer from its accessor
  79230. * @param gltfRuntime: the GLTF runtime
  79231. * @param accessor: the GLTF accessor
  79232. */
  79233. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79234. /**
  79235. * Decodes a buffer view into a string
  79236. * @param view: the buffer view
  79237. */
  79238. static DecodeBufferToText(view: ArrayBufferView): string;
  79239. /**
  79240. * Returns the default material of gltf. Related to
  79241. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79242. * @param scene: the Babylon.js scene
  79243. */
  79244. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79245. private static _DefaultMaterial;
  79246. }
  79247. }
  79248. declare module BABYLON.GLTF1 {
  79249. /**
  79250. * Implementation of the base glTF spec
  79251. * @hidden
  79252. */
  79253. export class GLTFLoaderBase {
  79254. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79255. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79256. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79257. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79258. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79259. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79260. }
  79261. /**
  79262. * glTF V1 Loader
  79263. * @hidden
  79264. */
  79265. export class GLTFLoader implements IGLTFLoader {
  79266. static Extensions: {
  79267. [name: string]: GLTFLoaderExtension;
  79268. };
  79269. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79270. state: Nullable<GLTFLoaderState>;
  79271. dispose(): void;
  79272. private _importMeshAsync;
  79273. /**
  79274. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79275. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79276. * @param scene the scene the meshes should be added to
  79277. * @param forAssetContainer defines if the entities must be stored in the scene
  79278. * @param data gltf data containing information of the meshes in a loaded file
  79279. * @param rootUrl root url to load from
  79280. * @param onProgress event that fires when loading progress has occured
  79281. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79282. */
  79283. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79284. private _loadAsync;
  79285. /**
  79286. * Imports all objects from a loaded gltf file and adds them to the scene
  79287. * @param scene the scene the objects should be added to
  79288. * @param data gltf data containing information of the meshes in a loaded file
  79289. * @param rootUrl root url to load from
  79290. * @param onProgress event that fires when loading progress has occured
  79291. * @returns a promise which completes when objects have been loaded to the scene
  79292. */
  79293. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  79294. private _loadShadersAsync;
  79295. private _loadBuffersAsync;
  79296. private _createNodes;
  79297. }
  79298. /** @hidden */
  79299. export abstract class GLTFLoaderExtension {
  79300. private _name;
  79301. constructor(name: string);
  79302. get name(): string;
  79303. /**
  79304. * Defines an override for loading the runtime
  79305. * Return true to stop further extensions from loading the runtime
  79306. */
  79307. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79308. /**
  79309. * Defines an onverride for creating gltf runtime
  79310. * Return true to stop further extensions from creating the runtime
  79311. */
  79312. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79313. /**
  79314. * Defines an override for loading buffers
  79315. * Return true to stop further extensions from loading this buffer
  79316. */
  79317. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79318. /**
  79319. * Defines an override for loading texture buffers
  79320. * Return true to stop further extensions from loading this texture data
  79321. */
  79322. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79323. /**
  79324. * Defines an override for creating textures
  79325. * Return true to stop further extensions from loading this texture
  79326. */
  79327. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79328. /**
  79329. * Defines an override for loading shader strings
  79330. * Return true to stop further extensions from loading this shader data
  79331. */
  79332. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79333. /**
  79334. * Defines an override for loading materials
  79335. * Return true to stop further extensions from loading this material
  79336. */
  79337. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79338. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79339. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79340. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79341. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79342. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79343. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79344. private static LoadTextureBufferAsync;
  79345. private static CreateTextureAsync;
  79346. private static ApplyExtensions;
  79347. }
  79348. }
  79349. declare module BABYLON.GLTF1 {
  79350. /** @hidden */
  79351. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79352. private _bin;
  79353. constructor();
  79354. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79355. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79356. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79357. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79358. }
  79359. }
  79360. declare module BABYLON.GLTF1 {
  79361. /** @hidden */
  79362. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79363. constructor();
  79364. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79365. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79366. private _loadTexture;
  79367. }
  79368. }
  79369. declare module BABYLON.GLTF2.Loader {
  79370. /**
  79371. * Loader interface with an index field.
  79372. */
  79373. export interface IArrayItem {
  79374. /**
  79375. * The index of this item in the array.
  79376. */
  79377. index: number;
  79378. }
  79379. /**
  79380. * Loader interface with additional members.
  79381. */
  79382. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79383. /** @hidden */
  79384. _data?: Promise<ArrayBufferView>;
  79385. /** @hidden */
  79386. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79387. }
  79388. /**
  79389. * Loader interface with additional members.
  79390. */
  79391. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79392. }
  79393. /** @hidden */
  79394. export interface _IAnimationSamplerData {
  79395. input: Float32Array;
  79396. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79397. output: Float32Array;
  79398. }
  79399. /**
  79400. * Loader interface with additional members.
  79401. */
  79402. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79403. /** @hidden */
  79404. _data?: Promise<_IAnimationSamplerData>;
  79405. }
  79406. /**
  79407. * Loader interface with additional members.
  79408. */
  79409. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79410. channels: IAnimationChannel[];
  79411. samplers: IAnimationSampler[];
  79412. /** @hidden */
  79413. _babylonAnimationGroup?: AnimationGroup;
  79414. }
  79415. /**
  79416. * Loader interface with additional members.
  79417. */
  79418. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79419. /** @hidden */
  79420. _data?: Promise<ArrayBufferView>;
  79421. }
  79422. /**
  79423. * Loader interface with additional members.
  79424. */
  79425. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79426. /** @hidden */
  79427. _data?: Promise<ArrayBufferView>;
  79428. /** @hidden */
  79429. _babylonBuffer?: Promise<Buffer>;
  79430. }
  79431. /**
  79432. * Loader interface with additional members.
  79433. */
  79434. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79435. }
  79436. /**
  79437. * Loader interface with additional members.
  79438. */
  79439. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79440. /** @hidden */
  79441. _data?: Promise<ArrayBufferView>;
  79442. }
  79443. /**
  79444. * Loader interface with additional members.
  79445. */
  79446. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79447. }
  79448. /**
  79449. * Loader interface with additional members.
  79450. */
  79451. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79452. }
  79453. /**
  79454. * Loader interface with additional members.
  79455. */
  79456. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79457. baseColorTexture?: ITextureInfo;
  79458. metallicRoughnessTexture?: ITextureInfo;
  79459. }
  79460. /**
  79461. * Loader interface with additional members.
  79462. */
  79463. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79464. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79465. normalTexture?: IMaterialNormalTextureInfo;
  79466. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79467. emissiveTexture?: ITextureInfo;
  79468. /** @hidden */
  79469. _data?: {
  79470. [babylonDrawMode: number]: {
  79471. babylonMaterial: Material;
  79472. babylonMeshes: AbstractMesh[];
  79473. promise: Promise<void>;
  79474. };
  79475. };
  79476. }
  79477. /**
  79478. * Loader interface with additional members.
  79479. */
  79480. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79481. primitives: IMeshPrimitive[];
  79482. }
  79483. /**
  79484. * Loader interface with additional members.
  79485. */
  79486. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79487. /** @hidden */
  79488. _instanceData?: {
  79489. babylonSourceMesh: Mesh;
  79490. promise: Promise<any>;
  79491. };
  79492. }
  79493. /**
  79494. * Loader interface with additional members.
  79495. */
  79496. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79497. /**
  79498. * The parent glTF node.
  79499. */
  79500. parent?: INode;
  79501. /** @hidden */
  79502. _babylonTransformNode?: TransformNode;
  79503. /** @hidden */
  79504. _primitiveBabylonMeshes?: AbstractMesh[];
  79505. /** @hidden */
  79506. _babylonBones?: Bone[];
  79507. /** @hidden */
  79508. _numMorphTargets?: number;
  79509. }
  79510. /** @hidden */
  79511. export interface _ISamplerData {
  79512. noMipMaps: boolean;
  79513. samplingMode: number;
  79514. wrapU: number;
  79515. wrapV: number;
  79516. }
  79517. /**
  79518. * Loader interface with additional members.
  79519. */
  79520. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  79521. /** @hidden */
  79522. _data?: _ISamplerData;
  79523. }
  79524. /**
  79525. * Loader interface with additional members.
  79526. */
  79527. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  79528. }
  79529. /**
  79530. * Loader interface with additional members.
  79531. */
  79532. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  79533. /** @hidden */
  79534. _data?: {
  79535. babylonSkeleton: Skeleton;
  79536. promise: Promise<void>;
  79537. };
  79538. }
  79539. /**
  79540. * Loader interface with additional members.
  79541. */
  79542. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  79543. }
  79544. /**
  79545. * Loader interface with additional members.
  79546. */
  79547. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  79548. }
  79549. /**
  79550. * Loader interface with additional members.
  79551. */
  79552. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  79553. accessors?: IAccessor[];
  79554. animations?: IAnimation[];
  79555. buffers?: IBuffer[];
  79556. bufferViews?: IBufferView[];
  79557. cameras?: ICamera[];
  79558. images?: IImage[];
  79559. materials?: IMaterial[];
  79560. meshes?: IMesh[];
  79561. nodes?: INode[];
  79562. samplers?: ISampler[];
  79563. scenes?: IScene[];
  79564. skins?: ISkin[];
  79565. textures?: ITexture[];
  79566. }
  79567. }
  79568. declare module BABYLON.GLTF2 {
  79569. /**
  79570. * Interface for a glTF loader extension.
  79571. */
  79572. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  79573. /**
  79574. * Called after the loader state changes to LOADING.
  79575. */
  79576. onLoading?(): void;
  79577. /**
  79578. * Called after the loader state changes to READY.
  79579. */
  79580. onReady?(): void;
  79581. /**
  79582. * Define this method to modify the default behavior when loading scenes.
  79583. * @param context The context when loading the asset
  79584. * @param scene The glTF scene property
  79585. * @returns A promise that resolves when the load is complete or null if not handled
  79586. */
  79587. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  79588. /**
  79589. * Define this method to modify the default behavior when loading nodes.
  79590. * @param context The context when loading the asset
  79591. * @param node The glTF node property
  79592. * @param assign A function called synchronously after parsing the glTF properties
  79593. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  79594. */
  79595. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79596. /**
  79597. * Define this method to modify the default behavior when loading cameras.
  79598. * @param context The context when loading the asset
  79599. * @param camera The glTF camera property
  79600. * @param assign A function called synchronously after parsing the glTF properties
  79601. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  79602. */
  79603. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79604. /**
  79605. * @hidden
  79606. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  79607. * @param context The context when loading the asset
  79608. * @param primitive The glTF mesh primitive property
  79609. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  79610. */
  79611. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79612. /**
  79613. * @hidden
  79614. * Define this method to modify the default behavior when loading data for mesh primitives.
  79615. * @param context The context when loading the asset
  79616. * @param name The mesh name when loading the asset
  79617. * @param node The glTF node when loading the asset
  79618. * @param mesh The glTF mesh when loading the asset
  79619. * @param primitive The glTF mesh primitive property
  79620. * @param assign A function called synchronously after parsing the glTF properties
  79621. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79622. */
  79623. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  79624. /**
  79625. * @hidden
  79626. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  79627. * @param context The context when loading the asset
  79628. * @param material The glTF material property
  79629. * @param assign A function called synchronously after parsing the glTF properties
  79630. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  79631. */
  79632. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79633. /**
  79634. * Define this method to modify the default behavior when creating materials.
  79635. * @param context The context when loading the asset
  79636. * @param material The glTF material property
  79637. * @param babylonDrawMode The draw mode for the Babylon material
  79638. * @returns The Babylon material or null if not handled
  79639. */
  79640. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79641. /**
  79642. * Define this method to modify the default behavior when loading material properties.
  79643. * @param context The context when loading the asset
  79644. * @param material The glTF material property
  79645. * @param babylonMaterial The Babylon material
  79646. * @returns A promise that resolves when the load is complete or null if not handled
  79647. */
  79648. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79649. /**
  79650. * Define this method to modify the default behavior when loading texture infos.
  79651. * @param context The context when loading the asset
  79652. * @param textureInfo The glTF texture info property
  79653. * @param assign A function called synchronously after parsing the glTF properties
  79654. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79655. */
  79656. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79657. /**
  79658. * @hidden
  79659. * Define this method to modify the default behavior when loading textures.
  79660. * @param context The context when loading the asset
  79661. * @param texture The glTF texture property
  79662. * @param assign A function called synchronously after parsing the glTF properties
  79663. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79664. */
  79665. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79666. /**
  79667. * Define this method to modify the default behavior when loading animations.
  79668. * @param context The context when loading the asset
  79669. * @param animation The glTF animation property
  79670. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  79671. */
  79672. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79673. /**
  79674. * @hidden
  79675. * Define this method to modify the default behavior when loading skins.
  79676. * @param context The context when loading the asset
  79677. * @param node The glTF node property
  79678. * @param skin The glTF skin property
  79679. * @returns A promise that resolves when the load is complete or null if not handled
  79680. */
  79681. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  79682. /**
  79683. * @hidden
  79684. * Define this method to modify the default behavior when loading uris.
  79685. * @param context The context when loading the asset
  79686. * @param property The glTF property associated with the uri
  79687. * @param uri The uri to load
  79688. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79689. */
  79690. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79691. /**
  79692. * Define this method to modify the default behavior when loading buffer views.
  79693. * @param context The context when loading the asset
  79694. * @param bufferView The glTF buffer view property
  79695. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79696. */
  79697. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  79698. /**
  79699. * Define this method to modify the default behavior when loading buffers.
  79700. * @param context The context when loading the asset
  79701. * @param buffer The glTF buffer property
  79702. * @param byteOffset The byte offset to load
  79703. * @param byteLength The byte length to load
  79704. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79705. */
  79706. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79707. }
  79708. }
  79709. declare module BABYLON.GLTF2 {
  79710. /**
  79711. * Helper class for working with arrays when loading the glTF asset
  79712. */
  79713. export class ArrayItem {
  79714. /**
  79715. * Gets an item from the given array.
  79716. * @param context The context when loading the asset
  79717. * @param array The array to get the item from
  79718. * @param index The index to the array
  79719. * @returns The array item
  79720. */
  79721. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  79722. /**
  79723. * Assign an `index` field to each item of the given array.
  79724. * @param array The array of items
  79725. */
  79726. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  79727. }
  79728. /**
  79729. * The glTF 2.0 loader
  79730. */
  79731. export class GLTFLoader implements IGLTFLoader {
  79732. /** @hidden */
  79733. _completePromises: Promise<any>[];
  79734. /** @hidden */
  79735. _forAssetContainer: boolean;
  79736. /** Storage */
  79737. _babylonLights: Light[];
  79738. /** @hidden */
  79739. _disableInstancedMesh: number;
  79740. private _disposed;
  79741. private _parent;
  79742. private _state;
  79743. private _extensions;
  79744. private _rootUrl;
  79745. private _fileName;
  79746. private _uniqueRootUrl;
  79747. private _gltf;
  79748. private _bin;
  79749. private _babylonScene;
  79750. private _rootBabylonMesh;
  79751. private _defaultBabylonMaterialData;
  79752. private static _RegisteredExtensions;
  79753. /**
  79754. * The default glTF sampler.
  79755. */
  79756. static readonly DefaultSampler: ISampler;
  79757. /**
  79758. * Registers a loader extension.
  79759. * @param name The name of the loader extension.
  79760. * @param factory The factory function that creates the loader extension.
  79761. */
  79762. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  79763. /**
  79764. * Unregisters a loader extension.
  79765. * @param name The name of the loader extension.
  79766. * @returns A boolean indicating whether the extension has been unregistered
  79767. */
  79768. static UnregisterExtension(name: string): boolean;
  79769. /**
  79770. * The loader state.
  79771. */
  79772. get state(): Nullable<GLTFLoaderState>;
  79773. /**
  79774. * The object that represents the glTF JSON.
  79775. */
  79776. get gltf(): IGLTF;
  79777. /**
  79778. * The BIN chunk of a binary glTF.
  79779. */
  79780. get bin(): Nullable<IDataBuffer>;
  79781. /**
  79782. * The parent file loader.
  79783. */
  79784. get parent(): GLTFFileLoader;
  79785. /**
  79786. * The Babylon scene when loading the asset.
  79787. */
  79788. get babylonScene(): Scene;
  79789. /**
  79790. * The root Babylon mesh when loading the asset.
  79791. */
  79792. get rootBabylonMesh(): Mesh;
  79793. /** @hidden */
  79794. constructor(parent: GLTFFileLoader);
  79795. /** @hidden */
  79796. dispose(): void;
  79797. /** @hidden */
  79798. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79799. /** @hidden */
  79800. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79801. private _loadAsync;
  79802. private _loadData;
  79803. private _setupData;
  79804. private _loadExtensions;
  79805. private _checkExtensions;
  79806. private _setState;
  79807. private _createRootNode;
  79808. /**
  79809. * Loads a glTF scene.
  79810. * @param context The context when loading the asset
  79811. * @param scene The glTF scene property
  79812. * @returns A promise that resolves when the load is complete
  79813. */
  79814. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79815. private _forEachPrimitive;
  79816. private _getMeshes;
  79817. private _getTransformNodes;
  79818. private _getSkeletons;
  79819. private _getAnimationGroups;
  79820. private _startAnimations;
  79821. /**
  79822. * Loads a glTF node.
  79823. * @param context The context when loading the asset
  79824. * @param node The glTF node property
  79825. * @param assign A function called synchronously after parsing the glTF properties
  79826. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79827. */
  79828. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79829. private _loadMeshAsync;
  79830. /**
  79831. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79832. * @param context The context when loading the asset
  79833. * @param name The mesh name when loading the asset
  79834. * @param node The glTF node when loading the asset
  79835. * @param mesh The glTF mesh when loading the asset
  79836. * @param primitive The glTF mesh primitive property
  79837. * @param assign A function called synchronously after parsing the glTF properties
  79838. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79839. */
  79840. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79841. private _loadVertexDataAsync;
  79842. private _createMorphTargets;
  79843. private _loadMorphTargetsAsync;
  79844. private _loadMorphTargetVertexDataAsync;
  79845. private static _LoadTransform;
  79846. private _loadSkinAsync;
  79847. private _loadBones;
  79848. private _loadBone;
  79849. private _loadSkinInverseBindMatricesDataAsync;
  79850. private _updateBoneMatrices;
  79851. private _getNodeMatrix;
  79852. /**
  79853. * Loads a glTF camera.
  79854. * @param context The context when loading the asset
  79855. * @param camera The glTF camera property
  79856. * @param assign A function called synchronously after parsing the glTF properties
  79857. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79858. */
  79859. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79860. private _loadAnimationsAsync;
  79861. /**
  79862. * Loads a glTF animation.
  79863. * @param context The context when loading the asset
  79864. * @param animation The glTF animation property
  79865. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79866. */
  79867. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79868. /**
  79869. * @hidden Loads a glTF animation channel.
  79870. * @param context The context when loading the asset
  79871. * @param animationContext The context of the animation when loading the asset
  79872. * @param animation The glTF animation property
  79873. * @param channel The glTF animation channel property
  79874. * @param babylonAnimationGroup The babylon animation group property
  79875. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79876. * @returns A void promise when the channel load is complete
  79877. */
  79878. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79879. private _loadAnimationSamplerAsync;
  79880. private _loadBufferAsync;
  79881. /**
  79882. * Loads a glTF buffer view.
  79883. * @param context The context when loading the asset
  79884. * @param bufferView The glTF buffer view property
  79885. * @returns A promise that resolves with the loaded data when the load is complete
  79886. */
  79887. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79888. private _loadAccessorAsync;
  79889. /** @hidden */
  79890. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79891. private _loadIndicesAccessorAsync;
  79892. private _loadVertexBufferViewAsync;
  79893. private _loadVertexAccessorAsync;
  79894. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79895. /** @hidden */
  79896. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79897. private _createDefaultMaterial;
  79898. /**
  79899. * Creates a Babylon material from a glTF material.
  79900. * @param context The context when loading the asset
  79901. * @param material The glTF material property
  79902. * @param babylonDrawMode The draw mode for the Babylon material
  79903. * @returns The Babylon material
  79904. */
  79905. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79906. /**
  79907. * Loads properties from a glTF material into a Babylon material.
  79908. * @param context The context when loading the asset
  79909. * @param material The glTF material property
  79910. * @param babylonMaterial The Babylon material
  79911. * @returns A promise that resolves when the load is complete
  79912. */
  79913. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79914. /**
  79915. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79916. * @param context The context when loading the asset
  79917. * @param material The glTF material property
  79918. * @param babylonMaterial The Babylon material
  79919. * @returns A promise that resolves when the load is complete
  79920. */
  79921. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79922. /**
  79923. * Loads the alpha properties from a glTF material into a Babylon material.
  79924. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79925. * @param context The context when loading the asset
  79926. * @param material The glTF material property
  79927. * @param babylonMaterial The Babylon material
  79928. */
  79929. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79930. /**
  79931. * Loads a glTF texture info.
  79932. * @param context The context when loading the asset
  79933. * @param textureInfo The glTF texture info property
  79934. * @param assign A function called synchronously after parsing the glTF properties
  79935. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79936. */
  79937. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79938. /** @hidden */
  79939. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79940. /** @hidden */
  79941. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79942. private _loadSampler;
  79943. /**
  79944. * Loads a glTF image.
  79945. * @param context The context when loading the asset
  79946. * @param image The glTF image property
  79947. * @returns A promise that resolves with the loaded data when the load is complete
  79948. */
  79949. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79950. /**
  79951. * Loads a glTF uri.
  79952. * @param context The context when loading the asset
  79953. * @param property The glTF property associated with the uri
  79954. * @param uri The base64 or relative uri
  79955. * @returns A promise that resolves with the loaded data when the load is complete
  79956. */
  79957. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79958. /**
  79959. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79960. * @param babylonObject the Babylon object with metadata
  79961. * @param pointer the JSON pointer
  79962. */
  79963. static AddPointerMetadata(babylonObject: {
  79964. metadata: any;
  79965. }, pointer: string): void;
  79966. private static _GetTextureWrapMode;
  79967. private static _GetTextureSamplingMode;
  79968. private static _GetTypedArrayConstructor;
  79969. private static _GetTypedArray;
  79970. private static _GetNumComponents;
  79971. private static _ValidateUri;
  79972. /** @hidden */
  79973. static _GetDrawMode(context: string, mode: number | undefined): number;
  79974. private _compileMaterialsAsync;
  79975. private _compileShadowGeneratorsAsync;
  79976. private _forEachExtensions;
  79977. private _applyExtensions;
  79978. private _extensionsOnLoading;
  79979. private _extensionsOnReady;
  79980. private _extensionsLoadSceneAsync;
  79981. private _extensionsLoadNodeAsync;
  79982. private _extensionsLoadCameraAsync;
  79983. private _extensionsLoadVertexDataAsync;
  79984. private _extensionsLoadMeshPrimitiveAsync;
  79985. private _extensionsLoadMaterialAsync;
  79986. private _extensionsCreateMaterial;
  79987. private _extensionsLoadMaterialPropertiesAsync;
  79988. private _extensionsLoadTextureInfoAsync;
  79989. private _extensionsLoadTextureAsync;
  79990. private _extensionsLoadAnimationAsync;
  79991. private _extensionsLoadSkinAsync;
  79992. private _extensionsLoadUriAsync;
  79993. private _extensionsLoadBufferViewAsync;
  79994. private _extensionsLoadBufferAsync;
  79995. /**
  79996. * Helper method called by a loader extension to load an glTF extension.
  79997. * @param context The context when loading the asset
  79998. * @param property The glTF property to load the extension from
  79999. * @param extensionName The name of the extension to load
  80000. * @param actionAsync The action to run
  80001. * @returns The promise returned by actionAsync or null if the extension does not exist
  80002. */
  80003. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80004. /**
  80005. * Helper method called by a loader extension to load a glTF extra.
  80006. * @param context The context when loading the asset
  80007. * @param property The glTF property to load the extra from
  80008. * @param extensionName The name of the extension to load
  80009. * @param actionAsync The action to run
  80010. * @returns The promise returned by actionAsync or null if the extra does not exist
  80011. */
  80012. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80013. /**
  80014. * Checks for presence of an extension.
  80015. * @param name The name of the extension to check
  80016. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  80017. */
  80018. isExtensionUsed(name: string): boolean;
  80019. /**
  80020. * Increments the indentation level and logs a message.
  80021. * @param message The message to log
  80022. */
  80023. logOpen(message: string): void;
  80024. /**
  80025. * Decrements the indentation level.
  80026. */
  80027. logClose(): void;
  80028. /**
  80029. * Logs a message
  80030. * @param message The message to log
  80031. */
  80032. log(message: string): void;
  80033. /**
  80034. * Starts a performance counter.
  80035. * @param counterName The name of the performance counter
  80036. */
  80037. startPerformanceCounter(counterName: string): void;
  80038. /**
  80039. * Ends a performance counter.
  80040. * @param counterName The name of the performance counter
  80041. */
  80042. endPerformanceCounter(counterName: string): void;
  80043. }
  80044. }
  80045. declare module BABYLON.GLTF2.Loader.Extensions {
  80046. /**
  80047. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  80048. */
  80049. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  80050. /**
  80051. * The name of this extension.
  80052. */
  80053. readonly name: string;
  80054. /**
  80055. * Defines whether this extension is enabled.
  80056. */
  80057. enabled: boolean;
  80058. private _loader;
  80059. private _lights?;
  80060. /** @hidden */
  80061. constructor(loader: GLTFLoader);
  80062. /** @hidden */
  80063. dispose(): void;
  80064. /** @hidden */
  80065. onLoading(): void;
  80066. /** @hidden */
  80067. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80068. private _loadLightAsync;
  80069. }
  80070. }
  80071. declare module BABYLON.GLTF2.Loader.Extensions {
  80072. /**
  80073. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  80074. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  80075. * !!! Experimental Extension Subject to Changes !!!
  80076. */
  80077. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  80078. /**
  80079. * The name of this extension.
  80080. */
  80081. readonly name: string;
  80082. /**
  80083. * Defines whether this extension is enabled.
  80084. */
  80085. enabled: boolean;
  80086. private _loader;
  80087. /** @hidden */
  80088. constructor(loader: GLTFLoader);
  80089. /** @hidden */
  80090. dispose(): void;
  80091. /** @hidden */
  80092. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80093. }
  80094. }
  80095. declare module BABYLON.GLTF2.Loader.Extensions {
  80096. /**
  80097. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  80098. */
  80099. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  80100. /**
  80101. * The name of this extension.
  80102. */
  80103. readonly name: string;
  80104. /**
  80105. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  80106. */
  80107. dracoCompression?: DracoCompression;
  80108. /**
  80109. * Defines whether this extension is enabled.
  80110. */
  80111. enabled: boolean;
  80112. private _loader;
  80113. /** @hidden */
  80114. constructor(loader: GLTFLoader);
  80115. /** @hidden */
  80116. dispose(): void;
  80117. /** @hidden */
  80118. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80119. }
  80120. }
  80121. declare module BABYLON.GLTF2.Loader.Extensions {
  80122. /**
  80123. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  80124. */
  80125. export class KHR_lights implements IGLTFLoaderExtension {
  80126. /**
  80127. * The name of this extension.
  80128. */
  80129. readonly name: string;
  80130. /**
  80131. * Defines whether this extension is enabled.
  80132. */
  80133. enabled: boolean;
  80134. private _loader;
  80135. private _lights?;
  80136. /** @hidden */
  80137. constructor(loader: GLTFLoader);
  80138. /** @hidden */
  80139. dispose(): void;
  80140. /** @hidden */
  80141. onLoading(): void;
  80142. /** @hidden */
  80143. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80144. }
  80145. }
  80146. declare module BABYLON.GLTF2.Loader.Extensions {
  80147. /**
  80148. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80149. */
  80150. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80151. /**
  80152. * The name of this extension.
  80153. */
  80154. readonly name: string;
  80155. /**
  80156. * Defines whether this extension is enabled.
  80157. */
  80158. enabled: boolean;
  80159. /**
  80160. * Defines a number that determines the order the extensions are applied.
  80161. */
  80162. order: number;
  80163. private _loader;
  80164. /** @hidden */
  80165. constructor(loader: GLTFLoader);
  80166. /** @hidden */
  80167. dispose(): void;
  80168. /** @hidden */
  80169. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80170. private _loadSpecularGlossinessPropertiesAsync;
  80171. }
  80172. }
  80173. declare module BABYLON.GLTF2.Loader.Extensions {
  80174. /**
  80175. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80176. */
  80177. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80178. /**
  80179. * The name of this extension.
  80180. */
  80181. readonly name: string;
  80182. /**
  80183. * Defines whether this extension is enabled.
  80184. */
  80185. enabled: boolean;
  80186. /**
  80187. * Defines a number that determines the order the extensions are applied.
  80188. */
  80189. order: number;
  80190. private _loader;
  80191. /** @hidden */
  80192. constructor(loader: GLTFLoader);
  80193. /** @hidden */
  80194. dispose(): void;
  80195. /** @hidden */
  80196. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80197. private _loadUnlitPropertiesAsync;
  80198. }
  80199. }
  80200. declare module BABYLON.GLTF2.Loader.Extensions {
  80201. /**
  80202. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80203. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80204. * !!! Experimental Extension Subject to Changes !!!
  80205. */
  80206. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80207. /**
  80208. * The name of this extension.
  80209. */
  80210. readonly name: string;
  80211. /**
  80212. * Defines whether this extension is enabled.
  80213. */
  80214. enabled: boolean;
  80215. /**
  80216. * Defines a number that determines the order the extensions are applied.
  80217. */
  80218. order: number;
  80219. private _loader;
  80220. /** @hidden */
  80221. constructor(loader: GLTFLoader);
  80222. /** @hidden */
  80223. dispose(): void;
  80224. /** @hidden */
  80225. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80226. private _loadClearCoatPropertiesAsync;
  80227. }
  80228. }
  80229. declare module BABYLON.GLTF2.Loader.Extensions {
  80230. /**
  80231. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80232. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80233. * !!! Experimental Extension Subject to Changes !!!
  80234. */
  80235. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80236. /**
  80237. * The name of this extension.
  80238. */
  80239. readonly name: string;
  80240. /**
  80241. * Defines whether this extension is enabled.
  80242. */
  80243. enabled: boolean;
  80244. /**
  80245. * Defines a number that determines the order the extensions are applied.
  80246. */
  80247. order: number;
  80248. private _loader;
  80249. /** @hidden */
  80250. constructor(loader: GLTFLoader);
  80251. /** @hidden */
  80252. dispose(): void;
  80253. /** @hidden */
  80254. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80255. private _loadSheenPropertiesAsync;
  80256. }
  80257. }
  80258. declare module BABYLON.GLTF2.Loader.Extensions {
  80259. /**
  80260. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80261. * !!! Experimental Extension Subject to Changes !!!
  80262. */
  80263. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80264. /**
  80265. * The name of this extension.
  80266. */
  80267. readonly name: string;
  80268. /**
  80269. * Defines whether this extension is enabled.
  80270. */
  80271. enabled: boolean;
  80272. /**
  80273. * Defines a number that determines the order the extensions are applied.
  80274. */
  80275. order: number;
  80276. private _loader;
  80277. /** @hidden */
  80278. constructor(loader: GLTFLoader);
  80279. /** @hidden */
  80280. dispose(): void;
  80281. /** @hidden */
  80282. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80283. private _loadSpecularPropertiesAsync;
  80284. }
  80285. }
  80286. declare module BABYLON.GLTF2.Loader.Extensions {
  80287. /**
  80288. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80289. * !!! Experimental Extension Subject to Changes !!!
  80290. */
  80291. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80292. /**
  80293. * Default ior Value from the spec.
  80294. */
  80295. private static readonly _DEFAULT_IOR;
  80296. /**
  80297. * The name of this extension.
  80298. */
  80299. readonly name: string;
  80300. /**
  80301. * Defines whether this extension is enabled.
  80302. */
  80303. enabled: boolean;
  80304. /**
  80305. * Defines a number that determines the order the extensions are applied.
  80306. */
  80307. order: number;
  80308. private _loader;
  80309. /** @hidden */
  80310. constructor(loader: GLTFLoader);
  80311. /** @hidden */
  80312. dispose(): void;
  80313. /** @hidden */
  80314. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80315. private _loadIorPropertiesAsync;
  80316. }
  80317. }
  80318. declare module BABYLON.GLTF2.Loader.Extensions {
  80319. /**
  80320. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80321. * !!! Experimental Extension Subject to Changes !!!
  80322. */
  80323. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80324. /**
  80325. * The name of this extension.
  80326. */
  80327. readonly name: string;
  80328. /**
  80329. * Defines whether this extension is enabled.
  80330. */
  80331. enabled: boolean;
  80332. private _loader;
  80333. /** @hidden */
  80334. constructor(loader: GLTFLoader);
  80335. /** @hidden */
  80336. dispose(): void;
  80337. /**
  80338. * Gets the list of available variant tag names for this asset.
  80339. * @param rootMesh The glTF root mesh
  80340. * @returns the list of all the variant names for this model
  80341. */
  80342. static GetAvailableVariants(rootMesh: Mesh): string[];
  80343. /**
  80344. * Select a variant given a variant tag name or a list of variant tag names.
  80345. * @param rootMesh The glTF root mesh
  80346. * @param variantName The variant name(s) to select.
  80347. */
  80348. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  80349. /**
  80350. * Reset back to the original before selecting a variant.
  80351. * @param rootMesh The glTF root mesh
  80352. */
  80353. static Reset(rootMesh: Mesh): void;
  80354. /**
  80355. * Gets the last selected variant tag name(s) or null if original.
  80356. * @param rootMesh The glTF root mesh
  80357. * @returns The selected variant tag name(s).
  80358. */
  80359. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  80360. private static _GetExtensionMetadata;
  80361. /** @hidden */
  80362. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80363. }
  80364. }
  80365. declare module BABYLON.GLTF2.Loader.Extensions {
  80366. /**
  80367. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80368. * !!! Experimental Extension Subject to Changes !!!
  80369. */
  80370. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80371. /**
  80372. * The name of this extension.
  80373. */
  80374. readonly name: string;
  80375. /**
  80376. * Defines whether this extension is enabled.
  80377. */
  80378. enabled: boolean;
  80379. /**
  80380. * Defines a number that determines the order the extensions are applied.
  80381. */
  80382. order: number;
  80383. private _loader;
  80384. /** @hidden */
  80385. constructor(loader: GLTFLoader);
  80386. /** @hidden */
  80387. dispose(): void;
  80388. /** @hidden */
  80389. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80390. private _loadTransparentPropertiesAsync;
  80391. }
  80392. }
  80393. declare module BABYLON.GLTF2.Loader.Extensions {
  80394. /**
  80395. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80396. */
  80397. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80398. /**
  80399. * The name of this extension.
  80400. */
  80401. readonly name: string;
  80402. /**
  80403. * Defines whether this extension is enabled.
  80404. */
  80405. enabled: boolean;
  80406. /** @hidden */
  80407. constructor(loader: GLTFLoader);
  80408. /** @hidden */
  80409. dispose(): void;
  80410. }
  80411. }
  80412. declare module BABYLON.GLTF2.Loader.Extensions {
  80413. /**
  80414. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80415. * !!! Experimental Extension Subject to Changes !!!
  80416. */
  80417. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80418. /** The name of this extension. */
  80419. readonly name: string;
  80420. /** Defines whether this extension is enabled. */
  80421. enabled: boolean;
  80422. private _loader;
  80423. /** @hidden */
  80424. constructor(loader: GLTFLoader);
  80425. /** @hidden */
  80426. dispose(): void;
  80427. /** @hidden */
  80428. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80429. }
  80430. }
  80431. declare module BABYLON.GLTF2.Loader.Extensions {
  80432. /**
  80433. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80434. */
  80435. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80436. /**
  80437. * The name of this extension.
  80438. */
  80439. readonly name: string;
  80440. /**
  80441. * Defines whether this extension is enabled.
  80442. */
  80443. enabled: boolean;
  80444. private _loader;
  80445. /** @hidden */
  80446. constructor(loader: GLTFLoader);
  80447. /** @hidden */
  80448. dispose(): void;
  80449. /** @hidden */
  80450. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80451. }
  80452. }
  80453. declare module BABYLON.GLTF2.Loader.Extensions {
  80454. /**
  80455. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80456. * !!! Experimental Extension Subject to Changes !!!
  80457. */
  80458. export class KHR_xmp implements IGLTFLoaderExtension {
  80459. /**
  80460. * The name of this extension.
  80461. */
  80462. readonly name: string;
  80463. /**
  80464. * Defines whether this extension is enabled.
  80465. */
  80466. enabled: boolean;
  80467. /**
  80468. * Defines a number that determines the order the extensions are applied.
  80469. */
  80470. order: number;
  80471. private _loader;
  80472. /** @hidden */
  80473. constructor(loader: GLTFLoader);
  80474. /** @hidden */
  80475. dispose(): void;
  80476. /**
  80477. * Called after the loader state changes to LOADING.
  80478. */
  80479. onLoading(): void;
  80480. }
  80481. }
  80482. declare module BABYLON.GLTF2.Loader.Extensions {
  80483. /**
  80484. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80485. */
  80486. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80487. /**
  80488. * The name of this extension.
  80489. */
  80490. readonly name: string;
  80491. /**
  80492. * Defines whether this extension is enabled.
  80493. */
  80494. enabled: boolean;
  80495. private _loader;
  80496. private _clips;
  80497. private _emitters;
  80498. /** @hidden */
  80499. constructor(loader: GLTFLoader);
  80500. /** @hidden */
  80501. dispose(): void;
  80502. /** @hidden */
  80503. onLoading(): void;
  80504. /** @hidden */
  80505. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80506. /** @hidden */
  80507. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80508. /** @hidden */
  80509. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80510. private _loadClipAsync;
  80511. private _loadEmitterAsync;
  80512. private _getEventAction;
  80513. private _loadAnimationEventAsync;
  80514. }
  80515. }
  80516. declare module BABYLON.GLTF2.Loader.Extensions {
  80517. /**
  80518. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  80519. */
  80520. export class MSFT_lod implements IGLTFLoaderExtension {
  80521. /**
  80522. * The name of this extension.
  80523. */
  80524. readonly name: string;
  80525. /**
  80526. * Defines whether this extension is enabled.
  80527. */
  80528. enabled: boolean;
  80529. /**
  80530. * Defines a number that determines the order the extensions are applied.
  80531. */
  80532. order: number;
  80533. /**
  80534. * Maximum number of LODs to load, starting from the lowest LOD.
  80535. */
  80536. maxLODsToLoad: number;
  80537. /**
  80538. * Observable raised when all node LODs of one level are loaded.
  80539. * The event data is the index of the loaded LOD starting from zero.
  80540. * Dispose the loader to cancel the loading of the next level of LODs.
  80541. */
  80542. onNodeLODsLoadedObservable: Observable<number>;
  80543. /**
  80544. * Observable raised when all material LODs of one level are loaded.
  80545. * The event data is the index of the loaded LOD starting from zero.
  80546. * Dispose the loader to cancel the loading of the next level of LODs.
  80547. */
  80548. onMaterialLODsLoadedObservable: Observable<number>;
  80549. private _loader;
  80550. private _bufferLODs;
  80551. private _nodeIndexLOD;
  80552. private _nodeSignalLODs;
  80553. private _nodePromiseLODs;
  80554. private _nodeBufferLODs;
  80555. private _materialIndexLOD;
  80556. private _materialSignalLODs;
  80557. private _materialPromiseLODs;
  80558. private _materialBufferLODs;
  80559. /** @hidden */
  80560. constructor(loader: GLTFLoader);
  80561. /** @hidden */
  80562. dispose(): void;
  80563. /** @hidden */
  80564. onReady(): void;
  80565. /** @hidden */
  80566. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80567. /** @hidden */
  80568. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80569. /** @hidden */
  80570. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80571. /** @hidden */
  80572. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80573. /** @hidden */
  80574. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80575. private _loadBufferLOD;
  80576. /**
  80577. * Gets an array of LOD properties from lowest to highest.
  80578. */
  80579. private _getLODs;
  80580. private _disposeTransformNode;
  80581. private _disposeMaterials;
  80582. }
  80583. }
  80584. declare module BABYLON.GLTF2.Loader.Extensions {
  80585. /** @hidden */
  80586. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  80587. readonly name: string;
  80588. enabled: boolean;
  80589. private _loader;
  80590. constructor(loader: GLTFLoader);
  80591. dispose(): void;
  80592. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80593. }
  80594. }
  80595. declare module BABYLON.GLTF2.Loader.Extensions {
  80596. /** @hidden */
  80597. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  80598. readonly name: string;
  80599. enabled: boolean;
  80600. private _loader;
  80601. constructor(loader: GLTFLoader);
  80602. dispose(): void;
  80603. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80604. }
  80605. }
  80606. declare module BABYLON.GLTF2.Loader.Extensions {
  80607. /**
  80608. * Store glTF extras (if present) in BJS objects' metadata
  80609. */
  80610. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  80611. /**
  80612. * The name of this extension.
  80613. */
  80614. readonly name: string;
  80615. /**
  80616. * Defines whether this extension is enabled.
  80617. */
  80618. enabled: boolean;
  80619. private _loader;
  80620. private _assignExtras;
  80621. /** @hidden */
  80622. constructor(loader: GLTFLoader);
  80623. /** @hidden */
  80624. dispose(): void;
  80625. /** @hidden */
  80626. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80627. /** @hidden */
  80628. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80629. /** @hidden */
  80630. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80631. }
  80632. }
  80633. declare module BABYLON {
  80634. /**
  80635. * Class reading and parsing the MTL file bundled with the obj file.
  80636. */
  80637. export class MTLFileLoader {
  80638. /**
  80639. * Invert Y-Axis of referenced textures on load
  80640. */
  80641. static INVERT_TEXTURE_Y: boolean;
  80642. /**
  80643. * All material loaded from the mtl will be set here
  80644. */
  80645. materials: StandardMaterial[];
  80646. /**
  80647. * This function will read the mtl file and create each material described inside
  80648. * This function could be improve by adding :
  80649. * -some component missing (Ni, Tf...)
  80650. * -including the specific options available
  80651. *
  80652. * @param scene defines the scene the material will be created in
  80653. * @param data defines the mtl data to parse
  80654. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  80655. * @param forAssetContainer defines if the material should be registered in the scene
  80656. */
  80657. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  80658. /**
  80659. * Gets the texture for the material.
  80660. *
  80661. * If the material is imported from input file,
  80662. * We sanitize the url to ensure it takes the textre from aside the material.
  80663. *
  80664. * @param rootUrl The root url to load from
  80665. * @param value The value stored in the mtl
  80666. * @return The Texture
  80667. */
  80668. private static _getTexture;
  80669. }
  80670. }
  80671. declare module BABYLON {
  80672. /**
  80673. * Options for loading OBJ/MTL files
  80674. */
  80675. type MeshLoadOptions = {
  80676. /**
  80677. * Defines if UVs are optimized by default during load.
  80678. */
  80679. OptimizeWithUV: boolean;
  80680. /**
  80681. * Defines custom scaling of UV coordinates of loaded meshes.
  80682. */
  80683. UVScaling: Vector2;
  80684. /**
  80685. * Invert model on y-axis (does a model scaling inversion)
  80686. */
  80687. InvertY: boolean;
  80688. /**
  80689. * Invert Y-Axis of referenced textures on load
  80690. */
  80691. InvertTextureY: boolean;
  80692. /**
  80693. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80694. */
  80695. ImportVertexColors: boolean;
  80696. /**
  80697. * Compute the normals for the model, even if normals are present in the file.
  80698. */
  80699. ComputeNormals: boolean;
  80700. /**
  80701. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80702. */
  80703. SkipMaterials: boolean;
  80704. /**
  80705. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80706. */
  80707. MaterialLoadingFailsSilently: boolean;
  80708. };
  80709. /**
  80710. * OBJ file type loader.
  80711. * This is a babylon scene loader plugin.
  80712. */
  80713. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80714. /**
  80715. * Defines if UVs are optimized by default during load.
  80716. */
  80717. static OPTIMIZE_WITH_UV: boolean;
  80718. /**
  80719. * Invert model on y-axis (does a model scaling inversion)
  80720. */
  80721. static INVERT_Y: boolean;
  80722. /**
  80723. * Invert Y-Axis of referenced textures on load
  80724. */
  80725. static get INVERT_TEXTURE_Y(): boolean;
  80726. static set INVERT_TEXTURE_Y(value: boolean);
  80727. /**
  80728. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80729. */
  80730. static IMPORT_VERTEX_COLORS: boolean;
  80731. /**
  80732. * Compute the normals for the model, even if normals are present in the file.
  80733. */
  80734. static COMPUTE_NORMALS: boolean;
  80735. /**
  80736. * Defines custom scaling of UV coordinates of loaded meshes.
  80737. */
  80738. static UV_SCALING: Vector2;
  80739. /**
  80740. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80741. */
  80742. static SKIP_MATERIALS: boolean;
  80743. /**
  80744. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80745. *
  80746. * Defaults to true for backwards compatibility.
  80747. */
  80748. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  80749. /**
  80750. * Defines the name of the plugin.
  80751. */
  80752. name: string;
  80753. /**
  80754. * Defines the extension the plugin is able to load.
  80755. */
  80756. extensions: string;
  80757. /** @hidden */
  80758. obj: RegExp;
  80759. /** @hidden */
  80760. group: RegExp;
  80761. /** @hidden */
  80762. mtllib: RegExp;
  80763. /** @hidden */
  80764. usemtl: RegExp;
  80765. /** @hidden */
  80766. smooth: RegExp;
  80767. /** @hidden */
  80768. vertexPattern: RegExp;
  80769. /** @hidden */
  80770. normalPattern: RegExp;
  80771. /** @hidden */
  80772. uvPattern: RegExp;
  80773. /** @hidden */
  80774. facePattern1: RegExp;
  80775. /** @hidden */
  80776. facePattern2: RegExp;
  80777. /** @hidden */
  80778. facePattern3: RegExp;
  80779. /** @hidden */
  80780. facePattern4: RegExp;
  80781. /** @hidden */
  80782. facePattern5: RegExp;
  80783. private _forAssetContainer;
  80784. private _meshLoadOptions;
  80785. /**
  80786. * Creates loader for .OBJ files
  80787. *
  80788. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  80789. */
  80790. constructor(meshLoadOptions?: MeshLoadOptions);
  80791. private static get currentMeshLoadOptions();
  80792. /**
  80793. * Calls synchronously the MTL file attached to this obj.
  80794. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  80795. * Without this function materials are not displayed in the first frame (but displayed after).
  80796. * In consequence it is impossible to get material information in your HTML file
  80797. *
  80798. * @param url The URL of the MTL file
  80799. * @param rootUrl
  80800. * @param onSuccess Callback function to be called when the MTL file is loaded
  80801. * @private
  80802. */
  80803. private _loadMTL;
  80804. /**
  80805. * Instantiates a OBJ file loader plugin.
  80806. * @returns the created plugin
  80807. */
  80808. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  80809. /**
  80810. * If the data string can be loaded directly.
  80811. *
  80812. * @param data string containing the file data
  80813. * @returns if the data can be loaded directly
  80814. */
  80815. canDirectLoad(data: string): boolean;
  80816. /**
  80817. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  80818. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80819. * @param scene the scene the meshes should be added to
  80820. * @param data the OBJ data to load
  80821. * @param rootUrl root url to load from
  80822. * @param onProgress event that fires when loading progress has occured
  80823. * @param fileName Defines the name of the file to load
  80824. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80825. */
  80826. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80827. meshes: AbstractMesh[];
  80828. particleSystems: IParticleSystem[];
  80829. skeletons: Skeleton[];
  80830. animationGroups: AnimationGroup[];
  80831. }>;
  80832. /**
  80833. * Imports all objects from the loaded OBJ data and adds them to the scene
  80834. * @param scene the scene the objects should be added to
  80835. * @param data the OBJ data to load
  80836. * @param rootUrl root url to load from
  80837. * @param onProgress event that fires when loading progress has occured
  80838. * @param fileName Defines the name of the file to load
  80839. * @returns a promise which completes when objects have been loaded to the scene
  80840. */
  80841. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80842. /**
  80843. * Load into an asset container.
  80844. * @param scene The scene to load into
  80845. * @param data The data to import
  80846. * @param rootUrl The root url for scene and resources
  80847. * @param onProgress The callback when the load progresses
  80848. * @param fileName Defines the name of the file to load
  80849. * @returns The loaded asset container
  80850. */
  80851. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80852. /**
  80853. * Read the OBJ file and create an Array of meshes.
  80854. * Each mesh contains all information given by the OBJ and the MTL file.
  80855. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  80856. *
  80857. * @param meshesNames
  80858. * @param scene Scene The scene where are displayed the data
  80859. * @param data String The content of the obj file
  80860. * @param rootUrl String The path to the folder
  80861. * @returns Array<AbstractMesh>
  80862. * @private
  80863. */
  80864. private _parseSolid;
  80865. }
  80866. }
  80867. declare module BABYLON {
  80868. /**
  80869. * STL file type loader.
  80870. * This is a babylon scene loader plugin.
  80871. */
  80872. export class STLFileLoader implements ISceneLoaderPlugin {
  80873. /** @hidden */
  80874. solidPattern: RegExp;
  80875. /** @hidden */
  80876. facetsPattern: RegExp;
  80877. /** @hidden */
  80878. normalPattern: RegExp;
  80879. /** @hidden */
  80880. vertexPattern: RegExp;
  80881. /**
  80882. * Defines the name of the plugin.
  80883. */
  80884. name: string;
  80885. /**
  80886. * Defines the extensions the stl loader is able to load.
  80887. * force data to come in as an ArrayBuffer
  80888. * we'll convert to string if it looks like it's an ASCII .stl
  80889. */
  80890. extensions: ISceneLoaderPluginExtensions;
  80891. /**
  80892. * Import meshes into a scene.
  80893. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80894. * @param scene The scene to import into
  80895. * @param data The data to import
  80896. * @param rootUrl The root url for scene and resources
  80897. * @param meshes The meshes array to import into
  80898. * @param particleSystems The particle systems array to import into
  80899. * @param skeletons The skeletons array to import into
  80900. * @param onError The callback when import fails
  80901. * @returns True if successful or false otherwise
  80902. */
  80903. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80904. /**
  80905. * Load into a scene.
  80906. * @param scene The scene to load into
  80907. * @param data The data to import
  80908. * @param rootUrl The root url for scene and resources
  80909. * @param onError The callback when import fails
  80910. * @returns true if successful or false otherwise
  80911. */
  80912. load(scene: Scene, data: any, rootUrl: string): boolean;
  80913. /**
  80914. * Load into an asset container.
  80915. * @param scene The scene to load into
  80916. * @param data The data to import
  80917. * @param rootUrl The root url for scene and resources
  80918. * @param onError The callback when import fails
  80919. * @returns The loaded asset container
  80920. */
  80921. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80922. private _isBinary;
  80923. private _parseBinary;
  80924. private _parseASCII;
  80925. }
  80926. }
  80927. declare module BABYLON {
  80928. /**
  80929. * Class for generating OBJ data from a Babylon scene.
  80930. */
  80931. export class OBJExport {
  80932. /**
  80933. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80934. * @param mesh defines the list of meshes to serialize
  80935. * @param materials defines if materials should be exported
  80936. * @param matlibname defines the name of the associated mtl file
  80937. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80938. * @returns the OBJ content
  80939. */
  80940. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80941. /**
  80942. * Exports the material(s) of a mesh in .MTL file format (text)
  80943. * @param mesh defines the mesh to extract the material from
  80944. * @returns the mtl content
  80945. */
  80946. static MTL(mesh: Mesh): string;
  80947. }
  80948. }
  80949. declare module BABYLON {
  80950. /** @hidden */
  80951. export var __IGLTFExporterExtension: number;
  80952. /**
  80953. * Interface for extending the exporter
  80954. * @hidden
  80955. */
  80956. export interface IGLTFExporterExtension {
  80957. /**
  80958. * The name of this extension
  80959. */
  80960. readonly name: string;
  80961. /**
  80962. * Defines whether this extension is enabled
  80963. */
  80964. enabled: boolean;
  80965. /**
  80966. * Defines whether this extension is required
  80967. */
  80968. required: boolean;
  80969. }
  80970. }
  80971. declare module BABYLON.GLTF2.Exporter {
  80972. /** @hidden */
  80973. export var __IGLTFExporterExtensionV2: number;
  80974. /**
  80975. * Interface for a glTF exporter extension
  80976. * @hidden
  80977. */
  80978. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80979. /**
  80980. * Define this method to modify the default behavior before exporting a texture
  80981. * @param context The context when loading the asset
  80982. * @param babylonTexture The Babylon.js texture
  80983. * @param mimeType The mime-type of the generated image
  80984. * @returns A promise that resolves with the exported texture
  80985. */
  80986. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80987. /**
  80988. * Define this method to get notified when a texture info is created
  80989. * @param context The context when loading the asset
  80990. * @param textureInfo The glTF texture info
  80991. * @param babylonTexture The Babylon.js texture
  80992. */
  80993. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80994. /**
  80995. * Define this method to modify the default behavior when exporting texture info
  80996. * @param context The context when loading the asset
  80997. * @param meshPrimitive glTF mesh primitive
  80998. * @param babylonSubMesh Babylon submesh
  80999. * @param binaryWriter glTF serializer binary writer instance
  81000. * @returns nullable IMeshPrimitive promise
  81001. */
  81002. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  81003. /**
  81004. * Define this method to modify the default behavior when exporting a node
  81005. * @param context The context when exporting the node
  81006. * @param node glTF node
  81007. * @param babylonNode BabylonJS node
  81008. * @returns nullable INode promise
  81009. */
  81010. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81011. [key: number]: number;
  81012. }): Promise<Nullable<INode>>;
  81013. /**
  81014. * Define this method to modify the default behavior when exporting a material
  81015. * @param material glTF material
  81016. * @param babylonMaterial BabylonJS material
  81017. * @returns nullable IMaterial promise
  81018. */
  81019. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  81020. /**
  81021. * Define this method to return additional textures to export from a material
  81022. * @param material glTF material
  81023. * @param babylonMaterial BabylonJS material
  81024. * @returns List of textures
  81025. */
  81026. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81027. /** Gets a boolean indicating that this extension was used */
  81028. wasUsed: boolean;
  81029. /** Gets a boolean indicating that this extension is required for the file to work */
  81030. required: boolean;
  81031. /**
  81032. * Called after the exporter state changes to EXPORTING
  81033. */
  81034. onExporting?(): void;
  81035. }
  81036. }
  81037. declare module BABYLON.GLTF2.Exporter {
  81038. /**
  81039. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  81040. * @hidden
  81041. */
  81042. export class _GLTFMaterialExporter {
  81043. /**
  81044. * Represents the dielectric specular values for R, G and B
  81045. */
  81046. private static readonly _DielectricSpecular;
  81047. /**
  81048. * Allows the maximum specular power to be defined for material calculations
  81049. */
  81050. private static readonly _MaxSpecularPower;
  81051. /**
  81052. * Mapping to store textures
  81053. */
  81054. private _textureMap;
  81055. /**
  81056. * Numeric tolerance value
  81057. */
  81058. private static readonly _Epsilon;
  81059. /**
  81060. * Reference to the glTF Exporter
  81061. */
  81062. private _exporter;
  81063. constructor(exporter: _Exporter);
  81064. /**
  81065. * Specifies if two colors are approximately equal in value
  81066. * @param color1 first color to compare to
  81067. * @param color2 second color to compare to
  81068. * @param epsilon threshold value
  81069. */
  81070. private static FuzzyEquals;
  81071. /**
  81072. * Gets the materials from a Babylon scene and converts them to glTF materials
  81073. * @param scene babylonjs scene
  81074. * @param mimeType texture mime type
  81075. * @param images array of images
  81076. * @param textures array of textures
  81077. * @param materials array of materials
  81078. * @param imageData mapping of texture names to base64 textures
  81079. * @param hasTextureCoords specifies if texture coordinates are present on the material
  81080. */
  81081. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  81082. /**
  81083. * Makes a copy of the glTF material without the texture parameters
  81084. * @param originalMaterial original glTF material
  81085. * @returns glTF material without texture parameters
  81086. */
  81087. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  81088. /**
  81089. * Specifies if the material has any texture parameters present
  81090. * @param material glTF Material
  81091. * @returns boolean specifying if texture parameters are present
  81092. */
  81093. _hasTexturesPresent(material: IMaterial): boolean;
  81094. /**
  81095. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  81096. * @param babylonStandardMaterial
  81097. * @returns glTF Metallic Roughness Material representation
  81098. */
  81099. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  81100. /**
  81101. * Computes the metallic factor
  81102. * @param diffuse diffused value
  81103. * @param specular specular value
  81104. * @param oneMinusSpecularStrength one minus the specular strength
  81105. * @returns metallic value
  81106. */
  81107. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  81108. /**
  81109. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  81110. * @param glTFMaterial glTF material
  81111. * @param babylonMaterial Babylon material
  81112. */
  81113. private static _SetAlphaMode;
  81114. /**
  81115. * Converts a Babylon Standard Material to a glTF Material
  81116. * @param babylonStandardMaterial BJS Standard Material
  81117. * @param mimeType mime type to use for the textures
  81118. * @param images array of glTF image interfaces
  81119. * @param textures array of glTF texture interfaces
  81120. * @param materials array of glTF material interfaces
  81121. * @param imageData map of image file name to data
  81122. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81123. */
  81124. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81125. private _finishMaterial;
  81126. /**
  81127. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81128. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  81129. * @param mimeType mime type to use for the textures
  81130. * @param images array of glTF image interfaces
  81131. * @param textures array of glTF texture interfaces
  81132. * @param materials array of glTF material interfaces
  81133. * @param imageData map of image file name to data
  81134. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81135. */
  81136. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81137. /**
  81138. * Converts an image typed array buffer to a base64 image
  81139. * @param buffer typed array buffer
  81140. * @param width width of the image
  81141. * @param height height of the image
  81142. * @param mimeType mimetype of the image
  81143. * @returns base64 image string
  81144. */
  81145. private _createBase64FromCanvasAsync;
  81146. /**
  81147. * Generates a white texture based on the specified width and height
  81148. * @param width width of the texture in pixels
  81149. * @param height height of the texture in pixels
  81150. * @param scene babylonjs scene
  81151. * @returns white texture
  81152. */
  81153. private _createWhiteTexture;
  81154. /**
  81155. * 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
  81156. * @param texture1 first texture to resize
  81157. * @param texture2 second texture to resize
  81158. * @param scene babylonjs scene
  81159. * @returns resized textures or null
  81160. */
  81161. private _resizeTexturesToSameDimensions;
  81162. /**
  81163. * Converts an array of pixels to a Float32Array
  81164. * Throws an error if the pixel format is not supported
  81165. * @param pixels - array buffer containing pixel values
  81166. * @returns Float32 of pixels
  81167. */
  81168. private _convertPixelArrayToFloat32;
  81169. /**
  81170. * Convert Specular Glossiness Textures to Metallic Roughness
  81171. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81172. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81173. * @param diffuseTexture texture used to store diffuse information
  81174. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81175. * @param factors specular glossiness material factors
  81176. * @param mimeType the mime type to use for the texture
  81177. * @returns pbr metallic roughness interface or null
  81178. */
  81179. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81180. /**
  81181. * Converts specular glossiness material properties to metallic roughness
  81182. * @param specularGlossiness interface with specular glossiness material properties
  81183. * @returns interface with metallic roughness material properties
  81184. */
  81185. private _convertSpecularGlossinessToMetallicRoughness;
  81186. /**
  81187. * Calculates the surface reflectance, independent of lighting conditions
  81188. * @param color Color source to calculate brightness from
  81189. * @returns number representing the perceived brightness, or zero if color is undefined
  81190. */
  81191. private _getPerceivedBrightness;
  81192. /**
  81193. * Returns the maximum color component value
  81194. * @param color
  81195. * @returns maximum color component value, or zero if color is null or undefined
  81196. */
  81197. private _getMaxComponent;
  81198. /**
  81199. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81200. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81201. * @param mimeType mime type to use for the textures
  81202. * @param images array of glTF image interfaces
  81203. * @param textures array of glTF texture interfaces
  81204. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81205. * @param imageData map of image file name to data
  81206. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81207. * @returns glTF PBR Metallic Roughness factors
  81208. */
  81209. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81210. private _getGLTFTextureSampler;
  81211. private _getGLTFTextureWrapMode;
  81212. private _getGLTFTextureWrapModesSampler;
  81213. /**
  81214. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81215. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81216. * @param mimeType mime type to use for the textures
  81217. * @param images array of glTF image interfaces
  81218. * @param textures array of glTF texture interfaces
  81219. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81220. * @param imageData map of image file name to data
  81221. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81222. * @returns glTF PBR Metallic Roughness factors
  81223. */
  81224. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81225. /**
  81226. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81227. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81228. * @param mimeType mime type to use for the textures
  81229. * @param images array of glTF image interfaces
  81230. * @param textures array of glTF texture interfaces
  81231. * @param materials array of glTF material interfaces
  81232. * @param imageData map of image file name to data
  81233. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81234. */
  81235. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81236. private setMetallicRoughnessPbrMaterial;
  81237. private getPixelsFromTexture;
  81238. /**
  81239. * Extracts a texture from a Babylon texture into file data and glTF data
  81240. * @param babylonTexture Babylon texture to extract
  81241. * @param mimeType Mime Type of the babylonTexture
  81242. * @return glTF texture info, or null if the texture format is not supported
  81243. */
  81244. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81245. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81246. /**
  81247. * Builds a texture from base64 string
  81248. * @param base64Texture base64 texture string
  81249. * @param baseTextureName Name to use for the texture
  81250. * @param mimeType image mime type for the texture
  81251. * @param images array of images
  81252. * @param textures array of textures
  81253. * @param imageData map of image data
  81254. * @returns glTF texture info, or null if the texture format is not supported
  81255. */
  81256. private _getTextureInfoFromBase64;
  81257. }
  81258. }
  81259. declare module BABYLON {
  81260. /**
  81261. * Class for holding and downloading glTF file data
  81262. */
  81263. export class GLTFData {
  81264. /**
  81265. * Object which contains the file name as the key and its data as the value
  81266. */
  81267. glTFFiles: {
  81268. [fileName: string]: string | Blob;
  81269. };
  81270. /**
  81271. * Initializes the glTF file object
  81272. */
  81273. constructor();
  81274. /**
  81275. * Downloads the glTF data as files based on their names and data
  81276. */
  81277. downloadFiles(): void;
  81278. }
  81279. }
  81280. declare module BABYLON {
  81281. /**
  81282. * Holds a collection of exporter options and parameters
  81283. */
  81284. export interface IExportOptions {
  81285. /**
  81286. * Function which indicates whether a babylon node should be exported or not
  81287. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81288. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81289. */
  81290. shouldExportNode?(node: Node): boolean;
  81291. /**
  81292. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81293. * @param metadata source metadata to read from
  81294. * @returns the data to store to glTF node extras
  81295. */
  81296. metadataSelector?(metadata: any): any;
  81297. /**
  81298. * The sample rate to bake animation curves
  81299. */
  81300. animationSampleRate?: number;
  81301. /**
  81302. * Begin serialization without waiting for the scene to be ready
  81303. */
  81304. exportWithoutWaitingForScene?: boolean;
  81305. /**
  81306. * Indicates if coordinate system swapping root nodes should be included in export
  81307. */
  81308. includeCoordinateSystemConversionNodes?: boolean;
  81309. }
  81310. /**
  81311. * Class for generating glTF data from a Babylon scene.
  81312. */
  81313. export class GLTF2Export {
  81314. /**
  81315. * Exports the geometry of the scene to .gltf file format asynchronously
  81316. * @param scene Babylon scene with scene hierarchy information
  81317. * @param filePrefix File prefix to use when generating the glTF file
  81318. * @param options Exporter options
  81319. * @returns Returns an object with a .gltf file and associates texture names
  81320. * as keys and their data and paths as values
  81321. */
  81322. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81323. private static _PreExportAsync;
  81324. private static _PostExportAsync;
  81325. /**
  81326. * Exports the geometry of the scene to .glb file format asychronously
  81327. * @param scene Babylon scene with scene hierarchy information
  81328. * @param filePrefix File prefix to use when generating glb file
  81329. * @param options Exporter options
  81330. * @returns Returns an object with a .glb filename as key and data as value
  81331. */
  81332. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81333. }
  81334. }
  81335. declare module BABYLON.GLTF2.Exporter {
  81336. /**
  81337. * @hidden
  81338. */
  81339. export class _GLTFUtilities {
  81340. /**
  81341. * Creates a buffer view based on the supplied arguments
  81342. * @param bufferIndex index value of the specified buffer
  81343. * @param byteOffset byte offset value
  81344. * @param byteLength byte length of the bufferView
  81345. * @param byteStride byte distance between conequential elements
  81346. * @param name name of the buffer view
  81347. * @returns bufferView for glTF
  81348. */
  81349. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81350. /**
  81351. * Creates an accessor based on the supplied arguments
  81352. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81353. * @param name The name of the accessor
  81354. * @param type The type of the accessor
  81355. * @param componentType The datatype of components in the attribute
  81356. * @param count The number of attributes referenced by this accessor
  81357. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81358. * @param min Minimum value of each component in this attribute
  81359. * @param max Maximum value of each component in this attribute
  81360. * @returns accessor for glTF
  81361. */
  81362. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81363. /**
  81364. * Calculates the minimum and maximum values of an array of position floats
  81365. * @param positions Positions array of a mesh
  81366. * @param vertexStart Starting vertex offset to calculate min and max values
  81367. * @param vertexCount Number of vertices to check for min and max values
  81368. * @returns min number array and max number array
  81369. */
  81370. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81371. min: number[];
  81372. max: number[];
  81373. };
  81374. /**
  81375. * Converts a new right-handed Vector3
  81376. * @param vector vector3 array
  81377. * @returns right-handed Vector3
  81378. */
  81379. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81380. /**
  81381. * Converts a Vector3 to right-handed
  81382. * @param vector Vector3 to convert to right-handed
  81383. */
  81384. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81385. /**
  81386. * Converts a three element number array to right-handed
  81387. * @param vector number array to convert to right-handed
  81388. */
  81389. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81390. /**
  81391. * Converts a new right-handed Vector3
  81392. * @param vector vector3 array
  81393. * @returns right-handed Vector3
  81394. */
  81395. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81396. /**
  81397. * Converts a Vector3 to right-handed
  81398. * @param vector Vector3 to convert to right-handed
  81399. */
  81400. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  81401. /**
  81402. * Converts a three element number array to right-handed
  81403. * @param vector number array to convert to right-handed
  81404. */
  81405. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81406. /**
  81407. * Converts a Vector4 to right-handed
  81408. * @param vector Vector4 to convert to right-handed
  81409. */
  81410. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81411. /**
  81412. * Converts a Vector4 to right-handed
  81413. * @param vector Vector4 to convert to right-handed
  81414. */
  81415. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81416. /**
  81417. * Converts a Quaternion to right-handed
  81418. * @param quaternion Source quaternion to convert to right-handed
  81419. */
  81420. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81421. /**
  81422. * Converts a Quaternion to right-handed
  81423. * @param quaternion Source quaternion to convert to right-handed
  81424. */
  81425. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81426. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81427. }
  81428. }
  81429. declare module BABYLON.GLTF2.Exporter {
  81430. /**
  81431. * Converts Babylon Scene into glTF 2.0.
  81432. * @hidden
  81433. */
  81434. export class _Exporter {
  81435. /**
  81436. * Stores the glTF to export
  81437. */
  81438. _glTF: IGLTF;
  81439. /**
  81440. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81441. */
  81442. _bufferViews: IBufferView[];
  81443. /**
  81444. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81445. */
  81446. _accessors: IAccessor[];
  81447. /**
  81448. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81449. */
  81450. _nodes: INode[];
  81451. /**
  81452. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81453. */
  81454. private _scenes;
  81455. /**
  81456. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81457. */
  81458. private _meshes;
  81459. /**
  81460. * Stores all the generated material information, which represents the appearance of each primitive
  81461. */
  81462. _materials: IMaterial[];
  81463. _materialMap: {
  81464. [materialID: number]: number;
  81465. };
  81466. /**
  81467. * Stores all the generated texture information, which is referenced by glTF materials
  81468. */
  81469. _textures: ITexture[];
  81470. /**
  81471. * Stores all the generated image information, which is referenced by glTF textures
  81472. */
  81473. _images: IImage[];
  81474. /**
  81475. * Stores all the texture samplers
  81476. */
  81477. _samplers: ISampler[];
  81478. /**
  81479. * Stores all the generated animation samplers, which is referenced by glTF animations
  81480. */
  81481. /**
  81482. * Stores the animations for glTF models
  81483. */
  81484. private _animations;
  81485. /**
  81486. * Stores the total amount of bytes stored in the glTF buffer
  81487. */
  81488. private _totalByteLength;
  81489. /**
  81490. * Stores a reference to the Babylon scene containing the source geometry and material information
  81491. */
  81492. _babylonScene: Scene;
  81493. /**
  81494. * Stores a map of the image data, where the key is the file name and the value
  81495. * is the image data
  81496. */
  81497. _imageData: {
  81498. [fileName: string]: {
  81499. data: Uint8Array;
  81500. mimeType: ImageMimeType;
  81501. };
  81502. };
  81503. /**
  81504. * Stores a map of the unique id of a node to its index in the node array
  81505. */
  81506. _nodeMap: {
  81507. [key: number]: number;
  81508. };
  81509. /**
  81510. * Specifies if the source Babylon scene was left handed, and needed conversion.
  81511. */
  81512. _convertToRightHandedSystem: boolean;
  81513. /**
  81514. * Specifies if a Babylon node should be converted to right-handed on export
  81515. */
  81516. _convertToRightHandedSystemMap: {
  81517. [nodeId: number]: boolean;
  81518. };
  81519. _includeCoordinateSystemConversionNodes: boolean;
  81520. /**
  81521. * Baked animation sample rate
  81522. */
  81523. private _animationSampleRate;
  81524. private _options;
  81525. private _localEngine;
  81526. _glTFMaterialExporter: _GLTFMaterialExporter;
  81527. private _extensions;
  81528. private static _ExtensionNames;
  81529. private static _ExtensionFactories;
  81530. private _applyExtension;
  81531. private _applyExtensions;
  81532. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  81533. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  81534. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81535. [key: number]: number;
  81536. }): Promise<Nullable<INode>>;
  81537. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  81538. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  81539. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81540. private _forEachExtensions;
  81541. private _extensionsOnExporting;
  81542. /**
  81543. * Load glTF serializer extensions
  81544. */
  81545. private _loadExtensions;
  81546. /**
  81547. * Creates a glTF Exporter instance, which can accept optional exporter options
  81548. * @param babylonScene Babylon scene object
  81549. * @param options Options to modify the behavior of the exporter
  81550. */
  81551. constructor(babylonScene: Scene, options?: IExportOptions);
  81552. dispose(): void;
  81553. /**
  81554. * Registers a glTF exporter extension
  81555. * @param name Name of the extension to export
  81556. * @param factory The factory function that creates the exporter extension
  81557. */
  81558. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  81559. /**
  81560. * Un-registers an exporter extension
  81561. * @param name The name fo the exporter extension
  81562. * @returns A boolean indicating whether the extension has been un-registered
  81563. */
  81564. static UnregisterExtension(name: string): boolean;
  81565. /**
  81566. * Lazy load a local engine
  81567. */
  81568. _getLocalEngine(): Engine;
  81569. private reorderIndicesBasedOnPrimitiveMode;
  81570. /**
  81571. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  81572. * clock-wise during export to glTF
  81573. * @param submesh BabylonJS submesh
  81574. * @param primitiveMode Primitive mode of the mesh
  81575. * @param sideOrientation the winding order of the submesh
  81576. * @param vertexBufferKind The type of vertex attribute
  81577. * @param meshAttributeArray The vertex attribute data
  81578. * @param byteOffset The offset to the binary data
  81579. * @param binaryWriter The binary data for the glTF file
  81580. * @param convertToRightHandedSystem Converts the values to right-handed
  81581. */
  81582. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  81583. /**
  81584. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  81585. * clock-wise during export to glTF
  81586. * @param submesh BabylonJS submesh
  81587. * @param primitiveMode Primitive mode of the mesh
  81588. * @param sideOrientation the winding order of the submesh
  81589. * @param vertexBufferKind The type of vertex attribute
  81590. * @param meshAttributeArray The vertex attribute data
  81591. * @param byteOffset The offset to the binary data
  81592. * @param binaryWriter The binary data for the glTF file
  81593. * @param convertToRightHandedSystem Converts the values to right-handed
  81594. */
  81595. private reorderTriangleFillMode;
  81596. /**
  81597. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  81598. * clock-wise during export to glTF
  81599. * @param submesh BabylonJS submesh
  81600. * @param primitiveMode Primitive mode of the mesh
  81601. * @param sideOrientation the winding order of the submesh
  81602. * @param vertexBufferKind The type of vertex attribute
  81603. * @param meshAttributeArray The vertex attribute data
  81604. * @param byteOffset The offset to the binary data
  81605. * @param binaryWriter The binary data for the glTF file
  81606. * @param convertToRightHandedSystem Converts the values to right-handed
  81607. */
  81608. private reorderTriangleStripDrawMode;
  81609. /**
  81610. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  81611. * clock-wise during export to glTF
  81612. * @param submesh BabylonJS submesh
  81613. * @param primitiveMode Primitive mode of the mesh
  81614. * @param sideOrientation the winding order of the submesh
  81615. * @param vertexBufferKind The type of vertex attribute
  81616. * @param meshAttributeArray The vertex attribute data
  81617. * @param byteOffset The offset to the binary data
  81618. * @param binaryWriter The binary data for the glTF file
  81619. * @param convertToRightHandedSystem Converts the values to right-handed
  81620. */
  81621. private reorderTriangleFanMode;
  81622. /**
  81623. * Writes the vertex attribute data to binary
  81624. * @param vertices The vertices to write to the binary writer
  81625. * @param byteOffset The offset into the binary writer to overwrite binary data
  81626. * @param vertexAttributeKind The vertex attribute type
  81627. * @param meshAttributeArray The vertex attribute data
  81628. * @param binaryWriter The writer containing the binary data
  81629. * @param convertToRightHandedSystem Converts the values to right-handed
  81630. */
  81631. private writeVertexAttributeData;
  81632. /**
  81633. * Writes mesh attribute data to a data buffer
  81634. * Returns the bytelength of the data
  81635. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  81636. * @param meshAttributeArray Array containing the attribute data
  81637. * @param binaryWriter The buffer to write the binary data to
  81638. * @param indices Used to specify the order of the vertex data
  81639. * @param convertToRightHandedSystem Converts the values to right-handed
  81640. */
  81641. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  81642. /**
  81643. * Generates glTF json data
  81644. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  81645. * @param glTFPrefix Text to use when prefixing a glTF file
  81646. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  81647. * @returns json data as string
  81648. */
  81649. private generateJSON;
  81650. /**
  81651. * Generates data for .gltf and .bin files based on the glTF prefix string
  81652. * @param glTFPrefix Text to use when prefixing a glTF file
  81653. * @param dispose Dispose the exporter
  81654. * @returns GLTFData with glTF file data
  81655. */
  81656. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81657. /**
  81658. * Creates a binary buffer for glTF
  81659. * @returns array buffer for binary data
  81660. */
  81661. private _generateBinaryAsync;
  81662. /**
  81663. * Pads the number to a multiple of 4
  81664. * @param num number to pad
  81665. * @returns padded number
  81666. */
  81667. private _getPadding;
  81668. /**
  81669. * @hidden
  81670. */
  81671. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81672. /**
  81673. * Sets the TRS for each node
  81674. * @param node glTF Node for storing the transformation data
  81675. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  81676. * @param convertToRightHandedSystem Converts the values to right-handed
  81677. */
  81678. private setNodeTransformation;
  81679. private getVertexBufferFromMesh;
  81680. /**
  81681. * Creates a bufferview based on the vertices type for the Babylon mesh
  81682. * @param kind Indicates the type of vertices data
  81683. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  81684. * @param binaryWriter The buffer to write the bufferview data to
  81685. * @param convertToRightHandedSystem Converts the values to right-handed
  81686. */
  81687. private createBufferViewKind;
  81688. /**
  81689. * The primitive mode of the Babylon mesh
  81690. * @param babylonMesh The BabylonJS mesh
  81691. */
  81692. private getMeshPrimitiveMode;
  81693. /**
  81694. * Sets the primitive mode of the glTF mesh primitive
  81695. * @param meshPrimitive glTF mesh primitive
  81696. * @param primitiveMode The primitive mode
  81697. */
  81698. private setPrimitiveMode;
  81699. /**
  81700. * Sets the vertex attribute accessor based of the glTF mesh primitive
  81701. * @param meshPrimitive glTF mesh primitive
  81702. * @param attributeKind vertex attribute
  81703. * @returns boolean specifying if uv coordinates are present
  81704. */
  81705. private setAttributeKind;
  81706. /**
  81707. * Sets data for the primitive attributes of each submesh
  81708. * @param mesh glTF Mesh object to store the primitive attribute information
  81709. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  81710. * @param binaryWriter Buffer to write the attribute data to
  81711. * @param convertToRightHandedSystem Converts the values to right-handed
  81712. */
  81713. private setPrimitiveAttributesAsync;
  81714. /**
  81715. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  81716. * @param node The node to check
  81717. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  81718. */
  81719. private isBabylonCoordinateSystemConvertingNode;
  81720. /**
  81721. * Creates a glTF scene based on the array of meshes
  81722. * Returns the the total byte offset
  81723. * @param babylonScene Babylon scene to get the mesh data from
  81724. * @param binaryWriter Buffer to write binary data to
  81725. */
  81726. private createSceneAsync;
  81727. /**
  81728. * Creates a mapping of Node unique id to node index and handles animations
  81729. * @param babylonScene Babylon Scene
  81730. * @param nodes Babylon transform nodes
  81731. * @param binaryWriter Buffer to write binary data to
  81732. * @returns Node mapping of unique id to index
  81733. */
  81734. private createNodeMapAndAnimationsAsync;
  81735. /**
  81736. * Creates a glTF node from a Babylon mesh
  81737. * @param babylonMesh Source Babylon mesh
  81738. * @param binaryWriter Buffer for storing geometry data
  81739. * @param convertToRightHandedSystem Converts the values to right-handed
  81740. * @param nodeMap Node mapping of unique id to glTF node index
  81741. * @returns glTF node
  81742. */
  81743. private createNodeAsync;
  81744. }
  81745. /**
  81746. * @hidden
  81747. *
  81748. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  81749. */
  81750. export class _BinaryWriter {
  81751. /**
  81752. * Array buffer which stores all binary data
  81753. */
  81754. private _arrayBuffer;
  81755. /**
  81756. * View of the array buffer
  81757. */
  81758. private _dataView;
  81759. /**
  81760. * byte offset of data in array buffer
  81761. */
  81762. private _byteOffset;
  81763. /**
  81764. * Initialize binary writer with an initial byte length
  81765. * @param byteLength Initial byte length of the array buffer
  81766. */
  81767. constructor(byteLength: number);
  81768. /**
  81769. * Resize the array buffer to the specified byte length
  81770. * @param byteLength
  81771. */
  81772. private resizeBuffer;
  81773. /**
  81774. * Get an array buffer with the length of the byte offset
  81775. * @returns ArrayBuffer resized to the byte offset
  81776. */
  81777. getArrayBuffer(): ArrayBuffer;
  81778. /**
  81779. * Get the byte offset of the array buffer
  81780. * @returns byte offset
  81781. */
  81782. getByteOffset(): number;
  81783. /**
  81784. * Stores an UInt8 in the array buffer
  81785. * @param entry
  81786. * @param byteOffset If defined, specifies where to set the value as an offset.
  81787. */
  81788. setUInt8(entry: number, byteOffset?: number): void;
  81789. /**
  81790. * Gets an UInt32 in the array buffer
  81791. * @param entry
  81792. * @param byteOffset If defined, specifies where to set the value as an offset.
  81793. */
  81794. getUInt32(byteOffset: number): number;
  81795. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81796. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81797. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81798. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81799. /**
  81800. * Stores a Float32 in the array buffer
  81801. * @param entry
  81802. */
  81803. setFloat32(entry: number, byteOffset?: number): void;
  81804. /**
  81805. * Stores an UInt32 in the array buffer
  81806. * @param entry
  81807. * @param byteOffset If defined, specifies where to set the value as an offset.
  81808. */
  81809. setUInt32(entry: number, byteOffset?: number): void;
  81810. }
  81811. }
  81812. declare module BABYLON.GLTF2.Exporter {
  81813. /**
  81814. * @hidden
  81815. * Interface to store animation data.
  81816. */
  81817. export interface _IAnimationData {
  81818. /**
  81819. * Keyframe data.
  81820. */
  81821. inputs: number[];
  81822. /**
  81823. * Value data.
  81824. */
  81825. outputs: number[][];
  81826. /**
  81827. * Animation interpolation data.
  81828. */
  81829. samplerInterpolation: AnimationSamplerInterpolation;
  81830. /**
  81831. * Minimum keyframe value.
  81832. */
  81833. inputsMin: number;
  81834. /**
  81835. * Maximum keyframe value.
  81836. */
  81837. inputsMax: number;
  81838. }
  81839. /**
  81840. * @hidden
  81841. */
  81842. export interface _IAnimationInfo {
  81843. /**
  81844. * The target channel for the animation
  81845. */
  81846. animationChannelTargetPath: AnimationChannelTargetPath;
  81847. /**
  81848. * The glTF accessor type for the data.
  81849. */
  81850. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  81851. /**
  81852. * Specifies if quaternions should be used.
  81853. */
  81854. useQuaternion: boolean;
  81855. }
  81856. /**
  81857. * @hidden
  81858. * Utility class for generating glTF animation data from BabylonJS.
  81859. */
  81860. export class _GLTFAnimation {
  81861. /**
  81862. * @ignore
  81863. *
  81864. * Creates glTF channel animation from BabylonJS animation.
  81865. * @param babylonTransformNode - BabylonJS mesh.
  81866. * @param animation - animation.
  81867. * @param animationChannelTargetPath - The target animation channel.
  81868. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81869. * @param useQuaternion - Specifies if quaternions are used.
  81870. * @returns nullable IAnimationData
  81871. */
  81872. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81873. private static _DeduceAnimationInfo;
  81874. /**
  81875. * @ignore
  81876. * Create node animations from the transform node animations
  81877. * @param babylonNode
  81878. * @param runtimeGLTFAnimation
  81879. * @param idleGLTFAnimations
  81880. * @param nodeMap
  81881. * @param nodes
  81882. * @param binaryWriter
  81883. * @param bufferViews
  81884. * @param accessors
  81885. * @param convertToRightHandedSystem
  81886. * @param animationSampleRate
  81887. */
  81888. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81889. [key: number]: number;
  81890. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81891. /**
  81892. * @ignore
  81893. * Create node animations from the animation groups
  81894. * @param babylonScene
  81895. * @param glTFAnimations
  81896. * @param nodeMap
  81897. * @param nodes
  81898. * @param binaryWriter
  81899. * @param bufferViews
  81900. * @param accessors
  81901. * @param convertToRightHandedSystemMap
  81902. * @param animationSampleRate
  81903. */
  81904. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81905. [key: number]: number;
  81906. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81907. [nodeId: number]: boolean;
  81908. }, animationSampleRate: number): void;
  81909. private static AddAnimation;
  81910. /**
  81911. * Create a baked animation
  81912. * @param babylonTransformNode BabylonJS mesh
  81913. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81914. * @param animationChannelTargetPath animation target channel
  81915. * @param minFrame minimum animation frame
  81916. * @param maxFrame maximum animation frame
  81917. * @param fps frames per second of the animation
  81918. * @param inputs input key frames of the animation
  81919. * @param outputs output key frame data of the animation
  81920. * @param convertToRightHandedSystem converts the values to right-handed
  81921. * @param useQuaternion specifies if quaternions should be used
  81922. */
  81923. private static _CreateBakedAnimation;
  81924. private static _ConvertFactorToVector3OrQuaternion;
  81925. private static _SetInterpolatedValue;
  81926. /**
  81927. * Creates linear animation from the animation key frames
  81928. * @param babylonTransformNode BabylonJS mesh
  81929. * @param animation BabylonJS animation
  81930. * @param animationChannelTargetPath The target animation channel
  81931. * @param frameDelta The difference between the last and first frame of the animation
  81932. * @param inputs Array to store the key frame times
  81933. * @param outputs Array to store the key frame data
  81934. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81935. * @param useQuaternion Specifies if quaternions are used in the animation
  81936. */
  81937. private static _CreateLinearOrStepAnimation;
  81938. /**
  81939. * Creates cubic spline animation from the animation key frames
  81940. * @param babylonTransformNode BabylonJS mesh
  81941. * @param animation BabylonJS animation
  81942. * @param animationChannelTargetPath The target animation channel
  81943. * @param frameDelta The difference between the last and first frame of the animation
  81944. * @param inputs Array to store the key frame times
  81945. * @param outputs Array to store the key frame data
  81946. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81947. * @param useQuaternion Specifies if quaternions are used in the animation
  81948. */
  81949. private static _CreateCubicSplineAnimation;
  81950. private static _GetBasePositionRotationOrScale;
  81951. /**
  81952. * Adds a key frame value
  81953. * @param keyFrame
  81954. * @param animation
  81955. * @param outputs
  81956. * @param animationChannelTargetPath
  81957. * @param basePositionRotationOrScale
  81958. * @param convertToRightHandedSystem
  81959. * @param useQuaternion
  81960. */
  81961. private static _AddKeyframeValue;
  81962. /**
  81963. * Determine the interpolation based on the key frames
  81964. * @param keyFrames
  81965. * @param animationChannelTargetPath
  81966. * @param useQuaternion
  81967. */
  81968. private static _DeduceInterpolation;
  81969. /**
  81970. * Adds an input tangent or output tangent to the output data
  81971. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81972. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81973. * @param outputs The animation data by keyframe
  81974. * @param animationChannelTargetPath The target animation channel
  81975. * @param interpolation The interpolation type
  81976. * @param keyFrame The key frame with the animation data
  81977. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81978. * @param useQuaternion Specifies if quaternions are used
  81979. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81980. */
  81981. private static AddSplineTangent;
  81982. /**
  81983. * Get the minimum and maximum key frames' frame values
  81984. * @param keyFrames animation key frames
  81985. * @returns the minimum and maximum key frame value
  81986. */
  81987. private static calculateMinMaxKeyFrames;
  81988. }
  81989. }
  81990. declare module BABYLON.GLTF2.Exporter {
  81991. /** @hidden */
  81992. export var textureTransformPixelShader: {
  81993. name: string;
  81994. shader: string;
  81995. };
  81996. }
  81997. declare module BABYLON.GLTF2.Exporter.Extensions {
  81998. /**
  81999. * @hidden
  82000. */
  82001. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  82002. private _recordedTextures;
  82003. /** Name of this extension */
  82004. readonly name: string;
  82005. /** Defines whether this extension is enabled */
  82006. enabled: boolean;
  82007. /** Defines whether this extension is required */
  82008. required: boolean;
  82009. /** Reference to the glTF exporter */
  82010. private _wasUsed;
  82011. constructor(exporter: _Exporter);
  82012. dispose(): void;
  82013. /** @hidden */
  82014. get wasUsed(): boolean;
  82015. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82016. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  82017. /**
  82018. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  82019. * @param babylonTexture
  82020. * @param offset
  82021. * @param rotation
  82022. * @param scale
  82023. * @param scene
  82024. */
  82025. private _textureTransformTextureAsync;
  82026. }
  82027. }
  82028. declare module BABYLON.GLTF2.Exporter.Extensions {
  82029. /**
  82030. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  82031. */
  82032. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  82033. /** The name of this extension. */
  82034. readonly name: string;
  82035. /** Defines whether this extension is enabled. */
  82036. enabled: boolean;
  82037. /** Defines whether this extension is required */
  82038. required: boolean;
  82039. /** Reference to the glTF exporter */
  82040. private _exporter;
  82041. private _lights;
  82042. /** @hidden */
  82043. constructor(exporter: _Exporter);
  82044. /** @hidden */
  82045. dispose(): void;
  82046. /** @hidden */
  82047. get wasUsed(): boolean;
  82048. /** @hidden */
  82049. onExporting(): void;
  82050. /**
  82051. * Define this method to modify the default behavior when exporting a node
  82052. * @param context The context when exporting the node
  82053. * @param node glTF node
  82054. * @param babylonNode BabylonJS node
  82055. * @param nodeMap Node mapping of unique id to glTF node index
  82056. * @returns nullable INode promise
  82057. */
  82058. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82059. [key: number]: number;
  82060. }): Promise<Nullable<INode>>;
  82061. }
  82062. }
  82063. declare module BABYLON.GLTF2.Exporter.Extensions {
  82064. /**
  82065. * @hidden
  82066. */
  82067. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  82068. /** Name of this extension */
  82069. readonly name: string;
  82070. /** Defines whether this extension is enabled */
  82071. enabled: boolean;
  82072. /** Defines whether this extension is required */
  82073. required: boolean;
  82074. /** Reference to the glTF exporter */
  82075. private _textureInfos;
  82076. private _exportedTextures;
  82077. private _wasUsed;
  82078. constructor(exporter: _Exporter);
  82079. dispose(): void;
  82080. /** @hidden */
  82081. get wasUsed(): boolean;
  82082. private _getTextureIndex;
  82083. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82084. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82085. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82086. }
  82087. }
  82088. declare module BABYLON {
  82089. /**
  82090. * Class for generating STL data from a Babylon scene.
  82091. */
  82092. export class STLExport {
  82093. /**
  82094. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  82095. * @param meshes list defines the mesh to serialize
  82096. * @param download triggers the automatic download of the file.
  82097. * @param fileName changes the downloads fileName.
  82098. * @param binary changes the STL to a binary type.
  82099. * @param isLittleEndian toggle for binary type exporter.
  82100. * @returns the STL as UTF8 string
  82101. */
  82102. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  82103. }
  82104. }
  82105. declare module "babylonjs-gltf2interface" {
  82106. export = BABYLON.GLTF2;
  82107. }
  82108. /**
  82109. * Module for glTF 2.0 Interface
  82110. */
  82111. declare module BABYLON.GLTF2 {
  82112. /**
  82113. * The datatype of the components in the attribute
  82114. */
  82115. const enum AccessorComponentType {
  82116. /**
  82117. * Byte
  82118. */
  82119. BYTE = 5120,
  82120. /**
  82121. * Unsigned Byte
  82122. */
  82123. UNSIGNED_BYTE = 5121,
  82124. /**
  82125. * Short
  82126. */
  82127. SHORT = 5122,
  82128. /**
  82129. * Unsigned Short
  82130. */
  82131. UNSIGNED_SHORT = 5123,
  82132. /**
  82133. * Unsigned Int
  82134. */
  82135. UNSIGNED_INT = 5125,
  82136. /**
  82137. * Float
  82138. */
  82139. FLOAT = 5126,
  82140. }
  82141. /**
  82142. * Specifies if the attirbute is a scalar, vector, or matrix
  82143. */
  82144. const enum AccessorType {
  82145. /**
  82146. * Scalar
  82147. */
  82148. SCALAR = "SCALAR",
  82149. /**
  82150. * Vector2
  82151. */
  82152. VEC2 = "VEC2",
  82153. /**
  82154. * Vector3
  82155. */
  82156. VEC3 = "VEC3",
  82157. /**
  82158. * Vector4
  82159. */
  82160. VEC4 = "VEC4",
  82161. /**
  82162. * Matrix2x2
  82163. */
  82164. MAT2 = "MAT2",
  82165. /**
  82166. * Matrix3x3
  82167. */
  82168. MAT3 = "MAT3",
  82169. /**
  82170. * Matrix4x4
  82171. */
  82172. MAT4 = "MAT4",
  82173. }
  82174. /**
  82175. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82176. */
  82177. const enum AnimationChannelTargetPath {
  82178. /**
  82179. * Translation
  82180. */
  82181. TRANSLATION = "translation",
  82182. /**
  82183. * Rotation
  82184. */
  82185. ROTATION = "rotation",
  82186. /**
  82187. * Scale
  82188. */
  82189. SCALE = "scale",
  82190. /**
  82191. * Weights
  82192. */
  82193. WEIGHTS = "weights",
  82194. }
  82195. /**
  82196. * Interpolation algorithm
  82197. */
  82198. const enum AnimationSamplerInterpolation {
  82199. /**
  82200. * The animated values are linearly interpolated between keyframes
  82201. */
  82202. LINEAR = "LINEAR",
  82203. /**
  82204. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82205. */
  82206. STEP = "STEP",
  82207. /**
  82208. * The animation's interpolation is computed using a cubic spline with specified tangents
  82209. */
  82210. CUBICSPLINE = "CUBICSPLINE",
  82211. }
  82212. /**
  82213. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82214. */
  82215. const enum CameraType {
  82216. /**
  82217. * A perspective camera containing properties to create a perspective projection matrix
  82218. */
  82219. PERSPECTIVE = "perspective",
  82220. /**
  82221. * An orthographic camera containing properties to create an orthographic projection matrix
  82222. */
  82223. ORTHOGRAPHIC = "orthographic",
  82224. }
  82225. /**
  82226. * The mime-type of the image
  82227. */
  82228. const enum ImageMimeType {
  82229. /**
  82230. * JPEG Mime-type
  82231. */
  82232. JPEG = "image/jpeg",
  82233. /**
  82234. * PNG Mime-type
  82235. */
  82236. PNG = "image/png",
  82237. }
  82238. /**
  82239. * The alpha rendering mode of the material
  82240. */
  82241. const enum MaterialAlphaMode {
  82242. /**
  82243. * The alpha value is ignored and the rendered output is fully opaque
  82244. */
  82245. OPAQUE = "OPAQUE",
  82246. /**
  82247. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82248. */
  82249. MASK = "MASK",
  82250. /**
  82251. * 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)
  82252. */
  82253. BLEND = "BLEND",
  82254. }
  82255. /**
  82256. * The type of the primitives to render
  82257. */
  82258. const enum MeshPrimitiveMode {
  82259. /**
  82260. * Points
  82261. */
  82262. POINTS = 0,
  82263. /**
  82264. * Lines
  82265. */
  82266. LINES = 1,
  82267. /**
  82268. * Line Loop
  82269. */
  82270. LINE_LOOP = 2,
  82271. /**
  82272. * Line Strip
  82273. */
  82274. LINE_STRIP = 3,
  82275. /**
  82276. * Triangles
  82277. */
  82278. TRIANGLES = 4,
  82279. /**
  82280. * Triangle Strip
  82281. */
  82282. TRIANGLE_STRIP = 5,
  82283. /**
  82284. * Triangle Fan
  82285. */
  82286. TRIANGLE_FAN = 6,
  82287. }
  82288. /**
  82289. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82290. */
  82291. const enum TextureMagFilter {
  82292. /**
  82293. * Nearest
  82294. */
  82295. NEAREST = 9728,
  82296. /**
  82297. * Linear
  82298. */
  82299. LINEAR = 9729,
  82300. }
  82301. /**
  82302. * Minification filter. All valid values correspond to WebGL enums
  82303. */
  82304. const enum TextureMinFilter {
  82305. /**
  82306. * Nearest
  82307. */
  82308. NEAREST = 9728,
  82309. /**
  82310. * Linear
  82311. */
  82312. LINEAR = 9729,
  82313. /**
  82314. * Nearest Mip-Map Nearest
  82315. */
  82316. NEAREST_MIPMAP_NEAREST = 9984,
  82317. /**
  82318. * Linear Mipmap Nearest
  82319. */
  82320. LINEAR_MIPMAP_NEAREST = 9985,
  82321. /**
  82322. * Nearest Mipmap Linear
  82323. */
  82324. NEAREST_MIPMAP_LINEAR = 9986,
  82325. /**
  82326. * Linear Mipmap Linear
  82327. */
  82328. LINEAR_MIPMAP_LINEAR = 9987,
  82329. }
  82330. /**
  82331. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82332. */
  82333. const enum TextureWrapMode {
  82334. /**
  82335. * Clamp to Edge
  82336. */
  82337. CLAMP_TO_EDGE = 33071,
  82338. /**
  82339. * Mirrored Repeat
  82340. */
  82341. MIRRORED_REPEAT = 33648,
  82342. /**
  82343. * Repeat
  82344. */
  82345. REPEAT = 10497,
  82346. }
  82347. /**
  82348. * glTF Property
  82349. */
  82350. interface IProperty {
  82351. /**
  82352. * Dictionary object with extension-specific objects
  82353. */
  82354. extensions?: {
  82355. [key: string]: any;
  82356. };
  82357. /**
  82358. * Application-Specific data
  82359. */
  82360. extras?: any;
  82361. }
  82362. /**
  82363. * glTF Child of Root Property
  82364. */
  82365. interface IChildRootProperty extends IProperty {
  82366. /**
  82367. * The user-defined name of this object
  82368. */
  82369. name?: string;
  82370. }
  82371. /**
  82372. * Indices of those attributes that deviate from their initialization value
  82373. */
  82374. interface IAccessorSparseIndices extends IProperty {
  82375. /**
  82376. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82377. */
  82378. bufferView: number;
  82379. /**
  82380. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82381. */
  82382. byteOffset?: number;
  82383. /**
  82384. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82385. */
  82386. componentType: AccessorComponentType;
  82387. }
  82388. /**
  82389. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82390. */
  82391. interface IAccessorSparseValues extends IProperty {
  82392. /**
  82393. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82394. */
  82395. bufferView: number;
  82396. /**
  82397. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82398. */
  82399. byteOffset?: number;
  82400. }
  82401. /**
  82402. * Sparse storage of attributes that deviate from their initialization value
  82403. */
  82404. interface IAccessorSparse extends IProperty {
  82405. /**
  82406. * The number of attributes encoded in this sparse accessor
  82407. */
  82408. count: number;
  82409. /**
  82410. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82411. */
  82412. indices: IAccessorSparseIndices;
  82413. /**
  82414. * 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
  82415. */
  82416. values: IAccessorSparseValues;
  82417. }
  82418. /**
  82419. * 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
  82420. */
  82421. interface IAccessor extends IChildRootProperty {
  82422. /**
  82423. * The index of the bufferview
  82424. */
  82425. bufferView?: number;
  82426. /**
  82427. * The offset relative to the start of the bufferView in bytes
  82428. */
  82429. byteOffset?: number;
  82430. /**
  82431. * The datatype of components in the attribute
  82432. */
  82433. componentType: AccessorComponentType;
  82434. /**
  82435. * Specifies whether integer data values should be normalized
  82436. */
  82437. normalized?: boolean;
  82438. /**
  82439. * The number of attributes referenced by this accessor
  82440. */
  82441. count: number;
  82442. /**
  82443. * Specifies if the attribute is a scalar, vector, or matrix
  82444. */
  82445. type: AccessorType;
  82446. /**
  82447. * Maximum value of each component in this attribute
  82448. */
  82449. max?: number[];
  82450. /**
  82451. * Minimum value of each component in this attribute
  82452. */
  82453. min?: number[];
  82454. /**
  82455. * Sparse storage of attributes that deviate from their initialization value
  82456. */
  82457. sparse?: IAccessorSparse;
  82458. }
  82459. /**
  82460. * Targets an animation's sampler at a node's property
  82461. */
  82462. interface IAnimationChannel extends IProperty {
  82463. /**
  82464. * The index of a sampler in this animation used to compute the value for the target
  82465. */
  82466. sampler: number;
  82467. /**
  82468. * The index of the node and TRS property to target
  82469. */
  82470. target: IAnimationChannelTarget;
  82471. }
  82472. /**
  82473. * The index of the node and TRS property that an animation channel targets
  82474. */
  82475. interface IAnimationChannelTarget extends IProperty {
  82476. /**
  82477. * The index of the node to target
  82478. */
  82479. node: number;
  82480. /**
  82481. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82482. */
  82483. path: AnimationChannelTargetPath;
  82484. }
  82485. /**
  82486. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82487. */
  82488. interface IAnimationSampler extends IProperty {
  82489. /**
  82490. * The index of an accessor containing keyframe input values, e.g., time
  82491. */
  82492. input: number;
  82493. /**
  82494. * Interpolation algorithm
  82495. */
  82496. interpolation?: AnimationSamplerInterpolation;
  82497. /**
  82498. * The index of an accessor, containing keyframe output values
  82499. */
  82500. output: number;
  82501. }
  82502. /**
  82503. * A keyframe animation
  82504. */
  82505. interface IAnimation extends IChildRootProperty {
  82506. /**
  82507. * An array of channels, each of which targets an animation's sampler at a node's property
  82508. */
  82509. channels: IAnimationChannel[];
  82510. /**
  82511. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82512. */
  82513. samplers: IAnimationSampler[];
  82514. }
  82515. /**
  82516. * Metadata about the glTF asset
  82517. */
  82518. interface IAsset extends IChildRootProperty {
  82519. /**
  82520. * A copyright message suitable for display to credit the content creator
  82521. */
  82522. copyright?: string;
  82523. /**
  82524. * Tool that generated this glTF model. Useful for debugging
  82525. */
  82526. generator?: string;
  82527. /**
  82528. * The glTF version that this asset targets
  82529. */
  82530. version: string;
  82531. /**
  82532. * The minimum glTF version that this asset targets
  82533. */
  82534. minVersion?: string;
  82535. }
  82536. /**
  82537. * A buffer points to binary geometry, animation, or skins
  82538. */
  82539. interface IBuffer extends IChildRootProperty {
  82540. /**
  82541. * 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
  82542. */
  82543. uri?: string;
  82544. /**
  82545. * The length of the buffer in bytes
  82546. */
  82547. byteLength: number;
  82548. }
  82549. /**
  82550. * A view into a buffer generally representing a subset of the buffer
  82551. */
  82552. interface IBufferView extends IChildRootProperty {
  82553. /**
  82554. * The index of the buffer
  82555. */
  82556. buffer: number;
  82557. /**
  82558. * The offset into the buffer in bytes
  82559. */
  82560. byteOffset?: number;
  82561. /**
  82562. * The lenth of the bufferView in bytes
  82563. */
  82564. byteLength: number;
  82565. /**
  82566. * The stride, in bytes
  82567. */
  82568. byteStride?: number;
  82569. }
  82570. /**
  82571. * An orthographic camera containing properties to create an orthographic projection matrix
  82572. */
  82573. interface ICameraOrthographic extends IProperty {
  82574. /**
  82575. * The floating-point horizontal magnification of the view. Must not be zero
  82576. */
  82577. xmag: number;
  82578. /**
  82579. * The floating-point vertical magnification of the view. Must not be zero
  82580. */
  82581. ymag: number;
  82582. /**
  82583. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  82584. */
  82585. zfar: number;
  82586. /**
  82587. * The floating-point distance to the near clipping plane
  82588. */
  82589. znear: number;
  82590. }
  82591. /**
  82592. * A perspective camera containing properties to create a perspective projection matrix
  82593. */
  82594. interface ICameraPerspective extends IProperty {
  82595. /**
  82596. * The floating-point aspect ratio of the field of view
  82597. */
  82598. aspectRatio?: number;
  82599. /**
  82600. * The floating-point vertical field of view in radians
  82601. */
  82602. yfov: number;
  82603. /**
  82604. * The floating-point distance to the far clipping plane
  82605. */
  82606. zfar?: number;
  82607. /**
  82608. * The floating-point distance to the near clipping plane
  82609. */
  82610. znear: number;
  82611. }
  82612. /**
  82613. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82614. */
  82615. interface ICamera extends IChildRootProperty {
  82616. /**
  82617. * An orthographic camera containing properties to create an orthographic projection matrix
  82618. */
  82619. orthographic?: ICameraOrthographic;
  82620. /**
  82621. * A perspective camera containing properties to create a perspective projection matrix
  82622. */
  82623. perspective?: ICameraPerspective;
  82624. /**
  82625. * Specifies if the camera uses a perspective or orthographic projection
  82626. */
  82627. type: CameraType;
  82628. }
  82629. /**
  82630. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  82631. */
  82632. interface IImage extends IChildRootProperty {
  82633. /**
  82634. * 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
  82635. */
  82636. uri?: string;
  82637. /**
  82638. * The image's MIME type
  82639. */
  82640. mimeType?: ImageMimeType;
  82641. /**
  82642. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  82643. */
  82644. bufferView?: number;
  82645. }
  82646. /**
  82647. * Material Normal Texture Info
  82648. */
  82649. interface IMaterialNormalTextureInfo extends ITextureInfo {
  82650. /**
  82651. * The scalar multiplier applied to each normal vector of the normal texture
  82652. */
  82653. scale?: number;
  82654. }
  82655. /**
  82656. * Material Occlusion Texture Info
  82657. */
  82658. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  82659. /**
  82660. * A scalar multiplier controlling the amount of occlusion applied
  82661. */
  82662. strength?: number;
  82663. }
  82664. /**
  82665. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  82666. */
  82667. interface IMaterialPbrMetallicRoughness {
  82668. /**
  82669. * The material's base color factor
  82670. */
  82671. baseColorFactor?: number[];
  82672. /**
  82673. * The base color texture
  82674. */
  82675. baseColorTexture?: ITextureInfo;
  82676. /**
  82677. * The metalness of the material
  82678. */
  82679. metallicFactor?: number;
  82680. /**
  82681. * The roughness of the material
  82682. */
  82683. roughnessFactor?: number;
  82684. /**
  82685. * The metallic-roughness texture
  82686. */
  82687. metallicRoughnessTexture?: ITextureInfo;
  82688. }
  82689. /**
  82690. * The material appearance of a primitive
  82691. */
  82692. interface IMaterial extends IChildRootProperty {
  82693. /**
  82694. * 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
  82695. */
  82696. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82697. /**
  82698. * The normal map texture
  82699. */
  82700. normalTexture?: IMaterialNormalTextureInfo;
  82701. /**
  82702. * The occlusion map texture
  82703. */
  82704. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82705. /**
  82706. * The emissive map texture
  82707. */
  82708. emissiveTexture?: ITextureInfo;
  82709. /**
  82710. * 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
  82711. */
  82712. emissiveFactor?: number[];
  82713. /**
  82714. * The alpha rendering mode of the material
  82715. */
  82716. alphaMode?: MaterialAlphaMode;
  82717. /**
  82718. * The alpha cutoff value of the material
  82719. */
  82720. alphaCutoff?: number;
  82721. /**
  82722. * Specifies whether the material is double sided
  82723. */
  82724. doubleSided?: boolean;
  82725. }
  82726. /**
  82727. * Geometry to be rendered with the given material
  82728. */
  82729. interface IMeshPrimitive extends IProperty {
  82730. /**
  82731. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  82732. */
  82733. attributes: {
  82734. [name: string]: number;
  82735. };
  82736. /**
  82737. * The index of the accessor that contains the indices
  82738. */
  82739. indices?: number;
  82740. /**
  82741. * The index of the material to apply to this primitive when rendering
  82742. */
  82743. material?: number;
  82744. /**
  82745. * The type of primitives to render. All valid values correspond to WebGL enums
  82746. */
  82747. mode?: MeshPrimitiveMode;
  82748. /**
  82749. * 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
  82750. */
  82751. targets?: {
  82752. [name: string]: number;
  82753. }[];
  82754. }
  82755. /**
  82756. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  82757. */
  82758. interface IMesh extends IChildRootProperty {
  82759. /**
  82760. * An array of primitives, each defining geometry to be rendered with a material
  82761. */
  82762. primitives: IMeshPrimitive[];
  82763. /**
  82764. * Array of weights to be applied to the Morph Targets
  82765. */
  82766. weights?: number[];
  82767. }
  82768. /**
  82769. * A node in the node hierarchy
  82770. */
  82771. interface INode extends IChildRootProperty {
  82772. /**
  82773. * The index of the camera referenced by this node
  82774. */
  82775. camera?: number;
  82776. /**
  82777. * The indices of this node's children
  82778. */
  82779. children?: number[];
  82780. /**
  82781. * The index of the skin referenced by this node
  82782. */
  82783. skin?: number;
  82784. /**
  82785. * A floating-point 4x4 transformation matrix stored in column-major order
  82786. */
  82787. matrix?: number[];
  82788. /**
  82789. * The index of the mesh in this node
  82790. */
  82791. mesh?: number;
  82792. /**
  82793. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  82794. */
  82795. rotation?: number[];
  82796. /**
  82797. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  82798. */
  82799. scale?: number[];
  82800. /**
  82801. * The node's translation along the x, y, and z axes
  82802. */
  82803. translation?: number[];
  82804. /**
  82805. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  82806. */
  82807. weights?: number[];
  82808. }
  82809. /**
  82810. * Texture sampler properties for filtering and wrapping modes
  82811. */
  82812. interface ISampler extends IChildRootProperty {
  82813. /**
  82814. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82815. */
  82816. magFilter?: TextureMagFilter;
  82817. /**
  82818. * Minification filter. All valid values correspond to WebGL enums
  82819. */
  82820. minFilter?: TextureMinFilter;
  82821. /**
  82822. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82823. */
  82824. wrapS?: TextureWrapMode;
  82825. /**
  82826. * T (V) wrapping mode. All valid values correspond to WebGL enums
  82827. */
  82828. wrapT?: TextureWrapMode;
  82829. }
  82830. /**
  82831. * The root nodes of a scene
  82832. */
  82833. interface IScene extends IChildRootProperty {
  82834. /**
  82835. * The indices of each root node
  82836. */
  82837. nodes: number[];
  82838. }
  82839. /**
  82840. * Joints and matrices defining a skin
  82841. */
  82842. interface ISkin extends IChildRootProperty {
  82843. /**
  82844. * 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
  82845. */
  82846. inverseBindMatrices?: number;
  82847. /**
  82848. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  82849. */
  82850. skeleton?: number;
  82851. /**
  82852. * 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)
  82853. */
  82854. joints: number[];
  82855. }
  82856. /**
  82857. * A texture and its sampler
  82858. */
  82859. interface ITexture extends IChildRootProperty {
  82860. /**
  82861. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82862. */
  82863. sampler?: number;
  82864. /**
  82865. * The index of the image used by this texture
  82866. */
  82867. source: number;
  82868. }
  82869. /**
  82870. * Reference to a texture
  82871. */
  82872. interface ITextureInfo extends IProperty {
  82873. /**
  82874. * The index of the texture
  82875. */
  82876. index: number;
  82877. /**
  82878. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82879. */
  82880. texCoord?: number;
  82881. }
  82882. /**
  82883. * The root object for a glTF asset
  82884. */
  82885. interface IGLTF extends IProperty {
  82886. /**
  82887. * An array of accessors. An accessor is a typed view into a bufferView
  82888. */
  82889. accessors?: IAccessor[];
  82890. /**
  82891. * An array of keyframe animations
  82892. */
  82893. animations?: IAnimation[];
  82894. /**
  82895. * Metadata about the glTF asset
  82896. */
  82897. asset: IAsset;
  82898. /**
  82899. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82900. */
  82901. buffers?: IBuffer[];
  82902. /**
  82903. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82904. */
  82905. bufferViews?: IBufferView[];
  82906. /**
  82907. * An array of cameras
  82908. */
  82909. cameras?: ICamera[];
  82910. /**
  82911. * Names of glTF extensions used somewhere in this asset
  82912. */
  82913. extensionsUsed?: string[];
  82914. /**
  82915. * Names of glTF extensions required to properly load this asset
  82916. */
  82917. extensionsRequired?: string[];
  82918. /**
  82919. * An array of images. An image defines data used to create a texture
  82920. */
  82921. images?: IImage[];
  82922. /**
  82923. * An array of materials. A material defines the appearance of a primitive
  82924. */
  82925. materials?: IMaterial[];
  82926. /**
  82927. * An array of meshes. A mesh is a set of primitives to be rendered
  82928. */
  82929. meshes?: IMesh[];
  82930. /**
  82931. * An array of nodes
  82932. */
  82933. nodes?: INode[];
  82934. /**
  82935. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82936. */
  82937. samplers?: ISampler[];
  82938. /**
  82939. * The index of the default scene
  82940. */
  82941. scene?: number;
  82942. /**
  82943. * An array of scenes
  82944. */
  82945. scenes?: IScene[];
  82946. /**
  82947. * An array of skins. A skin is defined by joints and matrices
  82948. */
  82949. skins?: ISkin[];
  82950. /**
  82951. * An array of textures
  82952. */
  82953. textures?: ITexture[];
  82954. }
  82955. /**
  82956. * The glTF validation results
  82957. * @ignore
  82958. */
  82959. interface IGLTFValidationResults {
  82960. info: {
  82961. generator: string;
  82962. hasAnimations: boolean;
  82963. hasDefaultScene: boolean;
  82964. hasMaterials: boolean;
  82965. hasMorphTargets: boolean;
  82966. hasSkins: boolean;
  82967. hasTextures: boolean;
  82968. maxAttributesUsed: number;
  82969. primitivesCount: number
  82970. };
  82971. issues: {
  82972. messages: Array<string>;
  82973. numErrors: number;
  82974. numHints: number;
  82975. numInfos: number;
  82976. numWarnings: number;
  82977. truncated: boolean
  82978. };
  82979. mimeType: string;
  82980. uri: string;
  82981. validatedAt: string;
  82982. validatorVersion: string;
  82983. }
  82984. /**
  82985. * The glTF validation options
  82986. */
  82987. interface IGLTFValidationOptions {
  82988. /** Uri to use */
  82989. uri?: string;
  82990. /** Function used to load external resources */
  82991. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82992. /** Boolean indicating that we need to validate accessor data */
  82993. validateAccessorData?: boolean;
  82994. /** max number of issues allowed */
  82995. maxIssues?: number;
  82996. /** Ignored issues */
  82997. ignoredIssues?: Array<string>;
  82998. /** Value to override severy settings */
  82999. severityOverrides?: Object;
  83000. }
  83001. /**
  83002. * The glTF validator object
  83003. * @ignore
  83004. */
  83005. interface IGLTFValidator {
  83006. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83007. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83008. }
  83009. }
  83010. declare module BABYLON {
  83011. /** @hidden */
  83012. export var cellPixelShader: {
  83013. name: string;
  83014. shader: string;
  83015. };
  83016. }
  83017. declare module BABYLON {
  83018. /** @hidden */
  83019. export var cellVertexShader: {
  83020. name: string;
  83021. shader: string;
  83022. };
  83023. }
  83024. declare module BABYLON {
  83025. export class CellMaterial extends BABYLON.PushMaterial {
  83026. private _diffuseTexture;
  83027. diffuseTexture: BABYLON.BaseTexture;
  83028. diffuseColor: BABYLON.Color3;
  83029. _computeHighLevel: boolean;
  83030. computeHighLevel: boolean;
  83031. private _disableLighting;
  83032. disableLighting: boolean;
  83033. private _maxSimultaneousLights;
  83034. maxSimultaneousLights: number;
  83035. constructor(name: string, scene: BABYLON.Scene);
  83036. needAlphaBlending(): boolean;
  83037. needAlphaTesting(): boolean;
  83038. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83039. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83040. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83041. getAnimatables(): BABYLON.IAnimatable[];
  83042. getActiveTextures(): BABYLON.BaseTexture[];
  83043. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83044. dispose(forceDisposeEffect?: boolean): void;
  83045. getClassName(): string;
  83046. clone(name: string): CellMaterial;
  83047. serialize(): any;
  83048. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  83049. }
  83050. }
  83051. declare module BABYLON {
  83052. export class CustomShaderStructure {
  83053. FragmentStore: string;
  83054. VertexStore: string;
  83055. constructor();
  83056. }
  83057. export class ShaderSpecialParts {
  83058. constructor();
  83059. Fragment_Begin: string;
  83060. Fragment_Definitions: string;
  83061. Fragment_MainBegin: string;
  83062. Fragment_Custom_Diffuse: string;
  83063. Fragment_Before_Lights: string;
  83064. Fragment_Before_Fog: string;
  83065. Fragment_Custom_Alpha: string;
  83066. Fragment_Before_FragColor: string;
  83067. Vertex_Begin: string;
  83068. Vertex_Definitions: string;
  83069. Vertex_MainBegin: string;
  83070. Vertex_Before_PositionUpdated: string;
  83071. Vertex_Before_NormalUpdated: string;
  83072. Vertex_After_WorldPosComputed: string;
  83073. Vertex_MainEnd: string;
  83074. }
  83075. export class CustomMaterial extends BABYLON.StandardMaterial {
  83076. static ShaderIndexer: number;
  83077. CustomParts: ShaderSpecialParts;
  83078. _isCreatedShader: boolean;
  83079. _createdShaderName: string;
  83080. _customUniform: string[];
  83081. _newUniforms: string[];
  83082. _newUniformInstances: {
  83083. [name: string]: any;
  83084. };
  83085. _newSamplerInstances: {
  83086. [name: string]: BABYLON.Texture;
  83087. };
  83088. _customAttributes: string[];
  83089. FragmentShader: string;
  83090. VertexShader: string;
  83091. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83092. ReviewUniform(name: string, arr: string[]): string[];
  83093. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83094. constructor(name: string, scene: BABYLON.Scene);
  83095. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  83096. AddAttribute(name: string): CustomMaterial;
  83097. Fragment_Begin(shaderPart: string): CustomMaterial;
  83098. Fragment_Definitions(shaderPart: string): CustomMaterial;
  83099. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  83100. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  83101. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  83102. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  83103. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  83104. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  83105. Vertex_Begin(shaderPart: string): CustomMaterial;
  83106. Vertex_Definitions(shaderPart: string): CustomMaterial;
  83107. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  83108. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  83109. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  83110. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  83111. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  83112. }
  83113. }
  83114. declare module BABYLON {
  83115. export class ShaderAlebdoParts {
  83116. constructor();
  83117. Fragment_Begin: string;
  83118. Fragment_Definitions: string;
  83119. Fragment_MainBegin: string;
  83120. Fragment_Custom_Albedo: string;
  83121. Fragment_Before_Lights: string;
  83122. Fragment_Custom_MetallicRoughness: string;
  83123. Fragment_Custom_MicroSurface: string;
  83124. Fragment_Before_Fog: string;
  83125. Fragment_Custom_Alpha: string;
  83126. Fragment_Before_FragColor: string;
  83127. Vertex_Begin: string;
  83128. Vertex_Definitions: string;
  83129. Vertex_MainBegin: string;
  83130. Vertex_Before_PositionUpdated: string;
  83131. Vertex_Before_NormalUpdated: string;
  83132. Vertex_After_WorldPosComputed: string;
  83133. Vertex_MainEnd: string;
  83134. }
  83135. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  83136. static ShaderIndexer: number;
  83137. CustomParts: ShaderAlebdoParts;
  83138. _isCreatedShader: boolean;
  83139. _createdShaderName: string;
  83140. _customUniform: string[];
  83141. _newUniforms: string[];
  83142. _newUniformInstances: {
  83143. [name: string]: any;
  83144. };
  83145. _newSamplerInstances: {
  83146. [name: string]: BABYLON.Texture;
  83147. };
  83148. _customAttributes: string[];
  83149. FragmentShader: string;
  83150. VertexShader: string;
  83151. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83152. ReviewUniform(name: string, arr: string[]): string[];
  83153. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83154. constructor(name: string, scene: BABYLON.Scene);
  83155. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  83156. AddAttribute(name: string): PBRCustomMaterial;
  83157. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  83158. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  83159. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  83160. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  83161. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  83162. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  83163. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  83164. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  83165. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  83166. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  83167. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  83168. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  83169. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  83170. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  83171. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  83172. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  83173. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  83174. }
  83175. }
  83176. declare module BABYLON {
  83177. /** @hidden */
  83178. export var firePixelShader: {
  83179. name: string;
  83180. shader: string;
  83181. };
  83182. }
  83183. declare module BABYLON {
  83184. /** @hidden */
  83185. export var fireVertexShader: {
  83186. name: string;
  83187. shader: string;
  83188. };
  83189. }
  83190. declare module BABYLON {
  83191. export class FireMaterial extends BABYLON.PushMaterial {
  83192. private _diffuseTexture;
  83193. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83194. private _distortionTexture;
  83195. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83196. private _opacityTexture;
  83197. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83198. diffuseColor: BABYLON.Color3;
  83199. speed: number;
  83200. private _scaledDiffuse;
  83201. private _lastTime;
  83202. constructor(name: string, scene: BABYLON.Scene);
  83203. needAlphaBlending(): boolean;
  83204. needAlphaTesting(): boolean;
  83205. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83206. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83207. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83208. getAnimatables(): BABYLON.IAnimatable[];
  83209. getActiveTextures(): BABYLON.BaseTexture[];
  83210. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83211. getClassName(): string;
  83212. dispose(forceDisposeEffect?: boolean): void;
  83213. clone(name: string): FireMaterial;
  83214. serialize(): any;
  83215. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  83216. }
  83217. }
  83218. declare module BABYLON {
  83219. /** @hidden */
  83220. export var furPixelShader: {
  83221. name: string;
  83222. shader: string;
  83223. };
  83224. }
  83225. declare module BABYLON {
  83226. /** @hidden */
  83227. export var furVertexShader: {
  83228. name: string;
  83229. shader: string;
  83230. };
  83231. }
  83232. declare module BABYLON {
  83233. export class FurMaterial extends BABYLON.PushMaterial {
  83234. private _diffuseTexture;
  83235. diffuseTexture: BABYLON.BaseTexture;
  83236. private _heightTexture;
  83237. heightTexture: BABYLON.BaseTexture;
  83238. diffuseColor: BABYLON.Color3;
  83239. furLength: number;
  83240. furAngle: number;
  83241. furColor: BABYLON.Color3;
  83242. furOffset: number;
  83243. furSpacing: number;
  83244. furGravity: BABYLON.Vector3;
  83245. furSpeed: number;
  83246. furDensity: number;
  83247. furOcclusion: number;
  83248. furTexture: BABYLON.DynamicTexture;
  83249. private _disableLighting;
  83250. disableLighting: boolean;
  83251. private _maxSimultaneousLights;
  83252. maxSimultaneousLights: number;
  83253. highLevelFur: boolean;
  83254. _meshes: BABYLON.AbstractMesh[];
  83255. private _furTime;
  83256. constructor(name: string, scene: BABYLON.Scene);
  83257. get furTime(): number;
  83258. set furTime(furTime: number);
  83259. needAlphaBlending(): boolean;
  83260. needAlphaTesting(): boolean;
  83261. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83262. updateFur(): void;
  83263. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83264. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83265. getAnimatables(): BABYLON.IAnimatable[];
  83266. getActiveTextures(): BABYLON.BaseTexture[];
  83267. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83268. dispose(forceDisposeEffect?: boolean): void;
  83269. clone(name: string): FurMaterial;
  83270. serialize(): any;
  83271. getClassName(): string;
  83272. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  83273. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  83274. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  83275. }
  83276. }
  83277. declare module BABYLON {
  83278. /** @hidden */
  83279. export var gradientPixelShader: {
  83280. name: string;
  83281. shader: string;
  83282. };
  83283. }
  83284. declare module BABYLON {
  83285. /** @hidden */
  83286. export var gradientVertexShader: {
  83287. name: string;
  83288. shader: string;
  83289. };
  83290. }
  83291. declare module BABYLON {
  83292. export class GradientMaterial extends BABYLON.PushMaterial {
  83293. private _maxSimultaneousLights;
  83294. maxSimultaneousLights: number;
  83295. topColor: BABYLON.Color3;
  83296. topColorAlpha: number;
  83297. bottomColor: BABYLON.Color3;
  83298. bottomColorAlpha: number;
  83299. offset: number;
  83300. scale: number;
  83301. smoothness: number;
  83302. private _disableLighting;
  83303. disableLighting: boolean;
  83304. constructor(name: string, scene: BABYLON.Scene);
  83305. needAlphaBlending(): boolean;
  83306. needAlphaTesting(): boolean;
  83307. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83308. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83309. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83310. getAnimatables(): BABYLON.IAnimatable[];
  83311. dispose(forceDisposeEffect?: boolean): void;
  83312. clone(name: string): GradientMaterial;
  83313. serialize(): any;
  83314. getClassName(): string;
  83315. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  83316. }
  83317. }
  83318. declare module BABYLON {
  83319. /** @hidden */
  83320. export var gridPixelShader: {
  83321. name: string;
  83322. shader: string;
  83323. };
  83324. }
  83325. declare module BABYLON {
  83326. /** @hidden */
  83327. export var gridVertexShader: {
  83328. name: string;
  83329. shader: string;
  83330. };
  83331. }
  83332. declare module BABYLON {
  83333. /**
  83334. * The grid materials allows you to wrap any shape with a grid.
  83335. * Colors are customizable.
  83336. */
  83337. export class GridMaterial extends BABYLON.PushMaterial {
  83338. /**
  83339. * Main color of the grid (e.g. between lines)
  83340. */
  83341. mainColor: BABYLON.Color3;
  83342. /**
  83343. * Color of the grid lines.
  83344. */
  83345. lineColor: BABYLON.Color3;
  83346. /**
  83347. * The scale of the grid compared to unit.
  83348. */
  83349. gridRatio: number;
  83350. /**
  83351. * Allows setting an offset for the grid lines.
  83352. */
  83353. gridOffset: BABYLON.Vector3;
  83354. /**
  83355. * The frequency of thicker lines.
  83356. */
  83357. majorUnitFrequency: number;
  83358. /**
  83359. * The visibility of minor units in the grid.
  83360. */
  83361. minorUnitVisibility: number;
  83362. /**
  83363. * The grid opacity outside of the lines.
  83364. */
  83365. opacity: number;
  83366. /**
  83367. * Determine RBG output is premultiplied by alpha value.
  83368. */
  83369. preMultiplyAlpha: boolean;
  83370. private _opacityTexture;
  83371. opacityTexture: BABYLON.BaseTexture;
  83372. private _gridControl;
  83373. /**
  83374. * constructor
  83375. * @param name The name given to the material in order to identify it afterwards.
  83376. * @param scene The scene the material is used in.
  83377. */
  83378. constructor(name: string, scene: BABYLON.Scene);
  83379. /**
  83380. * Returns wehter or not the grid requires alpha blending.
  83381. */
  83382. needAlphaBlending(): boolean;
  83383. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83384. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83385. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83386. /**
  83387. * Dispose the material and its associated resources.
  83388. * @param forceDisposeEffect will also dispose the used effect when true
  83389. */
  83390. dispose(forceDisposeEffect?: boolean): void;
  83391. clone(name: string): GridMaterial;
  83392. serialize(): any;
  83393. getClassName(): string;
  83394. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  83395. }
  83396. }
  83397. declare module BABYLON {
  83398. /** @hidden */
  83399. export var lavaPixelShader: {
  83400. name: string;
  83401. shader: string;
  83402. };
  83403. }
  83404. declare module BABYLON {
  83405. /** @hidden */
  83406. export var lavaVertexShader: {
  83407. name: string;
  83408. shader: string;
  83409. };
  83410. }
  83411. declare module BABYLON {
  83412. export class LavaMaterial extends BABYLON.PushMaterial {
  83413. private _diffuseTexture;
  83414. diffuseTexture: BABYLON.BaseTexture;
  83415. noiseTexture: BABYLON.BaseTexture;
  83416. fogColor: BABYLON.Color3;
  83417. speed: number;
  83418. movingSpeed: number;
  83419. lowFrequencySpeed: number;
  83420. fogDensity: number;
  83421. private _lastTime;
  83422. diffuseColor: BABYLON.Color3;
  83423. private _disableLighting;
  83424. disableLighting: boolean;
  83425. private _unlit;
  83426. unlit: boolean;
  83427. private _maxSimultaneousLights;
  83428. maxSimultaneousLights: number;
  83429. private _scaledDiffuse;
  83430. constructor(name: string, scene: BABYLON.Scene);
  83431. needAlphaBlending(): boolean;
  83432. needAlphaTesting(): boolean;
  83433. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83434. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83435. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83436. getAnimatables(): BABYLON.IAnimatable[];
  83437. getActiveTextures(): BABYLON.BaseTexture[];
  83438. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83439. dispose(forceDisposeEffect?: boolean): void;
  83440. clone(name: string): LavaMaterial;
  83441. serialize(): any;
  83442. getClassName(): string;
  83443. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  83444. }
  83445. }
  83446. declare module BABYLON {
  83447. /** @hidden */
  83448. export var mixPixelShader: {
  83449. name: string;
  83450. shader: string;
  83451. };
  83452. }
  83453. declare module BABYLON {
  83454. /** @hidden */
  83455. export var mixVertexShader: {
  83456. name: string;
  83457. shader: string;
  83458. };
  83459. }
  83460. declare module BABYLON {
  83461. export class MixMaterial extends BABYLON.PushMaterial {
  83462. /**
  83463. * Mix textures
  83464. */
  83465. private _mixTexture1;
  83466. mixTexture1: BABYLON.BaseTexture;
  83467. private _mixTexture2;
  83468. mixTexture2: BABYLON.BaseTexture;
  83469. /**
  83470. * Diffuse textures
  83471. */
  83472. private _diffuseTexture1;
  83473. diffuseTexture1: BABYLON.Texture;
  83474. private _diffuseTexture2;
  83475. diffuseTexture2: BABYLON.Texture;
  83476. private _diffuseTexture3;
  83477. diffuseTexture3: BABYLON.Texture;
  83478. private _diffuseTexture4;
  83479. diffuseTexture4: BABYLON.Texture;
  83480. private _diffuseTexture5;
  83481. diffuseTexture5: BABYLON.Texture;
  83482. private _diffuseTexture6;
  83483. diffuseTexture6: BABYLON.Texture;
  83484. private _diffuseTexture7;
  83485. diffuseTexture7: BABYLON.Texture;
  83486. private _diffuseTexture8;
  83487. diffuseTexture8: BABYLON.Texture;
  83488. /**
  83489. * Uniforms
  83490. */
  83491. diffuseColor: BABYLON.Color3;
  83492. specularColor: BABYLON.Color3;
  83493. specularPower: number;
  83494. private _disableLighting;
  83495. disableLighting: boolean;
  83496. private _maxSimultaneousLights;
  83497. maxSimultaneousLights: number;
  83498. constructor(name: string, scene: BABYLON.Scene);
  83499. needAlphaBlending(): boolean;
  83500. needAlphaTesting(): boolean;
  83501. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83502. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83503. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83504. getAnimatables(): BABYLON.IAnimatable[];
  83505. getActiveTextures(): BABYLON.BaseTexture[];
  83506. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83507. dispose(forceDisposeEffect?: boolean): void;
  83508. clone(name: string): MixMaterial;
  83509. serialize(): any;
  83510. getClassName(): string;
  83511. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  83512. }
  83513. }
  83514. declare module BABYLON {
  83515. /** @hidden */
  83516. export var normalPixelShader: {
  83517. name: string;
  83518. shader: string;
  83519. };
  83520. }
  83521. declare module BABYLON {
  83522. /** @hidden */
  83523. export var normalVertexShader: {
  83524. name: string;
  83525. shader: string;
  83526. };
  83527. }
  83528. declare module BABYLON {
  83529. export class NormalMaterial extends BABYLON.PushMaterial {
  83530. private _diffuseTexture;
  83531. diffuseTexture: BABYLON.BaseTexture;
  83532. diffuseColor: BABYLON.Color3;
  83533. private _disableLighting;
  83534. disableLighting: boolean;
  83535. private _maxSimultaneousLights;
  83536. maxSimultaneousLights: number;
  83537. constructor(name: string, scene: BABYLON.Scene);
  83538. needAlphaBlending(): boolean;
  83539. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83540. needAlphaTesting(): boolean;
  83541. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83542. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83543. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83544. getAnimatables(): BABYLON.IAnimatable[];
  83545. getActiveTextures(): BABYLON.BaseTexture[];
  83546. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83547. dispose(forceDisposeEffect?: boolean): void;
  83548. clone(name: string): NormalMaterial;
  83549. serialize(): any;
  83550. getClassName(): string;
  83551. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  83552. }
  83553. }
  83554. declare module BABYLON {
  83555. /** @hidden */
  83556. export var shadowOnlyPixelShader: {
  83557. name: string;
  83558. shader: string;
  83559. };
  83560. }
  83561. declare module BABYLON {
  83562. /** @hidden */
  83563. export var shadowOnlyVertexShader: {
  83564. name: string;
  83565. shader: string;
  83566. };
  83567. }
  83568. declare module BABYLON {
  83569. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  83570. private _activeLight;
  83571. private _needAlphaBlending;
  83572. constructor(name: string, scene: BABYLON.Scene);
  83573. shadowColor: BABYLON.Color3;
  83574. needAlphaBlending(): boolean;
  83575. needAlphaTesting(): boolean;
  83576. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83577. get activeLight(): BABYLON.IShadowLight;
  83578. set activeLight(light: BABYLON.IShadowLight);
  83579. private _getFirstShadowLightForMesh;
  83580. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83581. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83582. clone(name: string): ShadowOnlyMaterial;
  83583. serialize(): any;
  83584. getClassName(): string;
  83585. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  83586. }
  83587. }
  83588. declare module BABYLON {
  83589. /** @hidden */
  83590. export var simplePixelShader: {
  83591. name: string;
  83592. shader: string;
  83593. };
  83594. }
  83595. declare module BABYLON {
  83596. /** @hidden */
  83597. export var simpleVertexShader: {
  83598. name: string;
  83599. shader: string;
  83600. };
  83601. }
  83602. declare module BABYLON {
  83603. export class SimpleMaterial extends BABYLON.PushMaterial {
  83604. private _diffuseTexture;
  83605. diffuseTexture: BABYLON.BaseTexture;
  83606. diffuseColor: BABYLON.Color3;
  83607. private _disableLighting;
  83608. disableLighting: boolean;
  83609. private _maxSimultaneousLights;
  83610. maxSimultaneousLights: number;
  83611. constructor(name: string, scene: BABYLON.Scene);
  83612. needAlphaBlending(): boolean;
  83613. needAlphaTesting(): boolean;
  83614. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83615. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83616. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83617. getAnimatables(): BABYLON.IAnimatable[];
  83618. getActiveTextures(): BABYLON.BaseTexture[];
  83619. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83620. dispose(forceDisposeEffect?: boolean): void;
  83621. clone(name: string): SimpleMaterial;
  83622. serialize(): any;
  83623. getClassName(): string;
  83624. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  83625. }
  83626. }
  83627. declare module BABYLON {
  83628. /** @hidden */
  83629. export var skyPixelShader: {
  83630. name: string;
  83631. shader: string;
  83632. };
  83633. }
  83634. declare module BABYLON {
  83635. /** @hidden */
  83636. export var skyVertexShader: {
  83637. name: string;
  83638. shader: string;
  83639. };
  83640. }
  83641. declare module BABYLON {
  83642. /**
  83643. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  83644. * @see https://doc.babylonjs.com/extensions/sky
  83645. */
  83646. export class SkyMaterial extends BABYLON.PushMaterial {
  83647. /**
  83648. * Defines the overall luminance of sky in interval ]0, 1[.
  83649. */
  83650. luminance: number;
  83651. /**
  83652. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  83653. */
  83654. turbidity: number;
  83655. /**
  83656. * Defines the sky appearance (light intensity).
  83657. */
  83658. rayleigh: number;
  83659. /**
  83660. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  83661. */
  83662. mieCoefficient: number;
  83663. /**
  83664. * Defines the amount of haze particles following the Mie scattering theory.
  83665. */
  83666. mieDirectionalG: number;
  83667. /**
  83668. * Defines the distance of the sun according to the active scene camera.
  83669. */
  83670. distance: number;
  83671. /**
  83672. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  83673. * "inclined".
  83674. */
  83675. inclination: number;
  83676. /**
  83677. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  83678. * an object direction and a reference direction.
  83679. */
  83680. azimuth: number;
  83681. /**
  83682. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  83683. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  83684. */
  83685. sunPosition: BABYLON.Vector3;
  83686. /**
  83687. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  83688. * .sunPosition property.
  83689. */
  83690. useSunPosition: boolean;
  83691. /**
  83692. * Defines an offset vector used to get a horizon offset.
  83693. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  83694. */
  83695. cameraOffset: BABYLON.Vector3;
  83696. private _cameraPosition;
  83697. /**
  83698. * Instantiates a new sky material.
  83699. * This material allows to create dynamic and texture free
  83700. * effects for skyboxes by taking care of the atmosphere state.
  83701. * @see https://doc.babylonjs.com/extensions/sky
  83702. * @param name Define the name of the material in the scene
  83703. * @param scene Define the scene the material belong to
  83704. */
  83705. constructor(name: string, scene: BABYLON.Scene);
  83706. /**
  83707. * Specifies if the material will require alpha blending
  83708. * @returns a boolean specifying if alpha blending is needed
  83709. */
  83710. needAlphaBlending(): boolean;
  83711. /**
  83712. * Specifies if this material should be rendered in alpha test mode
  83713. * @returns false as the sky material doesn't need alpha testing.
  83714. */
  83715. needAlphaTesting(): boolean;
  83716. /**
  83717. * Get the texture used for alpha test purpose.
  83718. * @returns null as the sky material has no texture.
  83719. */
  83720. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83721. /**
  83722. * Get if the submesh is ready to be used and all its information available.
  83723. * Child classes can use it to update shaders
  83724. * @param mesh defines the mesh to check
  83725. * @param subMesh defines which submesh to check
  83726. * @param useInstances specifies that instances should be used
  83727. * @returns a boolean indicating that the submesh is ready or not
  83728. */
  83729. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83730. /**
  83731. * Binds the submesh to this material by preparing the effect and shader to draw
  83732. * @param world defines the world transformation matrix
  83733. * @param mesh defines the mesh containing the submesh
  83734. * @param subMesh defines the submesh to bind the material to
  83735. */
  83736. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83737. /**
  83738. * Get the list of animatables in the material.
  83739. * @returns the list of animatables object used in the material
  83740. */
  83741. getAnimatables(): BABYLON.IAnimatable[];
  83742. /**
  83743. * Disposes the material
  83744. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83745. */
  83746. dispose(forceDisposeEffect?: boolean): void;
  83747. /**
  83748. * Makes a duplicate of the material, and gives it a new name
  83749. * @param name defines the new name for the duplicated material
  83750. * @returns the cloned material
  83751. */
  83752. clone(name: string): SkyMaterial;
  83753. /**
  83754. * Serializes this material in a JSON representation
  83755. * @returns the serialized material object
  83756. */
  83757. serialize(): any;
  83758. /**
  83759. * Gets the current class name of the material e.g. "SkyMaterial"
  83760. * Mainly use in serialization.
  83761. * @returns the class name
  83762. */
  83763. getClassName(): string;
  83764. /**
  83765. * Creates a sky material from parsed material data
  83766. * @param source defines the JSON representation of the material
  83767. * @param scene defines the hosting scene
  83768. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83769. * @returns a new sky material
  83770. */
  83771. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  83772. }
  83773. }
  83774. declare module BABYLON {
  83775. /** @hidden */
  83776. export var terrainPixelShader: {
  83777. name: string;
  83778. shader: string;
  83779. };
  83780. }
  83781. declare module BABYLON {
  83782. /** @hidden */
  83783. export var terrainVertexShader: {
  83784. name: string;
  83785. shader: string;
  83786. };
  83787. }
  83788. declare module BABYLON {
  83789. export class TerrainMaterial extends BABYLON.PushMaterial {
  83790. private _mixTexture;
  83791. mixTexture: BABYLON.BaseTexture;
  83792. private _diffuseTexture1;
  83793. diffuseTexture1: BABYLON.Texture;
  83794. private _diffuseTexture2;
  83795. diffuseTexture2: BABYLON.Texture;
  83796. private _diffuseTexture3;
  83797. diffuseTexture3: BABYLON.Texture;
  83798. private _bumpTexture1;
  83799. bumpTexture1: BABYLON.Texture;
  83800. private _bumpTexture2;
  83801. bumpTexture2: BABYLON.Texture;
  83802. private _bumpTexture3;
  83803. bumpTexture3: BABYLON.Texture;
  83804. diffuseColor: BABYLON.Color3;
  83805. specularColor: BABYLON.Color3;
  83806. specularPower: number;
  83807. private _disableLighting;
  83808. disableLighting: boolean;
  83809. private _maxSimultaneousLights;
  83810. maxSimultaneousLights: number;
  83811. constructor(name: string, scene: BABYLON.Scene);
  83812. needAlphaBlending(): boolean;
  83813. needAlphaTesting(): boolean;
  83814. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83815. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83816. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83817. getAnimatables(): BABYLON.IAnimatable[];
  83818. getActiveTextures(): BABYLON.BaseTexture[];
  83819. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83820. dispose(forceDisposeEffect?: boolean): void;
  83821. clone(name: string): TerrainMaterial;
  83822. serialize(): any;
  83823. getClassName(): string;
  83824. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  83825. }
  83826. }
  83827. declare module BABYLON {
  83828. /** @hidden */
  83829. export var triplanarPixelShader: {
  83830. name: string;
  83831. shader: string;
  83832. };
  83833. }
  83834. declare module BABYLON {
  83835. /** @hidden */
  83836. export var triplanarVertexShader: {
  83837. name: string;
  83838. shader: string;
  83839. };
  83840. }
  83841. declare module BABYLON {
  83842. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  83843. mixTexture: BABYLON.BaseTexture;
  83844. private _diffuseTextureX;
  83845. diffuseTextureX: BABYLON.BaseTexture;
  83846. private _diffuseTextureY;
  83847. diffuseTextureY: BABYLON.BaseTexture;
  83848. private _diffuseTextureZ;
  83849. diffuseTextureZ: BABYLON.BaseTexture;
  83850. private _normalTextureX;
  83851. normalTextureX: BABYLON.BaseTexture;
  83852. private _normalTextureY;
  83853. normalTextureY: BABYLON.BaseTexture;
  83854. private _normalTextureZ;
  83855. normalTextureZ: BABYLON.BaseTexture;
  83856. tileSize: number;
  83857. diffuseColor: BABYLON.Color3;
  83858. specularColor: BABYLON.Color3;
  83859. specularPower: number;
  83860. private _disableLighting;
  83861. disableLighting: boolean;
  83862. private _maxSimultaneousLights;
  83863. maxSimultaneousLights: number;
  83864. constructor(name: string, scene: BABYLON.Scene);
  83865. needAlphaBlending(): boolean;
  83866. needAlphaTesting(): boolean;
  83867. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83868. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83869. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83870. getAnimatables(): BABYLON.IAnimatable[];
  83871. getActiveTextures(): BABYLON.BaseTexture[];
  83872. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83873. dispose(forceDisposeEffect?: boolean): void;
  83874. clone(name: string): TriPlanarMaterial;
  83875. serialize(): any;
  83876. getClassName(): string;
  83877. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83878. }
  83879. }
  83880. declare module BABYLON {
  83881. /** @hidden */
  83882. export var waterPixelShader: {
  83883. name: string;
  83884. shader: string;
  83885. };
  83886. }
  83887. declare module BABYLON {
  83888. /** @hidden */
  83889. export var waterVertexShader: {
  83890. name: string;
  83891. shader: string;
  83892. };
  83893. }
  83894. declare module BABYLON {
  83895. export class WaterMaterial extends BABYLON.PushMaterial {
  83896. renderTargetSize: BABYLON.Vector2;
  83897. private _bumpTexture;
  83898. bumpTexture: BABYLON.BaseTexture;
  83899. diffuseColor: BABYLON.Color3;
  83900. specularColor: BABYLON.Color3;
  83901. specularPower: number;
  83902. private _disableLighting;
  83903. disableLighting: boolean;
  83904. private _maxSimultaneousLights;
  83905. maxSimultaneousLights: number;
  83906. /**
  83907. * @param {number}: Represents the wind force
  83908. */
  83909. windForce: number;
  83910. /**
  83911. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83912. */
  83913. windDirection: BABYLON.Vector2;
  83914. /**
  83915. * @param {number}: Wave height, represents the height of the waves
  83916. */
  83917. waveHeight: number;
  83918. /**
  83919. * @param {number}: Bump height, represents the bump height related to the bump map
  83920. */
  83921. bumpHeight: number;
  83922. /**
  83923. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83924. */
  83925. private _bumpSuperimpose;
  83926. bumpSuperimpose: boolean;
  83927. /**
  83928. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83929. */
  83930. private _fresnelSeparate;
  83931. fresnelSeparate: boolean;
  83932. /**
  83933. * @param {boolean}: bump Waves modify the reflection.
  83934. */
  83935. private _bumpAffectsReflection;
  83936. bumpAffectsReflection: boolean;
  83937. /**
  83938. * @param {number}: The water color blended with the refraction (near)
  83939. */
  83940. waterColor: BABYLON.Color3;
  83941. /**
  83942. * @param {number}: The blend factor related to the water color
  83943. */
  83944. colorBlendFactor: number;
  83945. /**
  83946. * @param {number}: The water color blended with the reflection (far)
  83947. */
  83948. waterColor2: BABYLON.Color3;
  83949. /**
  83950. * @param {number}: The blend factor related to the water color (reflection, far)
  83951. */
  83952. colorBlendFactor2: number;
  83953. /**
  83954. * @param {number}: Represents the maximum length of a wave
  83955. */
  83956. waveLength: number;
  83957. /**
  83958. * @param {number}: Defines the waves speed
  83959. */
  83960. waveSpeed: number;
  83961. /**
  83962. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83963. * will avoid calculating useless pixels in the pixel shader of the water material.
  83964. */
  83965. disableClipPlane: boolean;
  83966. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83967. private _mesh;
  83968. private _refractionRTT;
  83969. private _reflectionRTT;
  83970. private _reflectionTransform;
  83971. private _lastTime;
  83972. private _lastDeltaTime;
  83973. private _useLogarithmicDepth;
  83974. private _waitingRenderList;
  83975. private _imageProcessingConfiguration;
  83976. private _imageProcessingObserver;
  83977. /**
  83978. * Gets a boolean indicating that current material needs to register RTT
  83979. */
  83980. get hasRenderTargetTextures(): boolean;
  83981. /**
  83982. * Constructor
  83983. */
  83984. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83985. get useLogarithmicDepth(): boolean;
  83986. set useLogarithmicDepth(value: boolean);
  83987. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83988. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83989. addToRenderList(node: any): void;
  83990. enableRenderTargets(enable: boolean): void;
  83991. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83992. get renderTargetsEnabled(): boolean;
  83993. needAlphaBlending(): boolean;
  83994. needAlphaTesting(): boolean;
  83995. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83996. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83997. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83998. private _createRenderTargets;
  83999. getAnimatables(): BABYLON.IAnimatable[];
  84000. getActiveTextures(): BABYLON.BaseTexture[];
  84001. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84002. dispose(forceDisposeEffect?: boolean): void;
  84003. clone(name: string): WaterMaterial;
  84004. serialize(): any;
  84005. getClassName(): string;
  84006. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  84007. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  84008. }
  84009. }
  84010. declare module BABYLON {
  84011. /** @hidden */
  84012. export var asciiartPixelShader: {
  84013. name: string;
  84014. shader: string;
  84015. };
  84016. }
  84017. declare module BABYLON {
  84018. /**
  84019. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  84020. *
  84021. * It basically takes care rendering the font front the given font size to a texture.
  84022. * This is used later on in the postprocess.
  84023. */
  84024. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  84025. private _font;
  84026. private _text;
  84027. private _charSize;
  84028. /**
  84029. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84030. */
  84031. get charSize(): number;
  84032. /**
  84033. * Create a new instance of the Ascii Art FontTexture class
  84034. * @param name the name of the texture
  84035. * @param font the font to use, use the W3C CSS notation
  84036. * @param text the caracter set to use in the rendering.
  84037. * @param scene the scene that owns the texture
  84038. */
  84039. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84040. /**
  84041. * Gets the max char width of a font.
  84042. * @param font the font to use, use the W3C CSS notation
  84043. * @return the max char width
  84044. */
  84045. private getFontWidth;
  84046. /**
  84047. * Gets the max char height of a font.
  84048. * @param font the font to use, use the W3C CSS notation
  84049. * @return the max char height
  84050. */
  84051. private getFontHeight;
  84052. /**
  84053. * Clones the current AsciiArtTexture.
  84054. * @return the clone of the texture.
  84055. */
  84056. clone(): AsciiArtFontTexture;
  84057. /**
  84058. * Parses a json object representing the texture and returns an instance of it.
  84059. * @param source the source JSON representation
  84060. * @param scene the scene to create the texture for
  84061. * @return the parsed texture
  84062. */
  84063. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  84064. }
  84065. /**
  84066. * Option available in the Ascii Art Post Process.
  84067. */
  84068. export interface IAsciiArtPostProcessOptions {
  84069. /**
  84070. * The font to use following the w3c font definition.
  84071. */
  84072. font?: string;
  84073. /**
  84074. * The character set to use in the postprocess.
  84075. */
  84076. characterSet?: string;
  84077. /**
  84078. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  84079. * This number is defined between 0 and 1;
  84080. */
  84081. mixToTile?: number;
  84082. /**
  84083. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  84084. * This number is defined between 0 and 1;
  84085. */
  84086. mixToNormal?: number;
  84087. }
  84088. /**
  84089. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  84090. *
  84091. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84092. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  84093. */
  84094. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  84095. /**
  84096. * The font texture used to render the char in the post process.
  84097. */
  84098. private _asciiArtFontTexture;
  84099. /**
  84100. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  84101. * This number is defined between 0 and 1;
  84102. */
  84103. mixToTile: number;
  84104. /**
  84105. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  84106. * This number is defined between 0 and 1;
  84107. */
  84108. mixToNormal: number;
  84109. /**
  84110. * Instantiates a new Ascii Art Post Process.
  84111. * @param name the name to give to the postprocess
  84112. * @camera the camera to apply the post process to.
  84113. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  84114. */
  84115. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  84116. }
  84117. }
  84118. declare module BABYLON {
  84119. /** @hidden */
  84120. export var digitalrainPixelShader: {
  84121. name: string;
  84122. shader: string;
  84123. };
  84124. }
  84125. declare module BABYLON {
  84126. /**
  84127. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  84128. *
  84129. * It basically takes care rendering the font front the given font size to a texture.
  84130. * This is used later on in the postprocess.
  84131. */
  84132. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  84133. private _font;
  84134. private _text;
  84135. private _charSize;
  84136. /**
  84137. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84138. */
  84139. get charSize(): number;
  84140. /**
  84141. * Create a new instance of the Digital Rain FontTexture class
  84142. * @param name the name of the texture
  84143. * @param font the font to use, use the W3C CSS notation
  84144. * @param text the caracter set to use in the rendering.
  84145. * @param scene the scene that owns the texture
  84146. */
  84147. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84148. /**
  84149. * Gets the max char width of a font.
  84150. * @param font the font to use, use the W3C CSS notation
  84151. * @return the max char width
  84152. */
  84153. private getFontWidth;
  84154. /**
  84155. * Gets the max char height of a font.
  84156. * @param font the font to use, use the W3C CSS notation
  84157. * @return the max char height
  84158. */
  84159. private getFontHeight;
  84160. /**
  84161. * Clones the current DigitalRainFontTexture.
  84162. * @return the clone of the texture.
  84163. */
  84164. clone(): DigitalRainFontTexture;
  84165. /**
  84166. * Parses a json object representing the texture and returns an instance of it.
  84167. * @param source the source JSON representation
  84168. * @param scene the scene to create the texture for
  84169. * @return the parsed texture
  84170. */
  84171. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  84172. }
  84173. /**
  84174. * Option available in the Digital Rain Post Process.
  84175. */
  84176. export interface IDigitalRainPostProcessOptions {
  84177. /**
  84178. * The font to use following the w3c font definition.
  84179. */
  84180. font?: string;
  84181. /**
  84182. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84183. * This number is defined between 0 and 1;
  84184. */
  84185. mixToTile?: number;
  84186. /**
  84187. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84188. * This number is defined between 0 and 1;
  84189. */
  84190. mixToNormal?: number;
  84191. }
  84192. /**
  84193. * DigitalRainPostProcess helps rendering everithing in digital rain.
  84194. *
  84195. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84196. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  84197. */
  84198. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  84199. /**
  84200. * The font texture used to render the char in the post process.
  84201. */
  84202. private _digitalRainFontTexture;
  84203. /**
  84204. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84205. * This number is defined between 0 and 1;
  84206. */
  84207. mixToTile: number;
  84208. /**
  84209. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84210. * This number is defined between 0 and 1;
  84211. */
  84212. mixToNormal: number;
  84213. /**
  84214. * Instantiates a new Digital Rain Post Process.
  84215. * @param name the name to give to the postprocess
  84216. * @camera the camera to apply the post process to.
  84217. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  84218. */
  84219. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  84220. }
  84221. }
  84222. declare module BABYLON {
  84223. /** @hidden */
  84224. export var brickProceduralTexturePixelShader: {
  84225. name: string;
  84226. shader: string;
  84227. };
  84228. }
  84229. declare module BABYLON {
  84230. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  84231. private _numberOfBricksHeight;
  84232. private _numberOfBricksWidth;
  84233. private _jointColor;
  84234. private _brickColor;
  84235. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84236. updateShaderUniforms(): void;
  84237. get numberOfBricksHeight(): number;
  84238. set numberOfBricksHeight(value: number);
  84239. get numberOfBricksWidth(): number;
  84240. set numberOfBricksWidth(value: number);
  84241. get jointColor(): BABYLON.Color3;
  84242. set jointColor(value: BABYLON.Color3);
  84243. get brickColor(): BABYLON.Color3;
  84244. set brickColor(value: BABYLON.Color3);
  84245. /**
  84246. * Serializes this brick procedural texture
  84247. * @returns a serialized brick procedural texture object
  84248. */
  84249. serialize(): any;
  84250. /**
  84251. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  84252. * @param parsedTexture defines parsed texture data
  84253. * @param scene defines the current scene
  84254. * @param rootUrl defines the root URL containing brick procedural texture information
  84255. * @returns a parsed Brick Procedural BABYLON.Texture
  84256. */
  84257. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  84258. }
  84259. }
  84260. declare module BABYLON {
  84261. /** @hidden */
  84262. export var cloudProceduralTexturePixelShader: {
  84263. name: string;
  84264. shader: string;
  84265. };
  84266. }
  84267. declare module BABYLON {
  84268. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  84269. private _skyColor;
  84270. private _cloudColor;
  84271. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84272. updateShaderUniforms(): void;
  84273. get skyColor(): BABYLON.Color4;
  84274. set skyColor(value: BABYLON.Color4);
  84275. get cloudColor(): BABYLON.Color4;
  84276. set cloudColor(value: BABYLON.Color4);
  84277. /**
  84278. * Serializes this cloud procedural texture
  84279. * @returns a serialized cloud procedural texture object
  84280. */
  84281. serialize(): any;
  84282. /**
  84283. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  84284. * @param parsedTexture defines parsed texture data
  84285. * @param scene defines the current scene
  84286. * @param rootUrl defines the root URL containing cloud procedural texture information
  84287. * @returns a parsed Cloud Procedural BABYLON.Texture
  84288. */
  84289. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  84290. }
  84291. }
  84292. declare module BABYLON {
  84293. /** @hidden */
  84294. export var fireProceduralTexturePixelShader: {
  84295. name: string;
  84296. shader: string;
  84297. };
  84298. }
  84299. declare module BABYLON {
  84300. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  84301. private _time;
  84302. private _speed;
  84303. private _autoGenerateTime;
  84304. private _fireColors;
  84305. private _alphaThreshold;
  84306. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84307. updateShaderUniforms(): void;
  84308. render(useCameraPostProcess?: boolean): void;
  84309. static get PurpleFireColors(): BABYLON.Color3[];
  84310. static get GreenFireColors(): BABYLON.Color3[];
  84311. static get RedFireColors(): BABYLON.Color3[];
  84312. static get BlueFireColors(): BABYLON.Color3[];
  84313. get autoGenerateTime(): boolean;
  84314. set autoGenerateTime(value: boolean);
  84315. get fireColors(): BABYLON.Color3[];
  84316. set fireColors(value: BABYLON.Color3[]);
  84317. get time(): number;
  84318. set time(value: number);
  84319. get speed(): BABYLON.Vector2;
  84320. set speed(value: BABYLON.Vector2);
  84321. get alphaThreshold(): number;
  84322. set alphaThreshold(value: number);
  84323. /**
  84324. * Serializes this fire procedural texture
  84325. * @returns a serialized fire procedural texture object
  84326. */
  84327. serialize(): any;
  84328. /**
  84329. * Creates a Fire Procedural BABYLON.Texture from parsed fire 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 fire procedural texture information
  84333. * @returns a parsed Fire Procedural BABYLON.Texture
  84334. */
  84335. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  84336. }
  84337. }
  84338. declare module BABYLON {
  84339. /** @hidden */
  84340. export var grassProceduralTexturePixelShader: {
  84341. name: string;
  84342. shader: string;
  84343. };
  84344. }
  84345. declare module BABYLON {
  84346. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  84347. private _grassColors;
  84348. private _groundColor;
  84349. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84350. updateShaderUniforms(): void;
  84351. get grassColors(): BABYLON.Color3[];
  84352. set grassColors(value: BABYLON.Color3[]);
  84353. get groundColor(): BABYLON.Color3;
  84354. set groundColor(value: BABYLON.Color3);
  84355. /**
  84356. * Serializes this grass procedural texture
  84357. * @returns a serialized grass procedural texture object
  84358. */
  84359. serialize(): any;
  84360. /**
  84361. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  84362. * @param parsedTexture defines parsed texture data
  84363. * @param scene defines the current scene
  84364. * @param rootUrl defines the root URL containing grass procedural texture information
  84365. * @returns a parsed Grass Procedural BABYLON.Texture
  84366. */
  84367. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  84368. }
  84369. }
  84370. declare module BABYLON {
  84371. /** @hidden */
  84372. export var marbleProceduralTexturePixelShader: {
  84373. name: string;
  84374. shader: string;
  84375. };
  84376. }
  84377. declare module BABYLON {
  84378. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  84379. private _numberOfTilesHeight;
  84380. private _numberOfTilesWidth;
  84381. private _amplitude;
  84382. private _jointColor;
  84383. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84384. updateShaderUniforms(): void;
  84385. get numberOfTilesHeight(): number;
  84386. set numberOfTilesHeight(value: number);
  84387. get amplitude(): number;
  84388. set amplitude(value: number);
  84389. get numberOfTilesWidth(): number;
  84390. set numberOfTilesWidth(value: number);
  84391. get jointColor(): BABYLON.Color3;
  84392. set jointColor(value: BABYLON.Color3);
  84393. /**
  84394. * Serializes this marble procedural texture
  84395. * @returns a serialized marble procedural texture object
  84396. */
  84397. serialize(): any;
  84398. /**
  84399. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  84400. * @param parsedTexture defines parsed texture data
  84401. * @param scene defines the current scene
  84402. * @param rootUrl defines the root URL containing marble procedural texture information
  84403. * @returns a parsed Marble Procedural BABYLON.Texture
  84404. */
  84405. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  84406. }
  84407. }
  84408. declare module BABYLON {
  84409. /** @hidden */
  84410. export var normalMapProceduralTexturePixelShader: {
  84411. name: string;
  84412. shader: string;
  84413. };
  84414. }
  84415. declare module BABYLON {
  84416. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  84417. private _baseTexture;
  84418. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84419. updateShaderUniforms(): void;
  84420. render(useCameraPostProcess?: boolean): void;
  84421. resize(size: any, generateMipMaps: any): void;
  84422. get baseTexture(): BABYLON.Texture;
  84423. set baseTexture(texture: BABYLON.Texture);
  84424. /**
  84425. * Serializes this normal map procedural texture
  84426. * @returns a serialized normal map procedural texture object
  84427. */
  84428. serialize(): any;
  84429. /**
  84430. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  84431. * @param parsedTexture defines parsed texture data
  84432. * @param scene defines the current scene
  84433. * @param rootUrl defines the root URL containing normal map procedural texture information
  84434. * @returns a parsed Normal Map Procedural BABYLON.Texture
  84435. */
  84436. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  84437. }
  84438. }
  84439. declare module BABYLON {
  84440. /** @hidden */
  84441. export var perlinNoiseProceduralTexturePixelShader: {
  84442. name: string;
  84443. shader: string;
  84444. };
  84445. }
  84446. declare module BABYLON {
  84447. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  84448. time: number;
  84449. timeScale: number;
  84450. translationSpeed: number;
  84451. private _currentTranslation;
  84452. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84453. updateShaderUniforms(): void;
  84454. render(useCameraPostProcess?: boolean): void;
  84455. resize(size: any, generateMipMaps: any): void;
  84456. /**
  84457. * Serializes this perlin noise procedural texture
  84458. * @returns a serialized perlin noise procedural texture object
  84459. */
  84460. serialize(): any;
  84461. /**
  84462. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  84463. * @param parsedTexture defines parsed texture data
  84464. * @param scene defines the current scene
  84465. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  84466. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  84467. */
  84468. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  84469. }
  84470. }
  84471. declare module BABYLON {
  84472. /** @hidden */
  84473. export var roadProceduralTexturePixelShader: {
  84474. name: string;
  84475. shader: string;
  84476. };
  84477. }
  84478. declare module BABYLON {
  84479. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  84480. private _roadColor;
  84481. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84482. updateShaderUniforms(): void;
  84483. get roadColor(): BABYLON.Color3;
  84484. set roadColor(value: BABYLON.Color3);
  84485. /**
  84486. * Serializes this road procedural texture
  84487. * @returns a serialized road procedural texture object
  84488. */
  84489. serialize(): any;
  84490. /**
  84491. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  84492. * @param parsedTexture defines parsed texture data
  84493. * @param scene defines the current scene
  84494. * @param rootUrl defines the root URL containing road procedural texture information
  84495. * @returns a parsed Road Procedural BABYLON.Texture
  84496. */
  84497. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  84498. }
  84499. }
  84500. declare module BABYLON {
  84501. /** @hidden */
  84502. export var starfieldProceduralTexturePixelShader: {
  84503. name: string;
  84504. shader: string;
  84505. };
  84506. }
  84507. declare module BABYLON {
  84508. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  84509. private _time;
  84510. private _alpha;
  84511. private _beta;
  84512. private _zoom;
  84513. private _formuparam;
  84514. private _stepsize;
  84515. private _tile;
  84516. private _brightness;
  84517. private _darkmatter;
  84518. private _distfading;
  84519. private _saturation;
  84520. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84521. updateShaderUniforms(): void;
  84522. get time(): number;
  84523. set time(value: number);
  84524. get alpha(): number;
  84525. set alpha(value: number);
  84526. get beta(): number;
  84527. set beta(value: number);
  84528. get formuparam(): number;
  84529. set formuparam(value: number);
  84530. get stepsize(): number;
  84531. set stepsize(value: number);
  84532. get zoom(): number;
  84533. set zoom(value: number);
  84534. get tile(): number;
  84535. set tile(value: number);
  84536. get brightness(): number;
  84537. set brightness(value: number);
  84538. get darkmatter(): number;
  84539. set darkmatter(value: number);
  84540. get distfading(): number;
  84541. set distfading(value: number);
  84542. get saturation(): number;
  84543. set saturation(value: number);
  84544. /**
  84545. * Serializes this starfield procedural texture
  84546. * @returns a serialized starfield procedural texture object
  84547. */
  84548. serialize(): any;
  84549. /**
  84550. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  84551. * @param parsedTexture defines parsed texture data
  84552. * @param scene defines the current scene
  84553. * @param rootUrl defines the root URL containing startfield procedural texture information
  84554. * @returns a parsed Starfield Procedural BABYLON.Texture
  84555. */
  84556. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  84557. }
  84558. }
  84559. declare module BABYLON {
  84560. /** @hidden */
  84561. export var woodProceduralTexturePixelShader: {
  84562. name: string;
  84563. shader: string;
  84564. };
  84565. }
  84566. declare module BABYLON {
  84567. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  84568. private _ampScale;
  84569. private _woodColor;
  84570. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84571. updateShaderUniforms(): void;
  84572. get ampScale(): number;
  84573. set ampScale(value: number);
  84574. get woodColor(): BABYLON.Color3;
  84575. set woodColor(value: BABYLON.Color3);
  84576. /**
  84577. * Serializes this wood procedural texture
  84578. * @returns a serialized wood procedural texture object
  84579. */
  84580. serialize(): any;
  84581. /**
  84582. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  84583. * @param parsedTexture defines parsed texture data
  84584. * @param scene defines the current scene
  84585. * @param rootUrl defines the root URL containing wood procedural texture information
  84586. * @returns a parsed Wood Procedural BABYLON.Texture
  84587. */
  84588. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  84589. }
  84590. }