documentation.d.ts 3.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635
  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. readonly 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. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static readonly Now: number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. /**
  483. * Returns client's state
  484. */
  485. readonly readyState: number;
  486. /**
  487. * Returns client's status
  488. */
  489. readonly status: number;
  490. /**
  491. * Returns client's status as a text
  492. */
  493. readonly statusText: string;
  494. /**
  495. * Returns client's response
  496. */
  497. readonly response: any;
  498. /**
  499. * Returns client's response url
  500. */
  501. readonly responseURL: string;
  502. /**
  503. * Returns client's response as text
  504. */
  505. readonly responseText: string;
  506. /**
  507. * Gets or sets the expected response type
  508. */
  509. responseType: XMLHttpRequestResponseType;
  510. /** @hidden */
  511. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  512. /** @hidden */
  513. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  514. /**
  515. * Cancels any network activity
  516. */
  517. abort(): void;
  518. /**
  519. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  520. * @param body defines an optional request body
  521. */
  522. send(body?: Document | BodyInit | null): void;
  523. /**
  524. * Sets the request method, request URL
  525. * @param method defines the method to use (GET, POST, etc..)
  526. * @param url defines the url to connect with
  527. */
  528. open(method: string, url: string): void;
  529. /**
  530. * Sets the value of a request header.
  531. * @param name The name of the header whose value is to be set
  532. * @param value The value to set as the body of the header
  533. */
  534. setRequestHeader(name: string, value: string): void;
  535. /**
  536. * Get the string containing the text of a particular header's value.
  537. * @param name The name of the header
  538. * @returns The string containing the text of the given header name
  539. */
  540. getResponseHeader(name: string): Nullable<string>;
  541. }
  542. }
  543. declare module BABYLON {
  544. /**
  545. * File request interface
  546. */
  547. export interface IFileRequest {
  548. /**
  549. * Raised when the request is complete (success or error).
  550. */
  551. onCompleteObservable: Observable<IFileRequest>;
  552. /**
  553. * Aborts the request for a file.
  554. */
  555. abort: () => void;
  556. }
  557. }
  558. declare module BABYLON {
  559. /**
  560. * Define options used to create a render target texture
  561. */
  562. export class RenderTargetCreationOptions {
  563. /**
  564. * Specifies is mipmaps must be generated
  565. */
  566. generateMipMaps?: boolean;
  567. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  568. generateDepthBuffer?: boolean;
  569. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  570. generateStencilBuffer?: boolean;
  571. /** Defines texture type (int by default) */
  572. type?: number;
  573. /** Defines sampling mode (trilinear by default) */
  574. samplingMode?: number;
  575. /** Defines format (RGBA by default) */
  576. format?: number;
  577. }
  578. }
  579. declare module BABYLON {
  580. /**
  581. * @hidden
  582. **/
  583. export class _TimeToken {
  584. _startTimeQuery: Nullable<WebGLQuery>;
  585. _endTimeQuery: Nullable<WebGLQuery>;
  586. _timeElapsedQuery: Nullable<WebGLQuery>;
  587. _timeElapsedQueryEnded: boolean;
  588. }
  589. }
  590. declare module BABYLON {
  591. /** Defines the cross module used constants to avoid circular dependncies */
  592. export class Constants {
  593. /** Defines that alpha blending is disabled */
  594. static readonly ALPHA_DISABLE: number;
  595. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  596. static readonly ALPHA_ADD: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  598. static readonly ALPHA_COMBINE: number;
  599. /** Defines that alpha blending is DEST - SRC * DEST */
  600. static readonly ALPHA_SUBTRACT: number;
  601. /** Defines that alpha blending is SRC * DEST */
  602. static readonly ALPHA_MULTIPLY: number;
  603. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  604. static readonly ALPHA_MAXIMIZED: number;
  605. /** Defines that alpha blending is SRC + DEST */
  606. static readonly ALPHA_ONEONE: number;
  607. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  608. static readonly ALPHA_PREMULTIPLIED: number;
  609. /**
  610. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  611. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  612. */
  613. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  614. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  615. static readonly ALPHA_INTERPOLATE: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  618. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_SCREENMODE: number;
  621. /**
  622. * Defines that alpha blending is SRC + DST
  623. * Alpha will be set to SRC ALPHA + DST ALPHA
  624. */
  625. static readonly ALPHA_ONEONE_ONEONE: number;
  626. /**
  627. * Defines that alpha blending is SRC * DST ALPHA + DST
  628. * Alpha will be set to 0
  629. */
  630. static readonly ALPHA_ALPHATOCOLOR: number;
  631. /**
  632. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  633. */
  634. static readonly ALPHA_REVERSEONEMINUS: number;
  635. /**
  636. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  637. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  638. */
  639. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  640. /**
  641. * Defines that alpha blending is SRC + DST
  642. * Alpha will be set to SRC ALPHA
  643. */
  644. static readonly ALPHA_ONEONE_ONEZERO: number;
  645. /**
  646. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  647. * Alpha will be set to DST ALPHA
  648. */
  649. static readonly ALPHA_EXCLUSION: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** 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 */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** 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 */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** 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 */
  686. static readonly GEQUAL: number;
  687. /** 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 */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = nearest */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * 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.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * 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.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module BABYLON {
  1044. /**
  1045. * This represents the required contract to create a new type of texture loader.
  1046. */
  1047. export interface IInternalTextureLoader {
  1048. /**
  1049. * Defines wether the loader supports cascade loading the different faces.
  1050. */
  1051. supportCascades: boolean;
  1052. /**
  1053. * This returns if the loader support the current file information.
  1054. * @param extension defines the file extension of the file being loaded
  1055. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1056. * @param fallback defines the fallback internal texture if any
  1057. * @param isBase64 defines whether the texture is encoded as a base64
  1058. * @param isBuffer defines whether the texture data are stored as a buffer
  1059. * @returns true if the loader can load the specified file
  1060. */
  1061. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1062. /**
  1063. * Transform the url before loading if required.
  1064. * @param rootUrl the url of the texture
  1065. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1066. * @returns the transformed texture
  1067. */
  1068. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1069. /**
  1070. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1071. * @param rootUrl the url of the texture
  1072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1073. * @returns the fallback texture
  1074. */
  1075. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1076. /**
  1077. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param createPolynomials will be true if polynomials have been requested
  1081. * @param onLoad defines the callback to trigger once the texture is ready
  1082. * @param onError defines the callback to trigger in case of error
  1083. */
  1084. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1085. /**
  1086. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param callback defines the method to call once ready to upload
  1090. */
  1091. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1092. }
  1093. }
  1094. declare module BABYLON {
  1095. /**
  1096. * Class used to store and describe the pipeline context associated with an effect
  1097. */
  1098. export interface IPipelineContext {
  1099. /**
  1100. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1101. */
  1102. isAsync: boolean;
  1103. /**
  1104. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1105. */
  1106. isReady: boolean;
  1107. /** @hidden */
  1108. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1109. }
  1110. }
  1111. declare module BABYLON {
  1112. /**
  1113. * Class used to store gfx data (like WebGLBuffer)
  1114. */
  1115. export class DataBuffer {
  1116. /**
  1117. * Gets or sets the number of objects referencing this buffer
  1118. */
  1119. references: number;
  1120. /** Gets or sets the size of the underlying buffer */
  1121. capacity: number;
  1122. /**
  1123. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1124. */
  1125. is32Bits: boolean;
  1126. /**
  1127. * Gets the underlying buffer
  1128. */
  1129. readonly underlyingResource: any;
  1130. }
  1131. }
  1132. declare module BABYLON {
  1133. /** @hidden */
  1134. export interface IShaderProcessor {
  1135. attributeProcessor?: (attribute: string) => string;
  1136. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1137. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1138. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1139. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1140. lineProcessor?: (line: string, isFragment: boolean) => string;
  1141. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1142. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1143. }
  1144. }
  1145. declare module BABYLON {
  1146. /** @hidden */
  1147. export interface ProcessingOptions {
  1148. defines: string[];
  1149. indexParameters: any;
  1150. isFragment: boolean;
  1151. shouldUseHighPrecisionShader: boolean;
  1152. supportsUniformBuffers: boolean;
  1153. shadersRepository: string;
  1154. includesShadersStore: {
  1155. [key: string]: string;
  1156. };
  1157. processor?: IShaderProcessor;
  1158. version: string;
  1159. platformName: string;
  1160. lookForClosingBracketForUniformBuffer?: boolean;
  1161. }
  1162. }
  1163. declare module BABYLON {
  1164. /** @hidden */
  1165. export class ShaderCodeNode {
  1166. line: string;
  1167. children: ShaderCodeNode[];
  1168. additionalDefineKey?: string;
  1169. additionalDefineValue?: string;
  1170. isValid(preprocessors: {
  1171. [key: string]: string;
  1172. }): boolean;
  1173. process(preprocessors: {
  1174. [key: string]: string;
  1175. }, options: ProcessingOptions): string;
  1176. }
  1177. }
  1178. declare module BABYLON {
  1179. /** @hidden */
  1180. export class ShaderCodeCursor {
  1181. private _lines;
  1182. lineIndex: number;
  1183. readonly currentLine: string;
  1184. readonly canRead: boolean;
  1185. lines: string[];
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1191. process(preprocessors: {
  1192. [key: string]: string;
  1193. }, options: ProcessingOptions): string;
  1194. }
  1195. }
  1196. declare module BABYLON {
  1197. /** @hidden */
  1198. export class ShaderDefineExpression {
  1199. isTrue(preprocessors: {
  1200. [key: string]: string;
  1201. }): boolean;
  1202. }
  1203. }
  1204. declare module BABYLON {
  1205. /** @hidden */
  1206. export class ShaderCodeTestNode extends ShaderCodeNode {
  1207. testExpression: ShaderDefineExpression;
  1208. isValid(preprocessors: {
  1209. [key: string]: string;
  1210. }): boolean;
  1211. }
  1212. }
  1213. declare module BABYLON {
  1214. /** @hidden */
  1215. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1216. define: string;
  1217. not: boolean;
  1218. constructor(define: string, not?: boolean);
  1219. isTrue(preprocessors: {
  1220. [key: string]: string;
  1221. }): boolean;
  1222. }
  1223. }
  1224. declare module BABYLON {
  1225. /** @hidden */
  1226. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1227. leftOperand: ShaderDefineExpression;
  1228. rightOperand: ShaderDefineExpression;
  1229. isTrue(preprocessors: {
  1230. [key: string]: string;
  1231. }): boolean;
  1232. }
  1233. }
  1234. declare module BABYLON {
  1235. /** @hidden */
  1236. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module BABYLON {
  1245. /** @hidden */
  1246. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. operand: string;
  1249. testValue: string;
  1250. constructor(define: string, operand: string, testValue: string);
  1251. isTrue(preprocessors: {
  1252. [key: string]: string;
  1253. }): boolean;
  1254. }
  1255. }
  1256. declare module BABYLON {
  1257. /**
  1258. * Class used to enable access to offline support
  1259. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1260. */
  1261. export interface IOfflineProvider {
  1262. /**
  1263. * Gets a boolean indicating if scene must be saved in the database
  1264. */
  1265. enableSceneOffline: boolean;
  1266. /**
  1267. * Gets a boolean indicating if textures must be saved in the database
  1268. */
  1269. enableTexturesOffline: boolean;
  1270. /**
  1271. * Open the offline support and make it available
  1272. * @param successCallback defines the callback to call on success
  1273. * @param errorCallback defines the callback to call on error
  1274. */
  1275. open(successCallback: () => void, errorCallback: () => void): void;
  1276. /**
  1277. * Loads an image from the offline support
  1278. * @param url defines the url to load from
  1279. * @param image defines the target DOM image
  1280. */
  1281. loadImage(url: string, image: HTMLImageElement): void;
  1282. /**
  1283. * Loads a file from offline support
  1284. * @param url defines the URL to load from
  1285. * @param sceneLoaded defines a callback to call on success
  1286. * @param progressCallBack defines a callback to call when progress changed
  1287. * @param errorCallback defines a callback to call on error
  1288. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1289. */
  1290. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /**
  1295. * Class used to help managing file picking and drag'n'drop
  1296. * File Storage
  1297. */
  1298. export class FilesInputStore {
  1299. /**
  1300. * List of files ready to be loaded
  1301. */
  1302. static FilesToLoad: {
  1303. [key: string]: File;
  1304. };
  1305. }
  1306. }
  1307. declare module BABYLON {
  1308. /**
  1309. * Class used to define a retry strategy when error happens while loading assets
  1310. */
  1311. export class RetryStrategy {
  1312. /**
  1313. * Function used to defines an exponential back off strategy
  1314. * @param maxRetries defines the maximum number of retries (3 by default)
  1315. * @param baseInterval defines the interval between retries
  1316. * @returns the strategy function to use
  1317. */
  1318. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1319. }
  1320. }
  1321. declare module BABYLON {
  1322. /**
  1323. * @ignore
  1324. * Application error to support additional information when loading a file
  1325. */
  1326. export abstract class BaseError extends Error {
  1327. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1328. }
  1329. }
  1330. declare module BABYLON {
  1331. /** @ignore */
  1332. export class LoadFileError extends BaseError {
  1333. request?: WebRequest;
  1334. file?: File;
  1335. /**
  1336. * Creates a new LoadFileError
  1337. * @param message defines the message of the error
  1338. * @param request defines the optional web request
  1339. * @param file defines the optional file
  1340. */
  1341. constructor(message: string, object?: WebRequest | File);
  1342. }
  1343. /** @ignore */
  1344. export class RequestFileError extends BaseError {
  1345. request: WebRequest;
  1346. /**
  1347. * Creates a new LoadFileError
  1348. * @param message defines the message of the error
  1349. * @param request defines the optional web request
  1350. */
  1351. constructor(message: string, request: WebRequest);
  1352. }
  1353. /** @ignore */
  1354. export class ReadFileError extends BaseError {
  1355. file: File;
  1356. /**
  1357. * Creates a new ReadFileError
  1358. * @param message defines the message of the error
  1359. * @param file defines the optional file
  1360. */
  1361. constructor(message: string, file: File);
  1362. }
  1363. /**
  1364. * @hidden
  1365. */
  1366. export class FileTools {
  1367. /**
  1368. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1369. */
  1370. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1371. /**
  1372. * Gets or sets the base URL to use to load assets
  1373. */
  1374. static BaseUrl: string;
  1375. /**
  1376. * Default behaviour for cors in the application.
  1377. * It can be a string if the expected behavior is identical in the entire app.
  1378. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1379. */
  1380. static CorsBehavior: string | ((url: string | string[]) => string);
  1381. /**
  1382. * Gets or sets a function used to pre-process url before using them to load assets
  1383. */
  1384. static PreprocessUrl: (url: string) => string;
  1385. /**
  1386. * Removes unwanted characters from an url
  1387. * @param url defines the url to clean
  1388. * @returns the cleaned url
  1389. */
  1390. private static _CleanUrl;
  1391. /**
  1392. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1393. * @param url define the url we are trying
  1394. * @param element define the dom element where to configure the cors policy
  1395. */
  1396. static SetCorsBehavior(url: string | string[], element: {
  1397. crossOrigin: string | null;
  1398. }): void;
  1399. /**
  1400. * Loads an image as an HTMLImageElement.
  1401. * @param input url string, ArrayBuffer, or Blob to load
  1402. * @param onLoad callback called when the image successfully loads
  1403. * @param onError callback called when the image fails to load
  1404. * @param offlineProvider offline provider for caching
  1405. * @param mimeType optional mime type
  1406. * @returns the HTMLImageElement of the loaded image
  1407. */
  1408. 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>;
  1409. /**
  1410. * Reads a file from a File object
  1411. * @param file defines the file to load
  1412. * @param onSuccess defines the callback to call when data is loaded
  1413. * @param onProgress defines the callback to call during loading process
  1414. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1415. * @param onError defines the callback to call when an error occurs
  1416. * @returns a file request object
  1417. */
  1418. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1419. /**
  1420. * Loads a file from a url
  1421. * @param url url to load
  1422. * @param onSuccess callback called when the file successfully loads
  1423. * @param onProgress callback called while file is loading (if the server supports this mode)
  1424. * @param offlineProvider defines the offline provider for caching
  1425. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1426. * @param onError callback called when the file fails to load
  1427. * @returns a file request object
  1428. */
  1429. 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;
  1430. /**
  1431. * Loads a file
  1432. * @param url url to load
  1433. * @param onSuccess callback called when the file successfully loads
  1434. * @param onProgress callback called while file is loading (if the server supports this mode)
  1435. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1436. * @param onError callback called when the file fails to load
  1437. * @param onOpened callback called when the web request is opened
  1438. * @returns a file request object
  1439. */
  1440. 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;
  1441. /**
  1442. * Checks if the loaded document was accessed via `file:`-Protocol.
  1443. * @returns boolean
  1444. */
  1445. static IsFileURL(): boolean;
  1446. }
  1447. }
  1448. declare module BABYLON {
  1449. /** @hidden */
  1450. export class ShaderProcessor {
  1451. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1452. private static _ProcessPrecision;
  1453. private static _ExtractOperation;
  1454. private static _BuildSubExpression;
  1455. private static _BuildExpression;
  1456. private static _MoveCursorWithinIf;
  1457. private static _MoveCursor;
  1458. private static _EvaluatePreProcessors;
  1459. private static _PreparePreProcessors;
  1460. private static _ProcessShaderConversion;
  1461. private static _ProcessIncludes;
  1462. }
  1463. }
  1464. declare module BABYLON {
  1465. /**
  1466. * @hidden
  1467. */
  1468. export interface IColor4Like {
  1469. r: float;
  1470. g: float;
  1471. b: float;
  1472. a: float;
  1473. }
  1474. /**
  1475. * @hidden
  1476. */
  1477. export interface IColor3Like {
  1478. r: float;
  1479. g: float;
  1480. b: float;
  1481. }
  1482. /**
  1483. * @hidden
  1484. */
  1485. export interface IVector4Like {
  1486. x: float;
  1487. y: float;
  1488. z: float;
  1489. w: float;
  1490. }
  1491. /**
  1492. * @hidden
  1493. */
  1494. export interface IVector3Like {
  1495. x: float;
  1496. y: float;
  1497. z: float;
  1498. }
  1499. /**
  1500. * @hidden
  1501. */
  1502. export interface IVector2Like {
  1503. x: float;
  1504. y: float;
  1505. }
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IMatrixLike {
  1510. toArray(): DeepImmutable<Float32Array>;
  1511. updateFlag: int;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IViewportLike {
  1517. x: float;
  1518. y: float;
  1519. width: float;
  1520. height: float;
  1521. }
  1522. /**
  1523. * @hidden
  1524. */
  1525. export interface IPlaneLike {
  1526. normal: IVector3Like;
  1527. d: float;
  1528. normalize(): void;
  1529. }
  1530. }
  1531. declare module BABYLON {
  1532. /**
  1533. * Interface used to define common properties for effect fallbacks
  1534. */
  1535. export interface IEffectFallbacks {
  1536. /**
  1537. * Removes the defines that should be removed when falling back.
  1538. * @param currentDefines defines the current define statements for the shader.
  1539. * @param effect defines the current effect we try to compile
  1540. * @returns The resulting defines with defines of the current rank removed.
  1541. */
  1542. reduce(currentDefines: string, effect: Effect): string;
  1543. /**
  1544. * Removes the fallback from the bound mesh.
  1545. */
  1546. unBindMesh(): void;
  1547. /**
  1548. * Checks to see if more fallbacks are still availible.
  1549. */
  1550. hasMoreFallbacks: boolean;
  1551. }
  1552. }
  1553. declare module BABYLON {
  1554. /**
  1555. * Class used to evalaute queries containing `and` and `or` operators
  1556. */
  1557. export class AndOrNotEvaluator {
  1558. /**
  1559. * Evaluate a query
  1560. * @param query defines the query to evaluate
  1561. * @param evaluateCallback defines the callback used to filter result
  1562. * @returns true if the query matches
  1563. */
  1564. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1565. private static _HandleParenthesisContent;
  1566. private static _SimplifyNegation;
  1567. }
  1568. }
  1569. declare module BABYLON {
  1570. /**
  1571. * Class used to store custom tags
  1572. */
  1573. export class Tags {
  1574. /**
  1575. * Adds support for tags on the given object
  1576. * @param obj defines the object to use
  1577. */
  1578. static EnableFor(obj: any): void;
  1579. /**
  1580. * Removes tags support
  1581. * @param obj defines the object to use
  1582. */
  1583. static DisableFor(obj: any): void;
  1584. /**
  1585. * Gets a boolean indicating if the given object has tags
  1586. * @param obj defines the object to use
  1587. * @returns a boolean
  1588. */
  1589. static HasTags(obj: any): boolean;
  1590. /**
  1591. * Gets the tags available on a given object
  1592. * @param obj defines the object to use
  1593. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1594. * @returns the tags
  1595. */
  1596. static GetTags(obj: any, asString?: boolean): any;
  1597. /**
  1598. * Adds tags to an object
  1599. * @param obj defines the object to use
  1600. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1601. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1602. */
  1603. static AddTagsTo(obj: any, tagsString: string): void;
  1604. /**
  1605. * @hidden
  1606. */
  1607. static _AddTagTo(obj: any, tag: string): void;
  1608. /**
  1609. * Removes specific tags from a specific object
  1610. * @param obj defines the object to use
  1611. * @param tagsString defines the tags to remove
  1612. */
  1613. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1614. /**
  1615. * @hidden
  1616. */
  1617. static _RemoveTagFrom(obj: any, tag: string): void;
  1618. /**
  1619. * Defines if tags hosted on an object match a given query
  1620. * @param obj defines the object to use
  1621. * @param tagsQuery defines the tag query
  1622. * @returns a boolean
  1623. */
  1624. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1625. }
  1626. }
  1627. declare module BABYLON {
  1628. /**
  1629. * Scalar computation library
  1630. */
  1631. export class Scalar {
  1632. /**
  1633. * Two pi constants convenient for computation.
  1634. */
  1635. static TwoPi: number;
  1636. /**
  1637. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1638. * @param a number
  1639. * @param b number
  1640. * @param epsilon (default = 1.401298E-45)
  1641. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1642. */
  1643. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1644. /**
  1645. * Returns a string : the upper case translation of the number i to hexadecimal.
  1646. * @param i number
  1647. * @returns the upper case translation of the number i to hexadecimal.
  1648. */
  1649. static ToHex(i: number): string;
  1650. /**
  1651. * Returns -1 if value is negative and +1 is value is positive.
  1652. * @param value the value
  1653. * @returns the value itself if it's equal to zero.
  1654. */
  1655. static Sign(value: number): number;
  1656. /**
  1657. * Returns the value itself if it's between min and max.
  1658. * Returns min if the value is lower than min.
  1659. * Returns max if the value is greater than max.
  1660. * @param value the value to clmap
  1661. * @param min the min value to clamp to (default: 0)
  1662. * @param max the max value to clamp to (default: 1)
  1663. * @returns the clamped value
  1664. */
  1665. static Clamp(value: number, min?: number, max?: number): number;
  1666. /**
  1667. * the log2 of value.
  1668. * @param value the value to compute log2 of
  1669. * @returns the log2 of value.
  1670. */
  1671. static Log2(value: number): number;
  1672. /**
  1673. * Loops the value, so that it is never larger than length and never smaller than 0.
  1674. *
  1675. * This is similar to the modulo operator but it works with floating point numbers.
  1676. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1677. * With t = 5 and length = 2.5, the result would be 0.0.
  1678. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1679. * @param value the value
  1680. * @param length the length
  1681. * @returns the looped value
  1682. */
  1683. static Repeat(value: number, length: number): number;
  1684. /**
  1685. * Normalize the value between 0.0 and 1.0 using min and max values
  1686. * @param value value to normalize
  1687. * @param min max to normalize between
  1688. * @param max min to normalize between
  1689. * @returns the normalized value
  1690. */
  1691. static Normalize(value: number, min: number, max: number): number;
  1692. /**
  1693. * Denormalize the value from 0.0 and 1.0 using min and max values
  1694. * @param normalized value to denormalize
  1695. * @param min max to denormalize between
  1696. * @param max min to denormalize between
  1697. * @returns the denormalized value
  1698. */
  1699. static Denormalize(normalized: number, min: number, max: number): number;
  1700. /**
  1701. * Calculates the shortest difference between two given angles given in degrees.
  1702. * @param current current angle in degrees
  1703. * @param target target angle in degrees
  1704. * @returns the delta
  1705. */
  1706. static DeltaAngle(current: number, target: number): number;
  1707. /**
  1708. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1709. * @param tx value
  1710. * @param length length
  1711. * @returns The returned value will move back and forth between 0 and length
  1712. */
  1713. static PingPong(tx: number, length: number): number;
  1714. /**
  1715. * Interpolates between min and max with smoothing at the limits.
  1716. *
  1717. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1718. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1719. * @param from from
  1720. * @param to to
  1721. * @param tx value
  1722. * @returns the smooth stepped value
  1723. */
  1724. static SmoothStep(from: number, to: number, tx: number): number;
  1725. /**
  1726. * Moves a value current towards target.
  1727. *
  1728. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1729. * Negative values of maxDelta pushes the value away from target.
  1730. * @param current current value
  1731. * @param target target value
  1732. * @param maxDelta max distance to move
  1733. * @returns resulting value
  1734. */
  1735. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1736. /**
  1737. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1738. *
  1739. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1740. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1741. * @param current current value
  1742. * @param target target value
  1743. * @param maxDelta max distance to move
  1744. * @returns resulting angle
  1745. */
  1746. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1747. /**
  1748. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1749. * @param start start value
  1750. * @param end target value
  1751. * @param amount amount to lerp between
  1752. * @returns the lerped value
  1753. */
  1754. static Lerp(start: number, end: number, amount: number): number;
  1755. /**
  1756. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1757. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1758. * @param start start value
  1759. * @param end target value
  1760. * @param amount amount to lerp between
  1761. * @returns the lerped value
  1762. */
  1763. static LerpAngle(start: number, end: number, amount: number): number;
  1764. /**
  1765. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1766. * @param a start value
  1767. * @param b target value
  1768. * @param value value between a and b
  1769. * @returns the inverseLerp value
  1770. */
  1771. static InverseLerp(a: number, b: number, value: number): number;
  1772. /**
  1773. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1774. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1775. * @param value1 spline value
  1776. * @param tangent1 spline value
  1777. * @param value2 spline value
  1778. * @param tangent2 spline value
  1779. * @param amount input value
  1780. * @returns hermite result
  1781. */
  1782. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1783. /**
  1784. * Returns a random float number between and min and max values
  1785. * @param min min value of random
  1786. * @param max max value of random
  1787. * @returns random value
  1788. */
  1789. static RandomRange(min: number, max: number): number;
  1790. /**
  1791. * This function returns percentage of a number in a given range.
  1792. *
  1793. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1794. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1795. * @param number to convert to percentage
  1796. * @param min min range
  1797. * @param max max range
  1798. * @returns the percentage
  1799. */
  1800. static RangeToPercent(number: number, min: number, max: number): number;
  1801. /**
  1802. * This function returns number that corresponds to the percentage in a given range.
  1803. *
  1804. * PercentToRange(0.34,0,100) will return 34.
  1805. * @param percent to convert to number
  1806. * @param min min range
  1807. * @param max max range
  1808. * @returns the number
  1809. */
  1810. static PercentToRange(percent: number, min: number, max: number): number;
  1811. /**
  1812. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1813. * @param angle The angle to normalize in radian.
  1814. * @return The converted angle.
  1815. */
  1816. static NormalizeRadians(angle: number): number;
  1817. }
  1818. }
  1819. declare module BABYLON {
  1820. /**
  1821. * Constant used to convert a value to gamma space
  1822. * @ignorenaming
  1823. */
  1824. export const ToGammaSpace: number;
  1825. /**
  1826. * Constant used to convert a value to linear space
  1827. * @ignorenaming
  1828. */
  1829. export const ToLinearSpace = 2.2;
  1830. /**
  1831. * Constant used to define the minimal number value in Babylon.js
  1832. * @ignorenaming
  1833. */
  1834. let Epsilon: number;
  1835. }
  1836. declare module BABYLON {
  1837. /**
  1838. * Class used to represent a viewport on screen
  1839. */
  1840. export class Viewport {
  1841. /** viewport left coordinate */
  1842. x: number;
  1843. /** viewport top coordinate */
  1844. y: number;
  1845. /**viewport width */
  1846. width: number;
  1847. /** viewport height */
  1848. height: number;
  1849. /**
  1850. * Creates a Viewport object located at (x, y) and sized (width, height)
  1851. * @param x defines viewport left coordinate
  1852. * @param y defines viewport top coordinate
  1853. * @param width defines the viewport width
  1854. * @param height defines the viewport height
  1855. */
  1856. constructor(
  1857. /** viewport left coordinate */
  1858. x: number,
  1859. /** viewport top coordinate */
  1860. y: number,
  1861. /**viewport width */
  1862. width: number,
  1863. /** viewport height */
  1864. height: number);
  1865. /**
  1866. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1867. * @param renderWidth defines the rendering width
  1868. * @param renderHeight defines the rendering height
  1869. * @returns a new Viewport
  1870. */
  1871. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1872. /**
  1873. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1874. * @param renderWidth defines the rendering width
  1875. * @param renderHeight defines the rendering height
  1876. * @param ref defines the target viewport
  1877. * @returns the current viewport
  1878. */
  1879. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1880. /**
  1881. * Returns a new Viewport copied from the current one
  1882. * @returns a new Viewport
  1883. */
  1884. clone(): Viewport;
  1885. }
  1886. }
  1887. declare module BABYLON {
  1888. /**
  1889. * Class containing a set of static utilities functions for arrays.
  1890. */
  1891. export class ArrayTools {
  1892. /**
  1893. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1894. * @param size the number of element to construct and put in the array
  1895. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1896. * @returns a new array filled with new objects
  1897. */
  1898. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1899. }
  1900. }
  1901. declare module BABYLON {
  1902. /**
  1903. * Class representing a vector containing 2 coordinates
  1904. */
  1905. export class Vector2 {
  1906. /** defines the first coordinate */
  1907. x: number;
  1908. /** defines the second coordinate */
  1909. y: number;
  1910. /**
  1911. * Creates a new Vector2 from the given x and y coordinates
  1912. * @param x defines the first coordinate
  1913. * @param y defines the second coordinate
  1914. */
  1915. constructor(
  1916. /** defines the first coordinate */
  1917. x?: number,
  1918. /** defines the second coordinate */
  1919. y?: number);
  1920. /**
  1921. * Gets a string with the Vector2 coordinates
  1922. * @returns a string with the Vector2 coordinates
  1923. */
  1924. toString(): string;
  1925. /**
  1926. * Gets class name
  1927. * @returns the string "Vector2"
  1928. */
  1929. getClassName(): string;
  1930. /**
  1931. * Gets current vector hash code
  1932. * @returns the Vector2 hash code as a number
  1933. */
  1934. getHashCode(): number;
  1935. /**
  1936. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1937. * @param array defines the source array
  1938. * @param index defines the offset in source array
  1939. * @returns the current Vector2
  1940. */
  1941. toArray(array: FloatArray, index?: number): Vector2;
  1942. /**
  1943. * Copy the current vector to an array
  1944. * @returns a new array with 2 elements: the Vector2 coordinates.
  1945. */
  1946. asArray(): number[];
  1947. /**
  1948. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1949. * @param source defines the source Vector2
  1950. * @returns the current updated Vector2
  1951. */
  1952. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1953. /**
  1954. * Sets the Vector2 coordinates with the given floats
  1955. * @param x defines the first coordinate
  1956. * @param y defines the second coordinate
  1957. * @returns the current updated Vector2
  1958. */
  1959. copyFromFloats(x: number, y: number): Vector2;
  1960. /**
  1961. * Sets the Vector2 coordinates with the given floats
  1962. * @param x defines the first coordinate
  1963. * @param y defines the second coordinate
  1964. * @returns the current updated Vector2
  1965. */
  1966. set(x: number, y: number): Vector2;
  1967. /**
  1968. * Add another vector with the current one
  1969. * @param otherVector defines the other vector
  1970. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1971. */
  1972. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1973. /**
  1974. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1975. * @param otherVector defines the other vector
  1976. * @param result defines the target vector
  1977. * @returns the unmodified current Vector2
  1978. */
  1979. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1980. /**
  1981. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1982. * @param otherVector defines the other vector
  1983. * @returns the current updated Vector2
  1984. */
  1985. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1986. /**
  1987. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1988. * @param otherVector defines the other vector
  1989. * @returns a new Vector2
  1990. */
  1991. addVector3(otherVector: Vector3): Vector2;
  1992. /**
  1993. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2
  1996. */
  1997. subtract(otherVector: Vector2): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Multiplies in place the current Vector2 coordinates by the given ones
  2013. * @param otherVector defines the other vector
  2014. * @returns the current updated Vector2
  2015. */
  2016. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2017. /**
  2018. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2023. /**
  2024. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2032. * @param x defines the first coordinate
  2033. * @param y defines the second coordinate
  2034. * @returns a new Vector2
  2035. */
  2036. multiplyByFloats(x: number, y: number): Vector2;
  2037. /**
  2038. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @returns a new Vector2
  2041. */
  2042. divide(otherVector: Vector2): Vector2;
  2043. /**
  2044. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2045. * @param otherVector defines the other vector
  2046. * @param result defines the target vector
  2047. * @returns the unmodified current Vector2
  2048. */
  2049. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2050. /**
  2051. * Divides the current Vector2 coordinates by the given ones
  2052. * @param otherVector defines the other vector
  2053. * @returns the current updated Vector2
  2054. */
  2055. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2056. /**
  2057. * Gets a new Vector2 with current Vector2 negated coordinates
  2058. * @returns a new Vector2
  2059. */
  2060. negate(): Vector2;
  2061. /**
  2062. * Multiply the Vector2 coordinates by scale
  2063. * @param scale defines the scaling factor
  2064. * @returns the current updated Vector2
  2065. */
  2066. scaleInPlace(scale: number): Vector2;
  2067. /**
  2068. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2069. * @param scale defines the scaling factor
  2070. * @returns a new Vector2
  2071. */
  2072. scale(scale: number): Vector2;
  2073. /**
  2074. * Scale the current Vector2 values by a factor to a given Vector2
  2075. * @param scale defines the scale factor
  2076. * @param result defines the Vector2 object where to store the result
  2077. * @returns the unmodified current Vector2
  2078. */
  2079. scaleToRef(scale: number, result: Vector2): Vector2;
  2080. /**
  2081. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2082. * @param scale defines the scale factor
  2083. * @param result defines the Vector2 object where to store the result
  2084. * @returns the unmodified current Vector2
  2085. */
  2086. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2087. /**
  2088. * Gets a boolean if two vectors are equals
  2089. * @param otherVector defines the other vector
  2090. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2091. */
  2092. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2093. /**
  2094. * Gets a boolean if two vectors are equals (using an epsilon value)
  2095. * @param otherVector defines the other vector
  2096. * @param epsilon defines the minimal distance to consider equality
  2097. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2098. */
  2099. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2100. /**
  2101. * Gets a new Vector2 from current Vector2 floored values
  2102. * @returns a new Vector2
  2103. */
  2104. floor(): Vector2;
  2105. /**
  2106. * Gets a new Vector2 from current Vector2 floored values
  2107. * @returns a new Vector2
  2108. */
  2109. fract(): Vector2;
  2110. /**
  2111. * Gets the length of the vector
  2112. * @returns the vector length (float)
  2113. */
  2114. length(): number;
  2115. /**
  2116. * Gets the vector squared length
  2117. * @returns the vector squared length (float)
  2118. */
  2119. lengthSquared(): number;
  2120. /**
  2121. * Normalize the vector
  2122. * @returns the current updated Vector2
  2123. */
  2124. normalize(): Vector2;
  2125. /**
  2126. * Gets a new Vector2 copied from the Vector2
  2127. * @returns a new Vector2
  2128. */
  2129. clone(): Vector2;
  2130. /**
  2131. * Gets a new Vector2(0, 0)
  2132. * @returns a new Vector2
  2133. */
  2134. static Zero(): Vector2;
  2135. /**
  2136. * Gets a new Vector2(1, 1)
  2137. * @returns a new Vector2
  2138. */
  2139. static One(): Vector2;
  2140. /**
  2141. * Gets a new Vector2 set from the given index element of the given array
  2142. * @param array defines the data source
  2143. * @param offset defines the offset in the data source
  2144. * @returns a new Vector2
  2145. */
  2146. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2147. /**
  2148. * Sets "result" from the given index element of the given array
  2149. * @param array defines the data source
  2150. * @param offset defines the offset in the data source
  2151. * @param result defines the target vector
  2152. */
  2153. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2154. /**
  2155. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2156. * @param value1 defines 1st point of control
  2157. * @param value2 defines 2nd point of control
  2158. * @param value3 defines 3rd point of control
  2159. * @param value4 defines 4th point of control
  2160. * @param amount defines the interpolation factor
  2161. * @returns a new Vector2
  2162. */
  2163. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2164. /**
  2165. * 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".
  2166. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2167. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2168. * @param value defines the value to clamp
  2169. * @param min defines the lower limit
  2170. * @param max defines the upper limit
  2171. * @returns a new Vector2
  2172. */
  2173. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2174. /**
  2175. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2176. * @param value1 defines the 1st control point
  2177. * @param tangent1 defines the outgoing tangent
  2178. * @param value2 defines the 2nd control point
  2179. * @param tangent2 defines the incoming tangent
  2180. * @param amount defines the interpolation factor
  2181. * @returns a new Vector2
  2182. */
  2183. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2184. /**
  2185. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2186. * @param start defines the start vector
  2187. * @param end defines the end vector
  2188. * @param amount defines the interpolation factor
  2189. * @returns a new Vector2
  2190. */
  2191. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2192. /**
  2193. * Gets the dot product of the vector "left" and the vector "right"
  2194. * @param left defines first vector
  2195. * @param right defines second vector
  2196. * @returns the dot product (float)
  2197. */
  2198. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2199. /**
  2200. * Returns a new Vector2 equal to the normalized given vector
  2201. * @param vector defines the vector to normalize
  2202. * @returns a new Vector2
  2203. */
  2204. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2207. * @param left defines 1st vector
  2208. * @param right defines 2nd vector
  2209. * @returns a new Vector2
  2210. */
  2211. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2214. * @param left defines 1st vector
  2215. * @param right defines 2nd vector
  2216. * @returns a new Vector2
  2217. */
  2218. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2221. * @param vector defines the vector to transform
  2222. * @param transformation defines the matrix to apply
  2223. * @returns a new Vector2
  2224. */
  2225. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2226. /**
  2227. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2228. * @param vector defines the vector to transform
  2229. * @param transformation defines the matrix to apply
  2230. * @param result defines the target vector
  2231. */
  2232. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2233. /**
  2234. * Determines if a given vector is included in a triangle
  2235. * @param p defines the vector to test
  2236. * @param p0 defines 1st triangle point
  2237. * @param p1 defines 2nd triangle point
  2238. * @param p2 defines 3rd triangle point
  2239. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2240. */
  2241. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2242. /**
  2243. * Gets the distance between the vectors "value1" and "value2"
  2244. * @param value1 defines first vector
  2245. * @param value2 defines second vector
  2246. * @returns the distance between vectors
  2247. */
  2248. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2249. /**
  2250. * Returns the squared distance between the vectors "value1" and "value2"
  2251. * @param value1 defines first vector
  2252. * @param value2 defines second vector
  2253. * @returns the squared distance between vectors
  2254. */
  2255. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2256. /**
  2257. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns a new Vector2
  2261. */
  2262. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2263. /**
  2264. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2265. * @param p defines the middle point
  2266. * @param segA defines one point of the segment
  2267. * @param segB defines the other point of the segment
  2268. * @returns the shortest distance
  2269. */
  2270. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2271. }
  2272. /**
  2273. * Class used to store (x,y,z) vector representation
  2274. * A Vector3 is the main object used in 3D geometry
  2275. * It can represent etiher the coordinates of a point the space, either a direction
  2276. * Reminder: js uses a left handed forward facing system
  2277. */
  2278. export class Vector3 {
  2279. /**
  2280. * Defines the first coordinates (on X axis)
  2281. */
  2282. x: number;
  2283. /**
  2284. * Defines the second coordinates (on Y axis)
  2285. */
  2286. y: number;
  2287. /**
  2288. * Defines the third coordinates (on Z axis)
  2289. */
  2290. z: number;
  2291. private static _UpReadOnly;
  2292. private static _ZeroReadOnly;
  2293. /**
  2294. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2295. * @param x defines the first coordinates (on X axis)
  2296. * @param y defines the second coordinates (on Y axis)
  2297. * @param z defines the third coordinates (on Z axis)
  2298. */
  2299. constructor(
  2300. /**
  2301. * Defines the first coordinates (on X axis)
  2302. */
  2303. x?: number,
  2304. /**
  2305. * Defines the second coordinates (on Y axis)
  2306. */
  2307. y?: number,
  2308. /**
  2309. * Defines the third coordinates (on Z axis)
  2310. */
  2311. z?: number);
  2312. /**
  2313. * Creates a string representation of the Vector3
  2314. * @returns a string with the Vector3 coordinates.
  2315. */
  2316. toString(): string;
  2317. /**
  2318. * Gets the class name
  2319. * @returns the string "Vector3"
  2320. */
  2321. getClassName(): string;
  2322. /**
  2323. * Creates the Vector3 hash code
  2324. * @returns a number which tends to be unique between Vector3 instances
  2325. */
  2326. getHashCode(): number;
  2327. /**
  2328. * Creates an array containing three elements : the coordinates of the Vector3
  2329. * @returns a new array of numbers
  2330. */
  2331. asArray(): number[];
  2332. /**
  2333. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2334. * @param array defines the destination array
  2335. * @param index defines the offset in the destination array
  2336. * @returns the current Vector3
  2337. */
  2338. toArray(array: FloatArray, index?: number): Vector3;
  2339. /**
  2340. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2341. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2342. */
  2343. toQuaternion(): Quaternion;
  2344. /**
  2345. * Adds the given vector to the current Vector3
  2346. * @param otherVector defines the second operand
  2347. * @returns the current updated Vector3
  2348. */
  2349. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2350. /**
  2351. * Adds the given coordinates to the current Vector3
  2352. * @param x defines the x coordinate of the operand
  2353. * @param y defines the y coordinate of the operand
  2354. * @param z defines the z coordinate of the operand
  2355. * @returns the current updated Vector3
  2356. */
  2357. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2358. /**
  2359. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2360. * @param otherVector defines the second operand
  2361. * @returns the resulting Vector3
  2362. */
  2363. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2366. * @param otherVector defines the second operand
  2367. * @param result defines the Vector3 object where to store the result
  2368. * @returns the current Vector3
  2369. */
  2370. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2371. /**
  2372. * Subtract the given vector from the current Vector3
  2373. * @param otherVector defines the second operand
  2374. * @returns the current updated Vector3
  2375. */
  2376. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2377. /**
  2378. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2379. * @param otherVector defines the second operand
  2380. * @returns the resulting Vector3
  2381. */
  2382. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2383. /**
  2384. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2385. * @param otherVector defines the second operand
  2386. * @param result defines the Vector3 object where to store the result
  2387. * @returns the current Vector3
  2388. */
  2389. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2390. /**
  2391. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2392. * @param x defines the x coordinate of the operand
  2393. * @param y defines the y coordinate of the operand
  2394. * @param z defines the z coordinate of the operand
  2395. * @returns the resulting Vector3
  2396. */
  2397. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2398. /**
  2399. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2400. * @param x defines the x coordinate of the operand
  2401. * @param y defines the y coordinate of the operand
  2402. * @param z defines the z coordinate of the operand
  2403. * @param result defines the Vector3 object where to store the result
  2404. * @returns the current Vector3
  2405. */
  2406. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2407. /**
  2408. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2409. * @returns a new Vector3
  2410. */
  2411. negate(): Vector3;
  2412. /**
  2413. * Multiplies the Vector3 coordinates by the float "scale"
  2414. * @param scale defines the multiplier factor
  2415. * @returns the current updated Vector3
  2416. */
  2417. scaleInPlace(scale: number): Vector3;
  2418. /**
  2419. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2420. * @param scale defines the multiplier factor
  2421. * @returns a new Vector3
  2422. */
  2423. scale(scale: number): Vector3;
  2424. /**
  2425. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2426. * @param scale defines the multiplier factor
  2427. * @param result defines the Vector3 object where to store the result
  2428. * @returns the current Vector3
  2429. */
  2430. scaleToRef(scale: number, result: Vector3): Vector3;
  2431. /**
  2432. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2433. * @param scale defines the scale factor
  2434. * @param result defines the Vector3 object where to store the result
  2435. * @returns the unmodified current Vector3
  2436. */
  2437. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2438. /**
  2439. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2440. * @param otherVector defines the second operand
  2441. * @returns true if both vectors are equals
  2442. */
  2443. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2444. /**
  2445. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2446. * @param otherVector defines the second operand
  2447. * @param epsilon defines the minimal distance to define values as equals
  2448. * @returns true if both vectors are distant less than epsilon
  2449. */
  2450. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2451. /**
  2452. * Returns true if the current Vector3 coordinates equals the given floats
  2453. * @param x defines the x coordinate of the operand
  2454. * @param y defines the y coordinate of the operand
  2455. * @param z defines the z coordinate of the operand
  2456. * @returns true if both vectors are equals
  2457. */
  2458. equalsToFloats(x: number, y: number, z: number): boolean;
  2459. /**
  2460. * Multiplies the current Vector3 coordinates by the given ones
  2461. * @param otherVector defines the second operand
  2462. * @returns the current updated Vector3
  2463. */
  2464. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2465. /**
  2466. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2467. * @param otherVector defines the second operand
  2468. * @returns the new Vector3
  2469. */
  2470. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2471. /**
  2472. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2473. * @param otherVector defines the second operand
  2474. * @param result defines the Vector3 object where to store the result
  2475. * @returns the current Vector3
  2476. */
  2477. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2478. /**
  2479. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2480. * @param x defines the x coordinate of the operand
  2481. * @param y defines the y coordinate of the operand
  2482. * @param z defines the z coordinate of the operand
  2483. * @returns the new Vector3
  2484. */
  2485. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2486. /**
  2487. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2488. * @param otherVector defines the second operand
  2489. * @returns the new Vector3
  2490. */
  2491. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2492. /**
  2493. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2494. * @param otherVector defines the second operand
  2495. * @param result defines the Vector3 object where to store the result
  2496. * @returns the current Vector3
  2497. */
  2498. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2499. /**
  2500. * Divides the current Vector3 coordinates by the given ones.
  2501. * @param otherVector defines the second operand
  2502. * @returns the current updated Vector3
  2503. */
  2504. divideInPlace(otherVector: Vector3): Vector3;
  2505. /**
  2506. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2507. * @param other defines the second operand
  2508. * @returns the current updated Vector3
  2509. */
  2510. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2513. * @param other defines the second operand
  2514. * @returns the current updated Vector3
  2515. */
  2516. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2519. * @param x defines the x coordinate of the operand
  2520. * @param y defines the y coordinate of the operand
  2521. * @param z defines the z coordinate of the operand
  2522. * @returns the current updated Vector3
  2523. */
  2524. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2525. /**
  2526. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2527. * @param x defines the x coordinate of the operand
  2528. * @param y defines the y coordinate of the operand
  2529. * @param z defines the z coordinate of the operand
  2530. * @returns the current updated Vector3
  2531. */
  2532. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2533. /**
  2534. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2535. * Check if is non uniform within a certain amount of decimal places to account for this
  2536. * @param epsilon the amount the values can differ
  2537. * @returns if the the vector is non uniform to a certain number of decimal places
  2538. */
  2539. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2540. /**
  2541. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2542. */
  2543. readonly isNonUniform: boolean;
  2544. /**
  2545. * Gets a new Vector3 from current Vector3 floored values
  2546. * @returns a new Vector3
  2547. */
  2548. floor(): Vector3;
  2549. /**
  2550. * Gets a new Vector3 from current Vector3 floored values
  2551. * @returns a new Vector3
  2552. */
  2553. fract(): Vector3;
  2554. /**
  2555. * Gets the length of the Vector3
  2556. * @returns the length of the Vector3
  2557. */
  2558. length(): number;
  2559. /**
  2560. * Gets the squared length of the Vector3
  2561. * @returns squared length of the Vector3
  2562. */
  2563. lengthSquared(): number;
  2564. /**
  2565. * Normalize the current Vector3.
  2566. * Please note that this is an in place operation.
  2567. * @returns the current updated Vector3
  2568. */
  2569. normalize(): Vector3;
  2570. /**
  2571. * Reorders the x y z properties of the vector in place
  2572. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2573. * @returns the current updated vector
  2574. */
  2575. reorderInPlace(order: string): this;
  2576. /**
  2577. * Rotates the vector around 0,0,0 by a quaternion
  2578. * @param quaternion the rotation quaternion
  2579. * @param result vector to store the result
  2580. * @returns the resulting vector
  2581. */
  2582. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2583. /**
  2584. * Rotates a vector around a given point
  2585. * @param quaternion the rotation quaternion
  2586. * @param point the point to rotate around
  2587. * @param result vector to store the result
  2588. * @returns the resulting vector
  2589. */
  2590. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2591. /**
  2592. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2593. * The cross product is then orthogonal to both current and "other"
  2594. * @param other defines the right operand
  2595. * @returns the cross product
  2596. */
  2597. cross(other: Vector3): Vector3;
  2598. /**
  2599. * Normalize the current Vector3 with the given input length.
  2600. * Please note that this is an in place operation.
  2601. * @param len the length of the vector
  2602. * @returns the current updated Vector3
  2603. */
  2604. normalizeFromLength(len: number): Vector3;
  2605. /**
  2606. * Normalize the current Vector3 to a new vector
  2607. * @returns the new Vector3
  2608. */
  2609. normalizeToNew(): Vector3;
  2610. /**
  2611. * Normalize the current Vector3 to the reference
  2612. * @param reference define the Vector3 to update
  2613. * @returns the updated Vector3
  2614. */
  2615. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2616. /**
  2617. * Creates a new Vector3 copied from the current Vector3
  2618. * @returns the new Vector3
  2619. */
  2620. clone(): Vector3;
  2621. /**
  2622. * Copies the given vector coordinates to the current Vector3 ones
  2623. * @param source defines the source Vector3
  2624. * @returns the current updated Vector3
  2625. */
  2626. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2627. /**
  2628. * Copies the given floats to the current Vector3 coordinates
  2629. * @param x defines the x coordinate of the operand
  2630. * @param y defines the y coordinate of the operand
  2631. * @param z defines the z coordinate of the operand
  2632. * @returns the current updated Vector3
  2633. */
  2634. copyFromFloats(x: number, y: number, z: number): Vector3;
  2635. /**
  2636. * Copies the given floats to the current Vector3 coordinates
  2637. * @param x defines the x coordinate of the operand
  2638. * @param y defines the y coordinate of the operand
  2639. * @param z defines the z coordinate of the operand
  2640. * @returns the current updated Vector3
  2641. */
  2642. set(x: number, y: number, z: number): Vector3;
  2643. /**
  2644. * Copies the given float to the current Vector3 coordinates
  2645. * @param v defines the x, y and z coordinates of the operand
  2646. * @returns the current updated Vector3
  2647. */
  2648. setAll(v: number): Vector3;
  2649. /**
  2650. * Get the clip factor between two vectors
  2651. * @param vector0 defines the first operand
  2652. * @param vector1 defines the second operand
  2653. * @param axis defines the axis to use
  2654. * @param size defines the size along the axis
  2655. * @returns the clip factor
  2656. */
  2657. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2658. /**
  2659. * Get angle between two vectors
  2660. * @param vector0 angle between vector0 and vector1
  2661. * @param vector1 angle between vector0 and vector1
  2662. * @param normal direction of the normal
  2663. * @return the angle between vector0 and vector1
  2664. */
  2665. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2666. /**
  2667. * Returns a new Vector3 set from the index "offset" of the given array
  2668. * @param array defines the source array
  2669. * @param offset defines the offset in the source array
  2670. * @returns the new Vector3
  2671. */
  2672. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2673. /**
  2674. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2675. * @param array defines the source array
  2676. * @param offset defines the offset in the source array
  2677. * @returns the new Vector3
  2678. * @deprecated Please use FromArray instead.
  2679. */
  2680. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2681. /**
  2682. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2683. * @param array defines the source array
  2684. * @param offset defines the offset in the source array
  2685. * @param result defines the Vector3 where to store the result
  2686. */
  2687. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2688. /**
  2689. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2690. * @param array defines the source array
  2691. * @param offset defines the offset in the source array
  2692. * @param result defines the Vector3 where to store the result
  2693. * @deprecated Please use FromArrayToRef instead.
  2694. */
  2695. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2696. /**
  2697. * Sets the given vector "result" with the given floats.
  2698. * @param x defines the x coordinate of the source
  2699. * @param y defines the y coordinate of the source
  2700. * @param z defines the z coordinate of the source
  2701. * @param result defines the Vector3 where to store the result
  2702. */
  2703. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2704. /**
  2705. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2706. * @returns a new empty Vector3
  2707. */
  2708. static Zero(): Vector3;
  2709. /**
  2710. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2711. * @returns a new unit Vector3
  2712. */
  2713. static One(): Vector3;
  2714. /**
  2715. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2716. * @returns a new up Vector3
  2717. */
  2718. static Up(): Vector3;
  2719. /**
  2720. * Gets a up Vector3 that must not be updated
  2721. */
  2722. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2723. /**
  2724. * Gets a zero Vector3 that must not be updated
  2725. */
  2726. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2727. /**
  2728. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2729. * @returns a new down Vector3
  2730. */
  2731. static Down(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2734. * @returns a new forward Vector3
  2735. */
  2736. static Forward(): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2739. * @returns a new forward Vector3
  2740. */
  2741. static Backward(): Vector3;
  2742. /**
  2743. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2744. * @returns a new right Vector3
  2745. */
  2746. static Right(): Vector3;
  2747. /**
  2748. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2749. * @returns a new left Vector3
  2750. */
  2751. static Left(): Vector3;
  2752. /**
  2753. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2754. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2755. * @param vector defines the Vector3 to transform
  2756. * @param transformation defines the transformation matrix
  2757. * @returns the transformed Vector3
  2758. */
  2759. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2760. /**
  2761. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2762. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2763. * @param vector defines the Vector3 to transform
  2764. * @param transformation defines the transformation matrix
  2765. * @param result defines the Vector3 where to store the result
  2766. */
  2767. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2768. /**
  2769. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2770. * This method computes tranformed coordinates only, not transformed direction vectors
  2771. * @param x define the x coordinate of the source vector
  2772. * @param y define the y coordinate of the source vector
  2773. * @param z define the z coordinate of the source vector
  2774. * @param transformation defines the transformation matrix
  2775. * @param result defines the Vector3 where to store the result
  2776. */
  2777. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2778. /**
  2779. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2780. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2781. * @param vector defines the Vector3 to transform
  2782. * @param transformation defines the transformation matrix
  2783. * @returns the new Vector3
  2784. */
  2785. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2786. /**
  2787. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2788. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2789. * @param vector defines the Vector3 to transform
  2790. * @param transformation defines the transformation matrix
  2791. * @param result defines the Vector3 where to store the result
  2792. */
  2793. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2794. /**
  2795. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2796. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2797. * @param x define the x coordinate of the source vector
  2798. * @param y define the y coordinate of the source vector
  2799. * @param z define the z coordinate of the source vector
  2800. * @param transformation defines the transformation matrix
  2801. * @param result defines the Vector3 where to store the result
  2802. */
  2803. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2804. /**
  2805. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2806. * @param value1 defines the first control point
  2807. * @param value2 defines the second control point
  2808. * @param value3 defines the third control point
  2809. * @param value4 defines the fourth control point
  2810. * @param amount defines the amount on the spline to use
  2811. * @returns the new Vector3
  2812. */
  2813. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2814. /**
  2815. * 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"
  2816. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2817. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2818. * @param value defines the current value
  2819. * @param min defines the lower range value
  2820. * @param max defines the upper range value
  2821. * @returns the new Vector3
  2822. */
  2823. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2824. /**
  2825. * 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"
  2826. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2827. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2828. * @param value defines the current value
  2829. * @param min defines the lower range value
  2830. * @param max defines the upper range value
  2831. * @param result defines the Vector3 where to store the result
  2832. */
  2833. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2834. /**
  2835. * Checks if a given vector is inside a specific range
  2836. * @param v defines the vector to test
  2837. * @param min defines the minimum range
  2838. * @param max defines the maximum range
  2839. */
  2840. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2841. /**
  2842. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2843. * @param value1 defines the first control point
  2844. * @param tangent1 defines the first tangent vector
  2845. * @param value2 defines the second control point
  2846. * @param tangent2 defines the second tangent vector
  2847. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2848. * @returns the new Vector3
  2849. */
  2850. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2851. /**
  2852. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2853. * @param start defines the start value
  2854. * @param end defines the end value
  2855. * @param amount max defines amount between both (between 0 and 1)
  2856. * @returns the new Vector3
  2857. */
  2858. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2859. /**
  2860. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2861. * @param start defines the start value
  2862. * @param end defines the end value
  2863. * @param amount max defines amount between both (between 0 and 1)
  2864. * @param result defines the Vector3 where to store the result
  2865. */
  2866. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2867. /**
  2868. * Returns the dot product (float) between the vectors "left" and "right"
  2869. * @param left defines the left operand
  2870. * @param right defines the right operand
  2871. * @returns the dot product
  2872. */
  2873. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2874. /**
  2875. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2876. * The cross product is then orthogonal to both "left" and "right"
  2877. * @param left defines the left operand
  2878. * @param right defines the right operand
  2879. * @returns the cross product
  2880. */
  2881. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2882. /**
  2883. * Sets the given vector "result" with the cross product of "left" and "right"
  2884. * The cross product is then orthogonal to both "left" and "right"
  2885. * @param left defines the left operand
  2886. * @param right defines the right operand
  2887. * @param result defines the Vector3 where to store the result
  2888. */
  2889. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2890. /**
  2891. * Returns a new Vector3 as the normalization of the given vector
  2892. * @param vector defines the Vector3 to normalize
  2893. * @returns the new Vector3
  2894. */
  2895. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2896. /**
  2897. * Sets the given vector "result" with the normalization of the given first vector
  2898. * @param vector defines the Vector3 to normalize
  2899. * @param result defines the Vector3 where to store the result
  2900. */
  2901. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2902. /**
  2903. * Project a Vector3 onto screen space
  2904. * @param vector defines the Vector3 to project
  2905. * @param world defines the world matrix to use
  2906. * @param transform defines the transform (view x projection) matrix to use
  2907. * @param viewport defines the screen viewport to use
  2908. * @returns the new Vector3
  2909. */
  2910. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2911. /** @hidden */
  2912. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2913. /**
  2914. * Unproject from screen space to object space
  2915. * @param source defines the screen space Vector3 to use
  2916. * @param viewportWidth defines the current width of the viewport
  2917. * @param viewportHeight defines the current height of the viewport
  2918. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2919. * @param transform defines the transform (view x projection) matrix to use
  2920. * @returns the new Vector3
  2921. */
  2922. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2923. /**
  2924. * Unproject from screen space to object space
  2925. * @param source defines the screen space Vector3 to use
  2926. * @param viewportWidth defines the current width of the viewport
  2927. * @param viewportHeight defines the current height of the viewport
  2928. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2929. * @param view defines the view matrix to use
  2930. * @param projection defines the projection matrix to use
  2931. * @returns the new Vector3
  2932. */
  2933. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2934. /**
  2935. * Unproject from screen space to object space
  2936. * @param source defines the screen space Vector3 to use
  2937. * @param viewportWidth defines the current width of the viewport
  2938. * @param viewportHeight defines the current height of the viewport
  2939. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2940. * @param view defines the view matrix to use
  2941. * @param projection defines the projection matrix to use
  2942. * @param result defines the Vector3 where to store the result
  2943. */
  2944. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2945. /**
  2946. * Unproject from screen space to object space
  2947. * @param sourceX defines the screen space x coordinate to use
  2948. * @param sourceY defines the screen space y coordinate to use
  2949. * @param sourceZ defines the screen space z coordinate to use
  2950. * @param viewportWidth defines the current width of the viewport
  2951. * @param viewportHeight defines the current height of the viewport
  2952. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2953. * @param view defines the view matrix to use
  2954. * @param projection defines the projection matrix to use
  2955. * @param result defines the Vector3 where to store the result
  2956. */
  2957. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2958. /**
  2959. * Gets the minimal coordinate values between two Vector3
  2960. * @param left defines the first operand
  2961. * @param right defines the second operand
  2962. * @returns the new Vector3
  2963. */
  2964. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2965. /**
  2966. * Gets the maximal coordinate values between two Vector3
  2967. * @param left defines the first operand
  2968. * @param right defines the second operand
  2969. * @returns the new Vector3
  2970. */
  2971. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2972. /**
  2973. * Returns the distance between the vectors "value1" and "value2"
  2974. * @param value1 defines the first operand
  2975. * @param value2 defines the second operand
  2976. * @returns the distance
  2977. */
  2978. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2979. /**
  2980. * Returns the squared distance between the vectors "value1" and "value2"
  2981. * @param value1 defines the first operand
  2982. * @param value2 defines the second operand
  2983. * @returns the squared distance
  2984. */
  2985. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2986. /**
  2987. * Returns a new Vector3 located at the center between "value1" and "value2"
  2988. * @param value1 defines the first operand
  2989. * @param value2 defines the second operand
  2990. * @returns the new Vector3
  2991. */
  2992. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2993. /**
  2994. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2995. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2996. * to something in order to rotate it from its local system to the given target system
  2997. * Note: axis1, axis2 and axis3 are normalized during this operation
  2998. * @param axis1 defines the first axis
  2999. * @param axis2 defines the second axis
  3000. * @param axis3 defines the third axis
  3001. * @returns a new Vector3
  3002. */
  3003. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3004. /**
  3005. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3006. * @param axis1 defines the first axis
  3007. * @param axis2 defines the second axis
  3008. * @param axis3 defines the third axis
  3009. * @param ref defines the Vector3 where to store the result
  3010. */
  3011. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3012. }
  3013. /**
  3014. * Vector4 class created for EulerAngle class conversion to Quaternion
  3015. */
  3016. export class Vector4 {
  3017. /** x value of the vector */
  3018. x: number;
  3019. /** y value of the vector */
  3020. y: number;
  3021. /** z value of the vector */
  3022. z: number;
  3023. /** w value of the vector */
  3024. w: number;
  3025. /**
  3026. * Creates a Vector4 object from the given floats.
  3027. * @param x x value of the vector
  3028. * @param y y value of the vector
  3029. * @param z z value of the vector
  3030. * @param w w value of the vector
  3031. */
  3032. constructor(
  3033. /** x value of the vector */
  3034. x: number,
  3035. /** y value of the vector */
  3036. y: number,
  3037. /** z value of the vector */
  3038. z: number,
  3039. /** w value of the vector */
  3040. w: number);
  3041. /**
  3042. * Returns the string with the Vector4 coordinates.
  3043. * @returns a string containing all the vector values
  3044. */
  3045. toString(): string;
  3046. /**
  3047. * Returns the string "Vector4".
  3048. * @returns "Vector4"
  3049. */
  3050. getClassName(): string;
  3051. /**
  3052. * Returns the Vector4 hash code.
  3053. * @returns a unique hash code
  3054. */
  3055. getHashCode(): number;
  3056. /**
  3057. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3058. * @returns the resulting array
  3059. */
  3060. asArray(): number[];
  3061. /**
  3062. * Populates the given array from the given index with the Vector4 coordinates.
  3063. * @param array array to populate
  3064. * @param index index of the array to start at (default: 0)
  3065. * @returns the Vector4.
  3066. */
  3067. toArray(array: FloatArray, index?: number): Vector4;
  3068. /**
  3069. * Adds the given vector to the current Vector4.
  3070. * @param otherVector the vector to add
  3071. * @returns the updated Vector4.
  3072. */
  3073. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3074. /**
  3075. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3076. * @param otherVector the vector to add
  3077. * @returns the resulting vector
  3078. */
  3079. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3080. /**
  3081. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3082. * @param otherVector the vector to add
  3083. * @param result the vector to store the result
  3084. * @returns the current Vector4.
  3085. */
  3086. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3087. /**
  3088. * Subtract in place the given vector from the current Vector4.
  3089. * @param otherVector the vector to subtract
  3090. * @returns the updated Vector4.
  3091. */
  3092. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3093. /**
  3094. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the new vector with the result
  3097. */
  3098. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3101. * @param otherVector the vector to subtract
  3102. * @param result the vector to store the result
  3103. * @returns the current Vector4.
  3104. */
  3105. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3106. /**
  3107. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3108. */
  3109. /**
  3110. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3111. * @param x value to subtract
  3112. * @param y value to subtract
  3113. * @param z value to subtract
  3114. * @param w value to subtract
  3115. * @returns new vector containing the result
  3116. */
  3117. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3118. /**
  3119. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3120. * @param x value to subtract
  3121. * @param y value to subtract
  3122. * @param z value to subtract
  3123. * @param w value to subtract
  3124. * @param result the vector to store the result in
  3125. * @returns the current Vector4.
  3126. */
  3127. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3128. /**
  3129. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3130. * @returns a new vector with the negated values
  3131. */
  3132. negate(): Vector4;
  3133. /**
  3134. * Multiplies the current Vector4 coordinates by scale (float).
  3135. * @param scale the number to scale with
  3136. * @returns the updated Vector4.
  3137. */
  3138. scaleInPlace(scale: number): Vector4;
  3139. /**
  3140. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3141. * @param scale the number to scale with
  3142. * @returns a new vector with the result
  3143. */
  3144. scale(scale: number): Vector4;
  3145. /**
  3146. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3147. * @param scale the number to scale with
  3148. * @param result a vector to store the result in
  3149. * @returns the current Vector4.
  3150. */
  3151. scaleToRef(scale: number, result: Vector4): Vector4;
  3152. /**
  3153. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3154. * @param scale defines the scale factor
  3155. * @param result defines the Vector4 object where to store the result
  3156. * @returns the unmodified current Vector4
  3157. */
  3158. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3159. /**
  3160. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3161. * @param otherVector the vector to compare against
  3162. * @returns true if they are equal
  3163. */
  3164. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3165. /**
  3166. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3167. * @param otherVector vector to compare against
  3168. * @param epsilon (Default: very small number)
  3169. * @returns true if they are equal
  3170. */
  3171. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3172. /**
  3173. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3174. * @param x x value to compare against
  3175. * @param y y value to compare against
  3176. * @param z z value to compare against
  3177. * @param w w value to compare against
  3178. * @returns true if equal
  3179. */
  3180. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3181. /**
  3182. * Multiplies in place the current Vector4 by the given one.
  3183. * @param otherVector vector to multiple with
  3184. * @returns the updated Vector4.
  3185. */
  3186. multiplyInPlace(otherVector: Vector4): Vector4;
  3187. /**
  3188. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3189. * @param otherVector vector to multiple with
  3190. * @returns resulting new vector
  3191. */
  3192. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3193. /**
  3194. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3195. * @param otherVector vector to multiple with
  3196. * @param result vector to store the result
  3197. * @returns the current Vector4.
  3198. */
  3199. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3200. /**
  3201. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3202. * @param x x value multiply with
  3203. * @param y y value multiply with
  3204. * @param z z value multiply with
  3205. * @param w w value multiply with
  3206. * @returns resulting new vector
  3207. */
  3208. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3209. /**
  3210. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3211. * @param otherVector vector to devide with
  3212. * @returns resulting new vector
  3213. */
  3214. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3215. /**
  3216. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3217. * @param otherVector vector to devide with
  3218. * @param result vector to store the result
  3219. * @returns the current Vector4.
  3220. */
  3221. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3222. /**
  3223. * Divides the current Vector3 coordinates by the given ones.
  3224. * @param otherVector vector to devide with
  3225. * @returns the updated Vector3.
  3226. */
  3227. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3228. /**
  3229. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3230. * @param other defines the second operand
  3231. * @returns the current updated Vector4
  3232. */
  3233. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3234. /**
  3235. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3236. * @param other defines the second operand
  3237. * @returns the current updated Vector4
  3238. */
  3239. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Gets a new Vector4 from current Vector4 floored values
  3242. * @returns a new Vector4
  3243. */
  3244. floor(): Vector4;
  3245. /**
  3246. * Gets a new Vector4 from current Vector3 floored values
  3247. * @returns a new Vector4
  3248. */
  3249. fract(): Vector4;
  3250. /**
  3251. * Returns the Vector4 length (float).
  3252. * @returns the length
  3253. */
  3254. length(): number;
  3255. /**
  3256. * Returns the Vector4 squared length (float).
  3257. * @returns the length squared
  3258. */
  3259. lengthSquared(): number;
  3260. /**
  3261. * Normalizes in place the Vector4.
  3262. * @returns the updated Vector4.
  3263. */
  3264. normalize(): Vector4;
  3265. /**
  3266. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3267. * @returns this converted to a new vector3
  3268. */
  3269. toVector3(): Vector3;
  3270. /**
  3271. * Returns a new Vector4 copied from the current one.
  3272. * @returns the new cloned vector
  3273. */
  3274. clone(): Vector4;
  3275. /**
  3276. * Updates the current Vector4 with the given one coordinates.
  3277. * @param source the source vector to copy from
  3278. * @returns the updated Vector4.
  3279. */
  3280. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3281. /**
  3282. * Updates the current Vector4 coordinates with the given floats.
  3283. * @param x float to copy from
  3284. * @param y float to copy from
  3285. * @param z float to copy from
  3286. * @param w float to copy from
  3287. * @returns the updated Vector4.
  3288. */
  3289. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3290. /**
  3291. * Updates the current Vector4 coordinates with the given floats.
  3292. * @param x float to set from
  3293. * @param y float to set from
  3294. * @param z float to set from
  3295. * @param w float to set from
  3296. * @returns the updated Vector4.
  3297. */
  3298. set(x: number, y: number, z: number, w: number): Vector4;
  3299. /**
  3300. * Copies the given float to the current Vector3 coordinates
  3301. * @param v defines the x, y, z and w coordinates of the operand
  3302. * @returns the current updated Vector3
  3303. */
  3304. setAll(v: number): Vector4;
  3305. /**
  3306. * Returns a new Vector4 set from the starting index of the given array.
  3307. * @param array the array to pull values from
  3308. * @param offset the offset into the array to start at
  3309. * @returns the new vector
  3310. */
  3311. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3312. /**
  3313. * Updates the given vector "result" from the starting index of the given array.
  3314. * @param array the array to pull values from
  3315. * @param offset the offset into the array to start at
  3316. * @param result the vector to store the result in
  3317. */
  3318. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3319. /**
  3320. * Updates the given vector "result" from the starting index of the given Float32Array.
  3321. * @param array the array to pull values from
  3322. * @param offset the offset into the array to start at
  3323. * @param result the vector to store the result in
  3324. */
  3325. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3326. /**
  3327. * Updates the given vector "result" coordinates from the given floats.
  3328. * @param x float to set from
  3329. * @param y float to set from
  3330. * @param z float to set from
  3331. * @param w float to set from
  3332. * @param result the vector to the floats in
  3333. */
  3334. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3335. /**
  3336. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3337. * @returns the new vector
  3338. */
  3339. static Zero(): Vector4;
  3340. /**
  3341. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3342. * @returns the new vector
  3343. */
  3344. static One(): Vector4;
  3345. /**
  3346. * Returns a new normalized Vector4 from the given one.
  3347. * @param vector the vector to normalize
  3348. * @returns the vector
  3349. */
  3350. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3351. /**
  3352. * Updates the given vector "result" from the normalization of the given one.
  3353. * @param vector the vector to normalize
  3354. * @param result the vector to store the result in
  3355. */
  3356. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3357. /**
  3358. * Returns a vector with the minimum values from the left and right vectors
  3359. * @param left left vector to minimize
  3360. * @param right right vector to minimize
  3361. * @returns a new vector with the minimum of the left and right vector values
  3362. */
  3363. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3364. /**
  3365. * Returns a vector with the maximum values from the left and right vectors
  3366. * @param left left vector to maximize
  3367. * @param right right vector to maximize
  3368. * @returns a new vector with the maximum of the left and right vector values
  3369. */
  3370. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3371. /**
  3372. * Returns the distance (float) between the vectors "value1" and "value2".
  3373. * @param value1 value to calulate the distance between
  3374. * @param value2 value to calulate the distance between
  3375. * @return the distance between the two vectors
  3376. */
  3377. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3378. /**
  3379. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3380. * @param value1 value to calulate the distance between
  3381. * @param value2 value to calulate the distance between
  3382. * @return the distance between the two vectors squared
  3383. */
  3384. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3385. /**
  3386. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3387. * @param value1 value to calulate the center between
  3388. * @param value2 value to calulate the center between
  3389. * @return the center between the two vectors
  3390. */
  3391. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3392. /**
  3393. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3394. * This methods computes transformed normalized direction vectors only.
  3395. * @param vector the vector to transform
  3396. * @param transformation the transformation matrix to apply
  3397. * @returns the new vector
  3398. */
  3399. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3400. /**
  3401. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3402. * This methods computes transformed normalized direction vectors only.
  3403. * @param vector the vector to transform
  3404. * @param transformation the transformation matrix to apply
  3405. * @param result the vector to store the result in
  3406. */
  3407. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3408. /**
  3409. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3410. * This methods computes transformed normalized direction vectors only.
  3411. * @param x value to transform
  3412. * @param y value to transform
  3413. * @param z value to transform
  3414. * @param w value to transform
  3415. * @param transformation the transformation matrix to apply
  3416. * @param result the vector to store the results in
  3417. */
  3418. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3419. /**
  3420. * Creates a new Vector4 from a Vector3
  3421. * @param source defines the source data
  3422. * @param w defines the 4th component (default is 0)
  3423. * @returns a new Vector4
  3424. */
  3425. static FromVector3(source: Vector3, w?: number): Vector4;
  3426. }
  3427. /**
  3428. * Class used to store quaternion data
  3429. * @see https://en.wikipedia.org/wiki/Quaternion
  3430. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3431. */
  3432. export class Quaternion {
  3433. /** defines the first component (0 by default) */
  3434. x: number;
  3435. /** defines the second component (0 by default) */
  3436. y: number;
  3437. /** defines the third component (0 by default) */
  3438. z: number;
  3439. /** defines the fourth component (1.0 by default) */
  3440. w: number;
  3441. /**
  3442. * Creates a new Quaternion from the given floats
  3443. * @param x defines the first component (0 by default)
  3444. * @param y defines the second component (0 by default)
  3445. * @param z defines the third component (0 by default)
  3446. * @param w defines the fourth component (1.0 by default)
  3447. */
  3448. constructor(
  3449. /** defines the first component (0 by default) */
  3450. x?: number,
  3451. /** defines the second component (0 by default) */
  3452. y?: number,
  3453. /** defines the third component (0 by default) */
  3454. z?: number,
  3455. /** defines the fourth component (1.0 by default) */
  3456. w?: number);
  3457. /**
  3458. * Gets a string representation for the current quaternion
  3459. * @returns a string with the Quaternion coordinates
  3460. */
  3461. toString(): string;
  3462. /**
  3463. * Gets the class name of the quaternion
  3464. * @returns the string "Quaternion"
  3465. */
  3466. getClassName(): string;
  3467. /**
  3468. * Gets a hash code for this quaternion
  3469. * @returns the quaternion hash code
  3470. */
  3471. getHashCode(): number;
  3472. /**
  3473. * Copy the quaternion to an array
  3474. * @returns a new array populated with 4 elements from the quaternion coordinates
  3475. */
  3476. asArray(): number[];
  3477. /**
  3478. * Check if two quaternions are equals
  3479. * @param otherQuaternion defines the second operand
  3480. * @return true if the current quaternion and the given one coordinates are strictly equals
  3481. */
  3482. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3483. /**
  3484. * Clone the current quaternion
  3485. * @returns a new quaternion copied from the current one
  3486. */
  3487. clone(): Quaternion;
  3488. /**
  3489. * Copy a quaternion to the current one
  3490. * @param other defines the other quaternion
  3491. * @returns the updated current quaternion
  3492. */
  3493. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3494. /**
  3495. * Updates the current quaternion with the given float coordinates
  3496. * @param x defines the x coordinate
  3497. * @param y defines the y coordinate
  3498. * @param z defines the z coordinate
  3499. * @param w defines the w coordinate
  3500. * @returns the updated current quaternion
  3501. */
  3502. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3503. /**
  3504. * Updates the current quaternion from the given float coordinates
  3505. * @param x defines the x coordinate
  3506. * @param y defines the y coordinate
  3507. * @param z defines the z coordinate
  3508. * @param w defines the w coordinate
  3509. * @returns the updated current quaternion
  3510. */
  3511. set(x: number, y: number, z: number, w: number): Quaternion;
  3512. /**
  3513. * Adds two quaternions
  3514. * @param other defines the second operand
  3515. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3516. */
  3517. add(other: DeepImmutable<Quaternion>): Quaternion;
  3518. /**
  3519. * Add a quaternion to the current one
  3520. * @param other defines the quaternion to add
  3521. * @returns the current quaternion
  3522. */
  3523. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3524. /**
  3525. * Subtract two quaternions
  3526. * @param other defines the second operand
  3527. * @returns a new quaternion as the subtraction result of the given one from the current one
  3528. */
  3529. subtract(other: Quaternion): Quaternion;
  3530. /**
  3531. * Multiplies the current quaternion by a scale factor
  3532. * @param value defines the scale factor
  3533. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3534. */
  3535. scale(value: number): Quaternion;
  3536. /**
  3537. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Quaternion object where to store the result
  3540. * @returns the unmodified current quaternion
  3541. */
  3542. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3543. /**
  3544. * Multiplies in place the current quaternion by a scale factor
  3545. * @param value defines the scale factor
  3546. * @returns the current modified quaternion
  3547. */
  3548. scaleInPlace(value: number): Quaternion;
  3549. /**
  3550. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3551. * @param scale defines the scale factor
  3552. * @param result defines the Quaternion object where to store the result
  3553. * @returns the unmodified current quaternion
  3554. */
  3555. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3556. /**
  3557. * Multiplies two quaternions
  3558. * @param q1 defines the second operand
  3559. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3560. */
  3561. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3562. /**
  3563. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3564. * @param q1 defines the second operand
  3565. * @param result defines the target quaternion
  3566. * @returns the current quaternion
  3567. */
  3568. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3569. /**
  3570. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3571. * @param q1 defines the second operand
  3572. * @returns the currentupdated quaternion
  3573. */
  3574. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3575. /**
  3576. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3577. * @param ref defines the target quaternion
  3578. * @returns the current quaternion
  3579. */
  3580. conjugateToRef(ref: Quaternion): Quaternion;
  3581. /**
  3582. * Conjugates in place (1-q) the current quaternion
  3583. * @returns the current updated quaternion
  3584. */
  3585. conjugateInPlace(): Quaternion;
  3586. /**
  3587. * Conjugates in place (1-q) the current quaternion
  3588. * @returns a new quaternion
  3589. */
  3590. conjugate(): Quaternion;
  3591. /**
  3592. * Gets length of current quaternion
  3593. * @returns the quaternion length (float)
  3594. */
  3595. length(): number;
  3596. /**
  3597. * Normalize in place the current quaternion
  3598. * @returns the current updated quaternion
  3599. */
  3600. normalize(): Quaternion;
  3601. /**
  3602. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3603. * @param order is a reserved parameter and is ignore for now
  3604. * @returns a new Vector3 containing the Euler angles
  3605. */
  3606. toEulerAngles(order?: string): Vector3;
  3607. /**
  3608. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3609. * @param result defines the vector which will be filled with the Euler angles
  3610. * @param order is a reserved parameter and is ignore for now
  3611. * @returns the current unchanged quaternion
  3612. */
  3613. toEulerAnglesToRef(result: Vector3): Quaternion;
  3614. /**
  3615. * Updates the given rotation matrix with the current quaternion values
  3616. * @param result defines the target matrix
  3617. * @returns the current unchanged quaternion
  3618. */
  3619. toRotationMatrix(result: Matrix): Quaternion;
  3620. /**
  3621. * Updates the current quaternion from the given rotation matrix values
  3622. * @param matrix defines the source matrix
  3623. * @returns the current updated quaternion
  3624. */
  3625. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3626. /**
  3627. * Creates a new quaternion from a rotation matrix
  3628. * @param matrix defines the source matrix
  3629. * @returns a new quaternion created from the given rotation matrix values
  3630. */
  3631. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3632. /**
  3633. * Updates the given quaternion with the given rotation matrix values
  3634. * @param matrix defines the source matrix
  3635. * @param result defines the target quaternion
  3636. */
  3637. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3638. /**
  3639. * Returns the dot product (float) between the quaternions "left" and "right"
  3640. * @param left defines the left operand
  3641. * @param right defines the right operand
  3642. * @returns the dot product
  3643. */
  3644. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3645. /**
  3646. * Checks if the two quaternions are close to each other
  3647. * @param quat0 defines the first quaternion to check
  3648. * @param quat1 defines the second quaternion to check
  3649. * @returns true if the two quaternions are close to each other
  3650. */
  3651. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3652. /**
  3653. * Creates an empty quaternion
  3654. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3655. */
  3656. static Zero(): Quaternion;
  3657. /**
  3658. * Inverse a given quaternion
  3659. * @param q defines the source quaternion
  3660. * @returns a new quaternion as the inverted current quaternion
  3661. */
  3662. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3663. /**
  3664. * Inverse a given quaternion
  3665. * @param q defines the source quaternion
  3666. * @param result the quaternion the result will be stored in
  3667. * @returns the result quaternion
  3668. */
  3669. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3670. /**
  3671. * Creates an identity quaternion
  3672. * @returns the identity quaternion
  3673. */
  3674. static Identity(): Quaternion;
  3675. /**
  3676. * Gets a boolean indicating if the given quaternion is identity
  3677. * @param quaternion defines the quaternion to check
  3678. * @returns true if the quaternion is identity
  3679. */
  3680. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3681. /**
  3682. * Creates a quaternion from a rotation around an axis
  3683. * @param axis defines the axis to use
  3684. * @param angle defines the angle to use
  3685. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3686. */
  3687. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3688. /**
  3689. * Creates a rotation around an axis and stores it into the given quaternion
  3690. * @param axis defines the axis to use
  3691. * @param angle defines the angle to use
  3692. * @param result defines the target quaternion
  3693. * @returns the target quaternion
  3694. */
  3695. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3696. /**
  3697. * Creates a new quaternion from data stored into an array
  3698. * @param array defines the data source
  3699. * @param offset defines the offset in the source array where the data starts
  3700. * @returns a new quaternion
  3701. */
  3702. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3703. /**
  3704. * Create a quaternion from Euler rotation angles
  3705. * @param x Pitch
  3706. * @param y Yaw
  3707. * @param z Roll
  3708. * @returns the new Quaternion
  3709. */
  3710. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3711. /**
  3712. * Updates a quaternion from Euler rotation angles
  3713. * @param x Pitch
  3714. * @param y Yaw
  3715. * @param z Roll
  3716. * @param result the quaternion to store the result
  3717. * @returns the updated quaternion
  3718. */
  3719. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3720. /**
  3721. * Create a quaternion from Euler rotation vector
  3722. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3723. * @returns the new Quaternion
  3724. */
  3725. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3726. /**
  3727. * Updates a quaternion from Euler rotation vector
  3728. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3729. * @param result the quaternion to store the result
  3730. * @returns the updated quaternion
  3731. */
  3732. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3733. /**
  3734. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3735. * @param yaw defines the rotation around Y axis
  3736. * @param pitch defines the rotation around X axis
  3737. * @param roll defines the rotation around Z axis
  3738. * @returns the new quaternion
  3739. */
  3740. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3741. /**
  3742. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3743. * @param yaw defines the rotation around Y axis
  3744. * @param pitch defines the rotation around X axis
  3745. * @param roll defines the rotation around Z axis
  3746. * @param result defines the target quaternion
  3747. */
  3748. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3749. /**
  3750. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3751. * @param alpha defines the rotation around first axis
  3752. * @param beta defines the rotation around second axis
  3753. * @param gamma defines the rotation around third axis
  3754. * @returns the new quaternion
  3755. */
  3756. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3757. /**
  3758. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3759. * @param alpha defines the rotation around first axis
  3760. * @param beta defines the rotation around second axis
  3761. * @param gamma defines the rotation around third axis
  3762. * @param result defines the target quaternion
  3763. */
  3764. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3765. /**
  3766. * 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)
  3767. * @param axis1 defines the first axis
  3768. * @param axis2 defines the second axis
  3769. * @param axis3 defines the third axis
  3770. * @returns the new quaternion
  3771. */
  3772. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3773. /**
  3774. * 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
  3775. * @param axis1 defines the first axis
  3776. * @param axis2 defines the second axis
  3777. * @param axis3 defines the third axis
  3778. * @param ref defines the target quaternion
  3779. */
  3780. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3781. /**
  3782. * Interpolates between two quaternions
  3783. * @param left defines first quaternion
  3784. * @param right defines second quaternion
  3785. * @param amount defines the gradient to use
  3786. * @returns the new interpolated quaternion
  3787. */
  3788. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3789. /**
  3790. * Interpolates between two quaternions and stores it into a target quaternion
  3791. * @param left defines first quaternion
  3792. * @param right defines second quaternion
  3793. * @param amount defines the gradient to use
  3794. * @param result defines the target quaternion
  3795. */
  3796. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3797. /**
  3798. * Interpolate between two quaternions using Hermite interpolation
  3799. * @param value1 defines first quaternion
  3800. * @param tangent1 defines the incoming tangent
  3801. * @param value2 defines second quaternion
  3802. * @param tangent2 defines the outgoing tangent
  3803. * @param amount defines the target quaternion
  3804. * @returns the new interpolated quaternion
  3805. */
  3806. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3807. }
  3808. /**
  3809. * Class used to store matrix data (4x4)
  3810. */
  3811. export class Matrix {
  3812. private static _updateFlagSeed;
  3813. private static _identityReadOnly;
  3814. private _isIdentity;
  3815. private _isIdentityDirty;
  3816. private _isIdentity3x2;
  3817. private _isIdentity3x2Dirty;
  3818. /**
  3819. * Gets the update flag of the matrix which is an unique number for the matrix.
  3820. * It will be incremented every time the matrix data change.
  3821. * You can use it to speed the comparison between two versions of the same matrix.
  3822. */
  3823. updateFlag: number;
  3824. private readonly _m;
  3825. /**
  3826. * Gets the internal data of the matrix
  3827. */
  3828. readonly m: DeepImmutable<Float32Array>;
  3829. /** @hidden */
  3830. _markAsUpdated(): void;
  3831. /** @hidden */
  3832. private _updateIdentityStatus;
  3833. /**
  3834. * Creates an empty matrix (filled with zeros)
  3835. */
  3836. constructor();
  3837. /**
  3838. * Check if the current matrix is identity
  3839. * @returns true is the matrix is the identity matrix
  3840. */
  3841. isIdentity(): boolean;
  3842. /**
  3843. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3844. * @returns true is the matrix is the identity matrix
  3845. */
  3846. isIdentityAs3x2(): boolean;
  3847. /**
  3848. * Gets the determinant of the matrix
  3849. * @returns the matrix determinant
  3850. */
  3851. determinant(): number;
  3852. /**
  3853. * Returns the matrix as a Float32Array
  3854. * @returns the matrix underlying array
  3855. */
  3856. toArray(): DeepImmutable<Float32Array>;
  3857. /**
  3858. * Returns the matrix as a Float32Array
  3859. * @returns the matrix underlying array.
  3860. */
  3861. asArray(): DeepImmutable<Float32Array>;
  3862. /**
  3863. * Inverts the current matrix in place
  3864. * @returns the current inverted matrix
  3865. */
  3866. invert(): Matrix;
  3867. /**
  3868. * Sets all the matrix elements to zero
  3869. * @returns the current matrix
  3870. */
  3871. reset(): Matrix;
  3872. /**
  3873. * Adds the current matrix with a second one
  3874. * @param other defines the matrix to add
  3875. * @returns a new matrix as the addition of the current matrix and the given one
  3876. */
  3877. add(other: DeepImmutable<Matrix>): Matrix;
  3878. /**
  3879. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3880. * @param other defines the matrix to add
  3881. * @param result defines the target matrix
  3882. * @returns the current matrix
  3883. */
  3884. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3885. /**
  3886. * Adds in place the given matrix to the current matrix
  3887. * @param other defines the second operand
  3888. * @returns the current updated matrix
  3889. */
  3890. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3891. /**
  3892. * Sets the given matrix to the current inverted Matrix
  3893. * @param other defines the target matrix
  3894. * @returns the unmodified current matrix
  3895. */
  3896. invertToRef(other: Matrix): Matrix;
  3897. /**
  3898. * add a value at the specified position in the current Matrix
  3899. * @param index the index of the value within the matrix. between 0 and 15.
  3900. * @param value the value to be added
  3901. * @returns the current updated matrix
  3902. */
  3903. addAtIndex(index: number, value: number): Matrix;
  3904. /**
  3905. * mutiply the specified position in the current Matrix by a value
  3906. * @param index the index of the value within the matrix. between 0 and 15.
  3907. * @param value the value to be added
  3908. * @returns the current updated matrix
  3909. */
  3910. multiplyAtIndex(index: number, value: number): Matrix;
  3911. /**
  3912. * Inserts the translation vector (using 3 floats) in the current matrix
  3913. * @param x defines the 1st component of the translation
  3914. * @param y defines the 2nd component of the translation
  3915. * @param z defines the 3rd component of the translation
  3916. * @returns the current updated matrix
  3917. */
  3918. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3919. /**
  3920. * Adds the translation vector (using 3 floats) in the current matrix
  3921. * @param x defines the 1st component of the translation
  3922. * @param y defines the 2nd component of the translation
  3923. * @param z defines the 3rd component of the translation
  3924. * @returns the current updated matrix
  3925. */
  3926. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3927. /**
  3928. * Inserts the translation vector in the current matrix
  3929. * @param vector3 defines the translation to insert
  3930. * @returns the current updated matrix
  3931. */
  3932. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3933. /**
  3934. * Gets the translation value of the current matrix
  3935. * @returns a new Vector3 as the extracted translation from the matrix
  3936. */
  3937. getTranslation(): Vector3;
  3938. /**
  3939. * Fill a Vector3 with the extracted translation from the matrix
  3940. * @param result defines the Vector3 where to store the translation
  3941. * @returns the current matrix
  3942. */
  3943. getTranslationToRef(result: Vector3): Matrix;
  3944. /**
  3945. * Remove rotation and scaling part from the matrix
  3946. * @returns the updated matrix
  3947. */
  3948. removeRotationAndScaling(): Matrix;
  3949. /**
  3950. * Multiply two matrices
  3951. * @param other defines the second operand
  3952. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3953. */
  3954. multiply(other: DeepImmutable<Matrix>): Matrix;
  3955. /**
  3956. * Copy the current matrix from the given one
  3957. * @param other defines the source matrix
  3958. * @returns the current updated matrix
  3959. */
  3960. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3961. /**
  3962. * Populates the given array from the starting index with the current matrix values
  3963. * @param array defines the target array
  3964. * @param offset defines the offset in the target array where to start storing values
  3965. * @returns the current matrix
  3966. */
  3967. copyToArray(array: Float32Array, offset?: number): Matrix;
  3968. /**
  3969. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3970. * @param other defines the second operand
  3971. * @param result defines the matrix where to store the multiplication
  3972. * @returns the current matrix
  3973. */
  3974. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3975. /**
  3976. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3977. * @param other defines the second operand
  3978. * @param result defines the array where to store the multiplication
  3979. * @param offset defines the offset in the target array where to start storing values
  3980. * @returns the current matrix
  3981. */
  3982. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3983. /**
  3984. * Check equality between this matrix and a second one
  3985. * @param value defines the second matrix to compare
  3986. * @returns true is the current matrix and the given one values are strictly equal
  3987. */
  3988. equals(value: DeepImmutable<Matrix>): boolean;
  3989. /**
  3990. * Clone the current matrix
  3991. * @returns a new matrix from the current matrix
  3992. */
  3993. clone(): Matrix;
  3994. /**
  3995. * Returns the name of the current matrix class
  3996. * @returns the string "Matrix"
  3997. */
  3998. getClassName(): string;
  3999. /**
  4000. * Gets the hash code of the current matrix
  4001. * @returns the hash code
  4002. */
  4003. getHashCode(): number;
  4004. /**
  4005. * Decomposes the current Matrix into a translation, rotation and scaling components
  4006. * @param scale defines the scale vector3 given as a reference to update
  4007. * @param rotation defines the rotation quaternion given as a reference to update
  4008. * @param translation defines the translation vector3 given as a reference to update
  4009. * @returns true if operation was successful
  4010. */
  4011. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4012. /**
  4013. * Gets specific row of the matrix
  4014. * @param index defines the number of the row to get
  4015. * @returns the index-th row of the current matrix as a new Vector4
  4016. */
  4017. getRow(index: number): Nullable<Vector4>;
  4018. /**
  4019. * Sets the index-th row of the current matrix to the vector4 values
  4020. * @param index defines the number of the row to set
  4021. * @param row defines the target vector4
  4022. * @returns the updated current matrix
  4023. */
  4024. setRow(index: number, row: Vector4): Matrix;
  4025. /**
  4026. * Compute the transpose of the matrix
  4027. * @returns the new transposed matrix
  4028. */
  4029. transpose(): Matrix;
  4030. /**
  4031. * Compute the transpose of the matrix and store it in a given matrix
  4032. * @param result defines the target matrix
  4033. * @returns the current matrix
  4034. */
  4035. transposeToRef(result: Matrix): Matrix;
  4036. /**
  4037. * Sets the index-th row of the current matrix with the given 4 x float values
  4038. * @param index defines the row index
  4039. * @param x defines the x component to set
  4040. * @param y defines the y component to set
  4041. * @param z defines the z component to set
  4042. * @param w defines the w component to set
  4043. * @returns the updated current matrix
  4044. */
  4045. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4046. /**
  4047. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4048. * @param scale defines the scale factor
  4049. * @returns a new matrix
  4050. */
  4051. scale(scale: number): Matrix;
  4052. /**
  4053. * Scale the current matrix values by a factor to a given result matrix
  4054. * @param scale defines the scale factor
  4055. * @param result defines the matrix to store the result
  4056. * @returns the current matrix
  4057. */
  4058. scaleToRef(scale: number, result: Matrix): Matrix;
  4059. /**
  4060. * Scale the current matrix values by a factor and add the result to a given matrix
  4061. * @param scale defines the scale factor
  4062. * @param result defines the Matrix to store the result
  4063. * @returns the current matrix
  4064. */
  4065. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4066. /**
  4067. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4068. * @param ref matrix to store the result
  4069. */
  4070. toNormalMatrix(ref: Matrix): void;
  4071. /**
  4072. * Gets only rotation part of the current matrix
  4073. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4074. */
  4075. getRotationMatrix(): Matrix;
  4076. /**
  4077. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4078. * @param result defines the target matrix to store data to
  4079. * @returns the current matrix
  4080. */
  4081. getRotationMatrixToRef(result: Matrix): Matrix;
  4082. /**
  4083. * Toggles model matrix from being right handed to left handed in place and vice versa
  4084. */
  4085. toggleModelMatrixHandInPlace(): void;
  4086. /**
  4087. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4088. */
  4089. toggleProjectionMatrixHandInPlace(): void;
  4090. /**
  4091. * Creates a matrix from an array
  4092. * @param array defines the source array
  4093. * @param offset defines an offset in the source array
  4094. * @returns a new Matrix set from the starting index of the given array
  4095. */
  4096. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4097. /**
  4098. * Copy the content of an array into a given matrix
  4099. * @param array defines the source array
  4100. * @param offset defines an offset in the source array
  4101. * @param result defines the target matrix
  4102. */
  4103. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4104. /**
  4105. * Stores an array into a matrix after having multiplied each component by a given factor
  4106. * @param array defines the source array
  4107. * @param offset defines the offset in the source array
  4108. * @param scale defines the scaling factor
  4109. * @param result defines the target matrix
  4110. */
  4111. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4112. /**
  4113. * Gets an identity matrix that must not be updated
  4114. */
  4115. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4116. /**
  4117. * Stores a list of values (16) inside a given matrix
  4118. * @param initialM11 defines 1st value of 1st row
  4119. * @param initialM12 defines 2nd value of 1st row
  4120. * @param initialM13 defines 3rd value of 1st row
  4121. * @param initialM14 defines 4th value of 1st row
  4122. * @param initialM21 defines 1st value of 2nd row
  4123. * @param initialM22 defines 2nd value of 2nd row
  4124. * @param initialM23 defines 3rd value of 2nd row
  4125. * @param initialM24 defines 4th value of 2nd row
  4126. * @param initialM31 defines 1st value of 3rd row
  4127. * @param initialM32 defines 2nd value of 3rd row
  4128. * @param initialM33 defines 3rd value of 3rd row
  4129. * @param initialM34 defines 4th value of 3rd row
  4130. * @param initialM41 defines 1st value of 4th row
  4131. * @param initialM42 defines 2nd value of 4th row
  4132. * @param initialM43 defines 3rd value of 4th row
  4133. * @param initialM44 defines 4th value of 4th row
  4134. * @param result defines the target matrix
  4135. */
  4136. 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;
  4137. /**
  4138. * Creates new matrix from a list of values (16)
  4139. * @param initialM11 defines 1st value of 1st row
  4140. * @param initialM12 defines 2nd value of 1st row
  4141. * @param initialM13 defines 3rd value of 1st row
  4142. * @param initialM14 defines 4th value of 1st row
  4143. * @param initialM21 defines 1st value of 2nd row
  4144. * @param initialM22 defines 2nd value of 2nd row
  4145. * @param initialM23 defines 3rd value of 2nd row
  4146. * @param initialM24 defines 4th value of 2nd row
  4147. * @param initialM31 defines 1st value of 3rd row
  4148. * @param initialM32 defines 2nd value of 3rd row
  4149. * @param initialM33 defines 3rd value of 3rd row
  4150. * @param initialM34 defines 4th value of 3rd row
  4151. * @param initialM41 defines 1st value of 4th row
  4152. * @param initialM42 defines 2nd value of 4th row
  4153. * @param initialM43 defines 3rd value of 4th row
  4154. * @param initialM44 defines 4th value of 4th row
  4155. * @returns the new matrix
  4156. */
  4157. 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;
  4158. /**
  4159. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4160. * @param scale defines the scale vector3
  4161. * @param rotation defines the rotation quaternion
  4162. * @param translation defines the translation vector3
  4163. * @returns a new matrix
  4164. */
  4165. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4166. /**
  4167. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4168. * @param scale defines the scale vector3
  4169. * @param rotation defines the rotation quaternion
  4170. * @param translation defines the translation vector3
  4171. * @param result defines the target matrix
  4172. */
  4173. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4174. /**
  4175. * Creates a new identity matrix
  4176. * @returns a new identity matrix
  4177. */
  4178. static Identity(): Matrix;
  4179. /**
  4180. * Creates a new identity matrix and stores the result in a given matrix
  4181. * @param result defines the target matrix
  4182. */
  4183. static IdentityToRef(result: Matrix): void;
  4184. /**
  4185. * Creates a new zero matrix
  4186. * @returns a new zero matrix
  4187. */
  4188. static Zero(): Matrix;
  4189. /**
  4190. * Creates a new rotation matrix for "angle" radians around the X axis
  4191. * @param angle defines the angle (in radians) to use
  4192. * @return the new matrix
  4193. */
  4194. static RotationX(angle: number): Matrix;
  4195. /**
  4196. * Creates a new matrix as the invert of a given matrix
  4197. * @param source defines the source matrix
  4198. * @returns the new matrix
  4199. */
  4200. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4201. /**
  4202. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4203. * @param angle defines the angle (in radians) to use
  4204. * @param result defines the target matrix
  4205. */
  4206. static RotationXToRef(angle: number, result: Matrix): void;
  4207. /**
  4208. * Creates a new rotation matrix for "angle" radians around the Y axis
  4209. * @param angle defines the angle (in radians) to use
  4210. * @return the new matrix
  4211. */
  4212. static RotationY(angle: number): Matrix;
  4213. /**
  4214. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4215. * @param angle defines the angle (in radians) to use
  4216. * @param result defines the target matrix
  4217. */
  4218. static RotationYToRef(angle: number, result: Matrix): void;
  4219. /**
  4220. * Creates a new rotation matrix for "angle" radians around the Z axis
  4221. * @param angle defines the angle (in radians) to use
  4222. * @return the new matrix
  4223. */
  4224. static RotationZ(angle: number): Matrix;
  4225. /**
  4226. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4227. * @param angle defines the angle (in radians) to use
  4228. * @param result defines the target matrix
  4229. */
  4230. static RotationZToRef(angle: number, result: Matrix): void;
  4231. /**
  4232. * Creates a new rotation matrix for "angle" radians around the given axis
  4233. * @param axis defines the axis to use
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4240. * @param axis defines the axis to use
  4241. * @param angle defines the angle (in radians) to use
  4242. * @param result defines the target matrix
  4243. */
  4244. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4245. /**
  4246. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4247. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4248. * @param from defines the vector to align
  4249. * @param to defines the vector to align to
  4250. * @param result defines the target matrix
  4251. */
  4252. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4253. /**
  4254. * Creates a rotation matrix
  4255. * @param yaw defines the yaw angle in radians (Y axis)
  4256. * @param pitch defines the pitch angle in radians (X axis)
  4257. * @param roll defines the roll angle in radians (X axis)
  4258. * @returns the new rotation matrix
  4259. */
  4260. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4261. /**
  4262. * Creates a rotation matrix and stores it in a given matrix
  4263. * @param yaw defines the yaw angle in radians (Y axis)
  4264. * @param pitch defines the pitch angle in radians (X axis)
  4265. * @param roll defines the roll angle in radians (X axis)
  4266. * @param result defines the target matrix
  4267. */
  4268. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4269. /**
  4270. * Creates a scaling matrix
  4271. * @param x defines the scale factor on X axis
  4272. * @param y defines the scale factor on Y axis
  4273. * @param z defines the scale factor on Z axis
  4274. * @returns the new matrix
  4275. */
  4276. static Scaling(x: number, y: number, z: number): Matrix;
  4277. /**
  4278. * Creates a scaling matrix and stores it in a given matrix
  4279. * @param x defines the scale factor on X axis
  4280. * @param y defines the scale factor on Y axis
  4281. * @param z defines the scale factor on Z axis
  4282. * @param result defines the target matrix
  4283. */
  4284. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4285. /**
  4286. * Creates a translation matrix
  4287. * @param x defines the translation on X axis
  4288. * @param y defines the translation on Y axis
  4289. * @param z defines the translationon Z axis
  4290. * @returns the new matrix
  4291. */
  4292. static Translation(x: number, y: number, z: number): Matrix;
  4293. /**
  4294. * Creates a translation matrix and stores it in a given matrix
  4295. * @param x defines the translation on X axis
  4296. * @param y defines the translation on Y axis
  4297. * @param z defines the translationon Z axis
  4298. * @param result defines the target matrix
  4299. */
  4300. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4301. /**
  4302. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4303. * @param startValue defines the start value
  4304. * @param endValue defines the end value
  4305. * @param gradient defines the gradient factor
  4306. * @returns the new matrix
  4307. */
  4308. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4309. /**
  4310. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4311. * @param startValue defines the start value
  4312. * @param endValue defines the end value
  4313. * @param gradient defines the gradient factor
  4314. * @param result defines the Matrix object where to store data
  4315. */
  4316. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4317. /**
  4318. * Builds a new matrix whose values are computed by:
  4319. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4320. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4321. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4322. * @param startValue defines the first matrix
  4323. * @param endValue defines the second matrix
  4324. * @param gradient defines the gradient between the two matrices
  4325. * @returns the new matrix
  4326. */
  4327. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4328. /**
  4329. * Update a matrix to values which are computed by:
  4330. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4331. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4332. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4333. * @param startValue defines the first matrix
  4334. * @param endValue defines the second matrix
  4335. * @param gradient defines the gradient between the two matrices
  4336. * @param result defines the target matrix
  4337. */
  4338. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4339. /**
  4340. * 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"
  4341. * This function works in left handed mode
  4342. * @param eye defines the final position of the entity
  4343. * @param target defines where the entity should look at
  4344. * @param up defines the up vector for the entity
  4345. * @returns the new matrix
  4346. */
  4347. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4348. /**
  4349. * 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".
  4350. * This function works in left handed mode
  4351. * @param eye defines the final position of the entity
  4352. * @param target defines where the entity should look at
  4353. * @param up defines the up vector for the entity
  4354. * @param result defines the target matrix
  4355. */
  4356. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4357. /**
  4358. * 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"
  4359. * This function works in right handed mode
  4360. * @param eye defines the final position of the entity
  4361. * @param target defines where the entity should look at
  4362. * @param up defines the up vector for the entity
  4363. * @returns the new matrix
  4364. */
  4365. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4366. /**
  4367. * 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".
  4368. * This function works in right handed mode
  4369. * @param eye defines the final position of the entity
  4370. * @param target defines where the entity should look at
  4371. * @param up defines the up vector for the entity
  4372. * @param result defines the target matrix
  4373. */
  4374. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4375. /**
  4376. * Create a left-handed orthographic projection matrix
  4377. * @param width defines the viewport width
  4378. * @param height defines the viewport height
  4379. * @param znear defines the near clip plane
  4380. * @param zfar defines the far clip plane
  4381. * @returns a new matrix as a left-handed orthographic projection matrix
  4382. */
  4383. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4384. /**
  4385. * Store a left-handed orthographic projection to a given matrix
  4386. * @param width defines the viewport width
  4387. * @param height defines the viewport height
  4388. * @param znear defines the near clip plane
  4389. * @param zfar defines the far clip plane
  4390. * @param result defines the target matrix
  4391. */
  4392. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4393. /**
  4394. * Create a left-handed orthographic projection matrix
  4395. * @param left defines the viewport left coordinate
  4396. * @param right defines the viewport right coordinate
  4397. * @param bottom defines the viewport bottom coordinate
  4398. * @param top defines the viewport top coordinate
  4399. * @param znear defines the near clip plane
  4400. * @param zfar defines the far clip plane
  4401. * @returns a new matrix as a left-handed orthographic projection matrix
  4402. */
  4403. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4404. /**
  4405. * Stores a left-handed orthographic projection into a given matrix
  4406. * @param left defines the viewport left coordinate
  4407. * @param right defines the viewport right coordinate
  4408. * @param bottom defines the viewport bottom coordinate
  4409. * @param top defines the viewport top coordinate
  4410. * @param znear defines the near clip plane
  4411. * @param zfar defines the far clip plane
  4412. * @param result defines the target matrix
  4413. */
  4414. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4415. /**
  4416. * Creates a right-handed orthographic projection matrix
  4417. * @param left defines the viewport left coordinate
  4418. * @param right defines the viewport right coordinate
  4419. * @param bottom defines the viewport bottom coordinate
  4420. * @param top defines the viewport top coordinate
  4421. * @param znear defines the near clip plane
  4422. * @param zfar defines the far clip plane
  4423. * @returns a new matrix as a right-handed orthographic projection matrix
  4424. */
  4425. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4426. /**
  4427. * Stores a right-handed orthographic projection into a given matrix
  4428. * @param left defines the viewport left coordinate
  4429. * @param right defines the viewport right coordinate
  4430. * @param bottom defines the viewport bottom coordinate
  4431. * @param top defines the viewport top coordinate
  4432. * @param znear defines the near clip plane
  4433. * @param zfar defines the far clip plane
  4434. * @param result defines the target matrix
  4435. */
  4436. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4437. /**
  4438. * Creates a left-handed perspective projection matrix
  4439. * @param width defines the viewport width
  4440. * @param height defines the viewport height
  4441. * @param znear defines the near clip plane
  4442. * @param zfar defines the far clip plane
  4443. * @returns a new matrix as a left-handed perspective projection matrix
  4444. */
  4445. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4446. /**
  4447. * Creates a left-handed perspective projection matrix
  4448. * @param fov defines the horizontal field of view
  4449. * @param aspect defines the aspect ratio
  4450. * @param znear defines the near clip plane
  4451. * @param zfar defines the far clip plane
  4452. * @returns a new matrix as a left-handed perspective projection matrix
  4453. */
  4454. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4455. /**
  4456. * Stores a left-handed perspective projection into a given matrix
  4457. * @param fov defines the horizontal field of view
  4458. * @param aspect defines the aspect ratio
  4459. * @param znear defines the near clip plane
  4460. * @param zfar defines the far clip plane
  4461. * @param result defines the target matrix
  4462. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4463. */
  4464. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4465. /**
  4466. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4467. * @param fov defines the horizontal field of view
  4468. * @param aspect defines the aspect ratio
  4469. * @param znear defines the near clip plane
  4470. * @param zfar not used as infinity is used as far clip
  4471. * @param result defines the target matrix
  4472. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4473. */
  4474. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4475. /**
  4476. * Creates a right-handed perspective projection matrix
  4477. * @param fov defines the horizontal field of view
  4478. * @param aspect defines the aspect ratio
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @returns a new matrix as a right-handed perspective projection matrix
  4482. */
  4483. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4484. /**
  4485. * Stores a right-handed perspective projection into a given matrix
  4486. * @param fov defines the horizontal field of view
  4487. * @param aspect defines the aspect ratio
  4488. * @param znear defines the near clip plane
  4489. * @param zfar defines the far clip plane
  4490. * @param result defines the target matrix
  4491. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4492. */
  4493. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4494. /**
  4495. * Stores a right-handed perspective projection into a given matrix
  4496. * @param fov defines the horizontal field of view
  4497. * @param aspect defines the aspect ratio
  4498. * @param znear defines the near clip plane
  4499. * @param zfar not used as infinity is used as far clip
  4500. * @param result defines the target matrix
  4501. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4502. */
  4503. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4504. /**
  4505. * Stores a perspective projection for WebVR info a given matrix
  4506. * @param fov defines the field of view
  4507. * @param znear defines the near clip plane
  4508. * @param zfar defines the far clip plane
  4509. * @param result defines the target matrix
  4510. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4511. */
  4512. static PerspectiveFovWebVRToRef(fov: {
  4513. upDegrees: number;
  4514. downDegrees: number;
  4515. leftDegrees: number;
  4516. rightDegrees: number;
  4517. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4518. /**
  4519. * Computes a complete transformation matrix
  4520. * @param viewport defines the viewport to use
  4521. * @param world defines the world matrix
  4522. * @param view defines the view matrix
  4523. * @param projection defines the projection matrix
  4524. * @param zmin defines the near clip plane
  4525. * @param zmax defines the far clip plane
  4526. * @returns the transformation matrix
  4527. */
  4528. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4529. /**
  4530. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4531. * @param matrix defines the matrix to use
  4532. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4533. */
  4534. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4535. /**
  4536. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4537. * @param matrix defines the matrix to use
  4538. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4539. */
  4540. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4541. /**
  4542. * Compute the transpose of a given matrix
  4543. * @param matrix defines the matrix to transpose
  4544. * @returns the new matrix
  4545. */
  4546. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4547. /**
  4548. * Compute the transpose of a matrix and store it in a target matrix
  4549. * @param matrix defines the matrix to transpose
  4550. * @param result defines the target matrix
  4551. */
  4552. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4553. /**
  4554. * Computes a reflection matrix from a plane
  4555. * @param plane defines the reflection plane
  4556. * @returns a new matrix
  4557. */
  4558. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4559. /**
  4560. * Computes a reflection matrix from a plane
  4561. * @param plane defines the reflection plane
  4562. * @param result defines the target matrix
  4563. */
  4564. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4565. /**
  4566. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4567. * @param xaxis defines the value of the 1st axis
  4568. * @param yaxis defines the value of the 2nd axis
  4569. * @param zaxis defines the value of the 3rd axis
  4570. * @param result defines the target matrix
  4571. */
  4572. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4573. /**
  4574. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4575. * @param quat defines the quaternion to use
  4576. * @param result defines the target matrix
  4577. */
  4578. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4579. }
  4580. /**
  4581. * @hidden
  4582. */
  4583. export class TmpVectors {
  4584. static Vector2: Vector2[];
  4585. static Vector3: Vector3[];
  4586. static Vector4: Vector4[];
  4587. static Quaternion: Quaternion[];
  4588. static Matrix: Matrix[];
  4589. }
  4590. }
  4591. declare module BABYLON {
  4592. /**
  4593. * Defines potential orientation for back face culling
  4594. */
  4595. export enum Orientation {
  4596. /**
  4597. * Clockwise
  4598. */
  4599. CW = 0,
  4600. /** Counter clockwise */
  4601. CCW = 1
  4602. }
  4603. /** Class used to represent a Bezier curve */
  4604. export class BezierCurve {
  4605. /**
  4606. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4607. * @param t defines the time
  4608. * @param x1 defines the left coordinate on X axis
  4609. * @param y1 defines the left coordinate on Y axis
  4610. * @param x2 defines the right coordinate on X axis
  4611. * @param y2 defines the right coordinate on Y axis
  4612. * @returns the interpolated value
  4613. */
  4614. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4615. }
  4616. /**
  4617. * Defines angle representation
  4618. */
  4619. export class Angle {
  4620. private _radians;
  4621. /**
  4622. * Creates an Angle object of "radians" radians (float).
  4623. * @param radians the angle in radians
  4624. */
  4625. constructor(radians: number);
  4626. /**
  4627. * Get value in degrees
  4628. * @returns the Angle value in degrees (float)
  4629. */
  4630. degrees(): number;
  4631. /**
  4632. * Get value in radians
  4633. * @returns the Angle value in radians (float)
  4634. */
  4635. radians(): number;
  4636. /**
  4637. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4638. * @param a defines first vector
  4639. * @param b defines second vector
  4640. * @returns a new Angle
  4641. */
  4642. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4643. /**
  4644. * Gets a new Angle object from the given float in radians
  4645. * @param radians defines the angle value in radians
  4646. * @returns a new Angle
  4647. */
  4648. static FromRadians(radians: number): Angle;
  4649. /**
  4650. * Gets a new Angle object from the given float in degrees
  4651. * @param degrees defines the angle value in degrees
  4652. * @returns a new Angle
  4653. */
  4654. static FromDegrees(degrees: number): Angle;
  4655. }
  4656. /**
  4657. * This represents an arc in a 2d space.
  4658. */
  4659. export class Arc2 {
  4660. /** Defines the start point of the arc */
  4661. startPoint: Vector2;
  4662. /** Defines the mid point of the arc */
  4663. midPoint: Vector2;
  4664. /** Defines the end point of the arc */
  4665. endPoint: Vector2;
  4666. /**
  4667. * Defines the center point of the arc.
  4668. */
  4669. centerPoint: Vector2;
  4670. /**
  4671. * Defines the radius of the arc.
  4672. */
  4673. radius: number;
  4674. /**
  4675. * Defines the angle of the arc (from mid point to end point).
  4676. */
  4677. angle: Angle;
  4678. /**
  4679. * Defines the start angle of the arc (from start point to middle point).
  4680. */
  4681. startAngle: Angle;
  4682. /**
  4683. * Defines the orientation of the arc (clock wise/counter clock wise).
  4684. */
  4685. orientation: Orientation;
  4686. /**
  4687. * Creates an Arc object from the three given points : start, middle and end.
  4688. * @param startPoint Defines the start point of the arc
  4689. * @param midPoint Defines the midlle point of the arc
  4690. * @param endPoint Defines the end point of the arc
  4691. */
  4692. constructor(
  4693. /** Defines the start point of the arc */
  4694. startPoint: Vector2,
  4695. /** Defines the mid point of the arc */
  4696. midPoint: Vector2,
  4697. /** Defines the end point of the arc */
  4698. endPoint: Vector2);
  4699. }
  4700. /**
  4701. * Represents a 2D path made up of multiple 2D points
  4702. */
  4703. export class Path2 {
  4704. private _points;
  4705. private _length;
  4706. /**
  4707. * If the path start and end point are the same
  4708. */
  4709. closed: boolean;
  4710. /**
  4711. * Creates a Path2 object from the starting 2D coordinates x and y.
  4712. * @param x the starting points x value
  4713. * @param y the starting points y value
  4714. */
  4715. constructor(x: number, y: number);
  4716. /**
  4717. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4718. * @param x the added points x value
  4719. * @param y the added points y value
  4720. * @returns the updated Path2.
  4721. */
  4722. addLineTo(x: number, y: number): Path2;
  4723. /**
  4724. * 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.
  4725. * @param midX middle point x value
  4726. * @param midY middle point y value
  4727. * @param endX end point x value
  4728. * @param endY end point y value
  4729. * @param numberOfSegments (default: 36)
  4730. * @returns the updated Path2.
  4731. */
  4732. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4733. /**
  4734. * Closes the Path2.
  4735. * @returns the Path2.
  4736. */
  4737. close(): Path2;
  4738. /**
  4739. * Gets the sum of the distance between each sequential point in the path
  4740. * @returns the Path2 total length (float).
  4741. */
  4742. length(): number;
  4743. /**
  4744. * Gets the points which construct the path
  4745. * @returns the Path2 internal array of points.
  4746. */
  4747. getPoints(): Vector2[];
  4748. /**
  4749. * Retreives the point at the distance aways from the starting point
  4750. * @param normalizedLengthPosition the length along the path to retreive the point from
  4751. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4752. */
  4753. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4754. /**
  4755. * Creates a new path starting from an x and y position
  4756. * @param x starting x value
  4757. * @param y starting y value
  4758. * @returns a new Path2 starting at the coordinates (x, y).
  4759. */
  4760. static StartingAt(x: number, y: number): Path2;
  4761. }
  4762. /**
  4763. * Represents a 3D path made up of multiple 3D points
  4764. */
  4765. export class Path3D {
  4766. /**
  4767. * an array of Vector3, the curve axis of the Path3D
  4768. */
  4769. path: Vector3[];
  4770. private _curve;
  4771. private _distances;
  4772. private _tangents;
  4773. private _normals;
  4774. private _binormals;
  4775. private _raw;
  4776. private _alignTangentsWithPath;
  4777. private readonly _pointAtData;
  4778. /**
  4779. * new Path3D(path, normal, raw)
  4780. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4781. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4782. * @param path an array of Vector3, the curve axis of the Path3D
  4783. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4784. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4785. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4786. */
  4787. constructor(
  4788. /**
  4789. * an array of Vector3, the curve axis of the Path3D
  4790. */
  4791. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4792. /**
  4793. * Returns the Path3D array of successive Vector3 designing its curve.
  4794. * @returns the Path3D array of successive Vector3 designing its curve.
  4795. */
  4796. getCurve(): Vector3[];
  4797. /**
  4798. * Returns the Path3D array of successive Vector3 designing its curve.
  4799. * @returns the Path3D array of successive Vector3 designing its curve.
  4800. */
  4801. getPoints(): Vector3[];
  4802. /**
  4803. * @returns the computed length (float) of the path.
  4804. */
  4805. length(): number;
  4806. /**
  4807. * Returns an array populated with tangent vectors on each Path3D curve point.
  4808. * @returns an array populated with tangent vectors on each Path3D curve point.
  4809. */
  4810. getTangents(): Vector3[];
  4811. /**
  4812. * Returns an array populated with normal vectors on each Path3D curve point.
  4813. * @returns an array populated with normal vectors on each Path3D curve point.
  4814. */
  4815. getNormals(): Vector3[];
  4816. /**
  4817. * Returns an array populated with binormal vectors on each Path3D curve point.
  4818. * @returns an array populated with binormal vectors on each Path3D curve point.
  4819. */
  4820. getBinormals(): Vector3[];
  4821. /**
  4822. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4823. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4824. */
  4825. getDistances(): number[];
  4826. /**
  4827. * Returns an interpolated point along this path
  4828. * @param position the position of the point along this path, from 0.0 to 1.0
  4829. * @returns a new Vector3 as the point
  4830. */
  4831. getPointAt(position: number): Vector3;
  4832. /**
  4833. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4834. * @param position the position of the point along this path, from 0.0 to 1.0
  4835. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4836. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4837. */
  4838. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4839. /**
  4840. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4841. * @param position the position of the point along this path, from 0.0 to 1.0
  4842. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4843. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4844. */
  4845. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4846. /**
  4847. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4848. * @param position the position of the point along this path, from 0.0 to 1.0
  4849. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4850. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4851. */
  4852. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4853. /**
  4854. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4857. */
  4858. getDistanceAt(position: number): number;
  4859. /**
  4860. * Returns the array index of the previous point of an interpolated point along this path
  4861. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4862. * @returns the array index
  4863. */
  4864. getPreviousPointIndexAt(position: number): number;
  4865. /**
  4866. * 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)
  4867. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4868. * @returns the sub position
  4869. */
  4870. getSubPositionAt(position: number): number;
  4871. /**
  4872. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4873. * @param target the vector of which to get the closest position to
  4874. * @returns the position of the closest virtual point on this path to the target vector
  4875. */
  4876. getClosestPositionTo(target: Vector3): number;
  4877. /**
  4878. * Returns a sub path (slice) of this path
  4879. * @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
  4880. * @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
  4881. * @returns a sub path (slice) of this path
  4882. */
  4883. slice(start?: number, end?: number): Path3D;
  4884. /**
  4885. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4886. * @param path path which all values are copied into the curves points
  4887. * @param firstNormal which should be projected onto the curve
  4888. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4889. * @returns the same object updated.
  4890. */
  4891. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4892. private _compute;
  4893. private _getFirstNonNullVector;
  4894. private _getLastNonNullVector;
  4895. private _normalVector;
  4896. /**
  4897. * Updates the point at data for an interpolated point along this curve
  4898. * @param position the position of the point along this curve, from 0.0 to 1.0
  4899. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4900. * @returns the (updated) point at data
  4901. */
  4902. private _updatePointAtData;
  4903. /**
  4904. * Updates the point at data from the specified parameters
  4905. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4906. * @param point the interpolated point
  4907. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4908. */
  4909. private _setPointAtData;
  4910. /**
  4911. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4912. */
  4913. private _updateInterpolationMatrix;
  4914. }
  4915. /**
  4916. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4917. * A Curve3 is designed from a series of successive Vector3.
  4918. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4919. */
  4920. export class Curve3 {
  4921. private _points;
  4922. private _length;
  4923. /**
  4924. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4925. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4926. * @param v1 (Vector3) the control point
  4927. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4928. * @param nbPoints (integer) the wanted number of points in the curve
  4929. * @returns the created Curve3
  4930. */
  4931. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4932. /**
  4933. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4934. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4935. * @param v1 (Vector3) the first control point
  4936. * @param v2 (Vector3) the second control point
  4937. * @param v3 (Vector3) the end point of the Cubic Bezier
  4938. * @param nbPoints (integer) the wanted number of points in the curve
  4939. * @returns the created Curve3
  4940. */
  4941. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4942. /**
  4943. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4944. * @param p1 (Vector3) the origin point of the Hermite Spline
  4945. * @param t1 (Vector3) the tangent vector at the origin point
  4946. * @param p2 (Vector3) the end point of the Hermite Spline
  4947. * @param t2 (Vector3) the tangent vector at the end point
  4948. * @param nbPoints (integer) the wanted number of points in the curve
  4949. * @returns the created Curve3
  4950. */
  4951. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4952. /**
  4953. * Returns a Curve3 object along a CatmullRom Spline curve :
  4954. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4955. * @param nbPoints (integer) the wanted number of points between each curve control points
  4956. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4957. * @returns the created Curve3
  4958. */
  4959. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4960. /**
  4961. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4962. * A Curve3 is designed from a series of successive Vector3.
  4963. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4964. * @param points points which make up the curve
  4965. */
  4966. constructor(points: Vector3[]);
  4967. /**
  4968. * @returns the Curve3 stored array of successive Vector3
  4969. */
  4970. getPoints(): Vector3[];
  4971. /**
  4972. * @returns the computed length (float) of the curve.
  4973. */
  4974. length(): number;
  4975. /**
  4976. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4977. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4978. * curveA and curveB keep unchanged.
  4979. * @param curve the curve to continue from this curve
  4980. * @returns the newly constructed curve
  4981. */
  4982. continue(curve: DeepImmutable<Curve3>): Curve3;
  4983. private _computeLength;
  4984. }
  4985. }
  4986. declare module BABYLON {
  4987. /**
  4988. * This represents the main contract an easing function should follow.
  4989. * Easing functions are used throughout the animation system.
  4990. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4991. */
  4992. export interface IEasingFunction {
  4993. /**
  4994. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4995. * of the easing function.
  4996. * The link below provides some of the most common examples of easing functions.
  4997. * @see https://easings.net/
  4998. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4999. * @returns the corresponding value on the curve defined by the easing function
  5000. */
  5001. ease(gradient: number): number;
  5002. }
  5003. /**
  5004. * Base class used for every default easing function.
  5005. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5006. */
  5007. export class EasingFunction implements IEasingFunction {
  5008. /**
  5009. * Interpolation follows the mathematical formula associated with the easing function.
  5010. */
  5011. static readonly EASINGMODE_EASEIN: number;
  5012. /**
  5013. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5014. */
  5015. static readonly EASINGMODE_EASEOUT: number;
  5016. /**
  5017. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5018. */
  5019. static readonly EASINGMODE_EASEINOUT: number;
  5020. private _easingMode;
  5021. /**
  5022. * Sets the easing mode of the current function.
  5023. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5024. */
  5025. setEasingMode(easingMode: number): void;
  5026. /**
  5027. * Gets the current easing mode.
  5028. * @returns the easing mode
  5029. */
  5030. getEasingMode(): number;
  5031. /**
  5032. * @hidden
  5033. */
  5034. easeInCore(gradient: number): number;
  5035. /**
  5036. * Given an input gradient between 0 and 1, this returns the corresponding value
  5037. * of the easing function.
  5038. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5039. * @returns the corresponding value on the curve defined by the easing function
  5040. */
  5041. ease(gradient: number): number;
  5042. }
  5043. /**
  5044. * Easing function with a circle shape (see link below).
  5045. * @see https://easings.net/#easeInCirc
  5046. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5047. */
  5048. export class CircleEase extends EasingFunction implements IEasingFunction {
  5049. /** @hidden */
  5050. easeInCore(gradient: number): number;
  5051. }
  5052. /**
  5053. * Easing function with a ease back shape (see link below).
  5054. * @see https://easings.net/#easeInBack
  5055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5056. */
  5057. export class BackEase extends EasingFunction implements IEasingFunction {
  5058. /** Defines the amplitude of the function */
  5059. amplitude: number;
  5060. /**
  5061. * Instantiates a back ease easing
  5062. * @see https://easings.net/#easeInBack
  5063. * @param amplitude Defines the amplitude of the function
  5064. */
  5065. constructor(
  5066. /** Defines the amplitude of the function */
  5067. amplitude?: number);
  5068. /** @hidden */
  5069. easeInCore(gradient: number): number;
  5070. }
  5071. /**
  5072. * Easing function with a bouncing shape (see link below).
  5073. * @see https://easings.net/#easeInBounce
  5074. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5075. */
  5076. export class BounceEase extends EasingFunction implements IEasingFunction {
  5077. /** Defines the number of bounces */
  5078. bounces: number;
  5079. /** Defines the amplitude of the bounce */
  5080. bounciness: number;
  5081. /**
  5082. * Instantiates a bounce easing
  5083. * @see https://easings.net/#easeInBounce
  5084. * @param bounces Defines the number of bounces
  5085. * @param bounciness Defines the amplitude of the bounce
  5086. */
  5087. constructor(
  5088. /** Defines the number of bounces */
  5089. bounces?: number,
  5090. /** Defines the amplitude of the bounce */
  5091. bounciness?: number);
  5092. /** @hidden */
  5093. easeInCore(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a power of 3 shape (see link below).
  5097. * @see https://easings.net/#easeInCubic
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class CubicEase extends EasingFunction implements IEasingFunction {
  5101. /** @hidden */
  5102. easeInCore(gradient: number): number;
  5103. }
  5104. /**
  5105. * Easing function with an elastic shape (see link below).
  5106. * @see https://easings.net/#easeInElastic
  5107. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5108. */
  5109. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5110. /** Defines the number of oscillations*/
  5111. oscillations: number;
  5112. /** Defines the amplitude of the oscillations*/
  5113. springiness: number;
  5114. /**
  5115. * Instantiates an elastic easing function
  5116. * @see https://easings.net/#easeInElastic
  5117. * @param oscillations Defines the number of oscillations
  5118. * @param springiness Defines the amplitude of the oscillations
  5119. */
  5120. constructor(
  5121. /** Defines the number of oscillations*/
  5122. oscillations?: number,
  5123. /** Defines the amplitude of the oscillations*/
  5124. springiness?: number);
  5125. /** @hidden */
  5126. easeInCore(gradient: number): number;
  5127. }
  5128. /**
  5129. * Easing function with an exponential shape (see link below).
  5130. * @see https://easings.net/#easeInExpo
  5131. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5132. */
  5133. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5134. /** Defines the exponent of the function */
  5135. exponent: number;
  5136. /**
  5137. * Instantiates an exponential easing function
  5138. * @see https://easings.net/#easeInExpo
  5139. * @param exponent Defines the exponent of the function
  5140. */
  5141. constructor(
  5142. /** Defines the exponent of the function */
  5143. exponent?: number);
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with a power shape (see link below).
  5149. * @see https://easings.net/#easeInQuad
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class PowerEase extends EasingFunction implements IEasingFunction {
  5153. /** Defines the power of the function */
  5154. power: number;
  5155. /**
  5156. * Instantiates an power base easing function
  5157. * @see https://easings.net/#easeInQuad
  5158. * @param power Defines the power of the function
  5159. */
  5160. constructor(
  5161. /** Defines the power of the function */
  5162. power?: number);
  5163. /** @hidden */
  5164. easeInCore(gradient: number): number;
  5165. }
  5166. /**
  5167. * Easing function with a power of 2 shape (see link below).
  5168. * @see https://easings.net/#easeInQuad
  5169. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5170. */
  5171. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5172. /** @hidden */
  5173. easeInCore(gradient: number): number;
  5174. }
  5175. /**
  5176. * Easing function with a power of 4 shape (see link below).
  5177. * @see https://easings.net/#easeInQuart
  5178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5179. */
  5180. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5181. /** @hidden */
  5182. easeInCore(gradient: number): number;
  5183. }
  5184. /**
  5185. * Easing function with a power of 5 shape (see link below).
  5186. * @see https://easings.net/#easeInQuint
  5187. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5188. */
  5189. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5190. /** @hidden */
  5191. easeInCore(gradient: number): number;
  5192. }
  5193. /**
  5194. * Easing function with a sin shape (see link below).
  5195. * @see https://easings.net/#easeInSine
  5196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5197. */
  5198. export class SineEase extends EasingFunction implements IEasingFunction {
  5199. /** @hidden */
  5200. easeInCore(gradient: number): number;
  5201. }
  5202. /**
  5203. * Easing function with a bezier shape (see link below).
  5204. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5205. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5206. */
  5207. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5208. /** Defines the x component of the start tangent in the bezier curve */
  5209. x1: number;
  5210. /** Defines the y component of the start tangent in the bezier curve */
  5211. y1: number;
  5212. /** Defines the x component of the end tangent in the bezier curve */
  5213. x2: number;
  5214. /** Defines the y component of the end tangent in the bezier curve */
  5215. y2: number;
  5216. /**
  5217. * Instantiates a bezier function
  5218. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5219. * @param x1 Defines the x component of the start tangent in the bezier curve
  5220. * @param y1 Defines the y component of the start tangent in the bezier curve
  5221. * @param x2 Defines the x component of the end tangent in the bezier curve
  5222. * @param y2 Defines the y component of the end tangent in the bezier curve
  5223. */
  5224. constructor(
  5225. /** Defines the x component of the start tangent in the bezier curve */
  5226. x1?: number,
  5227. /** Defines the y component of the start tangent in the bezier curve */
  5228. y1?: number,
  5229. /** Defines the x component of the end tangent in the bezier curve */
  5230. x2?: number,
  5231. /** Defines the y component of the end tangent in the bezier curve */
  5232. y2?: number);
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. }
  5237. declare module BABYLON {
  5238. /**
  5239. * Class used to hold a RBG color
  5240. */
  5241. export class Color3 {
  5242. /**
  5243. * Defines the red component (between 0 and 1, default is 0)
  5244. */
  5245. r: number;
  5246. /**
  5247. * Defines the green component (between 0 and 1, default is 0)
  5248. */
  5249. g: number;
  5250. /**
  5251. * Defines the blue component (between 0 and 1, default is 0)
  5252. */
  5253. b: number;
  5254. /**
  5255. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5256. * @param r defines the red component (between 0 and 1, default is 0)
  5257. * @param g defines the green component (between 0 and 1, default is 0)
  5258. * @param b defines the blue component (between 0 and 1, default is 0)
  5259. */
  5260. constructor(
  5261. /**
  5262. * Defines the red component (between 0 and 1, default is 0)
  5263. */
  5264. r?: number,
  5265. /**
  5266. * Defines the green component (between 0 and 1, default is 0)
  5267. */
  5268. g?: number,
  5269. /**
  5270. * Defines the blue component (between 0 and 1, default is 0)
  5271. */
  5272. b?: number);
  5273. /**
  5274. * Creates a string with the Color3 current values
  5275. * @returns the string representation of the Color3 object
  5276. */
  5277. toString(): string;
  5278. /**
  5279. * Returns the string "Color3"
  5280. * @returns "Color3"
  5281. */
  5282. getClassName(): string;
  5283. /**
  5284. * Compute the Color3 hash code
  5285. * @returns an unique number that can be used to hash Color3 objects
  5286. */
  5287. getHashCode(): number;
  5288. /**
  5289. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5290. * @param array defines the array where to store the r,g,b components
  5291. * @param index defines an optional index in the target array to define where to start storing values
  5292. * @returns the current Color3 object
  5293. */
  5294. toArray(array: FloatArray, index?: number): Color3;
  5295. /**
  5296. * Returns a new Color4 object from the current Color3 and the given alpha
  5297. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5298. * @returns a new Color4 object
  5299. */
  5300. toColor4(alpha?: number): Color4;
  5301. /**
  5302. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5303. * @returns the new array
  5304. */
  5305. asArray(): number[];
  5306. /**
  5307. * Returns the luminance value
  5308. * @returns a float value
  5309. */
  5310. toLuminance(): number;
  5311. /**
  5312. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5313. * @param otherColor defines the second operand
  5314. * @returns the new Color3 object
  5315. */
  5316. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5317. /**
  5318. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5319. * @param otherColor defines the second operand
  5320. * @param result defines the Color3 object where to store the result
  5321. * @returns the current Color3
  5322. */
  5323. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5324. /**
  5325. * Determines equality between Color3 objects
  5326. * @param otherColor defines the second operand
  5327. * @returns true if the rgb values are equal to the given ones
  5328. */
  5329. equals(otherColor: DeepImmutable<Color3>): boolean;
  5330. /**
  5331. * Determines equality between the current Color3 object and a set of r,b,g values
  5332. * @param r defines the red component to check
  5333. * @param g defines the green component to check
  5334. * @param b defines the blue component to check
  5335. * @returns true if the rgb values are equal to the given ones
  5336. */
  5337. equalsFloats(r: number, g: number, b: number): boolean;
  5338. /**
  5339. * Multiplies in place each rgb value by scale
  5340. * @param scale defines the scaling factor
  5341. * @returns the updated Color3
  5342. */
  5343. scale(scale: number): Color3;
  5344. /**
  5345. * Multiplies the rgb values by scale and stores the result into "result"
  5346. * @param scale defines the scaling factor
  5347. * @param result defines the Color3 object where to store the result
  5348. * @returns the unmodified current Color3
  5349. */
  5350. scaleToRef(scale: number, result: Color3): Color3;
  5351. /**
  5352. * Scale the current Color3 values by a factor and add the result to a given Color3
  5353. * @param scale defines the scale factor
  5354. * @param result defines color to store the result into
  5355. * @returns the unmodified current Color3
  5356. */
  5357. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5358. /**
  5359. * Clamps the rgb values by the min and max values and stores the result into "result"
  5360. * @param min defines minimum clamping value (default is 0)
  5361. * @param max defines maximum clamping value (default is 1)
  5362. * @param result defines color to store the result into
  5363. * @returns the original Color3
  5364. */
  5365. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5366. /**
  5367. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5368. * @param otherColor defines the second operand
  5369. * @returns the new Color3
  5370. */
  5371. add(otherColor: DeepImmutable<Color3>): Color3;
  5372. /**
  5373. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5374. * @param otherColor defines the second operand
  5375. * @param result defines Color3 object to store the result into
  5376. * @returns the unmodified current Color3
  5377. */
  5378. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5379. /**
  5380. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5381. * @param otherColor defines the second operand
  5382. * @returns the new Color3
  5383. */
  5384. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5385. /**
  5386. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5387. * @param otherColor defines the second operand
  5388. * @param result defines Color3 object to store the result into
  5389. * @returns the unmodified current Color3
  5390. */
  5391. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5392. /**
  5393. * Copy the current object
  5394. * @returns a new Color3 copied the current one
  5395. */
  5396. clone(): Color3;
  5397. /**
  5398. * Copies the rgb values from the source in the current Color3
  5399. * @param source defines the source Color3 object
  5400. * @returns the updated Color3 object
  5401. */
  5402. copyFrom(source: DeepImmutable<Color3>): Color3;
  5403. /**
  5404. * Updates the Color3 rgb values from the given floats
  5405. * @param r defines the red component to read from
  5406. * @param g defines the green component to read from
  5407. * @param b defines the blue component to read from
  5408. * @returns the current Color3 object
  5409. */
  5410. copyFromFloats(r: number, g: number, b: number): Color3;
  5411. /**
  5412. * Updates the Color3 rgb values from the given floats
  5413. * @param r defines the red component to read from
  5414. * @param g defines the green component to read from
  5415. * @param b defines the blue component to read from
  5416. * @returns the current Color3 object
  5417. */
  5418. set(r: number, g: number, b: number): Color3;
  5419. /**
  5420. * Compute the Color3 hexadecimal code as a string
  5421. * @returns a string containing the hexadecimal representation of the Color3 object
  5422. */
  5423. toHexString(): string;
  5424. /**
  5425. * Computes a new Color3 converted from the current one to linear space
  5426. * @returns a new Color3 object
  5427. */
  5428. toLinearSpace(): Color3;
  5429. /**
  5430. * Converts current color in rgb space to HSV values
  5431. * @returns a new color3 representing the HSV values
  5432. */
  5433. toHSV(): Color3;
  5434. /**
  5435. * Converts current color in rgb space to HSV values
  5436. * @param result defines the Color3 where to store the HSV values
  5437. */
  5438. toHSVToRef(result: Color3): void;
  5439. /**
  5440. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5441. * @param convertedColor defines the Color3 object where to store the linear space version
  5442. * @returns the unmodified Color3
  5443. */
  5444. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5445. /**
  5446. * Computes a new Color3 converted from the current one to gamma space
  5447. * @returns a new Color3 object
  5448. */
  5449. toGammaSpace(): Color3;
  5450. /**
  5451. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5452. * @param convertedColor defines the Color3 object where to store the gamma space version
  5453. * @returns the unmodified Color3
  5454. */
  5455. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5456. private static _BlackReadOnly;
  5457. /**
  5458. * Convert Hue, saturation and value to a Color3 (RGB)
  5459. * @param hue defines the hue
  5460. * @param saturation defines the saturation
  5461. * @param value defines the value
  5462. * @param result defines the Color3 where to store the RGB values
  5463. */
  5464. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5465. /**
  5466. * Creates a new Color3 from the string containing valid hexadecimal values
  5467. * @param hex defines a string containing valid hexadecimal values
  5468. * @returns a new Color3 object
  5469. */
  5470. static FromHexString(hex: string): Color3;
  5471. /**
  5472. * Creates a new Color3 from the starting index of the given array
  5473. * @param array defines the source array
  5474. * @param offset defines an offset in the source array
  5475. * @returns a new Color3 object
  5476. */
  5477. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5478. /**
  5479. * Creates a new Color3 from integer values (< 256)
  5480. * @param r defines the red component to read from (value between 0 and 255)
  5481. * @param g defines the green component to read from (value between 0 and 255)
  5482. * @param b defines the blue component to read from (value between 0 and 255)
  5483. * @returns a new Color3 object
  5484. */
  5485. static FromInts(r: number, g: number, b: number): Color3;
  5486. /**
  5487. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5488. * @param start defines the start Color3 value
  5489. * @param end defines the end Color3 value
  5490. * @param amount defines the gradient value between start and end
  5491. * @returns a new Color3 object
  5492. */
  5493. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5494. /**
  5495. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5496. * @param left defines the start value
  5497. * @param right defines the end value
  5498. * @param amount defines the gradient factor
  5499. * @param result defines the Color3 object where to store the result
  5500. */
  5501. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5502. /**
  5503. * Returns a Color3 value containing a red color
  5504. * @returns a new Color3 object
  5505. */
  5506. static Red(): Color3;
  5507. /**
  5508. * Returns a Color3 value containing a green color
  5509. * @returns a new Color3 object
  5510. */
  5511. static Green(): Color3;
  5512. /**
  5513. * Returns a Color3 value containing a blue color
  5514. * @returns a new Color3 object
  5515. */
  5516. static Blue(): Color3;
  5517. /**
  5518. * Returns a Color3 value containing a black color
  5519. * @returns a new Color3 object
  5520. */
  5521. static Black(): Color3;
  5522. /**
  5523. * Gets a Color3 value containing a black color that must not be updated
  5524. */
  5525. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5526. /**
  5527. * Returns a Color3 value containing a white color
  5528. * @returns a new Color3 object
  5529. */
  5530. static White(): Color3;
  5531. /**
  5532. * Returns a Color3 value containing a purple color
  5533. * @returns a new Color3 object
  5534. */
  5535. static Purple(): Color3;
  5536. /**
  5537. * Returns a Color3 value containing a magenta color
  5538. * @returns a new Color3 object
  5539. */
  5540. static Magenta(): Color3;
  5541. /**
  5542. * Returns a Color3 value containing a yellow color
  5543. * @returns a new Color3 object
  5544. */
  5545. static Yellow(): Color3;
  5546. /**
  5547. * Returns a Color3 value containing a gray color
  5548. * @returns a new Color3 object
  5549. */
  5550. static Gray(): Color3;
  5551. /**
  5552. * Returns a Color3 value containing a teal color
  5553. * @returns a new Color3 object
  5554. */
  5555. static Teal(): Color3;
  5556. /**
  5557. * Returns a Color3 value containing a random color
  5558. * @returns a new Color3 object
  5559. */
  5560. static Random(): Color3;
  5561. }
  5562. /**
  5563. * Class used to hold a RBGA color
  5564. */
  5565. export class Color4 {
  5566. /**
  5567. * Defines the red component (between 0 and 1, default is 0)
  5568. */
  5569. r: number;
  5570. /**
  5571. * Defines the green component (between 0 and 1, default is 0)
  5572. */
  5573. g: number;
  5574. /**
  5575. * Defines the blue component (between 0 and 1, default is 0)
  5576. */
  5577. b: number;
  5578. /**
  5579. * Defines the alpha component (between 0 and 1, default is 1)
  5580. */
  5581. a: number;
  5582. /**
  5583. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5584. * @param r defines the red component (between 0 and 1, default is 0)
  5585. * @param g defines the green component (between 0 and 1, default is 0)
  5586. * @param b defines the blue component (between 0 and 1, default is 0)
  5587. * @param a defines the alpha component (between 0 and 1, default is 1)
  5588. */
  5589. constructor(
  5590. /**
  5591. * Defines the red component (between 0 and 1, default is 0)
  5592. */
  5593. r?: number,
  5594. /**
  5595. * Defines the green component (between 0 and 1, default is 0)
  5596. */
  5597. g?: number,
  5598. /**
  5599. * Defines the blue component (between 0 and 1, default is 0)
  5600. */
  5601. b?: number,
  5602. /**
  5603. * Defines the alpha component (between 0 and 1, default is 1)
  5604. */
  5605. a?: number);
  5606. /**
  5607. * Adds in place the given Color4 values to the current Color4 object
  5608. * @param right defines the second operand
  5609. * @returns the current updated Color4 object
  5610. */
  5611. addInPlace(right: DeepImmutable<Color4>): Color4;
  5612. /**
  5613. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5614. * @returns the new array
  5615. */
  5616. asArray(): number[];
  5617. /**
  5618. * Stores from the starting index in the given array the Color4 successive values
  5619. * @param array defines the array where to store the r,g,b components
  5620. * @param index defines an optional index in the target array to define where to start storing values
  5621. * @returns the current Color4 object
  5622. */
  5623. toArray(array: number[], index?: number): Color4;
  5624. /**
  5625. * Determines equality between Color4 objects
  5626. * @param otherColor defines the second operand
  5627. * @returns true if the rgba values are equal to the given ones
  5628. */
  5629. equals(otherColor: DeepImmutable<Color4>): boolean;
  5630. /**
  5631. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5632. * @param right defines the second operand
  5633. * @returns a new Color4 object
  5634. */
  5635. add(right: DeepImmutable<Color4>): Color4;
  5636. /**
  5637. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5638. * @param right defines the second operand
  5639. * @returns a new Color4 object
  5640. */
  5641. subtract(right: DeepImmutable<Color4>): Color4;
  5642. /**
  5643. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5644. * @param right defines the second operand
  5645. * @param result defines the Color4 object where to store the result
  5646. * @returns the current Color4 object
  5647. */
  5648. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5649. /**
  5650. * Creates a new Color4 with the current Color4 values multiplied by scale
  5651. * @param scale defines the scaling factor to apply
  5652. * @returns a new Color4 object
  5653. */
  5654. scale(scale: number): Color4;
  5655. /**
  5656. * Multiplies the current Color4 values by scale and stores the result in "result"
  5657. * @param scale defines the scaling factor to apply
  5658. * @param result defines the Color4 object where to store the result
  5659. * @returns the current unmodified Color4
  5660. */
  5661. scaleToRef(scale: number, result: Color4): Color4;
  5662. /**
  5663. * Scale the current Color4 values by a factor and add the result to a given Color4
  5664. * @param scale defines the scale factor
  5665. * @param result defines the Color4 object where to store the result
  5666. * @returns the unmodified current Color4
  5667. */
  5668. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5669. /**
  5670. * Clamps the rgb values by the min and max values and stores the result into "result"
  5671. * @param min defines minimum clamping value (default is 0)
  5672. * @param max defines maximum clamping value (default is 1)
  5673. * @param result defines color to store the result into.
  5674. * @returns the cuurent Color4
  5675. */
  5676. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5677. /**
  5678. * Multipy an Color4 value by another and return a new Color4 object
  5679. * @param color defines the Color4 value to multiply by
  5680. * @returns a new Color4 object
  5681. */
  5682. multiply(color: Color4): Color4;
  5683. /**
  5684. * Multipy a Color4 value by another and push the result in a reference value
  5685. * @param color defines the Color4 value to multiply by
  5686. * @param result defines the Color4 to fill the result in
  5687. * @returns the result Color4
  5688. */
  5689. multiplyToRef(color: Color4, result: Color4): Color4;
  5690. /**
  5691. * Creates a string with the Color4 current values
  5692. * @returns the string representation of the Color4 object
  5693. */
  5694. toString(): string;
  5695. /**
  5696. * Returns the string "Color4"
  5697. * @returns "Color4"
  5698. */
  5699. getClassName(): string;
  5700. /**
  5701. * Compute the Color4 hash code
  5702. * @returns an unique number that can be used to hash Color4 objects
  5703. */
  5704. getHashCode(): number;
  5705. /**
  5706. * Creates a new Color4 copied from the current one
  5707. * @returns a new Color4 object
  5708. */
  5709. clone(): Color4;
  5710. /**
  5711. * Copies the given Color4 values into the current one
  5712. * @param source defines the source Color4 object
  5713. * @returns the current updated Color4 object
  5714. */
  5715. copyFrom(source: Color4): Color4;
  5716. /**
  5717. * Copies the given float values into the current one
  5718. * @param r defines the red component to read from
  5719. * @param g defines the green component to read from
  5720. * @param b defines the blue component to read from
  5721. * @param a defines the alpha component to read from
  5722. * @returns the current updated Color4 object
  5723. */
  5724. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5725. /**
  5726. * Copies the given float values into the current one
  5727. * @param r defines the red component to read from
  5728. * @param g defines the green component to read from
  5729. * @param b defines the blue component to read from
  5730. * @param a defines the alpha component to read from
  5731. * @returns the current updated Color4 object
  5732. */
  5733. set(r: number, g: number, b: number, a: number): Color4;
  5734. /**
  5735. * Compute the Color4 hexadecimal code as a string
  5736. * @returns a string containing the hexadecimal representation of the Color4 object
  5737. */
  5738. toHexString(): string;
  5739. /**
  5740. * Computes a new Color4 converted from the current one to linear space
  5741. * @returns a new Color4 object
  5742. */
  5743. toLinearSpace(): Color4;
  5744. /**
  5745. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5746. * @param convertedColor defines the Color4 object where to store the linear space version
  5747. * @returns the unmodified Color4
  5748. */
  5749. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5750. /**
  5751. * Computes a new Color4 converted from the current one to gamma space
  5752. * @returns a new Color4 object
  5753. */
  5754. toGammaSpace(): Color4;
  5755. /**
  5756. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5757. * @param convertedColor defines the Color4 object where to store the gamma space version
  5758. * @returns the unmodified Color4
  5759. */
  5760. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5761. /**
  5762. * Creates a new Color4 from the string containing valid hexadecimal values
  5763. * @param hex defines a string containing valid hexadecimal values
  5764. * @returns a new Color4 object
  5765. */
  5766. static FromHexString(hex: string): Color4;
  5767. /**
  5768. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5769. * @param left defines the start value
  5770. * @param right defines the end value
  5771. * @param amount defines the gradient factor
  5772. * @returns a new Color4 object
  5773. */
  5774. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5775. /**
  5776. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5777. * @param left defines the start value
  5778. * @param right defines the end value
  5779. * @param amount defines the gradient factor
  5780. * @param result defines the Color4 object where to store data
  5781. */
  5782. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5783. /**
  5784. * Creates a new Color4 from a Color3 and an alpha value
  5785. * @param color3 defines the source Color3 to read from
  5786. * @param alpha defines the alpha component (1.0 by default)
  5787. * @returns a new Color4 object
  5788. */
  5789. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5790. /**
  5791. * Creates a new Color4 from the starting index element of the given array
  5792. * @param array defines the source array to read from
  5793. * @param offset defines the offset in the source array
  5794. * @returns a new Color4 object
  5795. */
  5796. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5797. /**
  5798. * Creates a new Color3 from integer values (< 256)
  5799. * @param r defines the red component to read from (value between 0 and 255)
  5800. * @param g defines the green component to read from (value between 0 and 255)
  5801. * @param b defines the blue component to read from (value between 0 and 255)
  5802. * @param a defines the alpha component to read from (value between 0 and 255)
  5803. * @returns a new Color3 object
  5804. */
  5805. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5806. /**
  5807. * Check the content of a given array and convert it to an array containing RGBA data
  5808. * If the original array was already containing count * 4 values then it is returned directly
  5809. * @param colors defines the array to check
  5810. * @param count defines the number of RGBA data to expect
  5811. * @returns an array containing count * 4 values (RGBA)
  5812. */
  5813. static CheckColors4(colors: number[], count: number): number[];
  5814. }
  5815. /**
  5816. * @hidden
  5817. */
  5818. export class TmpColors {
  5819. static Color3: Color3[];
  5820. static Color4: Color4[];
  5821. }
  5822. }
  5823. declare module BABYLON {
  5824. /**
  5825. * Defines an interface which represents an animation key frame
  5826. */
  5827. export interface IAnimationKey {
  5828. /**
  5829. * Frame of the key frame
  5830. */
  5831. frame: number;
  5832. /**
  5833. * Value at the specifies key frame
  5834. */
  5835. value: any;
  5836. /**
  5837. * The input tangent for the cubic hermite spline
  5838. */
  5839. inTangent?: any;
  5840. /**
  5841. * The output tangent for the cubic hermite spline
  5842. */
  5843. outTangent?: any;
  5844. /**
  5845. * The animation interpolation type
  5846. */
  5847. interpolation?: AnimationKeyInterpolation;
  5848. }
  5849. /**
  5850. * Enum for the animation key frame interpolation type
  5851. */
  5852. export enum AnimationKeyInterpolation {
  5853. /**
  5854. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5855. */
  5856. STEP = 1
  5857. }
  5858. }
  5859. declare module BABYLON {
  5860. /**
  5861. * Represents the range of an animation
  5862. */
  5863. export class AnimationRange {
  5864. /**The name of the animation range**/
  5865. name: string;
  5866. /**The starting frame of the animation */
  5867. from: number;
  5868. /**The ending frame of the animation*/
  5869. to: number;
  5870. /**
  5871. * Initializes the range of an animation
  5872. * @param name The name of the animation range
  5873. * @param from The starting frame of the animation
  5874. * @param to The ending frame of the animation
  5875. */
  5876. constructor(
  5877. /**The name of the animation range**/
  5878. name: string,
  5879. /**The starting frame of the animation */
  5880. from: number,
  5881. /**The ending frame of the animation*/
  5882. to: number);
  5883. /**
  5884. * Makes a copy of the animation range
  5885. * @returns A copy of the animation range
  5886. */
  5887. clone(): AnimationRange;
  5888. }
  5889. }
  5890. declare module BABYLON {
  5891. /**
  5892. * Composed of a frame, and an action function
  5893. */
  5894. export class AnimationEvent {
  5895. /** The frame for which the event is triggered **/
  5896. frame: number;
  5897. /** The event to perform when triggered **/
  5898. action: (currentFrame: number) => void;
  5899. /** Specifies if the event should be triggered only once**/
  5900. onlyOnce?: boolean | undefined;
  5901. /**
  5902. * Specifies if the animation event is done
  5903. */
  5904. isDone: boolean;
  5905. /**
  5906. * Initializes the animation event
  5907. * @param frame The frame for which the event is triggered
  5908. * @param action The event to perform when triggered
  5909. * @param onlyOnce Specifies if the event should be triggered only once
  5910. */
  5911. constructor(
  5912. /** The frame for which the event is triggered **/
  5913. frame: number,
  5914. /** The event to perform when triggered **/
  5915. action: (currentFrame: number) => void,
  5916. /** Specifies if the event should be triggered only once**/
  5917. onlyOnce?: boolean | undefined);
  5918. /** @hidden */
  5919. _clone(): AnimationEvent;
  5920. }
  5921. }
  5922. declare module BABYLON {
  5923. /**
  5924. * Interface used to define a behavior
  5925. */
  5926. export interface Behavior<T> {
  5927. /** gets or sets behavior's name */
  5928. name: string;
  5929. /**
  5930. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5931. */
  5932. init(): void;
  5933. /**
  5934. * Called when the behavior is attached to a target
  5935. * @param target defines the target where the behavior is attached to
  5936. */
  5937. attach(target: T): void;
  5938. /**
  5939. * Called when the behavior is detached from its target
  5940. */
  5941. detach(): void;
  5942. }
  5943. /**
  5944. * Interface implemented by classes supporting behaviors
  5945. */
  5946. export interface IBehaviorAware<T> {
  5947. /**
  5948. * Attach a behavior
  5949. * @param behavior defines the behavior to attach
  5950. * @returns the current host
  5951. */
  5952. addBehavior(behavior: Behavior<T>): T;
  5953. /**
  5954. * Remove a behavior from the current object
  5955. * @param behavior defines the behavior to detach
  5956. * @returns the current host
  5957. */
  5958. removeBehavior(behavior: Behavior<T>): T;
  5959. /**
  5960. * Gets a behavior using its name to search
  5961. * @param name defines the name to search
  5962. * @returns the behavior or null if not found
  5963. */
  5964. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5965. }
  5966. }
  5967. declare module BABYLON {
  5968. /**
  5969. * Defines an array and its length.
  5970. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5971. */
  5972. export interface ISmartArrayLike<T> {
  5973. /**
  5974. * The data of the array.
  5975. */
  5976. data: Array<T>;
  5977. /**
  5978. * The active length of the array.
  5979. */
  5980. length: number;
  5981. }
  5982. /**
  5983. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5984. */
  5985. export class SmartArray<T> implements ISmartArrayLike<T> {
  5986. /**
  5987. * The full set of data from the array.
  5988. */
  5989. data: Array<T>;
  5990. /**
  5991. * The active length of the array.
  5992. */
  5993. length: number;
  5994. protected _id: number;
  5995. /**
  5996. * Instantiates a Smart Array.
  5997. * @param capacity defines the default capacity of the array.
  5998. */
  5999. constructor(capacity: number);
  6000. /**
  6001. * Pushes a value at the end of the active data.
  6002. * @param value defines the object to push in the array.
  6003. */
  6004. push(value: T): void;
  6005. /**
  6006. * Iterates over the active data and apply the lambda to them.
  6007. * @param func defines the action to apply on each value.
  6008. */
  6009. forEach(func: (content: T) => void): void;
  6010. /**
  6011. * Sorts the full sets of data.
  6012. * @param compareFn defines the comparison function to apply.
  6013. */
  6014. sort(compareFn: (a: T, b: T) => number): void;
  6015. /**
  6016. * Resets the active data to an empty array.
  6017. */
  6018. reset(): void;
  6019. /**
  6020. * Releases all the data from the array as well as the array.
  6021. */
  6022. dispose(): void;
  6023. /**
  6024. * Concats the active data with a given array.
  6025. * @param array defines the data to concatenate with.
  6026. */
  6027. concat(array: any): void;
  6028. /**
  6029. * Returns the position of a value in the active data.
  6030. * @param value defines the value to find the index for
  6031. * @returns the index if found in the active data otherwise -1
  6032. */
  6033. indexOf(value: T): number;
  6034. /**
  6035. * Returns whether an element is part of the active data.
  6036. * @param value defines the value to look for
  6037. * @returns true if found in the active data otherwise false
  6038. */
  6039. contains(value: T): boolean;
  6040. private static _GlobalId;
  6041. }
  6042. /**
  6043. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6044. * The data in this array can only be present once
  6045. */
  6046. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6047. private _duplicateId;
  6048. /**
  6049. * Pushes a value at the end of the active data.
  6050. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6051. * @param value defines the object to push in the array.
  6052. */
  6053. push(value: T): void;
  6054. /**
  6055. * Pushes a value at the end of the active data.
  6056. * If the data is already present, it won t be added again
  6057. * @param value defines the object to push in the array.
  6058. * @returns true if added false if it was already present
  6059. */
  6060. pushNoDuplicate(value: T): boolean;
  6061. /**
  6062. * Resets the active data to an empty array.
  6063. */
  6064. reset(): void;
  6065. /**
  6066. * Concats the active data with a given array.
  6067. * This ensures no dupplicate will be present in the result.
  6068. * @param array defines the data to concatenate with.
  6069. */
  6070. concatWithNoDuplicate(array: any): void;
  6071. }
  6072. }
  6073. declare module BABYLON {
  6074. /**
  6075. * @ignore
  6076. * This is a list of all the different input types that are available in the application.
  6077. * Fo instance: ArcRotateCameraGamepadInput...
  6078. */
  6079. export var CameraInputTypes: {};
  6080. /**
  6081. * This is the contract to implement in order to create a new input class.
  6082. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6083. */
  6084. export interface ICameraInput<TCamera extends Camera> {
  6085. /**
  6086. * Defines the camera the input is attached to.
  6087. */
  6088. camera: Nullable<TCamera>;
  6089. /**
  6090. * Gets the class name of the current intput.
  6091. * @returns the class name
  6092. */
  6093. getClassName(): string;
  6094. /**
  6095. * Get the friendly name associated with the input class.
  6096. * @returns the input friendly name
  6097. */
  6098. getSimpleName(): string;
  6099. /**
  6100. * Attach the input controls to a specific dom element to get the input from.
  6101. * @param element Defines the element the controls should be listened from
  6102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6103. */
  6104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6105. /**
  6106. * Detach the current controls from the specified dom element.
  6107. * @param element Defines the element to stop listening the inputs from
  6108. */
  6109. detachControl(element: Nullable<HTMLElement>): void;
  6110. /**
  6111. * Update the current camera state depending on the inputs that have been used this frame.
  6112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6113. */
  6114. checkInputs?: () => void;
  6115. }
  6116. /**
  6117. * Represents a map of input types to input instance or input index to input instance.
  6118. */
  6119. export interface CameraInputsMap<TCamera extends Camera> {
  6120. /**
  6121. * Accessor to the input by input type.
  6122. */
  6123. [name: string]: ICameraInput<TCamera>;
  6124. /**
  6125. * Accessor to the input by input index.
  6126. */
  6127. [idx: number]: ICameraInput<TCamera>;
  6128. }
  6129. /**
  6130. * This represents the input manager used within a camera.
  6131. * It helps dealing with all the different kind of input attached to a camera.
  6132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6133. */
  6134. export class CameraInputsManager<TCamera extends Camera> {
  6135. /**
  6136. * Defines the list of inputs attahed to the camera.
  6137. */
  6138. attached: CameraInputsMap<TCamera>;
  6139. /**
  6140. * Defines the dom element the camera is collecting inputs from.
  6141. * This is null if the controls have not been attached.
  6142. */
  6143. attachedElement: Nullable<HTMLElement>;
  6144. /**
  6145. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6146. */
  6147. noPreventDefault: boolean;
  6148. /**
  6149. * Defined the camera the input manager belongs to.
  6150. */
  6151. camera: TCamera;
  6152. /**
  6153. * Update the current camera state depending on the inputs that have been used this frame.
  6154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6155. */
  6156. checkInputs: () => void;
  6157. /**
  6158. * Instantiate a new Camera Input Manager.
  6159. * @param camera Defines the camera the input manager blongs to
  6160. */
  6161. constructor(camera: TCamera);
  6162. /**
  6163. * Add an input method to a camera
  6164. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6165. * @param input camera input method
  6166. */
  6167. add(input: ICameraInput<TCamera>): void;
  6168. /**
  6169. * Remove a specific input method from a camera
  6170. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6171. * @param inputToRemove camera input method
  6172. */
  6173. remove(inputToRemove: ICameraInput<TCamera>): void;
  6174. /**
  6175. * Remove a specific input type from a camera
  6176. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6177. * @param inputType the type of the input to remove
  6178. */
  6179. removeByType(inputType: string): void;
  6180. private _addCheckInputs;
  6181. /**
  6182. * Attach the input controls to the currently attached dom element to listen the events from.
  6183. * @param input Defines the input to attach
  6184. */
  6185. attachInput(input: ICameraInput<TCamera>): void;
  6186. /**
  6187. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6188. * @param element Defines the dom element to collect the events from
  6189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6190. */
  6191. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6192. /**
  6193. * Detach the current manager inputs controls from a specific dom element.
  6194. * @param element Defines the dom element to collect the events from
  6195. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6196. */
  6197. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6198. /**
  6199. * Rebuild the dynamic inputCheck function from the current list of
  6200. * defined inputs in the manager.
  6201. */
  6202. rebuildInputCheck(): void;
  6203. /**
  6204. * Remove all attached input methods from a camera
  6205. */
  6206. clear(): void;
  6207. /**
  6208. * Serialize the current input manager attached to a camera.
  6209. * This ensures than once parsed,
  6210. * the input associated to the camera will be identical to the current ones
  6211. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6212. */
  6213. serialize(serializedCamera: any): void;
  6214. /**
  6215. * Parses an input manager serialized JSON to restore the previous list of inputs
  6216. * and states associated to a camera.
  6217. * @param parsedCamera Defines the JSON to parse
  6218. */
  6219. parse(parsedCamera: any): void;
  6220. }
  6221. }
  6222. declare module BABYLON {
  6223. /**
  6224. * Class used to store data that will be store in GPU memory
  6225. */
  6226. export class Buffer {
  6227. private _engine;
  6228. private _buffer;
  6229. /** @hidden */
  6230. _data: Nullable<DataArray>;
  6231. private _updatable;
  6232. private _instanced;
  6233. private _divisor;
  6234. /**
  6235. * Gets the byte stride.
  6236. */
  6237. readonly byteStride: number;
  6238. /**
  6239. * Constructor
  6240. * @param engine the engine
  6241. * @param data the data to use for this buffer
  6242. * @param updatable whether the data is updatable
  6243. * @param stride the stride (optional)
  6244. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6245. * @param instanced whether the buffer is instanced (optional)
  6246. * @param useBytes set to true if the stride in in bytes (optional)
  6247. * @param divisor sets an optional divisor for instances (1 by default)
  6248. */
  6249. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6250. /**
  6251. * Create a new VertexBuffer based on the current buffer
  6252. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6253. * @param offset defines offset in the buffer (0 by default)
  6254. * @param size defines the size in floats of attributes (position is 3 for instance)
  6255. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6256. * @param instanced defines if the vertex buffer contains indexed data
  6257. * @param useBytes defines if the offset and stride are in bytes *
  6258. * @param divisor sets an optional divisor for instances (1 by default)
  6259. * @returns the new vertex buffer
  6260. */
  6261. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6262. /**
  6263. * Gets a boolean indicating if the Buffer is updatable?
  6264. * @returns true if the buffer is updatable
  6265. */
  6266. isUpdatable(): boolean;
  6267. /**
  6268. * Gets current buffer's data
  6269. * @returns a DataArray or null
  6270. */
  6271. getData(): Nullable<DataArray>;
  6272. /**
  6273. * Gets underlying native buffer
  6274. * @returns underlying native buffer
  6275. */
  6276. getBuffer(): Nullable<DataBuffer>;
  6277. /**
  6278. * Gets the stride in float32 units (i.e. byte stride / 4).
  6279. * May not be an integer if the byte stride is not divisible by 4.
  6280. * @returns the stride in float32 units
  6281. * @deprecated Please use byteStride instead.
  6282. */
  6283. getStrideSize(): number;
  6284. /**
  6285. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6286. * @param data defines the data to store
  6287. */
  6288. create(data?: Nullable<DataArray>): void;
  6289. /** @hidden */
  6290. _rebuild(): void;
  6291. /**
  6292. * Update current buffer data
  6293. * @param data defines the data to store
  6294. */
  6295. update(data: DataArray): void;
  6296. /**
  6297. * Updates the data directly.
  6298. * @param data the new data
  6299. * @param offset the new offset
  6300. * @param vertexCount the vertex count (optional)
  6301. * @param useBytes set to true if the offset is in bytes
  6302. */
  6303. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6304. /**
  6305. * Release all resources
  6306. */
  6307. dispose(): void;
  6308. }
  6309. /**
  6310. * Specialized buffer used to store vertex data
  6311. */
  6312. export class VertexBuffer {
  6313. /** @hidden */
  6314. _buffer: Buffer;
  6315. private _kind;
  6316. private _size;
  6317. private _ownsBuffer;
  6318. private _instanced;
  6319. private _instanceDivisor;
  6320. /**
  6321. * The byte type.
  6322. */
  6323. static readonly BYTE: number;
  6324. /**
  6325. * The unsigned byte type.
  6326. */
  6327. static readonly UNSIGNED_BYTE: number;
  6328. /**
  6329. * The short type.
  6330. */
  6331. static readonly SHORT: number;
  6332. /**
  6333. * The unsigned short type.
  6334. */
  6335. static readonly UNSIGNED_SHORT: number;
  6336. /**
  6337. * The integer type.
  6338. */
  6339. static readonly INT: number;
  6340. /**
  6341. * The unsigned integer type.
  6342. */
  6343. static readonly UNSIGNED_INT: number;
  6344. /**
  6345. * The float type.
  6346. */
  6347. static readonly FLOAT: number;
  6348. /**
  6349. * Gets or sets the instance divisor when in instanced mode
  6350. */
  6351. instanceDivisor: number;
  6352. /**
  6353. * Gets the byte stride.
  6354. */
  6355. readonly byteStride: number;
  6356. /**
  6357. * Gets the byte offset.
  6358. */
  6359. readonly byteOffset: number;
  6360. /**
  6361. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6362. */
  6363. readonly normalized: boolean;
  6364. /**
  6365. * Gets the data type of each component in the array.
  6366. */
  6367. readonly type: number;
  6368. /**
  6369. * Constructor
  6370. * @param engine the engine
  6371. * @param data the data to use for this vertex buffer
  6372. * @param kind the vertex buffer kind
  6373. * @param updatable whether the data is updatable
  6374. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6375. * @param stride the stride (optional)
  6376. * @param instanced whether the buffer is instanced (optional)
  6377. * @param offset the offset of the data (optional)
  6378. * @param size the number of components (optional)
  6379. * @param type the type of the component (optional)
  6380. * @param normalized whether the data contains normalized data (optional)
  6381. * @param useBytes set to true if stride and offset are in bytes (optional)
  6382. * @param divisor defines the instance divisor to use (1 by default)
  6383. */
  6384. 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);
  6385. /** @hidden */
  6386. _rebuild(): void;
  6387. /**
  6388. * Returns the kind of the VertexBuffer (string)
  6389. * @returns a string
  6390. */
  6391. getKind(): string;
  6392. /**
  6393. * Gets a boolean indicating if the VertexBuffer is updatable?
  6394. * @returns true if the buffer is updatable
  6395. */
  6396. isUpdatable(): boolean;
  6397. /**
  6398. * Gets current buffer's data
  6399. * @returns a DataArray or null
  6400. */
  6401. getData(): Nullable<DataArray>;
  6402. /**
  6403. * Gets underlying native buffer
  6404. * @returns underlying native buffer
  6405. */
  6406. getBuffer(): Nullable<DataBuffer>;
  6407. /**
  6408. * Gets the stride in float32 units (i.e. byte stride / 4).
  6409. * May not be an integer if the byte stride is not divisible by 4.
  6410. * @returns the stride in float32 units
  6411. * @deprecated Please use byteStride instead.
  6412. */
  6413. getStrideSize(): number;
  6414. /**
  6415. * Returns the offset as a multiple of the type byte length.
  6416. * @returns the offset in bytes
  6417. * @deprecated Please use byteOffset instead.
  6418. */
  6419. getOffset(): number;
  6420. /**
  6421. * Returns the number of components per vertex attribute (integer)
  6422. * @returns the size in float
  6423. */
  6424. getSize(): number;
  6425. /**
  6426. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6427. * @returns true if this buffer is instanced
  6428. */
  6429. getIsInstanced(): boolean;
  6430. /**
  6431. * Returns the instancing divisor, zero for non-instanced (integer).
  6432. * @returns a number
  6433. */
  6434. getInstanceDivisor(): number;
  6435. /**
  6436. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6437. * @param data defines the data to store
  6438. */
  6439. create(data?: DataArray): void;
  6440. /**
  6441. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6442. * This function will create a new buffer if the current one is not updatable
  6443. * @param data defines the data to store
  6444. */
  6445. update(data: DataArray): void;
  6446. /**
  6447. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6448. * Returns the directly updated WebGLBuffer.
  6449. * @param data the new data
  6450. * @param offset the new offset
  6451. * @param useBytes set to true if the offset is in bytes
  6452. */
  6453. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6454. /**
  6455. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6456. */
  6457. dispose(): void;
  6458. /**
  6459. * Enumerates each value of this vertex buffer as numbers.
  6460. * @param count the number of values to enumerate
  6461. * @param callback the callback function called for each value
  6462. */
  6463. forEach(count: number, callback: (value: number, index: number) => void): void;
  6464. /**
  6465. * Positions
  6466. */
  6467. static readonly PositionKind: string;
  6468. /**
  6469. * Normals
  6470. */
  6471. static readonly NormalKind: string;
  6472. /**
  6473. * Tangents
  6474. */
  6475. static readonly TangentKind: string;
  6476. /**
  6477. * Texture coordinates
  6478. */
  6479. static readonly UVKind: string;
  6480. /**
  6481. * Texture coordinates 2
  6482. */
  6483. static readonly UV2Kind: string;
  6484. /**
  6485. * Texture coordinates 3
  6486. */
  6487. static readonly UV3Kind: string;
  6488. /**
  6489. * Texture coordinates 4
  6490. */
  6491. static readonly UV4Kind: string;
  6492. /**
  6493. * Texture coordinates 5
  6494. */
  6495. static readonly UV5Kind: string;
  6496. /**
  6497. * Texture coordinates 6
  6498. */
  6499. static readonly UV6Kind: string;
  6500. /**
  6501. * Colors
  6502. */
  6503. static readonly ColorKind: string;
  6504. /**
  6505. * Matrix indices (for bones)
  6506. */
  6507. static readonly MatricesIndicesKind: string;
  6508. /**
  6509. * Matrix weights (for bones)
  6510. */
  6511. static readonly MatricesWeightsKind: string;
  6512. /**
  6513. * Additional matrix indices (for bones)
  6514. */
  6515. static readonly MatricesIndicesExtraKind: string;
  6516. /**
  6517. * Additional matrix weights (for bones)
  6518. */
  6519. static readonly MatricesWeightsExtraKind: string;
  6520. /**
  6521. * Deduces the stride given a kind.
  6522. * @param kind The kind string to deduce
  6523. * @returns The deduced stride
  6524. */
  6525. static DeduceStride(kind: string): number;
  6526. /**
  6527. * Gets the byte length of the given type.
  6528. * @param type the type
  6529. * @returns the number of bytes
  6530. */
  6531. static GetTypeByteLength(type: number): number;
  6532. /**
  6533. * Enumerates each value of the given parameters as numbers.
  6534. * @param data the data to enumerate
  6535. * @param byteOffset the byte offset of the data
  6536. * @param byteStride the byte stride of the data
  6537. * @param componentCount the number of components per element
  6538. * @param componentType the type of the component
  6539. * @param count the number of values to enumerate
  6540. * @param normalized whether the data is normalized
  6541. * @param callback the callback function called for each value
  6542. */
  6543. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6544. private static _GetFloatValue;
  6545. }
  6546. }
  6547. declare module BABYLON {
  6548. /**
  6549. * @hidden
  6550. */
  6551. export class IntersectionInfo {
  6552. bu: Nullable<number>;
  6553. bv: Nullable<number>;
  6554. distance: number;
  6555. faceId: number;
  6556. subMeshId: number;
  6557. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6558. }
  6559. }
  6560. declare module BABYLON {
  6561. /**
  6562. * Represens a plane by the equation ax + by + cz + d = 0
  6563. */
  6564. export class Plane {
  6565. private static _TmpMatrix;
  6566. /**
  6567. * Normal of the plane (a,b,c)
  6568. */
  6569. normal: Vector3;
  6570. /**
  6571. * d component of the plane
  6572. */
  6573. d: number;
  6574. /**
  6575. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6576. * @param a a component of the plane
  6577. * @param b b component of the plane
  6578. * @param c c component of the plane
  6579. * @param d d component of the plane
  6580. */
  6581. constructor(a: number, b: number, c: number, d: number);
  6582. /**
  6583. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6584. */
  6585. asArray(): number[];
  6586. /**
  6587. * @returns a new plane copied from the current Plane.
  6588. */
  6589. clone(): Plane;
  6590. /**
  6591. * @returns the string "Plane".
  6592. */
  6593. getClassName(): string;
  6594. /**
  6595. * @returns the Plane hash code.
  6596. */
  6597. getHashCode(): number;
  6598. /**
  6599. * Normalize the current Plane in place.
  6600. * @returns the updated Plane.
  6601. */
  6602. normalize(): Plane;
  6603. /**
  6604. * Applies a transformation the plane and returns the result
  6605. * @param transformation the transformation matrix to be applied to the plane
  6606. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6607. */
  6608. transform(transformation: DeepImmutable<Matrix>): Plane;
  6609. /**
  6610. * Calcualtte the dot product between the point and the plane normal
  6611. * @param point point to calculate the dot product with
  6612. * @returns the dot product (float) of the point coordinates and the plane normal.
  6613. */
  6614. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6615. /**
  6616. * Updates the current Plane from the plane defined by the three given points.
  6617. * @param point1 one of the points used to contruct the plane
  6618. * @param point2 one of the points used to contruct the plane
  6619. * @param point3 one of the points used to contruct the plane
  6620. * @returns the updated Plane.
  6621. */
  6622. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6623. /**
  6624. * Checks if the plane is facing a given direction
  6625. * @param direction the direction to check if the plane is facing
  6626. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6627. * @returns True is the vector "direction" is the same side than the plane normal.
  6628. */
  6629. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6630. /**
  6631. * Calculates the distance to a point
  6632. * @param point point to calculate distance to
  6633. * @returns the signed distance (float) from the given point to the Plane.
  6634. */
  6635. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6636. /**
  6637. * Creates a plane from an array
  6638. * @param array the array to create a plane from
  6639. * @returns a new Plane from the given array.
  6640. */
  6641. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6642. /**
  6643. * Creates a plane from three points
  6644. * @param point1 point used to create the plane
  6645. * @param point2 point used to create the plane
  6646. * @param point3 point used to create the plane
  6647. * @returns a new Plane defined by the three given points.
  6648. */
  6649. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6650. /**
  6651. * Creates a plane from an origin point and a normal
  6652. * @param origin origin of the plane to be constructed
  6653. * @param normal normal of the plane to be constructed
  6654. * @returns a new Plane the normal vector to this plane at the given origin point.
  6655. * Note : the vector "normal" is updated because normalized.
  6656. */
  6657. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6658. /**
  6659. * Calculates the distance from a plane and a point
  6660. * @param origin origin of the plane to be constructed
  6661. * @param normal normal of the plane to be constructed
  6662. * @param point point to calculate distance to
  6663. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6664. */
  6665. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6666. }
  6667. }
  6668. declare module BABYLON {
  6669. /**
  6670. * Class used to store bounding sphere information
  6671. */
  6672. export class BoundingSphere {
  6673. /**
  6674. * Gets the center of the bounding sphere in local space
  6675. */
  6676. readonly center: Vector3;
  6677. /**
  6678. * Radius of the bounding sphere in local space
  6679. */
  6680. radius: number;
  6681. /**
  6682. * Gets the center of the bounding sphere in world space
  6683. */
  6684. readonly centerWorld: Vector3;
  6685. /**
  6686. * Radius of the bounding sphere in world space
  6687. */
  6688. radiusWorld: number;
  6689. /**
  6690. * Gets the minimum vector in local space
  6691. */
  6692. readonly minimum: Vector3;
  6693. /**
  6694. * Gets the maximum vector in local space
  6695. */
  6696. readonly maximum: Vector3;
  6697. private _worldMatrix;
  6698. private static readonly TmpVector3;
  6699. /**
  6700. * Creates a new bounding sphere
  6701. * @param min defines the minimum vector (in local space)
  6702. * @param max defines the maximum vector (in local space)
  6703. * @param worldMatrix defines the new world matrix
  6704. */
  6705. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6706. /**
  6707. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6708. * @param min defines the new minimum vector (in local space)
  6709. * @param max defines the new maximum vector (in local space)
  6710. * @param worldMatrix defines the new world matrix
  6711. */
  6712. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6713. /**
  6714. * Scale the current bounding sphere by applying a scale factor
  6715. * @param factor defines the scale factor to apply
  6716. * @returns the current bounding box
  6717. */
  6718. scale(factor: number): BoundingSphere;
  6719. /**
  6720. * Gets the world matrix of the bounding box
  6721. * @returns a matrix
  6722. */
  6723. getWorldMatrix(): DeepImmutable<Matrix>;
  6724. /** @hidden */
  6725. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6726. /**
  6727. * Tests if the bounding sphere is intersecting the frustum planes
  6728. * @param frustumPlanes defines the frustum planes to test
  6729. * @returns true if there is an intersection
  6730. */
  6731. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6732. /**
  6733. * Tests if the bounding sphere center is in between the frustum planes.
  6734. * Used for optimistic fast inclusion.
  6735. * @param frustumPlanes defines the frustum planes to test
  6736. * @returns true if the sphere center is in between the frustum planes
  6737. */
  6738. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6739. /**
  6740. * Tests if a point is inside the bounding sphere
  6741. * @param point defines the point to test
  6742. * @returns true if the point is inside the bounding sphere
  6743. */
  6744. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6745. /**
  6746. * Checks if two sphere intersct
  6747. * @param sphere0 sphere 0
  6748. * @param sphere1 sphere 1
  6749. * @returns true if the speres intersect
  6750. */
  6751. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6752. }
  6753. }
  6754. declare module BABYLON {
  6755. /**
  6756. * Class used to store bounding box information
  6757. */
  6758. export class BoundingBox implements ICullable {
  6759. /**
  6760. * Gets the 8 vectors representing the bounding box in local space
  6761. */
  6762. readonly vectors: Vector3[];
  6763. /**
  6764. * Gets the center of the bounding box in local space
  6765. */
  6766. readonly center: Vector3;
  6767. /**
  6768. * Gets the center of the bounding box in world space
  6769. */
  6770. readonly centerWorld: Vector3;
  6771. /**
  6772. * Gets the extend size in local space
  6773. */
  6774. readonly extendSize: Vector3;
  6775. /**
  6776. * Gets the extend size in world space
  6777. */
  6778. readonly extendSizeWorld: Vector3;
  6779. /**
  6780. * Gets the OBB (object bounding box) directions
  6781. */
  6782. readonly directions: Vector3[];
  6783. /**
  6784. * Gets the 8 vectors representing the bounding box in world space
  6785. */
  6786. readonly vectorsWorld: Vector3[];
  6787. /**
  6788. * Gets the minimum vector in world space
  6789. */
  6790. readonly minimumWorld: Vector3;
  6791. /**
  6792. * Gets the maximum vector in world space
  6793. */
  6794. readonly maximumWorld: Vector3;
  6795. /**
  6796. * Gets the minimum vector in local space
  6797. */
  6798. readonly minimum: Vector3;
  6799. /**
  6800. * Gets the maximum vector in local space
  6801. */
  6802. readonly maximum: Vector3;
  6803. private _worldMatrix;
  6804. private static readonly TmpVector3;
  6805. /**
  6806. * @hidden
  6807. */
  6808. _tag: number;
  6809. /**
  6810. * Creates a new bounding box
  6811. * @param min defines the minimum vector (in local space)
  6812. * @param max defines the maximum vector (in local space)
  6813. * @param worldMatrix defines the new world matrix
  6814. */
  6815. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6816. /**
  6817. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6818. * @param min defines the new minimum vector (in local space)
  6819. * @param max defines the new maximum vector (in local space)
  6820. * @param worldMatrix defines the new world matrix
  6821. */
  6822. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6823. /**
  6824. * Scale the current bounding box by applying a scale factor
  6825. * @param factor defines the scale factor to apply
  6826. * @returns the current bounding box
  6827. */
  6828. scale(factor: number): BoundingBox;
  6829. /**
  6830. * Gets the world matrix of the bounding box
  6831. * @returns a matrix
  6832. */
  6833. getWorldMatrix(): DeepImmutable<Matrix>;
  6834. /** @hidden */
  6835. _update(world: DeepImmutable<Matrix>): void;
  6836. /**
  6837. * Tests if the bounding box is intersecting the frustum planes
  6838. * @param frustumPlanes defines the frustum planes to test
  6839. * @returns true if there is an intersection
  6840. */
  6841. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6842. /**
  6843. * Tests if the bounding box is entirely inside the frustum planes
  6844. * @param frustumPlanes defines the frustum planes to test
  6845. * @returns true if there is an inclusion
  6846. */
  6847. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6848. /**
  6849. * Tests if a point is inside the bounding box
  6850. * @param point defines the point to test
  6851. * @returns true if the point is inside the bounding box
  6852. */
  6853. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6854. /**
  6855. * Tests if the bounding box intersects with a bounding sphere
  6856. * @param sphere defines the sphere to test
  6857. * @returns true if there is an intersection
  6858. */
  6859. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6860. /**
  6861. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6862. * @param min defines the min vector to use
  6863. * @param max defines the max vector to use
  6864. * @returns true if there is an intersection
  6865. */
  6866. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6867. /**
  6868. * Tests if two bounding boxes are intersections
  6869. * @param box0 defines the first box to test
  6870. * @param box1 defines the second box to test
  6871. * @returns true if there is an intersection
  6872. */
  6873. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6874. /**
  6875. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6876. * @param minPoint defines the minimum vector of the bounding box
  6877. * @param maxPoint defines the maximum vector of the bounding box
  6878. * @param sphereCenter defines the sphere center
  6879. * @param sphereRadius defines the sphere radius
  6880. * @returns true if there is an intersection
  6881. */
  6882. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6883. /**
  6884. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6885. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6886. * @param frustumPlanes defines the frustum planes to test
  6887. * @return true if there is an inclusion
  6888. */
  6889. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6890. /**
  6891. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6892. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6893. * @param frustumPlanes defines the frustum planes to test
  6894. * @return true if there is an intersection
  6895. */
  6896. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6897. }
  6898. }
  6899. declare module BABYLON {
  6900. /** @hidden */
  6901. export class Collider {
  6902. /** Define if a collision was found */
  6903. collisionFound: boolean;
  6904. /**
  6905. * Define last intersection point in local space
  6906. */
  6907. intersectionPoint: Vector3;
  6908. /**
  6909. * Define last collided mesh
  6910. */
  6911. collidedMesh: Nullable<AbstractMesh>;
  6912. private _collisionPoint;
  6913. private _planeIntersectionPoint;
  6914. private _tempVector;
  6915. private _tempVector2;
  6916. private _tempVector3;
  6917. private _tempVector4;
  6918. private _edge;
  6919. private _baseToVertex;
  6920. private _destinationPoint;
  6921. private _slidePlaneNormal;
  6922. private _displacementVector;
  6923. /** @hidden */
  6924. _radius: Vector3;
  6925. /** @hidden */
  6926. _retry: number;
  6927. private _velocity;
  6928. private _basePoint;
  6929. private _epsilon;
  6930. /** @hidden */
  6931. _velocityWorldLength: number;
  6932. /** @hidden */
  6933. _basePointWorld: Vector3;
  6934. private _velocityWorld;
  6935. private _normalizedVelocity;
  6936. /** @hidden */
  6937. _initialVelocity: Vector3;
  6938. /** @hidden */
  6939. _initialPosition: Vector3;
  6940. private _nearestDistance;
  6941. private _collisionMask;
  6942. collisionMask: number;
  6943. /**
  6944. * Gets the plane normal used to compute the sliding response (in local space)
  6945. */
  6946. readonly slidePlaneNormal: Vector3;
  6947. /** @hidden */
  6948. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6949. /** @hidden */
  6950. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6951. /** @hidden */
  6952. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6953. /** @hidden */
  6954. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6955. /** @hidden */
  6956. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6957. /** @hidden */
  6958. _getResponse(pos: Vector3, vel: Vector3): void;
  6959. }
  6960. }
  6961. declare module BABYLON {
  6962. /**
  6963. * Interface for cullable objects
  6964. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6965. */
  6966. export interface ICullable {
  6967. /**
  6968. * Checks if the object or part of the object is in the frustum
  6969. * @param frustumPlanes Camera near/planes
  6970. * @returns true if the object is in frustum otherwise false
  6971. */
  6972. isInFrustum(frustumPlanes: Plane[]): boolean;
  6973. /**
  6974. * Checks if a cullable object (mesh...) is in the camera frustum
  6975. * Unlike isInFrustum this cheks the full bounding box
  6976. * @param frustumPlanes Camera near/planes
  6977. * @returns true if the object is in frustum otherwise false
  6978. */
  6979. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6980. }
  6981. /**
  6982. * Info for a bounding data of a mesh
  6983. */
  6984. export class BoundingInfo implements ICullable {
  6985. /**
  6986. * Bounding box for the mesh
  6987. */
  6988. readonly boundingBox: BoundingBox;
  6989. /**
  6990. * Bounding sphere for the mesh
  6991. */
  6992. readonly boundingSphere: BoundingSphere;
  6993. private _isLocked;
  6994. private static readonly TmpVector3;
  6995. /**
  6996. * Constructs bounding info
  6997. * @param minimum min vector of the bounding box/sphere
  6998. * @param maximum max vector of the bounding box/sphere
  6999. * @param worldMatrix defines the new world matrix
  7000. */
  7001. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7002. /**
  7003. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7004. * @param min defines the new minimum vector (in local space)
  7005. * @param max defines the new maximum vector (in local space)
  7006. * @param worldMatrix defines the new world matrix
  7007. */
  7008. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7009. /**
  7010. * min vector of the bounding box/sphere
  7011. */
  7012. readonly minimum: Vector3;
  7013. /**
  7014. * max vector of the bounding box/sphere
  7015. */
  7016. readonly maximum: Vector3;
  7017. /**
  7018. * If the info is locked and won't be updated to avoid perf overhead
  7019. */
  7020. isLocked: boolean;
  7021. /**
  7022. * Updates the bounding sphere and box
  7023. * @param world world matrix to be used to update
  7024. */
  7025. update(world: DeepImmutable<Matrix>): void;
  7026. /**
  7027. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7028. * @param center New center of the bounding info
  7029. * @param extend New extend of the bounding info
  7030. * @returns the current bounding info
  7031. */
  7032. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7033. /**
  7034. * Scale the current bounding info by applying a scale factor
  7035. * @param factor defines the scale factor to apply
  7036. * @returns the current bounding info
  7037. */
  7038. scale(factor: number): BoundingInfo;
  7039. /**
  7040. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7041. * @param frustumPlanes defines the frustum to test
  7042. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7043. * @returns true if the bounding info is in the frustum planes
  7044. */
  7045. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7046. /**
  7047. * Gets the world distance between the min and max points of the bounding box
  7048. */
  7049. readonly diagonalLength: number;
  7050. /**
  7051. * Checks if a cullable object (mesh...) is in the camera frustum
  7052. * Unlike isInFrustum this cheks the full bounding box
  7053. * @param frustumPlanes Camera near/planes
  7054. * @returns true if the object is in frustum otherwise false
  7055. */
  7056. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /** @hidden */
  7058. _checkCollision(collider: Collider): boolean;
  7059. /**
  7060. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7061. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7062. * @param point the point to check intersection with
  7063. * @returns if the point intersects
  7064. */
  7065. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7066. /**
  7067. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7068. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7069. * @param boundingInfo the bounding info to check intersection with
  7070. * @param precise if the intersection should be done using OBB
  7071. * @returns if the bounding info intersects
  7072. */
  7073. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7074. }
  7075. }
  7076. declare module BABYLON {
  7077. /**
  7078. * Extracts minimum and maximum values from a list of indexed positions
  7079. * @param positions defines the positions to use
  7080. * @param indices defines the indices to the positions
  7081. * @param indexStart defines the start index
  7082. * @param indexCount defines the end index
  7083. * @param bias defines bias value to add to the result
  7084. * @return minimum and maximum values
  7085. */
  7086. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7087. minimum: Vector3;
  7088. maximum: Vector3;
  7089. };
  7090. /**
  7091. * Extracts minimum and maximum values from a list of positions
  7092. * @param positions defines the positions to use
  7093. * @param start defines the start index in the positions array
  7094. * @param count defines the number of positions to handle
  7095. * @param bias defines bias value to add to the result
  7096. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7097. * @return minimum and maximum values
  7098. */
  7099. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7100. minimum: Vector3;
  7101. maximum: Vector3;
  7102. };
  7103. }
  7104. declare module BABYLON {
  7105. /** @hidden */
  7106. export class WebGLDataBuffer extends DataBuffer {
  7107. private _buffer;
  7108. constructor(resource: WebGLBuffer);
  7109. readonly underlyingResource: any;
  7110. }
  7111. }
  7112. declare module BABYLON {
  7113. /** @hidden */
  7114. export class WebGLPipelineContext implements IPipelineContext {
  7115. engine: ThinEngine;
  7116. program: Nullable<WebGLProgram>;
  7117. context?: WebGLRenderingContext;
  7118. vertexShader?: WebGLShader;
  7119. fragmentShader?: WebGLShader;
  7120. isParallelCompiled: boolean;
  7121. onCompiled?: () => void;
  7122. transformFeedback?: WebGLTransformFeedback | null;
  7123. readonly isAsync: boolean;
  7124. readonly isReady: boolean;
  7125. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7126. }
  7127. }
  7128. declare module BABYLON {
  7129. interface ThinEngine {
  7130. /**
  7131. * Create an uniform buffer
  7132. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7133. * @param elements defines the content of the uniform buffer
  7134. * @returns the webGL uniform buffer
  7135. */
  7136. createUniformBuffer(elements: FloatArray): DataBuffer;
  7137. /**
  7138. * Create a dynamic uniform buffer
  7139. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7140. * @param elements defines the content of the uniform buffer
  7141. * @returns the webGL uniform buffer
  7142. */
  7143. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7144. /**
  7145. * Update an existing uniform buffer
  7146. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7147. * @param uniformBuffer defines the target uniform buffer
  7148. * @param elements defines the content to update
  7149. * @param offset defines the offset in the uniform buffer where update should start
  7150. * @param count defines the size of the data to update
  7151. */
  7152. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7153. /**
  7154. * Bind an uniform buffer to the current webGL context
  7155. * @param buffer defines the buffer to bind
  7156. */
  7157. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7158. /**
  7159. * Bind a buffer to the current webGL context at a given location
  7160. * @param buffer defines the buffer to bind
  7161. * @param location defines the index where to bind the buffer
  7162. */
  7163. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7164. /**
  7165. * Bind a specific block at a given index in a specific shader program
  7166. * @param pipelineContext defines the pipeline context to use
  7167. * @param blockName defines the block name
  7168. * @param index defines the index where to bind the block
  7169. */
  7170. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7171. }
  7172. }
  7173. declare module BABYLON {
  7174. /**
  7175. * Uniform buffer objects.
  7176. *
  7177. * Handles blocks of uniform on the GPU.
  7178. *
  7179. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7180. *
  7181. * For more information, please refer to :
  7182. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7183. */
  7184. export class UniformBuffer {
  7185. private _engine;
  7186. private _buffer;
  7187. private _data;
  7188. private _bufferData;
  7189. private _dynamic?;
  7190. private _uniformLocations;
  7191. private _uniformSizes;
  7192. private _uniformLocationPointer;
  7193. private _needSync;
  7194. private _noUBO;
  7195. private _currentEffect;
  7196. /** @hidden */
  7197. _alreadyBound: boolean;
  7198. private static _MAX_UNIFORM_SIZE;
  7199. private static _tempBuffer;
  7200. /**
  7201. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7202. * This is dynamic to allow compat with webgl 1 and 2.
  7203. * You will need to pass the name of the uniform as well as the value.
  7204. */
  7205. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7206. /**
  7207. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7208. * This is dynamic to allow compat with webgl 1 and 2.
  7209. * You will need to pass the name of the uniform as well as the value.
  7210. */
  7211. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7212. /**
  7213. * Lambda to Update a single float in a uniform buffer.
  7214. * This is dynamic to allow compat with webgl 1 and 2.
  7215. * You will need to pass the name of the uniform as well as the value.
  7216. */
  7217. updateFloat: (name: string, x: number) => void;
  7218. /**
  7219. * Lambda to Update a vec2 of float in a uniform buffer.
  7220. * This is dynamic to allow compat with webgl 1 and 2.
  7221. * You will need to pass the name of the uniform as well as the value.
  7222. */
  7223. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7224. /**
  7225. * Lambda to Update a vec3 of float in a uniform buffer.
  7226. * This is dynamic to allow compat with webgl 1 and 2.
  7227. * You will need to pass the name of the uniform as well as the value.
  7228. */
  7229. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7230. /**
  7231. * Lambda to Update a vec4 of float in a uniform buffer.
  7232. * This is dynamic to allow compat with webgl 1 and 2.
  7233. * You will need to pass the name of the uniform as well as the value.
  7234. */
  7235. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7236. /**
  7237. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7238. * This is dynamic to allow compat with webgl 1 and 2.
  7239. * You will need to pass the name of the uniform as well as the value.
  7240. */
  7241. updateMatrix: (name: string, mat: Matrix) => void;
  7242. /**
  7243. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7244. * This is dynamic to allow compat with webgl 1 and 2.
  7245. * You will need to pass the name of the uniform as well as the value.
  7246. */
  7247. updateVector3: (name: string, vector: Vector3) => void;
  7248. /**
  7249. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7250. * This is dynamic to allow compat with webgl 1 and 2.
  7251. * You will need to pass the name of the uniform as well as the value.
  7252. */
  7253. updateVector4: (name: string, vector: Vector4) => void;
  7254. /**
  7255. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7256. * This is dynamic to allow compat with webgl 1 and 2.
  7257. * You will need to pass the name of the uniform as well as the value.
  7258. */
  7259. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7260. /**
  7261. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7262. * This is dynamic to allow compat with webgl 1 and 2.
  7263. * You will need to pass the name of the uniform as well as the value.
  7264. */
  7265. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7266. /**
  7267. * Instantiates a new Uniform buffer objects.
  7268. *
  7269. * Handles blocks of uniform on the GPU.
  7270. *
  7271. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7272. *
  7273. * For more information, please refer to :
  7274. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7275. * @param engine Define the engine the buffer is associated with
  7276. * @param data Define the data contained in the buffer
  7277. * @param dynamic Define if the buffer is updatable
  7278. */
  7279. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7280. /**
  7281. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7282. * or just falling back on setUniformXXX calls.
  7283. */
  7284. readonly useUbo: boolean;
  7285. /**
  7286. * Indicates if the WebGL underlying uniform buffer is in sync
  7287. * with the javascript cache data.
  7288. */
  7289. readonly isSync: boolean;
  7290. /**
  7291. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7292. * Also, a dynamic UniformBuffer will disable cache verification and always
  7293. * update the underlying WebGL uniform buffer to the GPU.
  7294. * @returns if Dynamic, otherwise false
  7295. */
  7296. isDynamic(): boolean;
  7297. /**
  7298. * The data cache on JS side.
  7299. * @returns the underlying data as a float array
  7300. */
  7301. getData(): Float32Array;
  7302. /**
  7303. * The underlying WebGL Uniform buffer.
  7304. * @returns the webgl buffer
  7305. */
  7306. getBuffer(): Nullable<DataBuffer>;
  7307. /**
  7308. * std140 layout specifies how to align data within an UBO structure.
  7309. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7310. * for specs.
  7311. */
  7312. private _fillAlignment;
  7313. /**
  7314. * Adds an uniform in the buffer.
  7315. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7316. * for the layout to be correct !
  7317. * @param name Name of the uniform, as used in the uniform block in the shader.
  7318. * @param size Data size, or data directly.
  7319. */
  7320. addUniform(name: string, size: number | number[]): void;
  7321. /**
  7322. * Adds a Matrix 4x4 to the uniform buffer.
  7323. * @param name Name of the uniform, as used in the uniform block in the shader.
  7324. * @param mat A 4x4 matrix.
  7325. */
  7326. addMatrix(name: string, mat: Matrix): void;
  7327. /**
  7328. * Adds a vec2 to the uniform buffer.
  7329. * @param name Name of the uniform, as used in the uniform block in the shader.
  7330. * @param x Define the x component value of the vec2
  7331. * @param y Define the y component value of the vec2
  7332. */
  7333. addFloat2(name: string, x: number, y: number): void;
  7334. /**
  7335. * Adds a vec3 to the uniform buffer.
  7336. * @param name Name of the uniform, as used in the uniform block in the shader.
  7337. * @param x Define the x component value of the vec3
  7338. * @param y Define the y component value of the vec3
  7339. * @param z Define the z component value of the vec3
  7340. */
  7341. addFloat3(name: string, x: number, y: number, z: number): void;
  7342. /**
  7343. * Adds a vec3 to the uniform buffer.
  7344. * @param name Name of the uniform, as used in the uniform block in the shader.
  7345. * @param color Define the vec3 from a Color
  7346. */
  7347. addColor3(name: string, color: Color3): void;
  7348. /**
  7349. * Adds a vec4 to the uniform buffer.
  7350. * @param name Name of the uniform, as used in the uniform block in the shader.
  7351. * @param color Define the rgb components from a Color
  7352. * @param alpha Define the a component of the vec4
  7353. */
  7354. addColor4(name: string, color: Color3, alpha: number): void;
  7355. /**
  7356. * Adds a vec3 to the uniform buffer.
  7357. * @param name Name of the uniform, as used in the uniform block in the shader.
  7358. * @param vector Define the vec3 components from a Vector
  7359. */
  7360. addVector3(name: string, vector: Vector3): void;
  7361. /**
  7362. * Adds a Matrix 3x3 to the uniform buffer.
  7363. * @param name Name of the uniform, as used in the uniform block in the shader.
  7364. */
  7365. addMatrix3x3(name: string): void;
  7366. /**
  7367. * Adds a Matrix 2x2 to the uniform buffer.
  7368. * @param name Name of the uniform, as used in the uniform block in the shader.
  7369. */
  7370. addMatrix2x2(name: string): void;
  7371. /**
  7372. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7373. */
  7374. create(): void;
  7375. /** @hidden */
  7376. _rebuild(): void;
  7377. /**
  7378. * Updates the WebGL Uniform Buffer on the GPU.
  7379. * If the `dynamic` flag is set to true, no cache comparison is done.
  7380. * Otherwise, the buffer will be updated only if the cache differs.
  7381. */
  7382. update(): void;
  7383. /**
  7384. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7385. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7386. * @param data Define the flattened data
  7387. * @param size Define the size of the data.
  7388. */
  7389. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7390. private _valueCache;
  7391. private _cacheMatrix;
  7392. private _updateMatrix3x3ForUniform;
  7393. private _updateMatrix3x3ForEffect;
  7394. private _updateMatrix2x2ForEffect;
  7395. private _updateMatrix2x2ForUniform;
  7396. private _updateFloatForEffect;
  7397. private _updateFloatForUniform;
  7398. private _updateFloat2ForEffect;
  7399. private _updateFloat2ForUniform;
  7400. private _updateFloat3ForEffect;
  7401. private _updateFloat3ForUniform;
  7402. private _updateFloat4ForEffect;
  7403. private _updateFloat4ForUniform;
  7404. private _updateMatrixForEffect;
  7405. private _updateMatrixForUniform;
  7406. private _updateVector3ForEffect;
  7407. private _updateVector3ForUniform;
  7408. private _updateVector4ForEffect;
  7409. private _updateVector4ForUniform;
  7410. private _updateColor3ForEffect;
  7411. private _updateColor3ForUniform;
  7412. private _updateColor4ForEffect;
  7413. private _updateColor4ForUniform;
  7414. /**
  7415. * Sets a sampler uniform on the effect.
  7416. * @param name Define the name of the sampler.
  7417. * @param texture Define the texture to set in the sampler
  7418. */
  7419. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7420. /**
  7421. * Directly updates the value of the uniform in the cache AND on the GPU.
  7422. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7423. * @param data Define the flattened data
  7424. */
  7425. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7426. /**
  7427. * Binds this uniform buffer to an effect.
  7428. * @param effect Define the effect to bind the buffer to
  7429. * @param name Name of the uniform block in the shader.
  7430. */
  7431. bindToEffect(effect: Effect, name: string): void;
  7432. /**
  7433. * Disposes the uniform buffer.
  7434. */
  7435. dispose(): void;
  7436. }
  7437. }
  7438. declare module BABYLON {
  7439. /**
  7440. * Enum that determines the text-wrapping mode to use.
  7441. */
  7442. export enum InspectableType {
  7443. /**
  7444. * Checkbox for booleans
  7445. */
  7446. Checkbox = 0,
  7447. /**
  7448. * Sliders for numbers
  7449. */
  7450. Slider = 1,
  7451. /**
  7452. * Vector3
  7453. */
  7454. Vector3 = 2,
  7455. /**
  7456. * Quaternions
  7457. */
  7458. Quaternion = 3,
  7459. /**
  7460. * Color3
  7461. */
  7462. Color3 = 4,
  7463. /**
  7464. * String
  7465. */
  7466. String = 5
  7467. }
  7468. /**
  7469. * Interface used to define custom inspectable properties.
  7470. * This interface is used by the inspector to display custom property grids
  7471. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7472. */
  7473. export interface IInspectable {
  7474. /**
  7475. * Gets the label to display
  7476. */
  7477. label: string;
  7478. /**
  7479. * Gets the name of the property to edit
  7480. */
  7481. propertyName: string;
  7482. /**
  7483. * Gets the type of the editor to use
  7484. */
  7485. type: InspectableType;
  7486. /**
  7487. * Gets the minimum value of the property when using in "slider" mode
  7488. */
  7489. min?: number;
  7490. /**
  7491. * Gets the maximum value of the property when using in "slider" mode
  7492. */
  7493. max?: number;
  7494. /**
  7495. * Gets the setp to use when using in "slider" mode
  7496. */
  7497. step?: number;
  7498. }
  7499. }
  7500. declare module BABYLON {
  7501. /**
  7502. * Class used to provide helper for timing
  7503. */
  7504. export class TimingTools {
  7505. /**
  7506. * Polyfill for setImmediate
  7507. * @param action defines the action to execute after the current execution block
  7508. */
  7509. static SetImmediate(action: () => void): void;
  7510. }
  7511. }
  7512. declare module BABYLON {
  7513. /**
  7514. * Class used to enable instatition of objects by class name
  7515. */
  7516. export class InstantiationTools {
  7517. /**
  7518. * Use this object to register external classes like custom textures or material
  7519. * to allow the laoders to instantiate them
  7520. */
  7521. static RegisteredExternalClasses: {
  7522. [key: string]: Object;
  7523. };
  7524. /**
  7525. * Tries to instantiate a new object from a given class name
  7526. * @param className defines the class name to instantiate
  7527. * @returns the new object or null if the system was not able to do the instantiation
  7528. */
  7529. static Instantiate(className: string): any;
  7530. }
  7531. }
  7532. declare module BABYLON {
  7533. /**
  7534. * Define options used to create a depth texture
  7535. */
  7536. export class DepthTextureCreationOptions {
  7537. /** Specifies whether or not a stencil should be allocated in the texture */
  7538. generateStencil?: boolean;
  7539. /** Specifies whether or not bilinear filtering is enable on the texture */
  7540. bilinearFiltering?: boolean;
  7541. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7542. comparisonFunction?: number;
  7543. /** Specifies if the created texture is a cube texture */
  7544. isCube?: boolean;
  7545. }
  7546. }
  7547. declare module BABYLON {
  7548. interface ThinEngine {
  7549. /**
  7550. * Creates a depth stencil cube texture.
  7551. * This is only available in WebGL 2.
  7552. * @param size The size of face edge in the cube texture.
  7553. * @param options The options defining the cube texture.
  7554. * @returns The cube texture
  7555. */
  7556. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7557. /**
  7558. * Creates a cube texture
  7559. * @param rootUrl defines the url where the files to load is located
  7560. * @param scene defines the current scene
  7561. * @param files defines the list of files to load (1 per face)
  7562. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7563. * @param onLoad defines an optional callback raised when the texture is loaded
  7564. * @param onError defines an optional callback raised if there is an issue to load the texture
  7565. * @param format defines the format of the data
  7566. * @param forcedExtension defines the extension to use to pick the right loader
  7567. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7568. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7569. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7570. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7571. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7572. * @returns the cube texture as an InternalTexture
  7573. */
  7574. 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>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7575. /**
  7576. * Creates a cube texture
  7577. * @param rootUrl defines the url where the files to load is located
  7578. * @param scene defines the current scene
  7579. * @param files defines the list of files to load (1 per face)
  7580. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7581. * @param onLoad defines an optional callback raised when the texture is loaded
  7582. * @param onError defines an optional callback raised if there is an issue to load the texture
  7583. * @param format defines the format of the data
  7584. * @param forcedExtension defines the extension to use to pick the right loader
  7585. * @returns the cube texture as an InternalTexture
  7586. */
  7587. 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;
  7588. /**
  7589. * Creates a cube texture
  7590. * @param rootUrl defines the url where the files to load is located
  7591. * @param scene defines the current scene
  7592. * @param files defines the list of files to load (1 per face)
  7593. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7594. * @param onLoad defines an optional callback raised when the texture is loaded
  7595. * @param onError defines an optional callback raised if there is an issue to load the texture
  7596. * @param format defines the format of the data
  7597. * @param forcedExtension defines the extension to use to pick the right loader
  7598. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7599. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7600. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7601. * @returns the cube texture as an InternalTexture
  7602. */
  7603. 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;
  7604. /** @hidden */
  7605. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7606. /** @hidden */
  7607. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7608. /** @hidden */
  7609. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7610. /** @hidden */
  7611. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7612. /**
  7613. * @hidden
  7614. */
  7615. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7616. }
  7617. }
  7618. declare module BABYLON {
  7619. /**
  7620. * Class for creating a cube texture
  7621. */
  7622. export class CubeTexture extends BaseTexture {
  7623. private _delayedOnLoad;
  7624. /**
  7625. * The url of the texture
  7626. */
  7627. url: string;
  7628. /**
  7629. * Gets or sets the center of the bounding box associated with the cube texture.
  7630. * It must define where the camera used to render the texture was set
  7631. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7632. */
  7633. boundingBoxPosition: Vector3;
  7634. private _boundingBoxSize;
  7635. /**
  7636. * Gets or sets the size of the bounding box associated with the cube texture
  7637. * When defined, the cubemap will switch to local mode
  7638. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7639. * @example https://www.babylonjs-playground.com/#RNASML
  7640. */
  7641. /**
  7642. * Returns the bounding box size
  7643. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7644. */
  7645. boundingBoxSize: Vector3;
  7646. protected _rotationY: number;
  7647. /**
  7648. * Sets texture matrix rotation angle around Y axis in radians.
  7649. */
  7650. /**
  7651. * Gets texture matrix rotation angle around Y axis radians.
  7652. */
  7653. rotationY: number;
  7654. /**
  7655. * Are mip maps generated for this texture or not.
  7656. */
  7657. readonly noMipmap: boolean;
  7658. private _noMipmap;
  7659. private _files;
  7660. protected _forcedExtension: Nullable<string>;
  7661. private _extensions;
  7662. private _textureMatrix;
  7663. private _format;
  7664. private _createPolynomials;
  7665. /** @hidden */
  7666. _prefiltered: boolean;
  7667. /**
  7668. * Creates a cube texture from an array of image urls
  7669. * @param files defines an array of image urls
  7670. * @param scene defines the hosting scene
  7671. * @param noMipmap specifies if mip maps are not used
  7672. * @returns a cube texture
  7673. */
  7674. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7675. /**
  7676. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7677. * @param url defines the url of the prefiltered texture
  7678. * @param scene defines the scene the texture is attached to
  7679. * @param forcedExtension defines the extension of the file if different from the url
  7680. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7681. * @return the prefiltered texture
  7682. */
  7683. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7684. /**
  7685. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7686. * as prefiltered data.
  7687. * @param rootUrl defines the url of the texture or the root name of the six images
  7688. * @param scene defines the scene the texture is attached to
  7689. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7690. * @param noMipmap defines if mipmaps should be created or not
  7691. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7692. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7693. * @param onError defines a callback triggered in case of error during load
  7694. * @param format defines the internal format to use for the texture once loaded
  7695. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7696. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7697. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7698. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7699. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7700. * @return the cube texture
  7701. */
  7702. constructor(rootUrl: string, scene: Scene, 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);
  7703. /**
  7704. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7705. */
  7706. readonly isPrefiltered: boolean;
  7707. /**
  7708. * Get the current class name of the texture useful for serialization or dynamic coding.
  7709. * @returns "CubeTexture"
  7710. */
  7711. getClassName(): string;
  7712. /**
  7713. * Update the url (and optional buffer) of this texture if url was null during construction.
  7714. * @param url the url of the texture
  7715. * @param forcedExtension defines the extension to use
  7716. * @param onLoad callback called when the texture is loaded (defaults to null)
  7717. */
  7718. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7719. /**
  7720. * Delays loading of the cube texture
  7721. * @param forcedExtension defines the extension to use
  7722. */
  7723. delayLoad(forcedExtension?: string): void;
  7724. /**
  7725. * Returns the reflection texture matrix
  7726. * @returns the reflection texture matrix
  7727. */
  7728. getReflectionTextureMatrix(): Matrix;
  7729. /**
  7730. * Sets the reflection texture matrix
  7731. * @param value Reflection texture matrix
  7732. */
  7733. setReflectionTextureMatrix(value: Matrix): void;
  7734. /**
  7735. * Parses text to create a cube texture
  7736. * @param parsedTexture define the serialized text to read from
  7737. * @param scene defines the hosting scene
  7738. * @param rootUrl defines the root url of the cube texture
  7739. * @returns a cube texture
  7740. */
  7741. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7742. /**
  7743. * Makes a clone, or deep copy, of the cube texture
  7744. * @returns a new cube texture
  7745. */
  7746. clone(): CubeTexture;
  7747. }
  7748. }
  7749. declare module BABYLON {
  7750. /**
  7751. * Manages the defines for the Material
  7752. */
  7753. export class MaterialDefines {
  7754. /** @hidden */
  7755. protected _keys: string[];
  7756. private _isDirty;
  7757. /** @hidden */
  7758. _renderId: number;
  7759. /** @hidden */
  7760. _areLightsDirty: boolean;
  7761. /** @hidden */
  7762. _areLightsDisposed: boolean;
  7763. /** @hidden */
  7764. _areAttributesDirty: boolean;
  7765. /** @hidden */
  7766. _areTexturesDirty: boolean;
  7767. /** @hidden */
  7768. _areFresnelDirty: boolean;
  7769. /** @hidden */
  7770. _areMiscDirty: boolean;
  7771. /** @hidden */
  7772. _areImageProcessingDirty: boolean;
  7773. /** @hidden */
  7774. _normals: boolean;
  7775. /** @hidden */
  7776. _uvs: boolean;
  7777. /** @hidden */
  7778. _needNormals: boolean;
  7779. /** @hidden */
  7780. _needUVs: boolean;
  7781. [id: string]: any;
  7782. /**
  7783. * Specifies if the material needs to be re-calculated
  7784. */
  7785. readonly isDirty: boolean;
  7786. /**
  7787. * Marks the material to indicate that it has been re-calculated
  7788. */
  7789. markAsProcessed(): void;
  7790. /**
  7791. * Marks the material to indicate that it needs to be re-calculated
  7792. */
  7793. markAsUnprocessed(): void;
  7794. /**
  7795. * Marks the material to indicate all of its defines need to be re-calculated
  7796. */
  7797. markAllAsDirty(): void;
  7798. /**
  7799. * Marks the material to indicate that image processing needs to be re-calculated
  7800. */
  7801. markAsImageProcessingDirty(): void;
  7802. /**
  7803. * Marks the material to indicate the lights need to be re-calculated
  7804. * @param disposed Defines whether the light is dirty due to dispose or not
  7805. */
  7806. markAsLightDirty(disposed?: boolean): void;
  7807. /**
  7808. * Marks the attribute state as changed
  7809. */
  7810. markAsAttributesDirty(): void;
  7811. /**
  7812. * Marks the texture state as changed
  7813. */
  7814. markAsTexturesDirty(): void;
  7815. /**
  7816. * Marks the fresnel state as changed
  7817. */
  7818. markAsFresnelDirty(): void;
  7819. /**
  7820. * Marks the misc state as changed
  7821. */
  7822. markAsMiscDirty(): void;
  7823. /**
  7824. * Rebuilds the material defines
  7825. */
  7826. rebuild(): void;
  7827. /**
  7828. * Specifies if two material defines are equal
  7829. * @param other - A material define instance to compare to
  7830. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7831. */
  7832. isEqual(other: MaterialDefines): boolean;
  7833. /**
  7834. * Clones this instance's defines to another instance
  7835. * @param other - material defines to clone values to
  7836. */
  7837. cloneTo(other: MaterialDefines): void;
  7838. /**
  7839. * Resets the material define values
  7840. */
  7841. reset(): void;
  7842. /**
  7843. * Converts the material define values to a string
  7844. * @returns - String of material define information
  7845. */
  7846. toString(): string;
  7847. }
  7848. }
  7849. declare module BABYLON {
  7850. /**
  7851. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7852. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7853. * 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;
  7854. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7855. */
  7856. export class ColorCurves {
  7857. private _dirty;
  7858. private _tempColor;
  7859. private _globalCurve;
  7860. private _highlightsCurve;
  7861. private _midtonesCurve;
  7862. private _shadowsCurve;
  7863. private _positiveCurve;
  7864. private _negativeCurve;
  7865. private _globalHue;
  7866. private _globalDensity;
  7867. private _globalSaturation;
  7868. private _globalExposure;
  7869. /**
  7870. * Gets the global Hue value.
  7871. * 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).
  7872. */
  7873. /**
  7874. * Sets the global Hue value.
  7875. * 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).
  7876. */
  7877. globalHue: number;
  7878. /**
  7879. * Gets the global Density value.
  7880. * 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.
  7881. * Values less than zero provide a filter of opposite hue.
  7882. */
  7883. /**
  7884. * Sets the global Density value.
  7885. * 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.
  7886. * Values less than zero provide a filter of opposite hue.
  7887. */
  7888. globalDensity: number;
  7889. /**
  7890. * Gets the global Saturation value.
  7891. * 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.
  7892. */
  7893. /**
  7894. * Sets the global Saturation value.
  7895. * 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.
  7896. */
  7897. globalSaturation: number;
  7898. /**
  7899. * Gets the global Exposure value.
  7900. * 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.
  7901. */
  7902. /**
  7903. * Sets the global Exposure value.
  7904. * 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.
  7905. */
  7906. globalExposure: number;
  7907. private _highlightsHue;
  7908. private _highlightsDensity;
  7909. private _highlightsSaturation;
  7910. private _highlightsExposure;
  7911. /**
  7912. * Gets the highlights Hue value.
  7913. * 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).
  7914. */
  7915. /**
  7916. * Sets the highlights Hue value.
  7917. * 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).
  7918. */
  7919. highlightsHue: number;
  7920. /**
  7921. * Gets the highlights Density value.
  7922. * 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.
  7923. * Values less than zero provide a filter of opposite hue.
  7924. */
  7925. /**
  7926. * Sets the highlights Density value.
  7927. * 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.
  7928. * Values less than zero provide a filter of opposite hue.
  7929. */
  7930. highlightsDensity: number;
  7931. /**
  7932. * Gets the highlights Saturation value.
  7933. * 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.
  7934. */
  7935. /**
  7936. * Sets the highlights Saturation value.
  7937. * 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.
  7938. */
  7939. highlightsSaturation: number;
  7940. /**
  7941. * Gets the highlights Exposure value.
  7942. * 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.
  7943. */
  7944. /**
  7945. * Sets the highlights Exposure value.
  7946. * 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.
  7947. */
  7948. highlightsExposure: number;
  7949. private _midtonesHue;
  7950. private _midtonesDensity;
  7951. private _midtonesSaturation;
  7952. private _midtonesExposure;
  7953. /**
  7954. * Gets the midtones Hue value.
  7955. * 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).
  7956. */
  7957. /**
  7958. * Sets the midtones Hue value.
  7959. * 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).
  7960. */
  7961. midtonesHue: number;
  7962. /**
  7963. * Gets the midtones Density value.
  7964. * 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.
  7965. * Values less than zero provide a filter of opposite hue.
  7966. */
  7967. /**
  7968. * Sets the midtones Density value.
  7969. * 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.
  7970. * Values less than zero provide a filter of opposite hue.
  7971. */
  7972. midtonesDensity: number;
  7973. /**
  7974. * Gets the midtones Saturation value.
  7975. * 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.
  7976. */
  7977. /**
  7978. * Sets the midtones Saturation value.
  7979. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7980. */
  7981. midtonesSaturation: number;
  7982. /**
  7983. * Gets the midtones Exposure value.
  7984. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7985. */
  7986. /**
  7987. * Sets the midtones 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. midtonesExposure: number;
  7991. private _shadowsHue;
  7992. private _shadowsDensity;
  7993. private _shadowsSaturation;
  7994. private _shadowsExposure;
  7995. /**
  7996. * Gets the shadows Hue value.
  7997. * 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).
  7998. */
  7999. /**
  8000. * Sets the shadows Hue value.
  8001. * 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).
  8002. */
  8003. shadowsHue: number;
  8004. /**
  8005. * Gets the shadows Density value.
  8006. * 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.
  8007. * Values less than zero provide a filter of opposite hue.
  8008. */
  8009. /**
  8010. * Sets the shadows Density value.
  8011. * 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.
  8012. * Values less than zero provide a filter of opposite hue.
  8013. */
  8014. shadowsDensity: number;
  8015. /**
  8016. * Gets the shadows Saturation value.
  8017. * 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.
  8018. */
  8019. /**
  8020. * Sets the shadows Saturation value.
  8021. * 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.
  8022. */
  8023. shadowsSaturation: number;
  8024. /**
  8025. * Gets the shadows Exposure value.
  8026. * 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.
  8027. */
  8028. /**
  8029. * Sets the shadows Exposure value.
  8030. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8031. */
  8032. shadowsExposure: number;
  8033. /**
  8034. * Returns the class name
  8035. * @returns The class name
  8036. */
  8037. getClassName(): string;
  8038. /**
  8039. * Binds the color curves to the shader.
  8040. * @param colorCurves The color curve to bind
  8041. * @param effect The effect to bind to
  8042. * @param positiveUniform The positive uniform shader parameter
  8043. * @param neutralUniform The neutral uniform shader parameter
  8044. * @param negativeUniform The negative uniform shader parameter
  8045. */
  8046. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8047. /**
  8048. * Prepare the list of uniforms associated with the ColorCurves effects.
  8049. * @param uniformsList The list of uniforms used in the effect
  8050. */
  8051. static PrepareUniforms(uniformsList: string[]): void;
  8052. /**
  8053. * Returns color grading data based on a hue, density, saturation and exposure value.
  8054. * @param filterHue The hue of the color filter.
  8055. * @param filterDensity The density of the color filter.
  8056. * @param saturation The saturation.
  8057. * @param exposure The exposure.
  8058. * @param result The result data container.
  8059. */
  8060. private getColorGradingDataToRef;
  8061. /**
  8062. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8063. * @param value The input slider value in range [-100,100].
  8064. * @returns Adjusted value.
  8065. */
  8066. private static applyColorGradingSliderNonlinear;
  8067. /**
  8068. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8069. * @param hue The hue (H) input.
  8070. * @param saturation The saturation (S) input.
  8071. * @param brightness The brightness (B) input.
  8072. * @result An RGBA color represented as Vector4.
  8073. */
  8074. private static fromHSBToRef;
  8075. /**
  8076. * Returns a value clamped between min and max
  8077. * @param value The value to clamp
  8078. * @param min The minimum of value
  8079. * @param max The maximum of value
  8080. * @returns The clamped value.
  8081. */
  8082. private static clamp;
  8083. /**
  8084. * Clones the current color curve instance.
  8085. * @return The cloned curves
  8086. */
  8087. clone(): ColorCurves;
  8088. /**
  8089. * Serializes the current color curve instance to a json representation.
  8090. * @return a JSON representation
  8091. */
  8092. serialize(): any;
  8093. /**
  8094. * Parses the color curve from a json representation.
  8095. * @param source the JSON source to parse
  8096. * @return The parsed curves
  8097. */
  8098. static Parse(source: any): ColorCurves;
  8099. }
  8100. }
  8101. declare module BABYLON {
  8102. /**
  8103. * Interface to follow in your material defines to integrate easily the
  8104. * Image proccessing functions.
  8105. * @hidden
  8106. */
  8107. export interface IImageProcessingConfigurationDefines {
  8108. IMAGEPROCESSING: boolean;
  8109. VIGNETTE: boolean;
  8110. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8111. VIGNETTEBLENDMODEOPAQUE: boolean;
  8112. TONEMAPPING: boolean;
  8113. TONEMAPPING_ACES: boolean;
  8114. CONTRAST: boolean;
  8115. EXPOSURE: boolean;
  8116. COLORCURVES: boolean;
  8117. COLORGRADING: boolean;
  8118. COLORGRADING3D: boolean;
  8119. SAMPLER3DGREENDEPTH: boolean;
  8120. SAMPLER3DBGRMAP: boolean;
  8121. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8122. }
  8123. /**
  8124. * @hidden
  8125. */
  8126. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8127. IMAGEPROCESSING: boolean;
  8128. VIGNETTE: boolean;
  8129. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8130. VIGNETTEBLENDMODEOPAQUE: boolean;
  8131. TONEMAPPING: boolean;
  8132. TONEMAPPING_ACES: boolean;
  8133. CONTRAST: boolean;
  8134. COLORCURVES: boolean;
  8135. COLORGRADING: boolean;
  8136. COLORGRADING3D: boolean;
  8137. SAMPLER3DGREENDEPTH: boolean;
  8138. SAMPLER3DBGRMAP: boolean;
  8139. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8140. EXPOSURE: boolean;
  8141. constructor();
  8142. }
  8143. /**
  8144. * This groups together the common properties used for image processing either in direct forward pass
  8145. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8146. * or not.
  8147. */
  8148. export class ImageProcessingConfiguration {
  8149. /**
  8150. * Default tone mapping applied in BabylonJS.
  8151. */
  8152. static readonly TONEMAPPING_STANDARD: number;
  8153. /**
  8154. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8155. * to other engines rendering to increase portability.
  8156. */
  8157. static readonly TONEMAPPING_ACES: number;
  8158. /**
  8159. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8160. */
  8161. colorCurves: Nullable<ColorCurves>;
  8162. private _colorCurvesEnabled;
  8163. /**
  8164. * Gets wether the color curves effect is enabled.
  8165. */
  8166. /**
  8167. * Sets wether the color curves effect is enabled.
  8168. */
  8169. colorCurvesEnabled: boolean;
  8170. private _colorGradingTexture;
  8171. /**
  8172. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8173. */
  8174. /**
  8175. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8176. */
  8177. colorGradingTexture: Nullable<BaseTexture>;
  8178. private _colorGradingEnabled;
  8179. /**
  8180. * Gets wether the color grading effect is enabled.
  8181. */
  8182. /**
  8183. * Sets wether the color grading effect is enabled.
  8184. */
  8185. colorGradingEnabled: boolean;
  8186. private _colorGradingWithGreenDepth;
  8187. /**
  8188. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8189. */
  8190. /**
  8191. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8192. */
  8193. colorGradingWithGreenDepth: boolean;
  8194. private _colorGradingBGR;
  8195. /**
  8196. * Gets wether the color grading texture contains BGR values.
  8197. */
  8198. /**
  8199. * Sets wether the color grading texture contains BGR values.
  8200. */
  8201. colorGradingBGR: boolean;
  8202. /** @hidden */
  8203. _exposure: number;
  8204. /**
  8205. * Gets the Exposure used in the effect.
  8206. */
  8207. /**
  8208. * Sets the Exposure used in the effect.
  8209. */
  8210. exposure: number;
  8211. private _toneMappingEnabled;
  8212. /**
  8213. * Gets wether the tone mapping effect is enabled.
  8214. */
  8215. /**
  8216. * Sets wether the tone mapping effect is enabled.
  8217. */
  8218. toneMappingEnabled: boolean;
  8219. private _toneMappingType;
  8220. /**
  8221. * Gets the type of tone mapping effect.
  8222. */
  8223. /**
  8224. * Sets the type of tone mapping effect used in BabylonJS.
  8225. */
  8226. toneMappingType: number;
  8227. protected _contrast: number;
  8228. /**
  8229. * Gets the contrast used in the effect.
  8230. */
  8231. /**
  8232. * Sets the contrast used in the effect.
  8233. */
  8234. contrast: number;
  8235. /**
  8236. * Vignette stretch size.
  8237. */
  8238. vignetteStretch: number;
  8239. /**
  8240. * Vignette centre X Offset.
  8241. */
  8242. vignetteCentreX: number;
  8243. /**
  8244. * Vignette centre Y Offset.
  8245. */
  8246. vignetteCentreY: number;
  8247. /**
  8248. * Vignette weight or intensity of the vignette effect.
  8249. */
  8250. vignetteWeight: number;
  8251. /**
  8252. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8253. * if vignetteEnabled is set to true.
  8254. */
  8255. vignetteColor: Color4;
  8256. /**
  8257. * Camera field of view used by the Vignette effect.
  8258. */
  8259. vignetteCameraFov: number;
  8260. private _vignetteBlendMode;
  8261. /**
  8262. * Gets the vignette blend mode allowing different kind of effect.
  8263. */
  8264. /**
  8265. * Sets the vignette blend mode allowing different kind of effect.
  8266. */
  8267. vignetteBlendMode: number;
  8268. private _vignetteEnabled;
  8269. /**
  8270. * Gets wether the vignette effect is enabled.
  8271. */
  8272. /**
  8273. * Sets wether the vignette effect is enabled.
  8274. */
  8275. vignetteEnabled: boolean;
  8276. private _applyByPostProcess;
  8277. /**
  8278. * Gets wether the image processing is applied through a post process or not.
  8279. */
  8280. /**
  8281. * Sets wether the image processing is applied through a post process or not.
  8282. */
  8283. applyByPostProcess: boolean;
  8284. private _isEnabled;
  8285. /**
  8286. * Gets wether the image processing is enabled or not.
  8287. */
  8288. /**
  8289. * Sets wether the image processing is enabled or not.
  8290. */
  8291. isEnabled: boolean;
  8292. /**
  8293. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8294. */
  8295. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8296. /**
  8297. * Method called each time the image processing information changes requires to recompile the effect.
  8298. */
  8299. protected _updateParameters(): void;
  8300. /**
  8301. * Gets the current class name.
  8302. * @return "ImageProcessingConfiguration"
  8303. */
  8304. getClassName(): string;
  8305. /**
  8306. * Prepare the list of uniforms associated with the Image Processing effects.
  8307. * @param uniforms The list of uniforms used in the effect
  8308. * @param defines the list of defines currently in use
  8309. */
  8310. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8311. /**
  8312. * Prepare the list of samplers associated with the Image Processing effects.
  8313. * @param samplersList The list of uniforms used in the effect
  8314. * @param defines the list of defines currently in use
  8315. */
  8316. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8317. /**
  8318. * Prepare the list of defines associated to the shader.
  8319. * @param defines the list of defines to complete
  8320. * @param forPostProcess Define if we are currently in post process mode or not
  8321. */
  8322. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8323. /**
  8324. * Returns true if all the image processing information are ready.
  8325. * @returns True if ready, otherwise, false
  8326. */
  8327. isReady(): boolean;
  8328. /**
  8329. * Binds the image processing to the shader.
  8330. * @param effect The effect to bind to
  8331. * @param overrideAspectRatio Override the aspect ratio of the effect
  8332. */
  8333. bind(effect: Effect, overrideAspectRatio?: number): void;
  8334. /**
  8335. * Clones the current image processing instance.
  8336. * @return The cloned image processing
  8337. */
  8338. clone(): ImageProcessingConfiguration;
  8339. /**
  8340. * Serializes the current image processing instance to a json representation.
  8341. * @return a JSON representation
  8342. */
  8343. serialize(): any;
  8344. /**
  8345. * Parses the image processing from a json representation.
  8346. * @param source the JSON source to parse
  8347. * @return The parsed image processing
  8348. */
  8349. static Parse(source: any): ImageProcessingConfiguration;
  8350. private static _VIGNETTEMODE_MULTIPLY;
  8351. private static _VIGNETTEMODE_OPAQUE;
  8352. /**
  8353. * Used to apply the vignette as a mix with the pixel color.
  8354. */
  8355. static readonly VIGNETTEMODE_MULTIPLY: number;
  8356. /**
  8357. * Used to apply the vignette as a replacement of the pixel color.
  8358. */
  8359. static readonly VIGNETTEMODE_OPAQUE: number;
  8360. }
  8361. }
  8362. declare module BABYLON {
  8363. /** @hidden */
  8364. export var postprocessVertexShader: {
  8365. name: string;
  8366. shader: string;
  8367. };
  8368. }
  8369. declare module BABYLON {
  8370. interface ThinEngine {
  8371. /**
  8372. * Creates a new render target texture
  8373. * @param size defines the size of the texture
  8374. * @param options defines the options used to create the texture
  8375. * @returns a new render target texture stored in an InternalTexture
  8376. */
  8377. createRenderTargetTexture(size: number | {
  8378. width: number;
  8379. height: number;
  8380. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8381. /**
  8382. * Creates a depth stencil texture.
  8383. * This is only available in WebGL 2 or with the depth texture extension available.
  8384. * @param size The size of face edge in the texture.
  8385. * @param options The options defining the texture.
  8386. * @returns The texture
  8387. */
  8388. createDepthStencilTexture(size: number | {
  8389. width: number;
  8390. height: number;
  8391. }, options: DepthTextureCreationOptions): InternalTexture;
  8392. /** @hidden */
  8393. _createDepthStencilTexture(size: number | {
  8394. width: number;
  8395. height: number;
  8396. }, options: DepthTextureCreationOptions): InternalTexture;
  8397. }
  8398. }
  8399. declare module BABYLON {
  8400. /** Defines supported spaces */
  8401. export enum Space {
  8402. /** Local (object) space */
  8403. LOCAL = 0,
  8404. /** World space */
  8405. WORLD = 1,
  8406. /** Bone space */
  8407. BONE = 2
  8408. }
  8409. /** Defines the 3 main axes */
  8410. export class Axis {
  8411. /** X axis */
  8412. static X: Vector3;
  8413. /** Y axis */
  8414. static Y: Vector3;
  8415. /** Z axis */
  8416. static Z: Vector3;
  8417. }
  8418. }
  8419. declare module BABYLON {
  8420. /**
  8421. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8422. * This is the base of the follow, arc rotate cameras and Free camera
  8423. * @see http://doc.babylonjs.com/features/cameras
  8424. */
  8425. export class TargetCamera extends Camera {
  8426. private static _RigCamTransformMatrix;
  8427. private static _TargetTransformMatrix;
  8428. private static _TargetFocalPoint;
  8429. /**
  8430. * Define the current direction the camera is moving to
  8431. */
  8432. cameraDirection: Vector3;
  8433. /**
  8434. * Define the current rotation the camera is rotating to
  8435. */
  8436. cameraRotation: Vector2;
  8437. /**
  8438. * When set, the up vector of the camera will be updated by the rotation of the camera
  8439. */
  8440. updateUpVectorFromRotation: boolean;
  8441. private _tmpQuaternion;
  8442. /**
  8443. * Define the current rotation of the camera
  8444. */
  8445. rotation: Vector3;
  8446. /**
  8447. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8448. */
  8449. rotationQuaternion: Quaternion;
  8450. /**
  8451. * Define the current speed of the camera
  8452. */
  8453. speed: number;
  8454. /**
  8455. * Add constraint to the camera to prevent it to move freely in all directions and
  8456. * around all axis.
  8457. */
  8458. noRotationConstraint: boolean;
  8459. /**
  8460. * Define the current target of the camera as an object or a position.
  8461. */
  8462. lockedTarget: any;
  8463. /** @hidden */
  8464. _currentTarget: Vector3;
  8465. /** @hidden */
  8466. _initialFocalDistance: number;
  8467. /** @hidden */
  8468. _viewMatrix: Matrix;
  8469. /** @hidden */
  8470. _camMatrix: Matrix;
  8471. /** @hidden */
  8472. _cameraTransformMatrix: Matrix;
  8473. /** @hidden */
  8474. _cameraRotationMatrix: Matrix;
  8475. /** @hidden */
  8476. _referencePoint: Vector3;
  8477. /** @hidden */
  8478. _transformedReferencePoint: Vector3;
  8479. protected _globalCurrentTarget: Vector3;
  8480. protected _globalCurrentUpVector: Vector3;
  8481. /** @hidden */
  8482. _reset: () => void;
  8483. private _defaultUp;
  8484. /**
  8485. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8486. * This is the base of the follow, arc rotate cameras and Free camera
  8487. * @see http://doc.babylonjs.com/features/cameras
  8488. * @param name Defines the name of the camera in the scene
  8489. * @param position Defines the start position of the camera in the scene
  8490. * @param scene Defines the scene the camera belongs to
  8491. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8492. */
  8493. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8494. /**
  8495. * Gets the position in front of the camera at a given distance.
  8496. * @param distance The distance from the camera we want the position to be
  8497. * @returns the position
  8498. */
  8499. getFrontPosition(distance: number): Vector3;
  8500. /** @hidden */
  8501. _getLockedTargetPosition(): Nullable<Vector3>;
  8502. private _storedPosition;
  8503. private _storedRotation;
  8504. private _storedRotationQuaternion;
  8505. /**
  8506. * Store current camera state of the camera (fov, position, rotation, etc..)
  8507. * @returns the camera
  8508. */
  8509. storeState(): Camera;
  8510. /**
  8511. * Restored camera state. You must call storeState() first
  8512. * @returns whether it was successful or not
  8513. * @hidden
  8514. */
  8515. _restoreStateValues(): boolean;
  8516. /** @hidden */
  8517. _initCache(): void;
  8518. /** @hidden */
  8519. _updateCache(ignoreParentClass?: boolean): void;
  8520. /** @hidden */
  8521. _isSynchronizedViewMatrix(): boolean;
  8522. /** @hidden */
  8523. _computeLocalCameraSpeed(): number;
  8524. /**
  8525. * Defines the target the camera should look at.
  8526. * @param target Defines the new target as a Vector or a mesh
  8527. */
  8528. setTarget(target: Vector3): void;
  8529. /**
  8530. * Return the current target position of the camera. This value is expressed in local space.
  8531. * @returns the target position
  8532. */
  8533. getTarget(): Vector3;
  8534. /** @hidden */
  8535. _decideIfNeedsToMove(): boolean;
  8536. /** @hidden */
  8537. _updatePosition(): void;
  8538. /** @hidden */
  8539. _checkInputs(): void;
  8540. protected _updateCameraRotationMatrix(): void;
  8541. /**
  8542. * 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)
  8543. * @returns the current camera
  8544. */
  8545. private _rotateUpVectorWithCameraRotationMatrix;
  8546. private _cachedRotationZ;
  8547. private _cachedQuaternionRotationZ;
  8548. /** @hidden */
  8549. _getViewMatrix(): Matrix;
  8550. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8551. /**
  8552. * @hidden
  8553. */
  8554. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8555. /**
  8556. * @hidden
  8557. */
  8558. _updateRigCameras(): void;
  8559. private _getRigCamPositionAndTarget;
  8560. /**
  8561. * Gets the current object class name.
  8562. * @return the class name
  8563. */
  8564. getClassName(): string;
  8565. }
  8566. }
  8567. declare module BABYLON {
  8568. /**
  8569. * Gather the list of keyboard event types as constants.
  8570. */
  8571. export class KeyboardEventTypes {
  8572. /**
  8573. * The keydown event is fired when a key becomes active (pressed).
  8574. */
  8575. static readonly KEYDOWN: number;
  8576. /**
  8577. * The keyup event is fired when a key has been released.
  8578. */
  8579. static readonly KEYUP: number;
  8580. }
  8581. /**
  8582. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8583. */
  8584. export class KeyboardInfo {
  8585. /**
  8586. * Defines the type of event (KeyboardEventTypes)
  8587. */
  8588. type: number;
  8589. /**
  8590. * Defines the related dom event
  8591. */
  8592. event: KeyboardEvent;
  8593. /**
  8594. * Instantiates a new keyboard info.
  8595. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8596. * @param type Defines the type of event (KeyboardEventTypes)
  8597. * @param event Defines the related dom event
  8598. */
  8599. constructor(
  8600. /**
  8601. * Defines the type of event (KeyboardEventTypes)
  8602. */
  8603. type: number,
  8604. /**
  8605. * Defines the related dom event
  8606. */
  8607. event: KeyboardEvent);
  8608. }
  8609. /**
  8610. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8611. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8612. */
  8613. export class KeyboardInfoPre extends KeyboardInfo {
  8614. /**
  8615. * Defines the type of event (KeyboardEventTypes)
  8616. */
  8617. type: number;
  8618. /**
  8619. * Defines the related dom event
  8620. */
  8621. event: KeyboardEvent;
  8622. /**
  8623. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8624. */
  8625. skipOnPointerObservable: boolean;
  8626. /**
  8627. * Instantiates a new keyboard pre info.
  8628. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8629. * @param type Defines the type of event (KeyboardEventTypes)
  8630. * @param event Defines the related dom event
  8631. */
  8632. constructor(
  8633. /**
  8634. * Defines the type of event (KeyboardEventTypes)
  8635. */
  8636. type: number,
  8637. /**
  8638. * Defines the related dom event
  8639. */
  8640. event: KeyboardEvent);
  8641. }
  8642. }
  8643. declare module BABYLON {
  8644. /**
  8645. * Manage the keyboard inputs to control the movement of a free camera.
  8646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8647. */
  8648. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8649. /**
  8650. * Defines the camera the input is attached to.
  8651. */
  8652. camera: FreeCamera;
  8653. /**
  8654. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8655. */
  8656. keysUp: number[];
  8657. /**
  8658. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8659. */
  8660. keysDown: number[];
  8661. /**
  8662. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8663. */
  8664. keysLeft: number[];
  8665. /**
  8666. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8667. */
  8668. keysRight: number[];
  8669. private _keys;
  8670. private _onCanvasBlurObserver;
  8671. private _onKeyboardObserver;
  8672. private _engine;
  8673. private _scene;
  8674. /**
  8675. * Attach the input controls to a specific dom element to get the input from.
  8676. * @param element Defines the element the controls should be listened from
  8677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8678. */
  8679. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8680. /**
  8681. * Detach the current controls from the specified dom element.
  8682. * @param element Defines the element to stop listening the inputs from
  8683. */
  8684. detachControl(element: Nullable<HTMLElement>): void;
  8685. /**
  8686. * Update the current camera state depending on the inputs that have been used this frame.
  8687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8688. */
  8689. checkInputs(): void;
  8690. /**
  8691. * Gets the class name of the current intput.
  8692. * @returns the class name
  8693. */
  8694. getClassName(): string;
  8695. /** @hidden */
  8696. _onLostFocus(): void;
  8697. /**
  8698. * Get the friendly name associated with the input class.
  8699. * @returns the input friendly name
  8700. */
  8701. getSimpleName(): string;
  8702. }
  8703. }
  8704. declare module BABYLON {
  8705. /**
  8706. * Interface describing all the common properties and methods a shadow light needs to implement.
  8707. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8708. * as well as binding the different shadow properties to the effects.
  8709. */
  8710. export interface IShadowLight extends Light {
  8711. /**
  8712. * The light id in the scene (used in scene.findLighById for instance)
  8713. */
  8714. id: string;
  8715. /**
  8716. * The position the shdow will be casted from.
  8717. */
  8718. position: Vector3;
  8719. /**
  8720. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8721. */
  8722. direction: Vector3;
  8723. /**
  8724. * The transformed position. Position of the light in world space taking parenting in account.
  8725. */
  8726. transformedPosition: Vector3;
  8727. /**
  8728. * The transformed direction. Direction of the light in world space taking parenting in account.
  8729. */
  8730. transformedDirection: Vector3;
  8731. /**
  8732. * The friendly name of the light in the scene.
  8733. */
  8734. name: string;
  8735. /**
  8736. * Defines the shadow projection clipping minimum z value.
  8737. */
  8738. shadowMinZ: number;
  8739. /**
  8740. * Defines the shadow projection clipping maximum z value.
  8741. */
  8742. shadowMaxZ: number;
  8743. /**
  8744. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8745. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8746. */
  8747. computeTransformedInformation(): boolean;
  8748. /**
  8749. * Gets the scene the light belongs to.
  8750. * @returns The scene
  8751. */
  8752. getScene(): Scene;
  8753. /**
  8754. * Callback defining a custom Projection Matrix Builder.
  8755. * This can be used to override the default projection matrix computation.
  8756. */
  8757. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8758. /**
  8759. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8760. * @param matrix The materix to updated with the projection information
  8761. * @param viewMatrix The transform matrix of the light
  8762. * @param renderList The list of mesh to render in the map
  8763. * @returns The current light
  8764. */
  8765. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8766. /**
  8767. * Gets the current depth scale used in ESM.
  8768. * @returns The scale
  8769. */
  8770. getDepthScale(): number;
  8771. /**
  8772. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8773. * @returns true if a cube texture needs to be use
  8774. */
  8775. needCube(): boolean;
  8776. /**
  8777. * Detects if the projection matrix requires to be recomputed this frame.
  8778. * @returns true if it requires to be recomputed otherwise, false.
  8779. */
  8780. needProjectionMatrixCompute(): boolean;
  8781. /**
  8782. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8783. */
  8784. forceProjectionMatrixCompute(): void;
  8785. /**
  8786. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8787. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8788. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8789. */
  8790. getShadowDirection(faceIndex?: number): Vector3;
  8791. /**
  8792. * Gets the minZ used for shadow according to both the scene and the light.
  8793. * @param activeCamera The camera we are returning the min for
  8794. * @returns the depth min z
  8795. */
  8796. getDepthMinZ(activeCamera: Camera): number;
  8797. /**
  8798. * Gets the maxZ used for shadow according to both the scene and the light.
  8799. * @param activeCamera The camera we are returning the max for
  8800. * @returns the depth max z
  8801. */
  8802. getDepthMaxZ(activeCamera: Camera): number;
  8803. }
  8804. /**
  8805. * Base implementation IShadowLight
  8806. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8807. */
  8808. export abstract class ShadowLight extends Light implements IShadowLight {
  8809. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8810. protected _position: Vector3;
  8811. protected _setPosition(value: Vector3): void;
  8812. /**
  8813. * Sets the position the shadow will be casted from. Also use as the light position for both
  8814. * point and spot lights.
  8815. */
  8816. /**
  8817. * Sets the position the shadow will be casted from. Also use as the light position for both
  8818. * point and spot lights.
  8819. */
  8820. position: Vector3;
  8821. protected _direction: Vector3;
  8822. protected _setDirection(value: Vector3): void;
  8823. /**
  8824. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8825. * Also use as the light direction on spot and directional lights.
  8826. */
  8827. /**
  8828. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8829. * Also use as the light direction on spot and directional lights.
  8830. */
  8831. direction: Vector3;
  8832. private _shadowMinZ;
  8833. /**
  8834. * Gets the shadow projection clipping minimum z value.
  8835. */
  8836. /**
  8837. * Sets the shadow projection clipping minimum z value.
  8838. */
  8839. shadowMinZ: number;
  8840. private _shadowMaxZ;
  8841. /**
  8842. * Sets the shadow projection clipping maximum z value.
  8843. */
  8844. /**
  8845. * Gets the shadow projection clipping maximum z value.
  8846. */
  8847. shadowMaxZ: number;
  8848. /**
  8849. * Callback defining a custom Projection Matrix Builder.
  8850. * This can be used to override the default projection matrix computation.
  8851. */
  8852. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8853. /**
  8854. * The transformed position. Position of the light in world space taking parenting in account.
  8855. */
  8856. transformedPosition: Vector3;
  8857. /**
  8858. * The transformed direction. Direction of the light in world space taking parenting in account.
  8859. */
  8860. transformedDirection: Vector3;
  8861. private _needProjectionMatrixCompute;
  8862. /**
  8863. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8864. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8865. */
  8866. computeTransformedInformation(): boolean;
  8867. /**
  8868. * Return the depth scale used for the shadow map.
  8869. * @returns the depth scale.
  8870. */
  8871. getDepthScale(): number;
  8872. /**
  8873. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8874. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8875. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8876. */
  8877. getShadowDirection(faceIndex?: number): Vector3;
  8878. /**
  8879. * Returns the ShadowLight absolute position in the World.
  8880. * @returns the position vector in world space
  8881. */
  8882. getAbsolutePosition(): Vector3;
  8883. /**
  8884. * Sets the ShadowLight direction toward the passed target.
  8885. * @param target The point to target in local space
  8886. * @returns the updated ShadowLight direction
  8887. */
  8888. setDirectionToTarget(target: Vector3): Vector3;
  8889. /**
  8890. * Returns the light rotation in euler definition.
  8891. * @returns the x y z rotation in local space.
  8892. */
  8893. getRotation(): Vector3;
  8894. /**
  8895. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8896. * @returns true if a cube texture needs to be use
  8897. */
  8898. needCube(): boolean;
  8899. /**
  8900. * Detects if the projection matrix requires to be recomputed this frame.
  8901. * @returns true if it requires to be recomputed otherwise, false.
  8902. */
  8903. needProjectionMatrixCompute(): boolean;
  8904. /**
  8905. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8906. */
  8907. forceProjectionMatrixCompute(): void;
  8908. /** @hidden */
  8909. _initCache(): void;
  8910. /** @hidden */
  8911. _isSynchronized(): boolean;
  8912. /**
  8913. * Computes the world matrix of the node
  8914. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8915. * @returns the world matrix
  8916. */
  8917. computeWorldMatrix(force?: boolean): Matrix;
  8918. /**
  8919. * Gets the minZ used for shadow according to both the scene and the light.
  8920. * @param activeCamera The camera we are returning the min for
  8921. * @returns the depth min z
  8922. */
  8923. getDepthMinZ(activeCamera: Camera): number;
  8924. /**
  8925. * Gets the maxZ used for shadow according to both the scene and the light.
  8926. * @param activeCamera The camera we are returning the max for
  8927. * @returns the depth max z
  8928. */
  8929. getDepthMaxZ(activeCamera: Camera): number;
  8930. /**
  8931. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8932. * @param matrix The materix to updated with the projection information
  8933. * @param viewMatrix The transform matrix of the light
  8934. * @param renderList The list of mesh to render in the map
  8935. * @returns The current light
  8936. */
  8937. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8938. }
  8939. }
  8940. declare module BABYLON {
  8941. /**
  8942. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8943. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8944. */
  8945. export class EffectFallbacks implements IEffectFallbacks {
  8946. private _defines;
  8947. private _currentRank;
  8948. private _maxRank;
  8949. private _mesh;
  8950. /**
  8951. * Removes the fallback from the bound mesh.
  8952. */
  8953. unBindMesh(): void;
  8954. /**
  8955. * Adds a fallback on the specified property.
  8956. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8957. * @param define The name of the define in the shader
  8958. */
  8959. addFallback(rank: number, define: string): void;
  8960. /**
  8961. * Sets the mesh to use CPU skinning when needing to fallback.
  8962. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8963. * @param mesh The mesh to use the fallbacks.
  8964. */
  8965. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8966. /**
  8967. * Checks to see if more fallbacks are still availible.
  8968. */
  8969. readonly hasMoreFallbacks: boolean;
  8970. /**
  8971. * Removes the defines that should be removed when falling back.
  8972. * @param currentDefines defines the current define statements for the shader.
  8973. * @param effect defines the current effect we try to compile
  8974. * @returns The resulting defines with defines of the current rank removed.
  8975. */
  8976. reduce(currentDefines: string, effect: Effect): string;
  8977. }
  8978. }
  8979. declare module BABYLON {
  8980. /**
  8981. * "Static Class" containing the most commonly used helper while dealing with material for
  8982. * rendering purpose.
  8983. *
  8984. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8985. *
  8986. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8987. */
  8988. export class MaterialHelper {
  8989. /**
  8990. * Bind the current view position to an effect.
  8991. * @param effect The effect to be bound
  8992. * @param scene The scene the eyes position is used from
  8993. */
  8994. static BindEyePosition(effect: Effect, scene: Scene): void;
  8995. /**
  8996. * Helps preparing the defines values about the UVs in used in the effect.
  8997. * UVs are shared as much as we can accross channels in the shaders.
  8998. * @param texture The texture we are preparing the UVs for
  8999. * @param defines The defines to update
  9000. * @param key The channel key "diffuse", "specular"... used in the shader
  9001. */
  9002. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9003. /**
  9004. * Binds a texture matrix value to its corrsponding uniform
  9005. * @param texture The texture to bind the matrix for
  9006. * @param uniformBuffer The uniform buffer receivin the data
  9007. * @param key The channel key "diffuse", "specular"... used in the shader
  9008. */
  9009. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9010. /**
  9011. * Gets the current status of the fog (should it be enabled?)
  9012. * @param mesh defines the mesh to evaluate for fog support
  9013. * @param scene defines the hosting scene
  9014. * @returns true if fog must be enabled
  9015. */
  9016. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9017. /**
  9018. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9019. * @param mesh defines the current mesh
  9020. * @param scene defines the current scene
  9021. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9022. * @param pointsCloud defines if point cloud rendering has to be turned on
  9023. * @param fogEnabled defines if fog has to be turned on
  9024. * @param alphaTest defines if alpha testing has to be turned on
  9025. * @param defines defines the current list of defines
  9026. */
  9027. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9028. /**
  9029. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9030. * @param scene defines the current scene
  9031. * @param engine defines the current engine
  9032. * @param defines specifies the list of active defines
  9033. * @param useInstances defines if instances have to be turned on
  9034. * @param useClipPlane defines if clip plane have to be turned on
  9035. */
  9036. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9037. /**
  9038. * Prepares the defines for bones
  9039. * @param mesh The mesh containing the geometry data we will draw
  9040. * @param defines The defines to update
  9041. */
  9042. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9043. /**
  9044. * Prepares the defines for morph targets
  9045. * @param mesh The mesh containing the geometry data we will draw
  9046. * @param defines The defines to update
  9047. */
  9048. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9049. /**
  9050. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9051. * @param mesh The mesh containing the geometry data we will draw
  9052. * @param defines The defines to update
  9053. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9054. * @param useBones Precise whether bones should be used or not (override mesh info)
  9055. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9056. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9057. * @returns false if defines are considered not dirty and have not been checked
  9058. */
  9059. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9060. /**
  9061. * Prepares the defines related to multiview
  9062. * @param scene The scene we are intending to draw
  9063. * @param defines The defines to update
  9064. */
  9065. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9066. /**
  9067. * Prepares the defines related to the light information passed in parameter
  9068. * @param scene The scene we are intending to draw
  9069. * @param mesh The mesh the effect is compiling for
  9070. * @param light The light the effect is compiling for
  9071. * @param lightIndex The index of the light
  9072. * @param defines The defines to update
  9073. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9074. * @param state Defines the current state regarding what is needed (normals, etc...)
  9075. */
  9076. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9077. needNormals: boolean;
  9078. needRebuild: boolean;
  9079. shadowEnabled: boolean;
  9080. specularEnabled: boolean;
  9081. lightmapMode: boolean;
  9082. }): void;
  9083. /**
  9084. * Prepares the defines related to the light information passed in parameter
  9085. * @param scene The scene we are intending to draw
  9086. * @param mesh The mesh the effect is compiling for
  9087. * @param defines The defines to update
  9088. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9089. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9090. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9091. * @returns true if normals will be required for the rest of the effect
  9092. */
  9093. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9094. /**
  9095. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9096. * @param lightIndex defines the light index
  9097. * @param uniformsList The uniform list
  9098. * @param samplersList The sampler list
  9099. * @param projectedLightTexture defines if projected texture must be used
  9100. * @param uniformBuffersList defines an optional list of uniform buffers
  9101. */
  9102. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9103. /**
  9104. * Prepares the uniforms and samplers list to be used in the effect
  9105. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9106. * @param samplersList The sampler list
  9107. * @param defines The defines helping in the list generation
  9108. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9109. */
  9110. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9111. /**
  9112. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9113. * @param defines The defines to update while falling back
  9114. * @param fallbacks The authorized effect fallbacks
  9115. * @param maxSimultaneousLights The maximum number of lights allowed
  9116. * @param rank the current rank of the Effect
  9117. * @returns The newly affected rank
  9118. */
  9119. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9120. private static _TmpMorphInfluencers;
  9121. /**
  9122. * Prepares the list of attributes required for morph targets according to the effect defines.
  9123. * @param attribs The current list of supported attribs
  9124. * @param mesh The mesh to prepare the morph targets attributes for
  9125. * @param influencers The number of influencers
  9126. */
  9127. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9128. /**
  9129. * Prepares the list of attributes required for morph targets according to the effect defines.
  9130. * @param attribs The current list of supported attribs
  9131. * @param mesh The mesh to prepare the morph targets attributes for
  9132. * @param defines The current Defines of the effect
  9133. */
  9134. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9135. /**
  9136. * Prepares the list of attributes required for bones according to the effect defines.
  9137. * @param attribs The current list of supported attribs
  9138. * @param mesh The mesh to prepare the bones attributes for
  9139. * @param defines The current Defines of the effect
  9140. * @param fallbacks The current efffect fallback strategy
  9141. */
  9142. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9143. /**
  9144. * Check and prepare the list of attributes required for instances according to the effect defines.
  9145. * @param attribs The current list of supported attribs
  9146. * @param defines The current MaterialDefines of the effect
  9147. */
  9148. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9149. /**
  9150. * Add the list of attributes required for instances to the attribs array.
  9151. * @param attribs The current list of supported attribs
  9152. */
  9153. static PushAttributesForInstances(attribs: string[]): void;
  9154. /**
  9155. * Binds the light information to the effect.
  9156. * @param light The light containing the generator
  9157. * @param effect The effect we are binding the data to
  9158. * @param lightIndex The light index in the effect used to render
  9159. */
  9160. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9161. /**
  9162. * Binds the lights information from the scene to the effect for the given mesh.
  9163. * @param light Light to bind
  9164. * @param lightIndex Light index
  9165. * @param scene The scene where the light belongs to
  9166. * @param effect The effect we are binding the data to
  9167. * @param useSpecular Defines if specular is supported
  9168. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9169. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9170. */
  9171. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9172. /**
  9173. * Binds the lights information from the scene to the effect for the given mesh.
  9174. * @param scene The scene the lights belongs to
  9175. * @param mesh The mesh we are binding the information to render
  9176. * @param effect The effect we are binding the data to
  9177. * @param defines The generated defines for the effect
  9178. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9179. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9180. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9181. */
  9182. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9183. private static _tempFogColor;
  9184. /**
  9185. * Binds the fog information from the scene to the effect for the given mesh.
  9186. * @param scene The scene the lights belongs to
  9187. * @param mesh The mesh we are binding the information to render
  9188. * @param effect The effect we are binding the data to
  9189. * @param linearSpace Defines if the fog effect is applied in linear space
  9190. */
  9191. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9192. /**
  9193. * Binds the bones information from the mesh to the effect.
  9194. * @param mesh The mesh we are binding the information to render
  9195. * @param effect The effect we are binding the data to
  9196. */
  9197. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9198. /**
  9199. * Binds the morph targets information from the mesh to the effect.
  9200. * @param abstractMesh The mesh we are binding the information to render
  9201. * @param effect The effect we are binding the data to
  9202. */
  9203. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9204. /**
  9205. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9206. * @param defines The generated defines used in the effect
  9207. * @param effect The effect we are binding the data to
  9208. * @param scene The scene we are willing to render with logarithmic scale for
  9209. */
  9210. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9211. /**
  9212. * Binds the clip plane information from the scene to the effect.
  9213. * @param scene The scene the clip plane information are extracted from
  9214. * @param effect The effect we are binding the data to
  9215. */
  9216. static BindClipPlane(effect: Effect, scene: Scene): void;
  9217. }
  9218. }
  9219. declare module BABYLON {
  9220. /** @hidden */
  9221. export var packingFunctions: {
  9222. name: string;
  9223. shader: string;
  9224. };
  9225. }
  9226. declare module BABYLON {
  9227. /** @hidden */
  9228. export var shadowMapPixelShader: {
  9229. name: string;
  9230. shader: string;
  9231. };
  9232. }
  9233. declare module BABYLON {
  9234. /** @hidden */
  9235. export var bonesDeclaration: {
  9236. name: string;
  9237. shader: string;
  9238. };
  9239. }
  9240. declare module BABYLON {
  9241. /** @hidden */
  9242. export var morphTargetsVertexGlobalDeclaration: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module BABYLON {
  9248. /** @hidden */
  9249. export var morphTargetsVertexDeclaration: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module BABYLON {
  9255. /** @hidden */
  9256. export var instancesDeclaration: {
  9257. name: string;
  9258. shader: string;
  9259. };
  9260. }
  9261. declare module BABYLON {
  9262. /** @hidden */
  9263. export var helperFunctions: {
  9264. name: string;
  9265. shader: string;
  9266. };
  9267. }
  9268. declare module BABYLON {
  9269. /** @hidden */
  9270. export var morphTargetsVertex: {
  9271. name: string;
  9272. shader: string;
  9273. };
  9274. }
  9275. declare module BABYLON {
  9276. /** @hidden */
  9277. export var instancesVertex: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module BABYLON {
  9283. /** @hidden */
  9284. export var bonesVertex: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module BABYLON {
  9290. /** @hidden */
  9291. export var shadowMapVertexShader: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module BABYLON {
  9297. /** @hidden */
  9298. export var depthBoxBlurPixelShader: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module BABYLON {
  9304. /**
  9305. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9306. */
  9307. export interface ICustomShaderOptions {
  9308. /**
  9309. * Gets or sets the custom shader name to use
  9310. */
  9311. shaderName: string;
  9312. /**
  9313. * The list of attribute names used in the shader
  9314. */
  9315. attributes?: string[];
  9316. /**
  9317. * The list of unifrom names used in the shader
  9318. */
  9319. uniforms?: string[];
  9320. /**
  9321. * The list of sampler names used in the shader
  9322. */
  9323. samplers?: string[];
  9324. /**
  9325. * The list of defines used in the shader
  9326. */
  9327. defines?: string[];
  9328. }
  9329. /**
  9330. * Interface to implement to create a shadow generator compatible with BJS.
  9331. */
  9332. export interface IShadowGenerator {
  9333. /**
  9334. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9335. * @returns The render target texture if present otherwise, null
  9336. */
  9337. getShadowMap(): Nullable<RenderTargetTexture>;
  9338. /**
  9339. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9340. * @returns The render target texture if the shadow map is present otherwise, null
  9341. */
  9342. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9343. /**
  9344. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9345. * @param subMesh The submesh we want to render in the shadow map
  9346. * @param useInstances Defines wether will draw in the map using instances
  9347. * @returns true if ready otherwise, false
  9348. */
  9349. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9350. /**
  9351. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9352. * @param defines Defines of the material we want to update
  9353. * @param lightIndex Index of the light in the enabled light list of the material
  9354. */
  9355. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9356. /**
  9357. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9358. * defined in the generator but impacting the effect).
  9359. * It implies the unifroms available on the materials are the standard BJS ones.
  9360. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9361. * @param effect The effect we are binfing the information for
  9362. */
  9363. bindShadowLight(lightIndex: string, effect: Effect): void;
  9364. /**
  9365. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9366. * (eq to shadow prjection matrix * light transform matrix)
  9367. * @returns The transform matrix used to create the shadow map
  9368. */
  9369. getTransformMatrix(): Matrix;
  9370. /**
  9371. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9372. * Cube and 2D textures for instance.
  9373. */
  9374. recreateShadowMap(): void;
  9375. /**
  9376. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9377. * @param onCompiled Callback triggered at the and of the effects compilation
  9378. * @param options Sets of optional options forcing the compilation with different modes
  9379. */
  9380. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9381. useInstances: boolean;
  9382. }>): void;
  9383. /**
  9384. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9385. * @param options Sets of optional options forcing the compilation with different modes
  9386. * @returns A promise that resolves when the compilation completes
  9387. */
  9388. forceCompilationAsync(options?: Partial<{
  9389. useInstances: boolean;
  9390. }>): Promise<void>;
  9391. /**
  9392. * Serializes the shadow generator setup to a json object.
  9393. * @returns The serialized JSON object
  9394. */
  9395. serialize(): any;
  9396. /**
  9397. * Disposes the Shadow map and related Textures and effects.
  9398. */
  9399. dispose(): void;
  9400. }
  9401. /**
  9402. * Default implementation IShadowGenerator.
  9403. * This is the main object responsible of generating shadows in the framework.
  9404. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9405. */
  9406. export class ShadowGenerator implements IShadowGenerator {
  9407. /**
  9408. * Shadow generator mode None: no filtering applied.
  9409. */
  9410. static readonly FILTER_NONE: number;
  9411. /**
  9412. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9413. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9414. */
  9415. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9416. /**
  9417. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9418. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9419. */
  9420. static readonly FILTER_POISSONSAMPLING: number;
  9421. /**
  9422. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9423. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9424. */
  9425. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9426. /**
  9427. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9428. * edge artifacts on steep falloff.
  9429. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9430. */
  9431. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9432. /**
  9433. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9434. * edge artifacts on steep falloff.
  9435. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9436. */
  9437. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9438. /**
  9439. * Shadow generator mode PCF: Percentage Closer Filtering
  9440. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9441. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9442. */
  9443. static readonly FILTER_PCF: number;
  9444. /**
  9445. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9446. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9447. * Contact Hardening
  9448. */
  9449. static readonly FILTER_PCSS: number;
  9450. /**
  9451. * Reserved for PCF and PCSS
  9452. * Highest Quality.
  9453. *
  9454. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9455. *
  9456. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9457. */
  9458. static readonly QUALITY_HIGH: number;
  9459. /**
  9460. * Reserved for PCF and PCSS
  9461. * Good tradeoff for quality/perf cross devices
  9462. *
  9463. * Execute PCF on a 3*3 kernel.
  9464. *
  9465. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9466. */
  9467. static readonly QUALITY_MEDIUM: number;
  9468. /**
  9469. * Reserved for PCF and PCSS
  9470. * The lowest quality but the fastest.
  9471. *
  9472. * Execute PCF on a 1*1 kernel.
  9473. *
  9474. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9475. */
  9476. static readonly QUALITY_LOW: number;
  9477. /** Gets or sets the custom shader name to use */
  9478. customShaderOptions: ICustomShaderOptions;
  9479. /**
  9480. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9481. */
  9482. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9483. /**
  9484. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9485. */
  9486. onAfterShadowMapRenderObservable: Observable<Effect>;
  9487. /**
  9488. * Observable triggered before a mesh is rendered in the shadow map.
  9489. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9490. */
  9491. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9492. /**
  9493. * Observable triggered after a mesh is rendered in the shadow map.
  9494. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9495. */
  9496. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9497. private _bias;
  9498. /**
  9499. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9500. */
  9501. /**
  9502. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9503. */
  9504. bias: number;
  9505. private _normalBias;
  9506. /**
  9507. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9508. */
  9509. /**
  9510. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9511. */
  9512. normalBias: number;
  9513. private _blurBoxOffset;
  9514. /**
  9515. * Gets the blur box offset: offset applied during the blur pass.
  9516. * Only useful if useKernelBlur = false
  9517. */
  9518. /**
  9519. * Sets the blur box offset: offset applied during the blur pass.
  9520. * Only useful if useKernelBlur = false
  9521. */
  9522. blurBoxOffset: number;
  9523. private _blurScale;
  9524. /**
  9525. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9526. * 2 means half of the size.
  9527. */
  9528. /**
  9529. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9530. * 2 means half of the size.
  9531. */
  9532. blurScale: number;
  9533. private _blurKernel;
  9534. /**
  9535. * Gets the blur kernel: kernel size of the blur pass.
  9536. * Only useful if useKernelBlur = true
  9537. */
  9538. /**
  9539. * Sets the blur kernel: kernel size of the blur pass.
  9540. * Only useful if useKernelBlur = true
  9541. */
  9542. blurKernel: number;
  9543. private _useKernelBlur;
  9544. /**
  9545. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9546. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9547. */
  9548. /**
  9549. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9550. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9551. */
  9552. useKernelBlur: boolean;
  9553. private _depthScale;
  9554. /**
  9555. * Gets the depth scale used in ESM mode.
  9556. */
  9557. /**
  9558. * Sets the depth scale used in ESM mode.
  9559. * This can override the scale stored on the light.
  9560. */
  9561. depthScale: number;
  9562. private _filter;
  9563. /**
  9564. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9565. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9566. */
  9567. /**
  9568. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9569. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9570. */
  9571. filter: number;
  9572. /**
  9573. * Gets if the current filter is set to Poisson Sampling.
  9574. */
  9575. /**
  9576. * Sets the current filter to Poisson Sampling.
  9577. */
  9578. usePoissonSampling: boolean;
  9579. /**
  9580. * Gets if the current filter is set to ESM.
  9581. */
  9582. /**
  9583. * Sets the current filter is to ESM.
  9584. */
  9585. useExponentialShadowMap: boolean;
  9586. /**
  9587. * Gets if the current filter is set to filtered ESM.
  9588. */
  9589. /**
  9590. * Gets if the current filter is set to filtered ESM.
  9591. */
  9592. useBlurExponentialShadowMap: boolean;
  9593. /**
  9594. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9595. * exponential to prevent steep falloff artifacts).
  9596. */
  9597. /**
  9598. * Sets the current filter to "close ESM" (using the inverse of the
  9599. * exponential to prevent steep falloff artifacts).
  9600. */
  9601. useCloseExponentialShadowMap: boolean;
  9602. /**
  9603. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9604. * exponential to prevent steep falloff artifacts).
  9605. */
  9606. /**
  9607. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9608. * exponential to prevent steep falloff artifacts).
  9609. */
  9610. useBlurCloseExponentialShadowMap: boolean;
  9611. /**
  9612. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9613. */
  9614. /**
  9615. * Sets the current filter to "PCF" (percentage closer filtering).
  9616. */
  9617. usePercentageCloserFiltering: boolean;
  9618. private _filteringQuality;
  9619. /**
  9620. * Gets the PCF or PCSS Quality.
  9621. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9622. */
  9623. /**
  9624. * Sets the PCF or PCSS Quality.
  9625. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9626. */
  9627. filteringQuality: number;
  9628. /**
  9629. * Gets if the current filter is set to "PCSS" (contact hardening).
  9630. */
  9631. /**
  9632. * Sets the current filter to "PCSS" (contact hardening).
  9633. */
  9634. useContactHardeningShadow: boolean;
  9635. private _contactHardeningLightSizeUVRatio;
  9636. /**
  9637. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9638. * Using a ratio helps keeping shape stability independently of the map size.
  9639. *
  9640. * It does not account for the light projection as it was having too much
  9641. * instability during the light setup or during light position changes.
  9642. *
  9643. * Only valid if useContactHardeningShadow is true.
  9644. */
  9645. /**
  9646. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9647. * Using a ratio helps keeping shape stability independently of the map size.
  9648. *
  9649. * It does not account for the light projection as it was having too much
  9650. * instability during the light setup or during light position changes.
  9651. *
  9652. * Only valid if useContactHardeningShadow is true.
  9653. */
  9654. contactHardeningLightSizeUVRatio: number;
  9655. private _darkness;
  9656. /** Gets or sets the actual darkness of a shadow */
  9657. darkness: number;
  9658. /**
  9659. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9660. * 0 means strongest and 1 would means no shadow.
  9661. * @returns the darkness.
  9662. */
  9663. getDarkness(): number;
  9664. /**
  9665. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9666. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9667. * @returns the shadow generator allowing fluent coding.
  9668. */
  9669. setDarkness(darkness: number): ShadowGenerator;
  9670. private _transparencyShadow;
  9671. /** Gets or sets the ability to have transparent shadow */
  9672. transparencyShadow: boolean;
  9673. /**
  9674. * Sets the ability to have transparent shadow (boolean).
  9675. * @param transparent True if transparent else False
  9676. * @returns the shadow generator allowing fluent coding
  9677. */
  9678. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9679. private _shadowMap;
  9680. private _shadowMap2;
  9681. /**
  9682. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9683. * @returns The render target texture if present otherwise, null
  9684. */
  9685. getShadowMap(): Nullable<RenderTargetTexture>;
  9686. /**
  9687. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9688. * @returns The render target texture if the shadow map is present otherwise, null
  9689. */
  9690. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9691. /**
  9692. * Gets the class name of that object
  9693. * @returns "ShadowGenerator"
  9694. */
  9695. getClassName(): string;
  9696. /**
  9697. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9698. * @param mesh Mesh to add
  9699. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9700. * @returns the Shadow Generator itself
  9701. */
  9702. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9703. /**
  9704. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9705. * @param mesh Mesh to remove
  9706. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9707. * @returns the Shadow Generator itself
  9708. */
  9709. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9710. /**
  9711. * Controls the extent to which the shadows fade out at the edge of the frustum
  9712. * Used only by directionals and spots
  9713. */
  9714. frustumEdgeFalloff: number;
  9715. private _light;
  9716. /**
  9717. * Returns the associated light object.
  9718. * @returns the light generating the shadow
  9719. */
  9720. getLight(): IShadowLight;
  9721. /**
  9722. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9723. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9724. * It might on the other hand introduce peter panning.
  9725. */
  9726. forceBackFacesOnly: boolean;
  9727. private _scene;
  9728. private _lightDirection;
  9729. private _effect;
  9730. private _viewMatrix;
  9731. private _projectionMatrix;
  9732. private _transformMatrix;
  9733. private _cachedPosition;
  9734. private _cachedDirection;
  9735. private _cachedDefines;
  9736. private _currentRenderID;
  9737. private _boxBlurPostprocess;
  9738. private _kernelBlurXPostprocess;
  9739. private _kernelBlurYPostprocess;
  9740. private _blurPostProcesses;
  9741. private _mapSize;
  9742. private _currentFaceIndex;
  9743. private _currentFaceIndexCache;
  9744. private _textureType;
  9745. private _defaultTextureMatrix;
  9746. private _storedUniqueId;
  9747. /** @hidden */
  9748. static _SceneComponentInitialization: (scene: Scene) => void;
  9749. /**
  9750. * Creates a ShadowGenerator object.
  9751. * A ShadowGenerator is the required tool to use the shadows.
  9752. * Each light casting shadows needs to use its own ShadowGenerator.
  9753. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9754. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9755. * @param light The light object generating the shadows.
  9756. * @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.
  9757. */
  9758. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9759. private _initializeGenerator;
  9760. private _initializeShadowMap;
  9761. private _initializeBlurRTTAndPostProcesses;
  9762. private _renderForShadowMap;
  9763. private _renderSubMeshForShadowMap;
  9764. private _applyFilterValues;
  9765. /**
  9766. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9767. * @param onCompiled Callback triggered at the and of the effects compilation
  9768. * @param options Sets of optional options forcing the compilation with different modes
  9769. */
  9770. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9771. useInstances: boolean;
  9772. }>): void;
  9773. /**
  9774. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9775. * @param options Sets of optional options forcing the compilation with different modes
  9776. * @returns A promise that resolves when the compilation completes
  9777. */
  9778. forceCompilationAsync(options?: Partial<{
  9779. useInstances: boolean;
  9780. }>): Promise<void>;
  9781. /**
  9782. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9783. * @param subMesh The submesh we want to render in the shadow map
  9784. * @param useInstances Defines wether will draw in the map using instances
  9785. * @returns true if ready otherwise, false
  9786. */
  9787. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9788. /**
  9789. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9790. * @param defines Defines of the material we want to update
  9791. * @param lightIndex Index of the light in the enabled light list of the material
  9792. */
  9793. prepareDefines(defines: any, lightIndex: number): void;
  9794. /**
  9795. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9796. * defined in the generator but impacting the effect).
  9797. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9798. * @param effect The effect we are binfing the information for
  9799. */
  9800. bindShadowLight(lightIndex: string, effect: Effect): void;
  9801. /**
  9802. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9803. * (eq to shadow prjection matrix * light transform matrix)
  9804. * @returns The transform matrix used to create the shadow map
  9805. */
  9806. getTransformMatrix(): Matrix;
  9807. /**
  9808. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9809. * Cube and 2D textures for instance.
  9810. */
  9811. recreateShadowMap(): void;
  9812. private _disposeBlurPostProcesses;
  9813. private _disposeRTTandPostProcesses;
  9814. /**
  9815. * Disposes the ShadowGenerator.
  9816. * Returns nothing.
  9817. */
  9818. dispose(): void;
  9819. /**
  9820. * Serializes the shadow generator setup to a json object.
  9821. * @returns The serialized JSON object
  9822. */
  9823. serialize(): any;
  9824. /**
  9825. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9826. * @param parsedShadowGenerator The JSON object to parse
  9827. * @param scene The scene to create the shadow map for
  9828. * @returns The parsed shadow generator
  9829. */
  9830. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9831. }
  9832. }
  9833. declare module BABYLON {
  9834. /**
  9835. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9836. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9837. * 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.
  9838. */
  9839. export abstract class Light extends Node {
  9840. /**
  9841. * Falloff Default: light is falling off following the material specification:
  9842. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9843. */
  9844. static readonly FALLOFF_DEFAULT: number;
  9845. /**
  9846. * Falloff Physical: light is falling off following the inverse squared distance law.
  9847. */
  9848. static readonly FALLOFF_PHYSICAL: number;
  9849. /**
  9850. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9851. * to enhance interoperability with other engines.
  9852. */
  9853. static readonly FALLOFF_GLTF: number;
  9854. /**
  9855. * Falloff Standard: light is falling off like in the standard material
  9856. * to enhance interoperability with other materials.
  9857. */
  9858. static readonly FALLOFF_STANDARD: number;
  9859. /**
  9860. * If every light affecting the material is in this lightmapMode,
  9861. * material.lightmapTexture adds or multiplies
  9862. * (depends on material.useLightmapAsShadowmap)
  9863. * after every other light calculations.
  9864. */
  9865. static readonly LIGHTMAP_DEFAULT: number;
  9866. /**
  9867. * material.lightmapTexture as only diffuse lighting from this light
  9868. * adds only specular lighting from this light
  9869. * adds dynamic shadows
  9870. */
  9871. static readonly LIGHTMAP_SPECULAR: number;
  9872. /**
  9873. * material.lightmapTexture as only lighting
  9874. * no light calculation from this light
  9875. * only adds dynamic shadows from this light
  9876. */
  9877. static readonly LIGHTMAP_SHADOWSONLY: number;
  9878. /**
  9879. * Each light type uses the default quantity according to its type:
  9880. * point/spot lights use luminous intensity
  9881. * directional lights use illuminance
  9882. */
  9883. static readonly INTENSITYMODE_AUTOMATIC: number;
  9884. /**
  9885. * lumen (lm)
  9886. */
  9887. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9888. /**
  9889. * candela (lm/sr)
  9890. */
  9891. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9892. /**
  9893. * lux (lm/m^2)
  9894. */
  9895. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9896. /**
  9897. * nit (cd/m^2)
  9898. */
  9899. static readonly INTENSITYMODE_LUMINANCE: number;
  9900. /**
  9901. * Light type const id of the point light.
  9902. */
  9903. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9904. /**
  9905. * Light type const id of the directional light.
  9906. */
  9907. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9908. /**
  9909. * Light type const id of the spot light.
  9910. */
  9911. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9912. /**
  9913. * Light type const id of the hemispheric light.
  9914. */
  9915. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9916. /**
  9917. * Diffuse gives the basic color to an object.
  9918. */
  9919. diffuse: Color3;
  9920. /**
  9921. * Specular produces a highlight color on an object.
  9922. * Note: This is note affecting PBR materials.
  9923. */
  9924. specular: Color3;
  9925. /**
  9926. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9927. * falling off base on range or angle.
  9928. * This can be set to any values in Light.FALLOFF_x.
  9929. *
  9930. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9931. * other types of materials.
  9932. */
  9933. falloffType: number;
  9934. /**
  9935. * Strength of the light.
  9936. * Note: By default it is define in the framework own unit.
  9937. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9938. */
  9939. intensity: number;
  9940. private _range;
  9941. protected _inverseSquaredRange: number;
  9942. /**
  9943. * Defines how far from the source the light is impacting in scene units.
  9944. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9945. */
  9946. /**
  9947. * Defines how far from the source the light is impacting in scene units.
  9948. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9949. */
  9950. range: number;
  9951. /**
  9952. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9953. * of light.
  9954. */
  9955. private _photometricScale;
  9956. private _intensityMode;
  9957. /**
  9958. * Gets the photometric scale used to interpret the intensity.
  9959. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9960. */
  9961. /**
  9962. * Sets the photometric scale used to interpret the intensity.
  9963. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9964. */
  9965. intensityMode: number;
  9966. private _radius;
  9967. /**
  9968. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9969. */
  9970. /**
  9971. * sets the light radius used by PBR Materials to simulate soft area lights.
  9972. */
  9973. radius: number;
  9974. private _renderPriority;
  9975. /**
  9976. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9977. * exceeding the number allowed of the materials.
  9978. */
  9979. renderPriority: number;
  9980. private _shadowEnabled;
  9981. /**
  9982. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9983. * the current shadow generator.
  9984. */
  9985. /**
  9986. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9987. * the current shadow generator.
  9988. */
  9989. shadowEnabled: boolean;
  9990. private _includedOnlyMeshes;
  9991. /**
  9992. * Gets the only meshes impacted by this light.
  9993. */
  9994. /**
  9995. * Sets the only meshes impacted by this light.
  9996. */
  9997. includedOnlyMeshes: AbstractMesh[];
  9998. private _excludedMeshes;
  9999. /**
  10000. * Gets the meshes not impacted by this light.
  10001. */
  10002. /**
  10003. * Sets the meshes not impacted by this light.
  10004. */
  10005. excludedMeshes: AbstractMesh[];
  10006. private _excludeWithLayerMask;
  10007. /**
  10008. * Gets the layer id use to find what meshes are not impacted by the light.
  10009. * Inactive if 0
  10010. */
  10011. /**
  10012. * Sets the layer id use to find what meshes are not impacted by the light.
  10013. * Inactive if 0
  10014. */
  10015. excludeWithLayerMask: number;
  10016. private _includeOnlyWithLayerMask;
  10017. /**
  10018. * Gets the layer id use to find what meshes are impacted by the light.
  10019. * Inactive if 0
  10020. */
  10021. /**
  10022. * Sets the layer id use to find what meshes are impacted by the light.
  10023. * Inactive if 0
  10024. */
  10025. includeOnlyWithLayerMask: number;
  10026. private _lightmapMode;
  10027. /**
  10028. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10029. */
  10030. /**
  10031. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10032. */
  10033. lightmapMode: number;
  10034. /**
  10035. * Shadow generator associted to the light.
  10036. * @hidden Internal use only.
  10037. */
  10038. _shadowGenerator: Nullable<IShadowGenerator>;
  10039. /**
  10040. * @hidden Internal use only.
  10041. */
  10042. _excludedMeshesIds: string[];
  10043. /**
  10044. * @hidden Internal use only.
  10045. */
  10046. _includedOnlyMeshesIds: string[];
  10047. /**
  10048. * The current light unifom buffer.
  10049. * @hidden Internal use only.
  10050. */
  10051. _uniformBuffer: UniformBuffer;
  10052. /** @hidden */
  10053. _renderId: number;
  10054. /**
  10055. * Creates a Light object in the scene.
  10056. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10057. * @param name The firendly name of the light
  10058. * @param scene The scene the light belongs too
  10059. */
  10060. constructor(name: string, scene: Scene);
  10061. protected abstract _buildUniformLayout(): void;
  10062. /**
  10063. * Sets the passed Effect "effect" with the Light information.
  10064. * @param effect The effect to update
  10065. * @param lightIndex The index of the light in the effect to update
  10066. * @returns The light
  10067. */
  10068. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10069. /**
  10070. * Sets the passed Effect "effect" with the Light textures.
  10071. * @param effect The effect to update
  10072. * @param lightIndex The index of the light in the effect to update
  10073. * @returns The light
  10074. */
  10075. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10076. /**
  10077. * Binds the lights information from the scene to the effect for the given mesh.
  10078. * @param lightIndex Light index
  10079. * @param scene The scene where the light belongs to
  10080. * @param effect The effect we are binding the data to
  10081. * @param useSpecular Defines if specular is supported
  10082. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10083. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10084. */
  10085. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10086. /**
  10087. * Sets the passed Effect "effect" with the Light information.
  10088. * @param effect The effect to update
  10089. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10090. * @returns The light
  10091. */
  10092. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10093. /**
  10094. * Returns the string "Light".
  10095. * @returns the class name
  10096. */
  10097. getClassName(): string;
  10098. /** @hidden */
  10099. readonly _isLight: boolean;
  10100. /**
  10101. * Converts the light information to a readable string for debug purpose.
  10102. * @param fullDetails Supports for multiple levels of logging within scene loading
  10103. * @returns the human readable light info
  10104. */
  10105. toString(fullDetails?: boolean): string;
  10106. /** @hidden */
  10107. protected _syncParentEnabledState(): void;
  10108. /**
  10109. * Set the enabled state of this node.
  10110. * @param value - the new enabled state
  10111. */
  10112. setEnabled(value: boolean): void;
  10113. /**
  10114. * Returns the Light associated shadow generator if any.
  10115. * @return the associated shadow generator.
  10116. */
  10117. getShadowGenerator(): Nullable<IShadowGenerator>;
  10118. /**
  10119. * Returns a Vector3, the absolute light position in the World.
  10120. * @returns the world space position of the light
  10121. */
  10122. getAbsolutePosition(): Vector3;
  10123. /**
  10124. * Specifies if the light will affect the passed mesh.
  10125. * @param mesh The mesh to test against the light
  10126. * @return true the mesh is affected otherwise, false.
  10127. */
  10128. canAffectMesh(mesh: AbstractMesh): boolean;
  10129. /**
  10130. * Sort function to order lights for rendering.
  10131. * @param a First Light object to compare to second.
  10132. * @param b Second Light object to compare first.
  10133. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10134. */
  10135. static CompareLightsPriority(a: Light, b: Light): number;
  10136. /**
  10137. * Releases resources associated with this node.
  10138. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10139. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10140. */
  10141. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10142. /**
  10143. * Returns the light type ID (integer).
  10144. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10145. */
  10146. getTypeID(): number;
  10147. /**
  10148. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10149. * @returns the scaled intensity in intensity mode unit
  10150. */
  10151. getScaledIntensity(): number;
  10152. /**
  10153. * Returns a new Light object, named "name", from the current one.
  10154. * @param name The name of the cloned light
  10155. * @returns the new created light
  10156. */
  10157. clone(name: string): Nullable<Light>;
  10158. /**
  10159. * Serializes the current light into a Serialization object.
  10160. * @returns the serialized object.
  10161. */
  10162. serialize(): any;
  10163. /**
  10164. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10165. * This new light is named "name" and added to the passed scene.
  10166. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10167. * @param name The friendly name of the light
  10168. * @param scene The scene the new light will belong to
  10169. * @returns the constructor function
  10170. */
  10171. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10172. /**
  10173. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10174. * @param parsedLight The JSON representation of the light
  10175. * @param scene The scene to create the parsed light in
  10176. * @returns the created light after parsing
  10177. */
  10178. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10179. private _hookArrayForExcluded;
  10180. private _hookArrayForIncludedOnly;
  10181. private _resyncMeshes;
  10182. /**
  10183. * Forces the meshes to update their light related information in their rendering used effects
  10184. * @hidden Internal Use Only
  10185. */
  10186. _markMeshesAsLightDirty(): void;
  10187. /**
  10188. * Recomputes the cached photometric scale if needed.
  10189. */
  10190. private _computePhotometricScale;
  10191. /**
  10192. * Returns the Photometric Scale according to the light type and intensity mode.
  10193. */
  10194. private _getPhotometricScale;
  10195. /**
  10196. * Reorder the light in the scene according to their defined priority.
  10197. * @hidden Internal Use Only
  10198. */
  10199. _reorderLightsInScene(): void;
  10200. /**
  10201. * Prepares the list of defines specific to the light type.
  10202. * @param defines the list of defines
  10203. * @param lightIndex defines the index of the light for the effect
  10204. */
  10205. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10206. }
  10207. }
  10208. declare module BABYLON {
  10209. /**
  10210. * Interface used to define Action
  10211. */
  10212. export interface IAction {
  10213. /**
  10214. * Trigger for the action
  10215. */
  10216. trigger: number;
  10217. /** Options of the trigger */
  10218. triggerOptions: any;
  10219. /**
  10220. * Gets the trigger parameters
  10221. * @returns the trigger parameters
  10222. */
  10223. getTriggerParameter(): any;
  10224. /**
  10225. * Internal only - executes current action event
  10226. * @hidden
  10227. */
  10228. _executeCurrent(evt?: ActionEvent): void;
  10229. /**
  10230. * Serialize placeholder for child classes
  10231. * @param parent of child
  10232. * @returns the serialized object
  10233. */
  10234. serialize(parent: any): any;
  10235. /**
  10236. * Internal only
  10237. * @hidden
  10238. */
  10239. _prepare(): void;
  10240. /**
  10241. * Internal only - manager for action
  10242. * @hidden
  10243. */
  10244. _actionManager: AbstractActionManager;
  10245. /**
  10246. * Adds action to chain of actions, may be a DoNothingAction
  10247. * @param action defines the next action to execute
  10248. * @returns The action passed in
  10249. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10250. */
  10251. then(action: IAction): IAction;
  10252. }
  10253. /**
  10254. * The action to be carried out following a trigger
  10255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10256. */
  10257. export class Action implements IAction {
  10258. /** the trigger, with or without parameters, for the action */
  10259. triggerOptions: any;
  10260. /**
  10261. * Trigger for the action
  10262. */
  10263. trigger: number;
  10264. /**
  10265. * Internal only - manager for action
  10266. * @hidden
  10267. */
  10268. _actionManager: ActionManager;
  10269. private _nextActiveAction;
  10270. private _child;
  10271. private _condition?;
  10272. private _triggerParameter;
  10273. /**
  10274. * An event triggered prior to action being executed.
  10275. */
  10276. onBeforeExecuteObservable: Observable<Action>;
  10277. /**
  10278. * Creates a new Action
  10279. * @param triggerOptions the trigger, with or without parameters, for the action
  10280. * @param condition an optional determinant of action
  10281. */
  10282. constructor(
  10283. /** the trigger, with or without parameters, for the action */
  10284. triggerOptions: any, condition?: Condition);
  10285. /**
  10286. * Internal only
  10287. * @hidden
  10288. */
  10289. _prepare(): void;
  10290. /**
  10291. * Gets the trigger parameters
  10292. * @returns the trigger parameters
  10293. */
  10294. getTriggerParameter(): any;
  10295. /**
  10296. * Internal only - executes current action event
  10297. * @hidden
  10298. */
  10299. _executeCurrent(evt?: ActionEvent): void;
  10300. /**
  10301. * Execute placeholder for child classes
  10302. * @param evt optional action event
  10303. */
  10304. execute(evt?: ActionEvent): void;
  10305. /**
  10306. * Skips to next active action
  10307. */
  10308. skipToNextActiveAction(): void;
  10309. /**
  10310. * Adds action to chain of actions, may be a DoNothingAction
  10311. * @param action defines the next action to execute
  10312. * @returns The action passed in
  10313. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10314. */
  10315. then(action: Action): Action;
  10316. /**
  10317. * Internal only
  10318. * @hidden
  10319. */
  10320. _getProperty(propertyPath: string): string;
  10321. /**
  10322. * Internal only
  10323. * @hidden
  10324. */
  10325. _getEffectiveTarget(target: any, propertyPath: string): any;
  10326. /**
  10327. * Serialize placeholder for child classes
  10328. * @param parent of child
  10329. * @returns the serialized object
  10330. */
  10331. serialize(parent: any): any;
  10332. /**
  10333. * Internal only called by serialize
  10334. * @hidden
  10335. */
  10336. protected _serialize(serializedAction: any, parent?: any): any;
  10337. /**
  10338. * Internal only
  10339. * @hidden
  10340. */
  10341. static _SerializeValueAsString: (value: any) => string;
  10342. /**
  10343. * Internal only
  10344. * @hidden
  10345. */
  10346. static _GetTargetProperty: (target: Node | Scene) => {
  10347. name: string;
  10348. targetType: string;
  10349. value: string;
  10350. };
  10351. }
  10352. }
  10353. declare module BABYLON {
  10354. /**
  10355. * A Condition applied to an Action
  10356. */
  10357. export class Condition {
  10358. /**
  10359. * Internal only - manager for action
  10360. * @hidden
  10361. */
  10362. _actionManager: ActionManager;
  10363. /**
  10364. * Internal only
  10365. * @hidden
  10366. */
  10367. _evaluationId: number;
  10368. /**
  10369. * Internal only
  10370. * @hidden
  10371. */
  10372. _currentResult: boolean;
  10373. /**
  10374. * Creates a new Condition
  10375. * @param actionManager the manager of the action the condition is applied to
  10376. */
  10377. constructor(actionManager: ActionManager);
  10378. /**
  10379. * Check if the current condition is valid
  10380. * @returns a boolean
  10381. */
  10382. isValid(): boolean;
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. _getProperty(propertyPath: string): string;
  10388. /**
  10389. * Internal only
  10390. * @hidden
  10391. */
  10392. _getEffectiveTarget(target: any, propertyPath: string): any;
  10393. /**
  10394. * Serialize placeholder for child classes
  10395. * @returns the serialized object
  10396. */
  10397. serialize(): any;
  10398. /**
  10399. * Internal only
  10400. * @hidden
  10401. */
  10402. protected _serialize(serializedCondition: any): any;
  10403. }
  10404. /**
  10405. * Defines specific conditional operators as extensions of Condition
  10406. */
  10407. export class ValueCondition extends Condition {
  10408. /** path to specify the property of the target the conditional operator uses */
  10409. propertyPath: string;
  10410. /** the value compared by the conditional operator against the current value of the property */
  10411. value: any;
  10412. /** the conditional operator, default ValueCondition.IsEqual */
  10413. operator: number;
  10414. /**
  10415. * Internal only
  10416. * @hidden
  10417. */
  10418. private static _IsEqual;
  10419. /**
  10420. * Internal only
  10421. * @hidden
  10422. */
  10423. private static _IsDifferent;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. private static _IsGreater;
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. private static _IsLesser;
  10434. /**
  10435. * returns the number for IsEqual
  10436. */
  10437. static readonly IsEqual: number;
  10438. /**
  10439. * Returns the number for IsDifferent
  10440. */
  10441. static readonly IsDifferent: number;
  10442. /**
  10443. * Returns the number for IsGreater
  10444. */
  10445. static readonly IsGreater: number;
  10446. /**
  10447. * Returns the number for IsLesser
  10448. */
  10449. static readonly IsLesser: number;
  10450. /**
  10451. * Internal only The action manager for the condition
  10452. * @hidden
  10453. */
  10454. _actionManager: ActionManager;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. private _target;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private _effectiveTarget;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. private _property;
  10470. /**
  10471. * Creates a new ValueCondition
  10472. * @param actionManager manager for the action the condition applies to
  10473. * @param target for the action
  10474. * @param propertyPath path to specify the property of the target the conditional operator uses
  10475. * @param value the value compared by the conditional operator against the current value of the property
  10476. * @param operator the conditional operator, default ValueCondition.IsEqual
  10477. */
  10478. constructor(actionManager: ActionManager, target: any,
  10479. /** path to specify the property of the target the conditional operator uses */
  10480. propertyPath: string,
  10481. /** the value compared by the conditional operator against the current value of the property */
  10482. value: any,
  10483. /** the conditional operator, default ValueCondition.IsEqual */
  10484. operator?: number);
  10485. /**
  10486. * Compares the given value with the property value for the specified conditional operator
  10487. * @returns the result of the comparison
  10488. */
  10489. isValid(): boolean;
  10490. /**
  10491. * Serialize the ValueCondition into a JSON compatible object
  10492. * @returns serialization object
  10493. */
  10494. serialize(): any;
  10495. /**
  10496. * Gets the name of the conditional operator for the ValueCondition
  10497. * @param operator the conditional operator
  10498. * @returns the name
  10499. */
  10500. static GetOperatorName(operator: number): string;
  10501. }
  10502. /**
  10503. * Defines a predicate condition as an extension of Condition
  10504. */
  10505. export class PredicateCondition extends Condition {
  10506. /** defines the predicate function used to validate the condition */
  10507. predicate: () => boolean;
  10508. /**
  10509. * Internal only - manager for action
  10510. * @hidden
  10511. */
  10512. _actionManager: ActionManager;
  10513. /**
  10514. * Creates a new PredicateCondition
  10515. * @param actionManager manager for the action the condition applies to
  10516. * @param predicate defines the predicate function used to validate the condition
  10517. */
  10518. constructor(actionManager: ActionManager,
  10519. /** defines the predicate function used to validate the condition */
  10520. predicate: () => boolean);
  10521. /**
  10522. * @returns the validity of the predicate condition
  10523. */
  10524. isValid(): boolean;
  10525. }
  10526. /**
  10527. * Defines a state condition as an extension of Condition
  10528. */
  10529. export class StateCondition extends Condition {
  10530. /** Value to compare with target state */
  10531. value: string;
  10532. /**
  10533. * Internal only - manager for action
  10534. * @hidden
  10535. */
  10536. _actionManager: ActionManager;
  10537. /**
  10538. * Internal only
  10539. * @hidden
  10540. */
  10541. private _target;
  10542. /**
  10543. * Creates a new StateCondition
  10544. * @param actionManager manager for the action the condition applies to
  10545. * @param target of the condition
  10546. * @param value to compare with target state
  10547. */
  10548. constructor(actionManager: ActionManager, target: any,
  10549. /** Value to compare with target state */
  10550. value: string);
  10551. /**
  10552. * Gets a boolean indicating if the current condition is met
  10553. * @returns the validity of the state
  10554. */
  10555. isValid(): boolean;
  10556. /**
  10557. * Serialize the StateCondition into a JSON compatible object
  10558. * @returns serialization object
  10559. */
  10560. serialize(): any;
  10561. }
  10562. }
  10563. declare module BABYLON {
  10564. /**
  10565. * This defines an action responsible to toggle a boolean once triggered.
  10566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10567. */
  10568. export class SwitchBooleanAction extends Action {
  10569. /**
  10570. * The path to the boolean property in the target object
  10571. */
  10572. propertyPath: string;
  10573. private _target;
  10574. private _effectiveTarget;
  10575. private _property;
  10576. /**
  10577. * Instantiate the action
  10578. * @param triggerOptions defines the trigger options
  10579. * @param target defines the object containing the boolean
  10580. * @param propertyPath defines the path to the boolean property in the target object
  10581. * @param condition defines the trigger related conditions
  10582. */
  10583. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10584. /** @hidden */
  10585. _prepare(): void;
  10586. /**
  10587. * Execute the action toggle the boolean value.
  10588. */
  10589. execute(): void;
  10590. /**
  10591. * Serializes the actions and its related information.
  10592. * @param parent defines the object to serialize in
  10593. * @returns the serialized object
  10594. */
  10595. serialize(parent: any): any;
  10596. }
  10597. /**
  10598. * This defines an action responsible to set a the state field of the target
  10599. * to a desired value once triggered.
  10600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10601. */
  10602. export class SetStateAction extends Action {
  10603. /**
  10604. * The value to store in the state field.
  10605. */
  10606. value: string;
  10607. private _target;
  10608. /**
  10609. * Instantiate the action
  10610. * @param triggerOptions defines the trigger options
  10611. * @param target defines the object containing the state property
  10612. * @param value defines the value to store in the state field
  10613. * @param condition defines the trigger related conditions
  10614. */
  10615. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10616. /**
  10617. * Execute the action and store the value on the target state property.
  10618. */
  10619. execute(): void;
  10620. /**
  10621. * Serializes the actions and its related information.
  10622. * @param parent defines the object to serialize in
  10623. * @returns the serialized object
  10624. */
  10625. serialize(parent: any): any;
  10626. }
  10627. /**
  10628. * This defines an action responsible to set a property of the target
  10629. * to a desired value once triggered.
  10630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10631. */
  10632. export class SetValueAction extends Action {
  10633. /**
  10634. * The path of the property to set in the target.
  10635. */
  10636. propertyPath: string;
  10637. /**
  10638. * The value to set in the property
  10639. */
  10640. value: any;
  10641. private _target;
  10642. private _effectiveTarget;
  10643. private _property;
  10644. /**
  10645. * Instantiate the action
  10646. * @param triggerOptions defines the trigger options
  10647. * @param target defines the object containing the property
  10648. * @param propertyPath defines the path of the property to set in the target
  10649. * @param value defines the value to set in the property
  10650. * @param condition defines the trigger related conditions
  10651. */
  10652. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10653. /** @hidden */
  10654. _prepare(): void;
  10655. /**
  10656. * Execute the action and set the targetted property to the desired value.
  10657. */
  10658. execute(): void;
  10659. /**
  10660. * Serializes the actions and its related information.
  10661. * @param parent defines the object to serialize in
  10662. * @returns the serialized object
  10663. */
  10664. serialize(parent: any): any;
  10665. }
  10666. /**
  10667. * This defines an action responsible to increment the target value
  10668. * to a desired value once triggered.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class IncrementValueAction extends Action {
  10672. /**
  10673. * The path of the property to increment in the target.
  10674. */
  10675. propertyPath: string;
  10676. /**
  10677. * The value we should increment the property by.
  10678. */
  10679. value: any;
  10680. private _target;
  10681. private _effectiveTarget;
  10682. private _property;
  10683. /**
  10684. * Instantiate the action
  10685. * @param triggerOptions defines the trigger options
  10686. * @param target defines the object containing the property
  10687. * @param propertyPath defines the path of the property to increment in the target
  10688. * @param value defines the value value we should increment the property by
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and increment the target of the value amount.
  10696. */
  10697. execute(): void;
  10698. /**
  10699. * Serializes the actions and its related information.
  10700. * @param parent defines the object to serialize in
  10701. * @returns the serialized object
  10702. */
  10703. serialize(parent: any): any;
  10704. }
  10705. /**
  10706. * This defines an action responsible to start an animation once triggered.
  10707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10708. */
  10709. export class PlayAnimationAction extends Action {
  10710. /**
  10711. * Where the animation should start (animation frame)
  10712. */
  10713. from: number;
  10714. /**
  10715. * Where the animation should stop (animation frame)
  10716. */
  10717. to: number;
  10718. /**
  10719. * Define if the animation should loop or stop after the first play.
  10720. */
  10721. loop?: boolean;
  10722. private _target;
  10723. /**
  10724. * Instantiate the action
  10725. * @param triggerOptions defines the trigger options
  10726. * @param target defines the target animation or animation name
  10727. * @param from defines from where the animation should start (animation frame)
  10728. * @param end defines where the animation should stop (animation frame)
  10729. * @param loop defines if the animation should loop or stop after the first play
  10730. * @param condition defines the trigger related conditions
  10731. */
  10732. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10733. /** @hidden */
  10734. _prepare(): void;
  10735. /**
  10736. * Execute the action and play the animation.
  10737. */
  10738. execute(): void;
  10739. /**
  10740. * Serializes the actions and its related information.
  10741. * @param parent defines the object to serialize in
  10742. * @returns the serialized object
  10743. */
  10744. serialize(parent: any): any;
  10745. }
  10746. /**
  10747. * This defines an action responsible to stop an animation once triggered.
  10748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10749. */
  10750. export class StopAnimationAction extends Action {
  10751. private _target;
  10752. /**
  10753. * Instantiate the action
  10754. * @param triggerOptions defines the trigger options
  10755. * @param target defines the target animation or animation name
  10756. * @param condition defines the trigger related conditions
  10757. */
  10758. constructor(triggerOptions: any, target: any, condition?: Condition);
  10759. /** @hidden */
  10760. _prepare(): void;
  10761. /**
  10762. * Execute the action and stop the animation.
  10763. */
  10764. execute(): void;
  10765. /**
  10766. * Serializes the actions and its related information.
  10767. * @param parent defines the object to serialize in
  10768. * @returns the serialized object
  10769. */
  10770. serialize(parent: any): any;
  10771. }
  10772. /**
  10773. * This defines an action responsible that does nothing once triggered.
  10774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10775. */
  10776. export class DoNothingAction extends Action {
  10777. /**
  10778. * Instantiate the action
  10779. * @param triggerOptions defines the trigger options
  10780. * @param condition defines the trigger related conditions
  10781. */
  10782. constructor(triggerOptions?: any, condition?: Condition);
  10783. /**
  10784. * Execute the action and do nothing.
  10785. */
  10786. execute(): void;
  10787. /**
  10788. * Serializes the actions and its related information.
  10789. * @param parent defines the object to serialize in
  10790. * @returns the serialized object
  10791. */
  10792. serialize(parent: any): any;
  10793. }
  10794. /**
  10795. * This defines an action responsible to trigger several actions once triggered.
  10796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10797. */
  10798. export class CombineAction extends Action {
  10799. /**
  10800. * The list of aggregated animations to run.
  10801. */
  10802. children: Action[];
  10803. /**
  10804. * Instantiate the action
  10805. * @param triggerOptions defines the trigger options
  10806. * @param children defines the list of aggregated animations to run
  10807. * @param condition defines the trigger related conditions
  10808. */
  10809. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10810. /** @hidden */
  10811. _prepare(): void;
  10812. /**
  10813. * Execute the action and executes all the aggregated actions.
  10814. */
  10815. execute(evt: ActionEvent): void;
  10816. /**
  10817. * Serializes the actions and its related information.
  10818. * @param parent defines the object to serialize in
  10819. * @returns the serialized object
  10820. */
  10821. serialize(parent: any): any;
  10822. }
  10823. /**
  10824. * This defines an action responsible to run code (external event) once triggered.
  10825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10826. */
  10827. export class ExecuteCodeAction extends Action {
  10828. /**
  10829. * The callback function to run.
  10830. */
  10831. func: (evt: ActionEvent) => void;
  10832. /**
  10833. * Instantiate the action
  10834. * @param triggerOptions defines the trigger options
  10835. * @param func defines the callback function to run
  10836. * @param condition defines the trigger related conditions
  10837. */
  10838. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10839. /**
  10840. * Execute the action and run the attached code.
  10841. */
  10842. execute(evt: ActionEvent): void;
  10843. }
  10844. /**
  10845. * This defines an action responsible to set the parent property of the target once triggered.
  10846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10847. */
  10848. export class SetParentAction extends Action {
  10849. private _parent;
  10850. private _target;
  10851. /**
  10852. * Instantiate the action
  10853. * @param triggerOptions defines the trigger options
  10854. * @param target defines the target containing the parent property
  10855. * @param parent defines from where the animation should start (animation frame)
  10856. * @param condition defines the trigger related conditions
  10857. */
  10858. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10859. /** @hidden */
  10860. _prepare(): void;
  10861. /**
  10862. * Execute the action and set the parent property.
  10863. */
  10864. execute(): void;
  10865. /**
  10866. * Serializes the actions and its related information.
  10867. * @param parent defines the object to serialize in
  10868. * @returns the serialized object
  10869. */
  10870. serialize(parent: any): any;
  10871. }
  10872. }
  10873. declare module BABYLON {
  10874. /**
  10875. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10876. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10878. */
  10879. export class ActionManager extends AbstractActionManager {
  10880. /**
  10881. * Nothing
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly NothingTrigger: number;
  10885. /**
  10886. * On pick
  10887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10888. */
  10889. static readonly OnPickTrigger: number;
  10890. /**
  10891. * On left pick
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10893. */
  10894. static readonly OnLeftPickTrigger: number;
  10895. /**
  10896. * On right pick
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10898. */
  10899. static readonly OnRightPickTrigger: number;
  10900. /**
  10901. * On center pick
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10903. */
  10904. static readonly OnCenterPickTrigger: number;
  10905. /**
  10906. * On pick down
  10907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10908. */
  10909. static readonly OnPickDownTrigger: number;
  10910. /**
  10911. * On double pick
  10912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10913. */
  10914. static readonly OnDoublePickTrigger: number;
  10915. /**
  10916. * On pick up
  10917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10918. */
  10919. static readonly OnPickUpTrigger: number;
  10920. /**
  10921. * On pick out.
  10922. * This trigger will only be raised if you also declared a OnPickDown
  10923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10924. */
  10925. static readonly OnPickOutTrigger: number;
  10926. /**
  10927. * On long press
  10928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10929. */
  10930. static readonly OnLongPressTrigger: number;
  10931. /**
  10932. * On pointer over
  10933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10934. */
  10935. static readonly OnPointerOverTrigger: number;
  10936. /**
  10937. * On pointer out
  10938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10939. */
  10940. static readonly OnPointerOutTrigger: number;
  10941. /**
  10942. * On every frame
  10943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10944. */
  10945. static readonly OnEveryFrameTrigger: number;
  10946. /**
  10947. * On intersection enter
  10948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10949. */
  10950. static readonly OnIntersectionEnterTrigger: number;
  10951. /**
  10952. * On intersection exit
  10953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10954. */
  10955. static readonly OnIntersectionExitTrigger: number;
  10956. /**
  10957. * On key down
  10958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10959. */
  10960. static readonly OnKeyDownTrigger: number;
  10961. /**
  10962. * On key up
  10963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10964. */
  10965. static readonly OnKeyUpTrigger: number;
  10966. private _scene;
  10967. /**
  10968. * Creates a new action manager
  10969. * @param scene defines the hosting scene
  10970. */
  10971. constructor(scene: Scene);
  10972. /**
  10973. * Releases all associated resources
  10974. */
  10975. dispose(): void;
  10976. /**
  10977. * Gets hosting scene
  10978. * @returns the hosting scene
  10979. */
  10980. getScene(): Scene;
  10981. /**
  10982. * Does this action manager handles actions of any of the given triggers
  10983. * @param triggers defines the triggers to be tested
  10984. * @return a boolean indicating whether one (or more) of the triggers is handled
  10985. */
  10986. hasSpecificTriggers(triggers: number[]): boolean;
  10987. /**
  10988. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10989. * speed.
  10990. * @param triggerA defines the trigger to be tested
  10991. * @param triggerB defines the trigger to be tested
  10992. * @return a boolean indicating whether one (or more) of the triggers is handled
  10993. */
  10994. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10995. /**
  10996. * Does this action manager handles actions of a given trigger
  10997. * @param trigger defines the trigger to be tested
  10998. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10999. * @return whether the trigger is handled
  11000. */
  11001. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11002. /**
  11003. * Does this action manager has pointer triggers
  11004. */
  11005. readonly hasPointerTriggers: boolean;
  11006. /**
  11007. * Does this action manager has pick triggers
  11008. */
  11009. readonly hasPickTriggers: boolean;
  11010. /**
  11011. * Registers an action to this action manager
  11012. * @param action defines the action to be registered
  11013. * @return the action amended (prepared) after registration
  11014. */
  11015. registerAction(action: IAction): Nullable<IAction>;
  11016. /**
  11017. * Unregisters an action to this action manager
  11018. * @param action defines the action to be unregistered
  11019. * @return a boolean indicating whether the action has been unregistered
  11020. */
  11021. unregisterAction(action: IAction): Boolean;
  11022. /**
  11023. * Process a specific trigger
  11024. * @param trigger defines the trigger to process
  11025. * @param evt defines the event details to be processed
  11026. */
  11027. processTrigger(trigger: number, evt?: IActionEvent): void;
  11028. /** @hidden */
  11029. _getEffectiveTarget(target: any, propertyPath: string): any;
  11030. /** @hidden */
  11031. _getProperty(propertyPath: string): string;
  11032. /**
  11033. * Serialize this manager to a JSON object
  11034. * @param name defines the property name to store this manager
  11035. * @returns a JSON representation of this manager
  11036. */
  11037. serialize(name: string): any;
  11038. /**
  11039. * Creates a new ActionManager from a JSON data
  11040. * @param parsedActions defines the JSON data to read from
  11041. * @param object defines the hosting mesh
  11042. * @param scene defines the hosting scene
  11043. */
  11044. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11045. /**
  11046. * Get a trigger name by index
  11047. * @param trigger defines the trigger index
  11048. * @returns a trigger name
  11049. */
  11050. static GetTriggerName(trigger: number): string;
  11051. }
  11052. }
  11053. declare module BABYLON {
  11054. /**
  11055. * Class representing a ray with position and direction
  11056. */
  11057. export class Ray {
  11058. /** origin point */
  11059. origin: Vector3;
  11060. /** direction */
  11061. direction: Vector3;
  11062. /** length of the ray */
  11063. length: number;
  11064. private static readonly TmpVector3;
  11065. private _tmpRay;
  11066. /**
  11067. * Creates a new ray
  11068. * @param origin origin point
  11069. * @param direction direction
  11070. * @param length length of the ray
  11071. */
  11072. constructor(
  11073. /** origin point */
  11074. origin: Vector3,
  11075. /** direction */
  11076. direction: Vector3,
  11077. /** length of the ray */
  11078. length?: number);
  11079. /**
  11080. * Checks if the ray intersects a box
  11081. * @param minimum bound of the box
  11082. * @param maximum bound of the box
  11083. * @param intersectionTreshold extra extend to be added to the box in all direction
  11084. * @returns if the box was hit
  11085. */
  11086. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11087. /**
  11088. * Checks if the ray intersects a box
  11089. * @param box the bounding box to check
  11090. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11091. * @returns if the box was hit
  11092. */
  11093. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11094. /**
  11095. * If the ray hits a sphere
  11096. * @param sphere the bounding sphere to check
  11097. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11098. * @returns true if it hits the sphere
  11099. */
  11100. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11101. /**
  11102. * If the ray hits a triange
  11103. * @param vertex0 triangle vertex
  11104. * @param vertex1 triangle vertex
  11105. * @param vertex2 triangle vertex
  11106. * @returns intersection information if hit
  11107. */
  11108. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11109. /**
  11110. * Checks if ray intersects a plane
  11111. * @param plane the plane to check
  11112. * @returns the distance away it was hit
  11113. */
  11114. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11115. /**
  11116. * Calculate the intercept of a ray on a given axis
  11117. * @param axis to check 'x' | 'y' | 'z'
  11118. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11119. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11120. */
  11121. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11122. /**
  11123. * Checks if ray intersects a mesh
  11124. * @param mesh the mesh to check
  11125. * @param fastCheck if only the bounding box should checked
  11126. * @returns picking info of the intersecton
  11127. */
  11128. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11129. /**
  11130. * Checks if ray intersects a mesh
  11131. * @param meshes the meshes to check
  11132. * @param fastCheck if only the bounding box should checked
  11133. * @param results array to store result in
  11134. * @returns Array of picking infos
  11135. */
  11136. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11137. private _comparePickingInfo;
  11138. private static smallnum;
  11139. private static rayl;
  11140. /**
  11141. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11142. * @param sega the first point of the segment to test the intersection against
  11143. * @param segb the second point of the segment to test the intersection against
  11144. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11145. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11146. */
  11147. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11148. /**
  11149. * Update the ray from viewport position
  11150. * @param x position
  11151. * @param y y position
  11152. * @param viewportWidth viewport width
  11153. * @param viewportHeight viewport height
  11154. * @param world world matrix
  11155. * @param view view matrix
  11156. * @param projection projection matrix
  11157. * @returns this ray updated
  11158. */
  11159. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11160. /**
  11161. * Creates a ray with origin and direction of 0,0,0
  11162. * @returns the new ray
  11163. */
  11164. static Zero(): Ray;
  11165. /**
  11166. * Creates a new ray from screen space and viewport
  11167. * @param x position
  11168. * @param y y position
  11169. * @param viewportWidth viewport width
  11170. * @param viewportHeight viewport height
  11171. * @param world world matrix
  11172. * @param view view matrix
  11173. * @param projection projection matrix
  11174. * @returns new ray
  11175. */
  11176. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11177. /**
  11178. * 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
  11179. * transformed to the given world matrix.
  11180. * @param origin The origin point
  11181. * @param end The end point
  11182. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11183. * @returns the new ray
  11184. */
  11185. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11186. /**
  11187. * Transforms a ray by a matrix
  11188. * @param ray ray to transform
  11189. * @param matrix matrix to apply
  11190. * @returns the resulting new ray
  11191. */
  11192. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11193. /**
  11194. * Transforms a ray by a matrix
  11195. * @param ray ray to transform
  11196. * @param matrix matrix to apply
  11197. * @param result ray to store result in
  11198. */
  11199. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11200. /**
  11201. * Unproject a ray from screen space to object space
  11202. * @param sourceX defines the screen space x coordinate to use
  11203. * @param sourceY defines the screen space y coordinate to use
  11204. * @param viewportWidth defines the current width of the viewport
  11205. * @param viewportHeight defines the current height of the viewport
  11206. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11207. * @param view defines the view matrix to use
  11208. * @param projection defines the projection matrix to use
  11209. */
  11210. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11211. }
  11212. /**
  11213. * Type used to define predicate used to select faces when a mesh intersection is detected
  11214. */
  11215. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11216. interface Scene {
  11217. /** @hidden */
  11218. _tempPickingRay: Nullable<Ray>;
  11219. /** @hidden */
  11220. _cachedRayForTransform: Ray;
  11221. /** @hidden */
  11222. _pickWithRayInverseMatrix: Matrix;
  11223. /** @hidden */
  11224. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11225. /** @hidden */
  11226. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11227. }
  11228. }
  11229. declare module BABYLON {
  11230. /**
  11231. * Groups all the scene component constants in one place to ease maintenance.
  11232. * @hidden
  11233. */
  11234. export class SceneComponentConstants {
  11235. static readonly NAME_EFFECTLAYER: string;
  11236. static readonly NAME_LAYER: string;
  11237. static readonly NAME_LENSFLARESYSTEM: string;
  11238. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11239. static readonly NAME_PARTICLESYSTEM: string;
  11240. static readonly NAME_GAMEPAD: string;
  11241. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11242. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11243. static readonly NAME_DEPTHRENDERER: string;
  11244. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11245. static readonly NAME_SPRITE: string;
  11246. static readonly NAME_OUTLINERENDERER: string;
  11247. static readonly NAME_PROCEDURALTEXTURE: string;
  11248. static readonly NAME_SHADOWGENERATOR: string;
  11249. static readonly NAME_OCTREE: string;
  11250. static readonly NAME_PHYSICSENGINE: string;
  11251. static readonly NAME_AUDIO: string;
  11252. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11253. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11254. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11255. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11256. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11257. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11258. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11259. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11260. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11261. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11262. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11263. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11264. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11265. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11266. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11267. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11268. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11269. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11270. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11271. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11272. static readonly STEP_AFTERRENDER_AUDIO: number;
  11273. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11274. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11275. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11276. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11277. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11278. static readonly STEP_POINTERMOVE_SPRITE: number;
  11279. static readonly STEP_POINTERDOWN_SPRITE: number;
  11280. static readonly STEP_POINTERUP_SPRITE: number;
  11281. }
  11282. /**
  11283. * This represents a scene component.
  11284. *
  11285. * This is used to decouple the dependency the scene is having on the different workloads like
  11286. * layers, post processes...
  11287. */
  11288. export interface ISceneComponent {
  11289. /**
  11290. * The name of the component. Each component must have a unique name.
  11291. */
  11292. name: string;
  11293. /**
  11294. * The scene the component belongs to.
  11295. */
  11296. scene: Scene;
  11297. /**
  11298. * Register the component to one instance of a scene.
  11299. */
  11300. register(): void;
  11301. /**
  11302. * Rebuilds the elements related to this component in case of
  11303. * context lost for instance.
  11304. */
  11305. rebuild(): void;
  11306. /**
  11307. * Disposes the component and the associated ressources.
  11308. */
  11309. dispose(): void;
  11310. }
  11311. /**
  11312. * This represents a SERIALIZABLE scene component.
  11313. *
  11314. * This extends Scene Component to add Serialization methods on top.
  11315. */
  11316. export interface ISceneSerializableComponent extends ISceneComponent {
  11317. /**
  11318. * Adds all the elements from the container to the scene
  11319. * @param container the container holding the elements
  11320. */
  11321. addFromContainer(container: AbstractScene): void;
  11322. /**
  11323. * Removes all the elements in the container from the scene
  11324. * @param container contains the elements to remove
  11325. * @param dispose if the removed element should be disposed (default: false)
  11326. */
  11327. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11328. /**
  11329. * Serializes the component data to the specified json object
  11330. * @param serializationObject The object to serialize to
  11331. */
  11332. serialize(serializationObject: any): void;
  11333. }
  11334. /**
  11335. * Strong typing of a Mesh related stage step action
  11336. */
  11337. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11338. /**
  11339. * Strong typing of a Evaluate Sub Mesh related stage step action
  11340. */
  11341. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11342. /**
  11343. * Strong typing of a Active Mesh related stage step action
  11344. */
  11345. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11346. /**
  11347. * Strong typing of a Camera related stage step action
  11348. */
  11349. export type CameraStageAction = (camera: Camera) => void;
  11350. /**
  11351. * Strong typing of a Camera Frame buffer related stage step action
  11352. */
  11353. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11354. /**
  11355. * Strong typing of a Render Target related stage step action
  11356. */
  11357. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11358. /**
  11359. * Strong typing of a RenderingGroup related stage step action
  11360. */
  11361. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11362. /**
  11363. * Strong typing of a Mesh Render related stage step action
  11364. */
  11365. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11366. /**
  11367. * Strong typing of a simple stage step action
  11368. */
  11369. export type SimpleStageAction = () => void;
  11370. /**
  11371. * Strong typing of a render target action.
  11372. */
  11373. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11374. /**
  11375. * Strong typing of a pointer move action.
  11376. */
  11377. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11378. /**
  11379. * Strong typing of a pointer up/down action.
  11380. */
  11381. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11382. /**
  11383. * Representation of a stage in the scene (Basically a list of ordered steps)
  11384. * @hidden
  11385. */
  11386. export class Stage<T extends Function> extends Array<{
  11387. index: number;
  11388. component: ISceneComponent;
  11389. action: T;
  11390. }> {
  11391. /**
  11392. * Hide ctor from the rest of the world.
  11393. * @param items The items to add.
  11394. */
  11395. private constructor();
  11396. /**
  11397. * Creates a new Stage.
  11398. * @returns A new instance of a Stage
  11399. */
  11400. static Create<T extends Function>(): Stage<T>;
  11401. /**
  11402. * Registers a step in an ordered way in the targeted stage.
  11403. * @param index Defines the position to register the step in
  11404. * @param component Defines the component attached to the step
  11405. * @param action Defines the action to launch during the step
  11406. */
  11407. registerStep(index: number, component: ISceneComponent, action: T): void;
  11408. /**
  11409. * Clears all the steps from the stage.
  11410. */
  11411. clear(): void;
  11412. }
  11413. }
  11414. declare module BABYLON {
  11415. interface Scene {
  11416. /** @hidden */
  11417. _pointerOverSprite: Nullable<Sprite>;
  11418. /** @hidden */
  11419. _pickedDownSprite: Nullable<Sprite>;
  11420. /** @hidden */
  11421. _tempSpritePickingRay: Nullable<Ray>;
  11422. /**
  11423. * All of the sprite managers added to this scene
  11424. * @see http://doc.babylonjs.com/babylon101/sprites
  11425. */
  11426. spriteManagers: Array<ISpriteManager>;
  11427. /**
  11428. * An event triggered when sprites rendering is about to start
  11429. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11430. */
  11431. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11432. /**
  11433. * An event triggered when sprites rendering is done
  11434. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11435. */
  11436. onAfterSpritesRenderingObservable: Observable<Scene>;
  11437. /** @hidden */
  11438. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11439. /** Launch a ray to try to pick a sprite in the scene
  11440. * @param x position on screen
  11441. * @param y position on screen
  11442. * @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
  11443. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11444. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11445. * @returns a PickingInfo
  11446. */
  11447. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11448. /** Use the given ray to pick a sprite in the scene
  11449. * @param ray The ray (in world space) to use to pick meshes
  11450. * @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
  11451. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11452. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11453. * @returns a PickingInfo
  11454. */
  11455. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11456. /** @hidden */
  11457. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11458. /** Launch a ray to try to pick sprites in the scene
  11459. * @param x position on screen
  11460. * @param y position on screen
  11461. * @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
  11462. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11463. * @returns a PickingInfo array
  11464. */
  11465. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11466. /** Use the given ray to pick sprites in the scene
  11467. * @param ray The ray (in world space) to use to pick meshes
  11468. * @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
  11469. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11470. * @returns a PickingInfo array
  11471. */
  11472. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11473. /**
  11474. * Force the sprite under the pointer
  11475. * @param sprite defines the sprite to use
  11476. */
  11477. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11478. /**
  11479. * Gets the sprite under the pointer
  11480. * @returns a Sprite or null if no sprite is under the pointer
  11481. */
  11482. getPointerOverSprite(): Nullable<Sprite>;
  11483. }
  11484. /**
  11485. * Defines the sprite scene component responsible to manage sprites
  11486. * in a given scene.
  11487. */
  11488. export class SpriteSceneComponent implements ISceneComponent {
  11489. /**
  11490. * The component name helpfull to identify the component in the list of scene components.
  11491. */
  11492. readonly name: string;
  11493. /**
  11494. * The scene the component belongs to.
  11495. */
  11496. scene: Scene;
  11497. /** @hidden */
  11498. private _spritePredicate;
  11499. /**
  11500. * Creates a new instance of the component for the given scene
  11501. * @param scene Defines the scene to register the component in
  11502. */
  11503. constructor(scene: Scene);
  11504. /**
  11505. * Registers the component in a given scene
  11506. */
  11507. register(): void;
  11508. /**
  11509. * Rebuilds the elements related to this component in case of
  11510. * context lost for instance.
  11511. */
  11512. rebuild(): void;
  11513. /**
  11514. * Disposes the component and the associated ressources.
  11515. */
  11516. dispose(): void;
  11517. private _pickSpriteButKeepRay;
  11518. private _pointerMove;
  11519. private _pointerDown;
  11520. private _pointerUp;
  11521. }
  11522. }
  11523. declare module BABYLON {
  11524. /** @hidden */
  11525. export var fogFragmentDeclaration: {
  11526. name: string;
  11527. shader: string;
  11528. };
  11529. }
  11530. declare module BABYLON {
  11531. /** @hidden */
  11532. export var fogFragment: {
  11533. name: string;
  11534. shader: string;
  11535. };
  11536. }
  11537. declare module BABYLON {
  11538. /** @hidden */
  11539. export var spritesPixelShader: {
  11540. name: string;
  11541. shader: string;
  11542. };
  11543. }
  11544. declare module BABYLON {
  11545. /** @hidden */
  11546. export var fogVertexDeclaration: {
  11547. name: string;
  11548. shader: string;
  11549. };
  11550. }
  11551. declare module BABYLON {
  11552. /** @hidden */
  11553. export var spritesVertexShader: {
  11554. name: string;
  11555. shader: string;
  11556. };
  11557. }
  11558. declare module BABYLON {
  11559. /**
  11560. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11561. */
  11562. export interface ISpriteManager extends IDisposable {
  11563. /**
  11564. * Restricts the camera to viewing objects with the same layerMask.
  11565. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11566. */
  11567. layerMask: number;
  11568. /**
  11569. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11570. */
  11571. isPickable: boolean;
  11572. /**
  11573. * Specifies the rendering group id for this mesh (0 by default)
  11574. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11575. */
  11576. renderingGroupId: number;
  11577. /**
  11578. * Defines the list of sprites managed by the manager.
  11579. */
  11580. sprites: Array<Sprite>;
  11581. /**
  11582. * Tests the intersection of a sprite with a specific ray.
  11583. * @param ray The ray we are sending to test the collision
  11584. * @param camera The camera space we are sending rays in
  11585. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11586. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11587. * @returns picking info or null.
  11588. */
  11589. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11590. /**
  11591. * Intersects the sprites with a ray
  11592. * @param ray defines the ray to intersect with
  11593. * @param camera defines the current active camera
  11594. * @param predicate defines a predicate used to select candidate sprites
  11595. * @returns null if no hit or a PickingInfo array
  11596. */
  11597. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11598. /**
  11599. * Renders the list of sprites on screen.
  11600. */
  11601. render(): void;
  11602. }
  11603. /**
  11604. * Class used to manage multiple sprites on the same spritesheet
  11605. * @see http://doc.babylonjs.com/babylon101/sprites
  11606. */
  11607. export class SpriteManager implements ISpriteManager {
  11608. /** defines the manager's name */
  11609. name: string;
  11610. /** Gets the list of sprites */
  11611. sprites: Sprite[];
  11612. /** Gets or sets the rendering group id (0 by default) */
  11613. renderingGroupId: number;
  11614. /** Gets or sets camera layer mask */
  11615. layerMask: number;
  11616. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11617. fogEnabled: boolean;
  11618. /** Gets or sets a boolean indicating if the sprites are pickable */
  11619. isPickable: boolean;
  11620. /** Defines the default width of a cell in the spritesheet */
  11621. cellWidth: number;
  11622. /** Defines the default height of a cell in the spritesheet */
  11623. cellHeight: number;
  11624. /** Associative array from JSON sprite data file */
  11625. private _cellData;
  11626. /** Array of sprite names from JSON sprite data file */
  11627. private _spriteMap;
  11628. /** True when packed cell data from JSON file is ready*/
  11629. private _packedAndReady;
  11630. /**
  11631. * An event triggered when the manager is disposed.
  11632. */
  11633. onDisposeObservable: Observable<SpriteManager>;
  11634. private _onDisposeObserver;
  11635. /**
  11636. * Callback called when the manager is disposed
  11637. */
  11638. onDispose: () => void;
  11639. private _capacity;
  11640. private _fromPacked;
  11641. private _spriteTexture;
  11642. private _epsilon;
  11643. private _scene;
  11644. private _vertexData;
  11645. private _buffer;
  11646. private _vertexBuffers;
  11647. private _indexBuffer;
  11648. private _effectBase;
  11649. private _effectFog;
  11650. /**
  11651. * Gets or sets the spritesheet texture
  11652. */
  11653. texture: Texture;
  11654. /**
  11655. * Creates a new sprite manager
  11656. * @param name defines the manager's name
  11657. * @param imgUrl defines the sprite sheet url
  11658. * @param capacity defines the maximum allowed number of sprites
  11659. * @param cellSize defines the size of a sprite cell
  11660. * @param scene defines the hosting scene
  11661. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11662. * @param samplingMode defines the smapling mode to use with spritesheet
  11663. * @param fromPacked set to false; do not alter
  11664. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11665. */
  11666. constructor(
  11667. /** defines the manager's name */
  11668. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11669. private _makePacked;
  11670. private _appendSpriteVertex;
  11671. /**
  11672. * Intersects the sprites with a ray
  11673. * @param ray defines the ray to intersect with
  11674. * @param camera defines the current active camera
  11675. * @param predicate defines a predicate used to select candidate sprites
  11676. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11677. * @returns null if no hit or a PickingInfo
  11678. */
  11679. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11680. /**
  11681. * Intersects the sprites with a ray
  11682. * @param ray defines the ray to intersect with
  11683. * @param camera defines the current active camera
  11684. * @param predicate defines a predicate used to select candidate sprites
  11685. * @returns null if no hit or a PickingInfo array
  11686. */
  11687. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11688. /**
  11689. * Render all child sprites
  11690. */
  11691. render(): void;
  11692. /**
  11693. * Release associated resources
  11694. */
  11695. dispose(): void;
  11696. }
  11697. }
  11698. declare module BABYLON {
  11699. /**
  11700. * Class used to represent a sprite
  11701. * @see http://doc.babylonjs.com/babylon101/sprites
  11702. */
  11703. export class Sprite {
  11704. /** defines the name */
  11705. name: string;
  11706. /** Gets or sets the current world position */
  11707. position: Vector3;
  11708. /** Gets or sets the main color */
  11709. color: Color4;
  11710. /** Gets or sets the width */
  11711. width: number;
  11712. /** Gets or sets the height */
  11713. height: number;
  11714. /** Gets or sets rotation angle */
  11715. angle: number;
  11716. /** Gets or sets the cell index in the sprite sheet */
  11717. cellIndex: number;
  11718. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11719. cellRef: string;
  11720. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11721. invertU: number;
  11722. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11723. invertV: number;
  11724. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11725. disposeWhenFinishedAnimating: boolean;
  11726. /** Gets the list of attached animations */
  11727. animations: Animation[];
  11728. /** Gets or sets a boolean indicating if the sprite can be picked */
  11729. isPickable: boolean;
  11730. /**
  11731. * Gets or sets the associated action manager
  11732. */
  11733. actionManager: Nullable<ActionManager>;
  11734. private _animationStarted;
  11735. private _loopAnimation;
  11736. private _fromIndex;
  11737. private _toIndex;
  11738. private _delay;
  11739. private _direction;
  11740. private _manager;
  11741. private _time;
  11742. private _onAnimationEnd;
  11743. /**
  11744. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11745. */
  11746. isVisible: boolean;
  11747. /**
  11748. * Gets or sets the sprite size
  11749. */
  11750. size: number;
  11751. /**
  11752. * Creates a new Sprite
  11753. * @param name defines the name
  11754. * @param manager defines the manager
  11755. */
  11756. constructor(
  11757. /** defines the name */
  11758. name: string, manager: ISpriteManager);
  11759. /**
  11760. * Starts an animation
  11761. * @param from defines the initial key
  11762. * @param to defines the end key
  11763. * @param loop defines if the animation must loop
  11764. * @param delay defines the start delay (in ms)
  11765. * @param onAnimationEnd defines a callback to call when animation ends
  11766. */
  11767. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11768. /** Stops current animation (if any) */
  11769. stopAnimation(): void;
  11770. /** @hidden */
  11771. _animate(deltaTime: number): void;
  11772. /** Release associated resources */
  11773. dispose(): void;
  11774. }
  11775. }
  11776. declare module BABYLON {
  11777. /**
  11778. * Information about the result of picking within a scene
  11779. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11780. */
  11781. export class PickingInfo {
  11782. /** @hidden */
  11783. _pickingUnavailable: boolean;
  11784. /**
  11785. * If the pick collided with an object
  11786. */
  11787. hit: boolean;
  11788. /**
  11789. * Distance away where the pick collided
  11790. */
  11791. distance: number;
  11792. /**
  11793. * The location of pick collision
  11794. */
  11795. pickedPoint: Nullable<Vector3>;
  11796. /**
  11797. * The mesh corresponding the the pick collision
  11798. */
  11799. pickedMesh: Nullable<AbstractMesh>;
  11800. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11801. bu: number;
  11802. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11803. bv: number;
  11804. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11805. faceId: number;
  11806. /** Id of the the submesh that was picked */
  11807. subMeshId: number;
  11808. /** If a sprite was picked, this will be the sprite the pick collided with */
  11809. pickedSprite: Nullable<Sprite>;
  11810. /**
  11811. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11812. */
  11813. originMesh: Nullable<AbstractMesh>;
  11814. /**
  11815. * The ray that was used to perform the picking.
  11816. */
  11817. ray: Nullable<Ray>;
  11818. /**
  11819. * Gets the normal correspodning to the face the pick collided with
  11820. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11821. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11822. * @returns The normal correspodning to the face the pick collided with
  11823. */
  11824. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11825. /**
  11826. * Gets the texture coordinates of where the pick occured
  11827. * @returns the vector containing the coordnates of the texture
  11828. */
  11829. getTextureCoordinates(): Nullable<Vector2>;
  11830. }
  11831. }
  11832. declare module BABYLON {
  11833. /**
  11834. * Gather the list of pointer event types as constants.
  11835. */
  11836. export class PointerEventTypes {
  11837. /**
  11838. * 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.
  11839. */
  11840. static readonly POINTERDOWN: number;
  11841. /**
  11842. * The pointerup event is fired when a pointer is no longer active.
  11843. */
  11844. static readonly POINTERUP: number;
  11845. /**
  11846. * The pointermove event is fired when a pointer changes coordinates.
  11847. */
  11848. static readonly POINTERMOVE: number;
  11849. /**
  11850. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11851. */
  11852. static readonly POINTERWHEEL: number;
  11853. /**
  11854. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11855. */
  11856. static readonly POINTERPICK: number;
  11857. /**
  11858. * The pointertap event is fired when a the object has been touched and released without drag.
  11859. */
  11860. static readonly POINTERTAP: number;
  11861. /**
  11862. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11863. */
  11864. static readonly POINTERDOUBLETAP: number;
  11865. }
  11866. /**
  11867. * Base class of pointer info types.
  11868. */
  11869. export class PointerInfoBase {
  11870. /**
  11871. * Defines the type of event (PointerEventTypes)
  11872. */
  11873. type: number;
  11874. /**
  11875. * Defines the related dom event
  11876. */
  11877. event: PointerEvent | MouseWheelEvent;
  11878. /**
  11879. * Instantiates the base class of pointers info.
  11880. * @param type Defines the type of event (PointerEventTypes)
  11881. * @param event Defines the related dom event
  11882. */
  11883. constructor(
  11884. /**
  11885. * Defines the type of event (PointerEventTypes)
  11886. */
  11887. type: number,
  11888. /**
  11889. * Defines the related dom event
  11890. */
  11891. event: PointerEvent | MouseWheelEvent);
  11892. }
  11893. /**
  11894. * This class is used to store pointer related info for the onPrePointerObservable event.
  11895. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11896. */
  11897. export class PointerInfoPre extends PointerInfoBase {
  11898. /**
  11899. * Ray from a pointer if availible (eg. 6dof controller)
  11900. */
  11901. ray: Nullable<Ray>;
  11902. /**
  11903. * Defines the local position of the pointer on the canvas.
  11904. */
  11905. localPosition: Vector2;
  11906. /**
  11907. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11908. */
  11909. skipOnPointerObservable: boolean;
  11910. /**
  11911. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11912. * @param type Defines the type of event (PointerEventTypes)
  11913. * @param event Defines the related dom event
  11914. * @param localX Defines the local x coordinates of the pointer when the event occured
  11915. * @param localY Defines the local y coordinates of the pointer when the event occured
  11916. */
  11917. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11918. }
  11919. /**
  11920. * This type contains all the data related to a pointer event in Babylon.js.
  11921. * 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.
  11922. */
  11923. export class PointerInfo extends PointerInfoBase {
  11924. /**
  11925. * Defines the picking info associated to the info (if any)\
  11926. */
  11927. pickInfo: Nullable<PickingInfo>;
  11928. /**
  11929. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11930. * @param type Defines the type of event (PointerEventTypes)
  11931. * @param event Defines the related dom event
  11932. * @param pickInfo Defines the picking info associated to the info (if any)\
  11933. */
  11934. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11935. /**
  11936. * Defines the picking info associated to the info (if any)\
  11937. */
  11938. pickInfo: Nullable<PickingInfo>);
  11939. }
  11940. /**
  11941. * Data relating to a touch event on the screen.
  11942. */
  11943. export interface PointerTouch {
  11944. /**
  11945. * X coordinate of touch.
  11946. */
  11947. x: number;
  11948. /**
  11949. * Y coordinate of touch.
  11950. */
  11951. y: number;
  11952. /**
  11953. * Id of touch. Unique for each finger.
  11954. */
  11955. pointerId: number;
  11956. /**
  11957. * Event type passed from DOM.
  11958. */
  11959. type: any;
  11960. }
  11961. }
  11962. declare module BABYLON {
  11963. /**
  11964. * Manage the mouse inputs to control the movement of a free camera.
  11965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11966. */
  11967. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11968. /**
  11969. * Define if touch is enabled in the mouse input
  11970. */
  11971. touchEnabled: boolean;
  11972. /**
  11973. * Defines the camera the input is attached to.
  11974. */
  11975. camera: FreeCamera;
  11976. /**
  11977. * Defines the buttons associated with the input to handle camera move.
  11978. */
  11979. buttons: number[];
  11980. /**
  11981. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11982. */
  11983. angularSensibility: number;
  11984. private _pointerInput;
  11985. private _onMouseMove;
  11986. private _observer;
  11987. private previousPosition;
  11988. /**
  11989. * Observable for when a pointer move event occurs containing the move offset
  11990. */
  11991. onPointerMovedObservable: Observable<{
  11992. offsetX: number;
  11993. offsetY: number;
  11994. }>;
  11995. /**
  11996. * @hidden
  11997. * If the camera should be rotated automatically based on pointer movement
  11998. */
  11999. _allowCameraRotation: boolean;
  12000. /**
  12001. * Manage the mouse inputs to control the movement of a free camera.
  12002. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12003. * @param touchEnabled Defines if touch is enabled or not
  12004. */
  12005. constructor(
  12006. /**
  12007. * Define if touch is enabled in the mouse input
  12008. */
  12009. touchEnabled?: boolean);
  12010. /**
  12011. * Attach the input controls to a specific dom element to get the input from.
  12012. * @param element Defines the element the controls should be listened from
  12013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12014. */
  12015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12016. /**
  12017. * Called on JS contextmenu event.
  12018. * Override this method to provide functionality.
  12019. */
  12020. protected onContextMenu(evt: PointerEvent): void;
  12021. /**
  12022. * Detach the current controls from the specified dom element.
  12023. * @param element Defines the element to stop listening the inputs from
  12024. */
  12025. detachControl(element: Nullable<HTMLElement>): void;
  12026. /**
  12027. * Gets the class name of the current intput.
  12028. * @returns the class name
  12029. */
  12030. getClassName(): string;
  12031. /**
  12032. * Get the friendly name associated with the input class.
  12033. * @returns the input friendly name
  12034. */
  12035. getSimpleName(): string;
  12036. }
  12037. }
  12038. declare module BABYLON {
  12039. /**
  12040. * Manage the touch inputs to control the movement of a free camera.
  12041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12042. */
  12043. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12044. /**
  12045. * Defines the camera the input is attached to.
  12046. */
  12047. camera: FreeCamera;
  12048. /**
  12049. * Defines the touch sensibility for rotation.
  12050. * The higher the faster.
  12051. */
  12052. touchAngularSensibility: number;
  12053. /**
  12054. * Defines the touch sensibility for move.
  12055. * The higher the faster.
  12056. */
  12057. touchMoveSensibility: number;
  12058. private _offsetX;
  12059. private _offsetY;
  12060. private _pointerPressed;
  12061. private _pointerInput;
  12062. private _observer;
  12063. private _onLostFocus;
  12064. /**
  12065. * Attach the input controls to a specific dom element to get the input from.
  12066. * @param element Defines the element the controls should be listened from
  12067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12068. */
  12069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12070. /**
  12071. * Detach the current controls from the specified dom element.
  12072. * @param element Defines the element to stop listening the inputs from
  12073. */
  12074. detachControl(element: Nullable<HTMLElement>): void;
  12075. /**
  12076. * Update the current camera state depending on the inputs that have been used this frame.
  12077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12078. */
  12079. checkInputs(): void;
  12080. /**
  12081. * Gets the class name of the current intput.
  12082. * @returns the class name
  12083. */
  12084. getClassName(): string;
  12085. /**
  12086. * Get the friendly name associated with the input class.
  12087. * @returns the input friendly name
  12088. */
  12089. getSimpleName(): string;
  12090. }
  12091. }
  12092. declare module BABYLON {
  12093. /**
  12094. * Default Inputs manager for the FreeCamera.
  12095. * It groups all the default supported inputs for ease of use.
  12096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12097. */
  12098. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12099. /**
  12100. * @hidden
  12101. */
  12102. _mouseInput: Nullable<FreeCameraMouseInput>;
  12103. /**
  12104. * Instantiates a new FreeCameraInputsManager.
  12105. * @param camera Defines the camera the inputs belong to
  12106. */
  12107. constructor(camera: FreeCamera);
  12108. /**
  12109. * Add keyboard input support to the input manager.
  12110. * @returns the current input manager
  12111. */
  12112. addKeyboard(): FreeCameraInputsManager;
  12113. /**
  12114. * Add mouse input support to the input manager.
  12115. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12116. * @returns the current input manager
  12117. */
  12118. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12119. /**
  12120. * Removes the mouse input support from the manager
  12121. * @returns the current input manager
  12122. */
  12123. removeMouse(): FreeCameraInputsManager;
  12124. /**
  12125. * Add touch input support to the input manager.
  12126. * @returns the current input manager
  12127. */
  12128. addTouch(): FreeCameraInputsManager;
  12129. /**
  12130. * Remove all attached input methods from a camera
  12131. */
  12132. clear(): void;
  12133. }
  12134. }
  12135. declare module BABYLON {
  12136. /**
  12137. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12138. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12139. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12140. */
  12141. export class FreeCamera extends TargetCamera {
  12142. /**
  12143. * Define the collision ellipsoid of the camera.
  12144. * This is helpful to simulate a camera body like the player body around the camera
  12145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12146. */
  12147. ellipsoid: Vector3;
  12148. /**
  12149. * Define an offset for the position of the ellipsoid around the camera.
  12150. * This can be helpful to determine the center of the body near the gravity center of the body
  12151. * instead of its head.
  12152. */
  12153. ellipsoidOffset: Vector3;
  12154. /**
  12155. * Enable or disable collisions of the camera with the rest of the scene objects.
  12156. */
  12157. checkCollisions: boolean;
  12158. /**
  12159. * Enable or disable gravity on the camera.
  12160. */
  12161. applyGravity: boolean;
  12162. /**
  12163. * Define the input manager associated to the camera.
  12164. */
  12165. inputs: FreeCameraInputsManager;
  12166. /**
  12167. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12168. * Higher values reduce sensitivity.
  12169. */
  12170. /**
  12171. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12172. * Higher values reduce sensitivity.
  12173. */
  12174. angularSensibility: number;
  12175. /**
  12176. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12177. */
  12178. keysUp: number[];
  12179. /**
  12180. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12181. */
  12182. keysDown: number[];
  12183. /**
  12184. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12185. */
  12186. keysLeft: number[];
  12187. /**
  12188. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12189. */
  12190. keysRight: number[];
  12191. /**
  12192. * Event raised when the camera collide with a mesh in the scene.
  12193. */
  12194. onCollide: (collidedMesh: AbstractMesh) => void;
  12195. private _collider;
  12196. private _needMoveForGravity;
  12197. private _oldPosition;
  12198. private _diffPosition;
  12199. private _newPosition;
  12200. /** @hidden */
  12201. _localDirection: Vector3;
  12202. /** @hidden */
  12203. _transformedDirection: Vector3;
  12204. /**
  12205. * Instantiates a Free Camera.
  12206. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12207. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12208. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12209. * @param name Define the name of the camera in the scene
  12210. * @param position Define the start position of the camera in the scene
  12211. * @param scene Define the scene the camera belongs to
  12212. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12213. */
  12214. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12215. /**
  12216. * Attached controls to the current camera.
  12217. * @param element Defines the element the controls should be listened from
  12218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12219. */
  12220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12221. /**
  12222. * Detach the current controls from the camera.
  12223. * The camera will stop reacting to inputs.
  12224. * @param element Defines the element to stop listening the inputs from
  12225. */
  12226. detachControl(element: HTMLElement): void;
  12227. private _collisionMask;
  12228. /**
  12229. * Define a collision mask to limit the list of object the camera can collide with
  12230. */
  12231. collisionMask: number;
  12232. /** @hidden */
  12233. _collideWithWorld(displacement: Vector3): void;
  12234. private _onCollisionPositionChange;
  12235. /** @hidden */
  12236. _checkInputs(): void;
  12237. /** @hidden */
  12238. _decideIfNeedsToMove(): boolean;
  12239. /** @hidden */
  12240. _updatePosition(): void;
  12241. /**
  12242. * Destroy the camera and release the current resources hold by it.
  12243. */
  12244. dispose(): void;
  12245. /**
  12246. * Gets the current object class name.
  12247. * @return the class name
  12248. */
  12249. getClassName(): string;
  12250. }
  12251. }
  12252. declare module BABYLON {
  12253. /**
  12254. * Represents a gamepad control stick position
  12255. */
  12256. export class StickValues {
  12257. /**
  12258. * The x component of the control stick
  12259. */
  12260. x: number;
  12261. /**
  12262. * The y component of the control stick
  12263. */
  12264. y: number;
  12265. /**
  12266. * Initializes the gamepad x and y control stick values
  12267. * @param x The x component of the gamepad control stick value
  12268. * @param y The y component of the gamepad control stick value
  12269. */
  12270. constructor(
  12271. /**
  12272. * The x component of the control stick
  12273. */
  12274. x: number,
  12275. /**
  12276. * The y component of the control stick
  12277. */
  12278. y: number);
  12279. }
  12280. /**
  12281. * An interface which manages callbacks for gamepad button changes
  12282. */
  12283. export interface GamepadButtonChanges {
  12284. /**
  12285. * Called when a gamepad has been changed
  12286. */
  12287. changed: boolean;
  12288. /**
  12289. * Called when a gamepad press event has been triggered
  12290. */
  12291. pressChanged: boolean;
  12292. /**
  12293. * Called when a touch event has been triggered
  12294. */
  12295. touchChanged: boolean;
  12296. /**
  12297. * Called when a value has changed
  12298. */
  12299. valueChanged: boolean;
  12300. }
  12301. /**
  12302. * Represents a gamepad
  12303. */
  12304. export class Gamepad {
  12305. /**
  12306. * The id of the gamepad
  12307. */
  12308. id: string;
  12309. /**
  12310. * The index of the gamepad
  12311. */
  12312. index: number;
  12313. /**
  12314. * The browser gamepad
  12315. */
  12316. browserGamepad: any;
  12317. /**
  12318. * Specifies what type of gamepad this represents
  12319. */
  12320. type: number;
  12321. private _leftStick;
  12322. private _rightStick;
  12323. /** @hidden */
  12324. _isConnected: boolean;
  12325. private _leftStickAxisX;
  12326. private _leftStickAxisY;
  12327. private _rightStickAxisX;
  12328. private _rightStickAxisY;
  12329. /**
  12330. * Triggered when the left control stick has been changed
  12331. */
  12332. private _onleftstickchanged;
  12333. /**
  12334. * Triggered when the right control stick has been changed
  12335. */
  12336. private _onrightstickchanged;
  12337. /**
  12338. * Represents a gamepad controller
  12339. */
  12340. static GAMEPAD: number;
  12341. /**
  12342. * Represents a generic controller
  12343. */
  12344. static GENERIC: number;
  12345. /**
  12346. * Represents an XBox controller
  12347. */
  12348. static XBOX: number;
  12349. /**
  12350. * Represents a pose-enabled controller
  12351. */
  12352. static POSE_ENABLED: number;
  12353. /**
  12354. * Represents an Dual Shock controller
  12355. */
  12356. static DUALSHOCK: number;
  12357. /**
  12358. * Specifies whether the left control stick should be Y-inverted
  12359. */
  12360. protected _invertLeftStickY: boolean;
  12361. /**
  12362. * Specifies if the gamepad has been connected
  12363. */
  12364. readonly isConnected: boolean;
  12365. /**
  12366. * Initializes the gamepad
  12367. * @param id The id of the gamepad
  12368. * @param index The index of the gamepad
  12369. * @param browserGamepad The browser gamepad
  12370. * @param leftStickX The x component of the left joystick
  12371. * @param leftStickY The y component of the left joystick
  12372. * @param rightStickX The x component of the right joystick
  12373. * @param rightStickY The y component of the right joystick
  12374. */
  12375. constructor(
  12376. /**
  12377. * The id of the gamepad
  12378. */
  12379. id: string,
  12380. /**
  12381. * The index of the gamepad
  12382. */
  12383. index: number,
  12384. /**
  12385. * The browser gamepad
  12386. */
  12387. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12388. /**
  12389. * Callback triggered when the left joystick has changed
  12390. * @param callback
  12391. */
  12392. onleftstickchanged(callback: (values: StickValues) => void): void;
  12393. /**
  12394. * Callback triggered when the right joystick has changed
  12395. * @param callback
  12396. */
  12397. onrightstickchanged(callback: (values: StickValues) => void): void;
  12398. /**
  12399. * Gets the left joystick
  12400. */
  12401. /**
  12402. * Sets the left joystick values
  12403. */
  12404. leftStick: StickValues;
  12405. /**
  12406. * Gets the right joystick
  12407. */
  12408. /**
  12409. * Sets the right joystick value
  12410. */
  12411. rightStick: StickValues;
  12412. /**
  12413. * Updates the gamepad joystick positions
  12414. */
  12415. update(): void;
  12416. /**
  12417. * Disposes the gamepad
  12418. */
  12419. dispose(): void;
  12420. }
  12421. /**
  12422. * Represents a generic gamepad
  12423. */
  12424. export class GenericPad extends Gamepad {
  12425. private _buttons;
  12426. private _onbuttondown;
  12427. private _onbuttonup;
  12428. /**
  12429. * Observable triggered when a button has been pressed
  12430. */
  12431. onButtonDownObservable: Observable<number>;
  12432. /**
  12433. * Observable triggered when a button has been released
  12434. */
  12435. onButtonUpObservable: Observable<number>;
  12436. /**
  12437. * Callback triggered when a button has been pressed
  12438. * @param callback Called when a button has been pressed
  12439. */
  12440. onbuttondown(callback: (buttonPressed: number) => void): void;
  12441. /**
  12442. * Callback triggered when a button has been released
  12443. * @param callback Called when a button has been released
  12444. */
  12445. onbuttonup(callback: (buttonReleased: number) => void): void;
  12446. /**
  12447. * Initializes the generic gamepad
  12448. * @param id The id of the generic gamepad
  12449. * @param index The index of the generic gamepad
  12450. * @param browserGamepad The browser gamepad
  12451. */
  12452. constructor(id: string, index: number, browserGamepad: any);
  12453. private _setButtonValue;
  12454. /**
  12455. * Updates the generic gamepad
  12456. */
  12457. update(): void;
  12458. /**
  12459. * Disposes the generic gamepad
  12460. */
  12461. dispose(): void;
  12462. }
  12463. }
  12464. declare module BABYLON {
  12465. interface Engine {
  12466. /**
  12467. * Creates a raw texture
  12468. * @param data defines the data to store in the texture
  12469. * @param width defines the width of the texture
  12470. * @param height defines the height of the texture
  12471. * @param format defines the format of the data
  12472. * @param generateMipMaps defines if the engine should generate the mip levels
  12473. * @param invertY defines if data must be stored with Y axis inverted
  12474. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12475. * @param compression defines the compression used (null by default)
  12476. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12477. * @returns the raw texture inside an InternalTexture
  12478. */
  12479. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12480. /**
  12481. * Update a raw texture
  12482. * @param texture defines the texture to update
  12483. * @param data defines the data to store in the texture
  12484. * @param format defines the format of the data
  12485. * @param invertY defines if data must be stored with Y axis inverted
  12486. */
  12487. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12488. /**
  12489. * Update a raw texture
  12490. * @param texture defines the texture to update
  12491. * @param data defines the data to store in the texture
  12492. * @param format defines the format of the data
  12493. * @param invertY defines if data must be stored with Y axis inverted
  12494. * @param compression defines the compression used (null by default)
  12495. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12496. */
  12497. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12498. /**
  12499. * Creates a new raw cube texture
  12500. * @param data defines the array of data to use to create each face
  12501. * @param size defines the size of the textures
  12502. * @param format defines the format of the data
  12503. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12504. * @param generateMipMaps defines if the engine should generate the mip levels
  12505. * @param invertY defines if data must be stored with Y axis inverted
  12506. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12507. * @param compression defines the compression used (null by default)
  12508. * @returns the cube texture as an InternalTexture
  12509. */
  12510. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12511. /**
  12512. * Update a raw cube texture
  12513. * @param texture defines the texture to udpdate
  12514. * @param data defines the data to store
  12515. * @param format defines the data format
  12516. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12517. * @param invertY defines if data must be stored with Y axis inverted
  12518. */
  12519. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12520. /**
  12521. * Update a raw cube texture
  12522. * @param texture defines the texture to udpdate
  12523. * @param data defines the data to store
  12524. * @param format defines the data format
  12525. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12526. * @param invertY defines if data must be stored with Y axis inverted
  12527. * @param compression defines the compression used (null by default)
  12528. */
  12529. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12530. /**
  12531. * Update a raw cube texture
  12532. * @param texture defines the texture to udpdate
  12533. * @param data defines the data to store
  12534. * @param format defines the data format
  12535. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12536. * @param invertY defines if data must be stored with Y axis inverted
  12537. * @param compression defines the compression used (null by default)
  12538. * @param level defines which level of the texture to update
  12539. */
  12540. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12541. /**
  12542. * Creates a new raw cube texture from a specified url
  12543. * @param url defines the url where the data is located
  12544. * @param scene defines the current scene
  12545. * @param size defines the size of the textures
  12546. * @param format defines the format of the data
  12547. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12548. * @param noMipmap defines if the engine should avoid generating the mip levels
  12549. * @param callback defines a callback used to extract texture data from loaded data
  12550. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12551. * @param onLoad defines a callback called when texture is loaded
  12552. * @param onError defines a callback called if there is an error
  12553. * @returns the cube texture as an InternalTexture
  12554. */
  12555. createRawCubeTextureFromUrl(url: string, scene: 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;
  12556. /**
  12557. * Creates a new raw cube texture from a specified url
  12558. * @param url defines the url where the data is located
  12559. * @param scene defines the current scene
  12560. * @param size defines the size of the textures
  12561. * @param format defines the format of the data
  12562. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12563. * @param noMipmap defines if the engine should avoid generating the mip levels
  12564. * @param callback defines a callback used to extract texture data from loaded data
  12565. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12566. * @param onLoad defines a callback called when texture is loaded
  12567. * @param onError defines a callback called if there is an error
  12568. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12569. * @param invertY defines if data must be stored with Y axis inverted
  12570. * @returns the cube texture as an InternalTexture
  12571. */
  12572. createRawCubeTextureFromUrl(url: string, scene: 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;
  12573. /**
  12574. * Creates a new raw 3D texture
  12575. * @param data defines the data used to create the texture
  12576. * @param width defines the width of the texture
  12577. * @param height defines the height of the texture
  12578. * @param depth defines the depth of the texture
  12579. * @param format defines the format of the texture
  12580. * @param generateMipMaps defines if the engine must generate mip levels
  12581. * @param invertY defines if data must be stored with Y axis inverted
  12582. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12583. * @param compression defines the compressed used (can be null)
  12584. * @param textureType defines the compressed used (can be null)
  12585. * @returns a new raw 3D texture (stored in an InternalTexture)
  12586. */
  12587. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12588. /**
  12589. * Update a raw 3D texture
  12590. * @param texture defines the texture to update
  12591. * @param data defines the data to store
  12592. * @param format defines the data format
  12593. * @param invertY defines if data must be stored with Y axis inverted
  12594. */
  12595. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12596. /**
  12597. * Update a raw 3D texture
  12598. * @param texture defines the texture to update
  12599. * @param data defines the data to store
  12600. * @param format defines the data format
  12601. * @param invertY defines if data must be stored with Y axis inverted
  12602. * @param compression defines the used compression (can be null)
  12603. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12604. */
  12605. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12606. /**
  12607. * Creates a new raw 2D array texture
  12608. * @param data defines the data used to create the texture
  12609. * @param width defines the width of the texture
  12610. * @param height defines the height of the texture
  12611. * @param depth defines the number of layers of the texture
  12612. * @param format defines the format of the texture
  12613. * @param generateMipMaps defines if the engine must generate mip levels
  12614. * @param invertY defines if data must be stored with Y axis inverted
  12615. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12616. * @param compression defines the compressed used (can be null)
  12617. * @param textureType defines the compressed used (can be null)
  12618. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12619. */
  12620. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12621. /**
  12622. * Update a raw 2D array texture
  12623. * @param texture defines the texture to update
  12624. * @param data defines the data to store
  12625. * @param format defines the data format
  12626. * @param invertY defines if data must be stored with Y axis inverted
  12627. */
  12628. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12629. /**
  12630. * Update a raw 2D array texture
  12631. * @param texture defines the texture to update
  12632. * @param data defines the data to store
  12633. * @param format defines the data format
  12634. * @param invertY defines if data must be stored with Y axis inverted
  12635. * @param compression defines the used compression (can be null)
  12636. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12637. */
  12638. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12639. }
  12640. }
  12641. declare module BABYLON {
  12642. /**
  12643. * Raw texture can help creating a texture directly from an array of data.
  12644. * This can be super useful if you either get the data from an uncompressed source or
  12645. * if you wish to create your texture pixel by pixel.
  12646. */
  12647. export class RawTexture extends Texture {
  12648. /**
  12649. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12650. */
  12651. format: number;
  12652. private _engine;
  12653. /**
  12654. * Instantiates a new RawTexture.
  12655. * Raw texture can help creating a texture directly from an array of data.
  12656. * This can be super useful if you either get the data from an uncompressed source or
  12657. * if you wish to create your texture pixel by pixel.
  12658. * @param data define the array of data to use to create the texture
  12659. * @param width define the width of the texture
  12660. * @param height define the height of the texture
  12661. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12662. * @param scene define the scene the texture belongs to
  12663. * @param generateMipMaps define whether mip maps should be generated or not
  12664. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12665. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12666. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12667. */
  12668. constructor(data: ArrayBufferView, width: number, height: number,
  12669. /**
  12670. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12671. */
  12672. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12673. /**
  12674. * Updates the texture underlying data.
  12675. * @param data Define the new data of the texture
  12676. */
  12677. update(data: ArrayBufferView): void;
  12678. /**
  12679. * Creates a luminance texture from some data.
  12680. * @param data Define the texture data
  12681. * @param width Define the width of the texture
  12682. * @param height Define the height of the texture
  12683. * @param scene Define the scene the texture belongs to
  12684. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12685. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12686. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12687. * @returns the luminance texture
  12688. */
  12689. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12690. /**
  12691. * Creates a luminance alpha texture from some data.
  12692. * @param data Define the texture data
  12693. * @param width Define the width of the texture
  12694. * @param height Define the height of the texture
  12695. * @param scene Define the scene the texture belongs to
  12696. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12697. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12698. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12699. * @returns the luminance alpha texture
  12700. */
  12701. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12702. /**
  12703. * Creates an alpha texture from some data.
  12704. * @param data Define the texture data
  12705. * @param width Define the width of the texture
  12706. * @param height Define the height of the texture
  12707. * @param scene Define the scene the texture belongs to
  12708. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12709. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12710. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12711. * @returns the alpha texture
  12712. */
  12713. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12714. /**
  12715. * Creates a RGB texture from some data.
  12716. * @param data Define the texture data
  12717. * @param width Define the width of the texture
  12718. * @param height Define the height of the texture
  12719. * @param scene Define the scene the texture belongs to
  12720. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12721. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12722. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12723. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12724. * @returns the RGB alpha texture
  12725. */
  12726. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12727. /**
  12728. * Creates a RGBA texture from some data.
  12729. * @param data Define the texture data
  12730. * @param width Define the width of the texture
  12731. * @param height Define the height of the texture
  12732. * @param scene Define the scene the texture belongs to
  12733. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12734. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12735. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12736. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12737. * @returns the RGBA texture
  12738. */
  12739. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12740. /**
  12741. * Creates a R texture from some data.
  12742. * @param data Define the texture data
  12743. * @param width Define the width of the texture
  12744. * @param height Define the height of the texture
  12745. * @param scene Define the scene the texture belongs to
  12746. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12747. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12748. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12749. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12750. * @returns the R texture
  12751. */
  12752. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12753. }
  12754. }
  12755. declare module BABYLON {
  12756. /**
  12757. * Interface for the size containing width and height
  12758. */
  12759. export interface ISize {
  12760. /**
  12761. * Width
  12762. */
  12763. width: number;
  12764. /**
  12765. * Heighht
  12766. */
  12767. height: number;
  12768. }
  12769. /**
  12770. * Size containing widht and height
  12771. */
  12772. export class Size implements ISize {
  12773. /**
  12774. * Width
  12775. */
  12776. width: number;
  12777. /**
  12778. * Height
  12779. */
  12780. height: number;
  12781. /**
  12782. * Creates a Size object from the given width and height (floats).
  12783. * @param width width of the new size
  12784. * @param height height of the new size
  12785. */
  12786. constructor(width: number, height: number);
  12787. /**
  12788. * Returns a string with the Size width and height
  12789. * @returns a string with the Size width and height
  12790. */
  12791. toString(): string;
  12792. /**
  12793. * "Size"
  12794. * @returns the string "Size"
  12795. */
  12796. getClassName(): string;
  12797. /**
  12798. * Returns the Size hash code.
  12799. * @returns a hash code for a unique width and height
  12800. */
  12801. getHashCode(): number;
  12802. /**
  12803. * Updates the current size from the given one.
  12804. * @param src the given size
  12805. */
  12806. copyFrom(src: Size): void;
  12807. /**
  12808. * Updates in place the current Size from the given floats.
  12809. * @param width width of the new size
  12810. * @param height height of the new size
  12811. * @returns the updated Size.
  12812. */
  12813. copyFromFloats(width: number, height: number): Size;
  12814. /**
  12815. * Updates in place the current Size from the given floats.
  12816. * @param width width to set
  12817. * @param height height to set
  12818. * @returns the updated Size.
  12819. */
  12820. set(width: number, height: number): Size;
  12821. /**
  12822. * Multiplies the width and height by numbers
  12823. * @param w factor to multiple the width by
  12824. * @param h factor to multiple the height by
  12825. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12826. */
  12827. multiplyByFloats(w: number, h: number): Size;
  12828. /**
  12829. * Clones the size
  12830. * @returns a new Size copied from the given one.
  12831. */
  12832. clone(): Size;
  12833. /**
  12834. * True if the current Size and the given one width and height are strictly equal.
  12835. * @param other the other size to compare against
  12836. * @returns True if the current Size and the given one width and height are strictly equal.
  12837. */
  12838. equals(other: Size): boolean;
  12839. /**
  12840. * The surface of the Size : width * height (float).
  12841. */
  12842. readonly surface: number;
  12843. /**
  12844. * Create a new size of zero
  12845. * @returns a new Size set to (0.0, 0.0)
  12846. */
  12847. static Zero(): Size;
  12848. /**
  12849. * Sums the width and height of two sizes
  12850. * @param otherSize size to add to this size
  12851. * @returns a new Size set as the addition result of the current Size and the given one.
  12852. */
  12853. add(otherSize: Size): Size;
  12854. /**
  12855. * Subtracts the width and height of two
  12856. * @param otherSize size to subtract to this size
  12857. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12858. */
  12859. subtract(otherSize: Size): Size;
  12860. /**
  12861. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12862. * @param start starting size to lerp between
  12863. * @param end end size to lerp between
  12864. * @param amount amount to lerp between the start and end values
  12865. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12866. */
  12867. static Lerp(start: Size, end: Size, amount: number): Size;
  12868. }
  12869. }
  12870. declare module BABYLON {
  12871. /**
  12872. * Defines a runtime animation
  12873. */
  12874. export class RuntimeAnimation {
  12875. private _events;
  12876. /**
  12877. * The current frame of the runtime animation
  12878. */
  12879. private _currentFrame;
  12880. /**
  12881. * The animation used by the runtime animation
  12882. */
  12883. private _animation;
  12884. /**
  12885. * The target of the runtime animation
  12886. */
  12887. private _target;
  12888. /**
  12889. * The initiating animatable
  12890. */
  12891. private _host;
  12892. /**
  12893. * The original value of the runtime animation
  12894. */
  12895. private _originalValue;
  12896. /**
  12897. * The original blend value of the runtime animation
  12898. */
  12899. private _originalBlendValue;
  12900. /**
  12901. * The offsets cache of the runtime animation
  12902. */
  12903. private _offsetsCache;
  12904. /**
  12905. * The high limits cache of the runtime animation
  12906. */
  12907. private _highLimitsCache;
  12908. /**
  12909. * Specifies if the runtime animation has been stopped
  12910. */
  12911. private _stopped;
  12912. /**
  12913. * The blending factor of the runtime animation
  12914. */
  12915. private _blendingFactor;
  12916. /**
  12917. * The BabylonJS scene
  12918. */
  12919. private _scene;
  12920. /**
  12921. * The current value of the runtime animation
  12922. */
  12923. private _currentValue;
  12924. /** @hidden */
  12925. _animationState: _IAnimationState;
  12926. /**
  12927. * The active target of the runtime animation
  12928. */
  12929. private _activeTargets;
  12930. private _currentActiveTarget;
  12931. private _directTarget;
  12932. /**
  12933. * The target path of the runtime animation
  12934. */
  12935. private _targetPath;
  12936. /**
  12937. * The weight of the runtime animation
  12938. */
  12939. private _weight;
  12940. /**
  12941. * The ratio offset of the runtime animation
  12942. */
  12943. private _ratioOffset;
  12944. /**
  12945. * The previous delay of the runtime animation
  12946. */
  12947. private _previousDelay;
  12948. /**
  12949. * The previous ratio of the runtime animation
  12950. */
  12951. private _previousRatio;
  12952. private _enableBlending;
  12953. private _keys;
  12954. private _minFrame;
  12955. private _maxFrame;
  12956. private _minValue;
  12957. private _maxValue;
  12958. private _targetIsArray;
  12959. /**
  12960. * Gets the current frame of the runtime animation
  12961. */
  12962. readonly currentFrame: number;
  12963. /**
  12964. * Gets the weight of the runtime animation
  12965. */
  12966. readonly weight: number;
  12967. /**
  12968. * Gets the current value of the runtime animation
  12969. */
  12970. readonly currentValue: any;
  12971. /**
  12972. * Gets the target path of the runtime animation
  12973. */
  12974. readonly targetPath: string;
  12975. /**
  12976. * Gets the actual target of the runtime animation
  12977. */
  12978. readonly target: any;
  12979. /** @hidden */
  12980. _onLoop: () => void;
  12981. /**
  12982. * Create a new RuntimeAnimation object
  12983. * @param target defines the target of the animation
  12984. * @param animation defines the source animation object
  12985. * @param scene defines the hosting scene
  12986. * @param host defines the initiating Animatable
  12987. */
  12988. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12989. private _preparePath;
  12990. /**
  12991. * Gets the animation from the runtime animation
  12992. */
  12993. readonly animation: Animation;
  12994. /**
  12995. * Resets the runtime animation to the beginning
  12996. * @param restoreOriginal defines whether to restore the target property to the original value
  12997. */
  12998. reset(restoreOriginal?: boolean): void;
  12999. /**
  13000. * Specifies if the runtime animation is stopped
  13001. * @returns Boolean specifying if the runtime animation is stopped
  13002. */
  13003. isStopped(): boolean;
  13004. /**
  13005. * Disposes of the runtime animation
  13006. */
  13007. dispose(): void;
  13008. /**
  13009. * Apply the interpolated value to the target
  13010. * @param currentValue defines the value computed by the animation
  13011. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13012. */
  13013. setValue(currentValue: any, weight: number): void;
  13014. private _getOriginalValues;
  13015. private _setValue;
  13016. /**
  13017. * Gets the loop pmode of the runtime animation
  13018. * @returns Loop Mode
  13019. */
  13020. private _getCorrectLoopMode;
  13021. /**
  13022. * Move the current animation to a given frame
  13023. * @param frame defines the frame to move to
  13024. */
  13025. goToFrame(frame: number): void;
  13026. /**
  13027. * @hidden Internal use only
  13028. */
  13029. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13030. /**
  13031. * Execute the current animation
  13032. * @param delay defines the delay to add to the current frame
  13033. * @param from defines the lower bound of the animation range
  13034. * @param to defines the upper bound of the animation range
  13035. * @param loop defines if the current animation must loop
  13036. * @param speedRatio defines the current speed ratio
  13037. * @param weight defines the weight of the animation (default is -1 so no weight)
  13038. * @param onLoop optional callback called when animation loops
  13039. * @returns a boolean indicating if the animation is running
  13040. */
  13041. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13042. }
  13043. }
  13044. declare module BABYLON {
  13045. /**
  13046. * Class used to store an actual running animation
  13047. */
  13048. export class Animatable {
  13049. /** defines the target object */
  13050. target: any;
  13051. /** defines the starting frame number (default is 0) */
  13052. fromFrame: number;
  13053. /** defines the ending frame number (default is 100) */
  13054. toFrame: number;
  13055. /** defines if the animation must loop (default is false) */
  13056. loopAnimation: boolean;
  13057. /** defines a callback to call when animation ends if it is not looping */
  13058. onAnimationEnd?: (() => void) | null | undefined;
  13059. /** defines a callback to call when animation loops */
  13060. onAnimationLoop?: (() => void) | null | undefined;
  13061. private _localDelayOffset;
  13062. private _pausedDelay;
  13063. private _runtimeAnimations;
  13064. private _paused;
  13065. private _scene;
  13066. private _speedRatio;
  13067. private _weight;
  13068. private _syncRoot;
  13069. /**
  13070. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13071. * This will only apply for non looping animation (default is true)
  13072. */
  13073. disposeOnEnd: boolean;
  13074. /**
  13075. * Gets a boolean indicating if the animation has started
  13076. */
  13077. animationStarted: boolean;
  13078. /**
  13079. * Observer raised when the animation ends
  13080. */
  13081. onAnimationEndObservable: Observable<Animatable>;
  13082. /**
  13083. * Observer raised when the animation loops
  13084. */
  13085. onAnimationLoopObservable: Observable<Animatable>;
  13086. /**
  13087. * Gets the root Animatable used to synchronize and normalize animations
  13088. */
  13089. readonly syncRoot: Nullable<Animatable>;
  13090. /**
  13091. * Gets the current frame of the first RuntimeAnimation
  13092. * Used to synchronize Animatables
  13093. */
  13094. readonly masterFrame: number;
  13095. /**
  13096. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13097. */
  13098. weight: number;
  13099. /**
  13100. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13101. */
  13102. speedRatio: number;
  13103. /**
  13104. * Creates a new Animatable
  13105. * @param scene defines the hosting scene
  13106. * @param target defines the target object
  13107. * @param fromFrame defines the starting frame number (default is 0)
  13108. * @param toFrame defines the ending frame number (default is 100)
  13109. * @param loopAnimation defines if the animation must loop (default is false)
  13110. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13111. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13112. * @param animations defines a group of animation to add to the new Animatable
  13113. * @param onAnimationLoop defines a callback to call when animation loops
  13114. */
  13115. constructor(scene: Scene,
  13116. /** defines the target object */
  13117. target: any,
  13118. /** defines the starting frame number (default is 0) */
  13119. fromFrame?: number,
  13120. /** defines the ending frame number (default is 100) */
  13121. toFrame?: number,
  13122. /** defines if the animation must loop (default is false) */
  13123. loopAnimation?: boolean, speedRatio?: number,
  13124. /** defines a callback to call when animation ends if it is not looping */
  13125. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13126. /** defines a callback to call when animation loops */
  13127. onAnimationLoop?: (() => void) | null | undefined);
  13128. /**
  13129. * Synchronize and normalize current Animatable with a source Animatable
  13130. * This is useful when using animation weights and when animations are not of the same length
  13131. * @param root defines the root Animatable to synchronize with
  13132. * @returns the current Animatable
  13133. */
  13134. syncWith(root: Animatable): Animatable;
  13135. /**
  13136. * Gets the list of runtime animations
  13137. * @returns an array of RuntimeAnimation
  13138. */
  13139. getAnimations(): RuntimeAnimation[];
  13140. /**
  13141. * Adds more animations to the current animatable
  13142. * @param target defines the target of the animations
  13143. * @param animations defines the new animations to add
  13144. */
  13145. appendAnimations(target: any, animations: Animation[]): void;
  13146. /**
  13147. * Gets the source animation for a specific property
  13148. * @param property defines the propertyu to look for
  13149. * @returns null or the source animation for the given property
  13150. */
  13151. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13152. /**
  13153. * Gets the runtime animation for a specific property
  13154. * @param property defines the propertyu to look for
  13155. * @returns null or the runtime animation for the given property
  13156. */
  13157. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13158. /**
  13159. * Resets the animatable to its original state
  13160. */
  13161. reset(): void;
  13162. /**
  13163. * Allows the animatable to blend with current running animations
  13164. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13165. * @param blendingSpeed defines the blending speed to use
  13166. */
  13167. enableBlending(blendingSpeed: number): void;
  13168. /**
  13169. * Disable animation blending
  13170. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13171. */
  13172. disableBlending(): void;
  13173. /**
  13174. * Jump directly to a given frame
  13175. * @param frame defines the frame to jump to
  13176. */
  13177. goToFrame(frame: number): void;
  13178. /**
  13179. * Pause the animation
  13180. */
  13181. pause(): void;
  13182. /**
  13183. * Restart the animation
  13184. */
  13185. restart(): void;
  13186. private _raiseOnAnimationEnd;
  13187. /**
  13188. * Stop and delete the current animation
  13189. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13190. * @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)
  13191. */
  13192. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13193. /**
  13194. * Wait asynchronously for the animation to end
  13195. * @returns a promise which will be fullfilled when the animation ends
  13196. */
  13197. waitAsync(): Promise<Animatable>;
  13198. /** @hidden */
  13199. _animate(delay: number): boolean;
  13200. }
  13201. interface Scene {
  13202. /** @hidden */
  13203. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13204. /** @hidden */
  13205. _processLateAnimationBindingsForMatrices(holder: {
  13206. totalWeight: number;
  13207. animations: RuntimeAnimation[];
  13208. originalValue: Matrix;
  13209. }): any;
  13210. /** @hidden */
  13211. _processLateAnimationBindingsForQuaternions(holder: {
  13212. totalWeight: number;
  13213. animations: RuntimeAnimation[];
  13214. originalValue: Quaternion;
  13215. }, refQuaternion: Quaternion): Quaternion;
  13216. /** @hidden */
  13217. _processLateAnimationBindings(): void;
  13218. /**
  13219. * Will start the animation sequence of a given target
  13220. * @param target defines the target
  13221. * @param from defines from which frame should animation start
  13222. * @param to defines until which frame should animation run.
  13223. * @param weight defines the weight to apply to the animation (1.0 by default)
  13224. * @param loop defines if the animation loops
  13225. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13226. * @param onAnimationEnd defines the function to be executed when the animation ends
  13227. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13228. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13229. * @param onAnimationLoop defines the callback to call when an animation loops
  13230. * @returns the animatable object created for this animation
  13231. */
  13232. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13233. /**
  13234. * Will start the animation sequence of a given target
  13235. * @param target defines the target
  13236. * @param from defines from which frame should animation start
  13237. * @param to defines until which frame should animation run.
  13238. * @param loop defines if the animation loops
  13239. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13240. * @param onAnimationEnd defines the function to be executed when the animation ends
  13241. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13242. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13243. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13244. * @param onAnimationLoop defines the callback to call when an animation loops
  13245. * @returns the animatable object created for this animation
  13246. */
  13247. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13248. /**
  13249. * Will start the animation sequence of a given target and its hierarchy
  13250. * @param target defines the target
  13251. * @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.
  13252. * @param from defines from which frame should animation start
  13253. * @param to defines until which frame should animation run.
  13254. * @param loop defines if the animation loops
  13255. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13256. * @param onAnimationEnd defines the function to be executed when the animation ends
  13257. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13258. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13259. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13260. * @param onAnimationLoop defines the callback to call when an animation loops
  13261. * @returns the list of created animatables
  13262. */
  13263. 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): Animatable[];
  13264. /**
  13265. * Begin a new animation on a given node
  13266. * @param target defines the target where the animation will take place
  13267. * @param animations defines the list of animations to start
  13268. * @param from defines the initial value
  13269. * @param to defines the final value
  13270. * @param loop defines if you want animation to loop (off by default)
  13271. * @param speedRatio defines the speed ratio to apply to all animations
  13272. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13273. * @param onAnimationLoop defines the callback to call when an animation loops
  13274. * @returns the list of created animatables
  13275. */
  13276. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13277. /**
  13278. * Begin a new animation on a given node and its hierarchy
  13279. * @param target defines the root node where the animation will take place
  13280. * @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.
  13281. * @param animations defines the list of animations to start
  13282. * @param from defines the initial value
  13283. * @param to defines the final value
  13284. * @param loop defines if you want animation to loop (off by default)
  13285. * @param speedRatio defines the speed ratio to apply to all animations
  13286. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13287. * @param onAnimationLoop defines the callback to call when an animation loops
  13288. * @returns the list of animatables created for all nodes
  13289. */
  13290. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13291. /**
  13292. * Gets the animatable associated with a specific target
  13293. * @param target defines the target of the animatable
  13294. * @returns the required animatable if found
  13295. */
  13296. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13297. /**
  13298. * Gets all animatables associated with a given target
  13299. * @param target defines the target to look animatables for
  13300. * @returns an array of Animatables
  13301. */
  13302. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13303. /**
  13304. * Stops and removes all animations that have been applied to the scene
  13305. */
  13306. stopAllAnimations(): void;
  13307. /**
  13308. * Gets the current delta time used by animation engine
  13309. */
  13310. deltaTime: number;
  13311. }
  13312. interface Bone {
  13313. /**
  13314. * Copy an animation range from another bone
  13315. * @param source defines the source bone
  13316. * @param rangeName defines the range name to copy
  13317. * @param frameOffset defines the frame offset
  13318. * @param rescaleAsRequired defines if rescaling must be applied if required
  13319. * @param skelDimensionsRatio defines the scaling ratio
  13320. * @returns true if operation was successful
  13321. */
  13322. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13323. }
  13324. }
  13325. declare module BABYLON {
  13326. /**
  13327. * Class used to override all child animations of a given target
  13328. */
  13329. export class AnimationPropertiesOverride {
  13330. /**
  13331. * Gets or sets a value indicating if animation blending must be used
  13332. */
  13333. enableBlending: boolean;
  13334. /**
  13335. * Gets or sets the blending speed to use when enableBlending is true
  13336. */
  13337. blendingSpeed: number;
  13338. /**
  13339. * Gets or sets the default loop mode to use
  13340. */
  13341. loopMode: number;
  13342. }
  13343. }
  13344. declare module BABYLON {
  13345. /**
  13346. * Class used to handle skinning animations
  13347. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13348. */
  13349. export class Skeleton implements IAnimatable {
  13350. /** defines the skeleton name */
  13351. name: string;
  13352. /** defines the skeleton Id */
  13353. id: string;
  13354. /**
  13355. * Defines the list of child bones
  13356. */
  13357. bones: Bone[];
  13358. /**
  13359. * Defines an estimate of the dimension of the skeleton at rest
  13360. */
  13361. dimensionsAtRest: Vector3;
  13362. /**
  13363. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13364. */
  13365. needInitialSkinMatrix: boolean;
  13366. /**
  13367. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13368. */
  13369. overrideMesh: Nullable<AbstractMesh>;
  13370. /**
  13371. * Gets the list of animations attached to this skeleton
  13372. */
  13373. animations: Array<Animation>;
  13374. private _scene;
  13375. private _isDirty;
  13376. private _transformMatrices;
  13377. private _transformMatrixTexture;
  13378. private _meshesWithPoseMatrix;
  13379. private _animatables;
  13380. private _identity;
  13381. private _synchronizedWithMesh;
  13382. private _ranges;
  13383. private _lastAbsoluteTransformsUpdateId;
  13384. private _canUseTextureForBones;
  13385. private _uniqueId;
  13386. /** @hidden */
  13387. _numBonesWithLinkedTransformNode: number;
  13388. /** @hidden */
  13389. _hasWaitingData: Nullable<boolean>;
  13390. /**
  13391. * Specifies if the skeleton should be serialized
  13392. */
  13393. doNotSerialize: boolean;
  13394. private _useTextureToStoreBoneMatrices;
  13395. /**
  13396. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13397. * Please note that this option is not available if the hardware does not support it
  13398. */
  13399. useTextureToStoreBoneMatrices: boolean;
  13400. private _animationPropertiesOverride;
  13401. /**
  13402. * Gets or sets the animation properties override
  13403. */
  13404. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13405. /**
  13406. * List of inspectable custom properties (used by the Inspector)
  13407. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13408. */
  13409. inspectableCustomProperties: IInspectable[];
  13410. /**
  13411. * An observable triggered before computing the skeleton's matrices
  13412. */
  13413. onBeforeComputeObservable: Observable<Skeleton>;
  13414. /**
  13415. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13416. */
  13417. readonly isUsingTextureForMatrices: boolean;
  13418. /**
  13419. * Gets the unique ID of this skeleton
  13420. */
  13421. readonly uniqueId: number;
  13422. /**
  13423. * Creates a new skeleton
  13424. * @param name defines the skeleton name
  13425. * @param id defines the skeleton Id
  13426. * @param scene defines the hosting scene
  13427. */
  13428. constructor(
  13429. /** defines the skeleton name */
  13430. name: string,
  13431. /** defines the skeleton Id */
  13432. id: string, scene: Scene);
  13433. /**
  13434. * Gets the current object class name.
  13435. * @return the class name
  13436. */
  13437. getClassName(): string;
  13438. /**
  13439. * Returns an array containing the root bones
  13440. * @returns an array containing the root bones
  13441. */
  13442. getChildren(): Array<Bone>;
  13443. /**
  13444. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13445. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13446. * @returns a Float32Array containing matrices data
  13447. */
  13448. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13449. /**
  13450. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13451. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13452. * @returns a raw texture containing the data
  13453. */
  13454. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13455. /**
  13456. * Gets the current hosting scene
  13457. * @returns a scene object
  13458. */
  13459. getScene(): Scene;
  13460. /**
  13461. * Gets a string representing the current skeleton data
  13462. * @param fullDetails defines a boolean indicating if we want a verbose version
  13463. * @returns a string representing the current skeleton data
  13464. */
  13465. toString(fullDetails?: boolean): string;
  13466. /**
  13467. * Get bone's index searching by name
  13468. * @param name defines bone's name to search for
  13469. * @return the indice of the bone. Returns -1 if not found
  13470. */
  13471. getBoneIndexByName(name: string): number;
  13472. /**
  13473. * Creater a new animation range
  13474. * @param name defines the name of the range
  13475. * @param from defines the start key
  13476. * @param to defines the end key
  13477. */
  13478. createAnimationRange(name: string, from: number, to: number): void;
  13479. /**
  13480. * Delete a specific animation range
  13481. * @param name defines the name of the range
  13482. * @param deleteFrames defines if frames must be removed as well
  13483. */
  13484. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13485. /**
  13486. * Gets a specific animation range
  13487. * @param name defines the name of the range to look for
  13488. * @returns the requested animation range or null if not found
  13489. */
  13490. getAnimationRange(name: string): Nullable<AnimationRange>;
  13491. /**
  13492. * Gets the list of all animation ranges defined on this skeleton
  13493. * @returns an array
  13494. */
  13495. getAnimationRanges(): Nullable<AnimationRange>[];
  13496. /**
  13497. * Copy animation range from a source skeleton.
  13498. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13499. * @param source defines the source skeleton
  13500. * @param name defines the name of the range to copy
  13501. * @param rescaleAsRequired defines if rescaling must be applied if required
  13502. * @returns true if operation was successful
  13503. */
  13504. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13505. /**
  13506. * Forces the skeleton to go to rest pose
  13507. */
  13508. returnToRest(): void;
  13509. private _getHighestAnimationFrame;
  13510. /**
  13511. * Begin a specific animation range
  13512. * @param name defines the name of the range to start
  13513. * @param loop defines if looping must be turned on (false by default)
  13514. * @param speedRatio defines the speed ratio to apply (1 by default)
  13515. * @param onAnimationEnd defines a callback which will be called when animation will end
  13516. * @returns a new animatable
  13517. */
  13518. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13519. /** @hidden */
  13520. _markAsDirty(): void;
  13521. /** @hidden */
  13522. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13523. /** @hidden */
  13524. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13525. private _computeTransformMatrices;
  13526. /**
  13527. * Build all resources required to render a skeleton
  13528. */
  13529. prepare(): void;
  13530. /**
  13531. * Gets the list of animatables currently running for this skeleton
  13532. * @returns an array of animatables
  13533. */
  13534. getAnimatables(): IAnimatable[];
  13535. /**
  13536. * Clone the current skeleton
  13537. * @param name defines the name of the new skeleton
  13538. * @param id defines the id of the new skeleton
  13539. * @returns the new skeleton
  13540. */
  13541. clone(name: string, id?: string): Skeleton;
  13542. /**
  13543. * Enable animation blending for this skeleton
  13544. * @param blendingSpeed defines the blending speed to apply
  13545. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13546. */
  13547. enableBlending(blendingSpeed?: number): void;
  13548. /**
  13549. * Releases all resources associated with the current skeleton
  13550. */
  13551. dispose(): void;
  13552. /**
  13553. * Serialize the skeleton in a JSON object
  13554. * @returns a JSON object
  13555. */
  13556. serialize(): any;
  13557. /**
  13558. * Creates a new skeleton from serialized data
  13559. * @param parsedSkeleton defines the serialized data
  13560. * @param scene defines the hosting scene
  13561. * @returns a new skeleton
  13562. */
  13563. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13564. /**
  13565. * Compute all node absolute transforms
  13566. * @param forceUpdate defines if computation must be done even if cache is up to date
  13567. */
  13568. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13569. /**
  13570. * Gets the root pose matrix
  13571. * @returns a matrix
  13572. */
  13573. getPoseMatrix(): Nullable<Matrix>;
  13574. /**
  13575. * Sorts bones per internal index
  13576. */
  13577. sortBones(): void;
  13578. private _sortBones;
  13579. }
  13580. }
  13581. declare module BABYLON {
  13582. /**
  13583. * Class used to store bone information
  13584. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13585. */
  13586. export class Bone extends Node {
  13587. /**
  13588. * defines the bone name
  13589. */
  13590. name: string;
  13591. private static _tmpVecs;
  13592. private static _tmpQuat;
  13593. private static _tmpMats;
  13594. /**
  13595. * Gets the list of child bones
  13596. */
  13597. children: Bone[];
  13598. /** Gets the animations associated with this bone */
  13599. animations: Animation[];
  13600. /**
  13601. * Gets or sets bone length
  13602. */
  13603. length: number;
  13604. /**
  13605. * @hidden Internal only
  13606. * Set this value to map this bone to a different index in the transform matrices
  13607. * Set this value to -1 to exclude the bone from the transform matrices
  13608. */
  13609. _index: Nullable<number>;
  13610. private _skeleton;
  13611. private _localMatrix;
  13612. private _restPose;
  13613. private _baseMatrix;
  13614. private _absoluteTransform;
  13615. private _invertedAbsoluteTransform;
  13616. private _parent;
  13617. private _scalingDeterminant;
  13618. private _worldTransform;
  13619. private _localScaling;
  13620. private _localRotation;
  13621. private _localPosition;
  13622. private _needToDecompose;
  13623. private _needToCompose;
  13624. /** @hidden */
  13625. _linkedTransformNode: Nullable<TransformNode>;
  13626. /** @hidden */
  13627. _waitingTransformNodeId: Nullable<string>;
  13628. /** @hidden */
  13629. /** @hidden */
  13630. _matrix: Matrix;
  13631. /**
  13632. * Create a new bone
  13633. * @param name defines the bone name
  13634. * @param skeleton defines the parent skeleton
  13635. * @param parentBone defines the parent (can be null if the bone is the root)
  13636. * @param localMatrix defines the local matrix
  13637. * @param restPose defines the rest pose matrix
  13638. * @param baseMatrix defines the base matrix
  13639. * @param index defines index of the bone in the hiearchy
  13640. */
  13641. constructor(
  13642. /**
  13643. * defines the bone name
  13644. */
  13645. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13646. /**
  13647. * Gets the current object class name.
  13648. * @return the class name
  13649. */
  13650. getClassName(): string;
  13651. /**
  13652. * Gets the parent skeleton
  13653. * @returns a skeleton
  13654. */
  13655. getSkeleton(): Skeleton;
  13656. /**
  13657. * Gets parent bone
  13658. * @returns a bone or null if the bone is the root of the bone hierarchy
  13659. */
  13660. getParent(): Nullable<Bone>;
  13661. /**
  13662. * Returns an array containing the root bones
  13663. * @returns an array containing the root bones
  13664. */
  13665. getChildren(): Array<Bone>;
  13666. /**
  13667. * Gets the node index in matrix array generated for rendering
  13668. * @returns the node index
  13669. */
  13670. getIndex(): number;
  13671. /**
  13672. * Sets the parent bone
  13673. * @param parent defines the parent (can be null if the bone is the root)
  13674. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13675. */
  13676. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13677. /**
  13678. * Gets the local matrix
  13679. * @returns a matrix
  13680. */
  13681. getLocalMatrix(): Matrix;
  13682. /**
  13683. * Gets the base matrix (initial matrix which remains unchanged)
  13684. * @returns a matrix
  13685. */
  13686. getBaseMatrix(): Matrix;
  13687. /**
  13688. * Gets the rest pose matrix
  13689. * @returns a matrix
  13690. */
  13691. getRestPose(): Matrix;
  13692. /**
  13693. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13694. */
  13695. getWorldMatrix(): Matrix;
  13696. /**
  13697. * Sets the local matrix to rest pose matrix
  13698. */
  13699. returnToRest(): void;
  13700. /**
  13701. * Gets the inverse of the absolute transform matrix.
  13702. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13703. * @returns a matrix
  13704. */
  13705. getInvertedAbsoluteTransform(): Matrix;
  13706. /**
  13707. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13708. * @returns a matrix
  13709. */
  13710. getAbsoluteTransform(): Matrix;
  13711. /**
  13712. * Links with the given transform node.
  13713. * The local matrix of this bone is copied from the transform node every frame.
  13714. * @param transformNode defines the transform node to link to
  13715. */
  13716. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13717. /**
  13718. * Gets the node used to drive the bone's transformation
  13719. * @returns a transform node or null
  13720. */
  13721. getTransformNode(): Nullable<TransformNode>;
  13722. /** Gets or sets current position (in local space) */
  13723. position: Vector3;
  13724. /** Gets or sets current rotation (in local space) */
  13725. rotation: Vector3;
  13726. /** Gets or sets current rotation quaternion (in local space) */
  13727. rotationQuaternion: Quaternion;
  13728. /** Gets or sets current scaling (in local space) */
  13729. scaling: Vector3;
  13730. /**
  13731. * Gets the animation properties override
  13732. */
  13733. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13734. private _decompose;
  13735. private _compose;
  13736. /**
  13737. * Update the base and local matrices
  13738. * @param matrix defines the new base or local matrix
  13739. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13740. * @param updateLocalMatrix defines if the local matrix should be updated
  13741. */
  13742. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13743. /** @hidden */
  13744. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13745. /**
  13746. * Flag the bone as dirty (Forcing it to update everything)
  13747. */
  13748. markAsDirty(): void;
  13749. /** @hidden */
  13750. _markAsDirtyAndCompose(): void;
  13751. private _markAsDirtyAndDecompose;
  13752. /**
  13753. * Translate the bone in local or world space
  13754. * @param vec The amount to translate the bone
  13755. * @param space The space that the translation is in
  13756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13757. */
  13758. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13759. /**
  13760. * Set the postion of the bone in local or world space
  13761. * @param position The position to set the bone
  13762. * @param space The space that the position is in
  13763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13764. */
  13765. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13766. /**
  13767. * Set the absolute position of the bone (world space)
  13768. * @param position The position to set the bone
  13769. * @param mesh The mesh that this bone is attached to
  13770. */
  13771. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13772. /**
  13773. * Scale the bone on the x, y and z axes (in local space)
  13774. * @param x The amount to scale the bone on the x axis
  13775. * @param y The amount to scale the bone on the y axis
  13776. * @param z The amount to scale the bone on the z axis
  13777. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13778. */
  13779. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13780. /**
  13781. * Set the bone scaling in local space
  13782. * @param scale defines the scaling vector
  13783. */
  13784. setScale(scale: Vector3): void;
  13785. /**
  13786. * Gets the current scaling in local space
  13787. * @returns the current scaling vector
  13788. */
  13789. getScale(): Vector3;
  13790. /**
  13791. * Gets the current scaling in local space and stores it in a target vector
  13792. * @param result defines the target vector
  13793. */
  13794. getScaleToRef(result: Vector3): void;
  13795. /**
  13796. * Set the yaw, pitch, and roll of the bone in local or world space
  13797. * @param yaw The rotation of the bone on the y axis
  13798. * @param pitch The rotation of the bone on the x axis
  13799. * @param roll The rotation of the bone on the z axis
  13800. * @param space The space that the axes of rotation are in
  13801. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13802. */
  13803. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13804. /**
  13805. * Add a rotation to the bone on an axis in local or world space
  13806. * @param axis The axis to rotate the bone on
  13807. * @param amount The amount to rotate the bone
  13808. * @param space The space that the axis is in
  13809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13810. */
  13811. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13812. /**
  13813. * Set the rotation of the bone to a particular axis angle in local or world space
  13814. * @param axis The axis to rotate the bone on
  13815. * @param angle The angle that the bone should be rotated to
  13816. * @param space The space that the axis is in
  13817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13818. */
  13819. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13820. /**
  13821. * Set the euler rotation of the bone in local of world space
  13822. * @param rotation The euler rotation that the bone should be set to
  13823. * @param space The space that the rotation is in
  13824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13825. */
  13826. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13827. /**
  13828. * Set the quaternion rotation of the bone in local of world space
  13829. * @param quat The quaternion rotation that the bone should be set to
  13830. * @param space The space that the rotation is in
  13831. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13832. */
  13833. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13834. /**
  13835. * Set the rotation matrix of the bone in local of world space
  13836. * @param rotMat The rotation matrix that the bone should be set to
  13837. * @param space The space that the rotation is in
  13838. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13839. */
  13840. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13841. private _rotateWithMatrix;
  13842. private _getNegativeRotationToRef;
  13843. /**
  13844. * Get the position of the bone in local or world space
  13845. * @param space The space that the returned position is in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. * @returns The position of the bone
  13848. */
  13849. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13850. /**
  13851. * Copy the position of the bone to a vector3 in local or world space
  13852. * @param space The space that the returned position is in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. * @param result The vector3 to copy the position to
  13855. */
  13856. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13857. /**
  13858. * Get the absolute position of the bone (world space)
  13859. * @param mesh The mesh that this bone is attached to
  13860. * @returns The absolute position of the bone
  13861. */
  13862. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13863. /**
  13864. * Copy the absolute position of the bone (world space) to the result param
  13865. * @param mesh The mesh that this bone is attached to
  13866. * @param result The vector3 to copy the absolute position to
  13867. */
  13868. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13869. /**
  13870. * Compute the absolute transforms of this bone and its children
  13871. */
  13872. computeAbsoluteTransforms(): void;
  13873. /**
  13874. * Get the world direction from an axis that is in the local space of the bone
  13875. * @param localAxis The local direction that is used to compute the world direction
  13876. * @param mesh The mesh that this bone is attached to
  13877. * @returns The world direction
  13878. */
  13879. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13880. /**
  13881. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13882. * @param localAxis The local direction that is used to compute the world direction
  13883. * @param mesh The mesh that this bone is attached to
  13884. * @param result The vector3 that the world direction will be copied to
  13885. */
  13886. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13887. /**
  13888. * Get the euler rotation of the bone in local or world space
  13889. * @param space The space that the rotation should be in
  13890. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13891. * @returns The euler rotation
  13892. */
  13893. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13894. /**
  13895. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13896. * @param space The space that the rotation should be in
  13897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13898. * @param result The vector3 that the rotation should be copied to
  13899. */
  13900. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13901. /**
  13902. * Get the quaternion rotation of the bone in either local or world space
  13903. * @param space The space that the rotation should be in
  13904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13905. * @returns The quaternion rotation
  13906. */
  13907. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13908. /**
  13909. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13910. * @param space The space that the rotation should be in
  13911. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13912. * @param result The quaternion that the rotation should be copied to
  13913. */
  13914. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13915. /**
  13916. * Get the rotation matrix of the bone in local or world space
  13917. * @param space The space that the rotation should be in
  13918. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13919. * @returns The rotation matrix
  13920. */
  13921. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13922. /**
  13923. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13924. * @param space The space that the rotation should be in
  13925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13926. * @param result The quaternion that the rotation should be copied to
  13927. */
  13928. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13929. /**
  13930. * Get the world position of a point that is in the local space of the bone
  13931. * @param position The local position
  13932. * @param mesh The mesh that this bone is attached to
  13933. * @returns The world position
  13934. */
  13935. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13936. /**
  13937. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13938. * @param position The local position
  13939. * @param mesh The mesh that this bone is attached to
  13940. * @param result The vector3 that the world position should be copied to
  13941. */
  13942. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13943. /**
  13944. * Get the local position of a point that is in world space
  13945. * @param position The world position
  13946. * @param mesh The mesh that this bone is attached to
  13947. * @returns The local position
  13948. */
  13949. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13950. /**
  13951. * Get the local position of a point that is in world space and copy it to the result param
  13952. * @param position The world position
  13953. * @param mesh The mesh that this bone is attached to
  13954. * @param result The vector3 that the local position should be copied to
  13955. */
  13956. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13957. }
  13958. }
  13959. declare module BABYLON {
  13960. /**
  13961. * 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.
  13962. * @see https://doc.babylonjs.com/how_to/transformnode
  13963. */
  13964. export class TransformNode extends Node {
  13965. /**
  13966. * Object will not rotate to face the camera
  13967. */
  13968. static BILLBOARDMODE_NONE: number;
  13969. /**
  13970. * Object will rotate to face the camera but only on the x axis
  13971. */
  13972. static BILLBOARDMODE_X: number;
  13973. /**
  13974. * Object will rotate to face the camera but only on the y axis
  13975. */
  13976. static BILLBOARDMODE_Y: number;
  13977. /**
  13978. * Object will rotate to face the camera but only on the z axis
  13979. */
  13980. static BILLBOARDMODE_Z: number;
  13981. /**
  13982. * Object will rotate to face the camera
  13983. */
  13984. static BILLBOARDMODE_ALL: number;
  13985. /**
  13986. * Object will rotate to face the camera's position instead of orientation
  13987. */
  13988. static BILLBOARDMODE_USE_POSITION: number;
  13989. private _forward;
  13990. private _forwardInverted;
  13991. private _up;
  13992. private _right;
  13993. private _rightInverted;
  13994. private _position;
  13995. private _rotation;
  13996. private _rotationQuaternion;
  13997. protected _scaling: Vector3;
  13998. protected _isDirty: boolean;
  13999. private _transformToBoneReferal;
  14000. private _isAbsoluteSynced;
  14001. private _billboardMode;
  14002. /**
  14003. * Gets or sets the billboard mode. Default is 0.
  14004. *
  14005. * | Value | Type | Description |
  14006. * | --- | --- | --- |
  14007. * | 0 | BILLBOARDMODE_NONE | |
  14008. * | 1 | BILLBOARDMODE_X | |
  14009. * | 2 | BILLBOARDMODE_Y | |
  14010. * | 4 | BILLBOARDMODE_Z | |
  14011. * | 7 | BILLBOARDMODE_ALL | |
  14012. *
  14013. */
  14014. billboardMode: number;
  14015. private _preserveParentRotationForBillboard;
  14016. /**
  14017. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14018. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14019. */
  14020. preserveParentRotationForBillboard: boolean;
  14021. /**
  14022. * 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
  14023. */
  14024. scalingDeterminant: number;
  14025. private _infiniteDistance;
  14026. /**
  14027. * Gets or sets the distance of the object to max, often used by skybox
  14028. */
  14029. infiniteDistance: boolean;
  14030. /**
  14031. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14032. * By default the system will update normals to compensate
  14033. */
  14034. ignoreNonUniformScaling: boolean;
  14035. /**
  14036. * 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
  14037. */
  14038. reIntegrateRotationIntoRotationQuaternion: boolean;
  14039. /** @hidden */
  14040. _poseMatrix: Nullable<Matrix>;
  14041. /** @hidden */
  14042. _localMatrix: Matrix;
  14043. private _usePivotMatrix;
  14044. private _absolutePosition;
  14045. private _absoluteScaling;
  14046. private _absoluteRotationQuaternion;
  14047. private _pivotMatrix;
  14048. private _pivotMatrixInverse;
  14049. protected _postMultiplyPivotMatrix: boolean;
  14050. protected _isWorldMatrixFrozen: boolean;
  14051. /** @hidden */
  14052. _indexInSceneTransformNodesArray: number;
  14053. /**
  14054. * An event triggered after the world matrix is updated
  14055. */
  14056. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14057. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14058. /**
  14059. * Gets a string identifying the name of the class
  14060. * @returns "TransformNode" string
  14061. */
  14062. getClassName(): string;
  14063. /**
  14064. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14065. */
  14066. position: Vector3;
  14067. /**
  14068. * 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)).
  14069. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14070. */
  14071. rotation: Vector3;
  14072. /**
  14073. * 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)).
  14074. */
  14075. scaling: Vector3;
  14076. /**
  14077. * 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).
  14078. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14079. */
  14080. rotationQuaternion: Nullable<Quaternion>;
  14081. /**
  14082. * The forward direction of that transform in world space.
  14083. */
  14084. readonly forward: Vector3;
  14085. /**
  14086. * The up direction of that transform in world space.
  14087. */
  14088. readonly up: Vector3;
  14089. /**
  14090. * The right direction of that transform in world space.
  14091. */
  14092. readonly right: Vector3;
  14093. /**
  14094. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14095. * @param matrix the matrix to copy the pose from
  14096. * @returns this TransformNode.
  14097. */
  14098. updatePoseMatrix(matrix: Matrix): TransformNode;
  14099. /**
  14100. * Returns the mesh Pose matrix.
  14101. * @returns the pose matrix
  14102. */
  14103. getPoseMatrix(): Matrix;
  14104. /** @hidden */
  14105. _isSynchronized(): boolean;
  14106. /** @hidden */
  14107. _initCache(): void;
  14108. /**
  14109. * Flag the transform node as dirty (Forcing it to update everything)
  14110. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14111. * @returns this transform node
  14112. */
  14113. markAsDirty(property: string): TransformNode;
  14114. /**
  14115. * Returns the current mesh absolute position.
  14116. * Returns a Vector3.
  14117. */
  14118. readonly absolutePosition: Vector3;
  14119. /**
  14120. * Returns the current mesh absolute scaling.
  14121. * Returns a Vector3.
  14122. */
  14123. readonly absoluteScaling: Vector3;
  14124. /**
  14125. * Returns the current mesh absolute rotation.
  14126. * Returns a Quaternion.
  14127. */
  14128. readonly absoluteRotationQuaternion: Quaternion;
  14129. /**
  14130. * Sets a new matrix to apply before all other transformation
  14131. * @param matrix defines the transform matrix
  14132. * @returns the current TransformNode
  14133. */
  14134. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14135. /**
  14136. * Sets a new pivot matrix to the current node
  14137. * @param matrix defines the new pivot matrix to use
  14138. * @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
  14139. * @returns the current TransformNode
  14140. */
  14141. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14142. /**
  14143. * Returns the mesh pivot matrix.
  14144. * Default : Identity.
  14145. * @returns the matrix
  14146. */
  14147. getPivotMatrix(): Matrix;
  14148. /**
  14149. * Instantiate (when possible) or clone that node with its hierarchy
  14150. * @param newParent defines the new parent to use for the instance (or clone)
  14151. * @param options defines options to configure how copy is done
  14152. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14153. * @returns an instance (or a clone) of the current node with its hiearchy
  14154. */
  14155. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14156. doNotInstantiate: boolean;
  14157. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14158. /**
  14159. * Prevents the World matrix to be computed any longer
  14160. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14161. * @returns the TransformNode.
  14162. */
  14163. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14164. /**
  14165. * Allows back the World matrix computation.
  14166. * @returns the TransformNode.
  14167. */
  14168. unfreezeWorldMatrix(): this;
  14169. /**
  14170. * True if the World matrix has been frozen.
  14171. */
  14172. readonly isWorldMatrixFrozen: boolean;
  14173. /**
  14174. * Retuns the mesh absolute position in the World.
  14175. * @returns a Vector3.
  14176. */
  14177. getAbsolutePosition(): Vector3;
  14178. /**
  14179. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14180. * @param absolutePosition the absolute position to set
  14181. * @returns the TransformNode.
  14182. */
  14183. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14184. /**
  14185. * Sets the mesh position in its local space.
  14186. * @param vector3 the position to set in localspace
  14187. * @returns the TransformNode.
  14188. */
  14189. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14190. /**
  14191. * Returns the mesh position in the local space from the current World matrix values.
  14192. * @returns a new Vector3.
  14193. */
  14194. getPositionExpressedInLocalSpace(): Vector3;
  14195. /**
  14196. * Translates the mesh along the passed Vector3 in its local space.
  14197. * @param vector3 the distance to translate in localspace
  14198. * @returns the TransformNode.
  14199. */
  14200. locallyTranslate(vector3: Vector3): TransformNode;
  14201. private static _lookAtVectorCache;
  14202. /**
  14203. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14204. * @param targetPoint the position (must be in same space as current mesh) to look at
  14205. * @param yawCor optional yaw (y-axis) correction in radians
  14206. * @param pitchCor optional pitch (x-axis) correction in radians
  14207. * @param rollCor optional roll (z-axis) correction in radians
  14208. * @param space the choosen space of the target
  14209. * @returns the TransformNode.
  14210. */
  14211. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14212. /**
  14213. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14214. * This Vector3 is expressed in the World space.
  14215. * @param localAxis axis to rotate
  14216. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14217. */
  14218. getDirection(localAxis: Vector3): Vector3;
  14219. /**
  14220. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14221. * localAxis is expressed in the mesh local space.
  14222. * result is computed in the Wordl space from the mesh World matrix.
  14223. * @param localAxis axis to rotate
  14224. * @param result the resulting transformnode
  14225. * @returns this TransformNode.
  14226. */
  14227. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14228. /**
  14229. * Sets this transform node rotation to the given local axis.
  14230. * @param localAxis the axis in local space
  14231. * @param yawCor optional yaw (y-axis) correction in radians
  14232. * @param pitchCor optional pitch (x-axis) correction in radians
  14233. * @param rollCor optional roll (z-axis) correction in radians
  14234. * @returns this TransformNode
  14235. */
  14236. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14237. /**
  14238. * Sets a new pivot point to the current node
  14239. * @param point defines the new pivot point to use
  14240. * @param space defines if the point is in world or local space (local by default)
  14241. * @returns the current TransformNode
  14242. */
  14243. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14244. /**
  14245. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14246. * @returns the pivot point
  14247. */
  14248. getPivotPoint(): Vector3;
  14249. /**
  14250. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14251. * @param result the vector3 to store the result
  14252. * @returns this TransformNode.
  14253. */
  14254. getPivotPointToRef(result: Vector3): TransformNode;
  14255. /**
  14256. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14257. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14258. */
  14259. getAbsolutePivotPoint(): Vector3;
  14260. /**
  14261. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14262. * @param result vector3 to store the result
  14263. * @returns this TransformNode.
  14264. */
  14265. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14266. /**
  14267. * Defines the passed node as the parent of the current node.
  14268. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14269. * @see https://doc.babylonjs.com/how_to/parenting
  14270. * @param node the node ot set as the parent
  14271. * @returns this TransformNode.
  14272. */
  14273. setParent(node: Nullable<Node>): TransformNode;
  14274. private _nonUniformScaling;
  14275. /**
  14276. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14277. */
  14278. readonly nonUniformScaling: boolean;
  14279. /** @hidden */
  14280. _updateNonUniformScalingState(value: boolean): boolean;
  14281. /**
  14282. * Attach the current TransformNode to another TransformNode associated with a bone
  14283. * @param bone Bone affecting the TransformNode
  14284. * @param affectedTransformNode TransformNode associated with the bone
  14285. * @returns this object
  14286. */
  14287. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14288. /**
  14289. * Detach the transform node if its associated with a bone
  14290. * @returns this object
  14291. */
  14292. detachFromBone(): TransformNode;
  14293. private static _rotationAxisCache;
  14294. /**
  14295. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14296. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14297. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14298. * The passed axis is also normalized.
  14299. * @param axis the axis to rotate around
  14300. * @param amount the amount to rotate in radians
  14301. * @param space Space to rotate in (Default: local)
  14302. * @returns the TransformNode.
  14303. */
  14304. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14305. /**
  14306. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14307. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14308. * The passed axis is also normalized. .
  14309. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14310. * @param point the point to rotate around
  14311. * @param axis the axis to rotate around
  14312. * @param amount the amount to rotate in radians
  14313. * @returns the TransformNode
  14314. */
  14315. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14316. /**
  14317. * Translates the mesh along the axis vector for the passed distance in the given space.
  14318. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14319. * @param axis the axis to translate in
  14320. * @param distance the distance to translate
  14321. * @param space Space to rotate in (Default: local)
  14322. * @returns the TransformNode.
  14323. */
  14324. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14325. /**
  14326. * Adds a rotation step to the mesh current rotation.
  14327. * x, y, z are Euler angles expressed in radians.
  14328. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14329. * This means this rotation is made in the mesh local space only.
  14330. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14331. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14332. * ```javascript
  14333. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14334. * ```
  14335. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14336. * 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.
  14337. * @param x Rotation to add
  14338. * @param y Rotation to add
  14339. * @param z Rotation to add
  14340. * @returns the TransformNode.
  14341. */
  14342. addRotation(x: number, y: number, z: number): TransformNode;
  14343. /**
  14344. * @hidden
  14345. */
  14346. protected _getEffectiveParent(): Nullable<Node>;
  14347. /**
  14348. * Computes the world matrix of the node
  14349. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14350. * @returns the world matrix
  14351. */
  14352. computeWorldMatrix(force?: boolean): Matrix;
  14353. protected _afterComputeWorldMatrix(): void;
  14354. /**
  14355. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14356. * @param func callback function to add
  14357. *
  14358. * @returns the TransformNode.
  14359. */
  14360. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14361. /**
  14362. * Removes a registered callback function.
  14363. * @param func callback function to remove
  14364. * @returns the TransformNode.
  14365. */
  14366. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14367. /**
  14368. * Gets the position of the current mesh in camera space
  14369. * @param camera defines the camera to use
  14370. * @returns a position
  14371. */
  14372. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14373. /**
  14374. * Returns the distance from the mesh to the active camera
  14375. * @param camera defines the camera to use
  14376. * @returns the distance
  14377. */
  14378. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14379. /**
  14380. * Clone the current transform node
  14381. * @param name Name of the new clone
  14382. * @param newParent New parent for the clone
  14383. * @param doNotCloneChildren Do not clone children hierarchy
  14384. * @returns the new transform node
  14385. */
  14386. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14387. /**
  14388. * Serializes the objects information.
  14389. * @param currentSerializationObject defines the object to serialize in
  14390. * @returns the serialized object
  14391. */
  14392. serialize(currentSerializationObject?: any): any;
  14393. /**
  14394. * Returns a new TransformNode object parsed from the source provided.
  14395. * @param parsedTransformNode is the source.
  14396. * @param scene the scne the object belongs to
  14397. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14398. * @returns a new TransformNode object parsed from the source provided.
  14399. */
  14400. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14401. /**
  14402. * Get all child-transformNodes of this node
  14403. * @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
  14404. * @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
  14405. * @returns an array of TransformNode
  14406. */
  14407. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14408. /**
  14409. * Releases resources associated with this transform node.
  14410. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14411. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14412. */
  14413. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14414. /**
  14415. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14416. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14417. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14418. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14419. * @returns the current mesh
  14420. */
  14421. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14422. private _syncAbsoluteScalingAndRotation;
  14423. }
  14424. }
  14425. declare module BABYLON {
  14426. /**
  14427. * Defines the types of pose enabled controllers that are supported
  14428. */
  14429. export enum PoseEnabledControllerType {
  14430. /**
  14431. * HTC Vive
  14432. */
  14433. VIVE = 0,
  14434. /**
  14435. * Oculus Rift
  14436. */
  14437. OCULUS = 1,
  14438. /**
  14439. * Windows mixed reality
  14440. */
  14441. WINDOWS = 2,
  14442. /**
  14443. * Samsung gear VR
  14444. */
  14445. GEAR_VR = 3,
  14446. /**
  14447. * Google Daydream
  14448. */
  14449. DAYDREAM = 4,
  14450. /**
  14451. * Generic
  14452. */
  14453. GENERIC = 5
  14454. }
  14455. /**
  14456. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14457. */
  14458. export interface MutableGamepadButton {
  14459. /**
  14460. * Value of the button/trigger
  14461. */
  14462. value: number;
  14463. /**
  14464. * If the button/trigger is currently touched
  14465. */
  14466. touched: boolean;
  14467. /**
  14468. * If the button/trigger is currently pressed
  14469. */
  14470. pressed: boolean;
  14471. }
  14472. /**
  14473. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14474. * @hidden
  14475. */
  14476. export interface ExtendedGamepadButton extends GamepadButton {
  14477. /**
  14478. * If the button/trigger is currently pressed
  14479. */
  14480. readonly pressed: boolean;
  14481. /**
  14482. * If the button/trigger is currently touched
  14483. */
  14484. readonly touched: boolean;
  14485. /**
  14486. * Value of the button/trigger
  14487. */
  14488. readonly value: number;
  14489. }
  14490. /** @hidden */
  14491. export interface _GamePadFactory {
  14492. /**
  14493. * Returns wether or not the current gamepad can be created for this type of controller.
  14494. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14495. * @returns true if it can be created, otherwise false
  14496. */
  14497. canCreate(gamepadInfo: any): boolean;
  14498. /**
  14499. * Creates a new instance of the Gamepad.
  14500. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14501. * @returns the new gamepad instance
  14502. */
  14503. create(gamepadInfo: any): Gamepad;
  14504. }
  14505. /**
  14506. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14507. */
  14508. export class PoseEnabledControllerHelper {
  14509. /** @hidden */
  14510. static _ControllerFactories: _GamePadFactory[];
  14511. /** @hidden */
  14512. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14513. /**
  14514. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14515. * @param vrGamepad the gamepad to initialized
  14516. * @returns a vr controller of the type the gamepad identified as
  14517. */
  14518. static InitiateController(vrGamepad: any): Gamepad;
  14519. }
  14520. /**
  14521. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14522. */
  14523. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14524. /**
  14525. * If the controller is used in a webXR session
  14526. */
  14527. isXR: boolean;
  14528. private _deviceRoomPosition;
  14529. private _deviceRoomRotationQuaternion;
  14530. /**
  14531. * The device position in babylon space
  14532. */
  14533. devicePosition: Vector3;
  14534. /**
  14535. * The device rotation in babylon space
  14536. */
  14537. deviceRotationQuaternion: Quaternion;
  14538. /**
  14539. * The scale factor of the device in babylon space
  14540. */
  14541. deviceScaleFactor: number;
  14542. /**
  14543. * (Likely devicePosition should be used instead) The device position in its room space
  14544. */
  14545. position: Vector3;
  14546. /**
  14547. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14548. */
  14549. rotationQuaternion: Quaternion;
  14550. /**
  14551. * The type of controller (Eg. Windows mixed reality)
  14552. */
  14553. controllerType: PoseEnabledControllerType;
  14554. protected _calculatedPosition: Vector3;
  14555. private _calculatedRotation;
  14556. /**
  14557. * The raw pose from the device
  14558. */
  14559. rawPose: DevicePose;
  14560. private _trackPosition;
  14561. private _maxRotationDistFromHeadset;
  14562. private _draggedRoomRotation;
  14563. /**
  14564. * @hidden
  14565. */
  14566. _disableTrackPosition(fixedPosition: Vector3): void;
  14567. /**
  14568. * Internal, the mesh attached to the controller
  14569. * @hidden
  14570. */
  14571. _mesh: Nullable<AbstractMesh>;
  14572. private _poseControlledCamera;
  14573. private _leftHandSystemQuaternion;
  14574. /**
  14575. * Internal, matrix used to convert room space to babylon space
  14576. * @hidden
  14577. */
  14578. _deviceToWorld: Matrix;
  14579. /**
  14580. * Node to be used when casting a ray from the controller
  14581. * @hidden
  14582. */
  14583. _pointingPoseNode: Nullable<TransformNode>;
  14584. /**
  14585. * Name of the child mesh that can be used to cast a ray from the controller
  14586. */
  14587. static readonly POINTING_POSE: string;
  14588. /**
  14589. * Creates a new PoseEnabledController from a gamepad
  14590. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14591. */
  14592. constructor(browserGamepad: any);
  14593. private _workingMatrix;
  14594. /**
  14595. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14596. */
  14597. update(): void;
  14598. /**
  14599. * Updates only the pose device and mesh without doing any button event checking
  14600. */
  14601. protected _updatePoseAndMesh(): void;
  14602. /**
  14603. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14604. * @param poseData raw pose fromthe device
  14605. */
  14606. updateFromDevice(poseData: DevicePose): void;
  14607. /**
  14608. * @hidden
  14609. */
  14610. _meshAttachedObservable: Observable<AbstractMesh>;
  14611. /**
  14612. * Attaches a mesh to the controller
  14613. * @param mesh the mesh to be attached
  14614. */
  14615. attachToMesh(mesh: AbstractMesh): void;
  14616. /**
  14617. * Attaches the controllers mesh to a camera
  14618. * @param camera the camera the mesh should be attached to
  14619. */
  14620. attachToPoseControlledCamera(camera: TargetCamera): void;
  14621. /**
  14622. * Disposes of the controller
  14623. */
  14624. dispose(): void;
  14625. /**
  14626. * The mesh that is attached to the controller
  14627. */
  14628. readonly mesh: Nullable<AbstractMesh>;
  14629. /**
  14630. * Gets the ray of the controller in the direction the controller is pointing
  14631. * @param length the length the resulting ray should be
  14632. * @returns a ray in the direction the controller is pointing
  14633. */
  14634. getForwardRay(length?: number): Ray;
  14635. }
  14636. }
  14637. declare module BABYLON {
  14638. /**
  14639. * Defines the WebVRController object that represents controllers tracked in 3D space
  14640. */
  14641. export abstract class WebVRController extends PoseEnabledController {
  14642. /**
  14643. * Internal, the default controller model for the controller
  14644. */
  14645. protected _defaultModel: Nullable<AbstractMesh>;
  14646. /**
  14647. * Fired when the trigger state has changed
  14648. */
  14649. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14650. /**
  14651. * Fired when the main button state has changed
  14652. */
  14653. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14654. /**
  14655. * Fired when the secondary button state has changed
  14656. */
  14657. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14658. /**
  14659. * Fired when the pad state has changed
  14660. */
  14661. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14662. /**
  14663. * Fired when controllers stick values have changed
  14664. */
  14665. onPadValuesChangedObservable: Observable<StickValues>;
  14666. /**
  14667. * Array of button availible on the controller
  14668. */
  14669. protected _buttons: Array<MutableGamepadButton>;
  14670. private _onButtonStateChange;
  14671. /**
  14672. * Fired when a controller button's state has changed
  14673. * @param callback the callback containing the button that was modified
  14674. */
  14675. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14676. /**
  14677. * X and Y axis corresponding to the controllers joystick
  14678. */
  14679. pad: StickValues;
  14680. /**
  14681. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14682. */
  14683. hand: string;
  14684. /**
  14685. * The default controller model for the controller
  14686. */
  14687. readonly defaultModel: Nullable<AbstractMesh>;
  14688. /**
  14689. * Creates a new WebVRController from a gamepad
  14690. * @param vrGamepad the gamepad that the WebVRController should be created from
  14691. */
  14692. constructor(vrGamepad: any);
  14693. /**
  14694. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14695. */
  14696. update(): void;
  14697. /**
  14698. * Function to be called when a button is modified
  14699. */
  14700. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14701. /**
  14702. * Loads a mesh and attaches it to the controller
  14703. * @param scene the scene the mesh should be added to
  14704. * @param meshLoaded callback for when the mesh has been loaded
  14705. */
  14706. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14707. private _setButtonValue;
  14708. private _changes;
  14709. private _checkChanges;
  14710. /**
  14711. * Disposes of th webVRCOntroller
  14712. */
  14713. dispose(): void;
  14714. }
  14715. }
  14716. declare module BABYLON {
  14717. /**
  14718. * The HemisphericLight simulates the ambient environment light,
  14719. * so the passed direction is the light reflection direction, not the incoming direction.
  14720. */
  14721. export class HemisphericLight extends Light {
  14722. /**
  14723. * The groundColor is the light in the opposite direction to the one specified during creation.
  14724. * 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.
  14725. */
  14726. groundColor: Color3;
  14727. /**
  14728. * The light reflection direction, not the incoming direction.
  14729. */
  14730. direction: Vector3;
  14731. /**
  14732. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14733. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14734. * The HemisphericLight can't cast shadows.
  14735. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14736. * @param name The friendly name of the light
  14737. * @param direction The direction of the light reflection
  14738. * @param scene The scene the light belongs to
  14739. */
  14740. constructor(name: string, direction: Vector3, scene: Scene);
  14741. protected _buildUniformLayout(): void;
  14742. /**
  14743. * Returns the string "HemisphericLight".
  14744. * @return The class name
  14745. */
  14746. getClassName(): string;
  14747. /**
  14748. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14749. * Returns the updated direction.
  14750. * @param target The target the direction should point to
  14751. * @return The computed direction
  14752. */
  14753. setDirectionToTarget(target: Vector3): Vector3;
  14754. /**
  14755. * Returns the shadow generator associated to the light.
  14756. * @returns Always null for hemispheric lights because it does not support shadows.
  14757. */
  14758. getShadowGenerator(): Nullable<IShadowGenerator>;
  14759. /**
  14760. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14761. * @param effect The effect to update
  14762. * @param lightIndex The index of the light in the effect to update
  14763. * @returns The hemispheric light
  14764. */
  14765. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14766. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14767. /**
  14768. * Computes the world matrix of the node
  14769. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14770. * @param useWasUpdatedFlag defines a reserved property
  14771. * @returns the world matrix
  14772. */
  14773. computeWorldMatrix(): Matrix;
  14774. /**
  14775. * Returns the integer 3.
  14776. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14777. */
  14778. getTypeID(): number;
  14779. /**
  14780. * Prepares the list of defines specific to the light type.
  14781. * @param defines the list of defines
  14782. * @param lightIndex defines the index of the light for the effect
  14783. */
  14784. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14785. }
  14786. }
  14787. declare module BABYLON {
  14788. /** @hidden */
  14789. export var vrMultiviewToSingleviewPixelShader: {
  14790. name: string;
  14791. shader: string;
  14792. };
  14793. }
  14794. declare module BABYLON {
  14795. /**
  14796. * Renders to multiple views with a single draw call
  14797. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14798. */
  14799. export class MultiviewRenderTarget extends RenderTargetTexture {
  14800. /**
  14801. * Creates a multiview render target
  14802. * @param scene scene used with the render target
  14803. * @param size the size of the render target (used for each view)
  14804. */
  14805. constructor(scene: Scene, size?: number | {
  14806. width: number;
  14807. height: number;
  14808. } | {
  14809. ratio: number;
  14810. });
  14811. /**
  14812. * @hidden
  14813. * @param faceIndex the face index, if its a cube texture
  14814. */
  14815. _bindFrameBuffer(faceIndex?: number): void;
  14816. /**
  14817. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14818. * @returns the view count
  14819. */
  14820. getViewCount(): number;
  14821. }
  14822. }
  14823. declare module BABYLON {
  14824. /**
  14825. * Represents a camera frustum
  14826. */
  14827. export class Frustum {
  14828. /**
  14829. * Gets the planes representing the frustum
  14830. * @param transform matrix to be applied to the returned planes
  14831. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14832. */
  14833. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14834. /**
  14835. * Gets the near frustum plane transformed by the transform matrix
  14836. * @param transform transformation matrix to be applied to the resulting frustum plane
  14837. * @param frustumPlane the resuling frustum plane
  14838. */
  14839. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14840. /**
  14841. * Gets the far frustum plane transformed by the transform matrix
  14842. * @param transform transformation matrix to be applied to the resulting frustum plane
  14843. * @param frustumPlane the resuling frustum plane
  14844. */
  14845. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14846. /**
  14847. * Gets the left frustum plane transformed by the transform matrix
  14848. * @param transform transformation matrix to be applied to the resulting frustum plane
  14849. * @param frustumPlane the resuling frustum plane
  14850. */
  14851. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14852. /**
  14853. * Gets the right frustum plane transformed by the transform matrix
  14854. * @param transform transformation matrix to be applied to the resulting frustum plane
  14855. * @param frustumPlane the resuling frustum plane
  14856. */
  14857. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14858. /**
  14859. * Gets the top frustum plane transformed by the transform matrix
  14860. * @param transform transformation matrix to be applied to the resulting frustum plane
  14861. * @param frustumPlane the resuling frustum plane
  14862. */
  14863. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14864. /**
  14865. * Gets the bottom frustum plane transformed by the transform matrix
  14866. * @param transform transformation matrix to be applied to the resulting frustum plane
  14867. * @param frustumPlane the resuling frustum plane
  14868. */
  14869. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14870. /**
  14871. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14872. * @param transform transformation matrix to be applied to the resulting frustum planes
  14873. * @param frustumPlanes the resuling frustum planes
  14874. */
  14875. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14876. }
  14877. }
  14878. declare module BABYLON {
  14879. interface Engine {
  14880. /**
  14881. * Creates a new multiview render target
  14882. * @param width defines the width of the texture
  14883. * @param height defines the height of the texture
  14884. * @returns the created multiview texture
  14885. */
  14886. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14887. /**
  14888. * Binds a multiview framebuffer to be drawn to
  14889. * @param multiviewTexture texture to bind
  14890. */
  14891. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14892. }
  14893. interface Camera {
  14894. /**
  14895. * @hidden
  14896. * 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)
  14897. */
  14898. _useMultiviewToSingleView: boolean;
  14899. /**
  14900. * @hidden
  14901. * 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)
  14902. */
  14903. _multiviewTexture: Nullable<RenderTargetTexture>;
  14904. /**
  14905. * @hidden
  14906. * ensures the multiview texture of the camera exists and has the specified width/height
  14907. * @param width height to set on the multiview texture
  14908. * @param height width to set on the multiview texture
  14909. */
  14910. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14911. }
  14912. interface Scene {
  14913. /** @hidden */
  14914. _transformMatrixR: Matrix;
  14915. /** @hidden */
  14916. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14917. /** @hidden */
  14918. _createMultiviewUbo(): void;
  14919. /** @hidden */
  14920. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14921. /** @hidden */
  14922. _renderMultiviewToSingleView(camera: Camera): void;
  14923. }
  14924. }
  14925. declare module BABYLON {
  14926. /**
  14927. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14928. * This will not be used for webXR as it supports displaying texture arrays directly
  14929. */
  14930. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14931. /**
  14932. * Initializes a VRMultiviewToSingleview
  14933. * @param name name of the post process
  14934. * @param camera camera to be applied to
  14935. * @param scaleFactor scaling factor to the size of the output texture
  14936. */
  14937. constructor(name: string, camera: Camera, scaleFactor: number);
  14938. }
  14939. }
  14940. declare module BABYLON {
  14941. /**
  14942. * Interface used to define additional presentation attributes
  14943. */
  14944. export interface IVRPresentationAttributes {
  14945. /**
  14946. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  14947. */
  14948. highRefreshRate: boolean;
  14949. /**
  14950. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  14951. */
  14952. foveationLevel: number;
  14953. }
  14954. interface Engine {
  14955. /** @hidden */
  14956. _vrDisplay: any;
  14957. /** @hidden */
  14958. _vrSupported: boolean;
  14959. /** @hidden */
  14960. _oldSize: Size;
  14961. /** @hidden */
  14962. _oldHardwareScaleFactor: number;
  14963. /** @hidden */
  14964. _vrExclusivePointerMode: boolean;
  14965. /** @hidden */
  14966. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14967. /** @hidden */
  14968. _onVRDisplayPointerRestricted: () => void;
  14969. /** @hidden */
  14970. _onVRDisplayPointerUnrestricted: () => void;
  14971. /** @hidden */
  14972. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14973. /** @hidden */
  14974. _onVrDisplayDisconnect: Nullable<() => void>;
  14975. /** @hidden */
  14976. _onVrDisplayPresentChange: Nullable<() => void>;
  14977. /**
  14978. * Observable signaled when VR display mode changes
  14979. */
  14980. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14981. /**
  14982. * Observable signaled when VR request present is complete
  14983. */
  14984. onVRRequestPresentComplete: Observable<boolean>;
  14985. /**
  14986. * Observable signaled when VR request present starts
  14987. */
  14988. onVRRequestPresentStart: Observable<Engine>;
  14989. /**
  14990. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14991. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14992. */
  14993. isInVRExclusivePointerMode: boolean;
  14994. /**
  14995. * Gets a boolean indicating if a webVR device was detected
  14996. * @returns true if a webVR device was detected
  14997. */
  14998. isVRDevicePresent(): boolean;
  14999. /**
  15000. * Gets the current webVR device
  15001. * @returns the current webVR device (or null)
  15002. */
  15003. getVRDevice(): any;
  15004. /**
  15005. * Initializes a webVR display and starts listening to display change events
  15006. * The onVRDisplayChangedObservable will be notified upon these changes
  15007. * @returns A promise containing a VRDisplay and if vr is supported
  15008. */
  15009. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15010. /** @hidden */
  15011. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15012. /**
  15013. * Gets or sets the presentation attributes used to configure VR rendering
  15014. */
  15015. vrPresentationAttributes?: IVRPresentationAttributes;
  15016. /**
  15017. * Call this function to switch to webVR mode
  15018. * Will do nothing if webVR is not supported or if there is no webVR device
  15019. * @param options the webvr options provided to the camera. mainly used for multiview
  15020. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15021. */
  15022. enableVR(options: WebVROptions): void;
  15023. /** @hidden */
  15024. _onVRFullScreenTriggered(): void;
  15025. }
  15026. }
  15027. declare module BABYLON {
  15028. /**
  15029. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15030. * IMPORTANT!! The data is right-hand data.
  15031. * @export
  15032. * @interface DevicePose
  15033. */
  15034. export interface DevicePose {
  15035. /**
  15036. * The position of the device, values in array are [x,y,z].
  15037. */
  15038. readonly position: Nullable<Float32Array>;
  15039. /**
  15040. * The linearVelocity of the device, values in array are [x,y,z].
  15041. */
  15042. readonly linearVelocity: Nullable<Float32Array>;
  15043. /**
  15044. * The linearAcceleration of the device, values in array are [x,y,z].
  15045. */
  15046. readonly linearAcceleration: Nullable<Float32Array>;
  15047. /**
  15048. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15049. */
  15050. readonly orientation: Nullable<Float32Array>;
  15051. /**
  15052. * The angularVelocity of the device, values in array are [x,y,z].
  15053. */
  15054. readonly angularVelocity: Nullable<Float32Array>;
  15055. /**
  15056. * The angularAcceleration of the device, values in array are [x,y,z].
  15057. */
  15058. readonly angularAcceleration: Nullable<Float32Array>;
  15059. }
  15060. /**
  15061. * Interface representing a pose controlled object in Babylon.
  15062. * A pose controlled object has both regular pose values as well as pose values
  15063. * from an external device such as a VR head mounted display
  15064. */
  15065. export interface PoseControlled {
  15066. /**
  15067. * The position of the object in babylon space.
  15068. */
  15069. position: Vector3;
  15070. /**
  15071. * The rotation quaternion of the object in babylon space.
  15072. */
  15073. rotationQuaternion: Quaternion;
  15074. /**
  15075. * The position of the device in babylon space.
  15076. */
  15077. devicePosition?: Vector3;
  15078. /**
  15079. * The rotation quaternion of the device in babylon space.
  15080. */
  15081. deviceRotationQuaternion: Quaternion;
  15082. /**
  15083. * The raw pose coming from the device.
  15084. */
  15085. rawPose: Nullable<DevicePose>;
  15086. /**
  15087. * The scale of the device to be used when translating from device space to babylon space.
  15088. */
  15089. deviceScaleFactor: number;
  15090. /**
  15091. * Updates the poseControlled values based on the input device pose.
  15092. * @param poseData the pose data to update the object with
  15093. */
  15094. updateFromDevice(poseData: DevicePose): void;
  15095. }
  15096. /**
  15097. * Set of options to customize the webVRCamera
  15098. */
  15099. export interface WebVROptions {
  15100. /**
  15101. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15102. */
  15103. trackPosition?: boolean;
  15104. /**
  15105. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15106. */
  15107. positionScale?: number;
  15108. /**
  15109. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15110. */
  15111. displayName?: string;
  15112. /**
  15113. * Should the native controller meshes be initialized. (default: true)
  15114. */
  15115. controllerMeshes?: boolean;
  15116. /**
  15117. * Creating a default HemiLight only on controllers. (default: true)
  15118. */
  15119. defaultLightingOnControllers?: boolean;
  15120. /**
  15121. * If you don't want to use the default VR button of the helper. (default: false)
  15122. */
  15123. useCustomVRButton?: boolean;
  15124. /**
  15125. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15126. */
  15127. customVRButton?: HTMLButtonElement;
  15128. /**
  15129. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15130. */
  15131. rayLength?: number;
  15132. /**
  15133. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15134. */
  15135. defaultHeight?: number;
  15136. /**
  15137. * If multiview should be used if availible (default: false)
  15138. */
  15139. useMultiview?: boolean;
  15140. }
  15141. /**
  15142. * This represents a WebVR camera.
  15143. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15144. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15145. */
  15146. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15147. private webVROptions;
  15148. /**
  15149. * @hidden
  15150. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15151. */
  15152. _vrDevice: any;
  15153. /**
  15154. * The rawPose of the vrDevice.
  15155. */
  15156. rawPose: Nullable<DevicePose>;
  15157. private _onVREnabled;
  15158. private _specsVersion;
  15159. private _attached;
  15160. private _frameData;
  15161. protected _descendants: Array<Node>;
  15162. private _deviceRoomPosition;
  15163. /** @hidden */
  15164. _deviceRoomRotationQuaternion: Quaternion;
  15165. private _standingMatrix;
  15166. /**
  15167. * Represents device position in babylon space.
  15168. */
  15169. devicePosition: Vector3;
  15170. /**
  15171. * Represents device rotation in babylon space.
  15172. */
  15173. deviceRotationQuaternion: Quaternion;
  15174. /**
  15175. * The scale of the device to be used when translating from device space to babylon space.
  15176. */
  15177. deviceScaleFactor: number;
  15178. private _deviceToWorld;
  15179. private _worldToDevice;
  15180. /**
  15181. * References to the webVR controllers for the vrDevice.
  15182. */
  15183. controllers: Array<WebVRController>;
  15184. /**
  15185. * Emits an event when a controller is attached.
  15186. */
  15187. onControllersAttachedObservable: Observable<WebVRController[]>;
  15188. /**
  15189. * Emits an event when a controller's mesh has been loaded;
  15190. */
  15191. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15192. /**
  15193. * Emits an event when the HMD's pose has been updated.
  15194. */
  15195. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15196. private _poseSet;
  15197. /**
  15198. * If the rig cameras be used as parent instead of this camera.
  15199. */
  15200. rigParenting: boolean;
  15201. private _lightOnControllers;
  15202. private _defaultHeight?;
  15203. /**
  15204. * Instantiates a WebVRFreeCamera.
  15205. * @param name The name of the WebVRFreeCamera
  15206. * @param position The starting anchor position for the camera
  15207. * @param scene The scene the camera belongs to
  15208. * @param webVROptions a set of customizable options for the webVRCamera
  15209. */
  15210. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15211. /**
  15212. * Gets the device distance from the ground in meters.
  15213. * @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.
  15214. */
  15215. deviceDistanceToRoomGround(): number;
  15216. /**
  15217. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15218. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15219. */
  15220. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15221. /**
  15222. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15223. * @returns A promise with a boolean set to if the standing matrix is supported.
  15224. */
  15225. useStandingMatrixAsync(): Promise<boolean>;
  15226. /**
  15227. * Disposes the camera
  15228. */
  15229. dispose(): void;
  15230. /**
  15231. * Gets a vrController by name.
  15232. * @param name The name of the controller to retreive
  15233. * @returns the controller matching the name specified or null if not found
  15234. */
  15235. getControllerByName(name: string): Nullable<WebVRController>;
  15236. private _leftController;
  15237. /**
  15238. * The controller corresponding to the users left hand.
  15239. */
  15240. readonly leftController: Nullable<WebVRController>;
  15241. private _rightController;
  15242. /**
  15243. * The controller corresponding to the users right hand.
  15244. */
  15245. readonly rightController: Nullable<WebVRController>;
  15246. /**
  15247. * Casts a ray forward from the vrCamera's gaze.
  15248. * @param length Length of the ray (default: 100)
  15249. * @returns the ray corresponding to the gaze
  15250. */
  15251. getForwardRay(length?: number): Ray;
  15252. /**
  15253. * @hidden
  15254. * Updates the camera based on device's frame data
  15255. */
  15256. _checkInputs(): void;
  15257. /**
  15258. * Updates the poseControlled values based on the input device pose.
  15259. * @param poseData Pose coming from the device
  15260. */
  15261. updateFromDevice(poseData: DevicePose): void;
  15262. private _htmlElementAttached;
  15263. private _detachIfAttached;
  15264. /**
  15265. * WebVR's attach control will start broadcasting frames to the device.
  15266. * Note that in certain browsers (chrome for example) this function must be called
  15267. * within a user-interaction callback. Example:
  15268. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15269. *
  15270. * @param element html element to attach the vrDevice to
  15271. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15272. */
  15273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15274. /**
  15275. * Detaches the camera from the html element and disables VR
  15276. *
  15277. * @param element html element to detach from
  15278. */
  15279. detachControl(element: HTMLElement): void;
  15280. /**
  15281. * @returns the name of this class
  15282. */
  15283. getClassName(): string;
  15284. /**
  15285. * Calls resetPose on the vrDisplay
  15286. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15287. */
  15288. resetToCurrentRotation(): void;
  15289. /**
  15290. * @hidden
  15291. * Updates the rig cameras (left and right eye)
  15292. */
  15293. _updateRigCameras(): void;
  15294. private _workingVector;
  15295. private _oneVector;
  15296. private _workingMatrix;
  15297. private updateCacheCalled;
  15298. private _correctPositionIfNotTrackPosition;
  15299. /**
  15300. * @hidden
  15301. * Updates the cached values of the camera
  15302. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15303. */
  15304. _updateCache(ignoreParentClass?: boolean): void;
  15305. /**
  15306. * @hidden
  15307. * Get current device position in babylon world
  15308. */
  15309. _computeDevicePosition(): void;
  15310. /**
  15311. * Updates the current device position and rotation in the babylon world
  15312. */
  15313. update(): void;
  15314. /**
  15315. * @hidden
  15316. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15317. * @returns an identity matrix
  15318. */
  15319. _getViewMatrix(): Matrix;
  15320. private _tmpMatrix;
  15321. /**
  15322. * This function is called by the two RIG cameras.
  15323. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15324. * @hidden
  15325. */
  15326. _getWebVRViewMatrix(): Matrix;
  15327. /** @hidden */
  15328. _getWebVRProjectionMatrix(): Matrix;
  15329. private _onGamepadConnectedObserver;
  15330. private _onGamepadDisconnectedObserver;
  15331. private _updateCacheWhenTrackingDisabledObserver;
  15332. /**
  15333. * Initializes the controllers and their meshes
  15334. */
  15335. initControllers(): void;
  15336. }
  15337. }
  15338. declare module BABYLON {
  15339. /**
  15340. * Size options for a post process
  15341. */
  15342. export type PostProcessOptions = {
  15343. width: number;
  15344. height: number;
  15345. };
  15346. /**
  15347. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15348. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15349. */
  15350. export class PostProcess {
  15351. /** Name of the PostProcess. */
  15352. name: string;
  15353. /**
  15354. * Gets or sets the unique id of the post process
  15355. */
  15356. uniqueId: number;
  15357. /**
  15358. * Width of the texture to apply the post process on
  15359. */
  15360. width: number;
  15361. /**
  15362. * Height of the texture to apply the post process on
  15363. */
  15364. height: number;
  15365. /**
  15366. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15367. * @hidden
  15368. */
  15369. _outputTexture: Nullable<InternalTexture>;
  15370. /**
  15371. * Sampling mode used by the shader
  15372. * See https://doc.babylonjs.com/classes/3.1/texture
  15373. */
  15374. renderTargetSamplingMode: number;
  15375. /**
  15376. * Clear color to use when screen clearing
  15377. */
  15378. clearColor: Color4;
  15379. /**
  15380. * If the buffer needs to be cleared before applying the post process. (default: true)
  15381. * Should be set to false if shader will overwrite all previous pixels.
  15382. */
  15383. autoClear: boolean;
  15384. /**
  15385. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15386. */
  15387. alphaMode: number;
  15388. /**
  15389. * Sets the setAlphaBlendConstants of the babylon engine
  15390. */
  15391. alphaConstants: Color4;
  15392. /**
  15393. * Animations to be used for the post processing
  15394. */
  15395. animations: Animation[];
  15396. /**
  15397. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15398. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15399. */
  15400. enablePixelPerfectMode: boolean;
  15401. /**
  15402. * Force the postprocess to be applied without taking in account viewport
  15403. */
  15404. forceFullscreenViewport: boolean;
  15405. /**
  15406. * List of inspectable custom properties (used by the Inspector)
  15407. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15408. */
  15409. inspectableCustomProperties: IInspectable[];
  15410. /**
  15411. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15412. *
  15413. * | Value | Type | Description |
  15414. * | ----- | ----------------------------------- | ----------- |
  15415. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15416. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15417. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15418. *
  15419. */
  15420. scaleMode: number;
  15421. /**
  15422. * Force textures to be a power of two (default: false)
  15423. */
  15424. alwaysForcePOT: boolean;
  15425. private _samples;
  15426. /**
  15427. * Number of sample textures (default: 1)
  15428. */
  15429. samples: number;
  15430. /**
  15431. * Modify the scale of the post process to be the same as the viewport (default: false)
  15432. */
  15433. adaptScaleToCurrentViewport: boolean;
  15434. private _camera;
  15435. private _scene;
  15436. private _engine;
  15437. private _options;
  15438. private _reusable;
  15439. private _textureType;
  15440. /**
  15441. * Smart array of input and output textures for the post process.
  15442. * @hidden
  15443. */
  15444. _textures: SmartArray<InternalTexture>;
  15445. /**
  15446. * The index in _textures that corresponds to the output texture.
  15447. * @hidden
  15448. */
  15449. _currentRenderTextureInd: number;
  15450. private _effect;
  15451. private _samplers;
  15452. private _fragmentUrl;
  15453. private _vertexUrl;
  15454. private _parameters;
  15455. private _scaleRatio;
  15456. protected _indexParameters: any;
  15457. private _shareOutputWithPostProcess;
  15458. private _texelSize;
  15459. private _forcedOutputTexture;
  15460. /**
  15461. * Returns the fragment url or shader name used in the post process.
  15462. * @returns the fragment url or name in the shader store.
  15463. */
  15464. getEffectName(): string;
  15465. /**
  15466. * An event triggered when the postprocess is activated.
  15467. */
  15468. onActivateObservable: Observable<Camera>;
  15469. private _onActivateObserver;
  15470. /**
  15471. * A function that is added to the onActivateObservable
  15472. */
  15473. onActivate: Nullable<(camera: Camera) => void>;
  15474. /**
  15475. * An event triggered when the postprocess changes its size.
  15476. */
  15477. onSizeChangedObservable: Observable<PostProcess>;
  15478. private _onSizeChangedObserver;
  15479. /**
  15480. * A function that is added to the onSizeChangedObservable
  15481. */
  15482. onSizeChanged: (postProcess: PostProcess) => void;
  15483. /**
  15484. * An event triggered when the postprocess applies its effect.
  15485. */
  15486. onApplyObservable: Observable<Effect>;
  15487. private _onApplyObserver;
  15488. /**
  15489. * A function that is added to the onApplyObservable
  15490. */
  15491. onApply: (effect: Effect) => void;
  15492. /**
  15493. * An event triggered before rendering the postprocess
  15494. */
  15495. onBeforeRenderObservable: Observable<Effect>;
  15496. private _onBeforeRenderObserver;
  15497. /**
  15498. * A function that is added to the onBeforeRenderObservable
  15499. */
  15500. onBeforeRender: (effect: Effect) => void;
  15501. /**
  15502. * An event triggered after rendering the postprocess
  15503. */
  15504. onAfterRenderObservable: Observable<Effect>;
  15505. private _onAfterRenderObserver;
  15506. /**
  15507. * A function that is added to the onAfterRenderObservable
  15508. */
  15509. onAfterRender: (efect: Effect) => void;
  15510. /**
  15511. * 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
  15512. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15513. */
  15514. inputTexture: InternalTexture;
  15515. /**
  15516. * Gets the camera which post process is applied to.
  15517. * @returns The camera the post process is applied to.
  15518. */
  15519. getCamera(): Camera;
  15520. /**
  15521. * Gets the texel size of the postprocess.
  15522. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15523. */
  15524. readonly texelSize: Vector2;
  15525. /**
  15526. * Creates a new instance PostProcess
  15527. * @param name The name of the PostProcess.
  15528. * @param fragmentUrl The url of the fragment shader to be used.
  15529. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15530. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15531. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15532. * @param camera The camera to apply the render pass to.
  15533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15534. * @param engine The engine which the post process will be applied. (default: current engine)
  15535. * @param reusable If the post process can be reused on the same frame. (default: false)
  15536. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15537. * @param textureType Type of textures used when performing the post process. (default: 0)
  15538. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15539. * @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
  15540. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15541. */
  15542. constructor(
  15543. /** Name of the PostProcess. */
  15544. 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);
  15545. /**
  15546. * Gets a string idenfifying the name of the class
  15547. * @returns "PostProcess" string
  15548. */
  15549. getClassName(): string;
  15550. /**
  15551. * Gets the engine which this post process belongs to.
  15552. * @returns The engine the post process was enabled with.
  15553. */
  15554. getEngine(): Engine;
  15555. /**
  15556. * The effect that is created when initializing the post process.
  15557. * @returns The created effect corresponding the the postprocess.
  15558. */
  15559. getEffect(): Effect;
  15560. /**
  15561. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15562. * @param postProcess The post process to share the output with.
  15563. * @returns This post process.
  15564. */
  15565. shareOutputWith(postProcess: PostProcess): PostProcess;
  15566. /**
  15567. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15568. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15569. */
  15570. useOwnOutput(): void;
  15571. /**
  15572. * Updates the effect with the current post process compile time values and recompiles the shader.
  15573. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15574. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15575. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15576. * @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
  15577. * @param onCompiled Called when the shader has been compiled.
  15578. * @param onError Called if there is an error when compiling a shader.
  15579. */
  15580. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15581. /**
  15582. * The post process is reusable if it can be used multiple times within one frame.
  15583. * @returns If the post process is reusable
  15584. */
  15585. isReusable(): boolean;
  15586. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15587. markTextureDirty(): void;
  15588. /**
  15589. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15590. * 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.
  15591. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15592. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15593. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15594. * @returns The target texture that was bound to be written to.
  15595. */
  15596. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15597. /**
  15598. * If the post process is supported.
  15599. */
  15600. readonly isSupported: boolean;
  15601. /**
  15602. * The aspect ratio of the output texture.
  15603. */
  15604. readonly aspectRatio: number;
  15605. /**
  15606. * Get a value indicating if the post-process is ready to be used
  15607. * @returns true if the post-process is ready (shader is compiled)
  15608. */
  15609. isReady(): boolean;
  15610. /**
  15611. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15612. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15613. */
  15614. apply(): Nullable<Effect>;
  15615. private _disposeTextures;
  15616. /**
  15617. * Disposes the post process.
  15618. * @param camera The camera to dispose the post process on.
  15619. */
  15620. dispose(camera?: Camera): void;
  15621. }
  15622. }
  15623. declare module BABYLON {
  15624. /** @hidden */
  15625. export var kernelBlurVaryingDeclaration: {
  15626. name: string;
  15627. shader: string;
  15628. };
  15629. }
  15630. declare module BABYLON {
  15631. /** @hidden */
  15632. export var kernelBlurFragment: {
  15633. name: string;
  15634. shader: string;
  15635. };
  15636. }
  15637. declare module BABYLON {
  15638. /** @hidden */
  15639. export var kernelBlurFragment2: {
  15640. name: string;
  15641. shader: string;
  15642. };
  15643. }
  15644. declare module BABYLON {
  15645. /** @hidden */
  15646. export var kernelBlurPixelShader: {
  15647. name: string;
  15648. shader: string;
  15649. };
  15650. }
  15651. declare module BABYLON {
  15652. /** @hidden */
  15653. export var kernelBlurVertex: {
  15654. name: string;
  15655. shader: string;
  15656. };
  15657. }
  15658. declare module BABYLON {
  15659. /** @hidden */
  15660. export var kernelBlurVertexShader: {
  15661. name: string;
  15662. shader: string;
  15663. };
  15664. }
  15665. declare module BABYLON {
  15666. /**
  15667. * The Blur Post Process which blurs an image based on a kernel and direction.
  15668. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15669. */
  15670. export class BlurPostProcess extends PostProcess {
  15671. /** The direction in which to blur the image. */
  15672. direction: Vector2;
  15673. private blockCompilation;
  15674. protected _kernel: number;
  15675. protected _idealKernel: number;
  15676. protected _packedFloat: boolean;
  15677. private _staticDefines;
  15678. /**
  15679. * Sets the length in pixels of the blur sample region
  15680. */
  15681. /**
  15682. * Gets the length in pixels of the blur sample region
  15683. */
  15684. kernel: number;
  15685. /**
  15686. * Sets wether or not the blur needs to unpack/repack floats
  15687. */
  15688. /**
  15689. * Gets wether or not the blur is unpacking/repacking floats
  15690. */
  15691. packedFloat: boolean;
  15692. /**
  15693. * Creates a new instance BlurPostProcess
  15694. * @param name The name of the effect.
  15695. * @param direction The direction in which to blur the image.
  15696. * @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.
  15697. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15698. * @param camera The camera to apply the render pass to.
  15699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15700. * @param engine The engine which the post process will be applied. (default: current engine)
  15701. * @param reusable If the post process can be reused on the same frame. (default: false)
  15702. * @param textureType Type of textures used when performing the post process. (default: 0)
  15703. * @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)
  15704. */
  15705. constructor(name: string,
  15706. /** The direction in which to blur the image. */
  15707. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15708. /**
  15709. * Updates the effect with the current post process compile time values and recompiles the shader.
  15710. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15711. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15712. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15713. * @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
  15714. * @param onCompiled Called when the shader has been compiled.
  15715. * @param onError Called if there is an error when compiling a shader.
  15716. */
  15717. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15718. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15719. /**
  15720. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15721. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15722. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15723. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15724. * The gaps between physical kernels are compensated for in the weighting of the samples
  15725. * @param idealKernel Ideal blur kernel.
  15726. * @return Nearest best kernel.
  15727. */
  15728. protected _nearestBestKernel(idealKernel: number): number;
  15729. /**
  15730. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15731. * @param x The point on the Gaussian distribution to sample.
  15732. * @return the value of the Gaussian function at x.
  15733. */
  15734. protected _gaussianWeight(x: number): number;
  15735. /**
  15736. * Generates a string that can be used as a floating point number in GLSL.
  15737. * @param x Value to print.
  15738. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15739. * @return GLSL float string.
  15740. */
  15741. protected _glslFloat(x: number, decimalFigures?: number): string;
  15742. }
  15743. }
  15744. declare module BABYLON {
  15745. /**
  15746. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15747. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15748. * You can then easily use it as a reflectionTexture on a flat surface.
  15749. * In case the surface is not a plane, please consider relying on reflection probes.
  15750. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15751. */
  15752. export class MirrorTexture extends RenderTargetTexture {
  15753. private scene;
  15754. /**
  15755. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15756. * 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.
  15757. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15758. */
  15759. mirrorPlane: Plane;
  15760. /**
  15761. * Define the blur ratio used to blur the reflection if needed.
  15762. */
  15763. blurRatio: number;
  15764. /**
  15765. * Define the adaptive blur kernel used to blur the reflection if needed.
  15766. * This will autocompute the closest best match for the `blurKernel`
  15767. */
  15768. adaptiveBlurKernel: number;
  15769. /**
  15770. * Define the blur kernel used to blur the reflection if needed.
  15771. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15772. */
  15773. blurKernel: number;
  15774. /**
  15775. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15776. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15777. */
  15778. blurKernelX: number;
  15779. /**
  15780. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15781. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15782. */
  15783. blurKernelY: number;
  15784. private _autoComputeBlurKernel;
  15785. protected _onRatioRescale(): void;
  15786. private _updateGammaSpace;
  15787. private _imageProcessingConfigChangeObserver;
  15788. private _transformMatrix;
  15789. private _mirrorMatrix;
  15790. private _savedViewMatrix;
  15791. private _blurX;
  15792. private _blurY;
  15793. private _adaptiveBlurKernel;
  15794. private _blurKernelX;
  15795. private _blurKernelY;
  15796. private _blurRatio;
  15797. /**
  15798. * Instantiates a Mirror Texture.
  15799. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15800. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15801. * You can then easily use it as a reflectionTexture on a flat surface.
  15802. * In case the surface is not a plane, please consider relying on reflection probes.
  15803. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15804. * @param name
  15805. * @param size
  15806. * @param scene
  15807. * @param generateMipMaps
  15808. * @param type
  15809. * @param samplingMode
  15810. * @param generateDepthBuffer
  15811. */
  15812. constructor(name: string, size: number | {
  15813. width: number;
  15814. height: number;
  15815. } | {
  15816. ratio: number;
  15817. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15818. private _preparePostProcesses;
  15819. /**
  15820. * Clone the mirror texture.
  15821. * @returns the cloned texture
  15822. */
  15823. clone(): MirrorTexture;
  15824. /**
  15825. * Serialize the texture to a JSON representation you could use in Parse later on
  15826. * @returns the serialized JSON representation
  15827. */
  15828. serialize(): any;
  15829. /**
  15830. * Dispose the texture and release its associated resources.
  15831. */
  15832. dispose(): void;
  15833. }
  15834. }
  15835. declare module BABYLON {
  15836. /**
  15837. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15838. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15839. */
  15840. export class Texture extends BaseTexture {
  15841. /**
  15842. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15843. */
  15844. static SerializeBuffers: boolean;
  15845. /** @hidden */
  15846. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15847. /** @hidden */
  15848. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15849. /** @hidden */
  15850. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15851. /** nearest is mag = nearest and min = nearest and mip = linear */
  15852. static readonly NEAREST_SAMPLINGMODE: number;
  15853. /** nearest is mag = nearest and min = nearest and mip = linear */
  15854. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15855. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15856. static readonly BILINEAR_SAMPLINGMODE: number;
  15857. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15858. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15859. /** Trilinear is mag = linear and min = linear and mip = linear */
  15860. static readonly TRILINEAR_SAMPLINGMODE: number;
  15861. /** Trilinear is mag = linear and min = linear and mip = linear */
  15862. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15863. /** mag = nearest and min = nearest and mip = nearest */
  15864. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15865. /** mag = nearest and min = linear and mip = nearest */
  15866. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15867. /** mag = nearest and min = linear and mip = linear */
  15868. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15869. /** mag = nearest and min = linear and mip = none */
  15870. static readonly NEAREST_LINEAR: number;
  15871. /** mag = nearest and min = nearest and mip = none */
  15872. static readonly NEAREST_NEAREST: number;
  15873. /** mag = linear and min = nearest and mip = nearest */
  15874. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15875. /** mag = linear and min = nearest and mip = linear */
  15876. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15877. /** mag = linear and min = linear and mip = none */
  15878. static readonly LINEAR_LINEAR: number;
  15879. /** mag = linear and min = nearest and mip = none */
  15880. static readonly LINEAR_NEAREST: number;
  15881. /** Explicit coordinates mode */
  15882. static readonly EXPLICIT_MODE: number;
  15883. /** Spherical coordinates mode */
  15884. static readonly SPHERICAL_MODE: number;
  15885. /** Planar coordinates mode */
  15886. static readonly PLANAR_MODE: number;
  15887. /** Cubic coordinates mode */
  15888. static readonly CUBIC_MODE: number;
  15889. /** Projection coordinates mode */
  15890. static readonly PROJECTION_MODE: number;
  15891. /** Inverse Cubic coordinates mode */
  15892. static readonly SKYBOX_MODE: number;
  15893. /** Inverse Cubic coordinates mode */
  15894. static readonly INVCUBIC_MODE: number;
  15895. /** Equirectangular coordinates mode */
  15896. static readonly EQUIRECTANGULAR_MODE: number;
  15897. /** Equirectangular Fixed coordinates mode */
  15898. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15899. /** Equirectangular Fixed Mirrored coordinates mode */
  15900. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15901. /** Texture is not repeating outside of 0..1 UVs */
  15902. static readonly CLAMP_ADDRESSMODE: number;
  15903. /** Texture is repeating outside of 0..1 UVs */
  15904. static readonly WRAP_ADDRESSMODE: number;
  15905. /** Texture is repeating and mirrored */
  15906. static readonly MIRROR_ADDRESSMODE: number;
  15907. /**
  15908. * 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
  15909. */
  15910. static UseSerializedUrlIfAny: boolean;
  15911. /**
  15912. * Define the url of the texture.
  15913. */
  15914. url: Nullable<string>;
  15915. /**
  15916. * Define an offset on the texture to offset the u coordinates of the UVs
  15917. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15918. */
  15919. uOffset: number;
  15920. /**
  15921. * Define an offset on the texture to offset the v coordinates of the UVs
  15922. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15923. */
  15924. vOffset: number;
  15925. /**
  15926. * Define an offset on the texture to scale the u coordinates of the UVs
  15927. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15928. */
  15929. uScale: number;
  15930. /**
  15931. * Define an offset on the texture to scale the v coordinates of the UVs
  15932. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15933. */
  15934. vScale: number;
  15935. /**
  15936. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15937. * @see http://doc.babylonjs.com/how_to/more_materials
  15938. */
  15939. uAng: number;
  15940. /**
  15941. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15942. * @see http://doc.babylonjs.com/how_to/more_materials
  15943. */
  15944. vAng: number;
  15945. /**
  15946. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15947. * @see http://doc.babylonjs.com/how_to/more_materials
  15948. */
  15949. wAng: number;
  15950. /**
  15951. * Defines the center of rotation (U)
  15952. */
  15953. uRotationCenter: number;
  15954. /**
  15955. * Defines the center of rotation (V)
  15956. */
  15957. vRotationCenter: number;
  15958. /**
  15959. * Defines the center of rotation (W)
  15960. */
  15961. wRotationCenter: number;
  15962. /**
  15963. * Are mip maps generated for this texture or not.
  15964. */
  15965. readonly noMipmap: boolean;
  15966. /**
  15967. * List of inspectable custom properties (used by the Inspector)
  15968. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15969. */
  15970. inspectableCustomProperties: Nullable<IInspectable[]>;
  15971. private _noMipmap;
  15972. /** @hidden */
  15973. _invertY: boolean;
  15974. private _rowGenerationMatrix;
  15975. private _cachedTextureMatrix;
  15976. private _projectionModeMatrix;
  15977. private _t0;
  15978. private _t1;
  15979. private _t2;
  15980. private _cachedUOffset;
  15981. private _cachedVOffset;
  15982. private _cachedUScale;
  15983. private _cachedVScale;
  15984. private _cachedUAng;
  15985. private _cachedVAng;
  15986. private _cachedWAng;
  15987. private _cachedProjectionMatrixId;
  15988. private _cachedCoordinatesMode;
  15989. /** @hidden */
  15990. protected _initialSamplingMode: number;
  15991. /** @hidden */
  15992. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15993. private _deleteBuffer;
  15994. protected _format: Nullable<number>;
  15995. private _delayedOnLoad;
  15996. private _delayedOnError;
  15997. private _mimeType?;
  15998. /**
  15999. * Observable triggered once the texture has been loaded.
  16000. */
  16001. onLoadObservable: Observable<Texture>;
  16002. protected _isBlocking: boolean;
  16003. /**
  16004. * Is the texture preventing material to render while loading.
  16005. * If false, a default texture will be used instead of the loading one during the preparation step.
  16006. */
  16007. isBlocking: boolean;
  16008. /**
  16009. * Get the current sampling mode associated with the texture.
  16010. */
  16011. readonly samplingMode: number;
  16012. /**
  16013. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16014. */
  16015. readonly invertY: boolean;
  16016. /**
  16017. * Instantiates a new texture.
  16018. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16019. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16020. * @param url defines the url of the picture to load as a texture
  16021. * @param scene defines the scene or engine the texture will belong to
  16022. * @param noMipmap defines if the texture will require mip maps or not
  16023. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16024. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16025. * @param onLoad defines a callback triggered when the texture has been loaded
  16026. * @param onError defines a callback triggered when an error occurred during the loading session
  16027. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16028. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16029. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16030. * @param mimeType defines an optional mime type information
  16031. */
  16032. 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);
  16033. /**
  16034. * Update the url (and optional buffer) of this texture if url was null during construction.
  16035. * @param url the url of the texture
  16036. * @param buffer the buffer of the texture (defaults to null)
  16037. * @param onLoad callback called when the texture is loaded (defaults to null)
  16038. */
  16039. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16040. /**
  16041. * Finish the loading sequence of a texture flagged as delayed load.
  16042. * @hidden
  16043. */
  16044. delayLoad(): void;
  16045. private _prepareRowForTextureGeneration;
  16046. /**
  16047. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16048. * @returns the transform matrix of the texture.
  16049. */
  16050. getTextureMatrix(uBase?: number): Matrix;
  16051. /**
  16052. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16053. * @returns The reflection texture transform
  16054. */
  16055. getReflectionTextureMatrix(): Matrix;
  16056. /**
  16057. * Clones the texture.
  16058. * @returns the cloned texture
  16059. */
  16060. clone(): Texture;
  16061. /**
  16062. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16063. * @returns The JSON representation of the texture
  16064. */
  16065. serialize(): any;
  16066. /**
  16067. * Get the current class name of the texture useful for serialization or dynamic coding.
  16068. * @returns "Texture"
  16069. */
  16070. getClassName(): string;
  16071. /**
  16072. * Dispose the texture and release its associated resources.
  16073. */
  16074. dispose(): void;
  16075. /**
  16076. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16077. * @param parsedTexture Define the JSON representation of the texture
  16078. * @param scene Define the scene the parsed texture should be instantiated in
  16079. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16080. * @returns The parsed texture if successful
  16081. */
  16082. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16083. /**
  16084. * Creates a texture from its base 64 representation.
  16085. * @param data Define the base64 payload without the data: prefix
  16086. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16087. * @param scene Define the scene the texture should belong to
  16088. * @param noMipmap Forces the texture to not create mip map information if true
  16089. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16090. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16091. * @param onLoad define a callback triggered when the texture has been loaded
  16092. * @param onError define a callback triggered when an error occurred during the loading session
  16093. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16094. * @returns the created texture
  16095. */
  16096. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16097. /**
  16098. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16099. * @param data Define the base64 payload without the data: prefix
  16100. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16101. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16102. * @param scene Define the scene the texture should belong to
  16103. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16104. * @param noMipmap Forces the texture to not create mip map information if true
  16105. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16106. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16107. * @param onLoad define a callback triggered when the texture has been loaded
  16108. * @param onError define a callback triggered when an error occurred during the loading session
  16109. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16110. * @returns the created texture
  16111. */
  16112. 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;
  16113. }
  16114. }
  16115. declare module BABYLON {
  16116. /**
  16117. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16118. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16119. */
  16120. export class PostProcessManager {
  16121. private _scene;
  16122. private _indexBuffer;
  16123. private _vertexBuffers;
  16124. /**
  16125. * Creates a new instance PostProcess
  16126. * @param scene The scene that the post process is associated with.
  16127. */
  16128. constructor(scene: Scene);
  16129. private _prepareBuffers;
  16130. private _buildIndexBuffer;
  16131. /**
  16132. * Rebuilds the vertex buffers of the manager.
  16133. * @hidden
  16134. */
  16135. _rebuild(): void;
  16136. /**
  16137. * Prepares a frame to be run through a post process.
  16138. * @param sourceTexture The input texture to the post procesess. (default: null)
  16139. * @param postProcesses An array of post processes to be run. (default: null)
  16140. * @returns True if the post processes were able to be run.
  16141. * @hidden
  16142. */
  16143. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16144. /**
  16145. * Manually render a set of post processes to a texture.
  16146. * @param postProcesses An array of post processes to be run.
  16147. * @param targetTexture The target texture to render to.
  16148. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16149. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16150. * @param lodLevel defines which lod of the texture to render to
  16151. */
  16152. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16153. /**
  16154. * Finalize the result of the output of the postprocesses.
  16155. * @param doNotPresent If true the result will not be displayed to the screen.
  16156. * @param targetTexture The target texture to render to.
  16157. * @param faceIndex The index of the face to bind the target texture to.
  16158. * @param postProcesses The array of post processes to render.
  16159. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16160. * @hidden
  16161. */
  16162. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16163. /**
  16164. * Disposes of the post process manager.
  16165. */
  16166. dispose(): void;
  16167. }
  16168. }
  16169. declare module BABYLON {
  16170. /** Interface used by value gradients (color, factor, ...) */
  16171. export interface IValueGradient {
  16172. /**
  16173. * Gets or sets the gradient value (between 0 and 1)
  16174. */
  16175. gradient: number;
  16176. }
  16177. /** Class used to store color4 gradient */
  16178. export class ColorGradient implements IValueGradient {
  16179. /**
  16180. * Gets or sets the gradient value (between 0 and 1)
  16181. */
  16182. gradient: number;
  16183. /**
  16184. * Gets or sets first associated color
  16185. */
  16186. color1: Color4;
  16187. /**
  16188. * Gets or sets second associated color
  16189. */
  16190. color2?: Color4;
  16191. /**
  16192. * Will get a color picked randomly between color1 and color2.
  16193. * If color2 is undefined then color1 will be used
  16194. * @param result defines the target Color4 to store the result in
  16195. */
  16196. getColorToRef(result: Color4): void;
  16197. }
  16198. /** Class used to store color 3 gradient */
  16199. export class Color3Gradient implements IValueGradient {
  16200. /**
  16201. * Gets or sets the gradient value (between 0 and 1)
  16202. */
  16203. gradient: number;
  16204. /**
  16205. * Gets or sets the associated color
  16206. */
  16207. color: Color3;
  16208. }
  16209. /** Class used to store factor gradient */
  16210. export class FactorGradient implements IValueGradient {
  16211. /**
  16212. * Gets or sets the gradient value (between 0 and 1)
  16213. */
  16214. gradient: number;
  16215. /**
  16216. * Gets or sets first associated factor
  16217. */
  16218. factor1: number;
  16219. /**
  16220. * Gets or sets second associated factor
  16221. */
  16222. factor2?: number;
  16223. /**
  16224. * Will get a number picked randomly between factor1 and factor2.
  16225. * If factor2 is undefined then factor1 will be used
  16226. * @returns the picked number
  16227. */
  16228. getFactor(): number;
  16229. }
  16230. /**
  16231. * Helper used to simplify some generic gradient tasks
  16232. */
  16233. export class GradientHelper {
  16234. /**
  16235. * Gets the current gradient from an array of IValueGradient
  16236. * @param ratio defines the current ratio to get
  16237. * @param gradients defines the array of IValueGradient
  16238. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16239. */
  16240. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16241. }
  16242. }
  16243. declare module BABYLON {
  16244. interface ThinEngine {
  16245. /**
  16246. * Creates a dynamic texture
  16247. * @param width defines the width of the texture
  16248. * @param height defines the height of the texture
  16249. * @param generateMipMaps defines if the engine should generate the mip levels
  16250. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16251. * @returns the dynamic texture inside an InternalTexture
  16252. */
  16253. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16254. /**
  16255. * Update the content of a dynamic texture
  16256. * @param texture defines the texture to update
  16257. * @param canvas defines the canvas containing the source
  16258. * @param invertY defines if data must be stored with Y axis inverted
  16259. * @param premulAlpha defines if alpha is stored as premultiplied
  16260. * @param format defines the format of the data
  16261. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16262. */
  16263. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16264. }
  16265. }
  16266. declare module BABYLON {
  16267. /**
  16268. * Helper class used to generate a canvas to manipulate images
  16269. */
  16270. export class CanvasGenerator {
  16271. /**
  16272. * Create a new canvas (or offscreen canvas depending on the context)
  16273. * @param width defines the expected width
  16274. * @param height defines the expected height
  16275. * @return a new canvas or offscreen canvas
  16276. */
  16277. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16278. }
  16279. }
  16280. declare module BABYLON {
  16281. /**
  16282. * A class extending Texture allowing drawing on a texture
  16283. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16284. */
  16285. export class DynamicTexture extends Texture {
  16286. private _generateMipMaps;
  16287. private _canvas;
  16288. private _context;
  16289. private _engine;
  16290. /**
  16291. * Creates a DynamicTexture
  16292. * @param name defines the name of the texture
  16293. * @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
  16294. * @param scene defines the scene where you want the texture
  16295. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16296. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16297. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16298. */
  16299. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16300. /**
  16301. * Get the current class name of the texture useful for serialization or dynamic coding.
  16302. * @returns "DynamicTexture"
  16303. */
  16304. getClassName(): string;
  16305. /**
  16306. * Gets the current state of canRescale
  16307. */
  16308. readonly canRescale: boolean;
  16309. private _recreate;
  16310. /**
  16311. * Scales the texture
  16312. * @param ratio the scale factor to apply to both width and height
  16313. */
  16314. scale(ratio: number): void;
  16315. /**
  16316. * Resizes the texture
  16317. * @param width the new width
  16318. * @param height the new height
  16319. */
  16320. scaleTo(width: number, height: number): void;
  16321. /**
  16322. * Gets the context of the canvas used by the texture
  16323. * @returns the canvas context of the dynamic texture
  16324. */
  16325. getContext(): CanvasRenderingContext2D;
  16326. /**
  16327. * Clears the texture
  16328. */
  16329. clear(): void;
  16330. /**
  16331. * Updates the texture
  16332. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16333. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16334. */
  16335. update(invertY?: boolean, premulAlpha?: boolean): void;
  16336. /**
  16337. * Draws text onto the texture
  16338. * @param text defines the text to be drawn
  16339. * @param x defines the placement of the text from the left
  16340. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16341. * @param font defines the font to be used with font-style, font-size, font-name
  16342. * @param color defines the color used for the text
  16343. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16344. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16345. * @param update defines whether texture is immediately update (default is true)
  16346. */
  16347. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16348. /**
  16349. * Clones the texture
  16350. * @returns the clone of the texture.
  16351. */
  16352. clone(): DynamicTexture;
  16353. /**
  16354. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16355. * @returns a serialized dynamic texture object
  16356. */
  16357. serialize(): any;
  16358. /** @hidden */
  16359. _rebuild(): void;
  16360. }
  16361. }
  16362. declare module BABYLON {
  16363. interface AbstractScene {
  16364. /**
  16365. * The list of procedural textures added to the scene
  16366. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16367. */
  16368. proceduralTextures: Array<ProceduralTexture>;
  16369. }
  16370. /**
  16371. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16372. * in a given scene.
  16373. */
  16374. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16375. /**
  16376. * The component name helpfull to identify the component in the list of scene components.
  16377. */
  16378. readonly name: string;
  16379. /**
  16380. * The scene the component belongs to.
  16381. */
  16382. scene: Scene;
  16383. /**
  16384. * Creates a new instance of the component for the given scene
  16385. * @param scene Defines the scene to register the component in
  16386. */
  16387. constructor(scene: Scene);
  16388. /**
  16389. * Registers the component in a given scene
  16390. */
  16391. register(): void;
  16392. /**
  16393. * Rebuilds the elements related to this component in case of
  16394. * context lost for instance.
  16395. */
  16396. rebuild(): void;
  16397. /**
  16398. * Disposes the component and the associated ressources.
  16399. */
  16400. dispose(): void;
  16401. private _beforeClear;
  16402. }
  16403. }
  16404. declare module BABYLON {
  16405. interface ThinEngine {
  16406. /**
  16407. * Creates a new render target cube texture
  16408. * @param size defines the size of the texture
  16409. * @param options defines the options used to create the texture
  16410. * @returns a new render target cube texture stored in an InternalTexture
  16411. */
  16412. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16413. }
  16414. }
  16415. declare module BABYLON {
  16416. /** @hidden */
  16417. export var proceduralVertexShader: {
  16418. name: string;
  16419. shader: string;
  16420. };
  16421. }
  16422. declare module BABYLON {
  16423. /**
  16424. * 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.
  16425. * This is the base class of any Procedural texture and contains most of the shareable code.
  16426. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16427. */
  16428. export class ProceduralTexture extends Texture {
  16429. isCube: boolean;
  16430. /**
  16431. * Define if the texture is enabled or not (disabled texture will not render)
  16432. */
  16433. isEnabled: boolean;
  16434. /**
  16435. * Define if the texture must be cleared before rendering (default is true)
  16436. */
  16437. autoClear: boolean;
  16438. /**
  16439. * Callback called when the texture is generated
  16440. */
  16441. onGenerated: () => void;
  16442. /**
  16443. * Event raised when the texture is generated
  16444. */
  16445. onGeneratedObservable: Observable<ProceduralTexture>;
  16446. /** @hidden */
  16447. _generateMipMaps: boolean;
  16448. /** @hidden **/
  16449. _effect: Effect;
  16450. /** @hidden */
  16451. _textures: {
  16452. [key: string]: Texture;
  16453. };
  16454. private _size;
  16455. private _currentRefreshId;
  16456. private _refreshRate;
  16457. private _vertexBuffers;
  16458. private _indexBuffer;
  16459. private _uniforms;
  16460. private _samplers;
  16461. private _fragment;
  16462. private _floats;
  16463. private _ints;
  16464. private _floatsArrays;
  16465. private _colors3;
  16466. private _colors4;
  16467. private _vectors2;
  16468. private _vectors3;
  16469. private _matrices;
  16470. private _fallbackTexture;
  16471. private _fallbackTextureUsed;
  16472. private _engine;
  16473. private _cachedDefines;
  16474. private _contentUpdateId;
  16475. private _contentData;
  16476. /**
  16477. * Instantiates a new procedural texture.
  16478. * 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.
  16479. * This is the base class of any Procedural texture and contains most of the shareable code.
  16480. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16481. * @param name Define the name of the texture
  16482. * @param size Define the size of the texture to create
  16483. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16484. * @param scene Define the scene the texture belongs to
  16485. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16486. * @param generateMipMaps Define if the texture should creates mip maps or not
  16487. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16488. */
  16489. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16490. /**
  16491. * The effect that is created when initializing the post process.
  16492. * @returns The created effect corresponding the the postprocess.
  16493. */
  16494. getEffect(): Effect;
  16495. /**
  16496. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16497. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16498. */
  16499. getContent(): Nullable<ArrayBufferView>;
  16500. private _createIndexBuffer;
  16501. /** @hidden */
  16502. _rebuild(): void;
  16503. /**
  16504. * Resets the texture in order to recreate its associated resources.
  16505. * This can be called in case of context loss
  16506. */
  16507. reset(): void;
  16508. protected _getDefines(): string;
  16509. /**
  16510. * Is the texture ready to be used ? (rendered at least once)
  16511. * @returns true if ready, otherwise, false.
  16512. */
  16513. isReady(): boolean;
  16514. /**
  16515. * Resets the refresh counter of the texture and start bak from scratch.
  16516. * Could be useful to regenerate the texture if it is setup to render only once.
  16517. */
  16518. resetRefreshCounter(): void;
  16519. /**
  16520. * Set the fragment shader to use in order to render the texture.
  16521. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16522. */
  16523. setFragment(fragment: any): void;
  16524. /**
  16525. * Define the refresh rate of the texture or the rendering frequency.
  16526. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16527. */
  16528. refreshRate: number;
  16529. /** @hidden */
  16530. _shouldRender(): boolean;
  16531. /**
  16532. * Get the size the texture is rendering at.
  16533. * @returns the size (texture is always squared)
  16534. */
  16535. getRenderSize(): number;
  16536. /**
  16537. * Resize the texture to new value.
  16538. * @param size Define the new size the texture should have
  16539. * @param generateMipMaps Define whether the new texture should create mip maps
  16540. */
  16541. resize(size: number, generateMipMaps: boolean): void;
  16542. private _checkUniform;
  16543. /**
  16544. * Set a texture in the shader program used to render.
  16545. * @param name Define the name of the uniform samplers as defined in the shader
  16546. * @param texture Define the texture to bind to this sampler
  16547. * @return the texture itself allowing "fluent" like uniform updates
  16548. */
  16549. setTexture(name: string, texture: Texture): ProceduralTexture;
  16550. /**
  16551. * Set a float in the shader.
  16552. * @param name Define the name of the uniform as defined in the shader
  16553. * @param value Define the value to give to the uniform
  16554. * @return the texture itself allowing "fluent" like uniform updates
  16555. */
  16556. setFloat(name: string, value: number): ProceduralTexture;
  16557. /**
  16558. * Set a int in the shader.
  16559. * @param name Define the name of the uniform as defined in the shader
  16560. * @param value Define the value to give to the uniform
  16561. * @return the texture itself allowing "fluent" like uniform updates
  16562. */
  16563. setInt(name: string, value: number): ProceduralTexture;
  16564. /**
  16565. * Set an array of floats in the shader.
  16566. * @param name Define the name of the uniform as defined in the shader
  16567. * @param value Define the value to give to the uniform
  16568. * @return the texture itself allowing "fluent" like uniform updates
  16569. */
  16570. setFloats(name: string, value: number[]): ProceduralTexture;
  16571. /**
  16572. * Set a vec3 in the shader from a Color3.
  16573. * @param name Define the name of the uniform as defined in the shader
  16574. * @param value Define the value to give to the uniform
  16575. * @return the texture itself allowing "fluent" like uniform updates
  16576. */
  16577. setColor3(name: string, value: Color3): ProceduralTexture;
  16578. /**
  16579. * Set a vec4 in the shader from a Color4.
  16580. * @param name Define the name of the uniform as defined in the shader
  16581. * @param value Define the value to give to the uniform
  16582. * @return the texture itself allowing "fluent" like uniform updates
  16583. */
  16584. setColor4(name: string, value: Color4): ProceduralTexture;
  16585. /**
  16586. * Set a vec2 in the shader from a Vector2.
  16587. * @param name Define the name of the uniform as defined in the shader
  16588. * @param value Define the value to give to the uniform
  16589. * @return the texture itself allowing "fluent" like uniform updates
  16590. */
  16591. setVector2(name: string, value: Vector2): ProceduralTexture;
  16592. /**
  16593. * Set a vec3 in the shader from a Vector3.
  16594. * @param name Define the name of the uniform as defined in the shader
  16595. * @param value Define the value to give to the uniform
  16596. * @return the texture itself allowing "fluent" like uniform updates
  16597. */
  16598. setVector3(name: string, value: Vector3): ProceduralTexture;
  16599. /**
  16600. * Set a mat4 in the shader from a MAtrix.
  16601. * @param name Define the name of the uniform as defined in the shader
  16602. * @param value Define the value to give to the uniform
  16603. * @return the texture itself allowing "fluent" like uniform updates
  16604. */
  16605. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16606. /**
  16607. * Render the texture to its associated render target.
  16608. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16609. */
  16610. render(useCameraPostProcess?: boolean): void;
  16611. /**
  16612. * Clone the texture.
  16613. * @returns the cloned texture
  16614. */
  16615. clone(): ProceduralTexture;
  16616. /**
  16617. * Dispose the texture and release its asoociated resources.
  16618. */
  16619. dispose(): void;
  16620. }
  16621. }
  16622. declare module BABYLON {
  16623. /**
  16624. * This represents the base class for particle system in Babylon.
  16625. * 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.
  16626. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16627. * @example https://doc.babylonjs.com/babylon101/particles
  16628. */
  16629. export class BaseParticleSystem {
  16630. /**
  16631. * Source color is added to the destination color without alpha affecting the result
  16632. */
  16633. static BLENDMODE_ONEONE: number;
  16634. /**
  16635. * Blend current color and particle color using particle’s alpha
  16636. */
  16637. static BLENDMODE_STANDARD: number;
  16638. /**
  16639. * Add current color and particle color multiplied by particle’s alpha
  16640. */
  16641. static BLENDMODE_ADD: number;
  16642. /**
  16643. * Multiply current color with particle color
  16644. */
  16645. static BLENDMODE_MULTIPLY: number;
  16646. /**
  16647. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16648. */
  16649. static BLENDMODE_MULTIPLYADD: number;
  16650. /**
  16651. * List of animations used by the particle system.
  16652. */
  16653. animations: Animation[];
  16654. /**
  16655. * The id of the Particle system.
  16656. */
  16657. id: string;
  16658. /**
  16659. * The friendly name of the Particle system.
  16660. */
  16661. name: string;
  16662. /**
  16663. * The rendering group used by the Particle system to chose when to render.
  16664. */
  16665. renderingGroupId: number;
  16666. /**
  16667. * The emitter represents the Mesh or position we are attaching the particle system to.
  16668. */
  16669. emitter: Nullable<AbstractMesh | Vector3>;
  16670. /**
  16671. * The maximum number of particles to emit per frame
  16672. */
  16673. emitRate: number;
  16674. /**
  16675. * If you want to launch only a few particles at once, that can be done, as well.
  16676. */
  16677. manualEmitCount: number;
  16678. /**
  16679. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16680. */
  16681. updateSpeed: number;
  16682. /**
  16683. * The amount of time the particle system is running (depends of the overall update speed).
  16684. */
  16685. targetStopDuration: number;
  16686. /**
  16687. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16688. */
  16689. disposeOnStop: boolean;
  16690. /**
  16691. * Minimum power of emitting particles.
  16692. */
  16693. minEmitPower: number;
  16694. /**
  16695. * Maximum power of emitting particles.
  16696. */
  16697. maxEmitPower: number;
  16698. /**
  16699. * Minimum life time of emitting particles.
  16700. */
  16701. minLifeTime: number;
  16702. /**
  16703. * Maximum life time of emitting particles.
  16704. */
  16705. maxLifeTime: number;
  16706. /**
  16707. * Minimum Size of emitting particles.
  16708. */
  16709. minSize: number;
  16710. /**
  16711. * Maximum Size of emitting particles.
  16712. */
  16713. maxSize: number;
  16714. /**
  16715. * Minimum scale of emitting particles on X axis.
  16716. */
  16717. minScaleX: number;
  16718. /**
  16719. * Maximum scale of emitting particles on X axis.
  16720. */
  16721. maxScaleX: number;
  16722. /**
  16723. * Minimum scale of emitting particles on Y axis.
  16724. */
  16725. minScaleY: number;
  16726. /**
  16727. * Maximum scale of emitting particles on Y axis.
  16728. */
  16729. maxScaleY: number;
  16730. /**
  16731. * Gets or sets the minimal initial rotation in radians.
  16732. */
  16733. minInitialRotation: number;
  16734. /**
  16735. * Gets or sets the maximal initial rotation in radians.
  16736. */
  16737. maxInitialRotation: number;
  16738. /**
  16739. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16740. */
  16741. minAngularSpeed: number;
  16742. /**
  16743. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16744. */
  16745. maxAngularSpeed: number;
  16746. /**
  16747. * The texture used to render each particle. (this can be a spritesheet)
  16748. */
  16749. particleTexture: Nullable<Texture>;
  16750. /**
  16751. * The layer mask we are rendering the particles through.
  16752. */
  16753. layerMask: number;
  16754. /**
  16755. * This can help using your own shader to render the particle system.
  16756. * The according effect will be created
  16757. */
  16758. customShader: any;
  16759. /**
  16760. * By default particle system starts as soon as they are created. This prevents the
  16761. * automatic start to happen and let you decide when to start emitting particles.
  16762. */
  16763. preventAutoStart: boolean;
  16764. private _noiseTexture;
  16765. /**
  16766. * Gets or sets a texture used to add random noise to particle positions
  16767. */
  16768. noiseTexture: Nullable<ProceduralTexture>;
  16769. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16770. noiseStrength: Vector3;
  16771. /**
  16772. * Callback triggered when the particle animation is ending.
  16773. */
  16774. onAnimationEnd: Nullable<() => void>;
  16775. /**
  16776. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16777. */
  16778. blendMode: number;
  16779. /**
  16780. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16781. * to override the particles.
  16782. */
  16783. forceDepthWrite: boolean;
  16784. /** 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 */
  16785. preWarmCycles: number;
  16786. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16787. preWarmStepOffset: number;
  16788. /**
  16789. * 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)
  16790. */
  16791. spriteCellChangeSpeed: number;
  16792. /**
  16793. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16794. */
  16795. startSpriteCellID: number;
  16796. /**
  16797. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16798. */
  16799. endSpriteCellID: number;
  16800. /**
  16801. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16802. */
  16803. spriteCellWidth: number;
  16804. /**
  16805. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16806. */
  16807. spriteCellHeight: number;
  16808. /**
  16809. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16810. */
  16811. spriteRandomStartCell: boolean;
  16812. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16813. translationPivot: Vector2;
  16814. /** @hidden */
  16815. protected _isAnimationSheetEnabled: boolean;
  16816. /**
  16817. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16818. */
  16819. beginAnimationOnStart: boolean;
  16820. /**
  16821. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16822. */
  16823. beginAnimationFrom: number;
  16824. /**
  16825. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16826. */
  16827. beginAnimationTo: number;
  16828. /**
  16829. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16830. */
  16831. beginAnimationLoop: boolean;
  16832. /**
  16833. * Gets or sets a world offset applied to all particles
  16834. */
  16835. worldOffset: Vector3;
  16836. /**
  16837. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16838. */
  16839. isAnimationSheetEnabled: boolean;
  16840. /**
  16841. * Get hosting scene
  16842. * @returns the scene
  16843. */
  16844. getScene(): Scene;
  16845. /**
  16846. * You can use gravity if you want to give an orientation to your particles.
  16847. */
  16848. gravity: Vector3;
  16849. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16850. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16851. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16852. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16853. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16854. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16855. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16856. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16857. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16858. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16859. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16860. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16861. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16862. /**
  16863. * Defines the delay in milliseconds before starting the system (0 by default)
  16864. */
  16865. startDelay: number;
  16866. /**
  16867. * Gets the current list of drag gradients.
  16868. * You must use addDragGradient and removeDragGradient to udpate this list
  16869. * @returns the list of drag gradients
  16870. */
  16871. getDragGradients(): Nullable<Array<FactorGradient>>;
  16872. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16873. limitVelocityDamping: number;
  16874. /**
  16875. * Gets the current list of limit velocity gradients.
  16876. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16877. * @returns the list of limit velocity gradients
  16878. */
  16879. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16880. /**
  16881. * Gets the current list of color gradients.
  16882. * You must use addColorGradient and removeColorGradient to udpate this list
  16883. * @returns the list of color gradients
  16884. */
  16885. getColorGradients(): Nullable<Array<ColorGradient>>;
  16886. /**
  16887. * Gets the current list of size gradients.
  16888. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16889. * @returns the list of size gradients
  16890. */
  16891. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16892. /**
  16893. * Gets the current list of color remap gradients.
  16894. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16895. * @returns the list of color remap gradients
  16896. */
  16897. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16898. /**
  16899. * Gets the current list of alpha remap gradients.
  16900. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16901. * @returns the list of alpha remap gradients
  16902. */
  16903. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16904. /**
  16905. * Gets the current list of life time gradients.
  16906. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16907. * @returns the list of life time gradients
  16908. */
  16909. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16910. /**
  16911. * Gets the current list of angular speed gradients.
  16912. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16913. * @returns the list of angular speed gradients
  16914. */
  16915. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16916. /**
  16917. * Gets the current list of velocity gradients.
  16918. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16919. * @returns the list of velocity gradients
  16920. */
  16921. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16922. /**
  16923. * Gets the current list of start size gradients.
  16924. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16925. * @returns the list of start size gradients
  16926. */
  16927. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16928. /**
  16929. * Gets the current list of emit rate gradients.
  16930. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16931. * @returns the list of emit rate gradients
  16932. */
  16933. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16934. /**
  16935. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16936. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16937. */
  16938. direction1: Vector3;
  16939. /**
  16940. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16941. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16942. */
  16943. direction2: Vector3;
  16944. /**
  16945. * 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.
  16946. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16947. */
  16948. minEmitBox: Vector3;
  16949. /**
  16950. * 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.
  16951. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16952. */
  16953. maxEmitBox: Vector3;
  16954. /**
  16955. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16956. */
  16957. color1: Color4;
  16958. /**
  16959. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16960. */
  16961. color2: Color4;
  16962. /**
  16963. * Color the particle will have at the end of its lifetime
  16964. */
  16965. colorDead: Color4;
  16966. /**
  16967. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16968. */
  16969. textureMask: Color4;
  16970. /**
  16971. * The particle emitter type defines the emitter used by the particle system.
  16972. * It can be for example box, sphere, or cone...
  16973. */
  16974. particleEmitterType: IParticleEmitterType;
  16975. /** @hidden */
  16976. _isSubEmitter: boolean;
  16977. /**
  16978. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16979. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16980. */
  16981. billboardMode: number;
  16982. protected _isBillboardBased: boolean;
  16983. /**
  16984. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16985. */
  16986. isBillboardBased: boolean;
  16987. /**
  16988. * The scene the particle system belongs to.
  16989. */
  16990. protected _scene: Scene;
  16991. /**
  16992. * Local cache of defines for image processing.
  16993. */
  16994. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16995. /**
  16996. * Default configuration related to image processing available in the standard Material.
  16997. */
  16998. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16999. /**
  17000. * Gets the image processing configuration used either in this material.
  17001. */
  17002. /**
  17003. * Sets the Default image processing configuration used either in the this material.
  17004. *
  17005. * If sets to null, the scene one is in use.
  17006. */
  17007. imageProcessingConfiguration: ImageProcessingConfiguration;
  17008. /**
  17009. * Attaches a new image processing configuration to the Standard Material.
  17010. * @param configuration
  17011. */
  17012. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17013. /** @hidden */
  17014. protected _reset(): void;
  17015. /** @hidden */
  17016. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17017. /**
  17018. * Instantiates a particle system.
  17019. * 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.
  17020. * @param name The name of the particle system
  17021. */
  17022. constructor(name: string);
  17023. /**
  17024. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17025. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17026. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17027. * @returns the emitter
  17028. */
  17029. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17030. /**
  17031. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17032. * @param radius The radius of the hemisphere to emit from
  17033. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17034. * @returns the emitter
  17035. */
  17036. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17037. /**
  17038. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17039. * @param radius The radius of the sphere to emit from
  17040. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17041. * @returns the emitter
  17042. */
  17043. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17044. /**
  17045. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17046. * @param radius The radius of the sphere to emit from
  17047. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17048. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17049. * @returns the emitter
  17050. */
  17051. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17052. /**
  17053. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17054. * @param radius The radius of the emission cylinder
  17055. * @param height The height of the emission cylinder
  17056. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17057. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17058. * @returns the emitter
  17059. */
  17060. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17061. /**
  17062. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17063. * @param radius The radius of the cylinder to emit from
  17064. * @param height The height of the emission cylinder
  17065. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17066. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17067. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17068. * @returns the emitter
  17069. */
  17070. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17071. /**
  17072. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17073. * @param radius The radius of the cone to emit from
  17074. * @param angle The base angle of the cone
  17075. * @returns the emitter
  17076. */
  17077. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17078. /**
  17079. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17080. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17081. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17082. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17083. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17084. * @returns the emitter
  17085. */
  17086. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17087. }
  17088. }
  17089. declare module BABYLON {
  17090. /**
  17091. * Type of sub emitter
  17092. */
  17093. export enum SubEmitterType {
  17094. /**
  17095. * Attached to the particle over it's lifetime
  17096. */
  17097. ATTACHED = 0,
  17098. /**
  17099. * Created when the particle dies
  17100. */
  17101. END = 1
  17102. }
  17103. /**
  17104. * Sub emitter class used to emit particles from an existing particle
  17105. */
  17106. export class SubEmitter {
  17107. /**
  17108. * the particle system to be used by the sub emitter
  17109. */
  17110. particleSystem: ParticleSystem;
  17111. /**
  17112. * Type of the submitter (Default: END)
  17113. */
  17114. type: SubEmitterType;
  17115. /**
  17116. * 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)
  17117. * Note: This only is supported when using an emitter of type Mesh
  17118. */
  17119. inheritDirection: boolean;
  17120. /**
  17121. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17122. */
  17123. inheritedVelocityAmount: number;
  17124. /**
  17125. * Creates a sub emitter
  17126. * @param particleSystem the particle system to be used by the sub emitter
  17127. */
  17128. constructor(
  17129. /**
  17130. * the particle system to be used by the sub emitter
  17131. */
  17132. particleSystem: ParticleSystem);
  17133. /**
  17134. * Clones the sub emitter
  17135. * @returns the cloned sub emitter
  17136. */
  17137. clone(): SubEmitter;
  17138. /**
  17139. * Serialize current object to a JSON object
  17140. * @returns the serialized object
  17141. */
  17142. serialize(): any;
  17143. /** @hidden */
  17144. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17145. /**
  17146. * Creates a new SubEmitter from a serialized JSON version
  17147. * @param serializationObject defines the JSON object to read from
  17148. * @param scene defines the hosting scene
  17149. * @param rootUrl defines the rootUrl for data loading
  17150. * @returns a new SubEmitter
  17151. */
  17152. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17153. /** Release associated resources */
  17154. dispose(): void;
  17155. }
  17156. }
  17157. declare module BABYLON {
  17158. /** @hidden */
  17159. export var clipPlaneFragmentDeclaration: {
  17160. name: string;
  17161. shader: string;
  17162. };
  17163. }
  17164. declare module BABYLON {
  17165. /** @hidden */
  17166. export var imageProcessingDeclaration: {
  17167. name: string;
  17168. shader: string;
  17169. };
  17170. }
  17171. declare module BABYLON {
  17172. /** @hidden */
  17173. export var imageProcessingFunctions: {
  17174. name: string;
  17175. shader: string;
  17176. };
  17177. }
  17178. declare module BABYLON {
  17179. /** @hidden */
  17180. export var clipPlaneFragment: {
  17181. name: string;
  17182. shader: string;
  17183. };
  17184. }
  17185. declare module BABYLON {
  17186. /** @hidden */
  17187. export var particlesPixelShader: {
  17188. name: string;
  17189. shader: string;
  17190. };
  17191. }
  17192. declare module BABYLON {
  17193. /** @hidden */
  17194. export var clipPlaneVertexDeclaration: {
  17195. name: string;
  17196. shader: string;
  17197. };
  17198. }
  17199. declare module BABYLON {
  17200. /** @hidden */
  17201. export var clipPlaneVertex: {
  17202. name: string;
  17203. shader: string;
  17204. };
  17205. }
  17206. declare module BABYLON {
  17207. /** @hidden */
  17208. export var particlesVertexShader: {
  17209. name: string;
  17210. shader: string;
  17211. };
  17212. }
  17213. declare module BABYLON {
  17214. /**
  17215. * This represents a particle system in Babylon.
  17216. * 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.
  17217. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17218. * @example https://doc.babylonjs.com/babylon101/particles
  17219. */
  17220. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17221. /**
  17222. * Billboard mode will only apply to Y axis
  17223. */
  17224. static readonly BILLBOARDMODE_Y: number;
  17225. /**
  17226. * Billboard mode will apply to all axes
  17227. */
  17228. static readonly BILLBOARDMODE_ALL: number;
  17229. /**
  17230. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17231. */
  17232. static readonly BILLBOARDMODE_STRETCHED: number;
  17233. /**
  17234. * This function can be defined to provide custom update for active particles.
  17235. * This function will be called instead of regular update (age, position, color, etc.).
  17236. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17237. */
  17238. updateFunction: (particles: Particle[]) => void;
  17239. private _emitterWorldMatrix;
  17240. /**
  17241. * This function can be defined to specify initial direction for every new particle.
  17242. * It by default use the emitterType defined function
  17243. */
  17244. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17245. /**
  17246. * This function can be defined to specify initial position for every new particle.
  17247. * It by default use the emitterType defined function
  17248. */
  17249. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17250. /**
  17251. * @hidden
  17252. */
  17253. _inheritedVelocityOffset: Vector3;
  17254. /**
  17255. * An event triggered when the system is disposed
  17256. */
  17257. onDisposeObservable: Observable<ParticleSystem>;
  17258. private _onDisposeObserver;
  17259. /**
  17260. * Sets a callback that will be triggered when the system is disposed
  17261. */
  17262. onDispose: () => void;
  17263. private _particles;
  17264. private _epsilon;
  17265. private _capacity;
  17266. private _stockParticles;
  17267. private _newPartsExcess;
  17268. private _vertexData;
  17269. private _vertexBuffer;
  17270. private _vertexBuffers;
  17271. private _spriteBuffer;
  17272. private _indexBuffer;
  17273. private _effect;
  17274. private _customEffect;
  17275. private _cachedDefines;
  17276. private _scaledColorStep;
  17277. private _colorDiff;
  17278. private _scaledDirection;
  17279. private _scaledGravity;
  17280. private _currentRenderId;
  17281. private _alive;
  17282. private _useInstancing;
  17283. private _started;
  17284. private _stopped;
  17285. private _actualFrame;
  17286. private _scaledUpdateSpeed;
  17287. private _vertexBufferSize;
  17288. /** @hidden */
  17289. _currentEmitRateGradient: Nullable<FactorGradient>;
  17290. /** @hidden */
  17291. _currentEmitRate1: number;
  17292. /** @hidden */
  17293. _currentEmitRate2: number;
  17294. /** @hidden */
  17295. _currentStartSizeGradient: Nullable<FactorGradient>;
  17296. /** @hidden */
  17297. _currentStartSize1: number;
  17298. /** @hidden */
  17299. _currentStartSize2: number;
  17300. private readonly _rawTextureWidth;
  17301. private _rampGradientsTexture;
  17302. private _useRampGradients;
  17303. /** Gets or sets a boolean indicating that ramp gradients must be used
  17304. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17305. */
  17306. useRampGradients: boolean;
  17307. /**
  17308. * 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.
  17309. * 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: [])
  17310. */
  17311. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17312. private _subEmitters;
  17313. /**
  17314. * @hidden
  17315. * If the particle systems emitter should be disposed when the particle system is disposed
  17316. */
  17317. _disposeEmitterOnDispose: boolean;
  17318. /**
  17319. * The current active Sub-systems, this property is used by the root particle system only.
  17320. */
  17321. activeSubSystems: Array<ParticleSystem>;
  17322. private _rootParticleSystem;
  17323. /**
  17324. * Gets the current list of active particles
  17325. */
  17326. readonly particles: Particle[];
  17327. /**
  17328. * Returns the string "ParticleSystem"
  17329. * @returns a string containing the class name
  17330. */
  17331. getClassName(): string;
  17332. /**
  17333. * Instantiates a particle system.
  17334. * 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.
  17335. * @param name The name of the particle system
  17336. * @param capacity The max number of particles alive at the same time
  17337. * @param scene The scene the particle system belongs to
  17338. * @param customEffect a custom effect used to change the way particles are rendered by default
  17339. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17340. * @param epsilon Offset used to render the particles
  17341. */
  17342. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17343. private _addFactorGradient;
  17344. private _removeFactorGradient;
  17345. /**
  17346. * Adds a new life time gradient
  17347. * @param gradient defines the gradient to use (between 0 and 1)
  17348. * @param factor defines the life time factor to affect to the specified gradient
  17349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17350. * @returns the current particle system
  17351. */
  17352. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17353. /**
  17354. * Remove a specific life time gradient
  17355. * @param gradient defines the gradient to remove
  17356. * @returns the current particle system
  17357. */
  17358. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17359. /**
  17360. * Adds a new size gradient
  17361. * @param gradient defines the gradient to use (between 0 and 1)
  17362. * @param factor defines the size factor to affect to the specified gradient
  17363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17364. * @returns the current particle system
  17365. */
  17366. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17367. /**
  17368. * Remove a specific size gradient
  17369. * @param gradient defines the gradient to remove
  17370. * @returns the current particle system
  17371. */
  17372. removeSizeGradient(gradient: number): IParticleSystem;
  17373. /**
  17374. * Adds a new color remap gradient
  17375. * @param gradient defines the gradient to use (between 0 and 1)
  17376. * @param min defines the color remap minimal range
  17377. * @param max defines the color remap maximal range
  17378. * @returns the current particle system
  17379. */
  17380. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17381. /**
  17382. * Remove a specific color remap gradient
  17383. * @param gradient defines the gradient to remove
  17384. * @returns the current particle system
  17385. */
  17386. removeColorRemapGradient(gradient: number): IParticleSystem;
  17387. /**
  17388. * Adds a new alpha remap gradient
  17389. * @param gradient defines the gradient to use (between 0 and 1)
  17390. * @param min defines the alpha remap minimal range
  17391. * @param max defines the alpha remap maximal range
  17392. * @returns the current particle system
  17393. */
  17394. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17395. /**
  17396. * Remove a specific alpha remap gradient
  17397. * @param gradient defines the gradient to remove
  17398. * @returns the current particle system
  17399. */
  17400. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17401. /**
  17402. * Adds a new angular speed gradient
  17403. * @param gradient defines the gradient to use (between 0 and 1)
  17404. * @param factor defines the angular speed to affect to the specified gradient
  17405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17406. * @returns the current particle system
  17407. */
  17408. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17409. /**
  17410. * Remove a specific angular speed gradient
  17411. * @param gradient defines the gradient to remove
  17412. * @returns the current particle system
  17413. */
  17414. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17415. /**
  17416. * Adds a new velocity gradient
  17417. * @param gradient defines the gradient to use (between 0 and 1)
  17418. * @param factor defines the velocity to affect to the specified gradient
  17419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17420. * @returns the current particle system
  17421. */
  17422. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17423. /**
  17424. * Remove a specific velocity gradient
  17425. * @param gradient defines the gradient to remove
  17426. * @returns the current particle system
  17427. */
  17428. removeVelocityGradient(gradient: number): IParticleSystem;
  17429. /**
  17430. * Adds a new limit velocity gradient
  17431. * @param gradient defines the gradient to use (between 0 and 1)
  17432. * @param factor defines the limit velocity value to affect to the specified gradient
  17433. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17434. * @returns the current particle system
  17435. */
  17436. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17437. /**
  17438. * Remove a specific limit velocity gradient
  17439. * @param gradient defines the gradient to remove
  17440. * @returns the current particle system
  17441. */
  17442. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17443. /**
  17444. * Adds a new drag gradient
  17445. * @param gradient defines the gradient to use (between 0 and 1)
  17446. * @param factor defines the drag value to affect to the specified gradient
  17447. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17448. * @returns the current particle system
  17449. */
  17450. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17451. /**
  17452. * Remove a specific drag gradient
  17453. * @param gradient defines the gradient to remove
  17454. * @returns the current particle system
  17455. */
  17456. removeDragGradient(gradient: number): IParticleSystem;
  17457. /**
  17458. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17459. * @param gradient defines the gradient to use (between 0 and 1)
  17460. * @param factor defines the emit rate value to affect to the specified gradient
  17461. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17462. * @returns the current particle system
  17463. */
  17464. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17465. /**
  17466. * Remove a specific emit rate gradient
  17467. * @param gradient defines the gradient to remove
  17468. * @returns the current particle system
  17469. */
  17470. removeEmitRateGradient(gradient: number): IParticleSystem;
  17471. /**
  17472. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17473. * @param gradient defines the gradient to use (between 0 and 1)
  17474. * @param factor defines the start size value to affect to the specified gradient
  17475. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17476. * @returns the current particle system
  17477. */
  17478. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17479. /**
  17480. * Remove a specific start size gradient
  17481. * @param gradient defines the gradient to remove
  17482. * @returns the current particle system
  17483. */
  17484. removeStartSizeGradient(gradient: number): IParticleSystem;
  17485. private _createRampGradientTexture;
  17486. /**
  17487. * Gets the current list of ramp gradients.
  17488. * You must use addRampGradient and removeRampGradient to udpate this list
  17489. * @returns the list of ramp gradients
  17490. */
  17491. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17492. /**
  17493. * Adds a new ramp gradient used to remap particle colors
  17494. * @param gradient defines the gradient to use (between 0 and 1)
  17495. * @param color defines the color to affect to the specified gradient
  17496. * @returns the current particle system
  17497. */
  17498. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17499. /**
  17500. * Remove a specific ramp gradient
  17501. * @param gradient defines the gradient to remove
  17502. * @returns the current particle system
  17503. */
  17504. removeRampGradient(gradient: number): ParticleSystem;
  17505. /**
  17506. * Adds a new color gradient
  17507. * @param gradient defines the gradient to use (between 0 and 1)
  17508. * @param color1 defines the color to affect to the specified gradient
  17509. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17510. * @returns this particle system
  17511. */
  17512. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17513. /**
  17514. * Remove a specific color gradient
  17515. * @param gradient defines the gradient to remove
  17516. * @returns this particle system
  17517. */
  17518. removeColorGradient(gradient: number): IParticleSystem;
  17519. private _fetchR;
  17520. protected _reset(): void;
  17521. private _resetEffect;
  17522. private _createVertexBuffers;
  17523. private _createIndexBuffer;
  17524. /**
  17525. * Gets the maximum number of particles active at the same time.
  17526. * @returns The max number of active particles.
  17527. */
  17528. getCapacity(): number;
  17529. /**
  17530. * Gets whether there are still active particles in the system.
  17531. * @returns True if it is alive, otherwise false.
  17532. */
  17533. isAlive(): boolean;
  17534. /**
  17535. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17536. * @returns True if it has been started, otherwise false.
  17537. */
  17538. isStarted(): boolean;
  17539. private _prepareSubEmitterInternalArray;
  17540. /**
  17541. * Starts the particle system and begins to emit
  17542. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17543. */
  17544. start(delay?: number): void;
  17545. /**
  17546. * Stops the particle system.
  17547. * @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.
  17548. */
  17549. stop(stopSubEmitters?: boolean): void;
  17550. /**
  17551. * Remove all active particles
  17552. */
  17553. reset(): void;
  17554. /**
  17555. * @hidden (for internal use only)
  17556. */
  17557. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17558. /**
  17559. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17560. * Its lifetime will start back at 0.
  17561. */
  17562. recycleParticle: (particle: Particle) => void;
  17563. private _stopSubEmitters;
  17564. private _createParticle;
  17565. private _removeFromRoot;
  17566. private _emitFromParticle;
  17567. private _update;
  17568. /** @hidden */
  17569. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17570. /** @hidden */
  17571. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17572. /** @hidden */
  17573. private _getEffect;
  17574. /**
  17575. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17576. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17577. */
  17578. animate(preWarmOnly?: boolean): void;
  17579. private _appendParticleVertices;
  17580. /**
  17581. * Rebuilds the particle system.
  17582. */
  17583. rebuild(): void;
  17584. /**
  17585. * Is this system ready to be used/rendered
  17586. * @return true if the system is ready
  17587. */
  17588. isReady(): boolean;
  17589. private _render;
  17590. /**
  17591. * Renders the particle system in its current state.
  17592. * @returns the current number of particles
  17593. */
  17594. render(): number;
  17595. /**
  17596. * Disposes the particle system and free the associated resources
  17597. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17598. */
  17599. dispose(disposeTexture?: boolean): void;
  17600. /**
  17601. * Clones the particle system.
  17602. * @param name The name of the cloned object
  17603. * @param newEmitter The new emitter to use
  17604. * @returns the cloned particle system
  17605. */
  17606. clone(name: string, newEmitter: any): ParticleSystem;
  17607. /**
  17608. * Serializes the particle system to a JSON object.
  17609. * @returns the JSON object
  17610. */
  17611. serialize(): any;
  17612. /** @hidden */
  17613. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17614. /** @hidden */
  17615. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17616. /**
  17617. * Parses a JSON object to create a particle system.
  17618. * @param parsedParticleSystem The JSON object to parse
  17619. * @param scene The scene to create the particle system in
  17620. * @param rootUrl The root url to use to load external dependencies like texture
  17621. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17622. * @returns the Parsed particle system
  17623. */
  17624. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17625. }
  17626. }
  17627. declare module BABYLON {
  17628. /**
  17629. * A particle represents one of the element emitted by a particle system.
  17630. * This is mainly define by its coordinates, direction, velocity and age.
  17631. */
  17632. export class Particle {
  17633. /**
  17634. * The particle system the particle belongs to.
  17635. */
  17636. particleSystem: ParticleSystem;
  17637. private static _Count;
  17638. /**
  17639. * Unique ID of the particle
  17640. */
  17641. id: number;
  17642. /**
  17643. * The world position of the particle in the scene.
  17644. */
  17645. position: Vector3;
  17646. /**
  17647. * The world direction of the particle in the scene.
  17648. */
  17649. direction: Vector3;
  17650. /**
  17651. * The color of the particle.
  17652. */
  17653. color: Color4;
  17654. /**
  17655. * The color change of the particle per step.
  17656. */
  17657. colorStep: Color4;
  17658. /**
  17659. * Defines how long will the life of the particle be.
  17660. */
  17661. lifeTime: number;
  17662. /**
  17663. * The current age of the particle.
  17664. */
  17665. age: number;
  17666. /**
  17667. * The current size of the particle.
  17668. */
  17669. size: number;
  17670. /**
  17671. * The current scale of the particle.
  17672. */
  17673. scale: Vector2;
  17674. /**
  17675. * The current angle of the particle.
  17676. */
  17677. angle: number;
  17678. /**
  17679. * Defines how fast is the angle changing.
  17680. */
  17681. angularSpeed: number;
  17682. /**
  17683. * Defines the cell index used by the particle to be rendered from a sprite.
  17684. */
  17685. cellIndex: number;
  17686. /**
  17687. * The information required to support color remapping
  17688. */
  17689. remapData: Vector4;
  17690. /** @hidden */
  17691. _randomCellOffset?: number;
  17692. /** @hidden */
  17693. _initialDirection: Nullable<Vector3>;
  17694. /** @hidden */
  17695. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17696. /** @hidden */
  17697. _initialStartSpriteCellID: number;
  17698. /** @hidden */
  17699. _initialEndSpriteCellID: number;
  17700. /** @hidden */
  17701. _currentColorGradient: Nullable<ColorGradient>;
  17702. /** @hidden */
  17703. _currentColor1: Color4;
  17704. /** @hidden */
  17705. _currentColor2: Color4;
  17706. /** @hidden */
  17707. _currentSizeGradient: Nullable<FactorGradient>;
  17708. /** @hidden */
  17709. _currentSize1: number;
  17710. /** @hidden */
  17711. _currentSize2: number;
  17712. /** @hidden */
  17713. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17714. /** @hidden */
  17715. _currentAngularSpeed1: number;
  17716. /** @hidden */
  17717. _currentAngularSpeed2: number;
  17718. /** @hidden */
  17719. _currentVelocityGradient: Nullable<FactorGradient>;
  17720. /** @hidden */
  17721. _currentVelocity1: number;
  17722. /** @hidden */
  17723. _currentVelocity2: number;
  17724. /** @hidden */
  17725. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17726. /** @hidden */
  17727. _currentLimitVelocity1: number;
  17728. /** @hidden */
  17729. _currentLimitVelocity2: number;
  17730. /** @hidden */
  17731. _currentDragGradient: Nullable<FactorGradient>;
  17732. /** @hidden */
  17733. _currentDrag1: number;
  17734. /** @hidden */
  17735. _currentDrag2: number;
  17736. /** @hidden */
  17737. _randomNoiseCoordinates1: Vector3;
  17738. /** @hidden */
  17739. _randomNoiseCoordinates2: Vector3;
  17740. /**
  17741. * Creates a new instance Particle
  17742. * @param particleSystem the particle system the particle belongs to
  17743. */
  17744. constructor(
  17745. /**
  17746. * The particle system the particle belongs to.
  17747. */
  17748. particleSystem: ParticleSystem);
  17749. private updateCellInfoFromSystem;
  17750. /**
  17751. * Defines how the sprite cell index is updated for the particle
  17752. */
  17753. updateCellIndex(): void;
  17754. /** @hidden */
  17755. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17756. /** @hidden */
  17757. _inheritParticleInfoToSubEmitters(): void;
  17758. /** @hidden */
  17759. _reset(): void;
  17760. /**
  17761. * Copy the properties of particle to another one.
  17762. * @param other the particle to copy the information to.
  17763. */
  17764. copyTo(other: Particle): void;
  17765. }
  17766. }
  17767. declare module BABYLON {
  17768. /**
  17769. * Particle emitter represents a volume emitting particles.
  17770. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17771. */
  17772. export interface IParticleEmitterType {
  17773. /**
  17774. * Called by the particle System when the direction is computed for the created particle.
  17775. * @param worldMatrix is the world matrix of the particle system
  17776. * @param directionToUpdate is the direction vector to update with the result
  17777. * @param particle is the particle we are computed the direction for
  17778. */
  17779. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17780. /**
  17781. * Called by the particle System when the position is computed for the created particle.
  17782. * @param worldMatrix is the world matrix of the particle system
  17783. * @param positionToUpdate is the position vector to update with the result
  17784. * @param particle is the particle we are computed the position for
  17785. */
  17786. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17787. /**
  17788. * Clones the current emitter and returns a copy of it
  17789. * @returns the new emitter
  17790. */
  17791. clone(): IParticleEmitterType;
  17792. /**
  17793. * Called by the GPUParticleSystem to setup the update shader
  17794. * @param effect defines the update shader
  17795. */
  17796. applyToShader(effect: Effect): void;
  17797. /**
  17798. * Returns a string to use to update the GPU particles update shader
  17799. * @returns the effect defines string
  17800. */
  17801. getEffectDefines(): string;
  17802. /**
  17803. * Returns a string representing the class name
  17804. * @returns a string containing the class name
  17805. */
  17806. getClassName(): string;
  17807. /**
  17808. * Serializes the particle system to a JSON object.
  17809. * @returns the JSON object
  17810. */
  17811. serialize(): any;
  17812. /**
  17813. * Parse properties from a JSON object
  17814. * @param serializationObject defines the JSON object
  17815. */
  17816. parse(serializationObject: any): void;
  17817. }
  17818. }
  17819. declare module BABYLON {
  17820. /**
  17821. * Particle emitter emitting particles from the inside of a box.
  17822. * It emits the particles randomly between 2 given directions.
  17823. */
  17824. export class BoxParticleEmitter implements IParticleEmitterType {
  17825. /**
  17826. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17827. */
  17828. direction1: Vector3;
  17829. /**
  17830. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17831. */
  17832. direction2: Vector3;
  17833. /**
  17834. * 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.
  17835. */
  17836. minEmitBox: Vector3;
  17837. /**
  17838. * 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.
  17839. */
  17840. maxEmitBox: Vector3;
  17841. /**
  17842. * Creates a new instance BoxParticleEmitter
  17843. */
  17844. constructor();
  17845. /**
  17846. * Called by the particle System when the direction is computed for the created particle.
  17847. * @param worldMatrix is the world matrix of the particle system
  17848. * @param directionToUpdate is the direction vector to update with the result
  17849. * @param particle is the particle we are computed the direction for
  17850. */
  17851. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17852. /**
  17853. * Called by the particle System when the position is computed for the created particle.
  17854. * @param worldMatrix is the world matrix of the particle system
  17855. * @param positionToUpdate is the position vector to update with the result
  17856. * @param particle is the particle we are computed the position for
  17857. */
  17858. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17859. /**
  17860. * Clones the current emitter and returns a copy of it
  17861. * @returns the new emitter
  17862. */
  17863. clone(): BoxParticleEmitter;
  17864. /**
  17865. * Called by the GPUParticleSystem to setup the update shader
  17866. * @param effect defines the update shader
  17867. */
  17868. applyToShader(effect: Effect): void;
  17869. /**
  17870. * Returns a string to use to update the GPU particles update shader
  17871. * @returns a string containng the defines string
  17872. */
  17873. getEffectDefines(): string;
  17874. /**
  17875. * Returns the string "BoxParticleEmitter"
  17876. * @returns a string containing the class name
  17877. */
  17878. getClassName(): string;
  17879. /**
  17880. * Serializes the particle system to a JSON object.
  17881. * @returns the JSON object
  17882. */
  17883. serialize(): any;
  17884. /**
  17885. * Parse properties from a JSON object
  17886. * @param serializationObject defines the JSON object
  17887. */
  17888. parse(serializationObject: any): void;
  17889. }
  17890. }
  17891. declare module BABYLON {
  17892. /**
  17893. * Particle emitter emitting particles from the inside of a cone.
  17894. * It emits the particles alongside the cone volume from the base to the particle.
  17895. * The emission direction might be randomized.
  17896. */
  17897. export class ConeParticleEmitter implements IParticleEmitterType {
  17898. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17899. directionRandomizer: number;
  17900. private _radius;
  17901. private _angle;
  17902. private _height;
  17903. /**
  17904. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17905. */
  17906. radiusRange: number;
  17907. /**
  17908. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17909. */
  17910. heightRange: number;
  17911. /**
  17912. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17913. */
  17914. emitFromSpawnPointOnly: boolean;
  17915. /**
  17916. * Gets or sets the radius of the emission cone
  17917. */
  17918. radius: number;
  17919. /**
  17920. * Gets or sets the angle of the emission cone
  17921. */
  17922. angle: number;
  17923. private _buildHeight;
  17924. /**
  17925. * Creates a new instance ConeParticleEmitter
  17926. * @param radius the radius of the emission cone (1 by default)
  17927. * @param angle the cone base angle (PI by default)
  17928. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17929. */
  17930. constructor(radius?: number, angle?: number,
  17931. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17932. directionRandomizer?: number);
  17933. /**
  17934. * Called by the particle System when the direction is computed for the created particle.
  17935. * @param worldMatrix is the world matrix of the particle system
  17936. * @param directionToUpdate is the direction vector to update with the result
  17937. * @param particle is the particle we are computed the direction for
  17938. */
  17939. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17940. /**
  17941. * Called by the particle System when the position is computed for the created particle.
  17942. * @param worldMatrix is the world matrix of the particle system
  17943. * @param positionToUpdate is the position vector to update with the result
  17944. * @param particle is the particle we are computed the position for
  17945. */
  17946. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17947. /**
  17948. * Clones the current emitter and returns a copy of it
  17949. * @returns the new emitter
  17950. */
  17951. clone(): ConeParticleEmitter;
  17952. /**
  17953. * Called by the GPUParticleSystem to setup the update shader
  17954. * @param effect defines the update shader
  17955. */
  17956. applyToShader(effect: Effect): void;
  17957. /**
  17958. * Returns a string to use to update the GPU particles update shader
  17959. * @returns a string containng the defines string
  17960. */
  17961. getEffectDefines(): string;
  17962. /**
  17963. * Returns the string "ConeParticleEmitter"
  17964. * @returns a string containing the class name
  17965. */
  17966. getClassName(): string;
  17967. /**
  17968. * Serializes the particle system to a JSON object.
  17969. * @returns the JSON object
  17970. */
  17971. serialize(): any;
  17972. /**
  17973. * Parse properties from a JSON object
  17974. * @param serializationObject defines the JSON object
  17975. */
  17976. parse(serializationObject: any): void;
  17977. }
  17978. }
  17979. declare module BABYLON {
  17980. /**
  17981. * Particle emitter emitting particles from the inside of a cylinder.
  17982. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17983. */
  17984. export class CylinderParticleEmitter implements IParticleEmitterType {
  17985. /**
  17986. * The radius of the emission cylinder.
  17987. */
  17988. radius: number;
  17989. /**
  17990. * The height of the emission cylinder.
  17991. */
  17992. height: number;
  17993. /**
  17994. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17995. */
  17996. radiusRange: number;
  17997. /**
  17998. * How much to randomize the particle direction [0-1].
  17999. */
  18000. directionRandomizer: number;
  18001. /**
  18002. * Creates a new instance CylinderParticleEmitter
  18003. * @param radius the radius of the emission cylinder (1 by default)
  18004. * @param height the height of the emission cylinder (1 by default)
  18005. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18006. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18007. */
  18008. constructor(
  18009. /**
  18010. * The radius of the emission cylinder.
  18011. */
  18012. radius?: number,
  18013. /**
  18014. * The height of the emission cylinder.
  18015. */
  18016. height?: number,
  18017. /**
  18018. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18019. */
  18020. radiusRange?: number,
  18021. /**
  18022. * How much to randomize the particle direction [0-1].
  18023. */
  18024. directionRandomizer?: number);
  18025. /**
  18026. * Called by the particle System when the direction is computed for the created particle.
  18027. * @param worldMatrix is the world matrix of the particle system
  18028. * @param directionToUpdate is the direction vector to update with the result
  18029. * @param particle is the particle we are computed the direction for
  18030. */
  18031. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18032. /**
  18033. * Called by the particle System when the position is computed for the created particle.
  18034. * @param worldMatrix is the world matrix of the particle system
  18035. * @param positionToUpdate is the position vector to update with the result
  18036. * @param particle is the particle we are computed the position for
  18037. */
  18038. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18039. /**
  18040. * Clones the current emitter and returns a copy of it
  18041. * @returns the new emitter
  18042. */
  18043. clone(): CylinderParticleEmitter;
  18044. /**
  18045. * Called by the GPUParticleSystem to setup the update shader
  18046. * @param effect defines the update shader
  18047. */
  18048. applyToShader(effect: Effect): void;
  18049. /**
  18050. * Returns a string to use to update the GPU particles update shader
  18051. * @returns a string containng the defines string
  18052. */
  18053. getEffectDefines(): string;
  18054. /**
  18055. * Returns the string "CylinderParticleEmitter"
  18056. * @returns a string containing the class name
  18057. */
  18058. getClassName(): string;
  18059. /**
  18060. * Serializes the particle system to a JSON object.
  18061. * @returns the JSON object
  18062. */
  18063. serialize(): any;
  18064. /**
  18065. * Parse properties from a JSON object
  18066. * @param serializationObject defines the JSON object
  18067. */
  18068. parse(serializationObject: any): void;
  18069. }
  18070. /**
  18071. * Particle emitter emitting particles from the inside of a cylinder.
  18072. * It emits the particles randomly between two vectors.
  18073. */
  18074. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18075. /**
  18076. * The min limit of the emission direction.
  18077. */
  18078. direction1: Vector3;
  18079. /**
  18080. * The max limit of the emission direction.
  18081. */
  18082. direction2: Vector3;
  18083. /**
  18084. * Creates a new instance CylinderDirectedParticleEmitter
  18085. * @param radius the radius of the emission cylinder (1 by default)
  18086. * @param height the height of the emission cylinder (1 by default)
  18087. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18088. * @param direction1 the min limit of the emission direction (up vector by default)
  18089. * @param direction2 the max limit of the emission direction (up vector by default)
  18090. */
  18091. constructor(radius?: number, height?: number, radiusRange?: number,
  18092. /**
  18093. * The min limit of the emission direction.
  18094. */
  18095. direction1?: Vector3,
  18096. /**
  18097. * The max limit of the emission direction.
  18098. */
  18099. direction2?: Vector3);
  18100. /**
  18101. * Called by the particle System when the direction is computed for the created particle.
  18102. * @param worldMatrix is the world matrix of the particle system
  18103. * @param directionToUpdate is the direction vector to update with the result
  18104. * @param particle is the particle we are computed the direction for
  18105. */
  18106. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18107. /**
  18108. * Clones the current emitter and returns a copy of it
  18109. * @returns the new emitter
  18110. */
  18111. clone(): CylinderDirectedParticleEmitter;
  18112. /**
  18113. * Called by the GPUParticleSystem to setup the update shader
  18114. * @param effect defines the update shader
  18115. */
  18116. applyToShader(effect: Effect): void;
  18117. /**
  18118. * Returns a string to use to update the GPU particles update shader
  18119. * @returns a string containng the defines string
  18120. */
  18121. getEffectDefines(): string;
  18122. /**
  18123. * Returns the string "CylinderDirectedParticleEmitter"
  18124. * @returns a string containing the class name
  18125. */
  18126. getClassName(): string;
  18127. /**
  18128. * Serializes the particle system to a JSON object.
  18129. * @returns the JSON object
  18130. */
  18131. serialize(): any;
  18132. /**
  18133. * Parse properties from a JSON object
  18134. * @param serializationObject defines the JSON object
  18135. */
  18136. parse(serializationObject: any): void;
  18137. }
  18138. }
  18139. declare module BABYLON {
  18140. /**
  18141. * Particle emitter emitting particles from the inside of a hemisphere.
  18142. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18143. */
  18144. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18145. /**
  18146. * The radius of the emission hemisphere.
  18147. */
  18148. radius: number;
  18149. /**
  18150. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18151. */
  18152. radiusRange: number;
  18153. /**
  18154. * How much to randomize the particle direction [0-1].
  18155. */
  18156. directionRandomizer: number;
  18157. /**
  18158. * Creates a new instance HemisphericParticleEmitter
  18159. * @param radius the radius of the emission hemisphere (1 by default)
  18160. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18161. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18162. */
  18163. constructor(
  18164. /**
  18165. * The radius of the emission hemisphere.
  18166. */
  18167. radius?: number,
  18168. /**
  18169. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18170. */
  18171. radiusRange?: number,
  18172. /**
  18173. * How much to randomize the particle direction [0-1].
  18174. */
  18175. directionRandomizer?: number);
  18176. /**
  18177. * Called by the particle System when the direction is computed for the created particle.
  18178. * @param worldMatrix is the world matrix of the particle system
  18179. * @param directionToUpdate is the direction vector to update with the result
  18180. * @param particle is the particle we are computed the direction for
  18181. */
  18182. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18183. /**
  18184. * Called by the particle System when the position is computed for the created particle.
  18185. * @param worldMatrix is the world matrix of the particle system
  18186. * @param positionToUpdate is the position vector to update with the result
  18187. * @param particle is the particle we are computed the position for
  18188. */
  18189. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18190. /**
  18191. * Clones the current emitter and returns a copy of it
  18192. * @returns the new emitter
  18193. */
  18194. clone(): HemisphericParticleEmitter;
  18195. /**
  18196. * Called by the GPUParticleSystem to setup the update shader
  18197. * @param effect defines the update shader
  18198. */
  18199. applyToShader(effect: Effect): void;
  18200. /**
  18201. * Returns a string to use to update the GPU particles update shader
  18202. * @returns a string containng the defines string
  18203. */
  18204. getEffectDefines(): string;
  18205. /**
  18206. * Returns the string "HemisphericParticleEmitter"
  18207. * @returns a string containing the class name
  18208. */
  18209. getClassName(): string;
  18210. /**
  18211. * Serializes the particle system to a JSON object.
  18212. * @returns the JSON object
  18213. */
  18214. serialize(): any;
  18215. /**
  18216. * Parse properties from a JSON object
  18217. * @param serializationObject defines the JSON object
  18218. */
  18219. parse(serializationObject: any): void;
  18220. }
  18221. }
  18222. declare module BABYLON {
  18223. /**
  18224. * Particle emitter emitting particles from a point.
  18225. * It emits the particles randomly between 2 given directions.
  18226. */
  18227. export class PointParticleEmitter implements IParticleEmitterType {
  18228. /**
  18229. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18230. */
  18231. direction1: Vector3;
  18232. /**
  18233. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18234. */
  18235. direction2: Vector3;
  18236. /**
  18237. * Creates a new instance PointParticleEmitter
  18238. */
  18239. constructor();
  18240. /**
  18241. * Called by the particle System when the direction is computed for the created particle.
  18242. * @param worldMatrix is the world matrix of the particle system
  18243. * @param directionToUpdate is the direction vector to update with the result
  18244. * @param particle is the particle we are computed the direction for
  18245. */
  18246. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18247. /**
  18248. * Called by the particle System when the position is computed for the created particle.
  18249. * @param worldMatrix is the world matrix of the particle system
  18250. * @param positionToUpdate is the position vector to update with the result
  18251. * @param particle is the particle we are computed the position for
  18252. */
  18253. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18254. /**
  18255. * Clones the current emitter and returns a copy of it
  18256. * @returns the new emitter
  18257. */
  18258. clone(): PointParticleEmitter;
  18259. /**
  18260. * Called by the GPUParticleSystem to setup the update shader
  18261. * @param effect defines the update shader
  18262. */
  18263. applyToShader(effect: Effect): void;
  18264. /**
  18265. * Returns a string to use to update the GPU particles update shader
  18266. * @returns a string containng the defines string
  18267. */
  18268. getEffectDefines(): string;
  18269. /**
  18270. * Returns the string "PointParticleEmitter"
  18271. * @returns a string containing the class name
  18272. */
  18273. getClassName(): string;
  18274. /**
  18275. * Serializes the particle system to a JSON object.
  18276. * @returns the JSON object
  18277. */
  18278. serialize(): any;
  18279. /**
  18280. * Parse properties from a JSON object
  18281. * @param serializationObject defines the JSON object
  18282. */
  18283. parse(serializationObject: any): void;
  18284. }
  18285. }
  18286. declare module BABYLON {
  18287. /**
  18288. * Particle emitter emitting particles from the inside of a sphere.
  18289. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18290. */
  18291. export class SphereParticleEmitter implements IParticleEmitterType {
  18292. /**
  18293. * The radius of the emission sphere.
  18294. */
  18295. radius: number;
  18296. /**
  18297. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18298. */
  18299. radiusRange: number;
  18300. /**
  18301. * How much to randomize the particle direction [0-1].
  18302. */
  18303. directionRandomizer: number;
  18304. /**
  18305. * Creates a new instance SphereParticleEmitter
  18306. * @param radius the radius of the emission sphere (1 by default)
  18307. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18308. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18309. */
  18310. constructor(
  18311. /**
  18312. * The radius of the emission sphere.
  18313. */
  18314. radius?: number,
  18315. /**
  18316. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18317. */
  18318. radiusRange?: number,
  18319. /**
  18320. * How much to randomize the particle direction [0-1].
  18321. */
  18322. directionRandomizer?: number);
  18323. /**
  18324. * Called by the particle System when the direction is computed for the created particle.
  18325. * @param worldMatrix is the world matrix of the particle system
  18326. * @param directionToUpdate is the direction vector to update with the result
  18327. * @param particle is the particle we are computed the direction for
  18328. */
  18329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18330. /**
  18331. * Called by the particle System when the position is computed for the created particle.
  18332. * @param worldMatrix is the world matrix of the particle system
  18333. * @param positionToUpdate is the position vector to update with the result
  18334. * @param particle is the particle we are computed the position for
  18335. */
  18336. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18337. /**
  18338. * Clones the current emitter and returns a copy of it
  18339. * @returns the new emitter
  18340. */
  18341. clone(): SphereParticleEmitter;
  18342. /**
  18343. * Called by the GPUParticleSystem to setup the update shader
  18344. * @param effect defines the update shader
  18345. */
  18346. applyToShader(effect: Effect): void;
  18347. /**
  18348. * Returns a string to use to update the GPU particles update shader
  18349. * @returns a string containng the defines string
  18350. */
  18351. getEffectDefines(): string;
  18352. /**
  18353. * Returns the string "SphereParticleEmitter"
  18354. * @returns a string containing the class name
  18355. */
  18356. getClassName(): string;
  18357. /**
  18358. * Serializes the particle system to a JSON object.
  18359. * @returns the JSON object
  18360. */
  18361. serialize(): any;
  18362. /**
  18363. * Parse properties from a JSON object
  18364. * @param serializationObject defines the JSON object
  18365. */
  18366. parse(serializationObject: any): void;
  18367. }
  18368. /**
  18369. * Particle emitter emitting particles from the inside of a sphere.
  18370. * It emits the particles randomly between two vectors.
  18371. */
  18372. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18373. /**
  18374. * The min limit of the emission direction.
  18375. */
  18376. direction1: Vector3;
  18377. /**
  18378. * The max limit of the emission direction.
  18379. */
  18380. direction2: Vector3;
  18381. /**
  18382. * Creates a new instance SphereDirectedParticleEmitter
  18383. * @param radius the radius of the emission sphere (1 by default)
  18384. * @param direction1 the min limit of the emission direction (up vector by default)
  18385. * @param direction2 the max limit of the emission direction (up vector by default)
  18386. */
  18387. constructor(radius?: number,
  18388. /**
  18389. * The min limit of the emission direction.
  18390. */
  18391. direction1?: Vector3,
  18392. /**
  18393. * The max limit of the emission direction.
  18394. */
  18395. direction2?: Vector3);
  18396. /**
  18397. * Called by the particle System when the direction is computed for the created particle.
  18398. * @param worldMatrix is the world matrix of the particle system
  18399. * @param directionToUpdate is the direction vector to update with the result
  18400. * @param particle is the particle we are computed the direction for
  18401. */
  18402. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18403. /**
  18404. * Clones the current emitter and returns a copy of it
  18405. * @returns the new emitter
  18406. */
  18407. clone(): SphereDirectedParticleEmitter;
  18408. /**
  18409. * Called by the GPUParticleSystem to setup the update shader
  18410. * @param effect defines the update shader
  18411. */
  18412. applyToShader(effect: Effect): void;
  18413. /**
  18414. * Returns a string to use to update the GPU particles update shader
  18415. * @returns a string containng the defines string
  18416. */
  18417. getEffectDefines(): string;
  18418. /**
  18419. * Returns the string "SphereDirectedParticleEmitter"
  18420. * @returns a string containing the class name
  18421. */
  18422. getClassName(): string;
  18423. /**
  18424. * Serializes the particle system to a JSON object.
  18425. * @returns the JSON object
  18426. */
  18427. serialize(): any;
  18428. /**
  18429. * Parse properties from a JSON object
  18430. * @param serializationObject defines the JSON object
  18431. */
  18432. parse(serializationObject: any): void;
  18433. }
  18434. }
  18435. declare module BABYLON {
  18436. /**
  18437. * Interface representing a particle system in Babylon.js.
  18438. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18439. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18440. */
  18441. export interface IParticleSystem {
  18442. /**
  18443. * List of animations used by the particle system.
  18444. */
  18445. animations: Animation[];
  18446. /**
  18447. * The id of the Particle system.
  18448. */
  18449. id: string;
  18450. /**
  18451. * The name of the Particle system.
  18452. */
  18453. name: string;
  18454. /**
  18455. * The emitter represents the Mesh or position we are attaching the particle system to.
  18456. */
  18457. emitter: Nullable<AbstractMesh | Vector3>;
  18458. /**
  18459. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18460. */
  18461. isBillboardBased: boolean;
  18462. /**
  18463. * The rendering group used by the Particle system to chose when to render.
  18464. */
  18465. renderingGroupId: number;
  18466. /**
  18467. * The layer mask we are rendering the particles through.
  18468. */
  18469. layerMask: number;
  18470. /**
  18471. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18472. */
  18473. updateSpeed: number;
  18474. /**
  18475. * The amount of time the particle system is running (depends of the overall update speed).
  18476. */
  18477. targetStopDuration: number;
  18478. /**
  18479. * The texture used to render each particle. (this can be a spritesheet)
  18480. */
  18481. particleTexture: Nullable<Texture>;
  18482. /**
  18483. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18484. */
  18485. blendMode: number;
  18486. /**
  18487. * Minimum life time of emitting particles.
  18488. */
  18489. minLifeTime: number;
  18490. /**
  18491. * Maximum life time of emitting particles.
  18492. */
  18493. maxLifeTime: number;
  18494. /**
  18495. * Minimum Size of emitting particles.
  18496. */
  18497. minSize: number;
  18498. /**
  18499. * Maximum Size of emitting particles.
  18500. */
  18501. maxSize: number;
  18502. /**
  18503. * Minimum scale of emitting particles on X axis.
  18504. */
  18505. minScaleX: number;
  18506. /**
  18507. * Maximum scale of emitting particles on X axis.
  18508. */
  18509. maxScaleX: number;
  18510. /**
  18511. * Minimum scale of emitting particles on Y axis.
  18512. */
  18513. minScaleY: number;
  18514. /**
  18515. * Maximum scale of emitting particles on Y axis.
  18516. */
  18517. maxScaleY: number;
  18518. /**
  18519. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18520. */
  18521. color1: Color4;
  18522. /**
  18523. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18524. */
  18525. color2: Color4;
  18526. /**
  18527. * Color the particle will have at the end of its lifetime.
  18528. */
  18529. colorDead: Color4;
  18530. /**
  18531. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18532. */
  18533. emitRate: number;
  18534. /**
  18535. * You can use gravity if you want to give an orientation to your particles.
  18536. */
  18537. gravity: Vector3;
  18538. /**
  18539. * Minimum power of emitting particles.
  18540. */
  18541. minEmitPower: number;
  18542. /**
  18543. * Maximum power of emitting particles.
  18544. */
  18545. maxEmitPower: number;
  18546. /**
  18547. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18548. */
  18549. minAngularSpeed: number;
  18550. /**
  18551. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18552. */
  18553. maxAngularSpeed: number;
  18554. /**
  18555. * Gets or sets the minimal initial rotation in radians.
  18556. */
  18557. minInitialRotation: number;
  18558. /**
  18559. * Gets or sets the maximal initial rotation in radians.
  18560. */
  18561. maxInitialRotation: number;
  18562. /**
  18563. * The particle emitter type defines the emitter used by the particle system.
  18564. * It can be for example box, sphere, or cone...
  18565. */
  18566. particleEmitterType: Nullable<IParticleEmitterType>;
  18567. /**
  18568. * Defines the delay in milliseconds before starting the system (0 by default)
  18569. */
  18570. startDelay: number;
  18571. /**
  18572. * 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
  18573. */
  18574. preWarmCycles: number;
  18575. /**
  18576. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18577. */
  18578. preWarmStepOffset: number;
  18579. /**
  18580. * 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)
  18581. */
  18582. spriteCellChangeSpeed: number;
  18583. /**
  18584. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18585. */
  18586. startSpriteCellID: number;
  18587. /**
  18588. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18589. */
  18590. endSpriteCellID: number;
  18591. /**
  18592. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18593. */
  18594. spriteCellWidth: number;
  18595. /**
  18596. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18597. */
  18598. spriteCellHeight: number;
  18599. /**
  18600. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18601. */
  18602. spriteRandomStartCell: boolean;
  18603. /**
  18604. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18605. */
  18606. isAnimationSheetEnabled: boolean;
  18607. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18608. translationPivot: Vector2;
  18609. /**
  18610. * Gets or sets a texture used to add random noise to particle positions
  18611. */
  18612. noiseTexture: Nullable<BaseTexture>;
  18613. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18614. noiseStrength: Vector3;
  18615. /**
  18616. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18617. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18618. */
  18619. billboardMode: number;
  18620. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18621. limitVelocityDamping: number;
  18622. /**
  18623. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18624. */
  18625. beginAnimationOnStart: boolean;
  18626. /**
  18627. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18628. */
  18629. beginAnimationFrom: number;
  18630. /**
  18631. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18632. */
  18633. beginAnimationTo: number;
  18634. /**
  18635. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18636. */
  18637. beginAnimationLoop: boolean;
  18638. /**
  18639. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18640. */
  18641. disposeOnStop: boolean;
  18642. /**
  18643. * Gets the maximum number of particles active at the same time.
  18644. * @returns The max number of active particles.
  18645. */
  18646. getCapacity(): number;
  18647. /**
  18648. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18649. * @returns True if it has been started, otherwise false.
  18650. */
  18651. isStarted(): boolean;
  18652. /**
  18653. * Animates the particle system for this frame.
  18654. */
  18655. animate(): void;
  18656. /**
  18657. * Renders the particle system in its current state.
  18658. * @returns the current number of particles
  18659. */
  18660. render(): number;
  18661. /**
  18662. * Dispose the particle system and frees its associated resources.
  18663. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18664. */
  18665. dispose(disposeTexture?: boolean): void;
  18666. /**
  18667. * Clones the particle system.
  18668. * @param name The name of the cloned object
  18669. * @param newEmitter The new emitter to use
  18670. * @returns the cloned particle system
  18671. */
  18672. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18673. /**
  18674. * Serializes the particle system to a JSON object.
  18675. * @returns the JSON object
  18676. */
  18677. serialize(): any;
  18678. /**
  18679. * Rebuild the particle system
  18680. */
  18681. rebuild(): void;
  18682. /**
  18683. * Starts the particle system and begins to emit
  18684. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18685. */
  18686. start(delay?: number): void;
  18687. /**
  18688. * Stops the particle system.
  18689. */
  18690. stop(): void;
  18691. /**
  18692. * Remove all active particles
  18693. */
  18694. reset(): void;
  18695. /**
  18696. * Is this system ready to be used/rendered
  18697. * @return true if the system is ready
  18698. */
  18699. isReady(): boolean;
  18700. /**
  18701. * Adds a new color gradient
  18702. * @param gradient defines the gradient to use (between 0 and 1)
  18703. * @param color1 defines the color to affect to the specified gradient
  18704. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18705. * @returns the current particle system
  18706. */
  18707. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18708. /**
  18709. * Remove a specific color gradient
  18710. * @param gradient defines the gradient to remove
  18711. * @returns the current particle system
  18712. */
  18713. removeColorGradient(gradient: number): IParticleSystem;
  18714. /**
  18715. * Adds a new size gradient
  18716. * @param gradient defines the gradient to use (between 0 and 1)
  18717. * @param factor defines the size factor to affect to the specified gradient
  18718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18719. * @returns the current particle system
  18720. */
  18721. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18722. /**
  18723. * Remove a specific size gradient
  18724. * @param gradient defines the gradient to remove
  18725. * @returns the current particle system
  18726. */
  18727. removeSizeGradient(gradient: number): IParticleSystem;
  18728. /**
  18729. * Gets the current list of color gradients.
  18730. * You must use addColorGradient and removeColorGradient to udpate this list
  18731. * @returns the list of color gradients
  18732. */
  18733. getColorGradients(): Nullable<Array<ColorGradient>>;
  18734. /**
  18735. * Gets the current list of size gradients.
  18736. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18737. * @returns the list of size gradients
  18738. */
  18739. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18740. /**
  18741. * Gets the current list of angular speed gradients.
  18742. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18743. * @returns the list of angular speed gradients
  18744. */
  18745. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18746. /**
  18747. * Adds a new angular speed gradient
  18748. * @param gradient defines the gradient to use (between 0 and 1)
  18749. * @param factor defines the angular speed to affect to the specified gradient
  18750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18751. * @returns the current particle system
  18752. */
  18753. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18754. /**
  18755. * Remove a specific angular speed gradient
  18756. * @param gradient defines the gradient to remove
  18757. * @returns the current particle system
  18758. */
  18759. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18760. /**
  18761. * Gets the current list of velocity gradients.
  18762. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18763. * @returns the list of velocity gradients
  18764. */
  18765. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18766. /**
  18767. * Adds a new velocity gradient
  18768. * @param gradient defines the gradient to use (between 0 and 1)
  18769. * @param factor defines the velocity to affect to the specified gradient
  18770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18771. * @returns the current particle system
  18772. */
  18773. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18774. /**
  18775. * Remove a specific velocity gradient
  18776. * @param gradient defines the gradient to remove
  18777. * @returns the current particle system
  18778. */
  18779. removeVelocityGradient(gradient: number): IParticleSystem;
  18780. /**
  18781. * Gets the current list of limit velocity gradients.
  18782. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18783. * @returns the list of limit velocity gradients
  18784. */
  18785. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18786. /**
  18787. * Adds a new limit velocity gradient
  18788. * @param gradient defines the gradient to use (between 0 and 1)
  18789. * @param factor defines the limit velocity to affect to the specified gradient
  18790. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18791. * @returns the current particle system
  18792. */
  18793. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18794. /**
  18795. * Remove a specific limit velocity gradient
  18796. * @param gradient defines the gradient to remove
  18797. * @returns the current particle system
  18798. */
  18799. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18800. /**
  18801. * Adds a new drag gradient
  18802. * @param gradient defines the gradient to use (between 0 and 1)
  18803. * @param factor defines the drag to affect to the specified gradient
  18804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18805. * @returns the current particle system
  18806. */
  18807. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18808. /**
  18809. * Remove a specific drag gradient
  18810. * @param gradient defines the gradient to remove
  18811. * @returns the current particle system
  18812. */
  18813. removeDragGradient(gradient: number): IParticleSystem;
  18814. /**
  18815. * Gets the current list of drag gradients.
  18816. * You must use addDragGradient and removeDragGradient to udpate this list
  18817. * @returns the list of drag gradients
  18818. */
  18819. getDragGradients(): Nullable<Array<FactorGradient>>;
  18820. /**
  18821. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18822. * @param gradient defines the gradient to use (between 0 and 1)
  18823. * @param factor defines the emit rate to affect to the specified gradient
  18824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18825. * @returns the current particle system
  18826. */
  18827. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18828. /**
  18829. * Remove a specific emit rate gradient
  18830. * @param gradient defines the gradient to remove
  18831. * @returns the current particle system
  18832. */
  18833. removeEmitRateGradient(gradient: number): IParticleSystem;
  18834. /**
  18835. * Gets the current list of emit rate gradients.
  18836. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18837. * @returns the list of emit rate gradients
  18838. */
  18839. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18840. /**
  18841. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18842. * @param gradient defines the gradient to use (between 0 and 1)
  18843. * @param factor defines the start size to affect to the specified gradient
  18844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18845. * @returns the current particle system
  18846. */
  18847. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18848. /**
  18849. * Remove a specific start size gradient
  18850. * @param gradient defines the gradient to remove
  18851. * @returns the current particle system
  18852. */
  18853. removeStartSizeGradient(gradient: number): IParticleSystem;
  18854. /**
  18855. * Gets the current list of start size gradients.
  18856. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18857. * @returns the list of start size gradients
  18858. */
  18859. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18860. /**
  18861. * Adds a new life time gradient
  18862. * @param gradient defines the gradient to use (between 0 and 1)
  18863. * @param factor defines the life time factor to affect to the specified gradient
  18864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18865. * @returns the current particle system
  18866. */
  18867. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18868. /**
  18869. * Remove a specific life time gradient
  18870. * @param gradient defines the gradient to remove
  18871. * @returns the current particle system
  18872. */
  18873. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18874. /**
  18875. * Gets the current list of life time gradients.
  18876. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18877. * @returns the list of life time gradients
  18878. */
  18879. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18880. /**
  18881. * Gets the current list of color gradients.
  18882. * You must use addColorGradient and removeColorGradient to udpate this list
  18883. * @returns the list of color gradients
  18884. */
  18885. getColorGradients(): Nullable<Array<ColorGradient>>;
  18886. /**
  18887. * Adds a new ramp gradient used to remap particle colors
  18888. * @param gradient defines the gradient to use (between 0 and 1)
  18889. * @param color defines the color to affect to the specified gradient
  18890. * @returns the current particle system
  18891. */
  18892. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18893. /**
  18894. * Gets the current list of ramp gradients.
  18895. * You must use addRampGradient and removeRampGradient to udpate this list
  18896. * @returns the list of ramp gradients
  18897. */
  18898. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18899. /** Gets or sets a boolean indicating that ramp gradients must be used
  18900. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18901. */
  18902. useRampGradients: boolean;
  18903. /**
  18904. * Adds a new color remap gradient
  18905. * @param gradient defines the gradient to use (between 0 and 1)
  18906. * @param min defines the color remap minimal range
  18907. * @param max defines the color remap maximal range
  18908. * @returns the current particle system
  18909. */
  18910. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18911. /**
  18912. * Gets the current list of color remap gradients.
  18913. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18914. * @returns the list of color remap gradients
  18915. */
  18916. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18917. /**
  18918. * Adds a new alpha remap gradient
  18919. * @param gradient defines the gradient to use (between 0 and 1)
  18920. * @param min defines the alpha remap minimal range
  18921. * @param max defines the alpha remap maximal range
  18922. * @returns the current particle system
  18923. */
  18924. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18925. /**
  18926. * Gets the current list of alpha remap gradients.
  18927. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18928. * @returns the list of alpha remap gradients
  18929. */
  18930. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18931. /**
  18932. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18933. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18934. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18935. * @returns the emitter
  18936. */
  18937. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18938. /**
  18939. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18940. * @param radius The radius of the hemisphere to emit from
  18941. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18942. * @returns the emitter
  18943. */
  18944. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18945. /**
  18946. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18947. * @param radius The radius of the sphere to emit from
  18948. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18949. * @returns the emitter
  18950. */
  18951. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18952. /**
  18953. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18954. * @param radius The radius of the sphere to emit from
  18955. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18956. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18957. * @returns the emitter
  18958. */
  18959. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18960. /**
  18961. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18962. * @param radius The radius of the emission cylinder
  18963. * @param height The height of the emission cylinder
  18964. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18965. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18966. * @returns the emitter
  18967. */
  18968. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18969. /**
  18970. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18971. * @param radius The radius of the cylinder to emit from
  18972. * @param height The height of the emission cylinder
  18973. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18974. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18975. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18976. * @returns the emitter
  18977. */
  18978. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18979. /**
  18980. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18981. * @param radius The radius of the cone to emit from
  18982. * @param angle The base angle of the cone
  18983. * @returns the emitter
  18984. */
  18985. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18986. /**
  18987. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18988. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18989. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18990. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18991. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18992. * @returns the emitter
  18993. */
  18994. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18995. /**
  18996. * Get hosting scene
  18997. * @returns the scene
  18998. */
  18999. getScene(): Scene;
  19000. }
  19001. }
  19002. declare module BABYLON {
  19003. /**
  19004. * Creates an instance based on a source mesh.
  19005. */
  19006. export class InstancedMesh extends AbstractMesh {
  19007. private _sourceMesh;
  19008. private _currentLOD;
  19009. /** @hidden */
  19010. _indexInSourceMeshInstanceArray: number;
  19011. constructor(name: string, source: Mesh);
  19012. /**
  19013. * Returns the string "InstancedMesh".
  19014. */
  19015. getClassName(): string;
  19016. /** Gets the list of lights affecting that mesh */
  19017. readonly lightSources: Light[];
  19018. _resyncLightSources(): void;
  19019. _resyncLightSource(light: Light): void;
  19020. _removeLightSource(light: Light, dispose: boolean): void;
  19021. /**
  19022. * If the source mesh receives shadows
  19023. */
  19024. readonly receiveShadows: boolean;
  19025. /**
  19026. * The material of the source mesh
  19027. */
  19028. readonly material: Nullable<Material>;
  19029. /**
  19030. * Visibility of the source mesh
  19031. */
  19032. readonly visibility: number;
  19033. /**
  19034. * Skeleton of the source mesh
  19035. */
  19036. readonly skeleton: Nullable<Skeleton>;
  19037. /**
  19038. * Rendering ground id of the source mesh
  19039. */
  19040. renderingGroupId: number;
  19041. /**
  19042. * Returns the total number of vertices (integer).
  19043. */
  19044. getTotalVertices(): number;
  19045. /**
  19046. * Returns a positive integer : the total number of indices in this mesh geometry.
  19047. * @returns the numner of indices or zero if the mesh has no geometry.
  19048. */
  19049. getTotalIndices(): number;
  19050. /**
  19051. * The source mesh of the instance
  19052. */
  19053. readonly sourceMesh: Mesh;
  19054. /**
  19055. * Is this node ready to be used/rendered
  19056. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19057. * @return {boolean} is it ready
  19058. */
  19059. isReady(completeCheck?: boolean): boolean;
  19060. /**
  19061. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19062. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19063. * @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.
  19064. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19065. */
  19066. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19067. /**
  19068. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19069. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19070. * The `data` are either a numeric array either a Float32Array.
  19071. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19072. * 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).
  19073. * Note that a new underlying VertexBuffer object is created each call.
  19074. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19075. *
  19076. * Possible `kind` values :
  19077. * - VertexBuffer.PositionKind
  19078. * - VertexBuffer.UVKind
  19079. * - VertexBuffer.UV2Kind
  19080. * - VertexBuffer.UV3Kind
  19081. * - VertexBuffer.UV4Kind
  19082. * - VertexBuffer.UV5Kind
  19083. * - VertexBuffer.UV6Kind
  19084. * - VertexBuffer.ColorKind
  19085. * - VertexBuffer.MatricesIndicesKind
  19086. * - VertexBuffer.MatricesIndicesExtraKind
  19087. * - VertexBuffer.MatricesWeightsKind
  19088. * - VertexBuffer.MatricesWeightsExtraKind
  19089. *
  19090. * Returns the Mesh.
  19091. */
  19092. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19093. /**
  19094. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19095. * If the mesh has no geometry, it is simply returned as it is.
  19096. * The `data` are either a numeric array either a Float32Array.
  19097. * No new underlying VertexBuffer object is created.
  19098. * 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.
  19099. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19100. *
  19101. * Possible `kind` values :
  19102. * - VertexBuffer.PositionKind
  19103. * - VertexBuffer.UVKind
  19104. * - VertexBuffer.UV2Kind
  19105. * - VertexBuffer.UV3Kind
  19106. * - VertexBuffer.UV4Kind
  19107. * - VertexBuffer.UV5Kind
  19108. * - VertexBuffer.UV6Kind
  19109. * - VertexBuffer.ColorKind
  19110. * - VertexBuffer.MatricesIndicesKind
  19111. * - VertexBuffer.MatricesIndicesExtraKind
  19112. * - VertexBuffer.MatricesWeightsKind
  19113. * - VertexBuffer.MatricesWeightsExtraKind
  19114. *
  19115. * Returns the Mesh.
  19116. */
  19117. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19118. /**
  19119. * Sets the mesh indices.
  19120. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19121. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19122. * This method creates a new index buffer each call.
  19123. * Returns the Mesh.
  19124. */
  19125. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19126. /**
  19127. * Boolean : True if the mesh owns the requested kind of data.
  19128. */
  19129. isVerticesDataPresent(kind: string): boolean;
  19130. /**
  19131. * Returns an array of indices (IndicesArray).
  19132. */
  19133. getIndices(): Nullable<IndicesArray>;
  19134. readonly _positions: Nullable<Vector3[]>;
  19135. /**
  19136. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19137. * This means the mesh underlying bounding box and sphere are recomputed.
  19138. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19139. * @returns the current mesh
  19140. */
  19141. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19142. /** @hidden */
  19143. _preActivate(): InstancedMesh;
  19144. /** @hidden */
  19145. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19146. /** @hidden */
  19147. _postActivate(): void;
  19148. getWorldMatrix(): Matrix;
  19149. readonly isAnInstance: boolean;
  19150. /**
  19151. * Returns the current associated LOD AbstractMesh.
  19152. */
  19153. getLOD(camera: Camera): AbstractMesh;
  19154. /** @hidden */
  19155. _syncSubMeshes(): InstancedMesh;
  19156. /** @hidden */
  19157. _generatePointsArray(): boolean;
  19158. /**
  19159. * Creates a new InstancedMesh from the current mesh.
  19160. * - name (string) : the cloned mesh name
  19161. * - newParent (optional Node) : the optional Node to parent the clone to.
  19162. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19163. *
  19164. * Returns the clone.
  19165. */
  19166. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19167. /**
  19168. * Disposes the InstancedMesh.
  19169. * Returns nothing.
  19170. */
  19171. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19172. }
  19173. interface Mesh {
  19174. /**
  19175. * Register a custom buffer that will be instanced
  19176. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19177. * @param kind defines the buffer kind
  19178. * @param stride defines the stride in floats
  19179. */
  19180. registerInstancedBuffer(kind: string, stride: number): void;
  19181. /** @hidden */
  19182. _userInstancedBuffersStorage: {
  19183. data: {
  19184. [key: string]: Float32Array;
  19185. };
  19186. sizes: {
  19187. [key: string]: number;
  19188. };
  19189. vertexBuffers: {
  19190. [key: string]: Nullable<VertexBuffer>;
  19191. };
  19192. strides: {
  19193. [key: string]: number;
  19194. };
  19195. };
  19196. }
  19197. interface AbstractMesh {
  19198. /**
  19199. * Object used to store instanced buffers defined by user
  19200. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19201. */
  19202. instancedBuffers: {
  19203. [key: string]: any;
  19204. };
  19205. }
  19206. }
  19207. declare module BABYLON {
  19208. /**
  19209. * Defines the options associated with the creation of a shader material.
  19210. */
  19211. export interface IShaderMaterialOptions {
  19212. /**
  19213. * Does the material work in alpha blend mode
  19214. */
  19215. needAlphaBlending: boolean;
  19216. /**
  19217. * Does the material work in alpha test mode
  19218. */
  19219. needAlphaTesting: boolean;
  19220. /**
  19221. * The list of attribute names used in the shader
  19222. */
  19223. attributes: string[];
  19224. /**
  19225. * The list of unifrom names used in the shader
  19226. */
  19227. uniforms: string[];
  19228. /**
  19229. * The list of UBO names used in the shader
  19230. */
  19231. uniformBuffers: string[];
  19232. /**
  19233. * The list of sampler names used in the shader
  19234. */
  19235. samplers: string[];
  19236. /**
  19237. * The list of defines used in the shader
  19238. */
  19239. defines: string[];
  19240. }
  19241. /**
  19242. * 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.
  19243. *
  19244. * This returned material effects how the mesh will look based on the code in the shaders.
  19245. *
  19246. * @see http://doc.babylonjs.com/how_to/shader_material
  19247. */
  19248. export class ShaderMaterial extends Material {
  19249. private _shaderPath;
  19250. private _options;
  19251. private _textures;
  19252. private _textureArrays;
  19253. private _floats;
  19254. private _ints;
  19255. private _floatsArrays;
  19256. private _colors3;
  19257. private _colors3Arrays;
  19258. private _colors4;
  19259. private _colors4Arrays;
  19260. private _vectors2;
  19261. private _vectors3;
  19262. private _vectors4;
  19263. private _matrices;
  19264. private _matrixArrays;
  19265. private _matrices3x3;
  19266. private _matrices2x2;
  19267. private _vectors2Arrays;
  19268. private _vectors3Arrays;
  19269. private _vectors4Arrays;
  19270. private _cachedWorldViewMatrix;
  19271. private _cachedWorldViewProjectionMatrix;
  19272. private _renderId;
  19273. private _multiview;
  19274. /**
  19275. * Instantiate a new shader material.
  19276. * 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.
  19277. * This returned material effects how the mesh will look based on the code in the shaders.
  19278. * @see http://doc.babylonjs.com/how_to/shader_material
  19279. * @param name Define the name of the material in the scene
  19280. * @param scene Define the scene the material belongs to
  19281. * @param shaderPath Defines the route to the shader code in one of three ways:
  19282. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19283. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19284. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19285. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19286. * @param options Define the options used to create the shader
  19287. */
  19288. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19289. /**
  19290. * Gets the shader path used to define the shader code
  19291. * It can be modified to trigger a new compilation
  19292. */
  19293. /**
  19294. * Sets the shader path used to define the shader code
  19295. * It can be modified to trigger a new compilation
  19296. */
  19297. shaderPath: any;
  19298. /**
  19299. * Gets the options used to compile the shader.
  19300. * They can be modified to trigger a new compilation
  19301. */
  19302. readonly options: IShaderMaterialOptions;
  19303. /**
  19304. * Gets the current class name of the material e.g. "ShaderMaterial"
  19305. * Mainly use in serialization.
  19306. * @returns the class name
  19307. */
  19308. getClassName(): string;
  19309. /**
  19310. * Specifies if the material will require alpha blending
  19311. * @returns a boolean specifying if alpha blending is needed
  19312. */
  19313. needAlphaBlending(): boolean;
  19314. /**
  19315. * Specifies if this material should be rendered in alpha test mode
  19316. * @returns a boolean specifying if an alpha test is needed.
  19317. */
  19318. needAlphaTesting(): boolean;
  19319. private _checkUniform;
  19320. /**
  19321. * Set a texture in the shader.
  19322. * @param name Define the name of the uniform samplers as defined in the shader
  19323. * @param texture Define the texture to bind to this sampler
  19324. * @return the material itself allowing "fluent" like uniform updates
  19325. */
  19326. setTexture(name: string, texture: Texture): ShaderMaterial;
  19327. /**
  19328. * Set a texture array in the shader.
  19329. * @param name Define the name of the uniform sampler array as defined in the shader
  19330. * @param textures Define the list of textures to bind to this sampler
  19331. * @return the material itself allowing "fluent" like uniform updates
  19332. */
  19333. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19334. /**
  19335. * Set a float in the shader.
  19336. * @param name Define the name of the uniform as defined in the shader
  19337. * @param value Define the value to give to the uniform
  19338. * @return the material itself allowing "fluent" like uniform updates
  19339. */
  19340. setFloat(name: string, value: number): ShaderMaterial;
  19341. /**
  19342. * Set a int in the shader.
  19343. * @param name Define the name of the uniform as defined in the shader
  19344. * @param value Define the value to give to the uniform
  19345. * @return the material itself allowing "fluent" like uniform updates
  19346. */
  19347. setInt(name: string, value: number): ShaderMaterial;
  19348. /**
  19349. * Set an array of floats in the shader.
  19350. * @param name Define the name of the uniform as defined in the shader
  19351. * @param value Define the value to give to the uniform
  19352. * @return the material itself allowing "fluent" like uniform updates
  19353. */
  19354. setFloats(name: string, value: number[]): ShaderMaterial;
  19355. /**
  19356. * Set a vec3 in the shader from a Color3.
  19357. * @param name Define the name of the uniform as defined in the shader
  19358. * @param value Define the value to give to the uniform
  19359. * @return the material itself allowing "fluent" like uniform updates
  19360. */
  19361. setColor3(name: string, value: Color3): ShaderMaterial;
  19362. /**
  19363. * Set a vec3 array in the shader from a Color3 array.
  19364. * @param name Define the name of the uniform as defined in the shader
  19365. * @param value Define the value to give to the uniform
  19366. * @return the material itself allowing "fluent" like uniform updates
  19367. */
  19368. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19369. /**
  19370. * Set a vec4 in the shader from a Color4.
  19371. * @param name Define the name of the uniform as defined in the shader
  19372. * @param value Define the value to give to the uniform
  19373. * @return the material itself allowing "fluent" like uniform updates
  19374. */
  19375. setColor4(name: string, value: Color4): ShaderMaterial;
  19376. /**
  19377. * Set a vec4 array in the shader from a Color4 array.
  19378. * @param name Define the name of the uniform as defined in the shader
  19379. * @param value Define the value to give to the uniform
  19380. * @return the material itself allowing "fluent" like uniform updates
  19381. */
  19382. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19383. /**
  19384. * Set a vec2 in the shader from a Vector2.
  19385. * @param name Define the name of the uniform as defined in the shader
  19386. * @param value Define the value to give to the uniform
  19387. * @return the material itself allowing "fluent" like uniform updates
  19388. */
  19389. setVector2(name: string, value: Vector2): ShaderMaterial;
  19390. /**
  19391. * Set a vec3 in the shader from a Vector3.
  19392. * @param name Define the name of the uniform as defined in the shader
  19393. * @param value Define the value to give to the uniform
  19394. * @return the material itself allowing "fluent" like uniform updates
  19395. */
  19396. setVector3(name: string, value: Vector3): ShaderMaterial;
  19397. /**
  19398. * Set a vec4 in the shader from a Vector4.
  19399. * @param name Define the name of the uniform as defined in the shader
  19400. * @param value Define the value to give to the uniform
  19401. * @return the material itself allowing "fluent" like uniform updates
  19402. */
  19403. setVector4(name: string, value: Vector4): ShaderMaterial;
  19404. /**
  19405. * Set a mat4 in the shader from a Matrix.
  19406. * @param name Define the name of the uniform as defined in the shader
  19407. * @param value Define the value to give to the uniform
  19408. * @return the material itself allowing "fluent" like uniform updates
  19409. */
  19410. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19411. /**
  19412. * Set a float32Array in the shader from a matrix array.
  19413. * @param name Define the name of the uniform as defined in the shader
  19414. * @param value Define the value to give to the uniform
  19415. * @return the material itself allowing "fluent" like uniform updates
  19416. */
  19417. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19418. /**
  19419. * Set a mat3 in the shader from a Float32Array.
  19420. * @param name Define the name of the uniform as defined in the shader
  19421. * @param value Define the value to give to the uniform
  19422. * @return the material itself allowing "fluent" like uniform updates
  19423. */
  19424. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19425. /**
  19426. * Set a mat2 in the shader from a Float32Array.
  19427. * @param name Define the name of the uniform as defined in the shader
  19428. * @param value Define the value to give to the uniform
  19429. * @return the material itself allowing "fluent" like uniform updates
  19430. */
  19431. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19432. /**
  19433. * Set a vec2 array in the shader from a number array.
  19434. * @param name Define the name of the uniform as defined in the shader
  19435. * @param value Define the value to give to the uniform
  19436. * @return the material itself allowing "fluent" like uniform updates
  19437. */
  19438. setArray2(name: string, value: number[]): ShaderMaterial;
  19439. /**
  19440. * Set a vec3 array in the shader from a number array.
  19441. * @param name Define the name of the uniform as defined in the shader
  19442. * @param value Define the value to give to the uniform
  19443. * @return the material itself allowing "fluent" like uniform updates
  19444. */
  19445. setArray3(name: string, value: number[]): ShaderMaterial;
  19446. /**
  19447. * Set a vec4 array in the shader from a number array.
  19448. * @param name Define the name of the uniform as defined in the shader
  19449. * @param value Define the value to give to the uniform
  19450. * @return the material itself allowing "fluent" like uniform updates
  19451. */
  19452. setArray4(name: string, value: number[]): ShaderMaterial;
  19453. private _checkCache;
  19454. /**
  19455. * Specifies that the submesh is ready to be used
  19456. * @param mesh defines the mesh to check
  19457. * @param subMesh defines which submesh to check
  19458. * @param useInstances specifies that instances should be used
  19459. * @returns a boolean indicating that the submesh is ready or not
  19460. */
  19461. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19462. /**
  19463. * Checks if the material is ready to render the requested mesh
  19464. * @param mesh Define the mesh to render
  19465. * @param useInstances Define whether or not the material is used with instances
  19466. * @returns true if ready, otherwise false
  19467. */
  19468. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19469. /**
  19470. * Binds the world matrix to the material
  19471. * @param world defines the world transformation matrix
  19472. */
  19473. bindOnlyWorldMatrix(world: Matrix): void;
  19474. /**
  19475. * Binds the material to the mesh
  19476. * @param world defines the world transformation matrix
  19477. * @param mesh defines the mesh to bind the material to
  19478. */
  19479. bind(world: Matrix, mesh?: Mesh): void;
  19480. /**
  19481. * Gets the active textures from the material
  19482. * @returns an array of textures
  19483. */
  19484. getActiveTextures(): BaseTexture[];
  19485. /**
  19486. * Specifies if the material uses a texture
  19487. * @param texture defines the texture to check against the material
  19488. * @returns a boolean specifying if the material uses the texture
  19489. */
  19490. hasTexture(texture: BaseTexture): boolean;
  19491. /**
  19492. * Makes a duplicate of the material, and gives it a new name
  19493. * @param name defines the new name for the duplicated material
  19494. * @returns the cloned material
  19495. */
  19496. clone(name: string): ShaderMaterial;
  19497. /**
  19498. * Disposes the material
  19499. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19500. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19501. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19502. */
  19503. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19504. /**
  19505. * Serializes this material in a JSON representation
  19506. * @returns the serialized material object
  19507. */
  19508. serialize(): any;
  19509. /**
  19510. * Creates a shader material from parsed shader material data
  19511. * @param source defines the JSON represnetation of the material
  19512. * @param scene defines the hosting scene
  19513. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19514. * @returns a new material
  19515. */
  19516. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19517. }
  19518. }
  19519. declare module BABYLON {
  19520. /** @hidden */
  19521. export var colorPixelShader: {
  19522. name: string;
  19523. shader: string;
  19524. };
  19525. }
  19526. declare module BABYLON {
  19527. /** @hidden */
  19528. export var colorVertexShader: {
  19529. name: string;
  19530. shader: string;
  19531. };
  19532. }
  19533. declare module BABYLON {
  19534. /**
  19535. * Line mesh
  19536. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19537. */
  19538. export class LinesMesh extends Mesh {
  19539. /**
  19540. * If vertex color should be applied to the mesh
  19541. */
  19542. readonly useVertexColor?: boolean | undefined;
  19543. /**
  19544. * If vertex alpha should be applied to the mesh
  19545. */
  19546. readonly useVertexAlpha?: boolean | undefined;
  19547. /**
  19548. * Color of the line (Default: White)
  19549. */
  19550. color: Color3;
  19551. /**
  19552. * Alpha of the line (Default: 1)
  19553. */
  19554. alpha: number;
  19555. /**
  19556. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19557. * This margin is expressed in world space coordinates, so its value may vary.
  19558. * Default value is 0.1
  19559. */
  19560. intersectionThreshold: number;
  19561. private _colorShader;
  19562. private color4;
  19563. /**
  19564. * Creates a new LinesMesh
  19565. * @param name defines the name
  19566. * @param scene defines the hosting scene
  19567. * @param parent defines the parent mesh if any
  19568. * @param source defines the optional source LinesMesh used to clone data from
  19569. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19570. * When false, achieved by calling a clone(), also passing False.
  19571. * This will make creation of children, recursive.
  19572. * @param useVertexColor defines if this LinesMesh supports vertex color
  19573. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19574. */
  19575. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19576. /**
  19577. * If vertex color should be applied to the mesh
  19578. */
  19579. useVertexColor?: boolean | undefined,
  19580. /**
  19581. * If vertex alpha should be applied to the mesh
  19582. */
  19583. useVertexAlpha?: boolean | undefined);
  19584. private _addClipPlaneDefine;
  19585. private _removeClipPlaneDefine;
  19586. isReady(): boolean;
  19587. /**
  19588. * Returns the string "LineMesh"
  19589. */
  19590. getClassName(): string;
  19591. /**
  19592. * @hidden
  19593. */
  19594. /**
  19595. * @hidden
  19596. */
  19597. material: Material;
  19598. /**
  19599. * @hidden
  19600. */
  19601. readonly checkCollisions: boolean;
  19602. /** @hidden */
  19603. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19604. /** @hidden */
  19605. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19606. /**
  19607. * Disposes of the line mesh
  19608. * @param doNotRecurse If children should be disposed
  19609. */
  19610. dispose(doNotRecurse?: boolean): void;
  19611. /**
  19612. * Returns a new LineMesh object cloned from the current one.
  19613. */
  19614. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19615. /**
  19616. * Creates a new InstancedLinesMesh object from the mesh model.
  19617. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19618. * @param name defines the name of the new instance
  19619. * @returns a new InstancedLinesMesh
  19620. */
  19621. createInstance(name: string): InstancedLinesMesh;
  19622. }
  19623. /**
  19624. * Creates an instance based on a source LinesMesh
  19625. */
  19626. export class InstancedLinesMesh extends InstancedMesh {
  19627. /**
  19628. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19629. * This margin is expressed in world space coordinates, so its value may vary.
  19630. * Initilized with the intersectionThreshold value of the source LinesMesh
  19631. */
  19632. intersectionThreshold: number;
  19633. constructor(name: string, source: LinesMesh);
  19634. /**
  19635. * Returns the string "InstancedLinesMesh".
  19636. */
  19637. getClassName(): string;
  19638. }
  19639. }
  19640. declare module BABYLON {
  19641. /** @hidden */
  19642. export var linePixelShader: {
  19643. name: string;
  19644. shader: string;
  19645. };
  19646. }
  19647. declare module BABYLON {
  19648. /** @hidden */
  19649. export var lineVertexShader: {
  19650. name: string;
  19651. shader: string;
  19652. };
  19653. }
  19654. declare module BABYLON {
  19655. interface AbstractMesh {
  19656. /**
  19657. * Gets the edgesRenderer associated with the mesh
  19658. */
  19659. edgesRenderer: Nullable<EdgesRenderer>;
  19660. }
  19661. interface LinesMesh {
  19662. /**
  19663. * Enables the edge rendering mode on the mesh.
  19664. * This mode makes the mesh edges visible
  19665. * @param epsilon defines the maximal distance between two angles to detect a face
  19666. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19667. * @returns the currentAbstractMesh
  19668. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19669. */
  19670. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19671. }
  19672. interface InstancedLinesMesh {
  19673. /**
  19674. * Enables the edge rendering mode on the mesh.
  19675. * This mode makes the mesh edges visible
  19676. * @param epsilon defines the maximal distance between two angles to detect a face
  19677. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19678. * @returns the current InstancedLinesMesh
  19679. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19680. */
  19681. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19682. }
  19683. /**
  19684. * Defines the minimum contract an Edges renderer should follow.
  19685. */
  19686. export interface IEdgesRenderer extends IDisposable {
  19687. /**
  19688. * Gets or sets a boolean indicating if the edgesRenderer is active
  19689. */
  19690. isEnabled: boolean;
  19691. /**
  19692. * Renders the edges of the attached mesh,
  19693. */
  19694. render(): void;
  19695. /**
  19696. * Checks wether or not the edges renderer is ready to render.
  19697. * @return true if ready, otherwise false.
  19698. */
  19699. isReady(): boolean;
  19700. }
  19701. /**
  19702. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19703. */
  19704. export class EdgesRenderer implements IEdgesRenderer {
  19705. /**
  19706. * Define the size of the edges with an orthographic camera
  19707. */
  19708. edgesWidthScalerForOrthographic: number;
  19709. /**
  19710. * Define the size of the edges with a perspective camera
  19711. */
  19712. edgesWidthScalerForPerspective: number;
  19713. protected _source: AbstractMesh;
  19714. protected _linesPositions: number[];
  19715. protected _linesNormals: number[];
  19716. protected _linesIndices: number[];
  19717. protected _epsilon: number;
  19718. protected _indicesCount: number;
  19719. protected _lineShader: ShaderMaterial;
  19720. protected _ib: DataBuffer;
  19721. protected _buffers: {
  19722. [key: string]: Nullable<VertexBuffer>;
  19723. };
  19724. protected _checkVerticesInsteadOfIndices: boolean;
  19725. private _meshRebuildObserver;
  19726. private _meshDisposeObserver;
  19727. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19728. isEnabled: boolean;
  19729. /**
  19730. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19731. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19732. * @param source Mesh used to create edges
  19733. * @param epsilon sum of angles in adjacency to check for edge
  19734. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19735. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19736. */
  19737. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19738. protected _prepareRessources(): void;
  19739. /** @hidden */
  19740. _rebuild(): void;
  19741. /**
  19742. * Releases the required resources for the edges renderer
  19743. */
  19744. dispose(): void;
  19745. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19746. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19747. /**
  19748. * Checks if the pair of p0 and p1 is en edge
  19749. * @param faceIndex
  19750. * @param edge
  19751. * @param faceNormals
  19752. * @param p0
  19753. * @param p1
  19754. * @private
  19755. */
  19756. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19757. /**
  19758. * push line into the position, normal and index buffer
  19759. * @protected
  19760. */
  19761. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19762. /**
  19763. * Generates lines edges from adjacencjes
  19764. * @private
  19765. */
  19766. _generateEdgesLines(): void;
  19767. /**
  19768. * Checks wether or not the edges renderer is ready to render.
  19769. * @return true if ready, otherwise false.
  19770. */
  19771. isReady(): boolean;
  19772. /**
  19773. * Renders the edges of the attached mesh,
  19774. */
  19775. render(): void;
  19776. }
  19777. /**
  19778. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19779. */
  19780. export class LineEdgesRenderer extends EdgesRenderer {
  19781. /**
  19782. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19783. * @param source LineMesh used to generate edges
  19784. * @param epsilon not important (specified angle for edge detection)
  19785. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19786. */
  19787. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19788. /**
  19789. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19790. */
  19791. _generateEdgesLines(): void;
  19792. }
  19793. }
  19794. declare module BABYLON {
  19795. /**
  19796. * This represents the object necessary to create a rendering group.
  19797. * This is exclusively used and created by the rendering manager.
  19798. * To modify the behavior, you use the available helpers in your scene or meshes.
  19799. * @hidden
  19800. */
  19801. export class RenderingGroup {
  19802. index: number;
  19803. private static _zeroVector;
  19804. private _scene;
  19805. private _opaqueSubMeshes;
  19806. private _transparentSubMeshes;
  19807. private _alphaTestSubMeshes;
  19808. private _depthOnlySubMeshes;
  19809. private _particleSystems;
  19810. private _spriteManagers;
  19811. private _opaqueSortCompareFn;
  19812. private _alphaTestSortCompareFn;
  19813. private _transparentSortCompareFn;
  19814. private _renderOpaque;
  19815. private _renderAlphaTest;
  19816. private _renderTransparent;
  19817. /** @hidden */
  19818. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19819. onBeforeTransparentRendering: () => void;
  19820. /**
  19821. * Set the opaque sort comparison function.
  19822. * If null the sub meshes will be render in the order they were created
  19823. */
  19824. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19825. /**
  19826. * Set the alpha test sort comparison function.
  19827. * If null the sub meshes will be render in the order they were created
  19828. */
  19829. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19830. /**
  19831. * Set the transparent sort comparison function.
  19832. * If null the sub meshes will be render in the order they were created
  19833. */
  19834. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19835. /**
  19836. * Creates a new rendering group.
  19837. * @param index The rendering group index
  19838. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19839. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19840. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19841. */
  19842. 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>);
  19843. /**
  19844. * Render all the sub meshes contained in the group.
  19845. * @param customRenderFunction Used to override the default render behaviour of the group.
  19846. * @returns true if rendered some submeshes.
  19847. */
  19848. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19849. /**
  19850. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19851. * @param subMeshes The submeshes to render
  19852. */
  19853. private renderOpaqueSorted;
  19854. /**
  19855. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19856. * @param subMeshes The submeshes to render
  19857. */
  19858. private renderAlphaTestSorted;
  19859. /**
  19860. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19861. * @param subMeshes The submeshes to render
  19862. */
  19863. private renderTransparentSorted;
  19864. /**
  19865. * Renders the submeshes in a specified order.
  19866. * @param subMeshes The submeshes to sort before render
  19867. * @param sortCompareFn The comparison function use to sort
  19868. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19869. * @param transparent Specifies to activate blending if true
  19870. */
  19871. private static renderSorted;
  19872. /**
  19873. * Renders the submeshes in the order they were dispatched (no sort applied).
  19874. * @param subMeshes The submeshes to render
  19875. */
  19876. private static renderUnsorted;
  19877. /**
  19878. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19879. * are rendered back to front if in the same alpha index.
  19880. *
  19881. * @param a The first submesh
  19882. * @param b The second submesh
  19883. * @returns The result of the comparison
  19884. */
  19885. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19886. /**
  19887. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19888. * are rendered back to front.
  19889. *
  19890. * @param a The first submesh
  19891. * @param b The second submesh
  19892. * @returns The result of the comparison
  19893. */
  19894. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19895. /**
  19896. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19897. * are rendered front to back (prevent overdraw).
  19898. *
  19899. * @param a The first submesh
  19900. * @param b The second submesh
  19901. * @returns The result of the comparison
  19902. */
  19903. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19904. /**
  19905. * Resets the different lists of submeshes to prepare a new frame.
  19906. */
  19907. prepare(): void;
  19908. dispose(): void;
  19909. /**
  19910. * Inserts the submesh in its correct queue depending on its material.
  19911. * @param subMesh The submesh to dispatch
  19912. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19913. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19914. */
  19915. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19916. dispatchSprites(spriteManager: ISpriteManager): void;
  19917. dispatchParticles(particleSystem: IParticleSystem): void;
  19918. private _renderParticles;
  19919. private _renderSprites;
  19920. }
  19921. }
  19922. declare module BABYLON {
  19923. /**
  19924. * Interface describing the different options available in the rendering manager
  19925. * regarding Auto Clear between groups.
  19926. */
  19927. export interface IRenderingManagerAutoClearSetup {
  19928. /**
  19929. * Defines whether or not autoclear is enable.
  19930. */
  19931. autoClear: boolean;
  19932. /**
  19933. * Defines whether or not to autoclear the depth buffer.
  19934. */
  19935. depth: boolean;
  19936. /**
  19937. * Defines whether or not to autoclear the stencil buffer.
  19938. */
  19939. stencil: boolean;
  19940. }
  19941. /**
  19942. * This class is used by the onRenderingGroupObservable
  19943. */
  19944. export class RenderingGroupInfo {
  19945. /**
  19946. * The Scene that being rendered
  19947. */
  19948. scene: Scene;
  19949. /**
  19950. * The camera currently used for the rendering pass
  19951. */
  19952. camera: Nullable<Camera>;
  19953. /**
  19954. * The ID of the renderingGroup being processed
  19955. */
  19956. renderingGroupId: number;
  19957. }
  19958. /**
  19959. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19960. * It is enable to manage the different groups as well as the different necessary sort functions.
  19961. * This should not be used directly aside of the few static configurations
  19962. */
  19963. export class RenderingManager {
  19964. /**
  19965. * The max id used for rendering groups (not included)
  19966. */
  19967. static MAX_RENDERINGGROUPS: number;
  19968. /**
  19969. * The min id used for rendering groups (included)
  19970. */
  19971. static MIN_RENDERINGGROUPS: number;
  19972. /**
  19973. * Used to globally prevent autoclearing scenes.
  19974. */
  19975. static AUTOCLEAR: boolean;
  19976. /**
  19977. * @hidden
  19978. */
  19979. _useSceneAutoClearSetup: boolean;
  19980. private _scene;
  19981. private _renderingGroups;
  19982. private _depthStencilBufferAlreadyCleaned;
  19983. private _autoClearDepthStencil;
  19984. private _customOpaqueSortCompareFn;
  19985. private _customAlphaTestSortCompareFn;
  19986. private _customTransparentSortCompareFn;
  19987. private _renderingGroupInfo;
  19988. /**
  19989. * Instantiates a new rendering group for a particular scene
  19990. * @param scene Defines the scene the groups belongs to
  19991. */
  19992. constructor(scene: Scene);
  19993. private _clearDepthStencilBuffer;
  19994. /**
  19995. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19996. * @hidden
  19997. */
  19998. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19999. /**
  20000. * Resets the different information of the group to prepare a new frame
  20001. * @hidden
  20002. */
  20003. reset(): void;
  20004. /**
  20005. * Dispose and release the group and its associated resources.
  20006. * @hidden
  20007. */
  20008. dispose(): void;
  20009. /**
  20010. * Clear the info related to rendering groups preventing retention points during dispose.
  20011. */
  20012. freeRenderingGroups(): void;
  20013. private _prepareRenderingGroup;
  20014. /**
  20015. * Add a sprite manager to the rendering manager in order to render it this frame.
  20016. * @param spriteManager Define the sprite manager to render
  20017. */
  20018. dispatchSprites(spriteManager: ISpriteManager): void;
  20019. /**
  20020. * Add a particle system to the rendering manager in order to render it this frame.
  20021. * @param particleSystem Define the particle system to render
  20022. */
  20023. dispatchParticles(particleSystem: IParticleSystem): void;
  20024. /**
  20025. * Add a submesh to the manager in order to render it this frame
  20026. * @param subMesh The submesh to dispatch
  20027. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20028. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20029. */
  20030. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20031. /**
  20032. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20033. * This allowed control for front to back rendering or reversly depending of the special needs.
  20034. *
  20035. * @param renderingGroupId The rendering group id corresponding to its index
  20036. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20037. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20038. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20039. */
  20040. 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;
  20041. /**
  20042. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20043. *
  20044. * @param renderingGroupId The rendering group id corresponding to its index
  20045. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20046. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20047. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20048. */
  20049. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20050. /**
  20051. * Gets the current auto clear configuration for one rendering group of the rendering
  20052. * manager.
  20053. * @param index the rendering group index to get the information for
  20054. * @returns The auto clear setup for the requested rendering group
  20055. */
  20056. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20057. }
  20058. }
  20059. declare module BABYLON {
  20060. /**
  20061. * This Helps creating a texture that will be created from a camera in your scene.
  20062. * It is basically a dynamic texture that could be used to create special effects for instance.
  20063. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20064. */
  20065. export class RenderTargetTexture extends Texture {
  20066. isCube: boolean;
  20067. /**
  20068. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20069. */
  20070. static readonly REFRESHRATE_RENDER_ONCE: number;
  20071. /**
  20072. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20073. */
  20074. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20075. /**
  20076. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20077. * the central point of your effect and can save a lot of performances.
  20078. */
  20079. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20080. /**
  20081. * Use this predicate to dynamically define the list of mesh you want to render.
  20082. * If set, the renderList property will be overwritten.
  20083. */
  20084. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20085. private _renderList;
  20086. /**
  20087. * Use this list to define the list of mesh you want to render.
  20088. */
  20089. renderList: Nullable<Array<AbstractMesh>>;
  20090. private _hookArray;
  20091. /**
  20092. * Define if particles should be rendered in your texture.
  20093. */
  20094. renderParticles: boolean;
  20095. /**
  20096. * Define if sprites should be rendered in your texture.
  20097. */
  20098. renderSprites: boolean;
  20099. /**
  20100. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20101. */
  20102. coordinatesMode: number;
  20103. /**
  20104. * Define the camera used to render the texture.
  20105. */
  20106. activeCamera: Nullable<Camera>;
  20107. /**
  20108. * Override the render function of the texture with your own one.
  20109. */
  20110. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20111. /**
  20112. * Define if camera post processes should be use while rendering the texture.
  20113. */
  20114. useCameraPostProcesses: boolean;
  20115. /**
  20116. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20117. */
  20118. ignoreCameraViewport: boolean;
  20119. private _postProcessManager;
  20120. private _postProcesses;
  20121. private _resizeObserver;
  20122. /**
  20123. * An event triggered when the texture is unbind.
  20124. */
  20125. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20126. /**
  20127. * An event triggered when the texture is unbind.
  20128. */
  20129. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20130. private _onAfterUnbindObserver;
  20131. /**
  20132. * Set a after unbind callback in the texture.
  20133. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20134. */
  20135. onAfterUnbind: () => void;
  20136. /**
  20137. * An event triggered before rendering the texture
  20138. */
  20139. onBeforeRenderObservable: Observable<number>;
  20140. private _onBeforeRenderObserver;
  20141. /**
  20142. * Set a before render callback in the texture.
  20143. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20144. */
  20145. onBeforeRender: (faceIndex: number) => void;
  20146. /**
  20147. * An event triggered after rendering the texture
  20148. */
  20149. onAfterRenderObservable: Observable<number>;
  20150. private _onAfterRenderObserver;
  20151. /**
  20152. * Set a after render callback in the texture.
  20153. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20154. */
  20155. onAfterRender: (faceIndex: number) => void;
  20156. /**
  20157. * An event triggered after the texture clear
  20158. */
  20159. onClearObservable: Observable<Engine>;
  20160. private _onClearObserver;
  20161. /**
  20162. * Set a clear callback in the texture.
  20163. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20164. */
  20165. onClear: (Engine: Engine) => void;
  20166. /**
  20167. * An event triggered when the texture is resized.
  20168. */
  20169. onResizeObservable: Observable<RenderTargetTexture>;
  20170. /**
  20171. * Define the clear color of the Render Target if it should be different from the scene.
  20172. */
  20173. clearColor: Color4;
  20174. protected _size: number | {
  20175. width: number;
  20176. height: number;
  20177. };
  20178. protected _initialSizeParameter: number | {
  20179. width: number;
  20180. height: number;
  20181. } | {
  20182. ratio: number;
  20183. };
  20184. protected _sizeRatio: Nullable<number>;
  20185. /** @hidden */
  20186. _generateMipMaps: boolean;
  20187. protected _renderingManager: RenderingManager;
  20188. /** @hidden */
  20189. _waitingRenderList: string[];
  20190. protected _doNotChangeAspectRatio: boolean;
  20191. protected _currentRefreshId: number;
  20192. protected _refreshRate: number;
  20193. protected _textureMatrix: Matrix;
  20194. protected _samples: number;
  20195. protected _renderTargetOptions: RenderTargetCreationOptions;
  20196. /**
  20197. * Gets render target creation options that were used.
  20198. */
  20199. readonly renderTargetOptions: RenderTargetCreationOptions;
  20200. protected _engine: Engine;
  20201. protected _onRatioRescale(): void;
  20202. /**
  20203. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20204. * It must define where the camera used to render the texture is set
  20205. */
  20206. boundingBoxPosition: Vector3;
  20207. private _boundingBoxSize;
  20208. /**
  20209. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20210. * When defined, the cubemap will switch to local mode
  20211. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20212. * @example https://www.babylonjs-playground.com/#RNASML
  20213. */
  20214. boundingBoxSize: Vector3;
  20215. /**
  20216. * In case the RTT has been created with a depth texture, get the associated
  20217. * depth texture.
  20218. * Otherwise, return null.
  20219. */
  20220. depthStencilTexture: Nullable<InternalTexture>;
  20221. /**
  20222. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20223. * or used a shadow, depth texture...
  20224. * @param name The friendly name of the texture
  20225. * @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)
  20226. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20227. * @param generateMipMaps True if mip maps need to be generated after render.
  20228. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20229. * @param type The type of the buffer in the RTT (int, half float, float...)
  20230. * @param isCube True if a cube texture needs to be created
  20231. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20232. * @param generateDepthBuffer True to generate a depth buffer
  20233. * @param generateStencilBuffer True to generate a stencil buffer
  20234. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20235. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20236. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20237. */
  20238. constructor(name: string, size: number | {
  20239. width: number;
  20240. height: number;
  20241. } | {
  20242. ratio: number;
  20243. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20244. /**
  20245. * Creates a depth stencil texture.
  20246. * This is only available in WebGL 2 or with the depth texture extension available.
  20247. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20248. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20249. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20250. */
  20251. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20252. private _processSizeParameter;
  20253. /**
  20254. * Define the number of samples to use in case of MSAA.
  20255. * It defaults to one meaning no MSAA has been enabled.
  20256. */
  20257. samples: number;
  20258. /**
  20259. * Resets the refresh counter of the texture and start bak from scratch.
  20260. * Could be useful to regenerate the texture if it is setup to render only once.
  20261. */
  20262. resetRefreshCounter(): void;
  20263. /**
  20264. * Define the refresh rate of the texture or the rendering frequency.
  20265. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20266. */
  20267. refreshRate: number;
  20268. /**
  20269. * Adds a post process to the render target rendering passes.
  20270. * @param postProcess define the post process to add
  20271. */
  20272. addPostProcess(postProcess: PostProcess): void;
  20273. /**
  20274. * Clear all the post processes attached to the render target
  20275. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20276. */
  20277. clearPostProcesses(dispose?: boolean): void;
  20278. /**
  20279. * Remove one of the post process from the list of attached post processes to the texture
  20280. * @param postProcess define the post process to remove from the list
  20281. */
  20282. removePostProcess(postProcess: PostProcess): void;
  20283. /** @hidden */
  20284. _shouldRender(): boolean;
  20285. /**
  20286. * Gets the actual render size of the texture.
  20287. * @returns the width of the render size
  20288. */
  20289. getRenderSize(): number;
  20290. /**
  20291. * Gets the actual render width of the texture.
  20292. * @returns the width of the render size
  20293. */
  20294. getRenderWidth(): number;
  20295. /**
  20296. * Gets the actual render height of the texture.
  20297. * @returns the height of the render size
  20298. */
  20299. getRenderHeight(): number;
  20300. /**
  20301. * Get if the texture can be rescaled or not.
  20302. */
  20303. readonly canRescale: boolean;
  20304. /**
  20305. * Resize the texture using a ratio.
  20306. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20307. */
  20308. scale(ratio: number): void;
  20309. /**
  20310. * Get the texture reflection matrix used to rotate/transform the reflection.
  20311. * @returns the reflection matrix
  20312. */
  20313. getReflectionTextureMatrix(): Matrix;
  20314. /**
  20315. * Resize the texture to a new desired size.
  20316. * Be carrefull as it will recreate all the data in the new texture.
  20317. * @param size Define the new size. It can be:
  20318. * - a number for squared texture,
  20319. * - an object containing { width: number, height: number }
  20320. * - or an object containing a ratio { ratio: number }
  20321. */
  20322. resize(size: number | {
  20323. width: number;
  20324. height: number;
  20325. } | {
  20326. ratio: number;
  20327. }): void;
  20328. /**
  20329. * Renders all the objects from the render list into the texture.
  20330. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20331. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20332. */
  20333. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20334. private _bestReflectionRenderTargetDimension;
  20335. /**
  20336. * @hidden
  20337. * @param faceIndex face index to bind to if this is a cubetexture
  20338. */
  20339. _bindFrameBuffer(faceIndex?: number): void;
  20340. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20341. private renderToTarget;
  20342. /**
  20343. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20344. * This allowed control for front to back rendering or reversly depending of the special needs.
  20345. *
  20346. * @param renderingGroupId The rendering group id corresponding to its index
  20347. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20348. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20349. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20350. */
  20351. 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;
  20352. /**
  20353. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20354. *
  20355. * @param renderingGroupId The rendering group id corresponding to its index
  20356. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20357. */
  20358. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20359. /**
  20360. * Clones the texture.
  20361. * @returns the cloned texture
  20362. */
  20363. clone(): RenderTargetTexture;
  20364. /**
  20365. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20366. * @returns The JSON representation of the texture
  20367. */
  20368. serialize(): any;
  20369. /**
  20370. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20371. */
  20372. disposeFramebufferObjects(): void;
  20373. /**
  20374. * Dispose the texture and release its associated resources.
  20375. */
  20376. dispose(): void;
  20377. /** @hidden */
  20378. _rebuild(): void;
  20379. /**
  20380. * Clear the info related to rendering groups preventing retention point in material dispose.
  20381. */
  20382. freeRenderingGroups(): void;
  20383. /**
  20384. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20385. * @returns the view count
  20386. */
  20387. getViewCount(): number;
  20388. }
  20389. }
  20390. declare module BABYLON {
  20391. /**
  20392. * Options for compiling materials.
  20393. */
  20394. export interface IMaterialCompilationOptions {
  20395. /**
  20396. * Defines whether clip planes are enabled.
  20397. */
  20398. clipPlane: boolean;
  20399. /**
  20400. * Defines whether instances are enabled.
  20401. */
  20402. useInstances: boolean;
  20403. }
  20404. /**
  20405. * Base class for the main features of a material in Babylon.js
  20406. */
  20407. export class Material implements IAnimatable {
  20408. /**
  20409. * Returns the triangle fill mode
  20410. */
  20411. static readonly TriangleFillMode: number;
  20412. /**
  20413. * Returns the wireframe mode
  20414. */
  20415. static readonly WireFrameFillMode: number;
  20416. /**
  20417. * Returns the point fill mode
  20418. */
  20419. static readonly PointFillMode: number;
  20420. /**
  20421. * Returns the point list draw mode
  20422. */
  20423. static readonly PointListDrawMode: number;
  20424. /**
  20425. * Returns the line list draw mode
  20426. */
  20427. static readonly LineListDrawMode: number;
  20428. /**
  20429. * Returns the line loop draw mode
  20430. */
  20431. static readonly LineLoopDrawMode: number;
  20432. /**
  20433. * Returns the line strip draw mode
  20434. */
  20435. static readonly LineStripDrawMode: number;
  20436. /**
  20437. * Returns the triangle strip draw mode
  20438. */
  20439. static readonly TriangleStripDrawMode: number;
  20440. /**
  20441. * Returns the triangle fan draw mode
  20442. */
  20443. static readonly TriangleFanDrawMode: number;
  20444. /**
  20445. * Stores the clock-wise side orientation
  20446. */
  20447. static readonly ClockWiseSideOrientation: number;
  20448. /**
  20449. * Stores the counter clock-wise side orientation
  20450. */
  20451. static readonly CounterClockWiseSideOrientation: number;
  20452. /**
  20453. * The dirty texture flag value
  20454. */
  20455. static readonly TextureDirtyFlag: number;
  20456. /**
  20457. * The dirty light flag value
  20458. */
  20459. static readonly LightDirtyFlag: number;
  20460. /**
  20461. * The dirty fresnel flag value
  20462. */
  20463. static readonly FresnelDirtyFlag: number;
  20464. /**
  20465. * The dirty attribute flag value
  20466. */
  20467. static readonly AttributesDirtyFlag: number;
  20468. /**
  20469. * The dirty misc flag value
  20470. */
  20471. static readonly MiscDirtyFlag: number;
  20472. /**
  20473. * The all dirty flag value
  20474. */
  20475. static readonly AllDirtyFlag: number;
  20476. /**
  20477. * The ID of the material
  20478. */
  20479. id: string;
  20480. /**
  20481. * Gets or sets the unique id of the material
  20482. */
  20483. uniqueId: number;
  20484. /**
  20485. * The name of the material
  20486. */
  20487. name: string;
  20488. /**
  20489. * Gets or sets user defined metadata
  20490. */
  20491. metadata: any;
  20492. /**
  20493. * For internal use only. Please do not use.
  20494. */
  20495. reservedDataStore: any;
  20496. /**
  20497. * Specifies if the ready state should be checked on each call
  20498. */
  20499. checkReadyOnEveryCall: boolean;
  20500. /**
  20501. * Specifies if the ready state should be checked once
  20502. */
  20503. checkReadyOnlyOnce: boolean;
  20504. /**
  20505. * The state of the material
  20506. */
  20507. state: string;
  20508. /**
  20509. * The alpha value of the material
  20510. */
  20511. protected _alpha: number;
  20512. /**
  20513. * List of inspectable custom properties (used by the Inspector)
  20514. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20515. */
  20516. inspectableCustomProperties: IInspectable[];
  20517. /**
  20518. * Sets the alpha value of the material
  20519. */
  20520. /**
  20521. * Gets the alpha value of the material
  20522. */
  20523. alpha: number;
  20524. /**
  20525. * Specifies if back face culling is enabled
  20526. */
  20527. protected _backFaceCulling: boolean;
  20528. /**
  20529. * Sets the back-face culling state
  20530. */
  20531. /**
  20532. * Gets the back-face culling state
  20533. */
  20534. backFaceCulling: boolean;
  20535. /**
  20536. * Stores the value for side orientation
  20537. */
  20538. sideOrientation: number;
  20539. /**
  20540. * Callback triggered when the material is compiled
  20541. */
  20542. onCompiled: Nullable<(effect: Effect) => void>;
  20543. /**
  20544. * Callback triggered when an error occurs
  20545. */
  20546. onError: Nullable<(effect: Effect, errors: string) => void>;
  20547. /**
  20548. * Callback triggered to get the render target textures
  20549. */
  20550. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20551. /**
  20552. * Gets a boolean indicating that current material needs to register RTT
  20553. */
  20554. readonly hasRenderTargetTextures: boolean;
  20555. /**
  20556. * Specifies if the material should be serialized
  20557. */
  20558. doNotSerialize: boolean;
  20559. /**
  20560. * @hidden
  20561. */
  20562. _storeEffectOnSubMeshes: boolean;
  20563. /**
  20564. * Stores the animations for the material
  20565. */
  20566. animations: Nullable<Array<Animation>>;
  20567. /**
  20568. * An event triggered when the material is disposed
  20569. */
  20570. onDisposeObservable: Observable<Material>;
  20571. /**
  20572. * An observer which watches for dispose events
  20573. */
  20574. private _onDisposeObserver;
  20575. private _onUnBindObservable;
  20576. /**
  20577. * Called during a dispose event
  20578. */
  20579. onDispose: () => void;
  20580. private _onBindObservable;
  20581. /**
  20582. * An event triggered when the material is bound
  20583. */
  20584. readonly onBindObservable: Observable<AbstractMesh>;
  20585. /**
  20586. * An observer which watches for bind events
  20587. */
  20588. private _onBindObserver;
  20589. /**
  20590. * Called during a bind event
  20591. */
  20592. onBind: (Mesh: AbstractMesh) => void;
  20593. /**
  20594. * An event triggered when the material is unbound
  20595. */
  20596. readonly onUnBindObservable: Observable<Material>;
  20597. /**
  20598. * Stores the value of the alpha mode
  20599. */
  20600. private _alphaMode;
  20601. /**
  20602. * Sets the value of the alpha mode.
  20603. *
  20604. * | Value | Type | Description |
  20605. * | --- | --- | --- |
  20606. * | 0 | ALPHA_DISABLE | |
  20607. * | 1 | ALPHA_ADD | |
  20608. * | 2 | ALPHA_COMBINE | |
  20609. * | 3 | ALPHA_SUBTRACT | |
  20610. * | 4 | ALPHA_MULTIPLY | |
  20611. * | 5 | ALPHA_MAXIMIZED | |
  20612. * | 6 | ALPHA_ONEONE | |
  20613. * | 7 | ALPHA_PREMULTIPLIED | |
  20614. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20615. * | 9 | ALPHA_INTERPOLATE | |
  20616. * | 10 | ALPHA_SCREENMODE | |
  20617. *
  20618. */
  20619. /**
  20620. * Gets the value of the alpha mode
  20621. */
  20622. alphaMode: number;
  20623. /**
  20624. * Stores the state of the need depth pre-pass value
  20625. */
  20626. private _needDepthPrePass;
  20627. /**
  20628. * Sets the need depth pre-pass value
  20629. */
  20630. /**
  20631. * Gets the depth pre-pass value
  20632. */
  20633. needDepthPrePass: boolean;
  20634. /**
  20635. * Specifies if depth writing should be disabled
  20636. */
  20637. disableDepthWrite: boolean;
  20638. /**
  20639. * Specifies if depth writing should be forced
  20640. */
  20641. forceDepthWrite: boolean;
  20642. /**
  20643. * Specifies the depth function that should be used. 0 means the default engine function
  20644. */
  20645. depthFunction: number;
  20646. /**
  20647. * Specifies if there should be a separate pass for culling
  20648. */
  20649. separateCullingPass: boolean;
  20650. /**
  20651. * Stores the state specifing if fog should be enabled
  20652. */
  20653. private _fogEnabled;
  20654. /**
  20655. * Sets the state for enabling fog
  20656. */
  20657. /**
  20658. * Gets the value of the fog enabled state
  20659. */
  20660. fogEnabled: boolean;
  20661. /**
  20662. * Stores the size of points
  20663. */
  20664. pointSize: number;
  20665. /**
  20666. * Stores the z offset value
  20667. */
  20668. zOffset: number;
  20669. /**
  20670. * Gets a value specifying if wireframe mode is enabled
  20671. */
  20672. /**
  20673. * Sets the state of wireframe mode
  20674. */
  20675. wireframe: boolean;
  20676. /**
  20677. * Gets the value specifying if point clouds are enabled
  20678. */
  20679. /**
  20680. * Sets the state of point cloud mode
  20681. */
  20682. pointsCloud: boolean;
  20683. /**
  20684. * Gets the material fill mode
  20685. */
  20686. /**
  20687. * Sets the material fill mode
  20688. */
  20689. fillMode: number;
  20690. /**
  20691. * @hidden
  20692. * Stores the effects for the material
  20693. */
  20694. _effect: Nullable<Effect>;
  20695. /**
  20696. * @hidden
  20697. * Specifies if the material was previously ready
  20698. */
  20699. _wasPreviouslyReady: boolean;
  20700. /**
  20701. * Specifies if uniform buffers should be used
  20702. */
  20703. private _useUBO;
  20704. /**
  20705. * Stores a reference to the scene
  20706. */
  20707. private _scene;
  20708. /**
  20709. * Stores the fill mode state
  20710. */
  20711. private _fillMode;
  20712. /**
  20713. * Specifies if the depth write state should be cached
  20714. */
  20715. private _cachedDepthWriteState;
  20716. /**
  20717. * Specifies if the depth function state should be cached
  20718. */
  20719. private _cachedDepthFunctionState;
  20720. /**
  20721. * Stores the uniform buffer
  20722. */
  20723. protected _uniformBuffer: UniformBuffer;
  20724. /** @hidden */
  20725. _indexInSceneMaterialArray: number;
  20726. /** @hidden */
  20727. meshMap: Nullable<{
  20728. [id: string]: AbstractMesh | undefined;
  20729. }>;
  20730. /**
  20731. * Creates a material instance
  20732. * @param name defines the name of the material
  20733. * @param scene defines the scene to reference
  20734. * @param doNotAdd specifies if the material should be added to the scene
  20735. */
  20736. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20737. /**
  20738. * Returns a string representation of the current material
  20739. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20740. * @returns a string with material information
  20741. */
  20742. toString(fullDetails?: boolean): string;
  20743. /**
  20744. * Gets the class name of the material
  20745. * @returns a string with the class name of the material
  20746. */
  20747. getClassName(): string;
  20748. /**
  20749. * Specifies if updates for the material been locked
  20750. */
  20751. readonly isFrozen: boolean;
  20752. /**
  20753. * Locks updates for the material
  20754. */
  20755. freeze(): void;
  20756. /**
  20757. * Unlocks updates for the material
  20758. */
  20759. unfreeze(): void;
  20760. /**
  20761. * Specifies if the material is ready to be used
  20762. * @param mesh defines the mesh to check
  20763. * @param useInstances specifies if instances should be used
  20764. * @returns a boolean indicating if the material is ready to be used
  20765. */
  20766. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20767. /**
  20768. * Specifies that the submesh is ready to be used
  20769. * @param mesh defines the mesh to check
  20770. * @param subMesh defines which submesh to check
  20771. * @param useInstances specifies that instances should be used
  20772. * @returns a boolean indicating that the submesh is ready or not
  20773. */
  20774. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20775. /**
  20776. * Returns the material effect
  20777. * @returns the effect associated with the material
  20778. */
  20779. getEffect(): Nullable<Effect>;
  20780. /**
  20781. * Returns the current scene
  20782. * @returns a Scene
  20783. */
  20784. getScene(): Scene;
  20785. /**
  20786. * Specifies if the material will require alpha blending
  20787. * @returns a boolean specifying if alpha blending is needed
  20788. */
  20789. needAlphaBlending(): boolean;
  20790. /**
  20791. * Specifies if the mesh will require alpha blending
  20792. * @param mesh defines the mesh to check
  20793. * @returns a boolean specifying if alpha blending is needed for the mesh
  20794. */
  20795. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20796. /**
  20797. * Specifies if this material should be rendered in alpha test mode
  20798. * @returns a boolean specifying if an alpha test is needed.
  20799. */
  20800. needAlphaTesting(): boolean;
  20801. /**
  20802. * Gets the texture used for the alpha test
  20803. * @returns the texture to use for alpha testing
  20804. */
  20805. getAlphaTestTexture(): Nullable<BaseTexture>;
  20806. /**
  20807. * Marks the material to indicate that it needs to be re-calculated
  20808. */
  20809. markDirty(): void;
  20810. /** @hidden */
  20811. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20812. /**
  20813. * Binds the material to the mesh
  20814. * @param world defines the world transformation matrix
  20815. * @param mesh defines the mesh to bind the material to
  20816. */
  20817. bind(world: Matrix, mesh?: Mesh): void;
  20818. /**
  20819. * Binds the submesh to the material
  20820. * @param world defines the world transformation matrix
  20821. * @param mesh defines the mesh containing the submesh
  20822. * @param subMesh defines the submesh to bind the material to
  20823. */
  20824. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20825. /**
  20826. * Binds the world matrix to the material
  20827. * @param world defines the world transformation matrix
  20828. */
  20829. bindOnlyWorldMatrix(world: Matrix): void;
  20830. /**
  20831. * Binds the scene's uniform buffer to the effect.
  20832. * @param effect defines the effect to bind to the scene uniform buffer
  20833. * @param sceneUbo defines the uniform buffer storing scene data
  20834. */
  20835. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20836. /**
  20837. * Binds the view matrix to the effect
  20838. * @param effect defines the effect to bind the view matrix to
  20839. */
  20840. bindView(effect: Effect): void;
  20841. /**
  20842. * Binds the view projection matrix to the effect
  20843. * @param effect defines the effect to bind the view projection matrix to
  20844. */
  20845. bindViewProjection(effect: Effect): void;
  20846. /**
  20847. * Specifies if material alpha testing should be turned on for the mesh
  20848. * @param mesh defines the mesh to check
  20849. */
  20850. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20851. /**
  20852. * Processes to execute after binding the material to a mesh
  20853. * @param mesh defines the rendered mesh
  20854. */
  20855. protected _afterBind(mesh?: Mesh): void;
  20856. /**
  20857. * Unbinds the material from the mesh
  20858. */
  20859. unbind(): void;
  20860. /**
  20861. * Gets the active textures from the material
  20862. * @returns an array of textures
  20863. */
  20864. getActiveTextures(): BaseTexture[];
  20865. /**
  20866. * Specifies if the material uses a texture
  20867. * @param texture defines the texture to check against the material
  20868. * @returns a boolean specifying if the material uses the texture
  20869. */
  20870. hasTexture(texture: BaseTexture): boolean;
  20871. /**
  20872. * Makes a duplicate of the material, and gives it a new name
  20873. * @param name defines the new name for the duplicated material
  20874. * @returns the cloned material
  20875. */
  20876. clone(name: string): Nullable<Material>;
  20877. /**
  20878. * Gets the meshes bound to the material
  20879. * @returns an array of meshes bound to the material
  20880. */
  20881. getBindedMeshes(): AbstractMesh[];
  20882. /**
  20883. * Force shader compilation
  20884. * @param mesh defines the mesh associated with this material
  20885. * @param onCompiled defines a function to execute once the material is compiled
  20886. * @param options defines the options to configure the compilation
  20887. * @param onError defines a function to execute if the material fails compiling
  20888. */
  20889. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20890. /**
  20891. * Force shader compilation
  20892. * @param mesh defines the mesh that will use this material
  20893. * @param options defines additional options for compiling the shaders
  20894. * @returns a promise that resolves when the compilation completes
  20895. */
  20896. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20897. private static readonly _AllDirtyCallBack;
  20898. private static readonly _ImageProcessingDirtyCallBack;
  20899. private static readonly _TextureDirtyCallBack;
  20900. private static readonly _FresnelDirtyCallBack;
  20901. private static readonly _MiscDirtyCallBack;
  20902. private static readonly _LightsDirtyCallBack;
  20903. private static readonly _AttributeDirtyCallBack;
  20904. private static _FresnelAndMiscDirtyCallBack;
  20905. private static _TextureAndMiscDirtyCallBack;
  20906. private static readonly _DirtyCallbackArray;
  20907. private static readonly _RunDirtyCallBacks;
  20908. /**
  20909. * Marks a define in the material to indicate that it needs to be re-computed
  20910. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20911. */
  20912. markAsDirty(flag: number): void;
  20913. /**
  20914. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20915. * @param func defines a function which checks material defines against the submeshes
  20916. */
  20917. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20918. /**
  20919. * Indicates that we need to re-calculated for all submeshes
  20920. */
  20921. protected _markAllSubMeshesAsAllDirty(): void;
  20922. /**
  20923. * Indicates that image processing needs to be re-calculated for all submeshes
  20924. */
  20925. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20926. /**
  20927. * Indicates that textures need to be re-calculated for all submeshes
  20928. */
  20929. protected _markAllSubMeshesAsTexturesDirty(): void;
  20930. /**
  20931. * Indicates that fresnel needs to be re-calculated for all submeshes
  20932. */
  20933. protected _markAllSubMeshesAsFresnelDirty(): void;
  20934. /**
  20935. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20936. */
  20937. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20938. /**
  20939. * Indicates that lights need to be re-calculated for all submeshes
  20940. */
  20941. protected _markAllSubMeshesAsLightsDirty(): void;
  20942. /**
  20943. * Indicates that attributes need to be re-calculated for all submeshes
  20944. */
  20945. protected _markAllSubMeshesAsAttributesDirty(): void;
  20946. /**
  20947. * Indicates that misc needs to be re-calculated for all submeshes
  20948. */
  20949. protected _markAllSubMeshesAsMiscDirty(): void;
  20950. /**
  20951. * Indicates that textures and misc need to be re-calculated for all submeshes
  20952. */
  20953. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20954. /**
  20955. * Disposes the material
  20956. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20957. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20958. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20959. */
  20960. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20961. /** @hidden */
  20962. private releaseVertexArrayObject;
  20963. /**
  20964. * Serializes this material
  20965. * @returns the serialized material object
  20966. */
  20967. serialize(): any;
  20968. /**
  20969. * Creates a material from parsed material data
  20970. * @param parsedMaterial defines parsed material data
  20971. * @param scene defines the hosting scene
  20972. * @param rootUrl defines the root URL to use to load textures
  20973. * @returns a new material
  20974. */
  20975. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20976. }
  20977. }
  20978. declare module BABYLON {
  20979. /**
  20980. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20981. * separate meshes. This can be use to improve performances.
  20982. * @see http://doc.babylonjs.com/how_to/multi_materials
  20983. */
  20984. export class MultiMaterial extends Material {
  20985. private _subMaterials;
  20986. /**
  20987. * Gets or Sets the list of Materials used within the multi material.
  20988. * They need to be ordered according to the submeshes order in the associated mesh
  20989. */
  20990. subMaterials: Nullable<Material>[];
  20991. /**
  20992. * Function used to align with Node.getChildren()
  20993. * @returns the list of Materials used within the multi material
  20994. */
  20995. getChildren(): Nullable<Material>[];
  20996. /**
  20997. * Instantiates a new Multi Material
  20998. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20999. * separate meshes. This can be use to improve performances.
  21000. * @see http://doc.babylonjs.com/how_to/multi_materials
  21001. * @param name Define the name in the scene
  21002. * @param scene Define the scene the material belongs to
  21003. */
  21004. constructor(name: string, scene: Scene);
  21005. private _hookArray;
  21006. /**
  21007. * Get one of the submaterial by its index in the submaterials array
  21008. * @param index The index to look the sub material at
  21009. * @returns The Material if the index has been defined
  21010. */
  21011. getSubMaterial(index: number): Nullable<Material>;
  21012. /**
  21013. * Get the list of active textures for the whole sub materials list.
  21014. * @returns All the textures that will be used during the rendering
  21015. */
  21016. getActiveTextures(): BaseTexture[];
  21017. /**
  21018. * Gets the current class name of the material e.g. "MultiMaterial"
  21019. * Mainly use in serialization.
  21020. * @returns the class name
  21021. */
  21022. getClassName(): string;
  21023. /**
  21024. * Checks if the material is ready to render the requested sub mesh
  21025. * @param mesh Define the mesh the submesh belongs to
  21026. * @param subMesh Define the sub mesh to look readyness for
  21027. * @param useInstances Define whether or not the material is used with instances
  21028. * @returns true if ready, otherwise false
  21029. */
  21030. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21031. /**
  21032. * Clones the current material and its related sub materials
  21033. * @param name Define the name of the newly cloned material
  21034. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21035. * @returns the cloned material
  21036. */
  21037. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21038. /**
  21039. * Serializes the materials into a JSON representation.
  21040. * @returns the JSON representation
  21041. */
  21042. serialize(): any;
  21043. /**
  21044. * Dispose the material and release its associated resources
  21045. * @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)
  21046. * @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)
  21047. * @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)
  21048. */
  21049. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21050. /**
  21051. * Creates a MultiMaterial from parsed MultiMaterial data.
  21052. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21053. * @param scene defines the hosting scene
  21054. * @returns a new MultiMaterial
  21055. */
  21056. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21057. }
  21058. }
  21059. declare module BABYLON {
  21060. /**
  21061. * Base class for submeshes
  21062. */
  21063. export class BaseSubMesh {
  21064. /** @hidden */
  21065. _materialDefines: Nullable<MaterialDefines>;
  21066. /** @hidden */
  21067. _materialEffect: Nullable<Effect>;
  21068. /**
  21069. * Gets material defines used by the effect associated to the sub mesh
  21070. */
  21071. /**
  21072. * Sets material defines used by the effect associated to the sub mesh
  21073. */
  21074. materialDefines: Nullable<MaterialDefines>;
  21075. /**
  21076. * Gets associated effect
  21077. */
  21078. readonly effect: Nullable<Effect>;
  21079. /**
  21080. * Sets associated effect (effect used to render this submesh)
  21081. * @param effect defines the effect to associate with
  21082. * @param defines defines the set of defines used to compile this effect
  21083. */
  21084. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21085. }
  21086. /**
  21087. * Defines a subdivision inside a mesh
  21088. */
  21089. export class SubMesh extends BaseSubMesh implements ICullable {
  21090. /** the material index to use */
  21091. materialIndex: number;
  21092. /** vertex index start */
  21093. verticesStart: number;
  21094. /** vertices count */
  21095. verticesCount: number;
  21096. /** index start */
  21097. indexStart: number;
  21098. /** indices count */
  21099. indexCount: number;
  21100. /** @hidden */
  21101. _linesIndexCount: number;
  21102. private _mesh;
  21103. private _renderingMesh;
  21104. private _boundingInfo;
  21105. private _linesIndexBuffer;
  21106. /** @hidden */
  21107. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21108. /** @hidden */
  21109. _trianglePlanes: Plane[];
  21110. /** @hidden */
  21111. _lastColliderTransformMatrix: Nullable<Matrix>;
  21112. /** @hidden */
  21113. _renderId: number;
  21114. /** @hidden */
  21115. _alphaIndex: number;
  21116. /** @hidden */
  21117. _distanceToCamera: number;
  21118. /** @hidden */
  21119. _id: number;
  21120. private _currentMaterial;
  21121. /**
  21122. * Add a new submesh to a mesh
  21123. * @param materialIndex defines the material index to use
  21124. * @param verticesStart defines vertex index start
  21125. * @param verticesCount defines vertices count
  21126. * @param indexStart defines index start
  21127. * @param indexCount defines indices count
  21128. * @param mesh defines the parent mesh
  21129. * @param renderingMesh defines an optional rendering mesh
  21130. * @param createBoundingBox defines if bounding box should be created for this submesh
  21131. * @returns the new submesh
  21132. */
  21133. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21134. /**
  21135. * Creates a new submesh
  21136. * @param materialIndex defines the material index to use
  21137. * @param verticesStart defines vertex index start
  21138. * @param verticesCount defines vertices count
  21139. * @param indexStart defines index start
  21140. * @param indexCount defines indices count
  21141. * @param mesh defines the parent mesh
  21142. * @param renderingMesh defines an optional rendering mesh
  21143. * @param createBoundingBox defines if bounding box should be created for this submesh
  21144. */
  21145. constructor(
  21146. /** the material index to use */
  21147. materialIndex: number,
  21148. /** vertex index start */
  21149. verticesStart: number,
  21150. /** vertices count */
  21151. verticesCount: number,
  21152. /** index start */
  21153. indexStart: number,
  21154. /** indices count */
  21155. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21156. /**
  21157. * Returns true if this submesh covers the entire parent mesh
  21158. * @ignorenaming
  21159. */
  21160. readonly IsGlobal: boolean;
  21161. /**
  21162. * Returns the submesh BoudingInfo object
  21163. * @returns current bounding info (or mesh's one if the submesh is global)
  21164. */
  21165. getBoundingInfo(): BoundingInfo;
  21166. /**
  21167. * Sets the submesh BoundingInfo
  21168. * @param boundingInfo defines the new bounding info to use
  21169. * @returns the SubMesh
  21170. */
  21171. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21172. /**
  21173. * Returns the mesh of the current submesh
  21174. * @return the parent mesh
  21175. */
  21176. getMesh(): AbstractMesh;
  21177. /**
  21178. * Returns the rendering mesh of the submesh
  21179. * @returns the rendering mesh (could be different from parent mesh)
  21180. */
  21181. getRenderingMesh(): Mesh;
  21182. /**
  21183. * Returns the submesh material
  21184. * @returns null or the current material
  21185. */
  21186. getMaterial(): Nullable<Material>;
  21187. /**
  21188. * Sets a new updated BoundingInfo object to the submesh
  21189. * @param data defines an optional position array to use to determine the bounding info
  21190. * @returns the SubMesh
  21191. */
  21192. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21193. /** @hidden */
  21194. _checkCollision(collider: Collider): boolean;
  21195. /**
  21196. * Updates the submesh BoundingInfo
  21197. * @param world defines the world matrix to use to update the bounding info
  21198. * @returns the submesh
  21199. */
  21200. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21201. /**
  21202. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21203. * @param frustumPlanes defines the frustum planes
  21204. * @returns true if the submesh is intersecting with the frustum
  21205. */
  21206. isInFrustum(frustumPlanes: Plane[]): boolean;
  21207. /**
  21208. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21209. * @param frustumPlanes defines the frustum planes
  21210. * @returns true if the submesh is inside the frustum
  21211. */
  21212. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21213. /**
  21214. * Renders the submesh
  21215. * @param enableAlphaMode defines if alpha needs to be used
  21216. * @returns the submesh
  21217. */
  21218. render(enableAlphaMode: boolean): SubMesh;
  21219. /**
  21220. * @hidden
  21221. */
  21222. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21223. /**
  21224. * Checks if the submesh intersects with a ray
  21225. * @param ray defines the ray to test
  21226. * @returns true is the passed ray intersects the submesh bounding box
  21227. */
  21228. canIntersects(ray: Ray): boolean;
  21229. /**
  21230. * Intersects current submesh with a ray
  21231. * @param ray defines the ray to test
  21232. * @param positions defines mesh's positions array
  21233. * @param indices defines mesh's indices array
  21234. * @param fastCheck defines if only bounding info should be used
  21235. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21236. * @returns intersection info or null if no intersection
  21237. */
  21238. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21239. /** @hidden */
  21240. private _intersectLines;
  21241. /** @hidden */
  21242. private _intersectUnIndexedLines;
  21243. /** @hidden */
  21244. private _intersectTriangles;
  21245. /** @hidden */
  21246. private _intersectUnIndexedTriangles;
  21247. /** @hidden */
  21248. _rebuild(): void;
  21249. /**
  21250. * Creates a new submesh from the passed mesh
  21251. * @param newMesh defines the new hosting mesh
  21252. * @param newRenderingMesh defines an optional rendering mesh
  21253. * @returns the new submesh
  21254. */
  21255. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21256. /**
  21257. * Release associated resources
  21258. */
  21259. dispose(): void;
  21260. /**
  21261. * Gets the class name
  21262. * @returns the string "SubMesh".
  21263. */
  21264. getClassName(): string;
  21265. /**
  21266. * Creates a new submesh from indices data
  21267. * @param materialIndex the index of the main mesh material
  21268. * @param startIndex the index where to start the copy in the mesh indices array
  21269. * @param indexCount the number of indices to copy then from the startIndex
  21270. * @param mesh the main mesh to create the submesh from
  21271. * @param renderingMesh the optional rendering mesh
  21272. * @returns a new submesh
  21273. */
  21274. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21275. }
  21276. }
  21277. declare module BABYLON {
  21278. /**
  21279. * Class used to represent data loading progression
  21280. */
  21281. export class SceneLoaderFlags {
  21282. private static _ForceFullSceneLoadingForIncremental;
  21283. private static _ShowLoadingScreen;
  21284. private static _CleanBoneMatrixWeights;
  21285. private static _loggingLevel;
  21286. /**
  21287. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21288. */
  21289. static ForceFullSceneLoadingForIncremental: boolean;
  21290. /**
  21291. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21292. */
  21293. static ShowLoadingScreen: boolean;
  21294. /**
  21295. * Defines the current logging level (while loading the scene)
  21296. * @ignorenaming
  21297. */
  21298. static loggingLevel: number;
  21299. /**
  21300. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21301. */
  21302. static CleanBoneMatrixWeights: boolean;
  21303. }
  21304. }
  21305. declare module BABYLON {
  21306. /**
  21307. * Class used to store geometry data (vertex buffers + index buffer)
  21308. */
  21309. export class Geometry implements IGetSetVerticesData {
  21310. /**
  21311. * Gets or sets the ID of the geometry
  21312. */
  21313. id: string;
  21314. /**
  21315. * Gets or sets the unique ID of the geometry
  21316. */
  21317. uniqueId: number;
  21318. /**
  21319. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21320. */
  21321. delayLoadState: number;
  21322. /**
  21323. * Gets the file containing the data to load when running in delay load state
  21324. */
  21325. delayLoadingFile: Nullable<string>;
  21326. /**
  21327. * Callback called when the geometry is updated
  21328. */
  21329. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21330. private _scene;
  21331. private _engine;
  21332. private _meshes;
  21333. private _totalVertices;
  21334. /** @hidden */
  21335. _indices: IndicesArray;
  21336. /** @hidden */
  21337. _vertexBuffers: {
  21338. [key: string]: VertexBuffer;
  21339. };
  21340. private _isDisposed;
  21341. private _extend;
  21342. private _boundingBias;
  21343. /** @hidden */
  21344. _delayInfo: Array<string>;
  21345. private _indexBuffer;
  21346. private _indexBufferIsUpdatable;
  21347. /** @hidden */
  21348. _boundingInfo: Nullable<BoundingInfo>;
  21349. /** @hidden */
  21350. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21351. /** @hidden */
  21352. _softwareSkinningFrameId: number;
  21353. private _vertexArrayObjects;
  21354. private _updatable;
  21355. /** @hidden */
  21356. _positions: Nullable<Vector3[]>;
  21357. /**
  21358. * 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
  21359. */
  21360. /**
  21361. * 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
  21362. */
  21363. boundingBias: Vector2;
  21364. /**
  21365. * Static function used to attach a new empty geometry to a mesh
  21366. * @param mesh defines the mesh to attach the geometry to
  21367. * @returns the new Geometry
  21368. */
  21369. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21370. /**
  21371. * Creates a new geometry
  21372. * @param id defines the unique ID
  21373. * @param scene defines the hosting scene
  21374. * @param vertexData defines the VertexData used to get geometry data
  21375. * @param updatable defines if geometry must be updatable (false by default)
  21376. * @param mesh defines the mesh that will be associated with the geometry
  21377. */
  21378. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21379. /**
  21380. * Gets the current extend of the geometry
  21381. */
  21382. readonly extend: {
  21383. minimum: Vector3;
  21384. maximum: Vector3;
  21385. };
  21386. /**
  21387. * Gets the hosting scene
  21388. * @returns the hosting Scene
  21389. */
  21390. getScene(): Scene;
  21391. /**
  21392. * Gets the hosting engine
  21393. * @returns the hosting Engine
  21394. */
  21395. getEngine(): Engine;
  21396. /**
  21397. * Defines if the geometry is ready to use
  21398. * @returns true if the geometry is ready to be used
  21399. */
  21400. isReady(): boolean;
  21401. /**
  21402. * Gets a value indicating that the geometry should not be serialized
  21403. */
  21404. readonly doNotSerialize: boolean;
  21405. /** @hidden */
  21406. _rebuild(): void;
  21407. /**
  21408. * Affects all geometry data in one call
  21409. * @param vertexData defines the geometry data
  21410. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21411. */
  21412. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21413. /**
  21414. * Set specific vertex data
  21415. * @param kind defines the data kind (Position, normal, etc...)
  21416. * @param data defines the vertex data to use
  21417. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21418. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21419. */
  21420. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21421. /**
  21422. * Removes a specific vertex data
  21423. * @param kind defines the data kind (Position, normal, etc...)
  21424. */
  21425. removeVerticesData(kind: string): void;
  21426. /**
  21427. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21428. * @param buffer defines the vertex buffer to use
  21429. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21430. */
  21431. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21432. /**
  21433. * Update a specific vertex buffer
  21434. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21435. * It will do nothing if the buffer is not updatable
  21436. * @param kind defines the data kind (Position, normal, etc...)
  21437. * @param data defines the data to use
  21438. * @param offset defines the offset in the target buffer where to store the data
  21439. * @param useBytes set to true if the offset is in bytes
  21440. */
  21441. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21442. /**
  21443. * Update a specific vertex buffer
  21444. * This function will create a new buffer if the current one is not updatable
  21445. * @param kind defines the data kind (Position, normal, etc...)
  21446. * @param data defines the data to use
  21447. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21448. */
  21449. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21450. private _updateBoundingInfo;
  21451. /** @hidden */
  21452. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21453. /**
  21454. * Gets total number of vertices
  21455. * @returns the total number of vertices
  21456. */
  21457. getTotalVertices(): number;
  21458. /**
  21459. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21460. * @param kind defines the data kind (Position, normal, etc...)
  21461. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21462. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21463. * @returns a float array containing vertex data
  21464. */
  21465. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21466. /**
  21467. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21468. * @param kind defines the data kind (Position, normal, etc...)
  21469. * @returns true if the vertex buffer with the specified kind is updatable
  21470. */
  21471. isVertexBufferUpdatable(kind: string): boolean;
  21472. /**
  21473. * Gets a specific vertex buffer
  21474. * @param kind defines the data kind (Position, normal, etc...)
  21475. * @returns a VertexBuffer
  21476. */
  21477. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21478. /**
  21479. * Returns all vertex buffers
  21480. * @return an object holding all vertex buffers indexed by kind
  21481. */
  21482. getVertexBuffers(): Nullable<{
  21483. [key: string]: VertexBuffer;
  21484. }>;
  21485. /**
  21486. * Gets a boolean indicating if specific vertex buffer is present
  21487. * @param kind defines the data kind (Position, normal, etc...)
  21488. * @returns true if data is present
  21489. */
  21490. isVerticesDataPresent(kind: string): boolean;
  21491. /**
  21492. * Gets a list of all attached data kinds (Position, normal, etc...)
  21493. * @returns a list of string containing all kinds
  21494. */
  21495. getVerticesDataKinds(): string[];
  21496. /**
  21497. * Update index buffer
  21498. * @param indices defines the indices to store in the index buffer
  21499. * @param offset defines the offset in the target buffer where to store the data
  21500. * @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)
  21501. */
  21502. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21503. /**
  21504. * Creates a new index buffer
  21505. * @param indices defines the indices to store in the index buffer
  21506. * @param totalVertices defines the total number of vertices (could be null)
  21507. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21508. */
  21509. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21510. /**
  21511. * Return the total number of indices
  21512. * @returns the total number of indices
  21513. */
  21514. getTotalIndices(): number;
  21515. /**
  21516. * Gets the index buffer array
  21517. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21518. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21519. * @returns the index buffer array
  21520. */
  21521. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21522. /**
  21523. * Gets the index buffer
  21524. * @return the index buffer
  21525. */
  21526. getIndexBuffer(): Nullable<DataBuffer>;
  21527. /** @hidden */
  21528. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21529. /**
  21530. * Release the associated resources for a specific mesh
  21531. * @param mesh defines the source mesh
  21532. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21533. */
  21534. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21535. /**
  21536. * Apply current geometry to a given mesh
  21537. * @param mesh defines the mesh to apply geometry to
  21538. */
  21539. applyToMesh(mesh: Mesh): void;
  21540. private _updateExtend;
  21541. private _applyToMesh;
  21542. private notifyUpdate;
  21543. /**
  21544. * Load the geometry if it was flagged as delay loaded
  21545. * @param scene defines the hosting scene
  21546. * @param onLoaded defines a callback called when the geometry is loaded
  21547. */
  21548. load(scene: Scene, onLoaded?: () => void): void;
  21549. private _queueLoad;
  21550. /**
  21551. * Invert the geometry to move from a right handed system to a left handed one.
  21552. */
  21553. toLeftHanded(): void;
  21554. /** @hidden */
  21555. _resetPointsArrayCache(): void;
  21556. /** @hidden */
  21557. _generatePointsArray(): boolean;
  21558. /**
  21559. * Gets a value indicating if the geometry is disposed
  21560. * @returns true if the geometry was disposed
  21561. */
  21562. isDisposed(): boolean;
  21563. private _disposeVertexArrayObjects;
  21564. /**
  21565. * Free all associated resources
  21566. */
  21567. dispose(): void;
  21568. /**
  21569. * Clone the current geometry into a new geometry
  21570. * @param id defines the unique ID of the new geometry
  21571. * @returns a new geometry object
  21572. */
  21573. copy(id: string): Geometry;
  21574. /**
  21575. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21576. * @return a JSON representation of the current geometry data (without the vertices data)
  21577. */
  21578. serialize(): any;
  21579. private toNumberArray;
  21580. /**
  21581. * Serialize all vertices data into a JSON oject
  21582. * @returns a JSON representation of the current geometry data
  21583. */
  21584. serializeVerticeData(): any;
  21585. /**
  21586. * Extracts a clone of a mesh geometry
  21587. * @param mesh defines the source mesh
  21588. * @param id defines the unique ID of the new geometry object
  21589. * @returns the new geometry object
  21590. */
  21591. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21592. /**
  21593. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21594. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21595. * Be aware Math.random() could cause collisions, but:
  21596. * "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"
  21597. * @returns a string containing a new GUID
  21598. */
  21599. static RandomId(): string;
  21600. /** @hidden */
  21601. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21602. private static _CleanMatricesWeights;
  21603. /**
  21604. * Create a new geometry from persisted data (Using .babylon file format)
  21605. * @param parsedVertexData defines the persisted data
  21606. * @param scene defines the hosting scene
  21607. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21608. * @returns the new geometry object
  21609. */
  21610. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21611. }
  21612. }
  21613. declare module BABYLON {
  21614. /**
  21615. * Define an interface for all classes that will get and set the data on vertices
  21616. */
  21617. export interface IGetSetVerticesData {
  21618. /**
  21619. * Gets a boolean indicating if specific vertex data is present
  21620. * @param kind defines the vertex data kind to use
  21621. * @returns true is data kind is present
  21622. */
  21623. isVerticesDataPresent(kind: string): boolean;
  21624. /**
  21625. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21626. * @param kind defines the data kind (Position, normal, etc...)
  21627. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21628. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21629. * @returns a float array containing vertex data
  21630. */
  21631. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21632. /**
  21633. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21634. * @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.
  21635. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21636. * @returns the indices array or an empty array if the mesh has no geometry
  21637. */
  21638. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21639. /**
  21640. * Set specific vertex data
  21641. * @param kind defines the data kind (Position, normal, etc...)
  21642. * @param data defines the vertex data to use
  21643. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21644. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21645. */
  21646. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21647. /**
  21648. * Update a specific associated vertex buffer
  21649. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21650. * - VertexBuffer.PositionKind
  21651. * - VertexBuffer.UVKind
  21652. * - VertexBuffer.UV2Kind
  21653. * - VertexBuffer.UV3Kind
  21654. * - VertexBuffer.UV4Kind
  21655. * - VertexBuffer.UV5Kind
  21656. * - VertexBuffer.UV6Kind
  21657. * - VertexBuffer.ColorKind
  21658. * - VertexBuffer.MatricesIndicesKind
  21659. * - VertexBuffer.MatricesIndicesExtraKind
  21660. * - VertexBuffer.MatricesWeightsKind
  21661. * - VertexBuffer.MatricesWeightsExtraKind
  21662. * @param data defines the data source
  21663. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21664. * @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)
  21665. */
  21666. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21667. /**
  21668. * Creates a new index buffer
  21669. * @param indices defines the indices to store in the index buffer
  21670. * @param totalVertices defines the total number of vertices (could be null)
  21671. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21672. */
  21673. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21674. }
  21675. /**
  21676. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21677. */
  21678. export class VertexData {
  21679. /**
  21680. * Mesh side orientation : usually the external or front surface
  21681. */
  21682. static readonly FRONTSIDE: number;
  21683. /**
  21684. * Mesh side orientation : usually the internal or back surface
  21685. */
  21686. static readonly BACKSIDE: number;
  21687. /**
  21688. * Mesh side orientation : both internal and external or front and back surfaces
  21689. */
  21690. static readonly DOUBLESIDE: number;
  21691. /**
  21692. * Mesh side orientation : by default, `FRONTSIDE`
  21693. */
  21694. static readonly DEFAULTSIDE: number;
  21695. /**
  21696. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21697. */
  21698. positions: Nullable<FloatArray>;
  21699. /**
  21700. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21701. */
  21702. normals: Nullable<FloatArray>;
  21703. /**
  21704. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21705. */
  21706. tangents: Nullable<FloatArray>;
  21707. /**
  21708. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21709. */
  21710. uvs: Nullable<FloatArray>;
  21711. /**
  21712. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21713. */
  21714. uvs2: Nullable<FloatArray>;
  21715. /**
  21716. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21717. */
  21718. uvs3: Nullable<FloatArray>;
  21719. /**
  21720. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21721. */
  21722. uvs4: Nullable<FloatArray>;
  21723. /**
  21724. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21725. */
  21726. uvs5: Nullable<FloatArray>;
  21727. /**
  21728. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21729. */
  21730. uvs6: Nullable<FloatArray>;
  21731. /**
  21732. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21733. */
  21734. colors: Nullable<FloatArray>;
  21735. /**
  21736. * 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).
  21737. */
  21738. matricesIndices: Nullable<FloatArray>;
  21739. /**
  21740. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21741. */
  21742. matricesWeights: Nullable<FloatArray>;
  21743. /**
  21744. * An array extending the number of possible indices
  21745. */
  21746. matricesIndicesExtra: Nullable<FloatArray>;
  21747. /**
  21748. * An array extending the number of possible weights when the number of indices is extended
  21749. */
  21750. matricesWeightsExtra: Nullable<FloatArray>;
  21751. /**
  21752. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21753. */
  21754. indices: Nullable<IndicesArray>;
  21755. /**
  21756. * Uses the passed data array to set the set the values for the specified kind of data
  21757. * @param data a linear array of floating numbers
  21758. * @param kind the type of data that is being set, eg positions, colors etc
  21759. */
  21760. set(data: FloatArray, kind: string): void;
  21761. /**
  21762. * Associates the vertexData to the passed Mesh.
  21763. * Sets it as updatable or not (default `false`)
  21764. * @param mesh the mesh the vertexData is applied to
  21765. * @param updatable when used and having the value true allows new data to update the vertexData
  21766. * @returns the VertexData
  21767. */
  21768. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21769. /**
  21770. * Associates the vertexData to the passed Geometry.
  21771. * Sets it as updatable or not (default `false`)
  21772. * @param geometry the geometry the vertexData is applied to
  21773. * @param updatable when used and having the value true allows new data to update the vertexData
  21774. * @returns VertexData
  21775. */
  21776. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21777. /**
  21778. * Updates the associated mesh
  21779. * @param mesh the mesh to be updated
  21780. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21781. * @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
  21782. * @returns VertexData
  21783. */
  21784. updateMesh(mesh: Mesh): VertexData;
  21785. /**
  21786. * Updates the associated geometry
  21787. * @param geometry the geometry to be updated
  21788. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21789. * @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
  21790. * @returns VertexData.
  21791. */
  21792. updateGeometry(geometry: Geometry): VertexData;
  21793. private _applyTo;
  21794. private _update;
  21795. /**
  21796. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21797. * @param matrix the transforming matrix
  21798. * @returns the VertexData
  21799. */
  21800. transform(matrix: Matrix): VertexData;
  21801. /**
  21802. * Merges the passed VertexData into the current one
  21803. * @param other the VertexData to be merged into the current one
  21804. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21805. * @returns the modified VertexData
  21806. */
  21807. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21808. private _mergeElement;
  21809. private _validate;
  21810. /**
  21811. * Serializes the VertexData
  21812. * @returns a serialized object
  21813. */
  21814. serialize(): any;
  21815. /**
  21816. * Extracts the vertexData from a mesh
  21817. * @param mesh the mesh from which to extract the VertexData
  21818. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21819. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21820. * @returns the object VertexData associated to the passed mesh
  21821. */
  21822. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21823. /**
  21824. * Extracts the vertexData from the geometry
  21825. * @param geometry the geometry from which to extract the VertexData
  21826. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21827. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21828. * @returns the object VertexData associated to the passed mesh
  21829. */
  21830. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21831. private static _ExtractFrom;
  21832. /**
  21833. * Creates the VertexData for a Ribbon
  21834. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21835. * * pathArray array of paths, each of which an array of successive Vector3
  21836. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21837. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21838. * * 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
  21839. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21840. * * 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)
  21841. * * 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)
  21842. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21843. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21844. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21845. * @returns the VertexData of the ribbon
  21846. */
  21847. static CreateRibbon(options: {
  21848. pathArray: Vector3[][];
  21849. closeArray?: boolean;
  21850. closePath?: boolean;
  21851. offset?: number;
  21852. sideOrientation?: number;
  21853. frontUVs?: Vector4;
  21854. backUVs?: Vector4;
  21855. invertUV?: boolean;
  21856. uvs?: Vector2[];
  21857. colors?: Color4[];
  21858. }): VertexData;
  21859. /**
  21860. * Creates the VertexData for a box
  21861. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21862. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21863. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21864. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21865. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21866. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21867. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21868. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21869. * * 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)
  21870. * * 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)
  21871. * @returns the VertexData of the box
  21872. */
  21873. static CreateBox(options: {
  21874. size?: number;
  21875. width?: number;
  21876. height?: number;
  21877. depth?: number;
  21878. faceUV?: Vector4[];
  21879. faceColors?: Color4[];
  21880. sideOrientation?: number;
  21881. frontUVs?: Vector4;
  21882. backUVs?: Vector4;
  21883. }): VertexData;
  21884. /**
  21885. * Creates the VertexData for a tiled box
  21886. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21887. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21888. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21889. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21890. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21891. * @returns the VertexData of the box
  21892. */
  21893. static CreateTiledBox(options: {
  21894. pattern?: number;
  21895. width?: number;
  21896. height?: number;
  21897. depth?: number;
  21898. tileSize?: number;
  21899. tileWidth?: number;
  21900. tileHeight?: number;
  21901. alignHorizontal?: number;
  21902. alignVertical?: number;
  21903. faceUV?: Vector4[];
  21904. faceColors?: Color4[];
  21905. sideOrientation?: number;
  21906. }): VertexData;
  21907. /**
  21908. * Creates the VertexData for a tiled plane
  21909. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21910. * * pattern a limited pattern arrangement depending on the number
  21911. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21912. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21913. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21915. * * 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)
  21916. * * 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)
  21917. * @returns the VertexData of the tiled plane
  21918. */
  21919. static CreateTiledPlane(options: {
  21920. pattern?: number;
  21921. tileSize?: number;
  21922. tileWidth?: number;
  21923. tileHeight?: number;
  21924. size?: number;
  21925. width?: number;
  21926. height?: number;
  21927. alignHorizontal?: number;
  21928. alignVertical?: number;
  21929. sideOrientation?: number;
  21930. frontUVs?: Vector4;
  21931. backUVs?: Vector4;
  21932. }): VertexData;
  21933. /**
  21934. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21935. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21936. * * segments sets the number of horizontal strips optional, default 32
  21937. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21938. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21939. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21940. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21941. * * 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
  21942. * * 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
  21943. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21944. * * 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)
  21945. * * 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)
  21946. * @returns the VertexData of the ellipsoid
  21947. */
  21948. static CreateSphere(options: {
  21949. segments?: number;
  21950. diameter?: number;
  21951. diameterX?: number;
  21952. diameterY?: number;
  21953. diameterZ?: number;
  21954. arc?: number;
  21955. slice?: number;
  21956. sideOrientation?: number;
  21957. frontUVs?: Vector4;
  21958. backUVs?: Vector4;
  21959. }): VertexData;
  21960. /**
  21961. * Creates the VertexData for a cylinder, cone or prism
  21962. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21963. * * height sets the height (y direction) of the cylinder, optional, default 2
  21964. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21965. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21966. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21967. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21968. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21969. * * 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
  21970. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21971. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21972. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21973. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21974. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21975. * * 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)
  21976. * * 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)
  21977. * @returns the VertexData of the cylinder, cone or prism
  21978. */
  21979. static CreateCylinder(options: {
  21980. height?: number;
  21981. diameterTop?: number;
  21982. diameterBottom?: number;
  21983. diameter?: number;
  21984. tessellation?: number;
  21985. subdivisions?: number;
  21986. arc?: number;
  21987. faceColors?: Color4[];
  21988. faceUV?: Vector4[];
  21989. hasRings?: boolean;
  21990. enclose?: boolean;
  21991. sideOrientation?: number;
  21992. frontUVs?: Vector4;
  21993. backUVs?: Vector4;
  21994. }): VertexData;
  21995. /**
  21996. * Creates the VertexData for a torus
  21997. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21998. * * diameter the diameter of the torus, optional default 1
  21999. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22000. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22001. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22002. * * 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)
  22003. * * 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)
  22004. * @returns the VertexData of the torus
  22005. */
  22006. static CreateTorus(options: {
  22007. diameter?: number;
  22008. thickness?: number;
  22009. tessellation?: number;
  22010. sideOrientation?: number;
  22011. frontUVs?: Vector4;
  22012. backUVs?: Vector4;
  22013. }): VertexData;
  22014. /**
  22015. * Creates the VertexData of the LineSystem
  22016. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22017. * - lines an array of lines, each line being an array of successive Vector3
  22018. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22019. * @returns the VertexData of the LineSystem
  22020. */
  22021. static CreateLineSystem(options: {
  22022. lines: Vector3[][];
  22023. colors?: Nullable<Color4[][]>;
  22024. }): VertexData;
  22025. /**
  22026. * Create the VertexData for a DashedLines
  22027. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22028. * - points an array successive Vector3
  22029. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22030. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22031. * - dashNb the intended total number of dashes, optional, default 200
  22032. * @returns the VertexData for the DashedLines
  22033. */
  22034. static CreateDashedLines(options: {
  22035. points: Vector3[];
  22036. dashSize?: number;
  22037. gapSize?: number;
  22038. dashNb?: number;
  22039. }): VertexData;
  22040. /**
  22041. * Creates the VertexData for a Ground
  22042. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22043. * - width the width (x direction) of the ground, optional, default 1
  22044. * - height the height (z direction) of the ground, optional, default 1
  22045. * - subdivisions the number of subdivisions per side, optional, default 1
  22046. * @returns the VertexData of the Ground
  22047. */
  22048. static CreateGround(options: {
  22049. width?: number;
  22050. height?: number;
  22051. subdivisions?: number;
  22052. subdivisionsX?: number;
  22053. subdivisionsY?: number;
  22054. }): VertexData;
  22055. /**
  22056. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22057. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22058. * * xmin the ground minimum X coordinate, optional, default -1
  22059. * * zmin the ground minimum Z coordinate, optional, default -1
  22060. * * xmax the ground maximum X coordinate, optional, default 1
  22061. * * zmax the ground maximum Z coordinate, optional, default 1
  22062. * * 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}
  22063. * * 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}
  22064. * @returns the VertexData of the TiledGround
  22065. */
  22066. static CreateTiledGround(options: {
  22067. xmin: number;
  22068. zmin: number;
  22069. xmax: number;
  22070. zmax: number;
  22071. subdivisions?: {
  22072. w: number;
  22073. h: number;
  22074. };
  22075. precision?: {
  22076. w: number;
  22077. h: number;
  22078. };
  22079. }): VertexData;
  22080. /**
  22081. * Creates the VertexData of the Ground designed from a heightmap
  22082. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22083. * * width the width (x direction) of the ground
  22084. * * height the height (z direction) of the ground
  22085. * * subdivisions the number of subdivisions per side
  22086. * * minHeight the minimum altitude on the ground, optional, default 0
  22087. * * maxHeight the maximum altitude on the ground, optional default 1
  22088. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22089. * * buffer the array holding the image color data
  22090. * * bufferWidth the width of image
  22091. * * bufferHeight the height of image
  22092. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22093. * @returns the VertexData of the Ground designed from a heightmap
  22094. */
  22095. static CreateGroundFromHeightMap(options: {
  22096. width: number;
  22097. height: number;
  22098. subdivisions: number;
  22099. minHeight: number;
  22100. maxHeight: number;
  22101. colorFilter: Color3;
  22102. buffer: Uint8Array;
  22103. bufferWidth: number;
  22104. bufferHeight: number;
  22105. alphaFilter: number;
  22106. }): VertexData;
  22107. /**
  22108. * Creates the VertexData for a Plane
  22109. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22110. * * size sets the width and height of the plane to the value of size, optional default 1
  22111. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22112. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22113. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22114. * * 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)
  22115. * * 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)
  22116. * @returns the VertexData of the box
  22117. */
  22118. static CreatePlane(options: {
  22119. size?: number;
  22120. width?: number;
  22121. height?: number;
  22122. sideOrientation?: number;
  22123. frontUVs?: Vector4;
  22124. backUVs?: Vector4;
  22125. }): VertexData;
  22126. /**
  22127. * Creates the VertexData of the Disc or regular Polygon
  22128. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22129. * * radius the radius of the disc, optional default 0.5
  22130. * * tessellation the number of polygon sides, optional, default 64
  22131. * * 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
  22132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22133. * * 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)
  22134. * * 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)
  22135. * @returns the VertexData of the box
  22136. */
  22137. static CreateDisc(options: {
  22138. radius?: number;
  22139. tessellation?: number;
  22140. arc?: number;
  22141. sideOrientation?: number;
  22142. frontUVs?: Vector4;
  22143. backUVs?: Vector4;
  22144. }): VertexData;
  22145. /**
  22146. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22147. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22148. * @param polygon a mesh built from polygonTriangulation.build()
  22149. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22150. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22151. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22152. * @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)
  22153. * @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)
  22154. * @returns the VertexData of the Polygon
  22155. */
  22156. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22157. /**
  22158. * Creates the VertexData of the IcoSphere
  22159. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22160. * * radius the radius of the IcoSphere, optional default 1
  22161. * * radiusX allows stretching in the x direction, optional, default radius
  22162. * * radiusY allows stretching in the y direction, optional, default radius
  22163. * * radiusZ allows stretching in the z direction, optional, default radius
  22164. * * flat when true creates a flat shaded mesh, optional, default true
  22165. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22167. * * 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)
  22168. * * 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)
  22169. * @returns the VertexData of the IcoSphere
  22170. */
  22171. static CreateIcoSphere(options: {
  22172. radius?: number;
  22173. radiusX?: number;
  22174. radiusY?: number;
  22175. radiusZ?: number;
  22176. flat?: boolean;
  22177. subdivisions?: number;
  22178. sideOrientation?: number;
  22179. frontUVs?: Vector4;
  22180. backUVs?: Vector4;
  22181. }): VertexData;
  22182. /**
  22183. * Creates the VertexData for a Polyhedron
  22184. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22185. * * type provided types are:
  22186. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22187. * * 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)
  22188. * * size the size of the IcoSphere, optional default 1
  22189. * * sizeX allows stretching in the x direction, optional, default size
  22190. * * sizeY allows stretching in the y direction, optional, default size
  22191. * * sizeZ allows stretching in the z direction, optional, default size
  22192. * * 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
  22193. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22194. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22195. * * flat when true creates a flat shaded mesh, optional, default true
  22196. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22197. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22198. * * 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)
  22199. * * 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)
  22200. * @returns the VertexData of the Polyhedron
  22201. */
  22202. static CreatePolyhedron(options: {
  22203. type?: number;
  22204. size?: number;
  22205. sizeX?: number;
  22206. sizeY?: number;
  22207. sizeZ?: number;
  22208. custom?: any;
  22209. faceUV?: Vector4[];
  22210. faceColors?: Color4[];
  22211. flat?: boolean;
  22212. sideOrientation?: number;
  22213. frontUVs?: Vector4;
  22214. backUVs?: Vector4;
  22215. }): VertexData;
  22216. /**
  22217. * Creates the VertexData for a TorusKnot
  22218. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22219. * * radius the radius of the torus knot, optional, default 2
  22220. * * tube the thickness of the tube, optional, default 0.5
  22221. * * radialSegments the number of sides on each tube segments, optional, default 32
  22222. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22223. * * p the number of windings around the z axis, optional, default 2
  22224. * * q the number of windings around the x axis, optional, default 3
  22225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22226. * * 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)
  22227. * * 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)
  22228. * @returns the VertexData of the Torus Knot
  22229. */
  22230. static CreateTorusKnot(options: {
  22231. radius?: number;
  22232. tube?: number;
  22233. radialSegments?: number;
  22234. tubularSegments?: number;
  22235. p?: number;
  22236. q?: number;
  22237. sideOrientation?: number;
  22238. frontUVs?: Vector4;
  22239. backUVs?: Vector4;
  22240. }): VertexData;
  22241. /**
  22242. * Compute normals for given positions and indices
  22243. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22244. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22245. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22246. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22247. * * facetNormals : optional array of facet normals (vector3)
  22248. * * facetPositions : optional array of facet positions (vector3)
  22249. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22250. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22251. * * bInfo : optional bounding info, required for facetPartitioning computation
  22252. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22253. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22254. * * useRightHandedSystem: optional boolean to for right handed system computation
  22255. * * depthSort : optional boolean to enable the facet depth sort computation
  22256. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22257. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22258. */
  22259. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22260. facetNormals?: any;
  22261. facetPositions?: any;
  22262. facetPartitioning?: any;
  22263. ratio?: number;
  22264. bInfo?: any;
  22265. bbSize?: Vector3;
  22266. subDiv?: any;
  22267. useRightHandedSystem?: boolean;
  22268. depthSort?: boolean;
  22269. distanceTo?: Vector3;
  22270. depthSortedFacets?: any;
  22271. }): void;
  22272. /** @hidden */
  22273. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22274. /**
  22275. * Applies VertexData created from the imported parameters to the geometry
  22276. * @param parsedVertexData the parsed data from an imported file
  22277. * @param geometry the geometry to apply the VertexData to
  22278. */
  22279. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22280. }
  22281. }
  22282. declare module BABYLON {
  22283. /**
  22284. * Defines a target to use with MorphTargetManager
  22285. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22286. */
  22287. export class MorphTarget implements IAnimatable {
  22288. /** defines the name of the target */
  22289. name: string;
  22290. /**
  22291. * Gets or sets the list of animations
  22292. */
  22293. animations: Animation[];
  22294. private _scene;
  22295. private _positions;
  22296. private _normals;
  22297. private _tangents;
  22298. private _uvs;
  22299. private _influence;
  22300. private _uniqueId;
  22301. /**
  22302. * Observable raised when the influence changes
  22303. */
  22304. onInfluenceChanged: Observable<boolean>;
  22305. /** @hidden */
  22306. _onDataLayoutChanged: Observable<void>;
  22307. /**
  22308. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22309. */
  22310. influence: number;
  22311. /**
  22312. * Gets or sets the id of the morph Target
  22313. */
  22314. id: string;
  22315. private _animationPropertiesOverride;
  22316. /**
  22317. * Gets or sets the animation properties override
  22318. */
  22319. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22320. /**
  22321. * Creates a new MorphTarget
  22322. * @param name defines the name of the target
  22323. * @param influence defines the influence to use
  22324. * @param scene defines the scene the morphtarget belongs to
  22325. */
  22326. constructor(
  22327. /** defines the name of the target */
  22328. name: string, influence?: number, scene?: Nullable<Scene>);
  22329. /**
  22330. * Gets the unique ID of this manager
  22331. */
  22332. readonly uniqueId: number;
  22333. /**
  22334. * Gets a boolean defining if the target contains position data
  22335. */
  22336. readonly hasPositions: boolean;
  22337. /**
  22338. * Gets a boolean defining if the target contains normal data
  22339. */
  22340. readonly hasNormals: boolean;
  22341. /**
  22342. * Gets a boolean defining if the target contains tangent data
  22343. */
  22344. readonly hasTangents: boolean;
  22345. /**
  22346. * Gets a boolean defining if the target contains texture coordinates data
  22347. */
  22348. readonly hasUVs: boolean;
  22349. /**
  22350. * Affects position data to this target
  22351. * @param data defines the position data to use
  22352. */
  22353. setPositions(data: Nullable<FloatArray>): void;
  22354. /**
  22355. * Gets the position data stored in this target
  22356. * @returns a FloatArray containing the position data (or null if not present)
  22357. */
  22358. getPositions(): Nullable<FloatArray>;
  22359. /**
  22360. * Affects normal data to this target
  22361. * @param data defines the normal data to use
  22362. */
  22363. setNormals(data: Nullable<FloatArray>): void;
  22364. /**
  22365. * Gets the normal data stored in this target
  22366. * @returns a FloatArray containing the normal data (or null if not present)
  22367. */
  22368. getNormals(): Nullable<FloatArray>;
  22369. /**
  22370. * Affects tangent data to this target
  22371. * @param data defines the tangent data to use
  22372. */
  22373. setTangents(data: Nullable<FloatArray>): void;
  22374. /**
  22375. * Gets the tangent data stored in this target
  22376. * @returns a FloatArray containing the tangent data (or null if not present)
  22377. */
  22378. getTangents(): Nullable<FloatArray>;
  22379. /**
  22380. * Affects texture coordinates data to this target
  22381. * @param data defines the texture coordinates data to use
  22382. */
  22383. setUVs(data: Nullable<FloatArray>): void;
  22384. /**
  22385. * Gets the texture coordinates data stored in this target
  22386. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22387. */
  22388. getUVs(): Nullable<FloatArray>;
  22389. /**
  22390. * Clone the current target
  22391. * @returns a new MorphTarget
  22392. */
  22393. clone(): MorphTarget;
  22394. /**
  22395. * Serializes the current target into a Serialization object
  22396. * @returns the serialized object
  22397. */
  22398. serialize(): any;
  22399. /**
  22400. * Returns the string "MorphTarget"
  22401. * @returns "MorphTarget"
  22402. */
  22403. getClassName(): string;
  22404. /**
  22405. * Creates a new target from serialized data
  22406. * @param serializationObject defines the serialized data to use
  22407. * @returns a new MorphTarget
  22408. */
  22409. static Parse(serializationObject: any): MorphTarget;
  22410. /**
  22411. * Creates a MorphTarget from mesh data
  22412. * @param mesh defines the source mesh
  22413. * @param name defines the name to use for the new target
  22414. * @param influence defines the influence to attach to the target
  22415. * @returns a new MorphTarget
  22416. */
  22417. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22418. }
  22419. }
  22420. declare module BABYLON {
  22421. /**
  22422. * This class is used to deform meshes using morphing between different targets
  22423. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22424. */
  22425. export class MorphTargetManager {
  22426. private _targets;
  22427. private _targetInfluenceChangedObservers;
  22428. private _targetDataLayoutChangedObservers;
  22429. private _activeTargets;
  22430. private _scene;
  22431. private _influences;
  22432. private _supportsNormals;
  22433. private _supportsTangents;
  22434. private _supportsUVs;
  22435. private _vertexCount;
  22436. private _uniqueId;
  22437. private _tempInfluences;
  22438. /**
  22439. * Gets or sets a boolean indicating if normals must be morphed
  22440. */
  22441. enableNormalMorphing: boolean;
  22442. /**
  22443. * Gets or sets a boolean indicating if tangents must be morphed
  22444. */
  22445. enableTangentMorphing: boolean;
  22446. /**
  22447. * Gets or sets a boolean indicating if UV must be morphed
  22448. */
  22449. enableUVMorphing: boolean;
  22450. /**
  22451. * Creates a new MorphTargetManager
  22452. * @param scene defines the current scene
  22453. */
  22454. constructor(scene?: Nullable<Scene>);
  22455. /**
  22456. * Gets the unique ID of this manager
  22457. */
  22458. readonly uniqueId: number;
  22459. /**
  22460. * Gets the number of vertices handled by this manager
  22461. */
  22462. readonly vertexCount: number;
  22463. /**
  22464. * Gets a boolean indicating if this manager supports morphing of normals
  22465. */
  22466. readonly supportsNormals: boolean;
  22467. /**
  22468. * Gets a boolean indicating if this manager supports morphing of tangents
  22469. */
  22470. readonly supportsTangents: boolean;
  22471. /**
  22472. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22473. */
  22474. readonly supportsUVs: boolean;
  22475. /**
  22476. * Gets the number of targets stored in this manager
  22477. */
  22478. readonly numTargets: number;
  22479. /**
  22480. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22481. */
  22482. readonly numInfluencers: number;
  22483. /**
  22484. * Gets the list of influences (one per target)
  22485. */
  22486. readonly influences: Float32Array;
  22487. /**
  22488. * Gets the active target at specified index. An active target is a target with an influence > 0
  22489. * @param index defines the index to check
  22490. * @returns the requested target
  22491. */
  22492. getActiveTarget(index: number): MorphTarget;
  22493. /**
  22494. * Gets the target at specified index
  22495. * @param index defines the index to check
  22496. * @returns the requested target
  22497. */
  22498. getTarget(index: number): MorphTarget;
  22499. /**
  22500. * Add a new target to this manager
  22501. * @param target defines the target to add
  22502. */
  22503. addTarget(target: MorphTarget): void;
  22504. /**
  22505. * Removes a target from the manager
  22506. * @param target defines the target to remove
  22507. */
  22508. removeTarget(target: MorphTarget): void;
  22509. /**
  22510. * Clone the current manager
  22511. * @returns a new MorphTargetManager
  22512. */
  22513. clone(): MorphTargetManager;
  22514. /**
  22515. * Serializes the current manager into a Serialization object
  22516. * @returns the serialized object
  22517. */
  22518. serialize(): any;
  22519. private _syncActiveTargets;
  22520. /**
  22521. * Syncrhonize the targets with all the meshes using this morph target manager
  22522. */
  22523. synchronize(): void;
  22524. /**
  22525. * Creates a new MorphTargetManager from serialized data
  22526. * @param serializationObject defines the serialized data
  22527. * @param scene defines the hosting scene
  22528. * @returns the new MorphTargetManager
  22529. */
  22530. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22531. }
  22532. }
  22533. declare module BABYLON {
  22534. /**
  22535. * Class used to represent a specific level of detail of a mesh
  22536. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22537. */
  22538. export class MeshLODLevel {
  22539. /** Defines the distance where this level should start being displayed */
  22540. distance: number;
  22541. /** Defines the mesh to use to render this level */
  22542. mesh: Nullable<Mesh>;
  22543. /**
  22544. * Creates a new LOD level
  22545. * @param distance defines the distance where this level should star being displayed
  22546. * @param mesh defines the mesh to use to render this level
  22547. */
  22548. constructor(
  22549. /** Defines the distance where this level should start being displayed */
  22550. distance: number,
  22551. /** Defines the mesh to use to render this level */
  22552. mesh: Nullable<Mesh>);
  22553. }
  22554. }
  22555. declare module BABYLON {
  22556. /**
  22557. * Mesh representing the gorund
  22558. */
  22559. export class GroundMesh extends Mesh {
  22560. /** If octree should be generated */
  22561. generateOctree: boolean;
  22562. private _heightQuads;
  22563. /** @hidden */
  22564. _subdivisionsX: number;
  22565. /** @hidden */
  22566. _subdivisionsY: number;
  22567. /** @hidden */
  22568. _width: number;
  22569. /** @hidden */
  22570. _height: number;
  22571. /** @hidden */
  22572. _minX: number;
  22573. /** @hidden */
  22574. _maxX: number;
  22575. /** @hidden */
  22576. _minZ: number;
  22577. /** @hidden */
  22578. _maxZ: number;
  22579. constructor(name: string, scene: Scene);
  22580. /**
  22581. * "GroundMesh"
  22582. * @returns "GroundMesh"
  22583. */
  22584. getClassName(): string;
  22585. /**
  22586. * The minimum of x and y subdivisions
  22587. */
  22588. readonly subdivisions: number;
  22589. /**
  22590. * X subdivisions
  22591. */
  22592. readonly subdivisionsX: number;
  22593. /**
  22594. * Y subdivisions
  22595. */
  22596. readonly subdivisionsY: number;
  22597. /**
  22598. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22599. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22600. * @param chunksCount the number of subdivisions for x and y
  22601. * @param octreeBlocksSize (Default: 32)
  22602. */
  22603. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22604. /**
  22605. * Returns a height (y) value in the Worl system :
  22606. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22607. * @param x x coordinate
  22608. * @param z z coordinate
  22609. * @returns the ground y position if (x, z) are outside the ground surface.
  22610. */
  22611. getHeightAtCoordinates(x: number, z: number): number;
  22612. /**
  22613. * Returns a normalized vector (Vector3) orthogonal to the ground
  22614. * at the ground coordinates (x, z) expressed in the World system.
  22615. * @param x x coordinate
  22616. * @param z z coordinate
  22617. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22618. */
  22619. getNormalAtCoordinates(x: number, z: number): Vector3;
  22620. /**
  22621. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22622. * at the ground coordinates (x, z) expressed in the World system.
  22623. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22624. * @param x x coordinate
  22625. * @param z z coordinate
  22626. * @param ref vector to store the result
  22627. * @returns the GroundMesh.
  22628. */
  22629. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22630. /**
  22631. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22632. * if the ground has been updated.
  22633. * This can be used in the render loop.
  22634. * @returns the GroundMesh.
  22635. */
  22636. updateCoordinateHeights(): GroundMesh;
  22637. private _getFacetAt;
  22638. private _initHeightQuads;
  22639. private _computeHeightQuads;
  22640. /**
  22641. * Serializes this ground mesh
  22642. * @param serializationObject object to write serialization to
  22643. */
  22644. serialize(serializationObject: any): void;
  22645. /**
  22646. * Parses a serialized ground mesh
  22647. * @param parsedMesh the serialized mesh
  22648. * @param scene the scene to create the ground mesh in
  22649. * @returns the created ground mesh
  22650. */
  22651. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22652. }
  22653. }
  22654. declare module BABYLON {
  22655. /**
  22656. * Interface for Physics-Joint data
  22657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22658. */
  22659. export interface PhysicsJointData {
  22660. /**
  22661. * The main pivot of the joint
  22662. */
  22663. mainPivot?: Vector3;
  22664. /**
  22665. * The connected pivot of the joint
  22666. */
  22667. connectedPivot?: Vector3;
  22668. /**
  22669. * The main axis of the joint
  22670. */
  22671. mainAxis?: Vector3;
  22672. /**
  22673. * The connected axis of the joint
  22674. */
  22675. connectedAxis?: Vector3;
  22676. /**
  22677. * The collision of the joint
  22678. */
  22679. collision?: boolean;
  22680. /**
  22681. * Native Oimo/Cannon/Energy data
  22682. */
  22683. nativeParams?: any;
  22684. }
  22685. /**
  22686. * This is a holder class for the physics joint created by the physics plugin
  22687. * It holds a set of functions to control the underlying joint
  22688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22689. */
  22690. export class PhysicsJoint {
  22691. /**
  22692. * The type of the physics joint
  22693. */
  22694. type: number;
  22695. /**
  22696. * The data for the physics joint
  22697. */
  22698. jointData: PhysicsJointData;
  22699. private _physicsJoint;
  22700. protected _physicsPlugin: IPhysicsEnginePlugin;
  22701. /**
  22702. * Initializes the physics joint
  22703. * @param type The type of the physics joint
  22704. * @param jointData The data for the physics joint
  22705. */
  22706. constructor(
  22707. /**
  22708. * The type of the physics joint
  22709. */
  22710. type: number,
  22711. /**
  22712. * The data for the physics joint
  22713. */
  22714. jointData: PhysicsJointData);
  22715. /**
  22716. * Gets the physics joint
  22717. */
  22718. /**
  22719. * Sets the physics joint
  22720. */
  22721. physicsJoint: any;
  22722. /**
  22723. * Sets the physics plugin
  22724. */
  22725. physicsPlugin: IPhysicsEnginePlugin;
  22726. /**
  22727. * Execute a function that is physics-plugin specific.
  22728. * @param {Function} func the function that will be executed.
  22729. * It accepts two parameters: the physics world and the physics joint
  22730. */
  22731. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22732. /**
  22733. * Distance-Joint type
  22734. */
  22735. static DistanceJoint: number;
  22736. /**
  22737. * Hinge-Joint type
  22738. */
  22739. static HingeJoint: number;
  22740. /**
  22741. * Ball-and-Socket joint type
  22742. */
  22743. static BallAndSocketJoint: number;
  22744. /**
  22745. * Wheel-Joint type
  22746. */
  22747. static WheelJoint: number;
  22748. /**
  22749. * Slider-Joint type
  22750. */
  22751. static SliderJoint: number;
  22752. /**
  22753. * Prismatic-Joint type
  22754. */
  22755. static PrismaticJoint: number;
  22756. /**
  22757. * Universal-Joint type
  22758. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22759. */
  22760. static UniversalJoint: number;
  22761. /**
  22762. * Hinge-Joint 2 type
  22763. */
  22764. static Hinge2Joint: number;
  22765. /**
  22766. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22767. */
  22768. static PointToPointJoint: number;
  22769. /**
  22770. * Spring-Joint type
  22771. */
  22772. static SpringJoint: number;
  22773. /**
  22774. * Lock-Joint type
  22775. */
  22776. static LockJoint: number;
  22777. }
  22778. /**
  22779. * A class representing a physics distance joint
  22780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22781. */
  22782. export class DistanceJoint extends PhysicsJoint {
  22783. /**
  22784. *
  22785. * @param jointData The data for the Distance-Joint
  22786. */
  22787. constructor(jointData: DistanceJointData);
  22788. /**
  22789. * Update the predefined distance.
  22790. * @param maxDistance The maximum preferred distance
  22791. * @param minDistance The minimum preferred distance
  22792. */
  22793. updateDistance(maxDistance: number, minDistance?: number): void;
  22794. }
  22795. /**
  22796. * Represents a Motor-Enabled Joint
  22797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22798. */
  22799. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22800. /**
  22801. * Initializes the Motor-Enabled Joint
  22802. * @param type The type of the joint
  22803. * @param jointData The physica joint data for the joint
  22804. */
  22805. constructor(type: number, jointData: PhysicsJointData);
  22806. /**
  22807. * Set the motor values.
  22808. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22809. * @param force the force to apply
  22810. * @param maxForce max force for this motor.
  22811. */
  22812. setMotor(force?: number, maxForce?: number): void;
  22813. /**
  22814. * Set the motor's limits.
  22815. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22816. * @param upperLimit The upper limit of the motor
  22817. * @param lowerLimit The lower limit of the motor
  22818. */
  22819. setLimit(upperLimit: number, lowerLimit?: number): void;
  22820. }
  22821. /**
  22822. * This class represents a single physics Hinge-Joint
  22823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22824. */
  22825. export class HingeJoint extends MotorEnabledJoint {
  22826. /**
  22827. * Initializes the Hinge-Joint
  22828. * @param jointData The joint data for the Hinge-Joint
  22829. */
  22830. constructor(jointData: PhysicsJointData);
  22831. /**
  22832. * Set the motor values.
  22833. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22834. * @param {number} force the force to apply
  22835. * @param {number} maxForce max force for this motor.
  22836. */
  22837. setMotor(force?: number, maxForce?: number): void;
  22838. /**
  22839. * Set the motor's limits.
  22840. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22841. * @param upperLimit The upper limit of the motor
  22842. * @param lowerLimit The lower limit of the motor
  22843. */
  22844. setLimit(upperLimit: number, lowerLimit?: number): void;
  22845. }
  22846. /**
  22847. * This class represents a dual hinge physics joint (same as wheel joint)
  22848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22849. */
  22850. export class Hinge2Joint extends MotorEnabledJoint {
  22851. /**
  22852. * Initializes the Hinge2-Joint
  22853. * @param jointData The joint data for the Hinge2-Joint
  22854. */
  22855. constructor(jointData: PhysicsJointData);
  22856. /**
  22857. * Set the motor values.
  22858. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22859. * @param {number} targetSpeed the speed the motor is to reach
  22860. * @param {number} maxForce max force for this motor.
  22861. * @param {motorIndex} the motor's index, 0 or 1.
  22862. */
  22863. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22864. /**
  22865. * Set the motor limits.
  22866. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22867. * @param {number} upperLimit the upper limit
  22868. * @param {number} lowerLimit lower limit
  22869. * @param {motorIndex} the motor's index, 0 or 1.
  22870. */
  22871. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22872. }
  22873. /**
  22874. * Interface for a motor enabled joint
  22875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22876. */
  22877. export interface IMotorEnabledJoint {
  22878. /**
  22879. * Physics joint
  22880. */
  22881. physicsJoint: any;
  22882. /**
  22883. * Sets the motor of the motor-enabled joint
  22884. * @param force The force of the motor
  22885. * @param maxForce The maximum force of the motor
  22886. * @param motorIndex The index of the motor
  22887. */
  22888. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22889. /**
  22890. * Sets the limit of the motor
  22891. * @param upperLimit The upper limit of the motor
  22892. * @param lowerLimit The lower limit of the motor
  22893. * @param motorIndex The index of the motor
  22894. */
  22895. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22896. }
  22897. /**
  22898. * Joint data for a Distance-Joint
  22899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22900. */
  22901. export interface DistanceJointData extends PhysicsJointData {
  22902. /**
  22903. * Max distance the 2 joint objects can be apart
  22904. */
  22905. maxDistance: number;
  22906. }
  22907. /**
  22908. * Joint data from a spring joint
  22909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22910. */
  22911. export interface SpringJointData extends PhysicsJointData {
  22912. /**
  22913. * Length of the spring
  22914. */
  22915. length: number;
  22916. /**
  22917. * Stiffness of the spring
  22918. */
  22919. stiffness: number;
  22920. /**
  22921. * Damping of the spring
  22922. */
  22923. damping: number;
  22924. /** this callback will be called when applying the force to the impostors. */
  22925. forceApplicationCallback: () => void;
  22926. }
  22927. }
  22928. declare module BABYLON {
  22929. /**
  22930. * Holds the data for the raycast result
  22931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22932. */
  22933. export class PhysicsRaycastResult {
  22934. private _hasHit;
  22935. private _hitDistance;
  22936. private _hitNormalWorld;
  22937. private _hitPointWorld;
  22938. private _rayFromWorld;
  22939. private _rayToWorld;
  22940. /**
  22941. * Gets if there was a hit
  22942. */
  22943. readonly hasHit: boolean;
  22944. /**
  22945. * Gets the distance from the hit
  22946. */
  22947. readonly hitDistance: number;
  22948. /**
  22949. * Gets the hit normal/direction in the world
  22950. */
  22951. readonly hitNormalWorld: Vector3;
  22952. /**
  22953. * Gets the hit point in the world
  22954. */
  22955. readonly hitPointWorld: Vector3;
  22956. /**
  22957. * Gets the ray "start point" of the ray in the world
  22958. */
  22959. readonly rayFromWorld: Vector3;
  22960. /**
  22961. * Gets the ray "end point" of the ray in the world
  22962. */
  22963. readonly rayToWorld: Vector3;
  22964. /**
  22965. * Sets the hit data (normal & point in world space)
  22966. * @param hitNormalWorld defines the normal in world space
  22967. * @param hitPointWorld defines the point in world space
  22968. */
  22969. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22970. /**
  22971. * Sets the distance from the start point to the hit point
  22972. * @param distance
  22973. */
  22974. setHitDistance(distance: number): void;
  22975. /**
  22976. * Calculates the distance manually
  22977. */
  22978. calculateHitDistance(): void;
  22979. /**
  22980. * Resets all the values to default
  22981. * @param from The from point on world space
  22982. * @param to The to point on world space
  22983. */
  22984. reset(from?: Vector3, to?: Vector3): void;
  22985. }
  22986. /**
  22987. * Interface for the size containing width and height
  22988. */
  22989. interface IXYZ {
  22990. /**
  22991. * X
  22992. */
  22993. x: number;
  22994. /**
  22995. * Y
  22996. */
  22997. y: number;
  22998. /**
  22999. * Z
  23000. */
  23001. z: number;
  23002. }
  23003. }
  23004. declare module BABYLON {
  23005. /**
  23006. * Interface used to describe a physics joint
  23007. */
  23008. export interface PhysicsImpostorJoint {
  23009. /** Defines the main impostor to which the joint is linked */
  23010. mainImpostor: PhysicsImpostor;
  23011. /** Defines the impostor that is connected to the main impostor using this joint */
  23012. connectedImpostor: PhysicsImpostor;
  23013. /** Defines the joint itself */
  23014. joint: PhysicsJoint;
  23015. }
  23016. /** @hidden */
  23017. export interface IPhysicsEnginePlugin {
  23018. world: any;
  23019. name: string;
  23020. setGravity(gravity: Vector3): void;
  23021. setTimeStep(timeStep: number): void;
  23022. getTimeStep(): number;
  23023. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23024. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23025. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23026. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23027. removePhysicsBody(impostor: PhysicsImpostor): void;
  23028. generateJoint(joint: PhysicsImpostorJoint): void;
  23029. removeJoint(joint: PhysicsImpostorJoint): void;
  23030. isSupported(): boolean;
  23031. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23032. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23033. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23034. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23035. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23036. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23037. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23038. getBodyMass(impostor: PhysicsImpostor): number;
  23039. getBodyFriction(impostor: PhysicsImpostor): number;
  23040. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23041. getBodyRestitution(impostor: PhysicsImpostor): number;
  23042. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23043. getBodyPressure?(impostor: PhysicsImpostor): number;
  23044. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23045. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23046. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23047. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23048. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23049. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23050. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23051. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23052. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23053. sleepBody(impostor: PhysicsImpostor): void;
  23054. wakeUpBody(impostor: PhysicsImpostor): void;
  23055. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23056. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23057. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23058. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23059. getRadius(impostor: PhysicsImpostor): number;
  23060. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23061. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23062. dispose(): void;
  23063. }
  23064. /**
  23065. * Interface used to define a physics engine
  23066. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23067. */
  23068. export interface IPhysicsEngine {
  23069. /**
  23070. * Gets the gravity vector used by the simulation
  23071. */
  23072. gravity: Vector3;
  23073. /**
  23074. * Sets the gravity vector used by the simulation
  23075. * @param gravity defines the gravity vector to use
  23076. */
  23077. setGravity(gravity: Vector3): void;
  23078. /**
  23079. * Set the time step of the physics engine.
  23080. * Default is 1/60.
  23081. * To slow it down, enter 1/600 for example.
  23082. * To speed it up, 1/30
  23083. * @param newTimeStep the new timestep to apply to this world.
  23084. */
  23085. setTimeStep(newTimeStep: number): void;
  23086. /**
  23087. * Get the time step of the physics engine.
  23088. * @returns the current time step
  23089. */
  23090. getTimeStep(): number;
  23091. /**
  23092. * Set the sub time step of the physics engine.
  23093. * Default is 0 meaning there is no sub steps
  23094. * To increase physics resolution precision, set a small value (like 1 ms)
  23095. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23096. */
  23097. setSubTimeStep(subTimeStep: number): void;
  23098. /**
  23099. * Get the sub time step of the physics engine.
  23100. * @returns the current sub time step
  23101. */
  23102. getSubTimeStep(): number;
  23103. /**
  23104. * Release all resources
  23105. */
  23106. dispose(): void;
  23107. /**
  23108. * Gets the name of the current physics plugin
  23109. * @returns the name of the plugin
  23110. */
  23111. getPhysicsPluginName(): string;
  23112. /**
  23113. * Adding a new impostor for the impostor tracking.
  23114. * This will be done by the impostor itself.
  23115. * @param impostor the impostor to add
  23116. */
  23117. addImpostor(impostor: PhysicsImpostor): void;
  23118. /**
  23119. * Remove an impostor from the engine.
  23120. * This impostor and its mesh will not longer be updated by the physics engine.
  23121. * @param impostor the impostor to remove
  23122. */
  23123. removeImpostor(impostor: PhysicsImpostor): void;
  23124. /**
  23125. * Add a joint to the physics engine
  23126. * @param mainImpostor defines the main impostor to which the joint is added.
  23127. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23128. * @param joint defines the joint that will connect both impostors.
  23129. */
  23130. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23131. /**
  23132. * Removes a joint from the simulation
  23133. * @param mainImpostor defines the impostor used with the joint
  23134. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23135. * @param joint defines the joint to remove
  23136. */
  23137. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23138. /**
  23139. * Gets the current plugin used to run the simulation
  23140. * @returns current plugin
  23141. */
  23142. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23143. /**
  23144. * Gets the list of physic impostors
  23145. * @returns an array of PhysicsImpostor
  23146. */
  23147. getImpostors(): Array<PhysicsImpostor>;
  23148. /**
  23149. * Gets the impostor for a physics enabled object
  23150. * @param object defines the object impersonated by the impostor
  23151. * @returns the PhysicsImpostor or null if not found
  23152. */
  23153. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23154. /**
  23155. * Gets the impostor for a physics body object
  23156. * @param body defines physics body used by the impostor
  23157. * @returns the PhysicsImpostor or null if not found
  23158. */
  23159. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23160. /**
  23161. * Does a raycast in the physics world
  23162. * @param from when should the ray start?
  23163. * @param to when should the ray end?
  23164. * @returns PhysicsRaycastResult
  23165. */
  23166. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23167. /**
  23168. * Called by the scene. No need to call it.
  23169. * @param delta defines the timespam between frames
  23170. */
  23171. _step(delta: number): void;
  23172. }
  23173. }
  23174. declare module BABYLON {
  23175. /**
  23176. * The interface for the physics imposter parameters
  23177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23178. */
  23179. export interface PhysicsImpostorParameters {
  23180. /**
  23181. * The mass of the physics imposter
  23182. */
  23183. mass: number;
  23184. /**
  23185. * The friction of the physics imposter
  23186. */
  23187. friction?: number;
  23188. /**
  23189. * The coefficient of restitution of the physics imposter
  23190. */
  23191. restitution?: number;
  23192. /**
  23193. * The native options of the physics imposter
  23194. */
  23195. nativeOptions?: any;
  23196. /**
  23197. * Specifies if the parent should be ignored
  23198. */
  23199. ignoreParent?: boolean;
  23200. /**
  23201. * Specifies if bi-directional transformations should be disabled
  23202. */
  23203. disableBidirectionalTransformation?: boolean;
  23204. /**
  23205. * The pressure inside the physics imposter, soft object only
  23206. */
  23207. pressure?: number;
  23208. /**
  23209. * The stiffness the physics imposter, soft object only
  23210. */
  23211. stiffness?: number;
  23212. /**
  23213. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23214. */
  23215. velocityIterations?: number;
  23216. /**
  23217. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23218. */
  23219. positionIterations?: number;
  23220. /**
  23221. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23222. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23223. * Add to fix multiple points
  23224. */
  23225. fixedPoints?: number;
  23226. /**
  23227. * The collision margin around a soft object
  23228. */
  23229. margin?: number;
  23230. /**
  23231. * The collision margin around a soft object
  23232. */
  23233. damping?: number;
  23234. /**
  23235. * The path for a rope based on an extrusion
  23236. */
  23237. path?: any;
  23238. /**
  23239. * The shape of an extrusion used for a rope based on an extrusion
  23240. */
  23241. shape?: any;
  23242. }
  23243. /**
  23244. * Interface for a physics-enabled object
  23245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23246. */
  23247. export interface IPhysicsEnabledObject {
  23248. /**
  23249. * The position of the physics-enabled object
  23250. */
  23251. position: Vector3;
  23252. /**
  23253. * The rotation of the physics-enabled object
  23254. */
  23255. rotationQuaternion: Nullable<Quaternion>;
  23256. /**
  23257. * The scale of the physics-enabled object
  23258. */
  23259. scaling: Vector3;
  23260. /**
  23261. * The rotation of the physics-enabled object
  23262. */
  23263. rotation?: Vector3;
  23264. /**
  23265. * The parent of the physics-enabled object
  23266. */
  23267. parent?: any;
  23268. /**
  23269. * The bounding info of the physics-enabled object
  23270. * @returns The bounding info of the physics-enabled object
  23271. */
  23272. getBoundingInfo(): BoundingInfo;
  23273. /**
  23274. * Computes the world matrix
  23275. * @param force Specifies if the world matrix should be computed by force
  23276. * @returns A world matrix
  23277. */
  23278. computeWorldMatrix(force: boolean): Matrix;
  23279. /**
  23280. * Gets the world matrix
  23281. * @returns A world matrix
  23282. */
  23283. getWorldMatrix?(): Matrix;
  23284. /**
  23285. * Gets the child meshes
  23286. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23287. * @returns An array of abstract meshes
  23288. */
  23289. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23290. /**
  23291. * Gets the vertex data
  23292. * @param kind The type of vertex data
  23293. * @returns A nullable array of numbers, or a float32 array
  23294. */
  23295. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23296. /**
  23297. * Gets the indices from the mesh
  23298. * @returns A nullable array of index arrays
  23299. */
  23300. getIndices?(): Nullable<IndicesArray>;
  23301. /**
  23302. * Gets the scene from the mesh
  23303. * @returns the indices array or null
  23304. */
  23305. getScene?(): Scene;
  23306. /**
  23307. * Gets the absolute position from the mesh
  23308. * @returns the absolute position
  23309. */
  23310. getAbsolutePosition(): Vector3;
  23311. /**
  23312. * Gets the absolute pivot point from the mesh
  23313. * @returns the absolute pivot point
  23314. */
  23315. getAbsolutePivotPoint(): Vector3;
  23316. /**
  23317. * Rotates the mesh
  23318. * @param axis The axis of rotation
  23319. * @param amount The amount of rotation
  23320. * @param space The space of the rotation
  23321. * @returns The rotation transform node
  23322. */
  23323. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23324. /**
  23325. * Translates the mesh
  23326. * @param axis The axis of translation
  23327. * @param distance The distance of translation
  23328. * @param space The space of the translation
  23329. * @returns The transform node
  23330. */
  23331. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23332. /**
  23333. * Sets the absolute position of the mesh
  23334. * @param absolutePosition The absolute position of the mesh
  23335. * @returns The transform node
  23336. */
  23337. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23338. /**
  23339. * Gets the class name of the mesh
  23340. * @returns The class name
  23341. */
  23342. getClassName(): string;
  23343. }
  23344. /**
  23345. * Represents a physics imposter
  23346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23347. */
  23348. export class PhysicsImpostor {
  23349. /**
  23350. * The physics-enabled object used as the physics imposter
  23351. */
  23352. object: IPhysicsEnabledObject;
  23353. /**
  23354. * The type of the physics imposter
  23355. */
  23356. type: number;
  23357. private _options;
  23358. private _scene?;
  23359. /**
  23360. * The default object size of the imposter
  23361. */
  23362. static DEFAULT_OBJECT_SIZE: Vector3;
  23363. /**
  23364. * The identity quaternion of the imposter
  23365. */
  23366. static IDENTITY_QUATERNION: Quaternion;
  23367. /** @hidden */
  23368. _pluginData: any;
  23369. private _physicsEngine;
  23370. private _physicsBody;
  23371. private _bodyUpdateRequired;
  23372. private _onBeforePhysicsStepCallbacks;
  23373. private _onAfterPhysicsStepCallbacks;
  23374. /** @hidden */
  23375. _onPhysicsCollideCallbacks: Array<{
  23376. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23377. otherImpostors: Array<PhysicsImpostor>;
  23378. }>;
  23379. private _deltaPosition;
  23380. private _deltaRotation;
  23381. private _deltaRotationConjugated;
  23382. /** @hidden */
  23383. _isFromLine: boolean;
  23384. private _parent;
  23385. private _isDisposed;
  23386. private static _tmpVecs;
  23387. private static _tmpQuat;
  23388. /**
  23389. * Specifies if the physics imposter is disposed
  23390. */
  23391. readonly isDisposed: boolean;
  23392. /**
  23393. * Gets the mass of the physics imposter
  23394. */
  23395. mass: number;
  23396. /**
  23397. * Gets the coefficient of friction
  23398. */
  23399. /**
  23400. * Sets the coefficient of friction
  23401. */
  23402. friction: number;
  23403. /**
  23404. * Gets the coefficient of restitution
  23405. */
  23406. /**
  23407. * Sets the coefficient of restitution
  23408. */
  23409. restitution: number;
  23410. /**
  23411. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23412. */
  23413. /**
  23414. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23415. */
  23416. pressure: number;
  23417. /**
  23418. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23419. */
  23420. /**
  23421. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23422. */
  23423. stiffness: number;
  23424. /**
  23425. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23426. */
  23427. /**
  23428. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23429. */
  23430. velocityIterations: number;
  23431. /**
  23432. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23433. */
  23434. /**
  23435. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23436. */
  23437. positionIterations: number;
  23438. /**
  23439. * The unique id of the physics imposter
  23440. * set by the physics engine when adding this impostor to the array
  23441. */
  23442. uniqueId: number;
  23443. /**
  23444. * @hidden
  23445. */
  23446. soft: boolean;
  23447. /**
  23448. * @hidden
  23449. */
  23450. segments: number;
  23451. private _joints;
  23452. /**
  23453. * Initializes the physics imposter
  23454. * @param object The physics-enabled object used as the physics imposter
  23455. * @param type The type of the physics imposter
  23456. * @param _options The options for the physics imposter
  23457. * @param _scene The Babylon scene
  23458. */
  23459. constructor(
  23460. /**
  23461. * The physics-enabled object used as the physics imposter
  23462. */
  23463. object: IPhysicsEnabledObject,
  23464. /**
  23465. * The type of the physics imposter
  23466. */
  23467. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23468. /**
  23469. * This function will completly initialize this impostor.
  23470. * It will create a new body - but only if this mesh has no parent.
  23471. * If it has, this impostor will not be used other than to define the impostor
  23472. * of the child mesh.
  23473. * @hidden
  23474. */
  23475. _init(): void;
  23476. private _getPhysicsParent;
  23477. /**
  23478. * Should a new body be generated.
  23479. * @returns boolean specifying if body initialization is required
  23480. */
  23481. isBodyInitRequired(): boolean;
  23482. /**
  23483. * Sets the updated scaling
  23484. * @param updated Specifies if the scaling is updated
  23485. */
  23486. setScalingUpdated(): void;
  23487. /**
  23488. * Force a regeneration of this or the parent's impostor's body.
  23489. * Use under cautious - This will remove all joints already implemented.
  23490. */
  23491. forceUpdate(): void;
  23492. /**
  23493. * Gets the body that holds this impostor. Either its own, or its parent.
  23494. */
  23495. /**
  23496. * Set the physics body. Used mainly by the physics engine/plugin
  23497. */
  23498. physicsBody: any;
  23499. /**
  23500. * Get the parent of the physics imposter
  23501. * @returns Physics imposter or null
  23502. */
  23503. /**
  23504. * Sets the parent of the physics imposter
  23505. */
  23506. parent: Nullable<PhysicsImpostor>;
  23507. /**
  23508. * Resets the update flags
  23509. */
  23510. resetUpdateFlags(): void;
  23511. /**
  23512. * Gets the object extend size
  23513. * @returns the object extend size
  23514. */
  23515. getObjectExtendSize(): Vector3;
  23516. /**
  23517. * Gets the object center
  23518. * @returns The object center
  23519. */
  23520. getObjectCenter(): Vector3;
  23521. /**
  23522. * Get a specific parametes from the options parameter
  23523. * @param paramName The object parameter name
  23524. * @returns The object parameter
  23525. */
  23526. getParam(paramName: string): any;
  23527. /**
  23528. * Sets a specific parameter in the options given to the physics plugin
  23529. * @param paramName The parameter name
  23530. * @param value The value of the parameter
  23531. */
  23532. setParam(paramName: string, value: number): void;
  23533. /**
  23534. * Specifically change the body's mass option. Won't recreate the physics body object
  23535. * @param mass The mass of the physics imposter
  23536. */
  23537. setMass(mass: number): void;
  23538. /**
  23539. * Gets the linear velocity
  23540. * @returns linear velocity or null
  23541. */
  23542. getLinearVelocity(): Nullable<Vector3>;
  23543. /**
  23544. * Sets the linear velocity
  23545. * @param velocity linear velocity or null
  23546. */
  23547. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23548. /**
  23549. * Gets the angular velocity
  23550. * @returns angular velocity or null
  23551. */
  23552. getAngularVelocity(): Nullable<Vector3>;
  23553. /**
  23554. * Sets the angular velocity
  23555. * @param velocity The velocity or null
  23556. */
  23557. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23558. /**
  23559. * Execute a function with the physics plugin native code
  23560. * Provide a function the will have two variables - the world object and the physics body object
  23561. * @param func The function to execute with the physics plugin native code
  23562. */
  23563. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23564. /**
  23565. * Register a function that will be executed before the physics world is stepping forward
  23566. * @param func The function to execute before the physics world is stepped forward
  23567. */
  23568. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23569. /**
  23570. * Unregister a function that will be executed before the physics world is stepping forward
  23571. * @param func The function to execute before the physics world is stepped forward
  23572. */
  23573. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23574. /**
  23575. * Register a function that will be executed after the physics step
  23576. * @param func The function to execute after physics step
  23577. */
  23578. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23579. /**
  23580. * Unregisters a function that will be executed after the physics step
  23581. * @param func The function to execute after physics step
  23582. */
  23583. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23584. /**
  23585. * register a function that will be executed when this impostor collides against a different body
  23586. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23587. * @param func Callback that is executed on collision
  23588. */
  23589. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23590. /**
  23591. * Unregisters the physics imposter on contact
  23592. * @param collideAgainst The physics object to collide against
  23593. * @param func Callback to execute on collision
  23594. */
  23595. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23596. private _tmpQuat;
  23597. private _tmpQuat2;
  23598. /**
  23599. * Get the parent rotation
  23600. * @returns The parent rotation
  23601. */
  23602. getParentsRotation(): Quaternion;
  23603. /**
  23604. * this function is executed by the physics engine.
  23605. */
  23606. beforeStep: () => void;
  23607. /**
  23608. * this function is executed by the physics engine
  23609. */
  23610. afterStep: () => void;
  23611. /**
  23612. * Legacy collision detection event support
  23613. */
  23614. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23615. /**
  23616. * event and body object due to cannon's event-based architecture.
  23617. */
  23618. onCollide: (e: {
  23619. body: any;
  23620. }) => void;
  23621. /**
  23622. * Apply a force
  23623. * @param force The force to apply
  23624. * @param contactPoint The contact point for the force
  23625. * @returns The physics imposter
  23626. */
  23627. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23628. /**
  23629. * Apply an impulse
  23630. * @param force The impulse force
  23631. * @param contactPoint The contact point for the impulse force
  23632. * @returns The physics imposter
  23633. */
  23634. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23635. /**
  23636. * A help function to create a joint
  23637. * @param otherImpostor A physics imposter used to create a joint
  23638. * @param jointType The type of joint
  23639. * @param jointData The data for the joint
  23640. * @returns The physics imposter
  23641. */
  23642. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23643. /**
  23644. * Add a joint to this impostor with a different impostor
  23645. * @param otherImpostor A physics imposter used to add a joint
  23646. * @param joint The joint to add
  23647. * @returns The physics imposter
  23648. */
  23649. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23650. /**
  23651. * Add an anchor to a cloth impostor
  23652. * @param otherImpostor rigid impostor to anchor to
  23653. * @param width ratio across width from 0 to 1
  23654. * @param height ratio up height from 0 to 1
  23655. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23656. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23657. * @returns impostor the soft imposter
  23658. */
  23659. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23660. /**
  23661. * Add a hook to a rope impostor
  23662. * @param otherImpostor rigid impostor to anchor to
  23663. * @param length ratio across rope from 0 to 1
  23664. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23665. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23666. * @returns impostor the rope imposter
  23667. */
  23668. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23669. /**
  23670. * Will keep this body still, in a sleep mode.
  23671. * @returns the physics imposter
  23672. */
  23673. sleep(): PhysicsImpostor;
  23674. /**
  23675. * Wake the body up.
  23676. * @returns The physics imposter
  23677. */
  23678. wakeUp(): PhysicsImpostor;
  23679. /**
  23680. * Clones the physics imposter
  23681. * @param newObject The physics imposter clones to this physics-enabled object
  23682. * @returns A nullable physics imposter
  23683. */
  23684. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23685. /**
  23686. * Disposes the physics imposter
  23687. */
  23688. dispose(): void;
  23689. /**
  23690. * Sets the delta position
  23691. * @param position The delta position amount
  23692. */
  23693. setDeltaPosition(position: Vector3): void;
  23694. /**
  23695. * Sets the delta rotation
  23696. * @param rotation The delta rotation amount
  23697. */
  23698. setDeltaRotation(rotation: Quaternion): void;
  23699. /**
  23700. * Gets the box size of the physics imposter and stores the result in the input parameter
  23701. * @param result Stores the box size
  23702. * @returns The physics imposter
  23703. */
  23704. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23705. /**
  23706. * Gets the radius of the physics imposter
  23707. * @returns Radius of the physics imposter
  23708. */
  23709. getRadius(): number;
  23710. /**
  23711. * Sync a bone with this impostor
  23712. * @param bone The bone to sync to the impostor.
  23713. * @param boneMesh The mesh that the bone is influencing.
  23714. * @param jointPivot The pivot of the joint / bone in local space.
  23715. * @param distToJoint Optional distance from the impostor to the joint.
  23716. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23717. */
  23718. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23719. /**
  23720. * Sync impostor to a bone
  23721. * @param bone The bone that the impostor will be synced to.
  23722. * @param boneMesh The mesh that the bone is influencing.
  23723. * @param jointPivot The pivot of the joint / bone in local space.
  23724. * @param distToJoint Optional distance from the impostor to the joint.
  23725. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23726. * @param boneAxis Optional vector3 axis the bone is aligned with
  23727. */
  23728. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23729. /**
  23730. * No-Imposter type
  23731. */
  23732. static NoImpostor: number;
  23733. /**
  23734. * Sphere-Imposter type
  23735. */
  23736. static SphereImpostor: number;
  23737. /**
  23738. * Box-Imposter type
  23739. */
  23740. static BoxImpostor: number;
  23741. /**
  23742. * Plane-Imposter type
  23743. */
  23744. static PlaneImpostor: number;
  23745. /**
  23746. * Mesh-imposter type
  23747. */
  23748. static MeshImpostor: number;
  23749. /**
  23750. * Capsule-Impostor type (Ammo.js plugin only)
  23751. */
  23752. static CapsuleImpostor: number;
  23753. /**
  23754. * Cylinder-Imposter type
  23755. */
  23756. static CylinderImpostor: number;
  23757. /**
  23758. * Particle-Imposter type
  23759. */
  23760. static ParticleImpostor: number;
  23761. /**
  23762. * Heightmap-Imposter type
  23763. */
  23764. static HeightmapImpostor: number;
  23765. /**
  23766. * ConvexHull-Impostor type (Ammo.js plugin only)
  23767. */
  23768. static ConvexHullImpostor: number;
  23769. /**
  23770. * Custom-Imposter type (Ammo.js plugin only)
  23771. */
  23772. static CustomImpostor: number;
  23773. /**
  23774. * Rope-Imposter type
  23775. */
  23776. static RopeImpostor: number;
  23777. /**
  23778. * Cloth-Imposter type
  23779. */
  23780. static ClothImpostor: number;
  23781. /**
  23782. * Softbody-Imposter type
  23783. */
  23784. static SoftbodyImpostor: number;
  23785. }
  23786. }
  23787. declare module BABYLON {
  23788. /**
  23789. * @hidden
  23790. **/
  23791. export class _CreationDataStorage {
  23792. closePath?: boolean;
  23793. closeArray?: boolean;
  23794. idx: number[];
  23795. dashSize: number;
  23796. gapSize: number;
  23797. path3D: Path3D;
  23798. pathArray: Vector3[][];
  23799. arc: number;
  23800. radius: number;
  23801. cap: number;
  23802. tessellation: number;
  23803. }
  23804. /**
  23805. * @hidden
  23806. **/
  23807. class _InstanceDataStorage {
  23808. visibleInstances: any;
  23809. batchCache: _InstancesBatch;
  23810. instancesBufferSize: number;
  23811. instancesBuffer: Nullable<Buffer>;
  23812. instancesData: Float32Array;
  23813. overridenInstanceCount: number;
  23814. isFrozen: boolean;
  23815. previousBatch: Nullable<_InstancesBatch>;
  23816. hardwareInstancedRendering: boolean;
  23817. sideOrientation: number;
  23818. manualUpdate: boolean;
  23819. }
  23820. /**
  23821. * @hidden
  23822. **/
  23823. export class _InstancesBatch {
  23824. mustReturn: boolean;
  23825. visibleInstances: Nullable<InstancedMesh[]>[];
  23826. renderSelf: boolean[];
  23827. hardwareInstancedRendering: boolean[];
  23828. }
  23829. /**
  23830. * Class used to represent renderable models
  23831. */
  23832. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23833. /**
  23834. * Mesh side orientation : usually the external or front surface
  23835. */
  23836. static readonly FRONTSIDE: number;
  23837. /**
  23838. * Mesh side orientation : usually the internal or back surface
  23839. */
  23840. static readonly BACKSIDE: number;
  23841. /**
  23842. * Mesh side orientation : both internal and external or front and back surfaces
  23843. */
  23844. static readonly DOUBLESIDE: number;
  23845. /**
  23846. * Mesh side orientation : by default, `FRONTSIDE`
  23847. */
  23848. static readonly DEFAULTSIDE: number;
  23849. /**
  23850. * Mesh cap setting : no cap
  23851. */
  23852. static readonly NO_CAP: number;
  23853. /**
  23854. * Mesh cap setting : one cap at the beginning of the mesh
  23855. */
  23856. static readonly CAP_START: number;
  23857. /**
  23858. * Mesh cap setting : one cap at the end of the mesh
  23859. */
  23860. static readonly CAP_END: number;
  23861. /**
  23862. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23863. */
  23864. static readonly CAP_ALL: number;
  23865. /**
  23866. * Mesh pattern setting : no flip or rotate
  23867. */
  23868. static readonly NO_FLIP: number;
  23869. /**
  23870. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23871. */
  23872. static readonly FLIP_TILE: number;
  23873. /**
  23874. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23875. */
  23876. static readonly ROTATE_TILE: number;
  23877. /**
  23878. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23879. */
  23880. static readonly FLIP_ROW: number;
  23881. /**
  23882. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23883. */
  23884. static readonly ROTATE_ROW: number;
  23885. /**
  23886. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23887. */
  23888. static readonly FLIP_N_ROTATE_TILE: number;
  23889. /**
  23890. * Mesh pattern setting : rotate pattern and rotate
  23891. */
  23892. static readonly FLIP_N_ROTATE_ROW: number;
  23893. /**
  23894. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23895. */
  23896. static readonly CENTER: number;
  23897. /**
  23898. * Mesh tile positioning : part tiles on left
  23899. */
  23900. static readonly LEFT: number;
  23901. /**
  23902. * Mesh tile positioning : part tiles on right
  23903. */
  23904. static readonly RIGHT: number;
  23905. /**
  23906. * Mesh tile positioning : part tiles on top
  23907. */
  23908. static readonly TOP: number;
  23909. /**
  23910. * Mesh tile positioning : part tiles on bottom
  23911. */
  23912. static readonly BOTTOM: number;
  23913. /**
  23914. * Gets the default side orientation.
  23915. * @param orientation the orientation to value to attempt to get
  23916. * @returns the default orientation
  23917. * @hidden
  23918. */
  23919. static _GetDefaultSideOrientation(orientation?: number): number;
  23920. private _internalMeshDataInfo;
  23921. /**
  23922. * An event triggered before rendering the mesh
  23923. */
  23924. readonly onBeforeRenderObservable: Observable<Mesh>;
  23925. /**
  23926. * An event triggered before binding the mesh
  23927. */
  23928. readonly onBeforeBindObservable: Observable<Mesh>;
  23929. /**
  23930. * An event triggered after rendering the mesh
  23931. */
  23932. readonly onAfterRenderObservable: Observable<Mesh>;
  23933. /**
  23934. * An event triggered before drawing the mesh
  23935. */
  23936. readonly onBeforeDrawObservable: Observable<Mesh>;
  23937. private _onBeforeDrawObserver;
  23938. /**
  23939. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23940. */
  23941. onBeforeDraw: () => void;
  23942. readonly hasInstances: boolean;
  23943. /**
  23944. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23945. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23946. */
  23947. delayLoadState: number;
  23948. /**
  23949. * Gets the list of instances created from this mesh
  23950. * it is not supposed to be modified manually.
  23951. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23952. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23953. */
  23954. instances: InstancedMesh[];
  23955. /**
  23956. * Gets the file containing delay loading data for this mesh
  23957. */
  23958. delayLoadingFile: string;
  23959. /** @hidden */
  23960. _binaryInfo: any;
  23961. /**
  23962. * User defined function used to change how LOD level selection is done
  23963. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23964. */
  23965. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23966. /**
  23967. * Gets or sets the morph target manager
  23968. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23969. */
  23970. morphTargetManager: Nullable<MorphTargetManager>;
  23971. /** @hidden */
  23972. _creationDataStorage: Nullable<_CreationDataStorage>;
  23973. /** @hidden */
  23974. _geometry: Nullable<Geometry>;
  23975. /** @hidden */
  23976. _delayInfo: Array<string>;
  23977. /** @hidden */
  23978. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23979. /** @hidden */
  23980. _instanceDataStorage: _InstanceDataStorage;
  23981. private _effectiveMaterial;
  23982. /** @hidden */
  23983. _shouldGenerateFlatShading: boolean;
  23984. /** @hidden */
  23985. _originalBuilderSideOrientation: number;
  23986. /**
  23987. * Use this property to change the original side orientation defined at construction time
  23988. */
  23989. overrideMaterialSideOrientation: Nullable<number>;
  23990. /**
  23991. * Gets the source mesh (the one used to clone this one from)
  23992. */
  23993. readonly source: Nullable<Mesh>;
  23994. /**
  23995. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23996. */
  23997. isUnIndexed: boolean;
  23998. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  23999. readonly worldMatrixInstancedBuffer: Float32Array;
  24000. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24001. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24002. /**
  24003. * @constructor
  24004. * @param name The value used by scene.getMeshByName() to do a lookup.
  24005. * @param scene The scene to add this mesh to.
  24006. * @param parent The parent of this mesh, if it has one
  24007. * @param source An optional Mesh from which geometry is shared, cloned.
  24008. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24009. * When false, achieved by calling a clone(), also passing False.
  24010. * This will make creation of children, recursive.
  24011. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24012. */
  24013. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24014. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24015. doNotInstantiate: boolean;
  24016. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24017. /**
  24018. * Gets the class name
  24019. * @returns the string "Mesh".
  24020. */
  24021. getClassName(): string;
  24022. /** @hidden */
  24023. readonly _isMesh: boolean;
  24024. /**
  24025. * Returns a description of this mesh
  24026. * @param fullDetails define if full details about this mesh must be used
  24027. * @returns a descriptive string representing this mesh
  24028. */
  24029. toString(fullDetails?: boolean): string;
  24030. /** @hidden */
  24031. _unBindEffect(): void;
  24032. /**
  24033. * Gets a boolean indicating if this mesh has LOD
  24034. */
  24035. readonly hasLODLevels: boolean;
  24036. /**
  24037. * Gets the list of MeshLODLevel associated with the current mesh
  24038. * @returns an array of MeshLODLevel
  24039. */
  24040. getLODLevels(): MeshLODLevel[];
  24041. private _sortLODLevels;
  24042. /**
  24043. * Add a mesh as LOD level triggered at the given distance.
  24044. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24045. * @param distance The distance from the center of the object to show this level
  24046. * @param mesh The mesh to be added as LOD level (can be null)
  24047. * @return This mesh (for chaining)
  24048. */
  24049. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24050. /**
  24051. * Returns the LOD level mesh at the passed distance or null if not found.
  24052. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24053. * @param distance The distance from the center of the object to show this level
  24054. * @returns a Mesh or `null`
  24055. */
  24056. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24057. /**
  24058. * Remove a mesh from the LOD array
  24059. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24060. * @param mesh defines the mesh to be removed
  24061. * @return This mesh (for chaining)
  24062. */
  24063. removeLODLevel(mesh: Mesh): Mesh;
  24064. /**
  24065. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24066. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24067. * @param camera defines the camera to use to compute distance
  24068. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24069. * @return This mesh (for chaining)
  24070. */
  24071. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24072. /**
  24073. * Gets the mesh internal Geometry object
  24074. */
  24075. readonly geometry: Nullable<Geometry>;
  24076. /**
  24077. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24078. * @returns the total number of vertices
  24079. */
  24080. getTotalVertices(): number;
  24081. /**
  24082. * Returns the content of an associated vertex buffer
  24083. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24084. * - VertexBuffer.PositionKind
  24085. * - VertexBuffer.UVKind
  24086. * - VertexBuffer.UV2Kind
  24087. * - VertexBuffer.UV3Kind
  24088. * - VertexBuffer.UV4Kind
  24089. * - VertexBuffer.UV5Kind
  24090. * - VertexBuffer.UV6Kind
  24091. * - VertexBuffer.ColorKind
  24092. * - VertexBuffer.MatricesIndicesKind
  24093. * - VertexBuffer.MatricesIndicesExtraKind
  24094. * - VertexBuffer.MatricesWeightsKind
  24095. * - VertexBuffer.MatricesWeightsExtraKind
  24096. * @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
  24097. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24098. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24099. */
  24100. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24101. /**
  24102. * Returns the mesh VertexBuffer object from the requested `kind`
  24103. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24104. * - VertexBuffer.PositionKind
  24105. * - VertexBuffer.NormalKind
  24106. * - VertexBuffer.UVKind
  24107. * - VertexBuffer.UV2Kind
  24108. * - VertexBuffer.UV3Kind
  24109. * - VertexBuffer.UV4Kind
  24110. * - VertexBuffer.UV5Kind
  24111. * - VertexBuffer.UV6Kind
  24112. * - VertexBuffer.ColorKind
  24113. * - VertexBuffer.MatricesIndicesKind
  24114. * - VertexBuffer.MatricesIndicesExtraKind
  24115. * - VertexBuffer.MatricesWeightsKind
  24116. * - VertexBuffer.MatricesWeightsExtraKind
  24117. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24118. */
  24119. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24120. /**
  24121. * Tests if a specific vertex buffer is associated with this mesh
  24122. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24123. * - VertexBuffer.PositionKind
  24124. * - VertexBuffer.NormalKind
  24125. * - VertexBuffer.UVKind
  24126. * - VertexBuffer.UV2Kind
  24127. * - VertexBuffer.UV3Kind
  24128. * - VertexBuffer.UV4Kind
  24129. * - VertexBuffer.UV5Kind
  24130. * - VertexBuffer.UV6Kind
  24131. * - VertexBuffer.ColorKind
  24132. * - VertexBuffer.MatricesIndicesKind
  24133. * - VertexBuffer.MatricesIndicesExtraKind
  24134. * - VertexBuffer.MatricesWeightsKind
  24135. * - VertexBuffer.MatricesWeightsExtraKind
  24136. * @returns a boolean
  24137. */
  24138. isVerticesDataPresent(kind: string): boolean;
  24139. /**
  24140. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24141. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24142. * - VertexBuffer.PositionKind
  24143. * - VertexBuffer.UVKind
  24144. * - VertexBuffer.UV2Kind
  24145. * - VertexBuffer.UV3Kind
  24146. * - VertexBuffer.UV4Kind
  24147. * - VertexBuffer.UV5Kind
  24148. * - VertexBuffer.UV6Kind
  24149. * - VertexBuffer.ColorKind
  24150. * - VertexBuffer.MatricesIndicesKind
  24151. * - VertexBuffer.MatricesIndicesExtraKind
  24152. * - VertexBuffer.MatricesWeightsKind
  24153. * - VertexBuffer.MatricesWeightsExtraKind
  24154. * @returns a boolean
  24155. */
  24156. isVertexBufferUpdatable(kind: string): boolean;
  24157. /**
  24158. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24159. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24160. * - VertexBuffer.PositionKind
  24161. * - VertexBuffer.NormalKind
  24162. * - VertexBuffer.UVKind
  24163. * - VertexBuffer.UV2Kind
  24164. * - VertexBuffer.UV3Kind
  24165. * - VertexBuffer.UV4Kind
  24166. * - VertexBuffer.UV5Kind
  24167. * - VertexBuffer.UV6Kind
  24168. * - VertexBuffer.ColorKind
  24169. * - VertexBuffer.MatricesIndicesKind
  24170. * - VertexBuffer.MatricesIndicesExtraKind
  24171. * - VertexBuffer.MatricesWeightsKind
  24172. * - VertexBuffer.MatricesWeightsExtraKind
  24173. * @returns an array of strings
  24174. */
  24175. getVerticesDataKinds(): string[];
  24176. /**
  24177. * Returns a positive integer : the total number of indices in this mesh geometry.
  24178. * @returns the numner of indices or zero if the mesh has no geometry.
  24179. */
  24180. getTotalIndices(): number;
  24181. /**
  24182. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24183. * @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.
  24184. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24185. * @returns the indices array or an empty array if the mesh has no geometry
  24186. */
  24187. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24188. readonly isBlocked: boolean;
  24189. /**
  24190. * Determine if the current mesh is ready to be rendered
  24191. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24192. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24193. * @returns true if all associated assets are ready (material, textures, shaders)
  24194. */
  24195. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24196. /**
  24197. * 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.
  24198. */
  24199. readonly areNormalsFrozen: boolean;
  24200. /**
  24201. * 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.
  24202. * @returns the current mesh
  24203. */
  24204. freezeNormals(): Mesh;
  24205. /**
  24206. * 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
  24207. * @returns the current mesh
  24208. */
  24209. unfreezeNormals(): Mesh;
  24210. /**
  24211. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24212. */
  24213. overridenInstanceCount: number;
  24214. /** @hidden */
  24215. _preActivate(): Mesh;
  24216. /** @hidden */
  24217. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24218. /** @hidden */
  24219. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24220. /**
  24221. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24222. * This means the mesh underlying bounding box and sphere are recomputed.
  24223. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24224. * @returns the current mesh
  24225. */
  24226. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24227. /** @hidden */
  24228. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24229. /**
  24230. * This function will subdivide the mesh into multiple submeshes
  24231. * @param count defines the expected number of submeshes
  24232. */
  24233. subdivide(count: number): void;
  24234. /**
  24235. * Copy a FloatArray into a specific associated vertex buffer
  24236. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24237. * - VertexBuffer.PositionKind
  24238. * - VertexBuffer.UVKind
  24239. * - VertexBuffer.UV2Kind
  24240. * - VertexBuffer.UV3Kind
  24241. * - VertexBuffer.UV4Kind
  24242. * - VertexBuffer.UV5Kind
  24243. * - VertexBuffer.UV6Kind
  24244. * - VertexBuffer.ColorKind
  24245. * - VertexBuffer.MatricesIndicesKind
  24246. * - VertexBuffer.MatricesIndicesExtraKind
  24247. * - VertexBuffer.MatricesWeightsKind
  24248. * - VertexBuffer.MatricesWeightsExtraKind
  24249. * @param data defines the data source
  24250. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24251. * @param stride defines the data stride size (can be null)
  24252. * @returns the current mesh
  24253. */
  24254. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24255. /**
  24256. * Delete a vertex buffer associated with this mesh
  24257. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24258. * - VertexBuffer.PositionKind
  24259. * - VertexBuffer.UVKind
  24260. * - VertexBuffer.UV2Kind
  24261. * - VertexBuffer.UV3Kind
  24262. * - VertexBuffer.UV4Kind
  24263. * - VertexBuffer.UV5Kind
  24264. * - VertexBuffer.UV6Kind
  24265. * - VertexBuffer.ColorKind
  24266. * - VertexBuffer.MatricesIndicesKind
  24267. * - VertexBuffer.MatricesIndicesExtraKind
  24268. * - VertexBuffer.MatricesWeightsKind
  24269. * - VertexBuffer.MatricesWeightsExtraKind
  24270. */
  24271. removeVerticesData(kind: string): void;
  24272. /**
  24273. * Flags an associated vertex buffer as updatable
  24274. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24275. * - VertexBuffer.PositionKind
  24276. * - VertexBuffer.UVKind
  24277. * - VertexBuffer.UV2Kind
  24278. * - VertexBuffer.UV3Kind
  24279. * - VertexBuffer.UV4Kind
  24280. * - VertexBuffer.UV5Kind
  24281. * - VertexBuffer.UV6Kind
  24282. * - VertexBuffer.ColorKind
  24283. * - VertexBuffer.MatricesIndicesKind
  24284. * - VertexBuffer.MatricesIndicesExtraKind
  24285. * - VertexBuffer.MatricesWeightsKind
  24286. * - VertexBuffer.MatricesWeightsExtraKind
  24287. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24288. */
  24289. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24290. /**
  24291. * Sets the mesh global Vertex Buffer
  24292. * @param buffer defines the buffer to use
  24293. * @returns the current mesh
  24294. */
  24295. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24296. /**
  24297. * Update a specific associated vertex buffer
  24298. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24299. * - VertexBuffer.PositionKind
  24300. * - VertexBuffer.UVKind
  24301. * - VertexBuffer.UV2Kind
  24302. * - VertexBuffer.UV3Kind
  24303. * - VertexBuffer.UV4Kind
  24304. * - VertexBuffer.UV5Kind
  24305. * - VertexBuffer.UV6Kind
  24306. * - VertexBuffer.ColorKind
  24307. * - VertexBuffer.MatricesIndicesKind
  24308. * - VertexBuffer.MatricesIndicesExtraKind
  24309. * - VertexBuffer.MatricesWeightsKind
  24310. * - VertexBuffer.MatricesWeightsExtraKind
  24311. * @param data defines the data source
  24312. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24313. * @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)
  24314. * @returns the current mesh
  24315. */
  24316. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24317. /**
  24318. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24319. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24320. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24321. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24322. * @returns the current mesh
  24323. */
  24324. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24325. /**
  24326. * Creates a un-shared specific occurence of the geometry for the mesh.
  24327. * @returns the current mesh
  24328. */
  24329. makeGeometryUnique(): Mesh;
  24330. /**
  24331. * Set the index buffer of this mesh
  24332. * @param indices defines the source data
  24333. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24334. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24335. * @returns the current mesh
  24336. */
  24337. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24338. /**
  24339. * Update the current index buffer
  24340. * @param indices defines the source data
  24341. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24342. * @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)
  24343. * @returns the current mesh
  24344. */
  24345. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24346. /**
  24347. * Invert the geometry to move from a right handed system to a left handed one.
  24348. * @returns the current mesh
  24349. */
  24350. toLeftHanded(): Mesh;
  24351. /** @hidden */
  24352. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24353. /** @hidden */
  24354. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24355. /**
  24356. * Registers for this mesh a javascript function called just before the rendering process
  24357. * @param func defines the function to call before rendering this mesh
  24358. * @returns the current mesh
  24359. */
  24360. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24361. /**
  24362. * Disposes a previously registered javascript function called before the rendering
  24363. * @param func defines the function to remove
  24364. * @returns the current mesh
  24365. */
  24366. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24367. /**
  24368. * Registers for this mesh a javascript function called just after the rendering is complete
  24369. * @param func defines the function to call after rendering this mesh
  24370. * @returns the current mesh
  24371. */
  24372. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24373. /**
  24374. * Disposes a previously registered javascript function called after the rendering.
  24375. * @param func defines the function to remove
  24376. * @returns the current mesh
  24377. */
  24378. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24379. /** @hidden */
  24380. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24381. /** @hidden */
  24382. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24383. /** @hidden */
  24384. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24385. /** @hidden */
  24386. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24387. /** @hidden */
  24388. _rebuild(): void;
  24389. /** @hidden */
  24390. _freeze(): void;
  24391. /** @hidden */
  24392. _unFreeze(): void;
  24393. /**
  24394. * 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
  24395. * @param subMesh defines the subMesh to render
  24396. * @param enableAlphaMode defines if alpha mode can be changed
  24397. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24398. * @returns the current mesh
  24399. */
  24400. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24401. private _onBeforeDraw;
  24402. /**
  24403. * Renormalize the mesh and patch it up if there are no weights
  24404. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24405. * However in the case of zero weights then we set just a single influence to 1.
  24406. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24407. */
  24408. cleanMatrixWeights(): void;
  24409. private normalizeSkinFourWeights;
  24410. private normalizeSkinWeightsAndExtra;
  24411. /**
  24412. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24413. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24414. * the user know there was an issue with importing the mesh
  24415. * @returns a validation object with skinned, valid and report string
  24416. */
  24417. validateSkinning(): {
  24418. skinned: boolean;
  24419. valid: boolean;
  24420. report: string;
  24421. };
  24422. /** @hidden */
  24423. _checkDelayState(): Mesh;
  24424. private _queueLoad;
  24425. /**
  24426. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24427. * A mesh is in the frustum if its bounding box intersects the frustum
  24428. * @param frustumPlanes defines the frustum to test
  24429. * @returns true if the mesh is in the frustum planes
  24430. */
  24431. isInFrustum(frustumPlanes: Plane[]): boolean;
  24432. /**
  24433. * Sets the mesh material by the material or multiMaterial `id` property
  24434. * @param id is a string identifying the material or the multiMaterial
  24435. * @returns the current mesh
  24436. */
  24437. setMaterialByID(id: string): Mesh;
  24438. /**
  24439. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24440. * @returns an array of IAnimatable
  24441. */
  24442. getAnimatables(): IAnimatable[];
  24443. /**
  24444. * Modifies the mesh geometry according to the passed transformation matrix.
  24445. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24446. * The mesh normals are modified using the same transformation.
  24447. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24448. * @param transform defines the transform matrix to use
  24449. * @see http://doc.babylonjs.com/resources/baking_transformations
  24450. * @returns the current mesh
  24451. */
  24452. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24453. /**
  24454. * Modifies the mesh geometry according to its own current World Matrix.
  24455. * The mesh World Matrix is then reset.
  24456. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24457. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24458. * @see http://doc.babylonjs.com/resources/baking_transformations
  24459. * @returns the current mesh
  24460. */
  24461. bakeCurrentTransformIntoVertices(): Mesh;
  24462. /** @hidden */
  24463. readonly _positions: Nullable<Vector3[]>;
  24464. /** @hidden */
  24465. _resetPointsArrayCache(): Mesh;
  24466. /** @hidden */
  24467. _generatePointsArray(): boolean;
  24468. /**
  24469. * Returns a new Mesh object generated from the current mesh properties.
  24470. * This method must not get confused with createInstance()
  24471. * @param name is a string, the name given to the new mesh
  24472. * @param newParent can be any Node object (default `null`)
  24473. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24474. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24475. * @returns a new mesh
  24476. */
  24477. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24478. /**
  24479. * Releases resources associated with this mesh.
  24480. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24481. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24482. */
  24483. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24484. /** @hidden */
  24485. _disposeInstanceSpecificData(): void;
  24486. /**
  24487. * Modifies the mesh geometry according to a displacement map.
  24488. * 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.
  24489. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24490. * @param url is a string, the URL from the image file is to be downloaded.
  24491. * @param minHeight is the lower limit of the displacement.
  24492. * @param maxHeight is the upper limit of the displacement.
  24493. * @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.
  24494. * @param uvOffset is an optional vector2 used to offset UV.
  24495. * @param uvScale is an optional vector2 used to scale UV.
  24496. * @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.
  24497. * @returns the Mesh.
  24498. */
  24499. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24500. /**
  24501. * Modifies the mesh geometry according to a displacementMap buffer.
  24502. * 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.
  24503. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24504. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24505. * @param heightMapWidth is the width of the buffer image.
  24506. * @param heightMapHeight is the height of the buffer image.
  24507. * @param minHeight is the lower limit of the displacement.
  24508. * @param maxHeight is the upper limit of the displacement.
  24509. * @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.
  24510. * @param uvOffset is an optional vector2 used to offset UV.
  24511. * @param uvScale is an optional vector2 used to scale UV.
  24512. * @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.
  24513. * @returns the Mesh.
  24514. */
  24515. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24516. /**
  24517. * Modify the mesh to get a flat shading rendering.
  24518. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24519. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24520. * @returns current mesh
  24521. */
  24522. convertToFlatShadedMesh(): Mesh;
  24523. /**
  24524. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24525. * In other words, more vertices, no more indices and a single bigger VBO.
  24526. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24527. * @returns current mesh
  24528. */
  24529. convertToUnIndexedMesh(): Mesh;
  24530. /**
  24531. * Inverses facet orientations.
  24532. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24533. * @param flipNormals will also inverts the normals
  24534. * @returns current mesh
  24535. */
  24536. flipFaces(flipNormals?: boolean): Mesh;
  24537. /**
  24538. * Increase the number of facets and hence vertices in a mesh
  24539. * Vertex normals are interpolated from existing vertex normals
  24540. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24541. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24542. */
  24543. increaseVertices(numberPerEdge: number): void;
  24544. /**
  24545. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24546. * This will undo any application of covertToFlatShadedMesh
  24547. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24548. */
  24549. forceSharedVertices(): void;
  24550. /** @hidden */
  24551. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24552. /** @hidden */
  24553. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24554. /**
  24555. * Creates a new InstancedMesh object from the mesh model.
  24556. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24557. * @param name defines the name of the new instance
  24558. * @returns a new InstancedMesh
  24559. */
  24560. createInstance(name: string): InstancedMesh;
  24561. /**
  24562. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24563. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24564. * @returns the current mesh
  24565. */
  24566. synchronizeInstances(): Mesh;
  24567. /**
  24568. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24569. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24570. * This should be used together with the simplification to avoid disappearing triangles.
  24571. * @param successCallback an optional success callback to be called after the optimization finished.
  24572. * @returns the current mesh
  24573. */
  24574. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24575. /**
  24576. * Serialize current mesh
  24577. * @param serializationObject defines the object which will receive the serialization data
  24578. */
  24579. serialize(serializationObject: any): void;
  24580. /** @hidden */
  24581. _syncGeometryWithMorphTargetManager(): void;
  24582. /** @hidden */
  24583. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24584. /**
  24585. * Returns a new Mesh object parsed from the source provided.
  24586. * @param parsedMesh is the source
  24587. * @param scene defines the hosting scene
  24588. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24589. * @returns a new Mesh
  24590. */
  24591. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24592. /**
  24593. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24594. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24595. * @param name defines the name of the mesh to create
  24596. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24597. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24598. * @param closePath creates a seam between the first and the last points of each path of the path array
  24599. * @param offset is taken in account only if the `pathArray` is containing a single path
  24600. * @param scene defines the hosting scene
  24601. * @param updatable defines if the mesh must be flagged as updatable
  24602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24603. * @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)
  24604. * @returns a new Mesh
  24605. */
  24606. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24607. /**
  24608. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24609. * @param name defines the name of the mesh to create
  24610. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24611. * @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
  24612. * @param scene defines the hosting scene
  24613. * @param updatable defines if the mesh must be flagged as updatable
  24614. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24615. * @returns a new Mesh
  24616. */
  24617. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24618. /**
  24619. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24620. * @param name defines the name of the mesh to create
  24621. * @param size sets the size (float) of each box side (default 1)
  24622. * @param scene defines the hosting scene
  24623. * @param updatable defines if the mesh must be flagged as updatable
  24624. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24625. * @returns a new Mesh
  24626. */
  24627. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24628. /**
  24629. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24630. * @param name defines the name of the mesh to create
  24631. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24632. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24633. * @param scene defines the hosting scene
  24634. * @param updatable defines if the mesh must be flagged as updatable
  24635. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24636. * @returns a new Mesh
  24637. */
  24638. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24639. /**
  24640. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24641. * @param name defines the name of the mesh to create
  24642. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24643. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24644. * @param scene defines the hosting scene
  24645. * @returns a new Mesh
  24646. */
  24647. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24648. /**
  24649. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24650. * @param name defines the name of the mesh to create
  24651. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24652. * @param diameterTop set the top cap diameter (floats, default 1)
  24653. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24654. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24655. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24656. * @param scene defines the hosting scene
  24657. * @param updatable defines if the mesh must be flagged as updatable
  24658. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24659. * @returns a new Mesh
  24660. */
  24661. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24662. /**
  24663. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24664. * @param name defines the name of the mesh to create
  24665. * @param diameter sets the diameter size (float) of the torus (default 1)
  24666. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24667. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24668. * @param scene defines the hosting scene
  24669. * @param updatable defines if the mesh must be flagged as updatable
  24670. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24671. * @returns a new Mesh
  24672. */
  24673. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24674. /**
  24675. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24676. * @param name defines the name of the mesh to create
  24677. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24678. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24679. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24680. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24681. * @param p the number of windings on X axis (positive integers, default 2)
  24682. * @param q the number of windings on Y axis (positive integers, default 3)
  24683. * @param scene defines the hosting scene
  24684. * @param updatable defines if the mesh must be flagged as updatable
  24685. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24686. * @returns a new Mesh
  24687. */
  24688. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24689. /**
  24690. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24691. * @param name defines the name of the mesh to create
  24692. * @param points is an array successive Vector3
  24693. * @param scene defines the hosting scene
  24694. * @param updatable defines if the mesh must be flagged as updatable
  24695. * @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).
  24696. * @returns a new Mesh
  24697. */
  24698. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24699. /**
  24700. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24701. * @param name defines the name of the mesh to create
  24702. * @param points is an array successive Vector3
  24703. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24704. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24705. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24706. * @param scene defines the hosting scene
  24707. * @param updatable defines if the mesh must be flagged as updatable
  24708. * @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)
  24709. * @returns a new Mesh
  24710. */
  24711. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24712. /**
  24713. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24714. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24715. * 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.
  24716. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24717. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24718. * Remember you can only change the shape positions, not their number when updating a polygon.
  24719. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24720. * @param name defines the name of the mesh to create
  24721. * @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
  24722. * @param scene defines the hosting scene
  24723. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24724. * @param updatable defines if the mesh must be flagged as updatable
  24725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24726. * @param earcutInjection can be used to inject your own earcut reference
  24727. * @returns a new Mesh
  24728. */
  24729. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24730. /**
  24731. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24732. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24733. * @param name defines the name of the mesh to create
  24734. * @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
  24735. * @param depth defines the height of extrusion
  24736. * @param scene defines the hosting scene
  24737. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24738. * @param updatable defines if the mesh must be flagged as updatable
  24739. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24740. * @param earcutInjection can be used to inject your own earcut reference
  24741. * @returns a new Mesh
  24742. */
  24743. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24744. /**
  24745. * Creates an extruded shape mesh.
  24746. * 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
  24747. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24748. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24749. * @param name defines the name of the mesh to create
  24750. * @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
  24751. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24752. * @param scale is the value to scale the shape
  24753. * @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
  24754. * @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
  24755. * @param scene defines the hosting scene
  24756. * @param updatable defines if the mesh must be flagged as updatable
  24757. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24758. * @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)
  24759. * @returns a new Mesh
  24760. */
  24761. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24762. /**
  24763. * Creates an custom extruded shape mesh.
  24764. * The custom extrusion is a parametric shape.
  24765. * It has no predefined shape. Its final shape will depend on the input parameters.
  24766. * Please consider using the same method from the MeshBuilder class instead
  24767. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24768. * @param name defines the name of the mesh to create
  24769. * @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
  24770. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24771. * @param scaleFunction is a custom Javascript function called on each path point
  24772. * @param rotationFunction is a custom Javascript function called on each path point
  24773. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24774. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24775. * @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
  24776. * @param scene defines the hosting scene
  24777. * @param updatable defines if the mesh must be flagged as updatable
  24778. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24779. * @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)
  24780. * @returns a new Mesh
  24781. */
  24782. 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;
  24783. /**
  24784. * Creates lathe mesh.
  24785. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24786. * Please consider using the same method from the MeshBuilder class instead
  24787. * @param name defines the name of the mesh to create
  24788. * @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
  24789. * @param radius is the radius value of the lathe
  24790. * @param tessellation is the side number of the lathe.
  24791. * @param scene defines the hosting scene
  24792. * @param updatable defines if the mesh must be flagged as updatable
  24793. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24794. * @returns a new Mesh
  24795. */
  24796. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24797. /**
  24798. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24799. * @param name defines the name of the mesh to create
  24800. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24801. * @param scene defines the hosting scene
  24802. * @param updatable defines if the mesh must be flagged as updatable
  24803. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24804. * @returns a new Mesh
  24805. */
  24806. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24807. /**
  24808. * Creates a ground mesh.
  24809. * Please consider using the same method from the MeshBuilder class instead
  24810. * @param name defines the name of the mesh to create
  24811. * @param width set the width of the ground
  24812. * @param height set the height of the ground
  24813. * @param subdivisions sets the number of subdivisions per side
  24814. * @param scene defines the hosting scene
  24815. * @param updatable defines if the mesh must be flagged as updatable
  24816. * @returns a new Mesh
  24817. */
  24818. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24819. /**
  24820. * Creates a tiled ground mesh.
  24821. * Please consider using the same method from the MeshBuilder class instead
  24822. * @param name defines the name of the mesh to create
  24823. * @param xmin set the ground minimum X coordinate
  24824. * @param zmin set the ground minimum Y coordinate
  24825. * @param xmax set the ground maximum X coordinate
  24826. * @param zmax set the ground maximum Z coordinate
  24827. * @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
  24828. * @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
  24829. * @param scene defines the hosting scene
  24830. * @param updatable defines if the mesh must be flagged as updatable
  24831. * @returns a new Mesh
  24832. */
  24833. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24834. w: number;
  24835. h: number;
  24836. }, precision: {
  24837. w: number;
  24838. h: number;
  24839. }, scene: Scene, updatable?: boolean): Mesh;
  24840. /**
  24841. * Creates a ground mesh from a height map.
  24842. * Please consider using the same method from the MeshBuilder class instead
  24843. * @see http://doc.babylonjs.com/babylon101/height_map
  24844. * @param name defines the name of the mesh to create
  24845. * @param url sets the URL of the height map image resource
  24846. * @param width set the ground width size
  24847. * @param height set the ground height size
  24848. * @param subdivisions sets the number of subdivision per side
  24849. * @param minHeight is the minimum altitude on the ground
  24850. * @param maxHeight is the maximum altitude on the ground
  24851. * @param scene defines the hosting scene
  24852. * @param updatable defines if the mesh must be flagged as updatable
  24853. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24854. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24855. * @returns a new Mesh
  24856. */
  24857. 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;
  24858. /**
  24859. * Creates a tube mesh.
  24860. * The tube is a parametric shape.
  24861. * It has no predefined shape. Its final shape will depend on the input parameters.
  24862. * Please consider using the same method from the MeshBuilder class instead
  24863. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24864. * @param name defines the name of the mesh to create
  24865. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24866. * @param radius sets the tube radius size
  24867. * @param tessellation is the number of sides on the tubular surface
  24868. * @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
  24869. * @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
  24870. * @param scene defines the hosting scene
  24871. * @param updatable defines if the mesh must be flagged as updatable
  24872. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24873. * @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)
  24874. * @returns a new Mesh
  24875. */
  24876. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24877. (i: number, distance: number): number;
  24878. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24879. /**
  24880. * Creates a polyhedron mesh.
  24881. * Please consider using the same method from the MeshBuilder class instead.
  24882. * * 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
  24883. * * The parameter `size` (positive float, default 1) sets the polygon size
  24884. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24885. * * 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`
  24886. * * 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
  24887. * * 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)`)
  24888. * * 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
  24889. * * 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
  24890. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24891. * * 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
  24892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24893. * @param name defines the name of the mesh to create
  24894. * @param options defines the options used to create the mesh
  24895. * @param scene defines the hosting scene
  24896. * @returns a new Mesh
  24897. */
  24898. static CreatePolyhedron(name: string, options: {
  24899. type?: number;
  24900. size?: number;
  24901. sizeX?: number;
  24902. sizeY?: number;
  24903. sizeZ?: number;
  24904. custom?: any;
  24905. faceUV?: Vector4[];
  24906. faceColors?: Color4[];
  24907. updatable?: boolean;
  24908. sideOrientation?: number;
  24909. }, scene: Scene): Mesh;
  24910. /**
  24911. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24912. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24913. * * 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`)
  24914. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24915. * * 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
  24916. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24917. * * 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
  24918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24919. * @param name defines the name of the mesh
  24920. * @param options defines the options used to create the mesh
  24921. * @param scene defines the hosting scene
  24922. * @returns a new Mesh
  24923. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24924. */
  24925. static CreateIcoSphere(name: string, options: {
  24926. radius?: number;
  24927. flat?: boolean;
  24928. subdivisions?: number;
  24929. sideOrientation?: number;
  24930. updatable?: boolean;
  24931. }, scene: Scene): Mesh;
  24932. /**
  24933. * Creates a decal mesh.
  24934. * Please consider using the same method from the MeshBuilder class instead.
  24935. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24936. * @param name defines the name of the mesh
  24937. * @param sourceMesh defines the mesh receiving the decal
  24938. * @param position sets the position of the decal in world coordinates
  24939. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24940. * @param size sets the decal scaling
  24941. * @param angle sets the angle to rotate the decal
  24942. * @returns a new Mesh
  24943. */
  24944. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24945. /**
  24946. * Prepare internal position array for software CPU skinning
  24947. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24948. */
  24949. setPositionsForCPUSkinning(): Float32Array;
  24950. /**
  24951. * Prepare internal normal array for software CPU skinning
  24952. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24953. */
  24954. setNormalsForCPUSkinning(): Float32Array;
  24955. /**
  24956. * Updates the vertex buffer by applying transformation from the bones
  24957. * @param skeleton defines the skeleton to apply to current mesh
  24958. * @returns the current mesh
  24959. */
  24960. applySkeleton(skeleton: Skeleton): Mesh;
  24961. /**
  24962. * 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
  24963. * @param meshes defines the list of meshes to scan
  24964. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24965. */
  24966. static MinMax(meshes: AbstractMesh[]): {
  24967. min: Vector3;
  24968. max: Vector3;
  24969. };
  24970. /**
  24971. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24972. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24973. * @returns a vector3
  24974. */
  24975. static Center(meshesOrMinMaxVector: {
  24976. min: Vector3;
  24977. max: Vector3;
  24978. } | AbstractMesh[]): Vector3;
  24979. /**
  24980. * Merge the array of meshes into a single mesh for performance reasons.
  24981. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24982. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24983. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24984. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24985. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24986. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24987. * @returns a new mesh
  24988. */
  24989. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24990. /** @hidden */
  24991. addInstance(instance: InstancedMesh): void;
  24992. /** @hidden */
  24993. removeInstance(instance: InstancedMesh): void;
  24994. }
  24995. }
  24996. declare module BABYLON {
  24997. /**
  24998. * This is the base class of all the camera used in the application.
  24999. * @see http://doc.babylonjs.com/features/cameras
  25000. */
  25001. export class Camera extends Node {
  25002. /** @hidden */
  25003. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25004. /**
  25005. * This is the default projection mode used by the cameras.
  25006. * It helps recreating a feeling of perspective and better appreciate depth.
  25007. * This is the best way to simulate real life cameras.
  25008. */
  25009. static readonly PERSPECTIVE_CAMERA: number;
  25010. /**
  25011. * This helps creating camera with an orthographic mode.
  25012. * 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.
  25013. */
  25014. static readonly ORTHOGRAPHIC_CAMERA: number;
  25015. /**
  25016. * This is the default FOV mode for perspective cameras.
  25017. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25018. */
  25019. static readonly FOVMODE_VERTICAL_FIXED: number;
  25020. /**
  25021. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25022. */
  25023. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25024. /**
  25025. * This specifies ther is no need for a camera rig.
  25026. * Basically only one eye is rendered corresponding to the camera.
  25027. */
  25028. static readonly RIG_MODE_NONE: number;
  25029. /**
  25030. * Simulates a camera Rig with one blue eye and one red eye.
  25031. * This can be use with 3d blue and red glasses.
  25032. */
  25033. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25034. /**
  25035. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25036. */
  25037. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25038. /**
  25039. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25040. */
  25041. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25042. /**
  25043. * Defines that both eyes of the camera will be rendered over under each other.
  25044. */
  25045. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25046. /**
  25047. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25048. */
  25049. static readonly RIG_MODE_VR: number;
  25050. /**
  25051. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25052. */
  25053. static readonly RIG_MODE_WEBVR: number;
  25054. /**
  25055. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25056. */
  25057. static readonly RIG_MODE_CUSTOM: number;
  25058. /**
  25059. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25060. */
  25061. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25062. /**
  25063. * Define the input manager associated with the camera.
  25064. */
  25065. inputs: CameraInputsManager<Camera>;
  25066. /** @hidden */
  25067. _position: Vector3;
  25068. /**
  25069. * Define the current local position of the camera in the scene
  25070. */
  25071. position: Vector3;
  25072. /**
  25073. * The vector the camera should consider as up.
  25074. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25075. */
  25076. upVector: Vector3;
  25077. /**
  25078. * Define the current limit on the left side for an orthographic camera
  25079. * In scene unit
  25080. */
  25081. orthoLeft: Nullable<number>;
  25082. /**
  25083. * Define the current limit on the right side for an orthographic camera
  25084. * In scene unit
  25085. */
  25086. orthoRight: Nullable<number>;
  25087. /**
  25088. * Define the current limit on the bottom side for an orthographic camera
  25089. * In scene unit
  25090. */
  25091. orthoBottom: Nullable<number>;
  25092. /**
  25093. * Define the current limit on the top side for an orthographic camera
  25094. * In scene unit
  25095. */
  25096. orthoTop: Nullable<number>;
  25097. /**
  25098. * Field Of View is set in Radians. (default is 0.8)
  25099. */
  25100. fov: number;
  25101. /**
  25102. * Define the minimum distance the camera can see from.
  25103. * This is important to note that the depth buffer are not infinite and the closer it starts
  25104. * the more your scene might encounter depth fighting issue.
  25105. */
  25106. minZ: number;
  25107. /**
  25108. * Define the maximum distance the camera can see to.
  25109. * This is important to note that the depth buffer are not infinite and the further it end
  25110. * the more your scene might encounter depth fighting issue.
  25111. */
  25112. maxZ: number;
  25113. /**
  25114. * Define the default inertia of the camera.
  25115. * This helps giving a smooth feeling to the camera movement.
  25116. */
  25117. inertia: number;
  25118. /**
  25119. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25120. */
  25121. mode: number;
  25122. /**
  25123. * Define wether the camera is intermediate.
  25124. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25125. */
  25126. isIntermediate: boolean;
  25127. /**
  25128. * Define the viewport of the camera.
  25129. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25130. */
  25131. viewport: Viewport;
  25132. /**
  25133. * Restricts the camera to viewing objects with the same layerMask.
  25134. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25135. */
  25136. layerMask: number;
  25137. /**
  25138. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25139. */
  25140. fovMode: number;
  25141. /**
  25142. * Rig mode of the camera.
  25143. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25144. * This is normally controlled byt the camera themselves as internal use.
  25145. */
  25146. cameraRigMode: number;
  25147. /**
  25148. * Defines the distance between both "eyes" in case of a RIG
  25149. */
  25150. interaxialDistance: number;
  25151. /**
  25152. * Defines if stereoscopic rendering is done side by side or over under.
  25153. */
  25154. isStereoscopicSideBySide: boolean;
  25155. /**
  25156. * 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
  25157. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25158. * else in the scene. (Eg. security camera)
  25159. *
  25160. * 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)
  25161. */
  25162. customRenderTargets: RenderTargetTexture[];
  25163. /**
  25164. * When set, the camera will render to this render target instead of the default canvas
  25165. *
  25166. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25167. */
  25168. outputRenderTarget: Nullable<RenderTargetTexture>;
  25169. /**
  25170. * Observable triggered when the camera view matrix has changed.
  25171. */
  25172. onViewMatrixChangedObservable: Observable<Camera>;
  25173. /**
  25174. * Observable triggered when the camera Projection matrix has changed.
  25175. */
  25176. onProjectionMatrixChangedObservable: Observable<Camera>;
  25177. /**
  25178. * Observable triggered when the inputs have been processed.
  25179. */
  25180. onAfterCheckInputsObservable: Observable<Camera>;
  25181. /**
  25182. * Observable triggered when reset has been called and applied to the camera.
  25183. */
  25184. onRestoreStateObservable: Observable<Camera>;
  25185. /** @hidden */
  25186. _cameraRigParams: any;
  25187. /** @hidden */
  25188. _rigCameras: Camera[];
  25189. /** @hidden */
  25190. _rigPostProcess: Nullable<PostProcess>;
  25191. protected _webvrViewMatrix: Matrix;
  25192. /** @hidden */
  25193. _skipRendering: boolean;
  25194. /** @hidden */
  25195. _projectionMatrix: Matrix;
  25196. /** @hidden */
  25197. _postProcesses: Nullable<PostProcess>[];
  25198. /** @hidden */
  25199. _activeMeshes: SmartArray<AbstractMesh>;
  25200. protected _globalPosition: Vector3;
  25201. /** @hidden */
  25202. _computedViewMatrix: Matrix;
  25203. private _doNotComputeProjectionMatrix;
  25204. private _transformMatrix;
  25205. private _frustumPlanes;
  25206. private _refreshFrustumPlanes;
  25207. private _storedFov;
  25208. private _stateStored;
  25209. /**
  25210. * Instantiates a new camera object.
  25211. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25212. * @see http://doc.babylonjs.com/features/cameras
  25213. * @param name Defines the name of the camera in the scene
  25214. * @param position Defines the position of the camera
  25215. * @param scene Defines the scene the camera belongs too
  25216. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25217. */
  25218. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25219. /**
  25220. * Store current camera state (fov, position, etc..)
  25221. * @returns the camera
  25222. */
  25223. storeState(): Camera;
  25224. /**
  25225. * Restores the camera state values if it has been stored. You must call storeState() first
  25226. */
  25227. protected _restoreStateValues(): boolean;
  25228. /**
  25229. * Restored camera state. You must call storeState() first.
  25230. * @returns true if restored and false otherwise
  25231. */
  25232. restoreState(): boolean;
  25233. /**
  25234. * Gets the class name of the camera.
  25235. * @returns the class name
  25236. */
  25237. getClassName(): string;
  25238. /** @hidden */
  25239. readonly _isCamera: boolean;
  25240. /**
  25241. * Gets a string representation of the camera useful for debug purpose.
  25242. * @param fullDetails Defines that a more verboe level of logging is required
  25243. * @returns the string representation
  25244. */
  25245. toString(fullDetails?: boolean): string;
  25246. /**
  25247. * Gets the current world space position of the camera.
  25248. */
  25249. readonly globalPosition: Vector3;
  25250. /**
  25251. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25252. * @returns the active meshe list
  25253. */
  25254. getActiveMeshes(): SmartArray<AbstractMesh>;
  25255. /**
  25256. * Check wether a mesh is part of the current active mesh list of the camera
  25257. * @param mesh Defines the mesh to check
  25258. * @returns true if active, false otherwise
  25259. */
  25260. isActiveMesh(mesh: Mesh): boolean;
  25261. /**
  25262. * Is this camera ready to be used/rendered
  25263. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25264. * @return true if the camera is ready
  25265. */
  25266. isReady(completeCheck?: boolean): boolean;
  25267. /** @hidden */
  25268. _initCache(): void;
  25269. /** @hidden */
  25270. _updateCache(ignoreParentClass?: boolean): void;
  25271. /** @hidden */
  25272. _isSynchronized(): boolean;
  25273. /** @hidden */
  25274. _isSynchronizedViewMatrix(): boolean;
  25275. /** @hidden */
  25276. _isSynchronizedProjectionMatrix(): boolean;
  25277. /**
  25278. * Attach the input controls to a specific dom element to get the input from.
  25279. * @param element Defines the element the controls should be listened from
  25280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25281. */
  25282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25283. /**
  25284. * Detach the current controls from the specified dom element.
  25285. * @param element Defines the element to stop listening the inputs from
  25286. */
  25287. detachControl(element: HTMLElement): void;
  25288. /**
  25289. * Update the camera state according to the different inputs gathered during the frame.
  25290. */
  25291. update(): void;
  25292. /** @hidden */
  25293. _checkInputs(): void;
  25294. /** @hidden */
  25295. readonly rigCameras: Camera[];
  25296. /**
  25297. * Gets the post process used by the rig cameras
  25298. */
  25299. readonly rigPostProcess: Nullable<PostProcess>;
  25300. /**
  25301. * Internal, gets the first post proces.
  25302. * @returns the first post process to be run on this camera.
  25303. */
  25304. _getFirstPostProcess(): Nullable<PostProcess>;
  25305. private _cascadePostProcessesToRigCams;
  25306. /**
  25307. * Attach a post process to the camera.
  25308. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25309. * @param postProcess The post process to attach to the camera
  25310. * @param insertAt The position of the post process in case several of them are in use in the scene
  25311. * @returns the position the post process has been inserted at
  25312. */
  25313. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25314. /**
  25315. * Detach a post process to the camera.
  25316. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25317. * @param postProcess The post process to detach from the camera
  25318. */
  25319. detachPostProcess(postProcess: PostProcess): void;
  25320. /**
  25321. * Gets the current world matrix of the camera
  25322. */
  25323. getWorldMatrix(): Matrix;
  25324. /** @hidden */
  25325. _getViewMatrix(): Matrix;
  25326. /**
  25327. * Gets the current view matrix of the camera.
  25328. * @param force forces the camera to recompute the matrix without looking at the cached state
  25329. * @returns the view matrix
  25330. */
  25331. getViewMatrix(force?: boolean): Matrix;
  25332. /**
  25333. * Freeze the projection matrix.
  25334. * It will prevent the cache check of the camera projection compute and can speed up perf
  25335. * if no parameter of the camera are meant to change
  25336. * @param projection Defines manually a projection if necessary
  25337. */
  25338. freezeProjectionMatrix(projection?: Matrix): void;
  25339. /**
  25340. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25341. */
  25342. unfreezeProjectionMatrix(): void;
  25343. /**
  25344. * Gets the current projection matrix of the camera.
  25345. * @param force forces the camera to recompute the matrix without looking at the cached state
  25346. * @returns the projection matrix
  25347. */
  25348. getProjectionMatrix(force?: boolean): Matrix;
  25349. /**
  25350. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25351. * @returns a Matrix
  25352. */
  25353. getTransformationMatrix(): Matrix;
  25354. private _updateFrustumPlanes;
  25355. /**
  25356. * Checks if a cullable object (mesh...) is in the camera frustum
  25357. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25358. * @param target The object to check
  25359. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25360. * @returns true if the object is in frustum otherwise false
  25361. */
  25362. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25363. /**
  25364. * Checks if a cullable object (mesh...) is in the camera frustum
  25365. * Unlike isInFrustum this cheks the full bounding box
  25366. * @param target The object to check
  25367. * @returns true if the object is in frustum otherwise false
  25368. */
  25369. isCompletelyInFrustum(target: ICullable): boolean;
  25370. /**
  25371. * Gets a ray in the forward direction from the camera.
  25372. * @param length Defines the length of the ray to create
  25373. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25374. * @param origin Defines the start point of the ray which defaults to the camera position
  25375. * @returns the forward ray
  25376. */
  25377. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25378. /**
  25379. * Releases resources associated with this node.
  25380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25382. */
  25383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25384. /** @hidden */
  25385. _isLeftCamera: boolean;
  25386. /**
  25387. * Gets the left camera of a rig setup in case of Rigged Camera
  25388. */
  25389. readonly isLeftCamera: boolean;
  25390. /** @hidden */
  25391. _isRightCamera: boolean;
  25392. /**
  25393. * Gets the right camera of a rig setup in case of Rigged Camera
  25394. */
  25395. readonly isRightCamera: boolean;
  25396. /**
  25397. * Gets the left camera of a rig setup in case of Rigged Camera
  25398. */
  25399. readonly leftCamera: Nullable<FreeCamera>;
  25400. /**
  25401. * Gets the right camera of a rig setup in case of Rigged Camera
  25402. */
  25403. readonly rightCamera: Nullable<FreeCamera>;
  25404. /**
  25405. * Gets the left camera target of a rig setup in case of Rigged Camera
  25406. * @returns the target position
  25407. */
  25408. getLeftTarget(): Nullable<Vector3>;
  25409. /**
  25410. * Gets the right camera target of a rig setup in case of Rigged Camera
  25411. * @returns the target position
  25412. */
  25413. getRightTarget(): Nullable<Vector3>;
  25414. /**
  25415. * @hidden
  25416. */
  25417. setCameraRigMode(mode: number, rigParams: any): void;
  25418. /** @hidden */
  25419. static _setStereoscopicRigMode(camera: Camera): void;
  25420. /** @hidden */
  25421. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25422. /** @hidden */
  25423. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25424. /** @hidden */
  25425. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25426. /** @hidden */
  25427. _getVRProjectionMatrix(): Matrix;
  25428. protected _updateCameraRotationMatrix(): void;
  25429. protected _updateWebVRCameraRotationMatrix(): void;
  25430. /**
  25431. * This function MUST be overwritten by the different WebVR cameras available.
  25432. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25433. * @hidden
  25434. */
  25435. _getWebVRProjectionMatrix(): Matrix;
  25436. /**
  25437. * This function MUST be overwritten by the different WebVR cameras available.
  25438. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25439. * @hidden
  25440. */
  25441. _getWebVRViewMatrix(): Matrix;
  25442. /** @hidden */
  25443. setCameraRigParameter(name: string, value: any): void;
  25444. /**
  25445. * needs to be overridden by children so sub has required properties to be copied
  25446. * @hidden
  25447. */
  25448. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25449. /**
  25450. * May need to be overridden by children
  25451. * @hidden
  25452. */
  25453. _updateRigCameras(): void;
  25454. /** @hidden */
  25455. _setupInputs(): void;
  25456. /**
  25457. * Serialiaze the camera setup to a json represention
  25458. * @returns the JSON representation
  25459. */
  25460. serialize(): any;
  25461. /**
  25462. * Clones the current camera.
  25463. * @param name The cloned camera name
  25464. * @returns the cloned camera
  25465. */
  25466. clone(name: string): Camera;
  25467. /**
  25468. * Gets the direction of the camera relative to a given local axis.
  25469. * @param localAxis Defines the reference axis to provide a relative direction.
  25470. * @return the direction
  25471. */
  25472. getDirection(localAxis: Vector3): Vector3;
  25473. /**
  25474. * Returns the current camera absolute rotation
  25475. */
  25476. readonly absoluteRotation: Quaternion;
  25477. /**
  25478. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25479. * @param localAxis Defines the reference axis to provide a relative direction.
  25480. * @param result Defines the vector to store the result in
  25481. */
  25482. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25483. /**
  25484. * Gets a camera constructor for a given camera type
  25485. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25486. * @param name The name of the camera the result will be able to instantiate
  25487. * @param scene The scene the result will construct the camera in
  25488. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25489. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25490. * @returns a factory method to construc the camera
  25491. */
  25492. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25493. /**
  25494. * Compute the world matrix of the camera.
  25495. * @returns the camera world matrix
  25496. */
  25497. computeWorldMatrix(): Matrix;
  25498. /**
  25499. * Parse a JSON and creates the camera from the parsed information
  25500. * @param parsedCamera The JSON to parse
  25501. * @param scene The scene to instantiate the camera in
  25502. * @returns the newly constructed camera
  25503. */
  25504. static Parse(parsedCamera: any, scene: Scene): Camera;
  25505. }
  25506. }
  25507. declare module BABYLON {
  25508. /**
  25509. * Class containing static functions to help procedurally build meshes
  25510. */
  25511. export class DiscBuilder {
  25512. /**
  25513. * Creates a plane polygonal mesh. By default, this is a disc
  25514. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25515. * * 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
  25516. * * 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
  25517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25518. * * 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
  25519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25520. * @param name defines the name of the mesh
  25521. * @param options defines the options used to create the mesh
  25522. * @param scene defines the hosting scene
  25523. * @returns the plane polygonal mesh
  25524. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25525. */
  25526. static CreateDisc(name: string, options: {
  25527. radius?: number;
  25528. tessellation?: number;
  25529. arc?: number;
  25530. updatable?: boolean;
  25531. sideOrientation?: number;
  25532. frontUVs?: Vector4;
  25533. backUVs?: Vector4;
  25534. }, scene?: Nullable<Scene>): Mesh;
  25535. }
  25536. }
  25537. declare module BABYLON {
  25538. /**
  25539. * This represents all the required information to add a fresnel effect on a material:
  25540. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25541. */
  25542. export class FresnelParameters {
  25543. private _isEnabled;
  25544. /**
  25545. * Define if the fresnel effect is enable or not.
  25546. */
  25547. isEnabled: boolean;
  25548. /**
  25549. * Define the color used on edges (grazing angle)
  25550. */
  25551. leftColor: Color3;
  25552. /**
  25553. * Define the color used on center
  25554. */
  25555. rightColor: Color3;
  25556. /**
  25557. * Define bias applied to computed fresnel term
  25558. */
  25559. bias: number;
  25560. /**
  25561. * Defined the power exponent applied to fresnel term
  25562. */
  25563. power: number;
  25564. /**
  25565. * Clones the current fresnel and its valuues
  25566. * @returns a clone fresnel configuration
  25567. */
  25568. clone(): FresnelParameters;
  25569. /**
  25570. * Serializes the current fresnel parameters to a JSON representation.
  25571. * @return the JSON serialization
  25572. */
  25573. serialize(): any;
  25574. /**
  25575. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25576. * @param parsedFresnelParameters Define the JSON representation
  25577. * @returns the parsed parameters
  25578. */
  25579. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25580. }
  25581. }
  25582. declare module BABYLON {
  25583. /**
  25584. * Base class of materials working in push mode in babylon JS
  25585. * @hidden
  25586. */
  25587. export class PushMaterial extends Material {
  25588. protected _activeEffect: Effect;
  25589. protected _normalMatrix: Matrix;
  25590. /**
  25591. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25592. * This means that the material can keep using a previous shader while a new one is being compiled.
  25593. * This is mostly used when shader parallel compilation is supported (true by default)
  25594. */
  25595. allowShaderHotSwapping: boolean;
  25596. constructor(name: string, scene: Scene);
  25597. getEffect(): Effect;
  25598. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25599. /**
  25600. * Binds the given world matrix to the active effect
  25601. *
  25602. * @param world the matrix to bind
  25603. */
  25604. bindOnlyWorldMatrix(world: Matrix): void;
  25605. /**
  25606. * Binds the given normal matrix to the active effect
  25607. *
  25608. * @param normalMatrix the matrix to bind
  25609. */
  25610. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25611. bind(world: Matrix, mesh?: Mesh): void;
  25612. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25613. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25614. }
  25615. }
  25616. declare module BABYLON {
  25617. /**
  25618. * This groups all the flags used to control the materials channel.
  25619. */
  25620. export class MaterialFlags {
  25621. private static _DiffuseTextureEnabled;
  25622. /**
  25623. * Are diffuse textures enabled in the application.
  25624. */
  25625. static DiffuseTextureEnabled: boolean;
  25626. private static _AmbientTextureEnabled;
  25627. /**
  25628. * Are ambient textures enabled in the application.
  25629. */
  25630. static AmbientTextureEnabled: boolean;
  25631. private static _OpacityTextureEnabled;
  25632. /**
  25633. * Are opacity textures enabled in the application.
  25634. */
  25635. static OpacityTextureEnabled: boolean;
  25636. private static _ReflectionTextureEnabled;
  25637. /**
  25638. * Are reflection textures enabled in the application.
  25639. */
  25640. static ReflectionTextureEnabled: boolean;
  25641. private static _EmissiveTextureEnabled;
  25642. /**
  25643. * Are emissive textures enabled in the application.
  25644. */
  25645. static EmissiveTextureEnabled: boolean;
  25646. private static _SpecularTextureEnabled;
  25647. /**
  25648. * Are specular textures enabled in the application.
  25649. */
  25650. static SpecularTextureEnabled: boolean;
  25651. private static _BumpTextureEnabled;
  25652. /**
  25653. * Are bump textures enabled in the application.
  25654. */
  25655. static BumpTextureEnabled: boolean;
  25656. private static _LightmapTextureEnabled;
  25657. /**
  25658. * Are lightmap textures enabled in the application.
  25659. */
  25660. static LightmapTextureEnabled: boolean;
  25661. private static _RefractionTextureEnabled;
  25662. /**
  25663. * Are refraction textures enabled in the application.
  25664. */
  25665. static RefractionTextureEnabled: boolean;
  25666. private static _ColorGradingTextureEnabled;
  25667. /**
  25668. * Are color grading textures enabled in the application.
  25669. */
  25670. static ColorGradingTextureEnabled: boolean;
  25671. private static _FresnelEnabled;
  25672. /**
  25673. * Are fresnels enabled in the application.
  25674. */
  25675. static FresnelEnabled: boolean;
  25676. private static _ClearCoatTextureEnabled;
  25677. /**
  25678. * Are clear coat textures enabled in the application.
  25679. */
  25680. static ClearCoatTextureEnabled: boolean;
  25681. private static _ClearCoatBumpTextureEnabled;
  25682. /**
  25683. * Are clear coat bump textures enabled in the application.
  25684. */
  25685. static ClearCoatBumpTextureEnabled: boolean;
  25686. private static _ClearCoatTintTextureEnabled;
  25687. /**
  25688. * Are clear coat tint textures enabled in the application.
  25689. */
  25690. static ClearCoatTintTextureEnabled: boolean;
  25691. private static _SheenTextureEnabled;
  25692. /**
  25693. * Are sheen textures enabled in the application.
  25694. */
  25695. static SheenTextureEnabled: boolean;
  25696. private static _AnisotropicTextureEnabled;
  25697. /**
  25698. * Are anisotropic textures enabled in the application.
  25699. */
  25700. static AnisotropicTextureEnabled: boolean;
  25701. private static _ThicknessTextureEnabled;
  25702. /**
  25703. * Are thickness textures enabled in the application.
  25704. */
  25705. static ThicknessTextureEnabled: boolean;
  25706. }
  25707. }
  25708. declare module BABYLON {
  25709. /** @hidden */
  25710. export var defaultFragmentDeclaration: {
  25711. name: string;
  25712. shader: string;
  25713. };
  25714. }
  25715. declare module BABYLON {
  25716. /** @hidden */
  25717. export var defaultUboDeclaration: {
  25718. name: string;
  25719. shader: string;
  25720. };
  25721. }
  25722. declare module BABYLON {
  25723. /** @hidden */
  25724. export var lightFragmentDeclaration: {
  25725. name: string;
  25726. shader: string;
  25727. };
  25728. }
  25729. declare module BABYLON {
  25730. /** @hidden */
  25731. export var lightUboDeclaration: {
  25732. name: string;
  25733. shader: string;
  25734. };
  25735. }
  25736. declare module BABYLON {
  25737. /** @hidden */
  25738. export var lightsFragmentFunctions: {
  25739. name: string;
  25740. shader: string;
  25741. };
  25742. }
  25743. declare module BABYLON {
  25744. /** @hidden */
  25745. export var shadowsFragmentFunctions: {
  25746. name: string;
  25747. shader: string;
  25748. };
  25749. }
  25750. declare module BABYLON {
  25751. /** @hidden */
  25752. export var fresnelFunction: {
  25753. name: string;
  25754. shader: string;
  25755. };
  25756. }
  25757. declare module BABYLON {
  25758. /** @hidden */
  25759. export var reflectionFunction: {
  25760. name: string;
  25761. shader: string;
  25762. };
  25763. }
  25764. declare module BABYLON {
  25765. /** @hidden */
  25766. export var bumpFragmentFunctions: {
  25767. name: string;
  25768. shader: string;
  25769. };
  25770. }
  25771. declare module BABYLON {
  25772. /** @hidden */
  25773. export var logDepthDeclaration: {
  25774. name: string;
  25775. shader: string;
  25776. };
  25777. }
  25778. declare module BABYLON {
  25779. /** @hidden */
  25780. export var bumpFragment: {
  25781. name: string;
  25782. shader: string;
  25783. };
  25784. }
  25785. declare module BABYLON {
  25786. /** @hidden */
  25787. export var depthPrePass: {
  25788. name: string;
  25789. shader: string;
  25790. };
  25791. }
  25792. declare module BABYLON {
  25793. /** @hidden */
  25794. export var lightFragment: {
  25795. name: string;
  25796. shader: string;
  25797. };
  25798. }
  25799. declare module BABYLON {
  25800. /** @hidden */
  25801. export var logDepthFragment: {
  25802. name: string;
  25803. shader: string;
  25804. };
  25805. }
  25806. declare module BABYLON {
  25807. /** @hidden */
  25808. export var defaultPixelShader: {
  25809. name: string;
  25810. shader: string;
  25811. };
  25812. }
  25813. declare module BABYLON {
  25814. /** @hidden */
  25815. export var defaultVertexDeclaration: {
  25816. name: string;
  25817. shader: string;
  25818. };
  25819. }
  25820. declare module BABYLON {
  25821. /** @hidden */
  25822. export var bumpVertexDeclaration: {
  25823. name: string;
  25824. shader: string;
  25825. };
  25826. }
  25827. declare module BABYLON {
  25828. /** @hidden */
  25829. export var bumpVertex: {
  25830. name: string;
  25831. shader: string;
  25832. };
  25833. }
  25834. declare module BABYLON {
  25835. /** @hidden */
  25836. export var fogVertex: {
  25837. name: string;
  25838. shader: string;
  25839. };
  25840. }
  25841. declare module BABYLON {
  25842. /** @hidden */
  25843. export var shadowsVertex: {
  25844. name: string;
  25845. shader: string;
  25846. };
  25847. }
  25848. declare module BABYLON {
  25849. /** @hidden */
  25850. export var pointCloudVertex: {
  25851. name: string;
  25852. shader: string;
  25853. };
  25854. }
  25855. declare module BABYLON {
  25856. /** @hidden */
  25857. export var logDepthVertex: {
  25858. name: string;
  25859. shader: string;
  25860. };
  25861. }
  25862. declare module BABYLON {
  25863. /** @hidden */
  25864. export var defaultVertexShader: {
  25865. name: string;
  25866. shader: string;
  25867. };
  25868. }
  25869. declare module BABYLON {
  25870. /** @hidden */
  25871. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  25872. MAINUV1: boolean;
  25873. MAINUV2: boolean;
  25874. DIFFUSE: boolean;
  25875. DIFFUSEDIRECTUV: number;
  25876. AMBIENT: boolean;
  25877. AMBIENTDIRECTUV: number;
  25878. OPACITY: boolean;
  25879. OPACITYDIRECTUV: number;
  25880. OPACITYRGB: boolean;
  25881. REFLECTION: boolean;
  25882. EMISSIVE: boolean;
  25883. EMISSIVEDIRECTUV: number;
  25884. SPECULAR: boolean;
  25885. SPECULARDIRECTUV: number;
  25886. BUMP: boolean;
  25887. BUMPDIRECTUV: number;
  25888. PARALLAX: boolean;
  25889. PARALLAXOCCLUSION: boolean;
  25890. SPECULAROVERALPHA: boolean;
  25891. CLIPPLANE: boolean;
  25892. CLIPPLANE2: boolean;
  25893. CLIPPLANE3: boolean;
  25894. CLIPPLANE4: boolean;
  25895. ALPHATEST: boolean;
  25896. DEPTHPREPASS: boolean;
  25897. ALPHAFROMDIFFUSE: boolean;
  25898. POINTSIZE: boolean;
  25899. FOG: boolean;
  25900. SPECULARTERM: boolean;
  25901. DIFFUSEFRESNEL: boolean;
  25902. OPACITYFRESNEL: boolean;
  25903. REFLECTIONFRESNEL: boolean;
  25904. REFRACTIONFRESNEL: boolean;
  25905. EMISSIVEFRESNEL: boolean;
  25906. FRESNEL: boolean;
  25907. NORMAL: boolean;
  25908. UV1: boolean;
  25909. UV2: boolean;
  25910. VERTEXCOLOR: boolean;
  25911. VERTEXALPHA: boolean;
  25912. NUM_BONE_INFLUENCERS: number;
  25913. BonesPerMesh: number;
  25914. BONETEXTURE: boolean;
  25915. INSTANCES: boolean;
  25916. GLOSSINESS: boolean;
  25917. ROUGHNESS: boolean;
  25918. EMISSIVEASILLUMINATION: boolean;
  25919. LINKEMISSIVEWITHDIFFUSE: boolean;
  25920. REFLECTIONFRESNELFROMSPECULAR: boolean;
  25921. LIGHTMAP: boolean;
  25922. LIGHTMAPDIRECTUV: number;
  25923. OBJECTSPACE_NORMALMAP: boolean;
  25924. USELIGHTMAPASSHADOWMAP: boolean;
  25925. REFLECTIONMAP_3D: boolean;
  25926. REFLECTIONMAP_SPHERICAL: boolean;
  25927. REFLECTIONMAP_PLANAR: boolean;
  25928. REFLECTIONMAP_CUBIC: boolean;
  25929. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  25930. REFLECTIONMAP_PROJECTION: boolean;
  25931. REFLECTIONMAP_SKYBOX: boolean;
  25932. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  25933. REFLECTIONMAP_EXPLICIT: boolean;
  25934. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  25935. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  25936. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  25937. INVERTCUBICMAP: boolean;
  25938. LOGARITHMICDEPTH: boolean;
  25939. REFRACTION: boolean;
  25940. REFRACTIONMAP_3D: boolean;
  25941. REFLECTIONOVERALPHA: boolean;
  25942. TWOSIDEDLIGHTING: boolean;
  25943. SHADOWFLOAT: boolean;
  25944. MORPHTARGETS: boolean;
  25945. MORPHTARGETS_NORMAL: boolean;
  25946. MORPHTARGETS_TANGENT: boolean;
  25947. MORPHTARGETS_UV: boolean;
  25948. NUM_MORPH_INFLUENCERS: number;
  25949. NONUNIFORMSCALING: boolean;
  25950. PREMULTIPLYALPHA: boolean;
  25951. IMAGEPROCESSING: boolean;
  25952. VIGNETTE: boolean;
  25953. VIGNETTEBLENDMODEMULTIPLY: boolean;
  25954. VIGNETTEBLENDMODEOPAQUE: boolean;
  25955. TONEMAPPING: boolean;
  25956. TONEMAPPING_ACES: boolean;
  25957. CONTRAST: boolean;
  25958. COLORCURVES: boolean;
  25959. COLORGRADING: boolean;
  25960. COLORGRADING3D: boolean;
  25961. SAMPLER3DGREENDEPTH: boolean;
  25962. SAMPLER3DBGRMAP: boolean;
  25963. IMAGEPROCESSINGPOSTPROCESS: boolean;
  25964. MULTIVIEW: boolean;
  25965. /**
  25966. * If the reflection texture on this material is in linear color space
  25967. * @hidden
  25968. */
  25969. IS_REFLECTION_LINEAR: boolean;
  25970. /**
  25971. * If the refraction texture on this material is in linear color space
  25972. * @hidden
  25973. */
  25974. IS_REFRACTION_LINEAR: boolean;
  25975. EXPOSURE: boolean;
  25976. constructor();
  25977. setReflectionMode(modeToEnable: string): void;
  25978. }
  25979. /**
  25980. * This is the default material used in Babylon. It is the best trade off between quality
  25981. * and performances.
  25982. * @see http://doc.babylonjs.com/babylon101/materials
  25983. */
  25984. export class StandardMaterial extends PushMaterial {
  25985. private _diffuseTexture;
  25986. /**
  25987. * The basic texture of the material as viewed under a light.
  25988. */
  25989. diffuseTexture: Nullable<BaseTexture>;
  25990. private _ambientTexture;
  25991. /**
  25992. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  25993. */
  25994. ambientTexture: Nullable<BaseTexture>;
  25995. private _opacityTexture;
  25996. /**
  25997. * Define the transparency of the material from a texture.
  25998. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  25999. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26000. */
  26001. opacityTexture: Nullable<BaseTexture>;
  26002. private _reflectionTexture;
  26003. /**
  26004. * Define the texture used to display the reflection.
  26005. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26006. */
  26007. reflectionTexture: Nullable<BaseTexture>;
  26008. private _emissiveTexture;
  26009. /**
  26010. * Define texture of the material as if self lit.
  26011. * This will be mixed in the final result even in the absence of light.
  26012. */
  26013. emissiveTexture: Nullable<BaseTexture>;
  26014. private _specularTexture;
  26015. /**
  26016. * Define how the color and intensity of the highlight given by the light in the material.
  26017. */
  26018. specularTexture: Nullable<BaseTexture>;
  26019. private _bumpTexture;
  26020. /**
  26021. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26022. * 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.
  26023. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26024. */
  26025. bumpTexture: Nullable<BaseTexture>;
  26026. private _lightmapTexture;
  26027. /**
  26028. * Complex lighting can be computationally expensive to compute at runtime.
  26029. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26030. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26031. */
  26032. lightmapTexture: Nullable<BaseTexture>;
  26033. private _refractionTexture;
  26034. /**
  26035. * Define the texture used to display the refraction.
  26036. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26037. */
  26038. refractionTexture: Nullable<BaseTexture>;
  26039. /**
  26040. * The color of the material lit by the environmental background lighting.
  26041. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26042. */
  26043. ambientColor: Color3;
  26044. /**
  26045. * The basic color of the material as viewed under a light.
  26046. */
  26047. diffuseColor: Color3;
  26048. /**
  26049. * Define how the color and intensity of the highlight given by the light in the material.
  26050. */
  26051. specularColor: Color3;
  26052. /**
  26053. * Define the color of the material as if self lit.
  26054. * This will be mixed in the final result even in the absence of light.
  26055. */
  26056. emissiveColor: Color3;
  26057. /**
  26058. * Defines how sharp are the highlights in the material.
  26059. * The bigger the value the sharper giving a more glossy feeling to the result.
  26060. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26061. */
  26062. specularPower: number;
  26063. private _useAlphaFromDiffuseTexture;
  26064. /**
  26065. * Does the transparency come from the diffuse texture alpha channel.
  26066. */
  26067. useAlphaFromDiffuseTexture: boolean;
  26068. private _useEmissiveAsIllumination;
  26069. /**
  26070. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26071. */
  26072. useEmissiveAsIllumination: boolean;
  26073. private _linkEmissiveWithDiffuse;
  26074. /**
  26075. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26076. * the emissive level when the final color is close to one.
  26077. */
  26078. linkEmissiveWithDiffuse: boolean;
  26079. private _useSpecularOverAlpha;
  26080. /**
  26081. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26082. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26083. */
  26084. useSpecularOverAlpha: boolean;
  26085. private _useReflectionOverAlpha;
  26086. /**
  26087. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26088. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26089. */
  26090. useReflectionOverAlpha: boolean;
  26091. private _disableLighting;
  26092. /**
  26093. * Does lights from the scene impacts this material.
  26094. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26095. */
  26096. disableLighting: boolean;
  26097. private _useObjectSpaceNormalMap;
  26098. /**
  26099. * Allows using an object space normal map (instead of tangent space).
  26100. */
  26101. useObjectSpaceNormalMap: boolean;
  26102. private _useParallax;
  26103. /**
  26104. * Is parallax enabled or not.
  26105. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26106. */
  26107. useParallax: boolean;
  26108. private _useParallaxOcclusion;
  26109. /**
  26110. * Is parallax occlusion enabled or not.
  26111. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26112. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26113. */
  26114. useParallaxOcclusion: boolean;
  26115. /**
  26116. * 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.
  26117. */
  26118. parallaxScaleBias: number;
  26119. private _roughness;
  26120. /**
  26121. * Helps to define how blurry the reflections should appears in the material.
  26122. */
  26123. roughness: number;
  26124. /**
  26125. * In case of refraction, define the value of the index of refraction.
  26126. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26127. */
  26128. indexOfRefraction: number;
  26129. /**
  26130. * Invert the refraction texture alongside the y axis.
  26131. * It can be useful with procedural textures or probe for instance.
  26132. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26133. */
  26134. invertRefractionY: boolean;
  26135. /**
  26136. * Defines the alpha limits in alpha test mode.
  26137. */
  26138. alphaCutOff: number;
  26139. private _useLightmapAsShadowmap;
  26140. /**
  26141. * In case of light mapping, define whether the map contains light or shadow informations.
  26142. */
  26143. useLightmapAsShadowmap: boolean;
  26144. private _diffuseFresnelParameters;
  26145. /**
  26146. * Define the diffuse fresnel parameters of the material.
  26147. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26148. */
  26149. diffuseFresnelParameters: FresnelParameters;
  26150. private _opacityFresnelParameters;
  26151. /**
  26152. * Define the opacity fresnel parameters of the material.
  26153. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26154. */
  26155. opacityFresnelParameters: FresnelParameters;
  26156. private _reflectionFresnelParameters;
  26157. /**
  26158. * Define the reflection fresnel parameters of the material.
  26159. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26160. */
  26161. reflectionFresnelParameters: FresnelParameters;
  26162. private _refractionFresnelParameters;
  26163. /**
  26164. * Define the refraction fresnel parameters of the material.
  26165. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26166. */
  26167. refractionFresnelParameters: FresnelParameters;
  26168. private _emissiveFresnelParameters;
  26169. /**
  26170. * Define the emissive fresnel parameters of the material.
  26171. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26172. */
  26173. emissiveFresnelParameters: FresnelParameters;
  26174. private _useReflectionFresnelFromSpecular;
  26175. /**
  26176. * If true automatically deducts the fresnels values from the material specularity.
  26177. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26178. */
  26179. useReflectionFresnelFromSpecular: boolean;
  26180. private _useGlossinessFromSpecularMapAlpha;
  26181. /**
  26182. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26183. */
  26184. useGlossinessFromSpecularMapAlpha: boolean;
  26185. private _maxSimultaneousLights;
  26186. /**
  26187. * Defines the maximum number of lights that can be used in the material
  26188. */
  26189. maxSimultaneousLights: number;
  26190. private _invertNormalMapX;
  26191. /**
  26192. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26193. */
  26194. invertNormalMapX: boolean;
  26195. private _invertNormalMapY;
  26196. /**
  26197. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26198. */
  26199. invertNormalMapY: boolean;
  26200. private _twoSidedLighting;
  26201. /**
  26202. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26203. */
  26204. twoSidedLighting: boolean;
  26205. /**
  26206. * Default configuration related to image processing available in the standard Material.
  26207. */
  26208. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26209. /**
  26210. * Gets the image processing configuration used either in this material.
  26211. */
  26212. /**
  26213. * Sets the Default image processing configuration used either in the this material.
  26214. *
  26215. * If sets to null, the scene one is in use.
  26216. */
  26217. imageProcessingConfiguration: ImageProcessingConfiguration;
  26218. /**
  26219. * Keep track of the image processing observer to allow dispose and replace.
  26220. */
  26221. private _imageProcessingObserver;
  26222. /**
  26223. * Attaches a new image processing configuration to the Standard Material.
  26224. * @param configuration
  26225. */
  26226. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26227. /**
  26228. * Gets wether the color curves effect is enabled.
  26229. */
  26230. /**
  26231. * Sets wether the color curves effect is enabled.
  26232. */
  26233. cameraColorCurvesEnabled: boolean;
  26234. /**
  26235. * Gets wether the color grading effect is enabled.
  26236. */
  26237. /**
  26238. * Gets wether the color grading effect is enabled.
  26239. */
  26240. cameraColorGradingEnabled: boolean;
  26241. /**
  26242. * Gets wether tonemapping is enabled or not.
  26243. */
  26244. /**
  26245. * Sets wether tonemapping is enabled or not
  26246. */
  26247. cameraToneMappingEnabled: boolean;
  26248. /**
  26249. * The camera exposure used on this material.
  26250. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26251. * This corresponds to a photographic exposure.
  26252. */
  26253. /**
  26254. * The camera exposure used on this material.
  26255. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26256. * This corresponds to a photographic exposure.
  26257. */
  26258. cameraExposure: number;
  26259. /**
  26260. * Gets The camera contrast used on this material.
  26261. */
  26262. /**
  26263. * Sets The camera contrast used on this material.
  26264. */
  26265. cameraContrast: number;
  26266. /**
  26267. * Gets the Color Grading 2D Lookup Texture.
  26268. */
  26269. /**
  26270. * Sets the Color Grading 2D Lookup Texture.
  26271. */
  26272. cameraColorGradingTexture: Nullable<BaseTexture>;
  26273. /**
  26274. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26275. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26276. * 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;
  26277. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26278. */
  26279. /**
  26280. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26281. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26282. * 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;
  26283. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26284. */
  26285. cameraColorCurves: Nullable<ColorCurves>;
  26286. /**
  26287. * Custom callback helping to override the default shader used in the material.
  26288. */
  26289. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26290. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26291. protected _worldViewProjectionMatrix: Matrix;
  26292. protected _globalAmbientColor: Color3;
  26293. protected _useLogarithmicDepth: boolean;
  26294. protected _rebuildInParallel: boolean;
  26295. /**
  26296. * Instantiates a new standard material.
  26297. * This is the default material used in Babylon. It is the best trade off between quality
  26298. * and performances.
  26299. * @see http://doc.babylonjs.com/babylon101/materials
  26300. * @param name Define the name of the material in the scene
  26301. * @param scene Define the scene the material belong to
  26302. */
  26303. constructor(name: string, scene: Scene);
  26304. /**
  26305. * Gets a boolean indicating that current material needs to register RTT
  26306. */
  26307. readonly hasRenderTargetTextures: boolean;
  26308. /**
  26309. * Gets the current class name of the material e.g. "StandardMaterial"
  26310. * Mainly use in serialization.
  26311. * @returns the class name
  26312. */
  26313. getClassName(): string;
  26314. /**
  26315. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26316. * You can try switching to logarithmic depth.
  26317. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26318. */
  26319. useLogarithmicDepth: boolean;
  26320. /**
  26321. * Specifies if the material will require alpha blending
  26322. * @returns a boolean specifying if alpha blending is needed
  26323. */
  26324. needAlphaBlending(): boolean;
  26325. /**
  26326. * Specifies if this material should be rendered in alpha test mode
  26327. * @returns a boolean specifying if an alpha test is needed.
  26328. */
  26329. needAlphaTesting(): boolean;
  26330. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26331. /**
  26332. * Get the texture used for alpha test purpose.
  26333. * @returns the diffuse texture in case of the standard material.
  26334. */
  26335. getAlphaTestTexture(): Nullable<BaseTexture>;
  26336. /**
  26337. * Get if the submesh is ready to be used and all its information available.
  26338. * Child classes can use it to update shaders
  26339. * @param mesh defines the mesh to check
  26340. * @param subMesh defines which submesh to check
  26341. * @param useInstances specifies that instances should be used
  26342. * @returns a boolean indicating that the submesh is ready or not
  26343. */
  26344. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26345. /**
  26346. * Builds the material UBO layouts.
  26347. * Used internally during the effect preparation.
  26348. */
  26349. buildUniformLayout(): void;
  26350. /**
  26351. * Unbinds the material from the mesh
  26352. */
  26353. unbind(): void;
  26354. /**
  26355. * Binds the submesh to this material by preparing the effect and shader to draw
  26356. * @param world defines the world transformation matrix
  26357. * @param mesh defines the mesh containing the submesh
  26358. * @param subMesh defines the submesh to bind the material to
  26359. */
  26360. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26361. /**
  26362. * Get the list of animatables in the material.
  26363. * @returns the list of animatables object used in the material
  26364. */
  26365. getAnimatables(): IAnimatable[];
  26366. /**
  26367. * Gets the active textures from the material
  26368. * @returns an array of textures
  26369. */
  26370. getActiveTextures(): BaseTexture[];
  26371. /**
  26372. * Specifies if the material uses a texture
  26373. * @param texture defines the texture to check against the material
  26374. * @returns a boolean specifying if the material uses the texture
  26375. */
  26376. hasTexture(texture: BaseTexture): boolean;
  26377. /**
  26378. * Disposes the material
  26379. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26380. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26381. */
  26382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26383. /**
  26384. * Makes a duplicate of the material, and gives it a new name
  26385. * @param name defines the new name for the duplicated material
  26386. * @returns the cloned material
  26387. */
  26388. clone(name: string): StandardMaterial;
  26389. /**
  26390. * Serializes this material in a JSON representation
  26391. * @returns the serialized material object
  26392. */
  26393. serialize(): any;
  26394. /**
  26395. * Creates a standard material from parsed material data
  26396. * @param source defines the JSON representation of the material
  26397. * @param scene defines the hosting scene
  26398. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26399. * @returns a new standard material
  26400. */
  26401. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26402. /**
  26403. * Are diffuse textures enabled in the application.
  26404. */
  26405. static DiffuseTextureEnabled: boolean;
  26406. /**
  26407. * Are ambient textures enabled in the application.
  26408. */
  26409. static AmbientTextureEnabled: boolean;
  26410. /**
  26411. * Are opacity textures enabled in the application.
  26412. */
  26413. static OpacityTextureEnabled: boolean;
  26414. /**
  26415. * Are reflection textures enabled in the application.
  26416. */
  26417. static ReflectionTextureEnabled: boolean;
  26418. /**
  26419. * Are emissive textures enabled in the application.
  26420. */
  26421. static EmissiveTextureEnabled: boolean;
  26422. /**
  26423. * Are specular textures enabled in the application.
  26424. */
  26425. static SpecularTextureEnabled: boolean;
  26426. /**
  26427. * Are bump textures enabled in the application.
  26428. */
  26429. static BumpTextureEnabled: boolean;
  26430. /**
  26431. * Are lightmap textures enabled in the application.
  26432. */
  26433. static LightmapTextureEnabled: boolean;
  26434. /**
  26435. * Are refraction textures enabled in the application.
  26436. */
  26437. static RefractionTextureEnabled: boolean;
  26438. /**
  26439. * Are color grading textures enabled in the application.
  26440. */
  26441. static ColorGradingTextureEnabled: boolean;
  26442. /**
  26443. * Are fresnels enabled in the application.
  26444. */
  26445. static FresnelEnabled: boolean;
  26446. }
  26447. }
  26448. declare module BABYLON {
  26449. /**
  26450. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26451. *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.
  26452. * The SPS is also a particle system. It provides some methods to manage the particles.
  26453. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26454. *
  26455. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26456. */
  26457. export class SolidParticleSystem implements IDisposable {
  26458. /**
  26459. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26460. * Example : var p = SPS.particles[i];
  26461. */
  26462. particles: SolidParticle[];
  26463. /**
  26464. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26465. */
  26466. nbParticles: number;
  26467. /**
  26468. * If the particles must ever face the camera (default false). Useful for planar particles.
  26469. */
  26470. billboard: boolean;
  26471. /**
  26472. * Recompute normals when adding a shape
  26473. */
  26474. recomputeNormals: boolean;
  26475. /**
  26476. * This a counter ofr your own usage. It's not set by any SPS functions.
  26477. */
  26478. counter: number;
  26479. /**
  26480. * The SPS name. This name is also given to the underlying mesh.
  26481. */
  26482. name: string;
  26483. /**
  26484. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26485. */
  26486. mesh: Mesh;
  26487. /**
  26488. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26489. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26490. */
  26491. vars: any;
  26492. /**
  26493. * This array is populated when the SPS is set as 'pickable'.
  26494. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26495. * Each element of this array is an object `{idx: int, faceId: int}`.
  26496. * `idx` is the picked particle index in the `SPS.particles` array
  26497. * `faceId` is the picked face index counted within this particle.
  26498. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26499. */
  26500. pickedParticles: {
  26501. idx: number;
  26502. faceId: number;
  26503. }[];
  26504. /**
  26505. * This array is populated when `enableDepthSort` is set to true.
  26506. * Each element of this array is an instance of the class DepthSortedParticle.
  26507. */
  26508. depthSortedParticles: DepthSortedParticle[];
  26509. /**
  26510. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26511. * @hidden
  26512. */
  26513. _bSphereOnly: boolean;
  26514. /**
  26515. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26516. * @hidden
  26517. */
  26518. _bSphereRadiusFactor: number;
  26519. private _scene;
  26520. private _positions;
  26521. private _indices;
  26522. private _normals;
  26523. private _colors;
  26524. private _uvs;
  26525. private _indices32;
  26526. private _positions32;
  26527. private _normals32;
  26528. private _fixedNormal32;
  26529. private _colors32;
  26530. private _uvs32;
  26531. private _index;
  26532. private _updatable;
  26533. private _pickable;
  26534. private _isVisibilityBoxLocked;
  26535. private _alwaysVisible;
  26536. private _depthSort;
  26537. private _expandable;
  26538. private _shapeCounter;
  26539. private _copy;
  26540. private _color;
  26541. private _computeParticleColor;
  26542. private _computeParticleTexture;
  26543. private _computeParticleRotation;
  26544. private _computeParticleVertex;
  26545. private _computeBoundingBox;
  26546. private _depthSortParticles;
  26547. private _camera;
  26548. private _mustUnrotateFixedNormals;
  26549. private _particlesIntersect;
  26550. private _needs32Bits;
  26551. private _isNotBuilt;
  26552. private _lastParticleId;
  26553. private _idxOfId;
  26554. private _multimaterialEnabled;
  26555. private _useModelMaterial;
  26556. private _indicesByMaterial;
  26557. private _materialIndexes;
  26558. private _depthSortFunction;
  26559. private _materialSortFunction;
  26560. private _materials;
  26561. private _multimaterial;
  26562. private _materialIndexesById;
  26563. private _defaultMaterial;
  26564. private _autoUpdateSubMeshes;
  26565. /**
  26566. * Creates a SPS (Solid Particle System) object.
  26567. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26568. * @param scene (Scene) is the scene in which the SPS is added.
  26569. * @param options defines the options of the sps e.g.
  26570. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26571. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26572. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26573. * * 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.
  26574. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26575. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26576. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26577. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26578. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26579. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26580. */
  26581. constructor(name: string, scene: Scene, options?: {
  26582. updatable?: boolean;
  26583. isPickable?: boolean;
  26584. enableDepthSort?: boolean;
  26585. particleIntersection?: boolean;
  26586. boundingSphereOnly?: boolean;
  26587. bSphereRadiusFactor?: number;
  26588. expandable?: boolean;
  26589. useModelMaterial?: boolean;
  26590. enableMultiMaterial?: boolean;
  26591. });
  26592. /**
  26593. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26594. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26595. * @returns the created mesh
  26596. */
  26597. buildMesh(): Mesh;
  26598. /**
  26599. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26600. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26601. * Thus the particles generated from `digest()` have their property `position` set yet.
  26602. * @param mesh ( Mesh ) is the mesh to be digested
  26603. * @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
  26604. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26605. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26606. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26607. * @returns the current SPS
  26608. */
  26609. digest(mesh: Mesh, options?: {
  26610. facetNb?: number;
  26611. number?: number;
  26612. delta?: number;
  26613. storage?: [];
  26614. }): SolidParticleSystem;
  26615. /**
  26616. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26617. * @hidden
  26618. */
  26619. private _unrotateFixedNormals;
  26620. /**
  26621. * Resets the temporary working copy particle
  26622. * @hidden
  26623. */
  26624. private _resetCopy;
  26625. /**
  26626. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26627. * @param p the current index in the positions array to be updated
  26628. * @param ind the current index in the indices array
  26629. * @param shape a Vector3 array, the shape geometry
  26630. * @param positions the positions array to be updated
  26631. * @param meshInd the shape indices array
  26632. * @param indices the indices array to be updated
  26633. * @param meshUV the shape uv array
  26634. * @param uvs the uv array to be updated
  26635. * @param meshCol the shape color array
  26636. * @param colors the color array to be updated
  26637. * @param meshNor the shape normals array
  26638. * @param normals the normals array to be updated
  26639. * @param idx the particle index
  26640. * @param idxInShape the particle index in its shape
  26641. * @param options the addShape() method passed options
  26642. * @model the particle model
  26643. * @hidden
  26644. */
  26645. private _meshBuilder;
  26646. /**
  26647. * Returns a shape Vector3 array from positions float array
  26648. * @param positions float array
  26649. * @returns a vector3 array
  26650. * @hidden
  26651. */
  26652. private _posToShape;
  26653. /**
  26654. * Returns a shapeUV array from a float uvs (array deep copy)
  26655. * @param uvs as a float array
  26656. * @returns a shapeUV array
  26657. * @hidden
  26658. */
  26659. private _uvsToShapeUV;
  26660. /**
  26661. * Adds a new particle object in the particles array
  26662. * @param idx particle index in particles array
  26663. * @param id particle id
  26664. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26665. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26666. * @param model particle ModelShape object
  26667. * @param shapeId model shape identifier
  26668. * @param idxInShape index of the particle in the current model
  26669. * @param bInfo model bounding info object
  26670. * @param storage target storage array, if any
  26671. * @hidden
  26672. */
  26673. private _addParticle;
  26674. /**
  26675. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26676. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26677. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26678. * @param nb (positive integer) the number of particles to be created from this model
  26679. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26680. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26681. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26682. * @returns the number of shapes in the system
  26683. */
  26684. addShape(mesh: Mesh, nb: number, options?: {
  26685. positionFunction?: any;
  26686. vertexFunction?: any;
  26687. storage?: [];
  26688. }): number;
  26689. /**
  26690. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26691. * @hidden
  26692. */
  26693. private _rebuildParticle;
  26694. /**
  26695. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26696. * @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.
  26697. * @returns the SPS.
  26698. */
  26699. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26700. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26701. * Returns an array with the removed particles.
  26702. * 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.
  26703. * The SPS can't be empty so at least one particle needs to remain in place.
  26704. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26705. * @param start index of the first particle to remove
  26706. * @param end index of the last particle to remove (included)
  26707. * @returns an array populated with the removed particles
  26708. */
  26709. removeParticles(start: number, end: number): SolidParticle[];
  26710. /**
  26711. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26712. * @param solidParticleArray an array populated with Solid Particles objects
  26713. * @returns the SPS
  26714. */
  26715. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26716. /**
  26717. * Creates a new particle and modifies the SPS mesh geometry :
  26718. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26719. * - calls _addParticle() to populate the particle array
  26720. * factorized code from addShape() and insertParticlesFromArray()
  26721. * @param idx particle index in the particles array
  26722. * @param i particle index in its shape
  26723. * @param modelShape particle ModelShape object
  26724. * @param shape shape vertex array
  26725. * @param meshInd shape indices array
  26726. * @param meshUV shape uv array
  26727. * @param meshCol shape color array
  26728. * @param meshNor shape normals array
  26729. * @param bbInfo shape bounding info
  26730. * @param storage target particle storage
  26731. * @options addShape() passed options
  26732. * @hidden
  26733. */
  26734. private _insertNewParticle;
  26735. /**
  26736. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26737. * This method calls `updateParticle()` for each particle of the SPS.
  26738. * For an animated SPS, it is usually called within the render loop.
  26739. * 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.
  26740. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26741. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26742. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26743. * @returns the SPS.
  26744. */
  26745. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26746. /**
  26747. * Disposes the SPS.
  26748. */
  26749. dispose(): void;
  26750. /**
  26751. * Returns a SolidParticle object from its identifier : particle.id
  26752. * @param id (integer) the particle Id
  26753. * @returns the searched particle or null if not found in the SPS.
  26754. */
  26755. getParticleById(id: number): Nullable<SolidParticle>;
  26756. /**
  26757. * Returns a new array populated with the particles having the passed shapeId.
  26758. * @param shapeId (integer) the shape identifier
  26759. * @returns a new solid particle array
  26760. */
  26761. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26762. /**
  26763. * Populates the passed array "ref" with the particles having the passed shapeId.
  26764. * @param shapeId the shape identifier
  26765. * @returns the SPS
  26766. * @param ref
  26767. */
  26768. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26769. /**
  26770. * Computes the required SubMeshes according the materials assigned to the particles.
  26771. * @returns the solid particle system.
  26772. * Does nothing if called before the SPS mesh is built.
  26773. */
  26774. computeSubMeshes(): SolidParticleSystem;
  26775. /**
  26776. * Sorts the solid particles by material when MultiMaterial is enabled.
  26777. * Updates the indices32 array.
  26778. * Updates the indicesByMaterial array.
  26779. * Updates the mesh indices array.
  26780. * @returns the SPS
  26781. * @hidden
  26782. */
  26783. private _sortParticlesByMaterial;
  26784. /**
  26785. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  26786. * @hidden
  26787. */
  26788. private _setMaterialIndexesById;
  26789. /**
  26790. * Returns an array with unique values of Materials from the passed array
  26791. * @param array the material array to be checked and filtered
  26792. * @hidden
  26793. */
  26794. private _filterUniqueMaterialId;
  26795. /**
  26796. * Sets a new Standard Material as _defaultMaterial if not already set.
  26797. * @hidden
  26798. */
  26799. private _setDefaultMaterial;
  26800. /**
  26801. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26802. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26803. * @returns the SPS.
  26804. */
  26805. refreshVisibleSize(): SolidParticleSystem;
  26806. /**
  26807. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26808. * @param size the size (float) of the visibility box
  26809. * note : this doesn't lock the SPS mesh bounding box.
  26810. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26811. */
  26812. setVisibilityBox(size: number): void;
  26813. /**
  26814. * Gets whether the SPS as always visible or not
  26815. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26816. */
  26817. /**
  26818. * Sets the SPS as always visible or not
  26819. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26820. */
  26821. isAlwaysVisible: boolean;
  26822. /**
  26823. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26824. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26825. */
  26826. /**
  26827. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26828. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26829. */
  26830. isVisibilityBoxLocked: boolean;
  26831. /**
  26832. * Tells to `setParticles()` to compute the particle rotations or not.
  26833. * Default value : true. The SPS is faster when it's set to false.
  26834. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26835. */
  26836. /**
  26837. * Gets if `setParticles()` computes the particle rotations or not.
  26838. * Default value : true. The SPS is faster when it's set to false.
  26839. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26840. */
  26841. computeParticleRotation: boolean;
  26842. /**
  26843. * Tells to `setParticles()` to compute the particle colors or not.
  26844. * Default value : true. The SPS is faster when it's set to false.
  26845. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26846. */
  26847. /**
  26848. * Gets if `setParticles()` computes the particle colors or not.
  26849. * Default value : true. The SPS is faster when it's set to false.
  26850. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26851. */
  26852. computeParticleColor: boolean;
  26853. /**
  26854. * Gets if `setParticles()` computes the particle textures or not.
  26855. * Default value : true. The SPS is faster when it's set to false.
  26856. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26857. */
  26858. computeParticleTexture: boolean;
  26859. /**
  26860. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26861. * Default value : false. The SPS is faster when it's set to false.
  26862. * Note : the particle custom vertex positions aren't stored values.
  26863. */
  26864. /**
  26865. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26866. * Default value : false. The SPS is faster when it's set to false.
  26867. * Note : the particle custom vertex positions aren't stored values.
  26868. */
  26869. computeParticleVertex: boolean;
  26870. /**
  26871. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26872. */
  26873. /**
  26874. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26875. */
  26876. computeBoundingBox: boolean;
  26877. /**
  26878. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26879. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26880. * Default : `true`
  26881. */
  26882. /**
  26883. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26884. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26885. * Default : `true`
  26886. */
  26887. depthSortParticles: boolean;
  26888. /**
  26889. * Gets if the SPS is created as expandable at construction time.
  26890. * Default : `false`
  26891. */
  26892. readonly expandable: boolean;
  26893. /**
  26894. * Gets if the SPS supports the Multi Materials
  26895. */
  26896. readonly multimaterialEnabled: boolean;
  26897. /**
  26898. * Gets if the SPS uses the model materials for its own multimaterial.
  26899. */
  26900. readonly useModelMaterial: boolean;
  26901. /**
  26902. * The SPS used material array.
  26903. */
  26904. readonly materials: Material[];
  26905. /**
  26906. * Sets the SPS MultiMaterial from the passed materials.
  26907. * Note : the passed array is internally copied and not used then by reference.
  26908. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  26909. */
  26910. setMultiMaterial(materials: Material[]): void;
  26911. /**
  26912. * The SPS computed multimaterial object
  26913. */
  26914. multimaterial: MultiMaterial;
  26915. /**
  26916. * If the subMeshes must be updated on the next call to setParticles()
  26917. */
  26918. autoUpdateSubMeshes: boolean;
  26919. /**
  26920. * This function does nothing. It may be overwritten to set all the particle first values.
  26921. * The SPS doesn't call this function, you may have to call it by your own.
  26922. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26923. */
  26924. initParticles(): void;
  26925. /**
  26926. * This function does nothing. It may be overwritten to recycle a particle.
  26927. * The SPS doesn't call this function, you may have to call it by your own.
  26928. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26929. * @param particle The particle to recycle
  26930. * @returns the recycled particle
  26931. */
  26932. recycleParticle(particle: SolidParticle): SolidParticle;
  26933. /**
  26934. * Updates a particle : this function should be overwritten by the user.
  26935. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26936. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26937. * @example : just set a particle position or velocity and recycle conditions
  26938. * @param particle The particle to update
  26939. * @returns the updated particle
  26940. */
  26941. updateParticle(particle: SolidParticle): SolidParticle;
  26942. /**
  26943. * Updates a vertex of a particle : it can be overwritten by the user.
  26944. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26945. * @param particle the current particle
  26946. * @param vertex the current index of the current particle
  26947. * @param pt the index of the current vertex in the particle shape
  26948. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26949. * @example : just set a vertex particle position
  26950. * @returns the updated vertex
  26951. */
  26952. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26953. /**
  26954. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26955. * This does nothing and may be overwritten by the user.
  26956. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26957. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26958. * @param update the boolean update value actually passed to setParticles()
  26959. */
  26960. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26961. /**
  26962. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26963. * This will be passed three parameters.
  26964. * This does nothing and may be overwritten by the user.
  26965. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26966. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26967. * @param update the boolean update value actually passed to setParticles()
  26968. */
  26969. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26970. }
  26971. }
  26972. declare module BABYLON {
  26973. /**
  26974. * Represents one particle of a solid particle system.
  26975. */
  26976. export class SolidParticle {
  26977. /**
  26978. * particle global index
  26979. */
  26980. idx: number;
  26981. /**
  26982. * particle identifier
  26983. */
  26984. id: number;
  26985. /**
  26986. * The color of the particle
  26987. */
  26988. color: Nullable<Color4>;
  26989. /**
  26990. * The world space position of the particle.
  26991. */
  26992. position: Vector3;
  26993. /**
  26994. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26995. */
  26996. rotation: Vector3;
  26997. /**
  26998. * The world space rotation quaternion of the particle.
  26999. */
  27000. rotationQuaternion: Nullable<Quaternion>;
  27001. /**
  27002. * The scaling of the particle.
  27003. */
  27004. scaling: Vector3;
  27005. /**
  27006. * The uvs of the particle.
  27007. */
  27008. uvs: Vector4;
  27009. /**
  27010. * The current speed of the particle.
  27011. */
  27012. velocity: Vector3;
  27013. /**
  27014. * The pivot point in the particle local space.
  27015. */
  27016. pivot: Vector3;
  27017. /**
  27018. * Must the particle be translated from its pivot point in its local space ?
  27019. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27020. * Default : false
  27021. */
  27022. translateFromPivot: boolean;
  27023. /**
  27024. * Is the particle active or not ?
  27025. */
  27026. alive: boolean;
  27027. /**
  27028. * Is the particle visible or not ?
  27029. */
  27030. isVisible: boolean;
  27031. /**
  27032. * Index of this particle in the global "positions" array (Internal use)
  27033. * @hidden
  27034. */
  27035. _pos: number;
  27036. /**
  27037. * @hidden Index of this particle in the global "indices" array (Internal use)
  27038. */
  27039. _ind: number;
  27040. /**
  27041. * @hidden ModelShape of this particle (Internal use)
  27042. */
  27043. _model: ModelShape;
  27044. /**
  27045. * ModelShape id of this particle
  27046. */
  27047. shapeId: number;
  27048. /**
  27049. * Index of the particle in its shape id
  27050. */
  27051. idxInShape: number;
  27052. /**
  27053. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27054. */
  27055. _modelBoundingInfo: BoundingInfo;
  27056. /**
  27057. * @hidden Particle BoundingInfo object (Internal use)
  27058. */
  27059. _boundingInfo: BoundingInfo;
  27060. /**
  27061. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27062. */
  27063. _sps: SolidParticleSystem;
  27064. /**
  27065. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27066. */
  27067. _stillInvisible: boolean;
  27068. /**
  27069. * @hidden Last computed particle rotation matrix
  27070. */
  27071. _rotationMatrix: number[];
  27072. /**
  27073. * Parent particle Id, if any.
  27074. * Default null.
  27075. */
  27076. parentId: Nullable<number>;
  27077. /**
  27078. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27079. */
  27080. materialIndex: Nullable<number>;
  27081. /**
  27082. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27083. * The possible values are :
  27084. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27085. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27086. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27087. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27088. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27089. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27090. * */
  27091. cullingStrategy: number;
  27092. /**
  27093. * @hidden Internal global position in the SPS.
  27094. */
  27095. _globalPosition: Vector3;
  27096. /**
  27097. * Creates a Solid Particle object.
  27098. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27099. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27100. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27101. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27102. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27103. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27104. * @param shapeId (integer) is the model shape identifier in the SPS.
  27105. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27106. * @param sps defines the sps it is associated to
  27107. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27108. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27109. */
  27110. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27111. /**
  27112. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27113. * @param target the particle target
  27114. * @returns the current particle
  27115. */
  27116. copyToRef(target: SolidParticle): SolidParticle;
  27117. /**
  27118. * Legacy support, changed scale to scaling
  27119. */
  27120. /**
  27121. * Legacy support, changed scale to scaling
  27122. */
  27123. scale: Vector3;
  27124. /**
  27125. * Legacy support, changed quaternion to rotationQuaternion
  27126. */
  27127. /**
  27128. * Legacy support, changed quaternion to rotationQuaternion
  27129. */
  27130. quaternion: Nullable<Quaternion>;
  27131. /**
  27132. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27133. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27134. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27135. * @returns true if it intersects
  27136. */
  27137. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27138. /**
  27139. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27140. * A particle is in the frustum if its bounding box intersects the frustum
  27141. * @param frustumPlanes defines the frustum to test
  27142. * @returns true if the particle is in the frustum planes
  27143. */
  27144. isInFrustum(frustumPlanes: Plane[]): boolean;
  27145. /**
  27146. * get the rotation matrix of the particle
  27147. * @hidden
  27148. */
  27149. getRotationMatrix(m: Matrix): void;
  27150. }
  27151. /**
  27152. * Represents the shape of the model used by one particle of a solid particle system.
  27153. * SPS internal tool, don't use it manually.
  27154. */
  27155. export class ModelShape {
  27156. /**
  27157. * The shape id
  27158. * @hidden
  27159. */
  27160. shapeID: number;
  27161. /**
  27162. * flat array of model positions (internal use)
  27163. * @hidden
  27164. */
  27165. _shape: Vector3[];
  27166. /**
  27167. * flat array of model UVs (internal use)
  27168. * @hidden
  27169. */
  27170. _shapeUV: number[];
  27171. /**
  27172. * color array of the model
  27173. * @hidden
  27174. */
  27175. _shapeColors: number[];
  27176. /**
  27177. * indices array of the model
  27178. * @hidden
  27179. */
  27180. _indices: number[];
  27181. /**
  27182. * normals array of the model
  27183. * @hidden
  27184. */
  27185. _normals: number[];
  27186. /**
  27187. * length of the shape in the model indices array (internal use)
  27188. * @hidden
  27189. */
  27190. _indicesLength: number;
  27191. /**
  27192. * Custom position function (internal use)
  27193. * @hidden
  27194. */
  27195. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27196. /**
  27197. * Custom vertex function (internal use)
  27198. * @hidden
  27199. */
  27200. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27201. /**
  27202. * Model material (internal use)
  27203. * @hidden
  27204. */
  27205. _material: Nullable<Material>;
  27206. /**
  27207. * 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.
  27208. * SPS internal tool, don't use it manually.
  27209. * @hidden
  27210. */
  27211. 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>);
  27212. }
  27213. /**
  27214. * Represents a Depth Sorted Particle in the solid particle system.
  27215. * @hidden
  27216. */
  27217. export class DepthSortedParticle {
  27218. /**
  27219. * Index of the particle in the "indices" array
  27220. */
  27221. ind: number;
  27222. /**
  27223. * Length of the particle shape in the "indices" array
  27224. */
  27225. indicesLength: number;
  27226. /**
  27227. * Squared distance from the particle to the camera
  27228. */
  27229. sqDistance: number;
  27230. /**
  27231. * Material index when used with MultiMaterials
  27232. */
  27233. materialIndex: number;
  27234. /**
  27235. * Creates a new sorted particle
  27236. * @param materialIndex
  27237. */
  27238. constructor(ind: number, indLength: number, materialIndex: number);
  27239. }
  27240. }
  27241. declare module BABYLON {
  27242. /**
  27243. * @hidden
  27244. */
  27245. export class _MeshCollisionData {
  27246. _checkCollisions: boolean;
  27247. _collisionMask: number;
  27248. _collisionGroup: number;
  27249. _collider: Nullable<Collider>;
  27250. _oldPositionForCollisions: Vector3;
  27251. _diffPositionForCollisions: Vector3;
  27252. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27253. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27254. }
  27255. }
  27256. declare module BABYLON {
  27257. /** @hidden */
  27258. class _FacetDataStorage {
  27259. facetPositions: Vector3[];
  27260. facetNormals: Vector3[];
  27261. facetPartitioning: number[][];
  27262. facetNb: number;
  27263. partitioningSubdivisions: number;
  27264. partitioningBBoxRatio: number;
  27265. facetDataEnabled: boolean;
  27266. facetParameters: any;
  27267. bbSize: Vector3;
  27268. subDiv: {
  27269. max: number;
  27270. X: number;
  27271. Y: number;
  27272. Z: number;
  27273. };
  27274. facetDepthSort: boolean;
  27275. facetDepthSortEnabled: boolean;
  27276. depthSortedIndices: IndicesArray;
  27277. depthSortedFacets: {
  27278. ind: number;
  27279. sqDistance: number;
  27280. }[];
  27281. facetDepthSortFunction: (f1: {
  27282. ind: number;
  27283. sqDistance: number;
  27284. }, f2: {
  27285. ind: number;
  27286. sqDistance: number;
  27287. }) => number;
  27288. facetDepthSortFrom: Vector3;
  27289. facetDepthSortOrigin: Vector3;
  27290. invertedMatrix: Matrix;
  27291. }
  27292. /**
  27293. * @hidden
  27294. **/
  27295. class _InternalAbstractMeshDataInfo {
  27296. _hasVertexAlpha: boolean;
  27297. _useVertexColors: boolean;
  27298. _numBoneInfluencers: number;
  27299. _applyFog: boolean;
  27300. _receiveShadows: boolean;
  27301. _facetData: _FacetDataStorage;
  27302. _visibility: number;
  27303. _skeleton: Nullable<Skeleton>;
  27304. _layerMask: number;
  27305. _computeBonesUsingShaders: boolean;
  27306. _isActive: boolean;
  27307. _onlyForInstances: boolean;
  27308. _isActiveIntermediate: boolean;
  27309. _onlyForInstancesIntermediate: boolean;
  27310. _actAsRegularMesh: boolean;
  27311. }
  27312. /**
  27313. * Class used to store all common mesh properties
  27314. */
  27315. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27316. /** No occlusion */
  27317. static OCCLUSION_TYPE_NONE: number;
  27318. /** Occlusion set to optimisitic */
  27319. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27320. /** Occlusion set to strict */
  27321. static OCCLUSION_TYPE_STRICT: number;
  27322. /** Use an accurante occlusion algorithm */
  27323. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27324. /** Use a conservative occlusion algorithm */
  27325. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27326. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27327. * Test order :
  27328. * Is the bounding sphere outside the frustum ?
  27329. * If not, are the bounding box vertices outside the frustum ?
  27330. * It not, then the cullable object is in the frustum.
  27331. */
  27332. static readonly CULLINGSTRATEGY_STANDARD: number;
  27333. /** Culling strategy : Bounding Sphere Only.
  27334. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27335. * It's also less accurate than the standard because some not visible objects can still be selected.
  27336. * Test : is the bounding sphere outside the frustum ?
  27337. * If not, then the cullable object is in the frustum.
  27338. */
  27339. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27340. /** Culling strategy : Optimistic Inclusion.
  27341. * This in an inclusion test first, then the standard exclusion test.
  27342. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27343. * 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.
  27344. * Anyway, it's as accurate as the standard strategy.
  27345. * Test :
  27346. * Is the cullable object bounding sphere center in the frustum ?
  27347. * If not, apply the default culling strategy.
  27348. */
  27349. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27350. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27351. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27352. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27353. * 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.
  27354. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27355. * Test :
  27356. * Is the cullable object bounding sphere center in the frustum ?
  27357. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27358. */
  27359. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27360. /**
  27361. * No billboard
  27362. */
  27363. static readonly BILLBOARDMODE_NONE: number;
  27364. /** Billboard on X axis */
  27365. static readonly BILLBOARDMODE_X: number;
  27366. /** Billboard on Y axis */
  27367. static readonly BILLBOARDMODE_Y: number;
  27368. /** Billboard on Z axis */
  27369. static readonly BILLBOARDMODE_Z: number;
  27370. /** Billboard on all axes */
  27371. static readonly BILLBOARDMODE_ALL: number;
  27372. /** Billboard on using position instead of orientation */
  27373. static readonly BILLBOARDMODE_USE_POSITION: number;
  27374. /** @hidden */
  27375. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27376. /**
  27377. * The culling strategy to use to check whether the mesh must be rendered or not.
  27378. * This value can be changed at any time and will be used on the next render mesh selection.
  27379. * The possible values are :
  27380. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27381. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27382. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27383. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27384. * Please read each static variable documentation to get details about the culling process.
  27385. * */
  27386. cullingStrategy: number;
  27387. /**
  27388. * Gets the number of facets in the mesh
  27389. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27390. */
  27391. readonly facetNb: number;
  27392. /**
  27393. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27394. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27395. */
  27396. partitioningSubdivisions: number;
  27397. /**
  27398. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27399. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27400. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27401. */
  27402. partitioningBBoxRatio: number;
  27403. /**
  27404. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27405. * Works only for updatable meshes.
  27406. * Doesn't work with multi-materials
  27407. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27408. */
  27409. mustDepthSortFacets: boolean;
  27410. /**
  27411. * The location (Vector3) where the facet depth sort must be computed from.
  27412. * By default, the active camera position.
  27413. * Used only when facet depth sort is enabled
  27414. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27415. */
  27416. facetDepthSortFrom: Vector3;
  27417. /**
  27418. * gets a boolean indicating if facetData is enabled
  27419. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27420. */
  27421. readonly isFacetDataEnabled: boolean;
  27422. /** @hidden */
  27423. _updateNonUniformScalingState(value: boolean): boolean;
  27424. /**
  27425. * An event triggered when this mesh collides with another one
  27426. */
  27427. onCollideObservable: Observable<AbstractMesh>;
  27428. /** Set a function to call when this mesh collides with another one */
  27429. onCollide: () => void;
  27430. /**
  27431. * An event triggered when the collision's position changes
  27432. */
  27433. onCollisionPositionChangeObservable: Observable<Vector3>;
  27434. /** Set a function to call when the collision's position changes */
  27435. onCollisionPositionChange: () => void;
  27436. /**
  27437. * An event triggered when material is changed
  27438. */
  27439. onMaterialChangedObservable: Observable<AbstractMesh>;
  27440. /**
  27441. * Gets or sets the orientation for POV movement & rotation
  27442. */
  27443. definedFacingForward: boolean;
  27444. /** @hidden */
  27445. _occlusionQuery: Nullable<WebGLQuery>;
  27446. /** @hidden */
  27447. _renderingGroup: Nullable<RenderingGroup>;
  27448. /**
  27449. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27450. */
  27451. /**
  27452. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27453. */
  27454. visibility: number;
  27455. /** Gets or sets the alpha index used to sort transparent meshes
  27456. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27457. */
  27458. alphaIndex: number;
  27459. /**
  27460. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27461. */
  27462. isVisible: boolean;
  27463. /**
  27464. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27465. */
  27466. isPickable: boolean;
  27467. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27468. showSubMeshesBoundingBox: boolean;
  27469. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27470. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27471. */
  27472. isBlocker: boolean;
  27473. /**
  27474. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27475. */
  27476. enablePointerMoveEvents: boolean;
  27477. /**
  27478. * Specifies the rendering group id for this mesh (0 by default)
  27479. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27480. */
  27481. renderingGroupId: number;
  27482. private _material;
  27483. /** Gets or sets current material */
  27484. material: Nullable<Material>;
  27485. /**
  27486. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27487. * @see http://doc.babylonjs.com/babylon101/shadows
  27488. */
  27489. receiveShadows: boolean;
  27490. /** Defines color to use when rendering outline */
  27491. outlineColor: Color3;
  27492. /** Define width to use when rendering outline */
  27493. outlineWidth: number;
  27494. /** Defines color to use when rendering overlay */
  27495. overlayColor: Color3;
  27496. /** Defines alpha to use when rendering overlay */
  27497. overlayAlpha: number;
  27498. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27499. hasVertexAlpha: boolean;
  27500. /** 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) */
  27501. useVertexColors: boolean;
  27502. /**
  27503. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27504. */
  27505. computeBonesUsingShaders: boolean;
  27506. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27507. numBoneInfluencers: number;
  27508. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27509. applyFog: boolean;
  27510. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27511. useOctreeForRenderingSelection: boolean;
  27512. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27513. useOctreeForPicking: boolean;
  27514. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27515. useOctreeForCollisions: boolean;
  27516. /**
  27517. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27518. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27519. */
  27520. layerMask: number;
  27521. /**
  27522. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27523. */
  27524. alwaysSelectAsActiveMesh: boolean;
  27525. /**
  27526. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27527. */
  27528. doNotSyncBoundingInfo: boolean;
  27529. /**
  27530. * Gets or sets the current action manager
  27531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27532. */
  27533. actionManager: Nullable<AbstractActionManager>;
  27534. private _meshCollisionData;
  27535. /**
  27536. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27537. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27538. */
  27539. ellipsoid: Vector3;
  27540. /**
  27541. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27542. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27543. */
  27544. ellipsoidOffset: Vector3;
  27545. /**
  27546. * Gets or sets a collision mask used to mask collisions (default is -1).
  27547. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27548. */
  27549. collisionMask: number;
  27550. /**
  27551. * Gets or sets the current collision group mask (-1 by default).
  27552. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27553. */
  27554. collisionGroup: number;
  27555. /**
  27556. * Defines edge width used when edgesRenderer is enabled
  27557. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27558. */
  27559. edgesWidth: number;
  27560. /**
  27561. * Defines edge color used when edgesRenderer is enabled
  27562. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27563. */
  27564. edgesColor: Color4;
  27565. /** @hidden */
  27566. _edgesRenderer: Nullable<IEdgesRenderer>;
  27567. /** @hidden */
  27568. _masterMesh: Nullable<AbstractMesh>;
  27569. /** @hidden */
  27570. _boundingInfo: Nullable<BoundingInfo>;
  27571. /** @hidden */
  27572. _renderId: number;
  27573. /**
  27574. * Gets or sets the list of subMeshes
  27575. * @see http://doc.babylonjs.com/how_to/multi_materials
  27576. */
  27577. subMeshes: SubMesh[];
  27578. /** @hidden */
  27579. _intersectionsInProgress: AbstractMesh[];
  27580. /** @hidden */
  27581. _unIndexed: boolean;
  27582. /** @hidden */
  27583. _lightSources: Light[];
  27584. /** Gets the list of lights affecting that mesh */
  27585. readonly lightSources: Light[];
  27586. /** @hidden */
  27587. readonly _positions: Nullable<Vector3[]>;
  27588. /** @hidden */
  27589. _waitingData: {
  27590. lods: Nullable<any>;
  27591. actions: Nullable<any>;
  27592. freezeWorldMatrix: Nullable<boolean>;
  27593. };
  27594. /** @hidden */
  27595. _bonesTransformMatrices: Nullable<Float32Array>;
  27596. /** @hidden */
  27597. _transformMatrixTexture: Nullable<RawTexture>;
  27598. /**
  27599. * Gets or sets a skeleton to apply skining transformations
  27600. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27601. */
  27602. skeleton: Nullable<Skeleton>;
  27603. /**
  27604. * An event triggered when the mesh is rebuilt.
  27605. */
  27606. onRebuildObservable: Observable<AbstractMesh>;
  27607. /**
  27608. * Creates a new AbstractMesh
  27609. * @param name defines the name of the mesh
  27610. * @param scene defines the hosting scene
  27611. */
  27612. constructor(name: string, scene?: Nullable<Scene>);
  27613. /**
  27614. * Returns the string "AbstractMesh"
  27615. * @returns "AbstractMesh"
  27616. */
  27617. getClassName(): string;
  27618. /**
  27619. * Gets a string representation of the current mesh
  27620. * @param fullDetails defines a boolean indicating if full details must be included
  27621. * @returns a string representation of the current mesh
  27622. */
  27623. toString(fullDetails?: boolean): string;
  27624. /**
  27625. * @hidden
  27626. */
  27627. protected _getEffectiveParent(): Nullable<Node>;
  27628. /** @hidden */
  27629. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27630. /** @hidden */
  27631. _rebuild(): void;
  27632. /** @hidden */
  27633. _resyncLightSources(): void;
  27634. /** @hidden */
  27635. _resyncLightSource(light: Light): void;
  27636. /** @hidden */
  27637. _unBindEffect(): void;
  27638. /** @hidden */
  27639. _removeLightSource(light: Light, dispose: boolean): void;
  27640. private _markSubMeshesAsDirty;
  27641. /** @hidden */
  27642. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27643. /** @hidden */
  27644. _markSubMeshesAsAttributesDirty(): void;
  27645. /** @hidden */
  27646. _markSubMeshesAsMiscDirty(): void;
  27647. /**
  27648. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27649. */
  27650. scaling: Vector3;
  27651. /**
  27652. * Returns true if the mesh is blocked. Implemented by child classes
  27653. */
  27654. readonly isBlocked: boolean;
  27655. /**
  27656. * Returns the mesh itself by default. Implemented by child classes
  27657. * @param camera defines the camera to use to pick the right LOD level
  27658. * @returns the currentAbstractMesh
  27659. */
  27660. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27661. /**
  27662. * Returns 0 by default. Implemented by child classes
  27663. * @returns an integer
  27664. */
  27665. getTotalVertices(): number;
  27666. /**
  27667. * Returns a positive integer : the total number of indices in this mesh geometry.
  27668. * @returns the numner of indices or zero if the mesh has no geometry.
  27669. */
  27670. getTotalIndices(): number;
  27671. /**
  27672. * Returns null by default. Implemented by child classes
  27673. * @returns null
  27674. */
  27675. getIndices(): Nullable<IndicesArray>;
  27676. /**
  27677. * Returns the array of the requested vertex data kind. Implemented by child classes
  27678. * @param kind defines the vertex data kind to use
  27679. * @returns null
  27680. */
  27681. getVerticesData(kind: string): Nullable<FloatArray>;
  27682. /**
  27683. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27684. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27685. * Note that a new underlying VertexBuffer object is created each call.
  27686. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27687. * @param kind defines vertex data kind:
  27688. * * VertexBuffer.PositionKind
  27689. * * VertexBuffer.UVKind
  27690. * * VertexBuffer.UV2Kind
  27691. * * VertexBuffer.UV3Kind
  27692. * * VertexBuffer.UV4Kind
  27693. * * VertexBuffer.UV5Kind
  27694. * * VertexBuffer.UV6Kind
  27695. * * VertexBuffer.ColorKind
  27696. * * VertexBuffer.MatricesIndicesKind
  27697. * * VertexBuffer.MatricesIndicesExtraKind
  27698. * * VertexBuffer.MatricesWeightsKind
  27699. * * VertexBuffer.MatricesWeightsExtraKind
  27700. * @param data defines the data source
  27701. * @param updatable defines if the data must be flagged as updatable (or static)
  27702. * @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
  27703. * @returns the current mesh
  27704. */
  27705. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27706. /**
  27707. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27708. * If the mesh has no geometry, it is simply returned as it is.
  27709. * @param kind defines vertex data kind:
  27710. * * VertexBuffer.PositionKind
  27711. * * VertexBuffer.UVKind
  27712. * * VertexBuffer.UV2Kind
  27713. * * VertexBuffer.UV3Kind
  27714. * * VertexBuffer.UV4Kind
  27715. * * VertexBuffer.UV5Kind
  27716. * * VertexBuffer.UV6Kind
  27717. * * VertexBuffer.ColorKind
  27718. * * VertexBuffer.MatricesIndicesKind
  27719. * * VertexBuffer.MatricesIndicesExtraKind
  27720. * * VertexBuffer.MatricesWeightsKind
  27721. * * VertexBuffer.MatricesWeightsExtraKind
  27722. * @param data defines the data source
  27723. * @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
  27724. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27725. * @returns the current mesh
  27726. */
  27727. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27728. /**
  27729. * Sets the mesh indices,
  27730. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27731. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27732. * @param totalVertices Defines the total number of vertices
  27733. * @returns the current mesh
  27734. */
  27735. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27736. /**
  27737. * Gets a boolean indicating if specific vertex data is present
  27738. * @param kind defines the vertex data kind to use
  27739. * @returns true is data kind is present
  27740. */
  27741. isVerticesDataPresent(kind: string): boolean;
  27742. /**
  27743. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27744. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27745. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27746. * @returns a BoundingInfo
  27747. */
  27748. getBoundingInfo(): BoundingInfo;
  27749. /**
  27750. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27751. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27752. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27753. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27754. * @returns the current mesh
  27755. */
  27756. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27757. /**
  27758. * Overwrite the current bounding info
  27759. * @param boundingInfo defines the new bounding info
  27760. * @returns the current mesh
  27761. */
  27762. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27763. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27764. readonly useBones: boolean;
  27765. /** @hidden */
  27766. _preActivate(): void;
  27767. /** @hidden */
  27768. _preActivateForIntermediateRendering(renderId: number): void;
  27769. /** @hidden */
  27770. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27771. /** @hidden */
  27772. _postActivate(): void;
  27773. /** @hidden */
  27774. _freeze(): void;
  27775. /** @hidden */
  27776. _unFreeze(): void;
  27777. /**
  27778. * Gets the current world matrix
  27779. * @returns a Matrix
  27780. */
  27781. getWorldMatrix(): Matrix;
  27782. /** @hidden */
  27783. _getWorldMatrixDeterminant(): number;
  27784. /**
  27785. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27786. */
  27787. readonly isAnInstance: boolean;
  27788. /**
  27789. * Gets a boolean indicating if this mesh has instances
  27790. */
  27791. readonly hasInstances: boolean;
  27792. /**
  27793. * Perform relative position change from the point of view of behind the front of the mesh.
  27794. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27795. * Supports definition of mesh facing forward or backward
  27796. * @param amountRight defines the distance on the right axis
  27797. * @param amountUp defines the distance on the up axis
  27798. * @param amountForward defines the distance on the forward axis
  27799. * @returns the current mesh
  27800. */
  27801. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27802. /**
  27803. * Calculate relative position change from the point of view of behind the front of the mesh.
  27804. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27805. * Supports definition of mesh facing forward or backward
  27806. * @param amountRight defines the distance on the right axis
  27807. * @param amountUp defines the distance on the up axis
  27808. * @param amountForward defines the distance on the forward axis
  27809. * @returns the new displacement vector
  27810. */
  27811. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27812. /**
  27813. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27814. * Supports definition of mesh facing forward or backward
  27815. * @param flipBack defines the flip
  27816. * @param twirlClockwise defines the twirl
  27817. * @param tiltRight defines the tilt
  27818. * @returns the current mesh
  27819. */
  27820. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27821. /**
  27822. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27823. * Supports definition of mesh facing forward or backward.
  27824. * @param flipBack defines the flip
  27825. * @param twirlClockwise defines the twirl
  27826. * @param tiltRight defines the tilt
  27827. * @returns the new rotation vector
  27828. */
  27829. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27830. /**
  27831. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27832. * This means the mesh underlying bounding box and sphere are recomputed.
  27833. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27834. * @returns the current mesh
  27835. */
  27836. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27837. /** @hidden */
  27838. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27839. /** @hidden */
  27840. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27841. /** @hidden */
  27842. _updateBoundingInfo(): AbstractMesh;
  27843. /** @hidden */
  27844. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27845. /** @hidden */
  27846. protected _afterComputeWorldMatrix(): void;
  27847. /** @hidden */
  27848. readonly _effectiveMesh: AbstractMesh;
  27849. /**
  27850. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27851. * A mesh is in the frustum if its bounding box intersects the frustum
  27852. * @param frustumPlanes defines the frustum to test
  27853. * @returns true if the mesh is in the frustum planes
  27854. */
  27855. isInFrustum(frustumPlanes: Plane[]): boolean;
  27856. /**
  27857. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27858. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27859. * @param frustumPlanes defines the frustum to test
  27860. * @returns true if the mesh is completely in the frustum planes
  27861. */
  27862. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27863. /**
  27864. * True if the mesh intersects another mesh or a SolidParticle object
  27865. * @param mesh defines a target mesh or SolidParticle to test
  27866. * @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)
  27867. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27868. * @returns true if there is an intersection
  27869. */
  27870. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27871. /**
  27872. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27873. * @param point defines the point to test
  27874. * @returns true if there is an intersection
  27875. */
  27876. intersectsPoint(point: Vector3): boolean;
  27877. /**
  27878. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27879. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27880. */
  27881. checkCollisions: boolean;
  27882. /**
  27883. * Gets Collider object used to compute collisions (not physics)
  27884. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27885. */
  27886. readonly collider: Nullable<Collider>;
  27887. /**
  27888. * Move the mesh using collision engine
  27889. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27890. * @param displacement defines the requested displacement vector
  27891. * @returns the current mesh
  27892. */
  27893. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27894. private _onCollisionPositionChange;
  27895. /** @hidden */
  27896. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27897. /** @hidden */
  27898. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27899. /** @hidden */
  27900. _checkCollision(collider: Collider): AbstractMesh;
  27901. /** @hidden */
  27902. _generatePointsArray(): boolean;
  27903. /**
  27904. * Checks if the passed Ray intersects with the mesh
  27905. * @param ray defines the ray to use
  27906. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27907. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27908. * @returns the picking info
  27909. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27910. */
  27911. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27912. /**
  27913. * Clones the current mesh
  27914. * @param name defines the mesh name
  27915. * @param newParent defines the new mesh parent
  27916. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27917. * @returns the new mesh
  27918. */
  27919. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27920. /**
  27921. * Disposes all the submeshes of the current meshnp
  27922. * @returns the current mesh
  27923. */
  27924. releaseSubMeshes(): AbstractMesh;
  27925. /**
  27926. * Releases resources associated with this abstract mesh.
  27927. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27928. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27929. */
  27930. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27931. /**
  27932. * Adds the passed mesh as a child to the current mesh
  27933. * @param mesh defines the child mesh
  27934. * @returns the current mesh
  27935. */
  27936. addChild(mesh: AbstractMesh): AbstractMesh;
  27937. /**
  27938. * Removes the passed mesh from the current mesh children list
  27939. * @param mesh defines the child mesh
  27940. * @returns the current mesh
  27941. */
  27942. removeChild(mesh: AbstractMesh): AbstractMesh;
  27943. /** @hidden */
  27944. private _initFacetData;
  27945. /**
  27946. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27947. * This method can be called within the render loop.
  27948. * 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
  27949. * @returns the current mesh
  27950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27951. */
  27952. updateFacetData(): AbstractMesh;
  27953. /**
  27954. * Returns the facetLocalNormals array.
  27955. * The normals are expressed in the mesh local spac
  27956. * @returns an array of Vector3
  27957. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27958. */
  27959. getFacetLocalNormals(): Vector3[];
  27960. /**
  27961. * Returns the facetLocalPositions array.
  27962. * The facet positions are expressed in the mesh local space
  27963. * @returns an array of Vector3
  27964. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27965. */
  27966. getFacetLocalPositions(): Vector3[];
  27967. /**
  27968. * Returns the facetLocalPartioning array
  27969. * @returns an array of array of numbers
  27970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27971. */
  27972. getFacetLocalPartitioning(): number[][];
  27973. /**
  27974. * Returns the i-th facet position in the world system.
  27975. * This method allocates a new Vector3 per call
  27976. * @param i defines the facet index
  27977. * @returns a new Vector3
  27978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27979. */
  27980. getFacetPosition(i: number): Vector3;
  27981. /**
  27982. * Sets the reference Vector3 with the i-th facet position in the world system
  27983. * @param i defines the facet index
  27984. * @param ref defines the target vector
  27985. * @returns the current mesh
  27986. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27987. */
  27988. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27989. /**
  27990. * Returns the i-th facet normal in the world system.
  27991. * This method allocates a new Vector3 per call
  27992. * @param i defines the facet index
  27993. * @returns a new Vector3
  27994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27995. */
  27996. getFacetNormal(i: number): Vector3;
  27997. /**
  27998. * Sets the reference Vector3 with the i-th facet normal in the world system
  27999. * @param i defines the facet index
  28000. * @param ref defines the target vector
  28001. * @returns the current mesh
  28002. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28003. */
  28004. getFacetNormalToRef(i: number, ref: Vector3): this;
  28005. /**
  28006. * 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)
  28007. * @param x defines x coordinate
  28008. * @param y defines y coordinate
  28009. * @param z defines z coordinate
  28010. * @returns the array of facet indexes
  28011. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28012. */
  28013. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28014. /**
  28015. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28016. * @param projected sets as the (x,y,z) world projection on the facet
  28017. * @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
  28018. * @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
  28019. * @param x defines x coordinate
  28020. * @param y defines y coordinate
  28021. * @param z defines z coordinate
  28022. * @returns the face index if found (or null instead)
  28023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28024. */
  28025. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28026. /**
  28027. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28028. * @param projected sets as the (x,y,z) local projection on the facet
  28029. * @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
  28030. * @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
  28031. * @param x defines x coordinate
  28032. * @param y defines y coordinate
  28033. * @param z defines z coordinate
  28034. * @returns the face index if found (or null instead)
  28035. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28036. */
  28037. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28038. /**
  28039. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28040. * @returns the parameters
  28041. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28042. */
  28043. getFacetDataParameters(): any;
  28044. /**
  28045. * Disables the feature FacetData and frees the related memory
  28046. * @returns the current mesh
  28047. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28048. */
  28049. disableFacetData(): AbstractMesh;
  28050. /**
  28051. * Updates the AbstractMesh indices array
  28052. * @param indices defines the data source
  28053. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28054. * @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)
  28055. * @returns the current mesh
  28056. */
  28057. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28058. /**
  28059. * Creates new normals data for the mesh
  28060. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28061. * @returns the current mesh
  28062. */
  28063. createNormals(updatable: boolean): AbstractMesh;
  28064. /**
  28065. * Align the mesh with a normal
  28066. * @param normal defines the normal to use
  28067. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28068. * @returns the current mesh
  28069. */
  28070. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28071. /** @hidden */
  28072. _checkOcclusionQuery(): boolean;
  28073. /**
  28074. * Disables the mesh edge rendering mode
  28075. * @returns the currentAbstractMesh
  28076. */
  28077. disableEdgesRendering(): AbstractMesh;
  28078. /**
  28079. * Enables the edge rendering mode on the mesh.
  28080. * This mode makes the mesh edges visible
  28081. * @param epsilon defines the maximal distance between two angles to detect a face
  28082. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28083. * @returns the currentAbstractMesh
  28084. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28085. */
  28086. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28087. }
  28088. }
  28089. declare module BABYLON {
  28090. /**
  28091. * Interface used to define ActionEvent
  28092. */
  28093. export interface IActionEvent {
  28094. /** The mesh or sprite that triggered the action */
  28095. source: any;
  28096. /** The X mouse cursor position at the time of the event */
  28097. pointerX: number;
  28098. /** The Y mouse cursor position at the time of the event */
  28099. pointerY: number;
  28100. /** The mesh that is currently pointed at (can be null) */
  28101. meshUnderPointer: Nullable<AbstractMesh>;
  28102. /** the original (browser) event that triggered the ActionEvent */
  28103. sourceEvent?: any;
  28104. /** additional data for the event */
  28105. additionalData?: any;
  28106. }
  28107. /**
  28108. * ActionEvent is the event being sent when an action is triggered.
  28109. */
  28110. export class ActionEvent implements IActionEvent {
  28111. /** The mesh or sprite that triggered the action */
  28112. source: any;
  28113. /** The X mouse cursor position at the time of the event */
  28114. pointerX: number;
  28115. /** The Y mouse cursor position at the time of the event */
  28116. pointerY: number;
  28117. /** The mesh that is currently pointed at (can be null) */
  28118. meshUnderPointer: Nullable<AbstractMesh>;
  28119. /** the original (browser) event that triggered the ActionEvent */
  28120. sourceEvent?: any;
  28121. /** additional data for the event */
  28122. additionalData?: any;
  28123. /**
  28124. * Creates a new ActionEvent
  28125. * @param source The mesh or sprite that triggered the action
  28126. * @param pointerX The X mouse cursor position at the time of the event
  28127. * @param pointerY The Y mouse cursor position at the time of the event
  28128. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28129. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28130. * @param additionalData additional data for the event
  28131. */
  28132. constructor(
  28133. /** The mesh or sprite that triggered the action */
  28134. source: any,
  28135. /** The X mouse cursor position at the time of the event */
  28136. pointerX: number,
  28137. /** The Y mouse cursor position at the time of the event */
  28138. pointerY: number,
  28139. /** The mesh that is currently pointed at (can be null) */
  28140. meshUnderPointer: Nullable<AbstractMesh>,
  28141. /** the original (browser) event that triggered the ActionEvent */
  28142. sourceEvent?: any,
  28143. /** additional data for the event */
  28144. additionalData?: any);
  28145. /**
  28146. * Helper function to auto-create an ActionEvent from a source mesh.
  28147. * @param source The source mesh that triggered the event
  28148. * @param evt The original (browser) event
  28149. * @param additionalData additional data for the event
  28150. * @returns the new ActionEvent
  28151. */
  28152. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28153. /**
  28154. * Helper function to auto-create an ActionEvent from a source sprite
  28155. * @param source The source sprite that triggered the event
  28156. * @param scene Scene associated with the sprite
  28157. * @param evt The original (browser) event
  28158. * @param additionalData additional data for the event
  28159. * @returns the new ActionEvent
  28160. */
  28161. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28162. /**
  28163. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28164. * @param scene the scene where the event occurred
  28165. * @param evt The original (browser) event
  28166. * @returns the new ActionEvent
  28167. */
  28168. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28169. /**
  28170. * Helper function to auto-create an ActionEvent from a primitive
  28171. * @param prim defines the target primitive
  28172. * @param pointerPos defines the pointer position
  28173. * @param evt The original (browser) event
  28174. * @param additionalData additional data for the event
  28175. * @returns the new ActionEvent
  28176. */
  28177. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28178. }
  28179. }
  28180. declare module BABYLON {
  28181. /**
  28182. * Abstract class used to decouple action Manager from scene and meshes.
  28183. * Do not instantiate.
  28184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28185. */
  28186. export abstract class AbstractActionManager implements IDisposable {
  28187. /** Gets the list of active triggers */
  28188. static Triggers: {
  28189. [key: string]: number;
  28190. };
  28191. /** Gets the cursor to use when hovering items */
  28192. hoverCursor: string;
  28193. /** Gets the list of actions */
  28194. actions: IAction[];
  28195. /**
  28196. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28197. */
  28198. isRecursive: boolean;
  28199. /**
  28200. * Releases all associated resources
  28201. */
  28202. abstract dispose(): void;
  28203. /**
  28204. * Does this action manager has pointer triggers
  28205. */
  28206. abstract readonly hasPointerTriggers: boolean;
  28207. /**
  28208. * Does this action manager has pick triggers
  28209. */
  28210. abstract readonly hasPickTriggers: boolean;
  28211. /**
  28212. * Process a specific trigger
  28213. * @param trigger defines the trigger to process
  28214. * @param evt defines the event details to be processed
  28215. */
  28216. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28217. /**
  28218. * Does this action manager handles actions of any of the given triggers
  28219. * @param triggers defines the triggers to be tested
  28220. * @return a boolean indicating whether one (or more) of the triggers is handled
  28221. */
  28222. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28223. /**
  28224. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28225. * speed.
  28226. * @param triggerA defines the trigger to be tested
  28227. * @param triggerB defines the trigger to be tested
  28228. * @return a boolean indicating whether one (or more) of the triggers is handled
  28229. */
  28230. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28231. /**
  28232. * Does this action manager handles actions of a given trigger
  28233. * @param trigger defines the trigger to be tested
  28234. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28235. * @return whether the trigger is handled
  28236. */
  28237. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28238. /**
  28239. * Serialize this manager to a JSON object
  28240. * @param name defines the property name to store this manager
  28241. * @returns a JSON representation of this manager
  28242. */
  28243. abstract serialize(name: string): any;
  28244. /**
  28245. * Registers an action to this action manager
  28246. * @param action defines the action to be registered
  28247. * @return the action amended (prepared) after registration
  28248. */
  28249. abstract registerAction(action: IAction): Nullable<IAction>;
  28250. /**
  28251. * Unregisters an action to this action manager
  28252. * @param action defines the action to be unregistered
  28253. * @return a boolean indicating whether the action has been unregistered
  28254. */
  28255. abstract unregisterAction(action: IAction): Boolean;
  28256. /**
  28257. * Does exist one action manager with at least one trigger
  28258. **/
  28259. static readonly HasTriggers: boolean;
  28260. /**
  28261. * Does exist one action manager with at least one pick trigger
  28262. **/
  28263. static readonly HasPickTriggers: boolean;
  28264. /**
  28265. * Does exist one action manager that handles actions of a given trigger
  28266. * @param trigger defines the trigger to be tested
  28267. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28268. **/
  28269. static HasSpecificTrigger(trigger: number): boolean;
  28270. }
  28271. }
  28272. declare module BABYLON {
  28273. /**
  28274. * Defines how a node can be built from a string name.
  28275. */
  28276. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28277. /**
  28278. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28279. */
  28280. export class Node implements IBehaviorAware<Node> {
  28281. /** @hidden */
  28282. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28283. private static _NodeConstructors;
  28284. /**
  28285. * Add a new node constructor
  28286. * @param type defines the type name of the node to construct
  28287. * @param constructorFunc defines the constructor function
  28288. */
  28289. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28290. /**
  28291. * Returns a node constructor based on type name
  28292. * @param type defines the type name
  28293. * @param name defines the new node name
  28294. * @param scene defines the hosting scene
  28295. * @param options defines optional options to transmit to constructors
  28296. * @returns the new constructor or null
  28297. */
  28298. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28299. /**
  28300. * Gets or sets the name of the node
  28301. */
  28302. name: string;
  28303. /**
  28304. * Gets or sets the id of the node
  28305. */
  28306. id: string;
  28307. /**
  28308. * Gets or sets the unique id of the node
  28309. */
  28310. uniqueId: number;
  28311. /**
  28312. * Gets or sets a string used to store user defined state for the node
  28313. */
  28314. state: string;
  28315. /**
  28316. * Gets or sets an object used to store user defined information for the node
  28317. */
  28318. metadata: any;
  28319. /**
  28320. * For internal use only. Please do not use.
  28321. */
  28322. reservedDataStore: any;
  28323. /**
  28324. * List of inspectable custom properties (used by the Inspector)
  28325. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28326. */
  28327. inspectableCustomProperties: IInspectable[];
  28328. private _doNotSerialize;
  28329. /**
  28330. * Gets or sets a boolean used to define if the node must be serialized
  28331. */
  28332. doNotSerialize: boolean;
  28333. /** @hidden */
  28334. _isDisposed: boolean;
  28335. /**
  28336. * Gets a list of Animations associated with the node
  28337. */
  28338. animations: Animation[];
  28339. protected _ranges: {
  28340. [name: string]: Nullable<AnimationRange>;
  28341. };
  28342. /**
  28343. * Callback raised when the node is ready to be used
  28344. */
  28345. onReady: Nullable<(node: Node) => void>;
  28346. private _isEnabled;
  28347. private _isParentEnabled;
  28348. private _isReady;
  28349. /** @hidden */
  28350. _currentRenderId: number;
  28351. private _parentUpdateId;
  28352. /** @hidden */
  28353. _childUpdateId: number;
  28354. /** @hidden */
  28355. _waitingParentId: Nullable<string>;
  28356. /** @hidden */
  28357. _scene: Scene;
  28358. /** @hidden */
  28359. _cache: any;
  28360. private _parentNode;
  28361. private _children;
  28362. /** @hidden */
  28363. _worldMatrix: Matrix;
  28364. /** @hidden */
  28365. _worldMatrixDeterminant: number;
  28366. /** @hidden */
  28367. _worldMatrixDeterminantIsDirty: boolean;
  28368. /** @hidden */
  28369. private _sceneRootNodesIndex;
  28370. /**
  28371. * Gets a boolean indicating if the node has been disposed
  28372. * @returns true if the node was disposed
  28373. */
  28374. isDisposed(): boolean;
  28375. /**
  28376. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28377. * @see https://doc.babylonjs.com/how_to/parenting
  28378. */
  28379. parent: Nullable<Node>;
  28380. /** @hidden */
  28381. _addToSceneRootNodes(): void;
  28382. /** @hidden */
  28383. _removeFromSceneRootNodes(): void;
  28384. private _animationPropertiesOverride;
  28385. /**
  28386. * Gets or sets the animation properties override
  28387. */
  28388. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28389. /**
  28390. * Gets a string idenfifying the name of the class
  28391. * @returns "Node" string
  28392. */
  28393. getClassName(): string;
  28394. /** @hidden */
  28395. readonly _isNode: boolean;
  28396. /**
  28397. * An event triggered when the mesh is disposed
  28398. */
  28399. onDisposeObservable: Observable<Node>;
  28400. private _onDisposeObserver;
  28401. /**
  28402. * Sets a callback that will be raised when the node will be disposed
  28403. */
  28404. onDispose: () => void;
  28405. /**
  28406. * Creates a new Node
  28407. * @param name the name and id to be given to this node
  28408. * @param scene the scene this node will be added to
  28409. */
  28410. constructor(name: string, scene?: Nullable<Scene>);
  28411. /**
  28412. * Gets the scene of the node
  28413. * @returns a scene
  28414. */
  28415. getScene(): Scene;
  28416. /**
  28417. * Gets the engine of the node
  28418. * @returns a Engine
  28419. */
  28420. getEngine(): Engine;
  28421. private _behaviors;
  28422. /**
  28423. * Attach a behavior to the node
  28424. * @see http://doc.babylonjs.com/features/behaviour
  28425. * @param behavior defines the behavior to attach
  28426. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28427. * @returns the current Node
  28428. */
  28429. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28430. /**
  28431. * Remove an attached behavior
  28432. * @see http://doc.babylonjs.com/features/behaviour
  28433. * @param behavior defines the behavior to attach
  28434. * @returns the current Node
  28435. */
  28436. removeBehavior(behavior: Behavior<Node>): Node;
  28437. /**
  28438. * Gets the list of attached behaviors
  28439. * @see http://doc.babylonjs.com/features/behaviour
  28440. */
  28441. readonly behaviors: Behavior<Node>[];
  28442. /**
  28443. * Gets an attached behavior by name
  28444. * @param name defines the name of the behavior to look for
  28445. * @see http://doc.babylonjs.com/features/behaviour
  28446. * @returns null if behavior was not found else the requested behavior
  28447. */
  28448. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28449. /**
  28450. * Returns the latest update of the World matrix
  28451. * @returns a Matrix
  28452. */
  28453. getWorldMatrix(): Matrix;
  28454. /** @hidden */
  28455. _getWorldMatrixDeterminant(): number;
  28456. /**
  28457. * Returns directly the latest state of the mesh World matrix.
  28458. * A Matrix is returned.
  28459. */
  28460. readonly worldMatrixFromCache: Matrix;
  28461. /** @hidden */
  28462. _initCache(): void;
  28463. /** @hidden */
  28464. updateCache(force?: boolean): void;
  28465. /** @hidden */
  28466. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28467. /** @hidden */
  28468. _updateCache(ignoreParentClass?: boolean): void;
  28469. /** @hidden */
  28470. _isSynchronized(): boolean;
  28471. /** @hidden */
  28472. _markSyncedWithParent(): void;
  28473. /** @hidden */
  28474. isSynchronizedWithParent(): boolean;
  28475. /** @hidden */
  28476. isSynchronized(): boolean;
  28477. /**
  28478. * Is this node ready to be used/rendered
  28479. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28480. * @return true if the node is ready
  28481. */
  28482. isReady(completeCheck?: boolean): boolean;
  28483. /**
  28484. * Is this node enabled?
  28485. * 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
  28486. * @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
  28487. * @return whether this node (and its parent) is enabled
  28488. */
  28489. isEnabled(checkAncestors?: boolean): boolean;
  28490. /** @hidden */
  28491. protected _syncParentEnabledState(): void;
  28492. /**
  28493. * Set the enabled state of this node
  28494. * @param value defines the new enabled state
  28495. */
  28496. setEnabled(value: boolean): void;
  28497. /**
  28498. * Is this node a descendant of the given node?
  28499. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28500. * @param ancestor defines the parent node to inspect
  28501. * @returns a boolean indicating if this node is a descendant of the given node
  28502. */
  28503. isDescendantOf(ancestor: Node): boolean;
  28504. /** @hidden */
  28505. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28506. /**
  28507. * Will return all nodes that have this node as ascendant
  28508. * @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
  28509. * @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
  28510. * @return all children nodes of all types
  28511. */
  28512. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28513. /**
  28514. * Get all child-meshes of this node
  28515. * @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)
  28516. * @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
  28517. * @returns an array of AbstractMesh
  28518. */
  28519. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28520. /**
  28521. * Get all direct children of this node
  28522. * @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
  28523. * @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)
  28524. * @returns an array of Node
  28525. */
  28526. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28527. /** @hidden */
  28528. _setReady(state: boolean): void;
  28529. /**
  28530. * Get an animation by name
  28531. * @param name defines the name of the animation to look for
  28532. * @returns null if not found else the requested animation
  28533. */
  28534. getAnimationByName(name: string): Nullable<Animation>;
  28535. /**
  28536. * Creates an animation range for this node
  28537. * @param name defines the name of the range
  28538. * @param from defines the starting key
  28539. * @param to defines the end key
  28540. */
  28541. createAnimationRange(name: string, from: number, to: number): void;
  28542. /**
  28543. * Delete a specific animation range
  28544. * @param name defines the name of the range to delete
  28545. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28546. */
  28547. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28548. /**
  28549. * Get an animation range by name
  28550. * @param name defines the name of the animation range to look for
  28551. * @returns null if not found else the requested animation range
  28552. */
  28553. getAnimationRange(name: string): Nullable<AnimationRange>;
  28554. /**
  28555. * Gets the list of all animation ranges defined on this node
  28556. * @returns an array
  28557. */
  28558. getAnimationRanges(): Nullable<AnimationRange>[];
  28559. /**
  28560. * Will start the animation sequence
  28561. * @param name defines the range frames for animation sequence
  28562. * @param loop defines if the animation should loop (false by default)
  28563. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28564. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28565. * @returns the object created for this animation. If range does not exist, it will return null
  28566. */
  28567. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28568. /**
  28569. * Serialize animation ranges into a JSON compatible object
  28570. * @returns serialization object
  28571. */
  28572. serializeAnimationRanges(): any;
  28573. /**
  28574. * Computes the world matrix of the node
  28575. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28576. * @returns the world matrix
  28577. */
  28578. computeWorldMatrix(force?: boolean): Matrix;
  28579. /**
  28580. * Releases resources associated with this node.
  28581. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28582. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28583. */
  28584. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28585. /**
  28586. * Parse animation range data from a serialization object and store them into a given node
  28587. * @param node defines where to store the animation ranges
  28588. * @param parsedNode defines the serialization object to read data from
  28589. * @param scene defines the hosting scene
  28590. */
  28591. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28592. /**
  28593. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28594. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28595. * @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
  28596. * @returns the new bounding vectors
  28597. */
  28598. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28599. min: Vector3;
  28600. max: Vector3;
  28601. };
  28602. }
  28603. }
  28604. declare module BABYLON {
  28605. /**
  28606. * @hidden
  28607. */
  28608. export class _IAnimationState {
  28609. key: number;
  28610. repeatCount: number;
  28611. workValue?: any;
  28612. loopMode?: number;
  28613. offsetValue?: any;
  28614. highLimitValue?: any;
  28615. }
  28616. /**
  28617. * Class used to store any kind of animation
  28618. */
  28619. export class Animation {
  28620. /**Name of the animation */
  28621. name: string;
  28622. /**Property to animate */
  28623. targetProperty: string;
  28624. /**The frames per second of the animation */
  28625. framePerSecond: number;
  28626. /**The data type of the animation */
  28627. dataType: number;
  28628. /**The loop mode of the animation */
  28629. loopMode?: number | undefined;
  28630. /**Specifies if blending should be enabled */
  28631. enableBlending?: boolean | undefined;
  28632. /**
  28633. * Use matrix interpolation instead of using direct key value when animating matrices
  28634. */
  28635. static AllowMatricesInterpolation: boolean;
  28636. /**
  28637. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28638. */
  28639. static AllowMatrixDecomposeForInterpolation: boolean;
  28640. /**
  28641. * Stores the key frames of the animation
  28642. */
  28643. private _keys;
  28644. /**
  28645. * Stores the easing function of the animation
  28646. */
  28647. private _easingFunction;
  28648. /**
  28649. * @hidden Internal use only
  28650. */
  28651. _runtimeAnimations: RuntimeAnimation[];
  28652. /**
  28653. * The set of event that will be linked to this animation
  28654. */
  28655. private _events;
  28656. /**
  28657. * Stores an array of target property paths
  28658. */
  28659. targetPropertyPath: string[];
  28660. /**
  28661. * Stores the blending speed of the animation
  28662. */
  28663. blendingSpeed: number;
  28664. /**
  28665. * Stores the animation ranges for the animation
  28666. */
  28667. private _ranges;
  28668. /**
  28669. * @hidden Internal use
  28670. */
  28671. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28672. /**
  28673. * Sets up an animation
  28674. * @param property The property to animate
  28675. * @param animationType The animation type to apply
  28676. * @param framePerSecond The frames per second of the animation
  28677. * @param easingFunction The easing function used in the animation
  28678. * @returns The created animation
  28679. */
  28680. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28681. /**
  28682. * Create and start an animation on a node
  28683. * @param name defines the name of the global animation that will be run on all nodes
  28684. * @param node defines the root node where the animation will take place
  28685. * @param targetProperty defines property to animate
  28686. * @param framePerSecond defines the number of frame per second yo use
  28687. * @param totalFrame defines the number of frames in total
  28688. * @param from defines the initial value
  28689. * @param to defines the final value
  28690. * @param loopMode defines which loop mode you want to use (off by default)
  28691. * @param easingFunction defines the easing function to use (linear by default)
  28692. * @param onAnimationEnd defines the callback to call when animation end
  28693. * @returns the animatable created for this animation
  28694. */
  28695. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28696. /**
  28697. * Create and start an animation on a node and its descendants
  28698. * @param name defines the name of the global animation that will be run on all nodes
  28699. * @param node defines the root node where the animation will take place
  28700. * @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
  28701. * @param targetProperty defines property to animate
  28702. * @param framePerSecond defines the number of frame per second to use
  28703. * @param totalFrame defines the number of frames in total
  28704. * @param from defines the initial value
  28705. * @param to defines the final value
  28706. * @param loopMode defines which loop mode you want to use (off by default)
  28707. * @param easingFunction defines the easing function to use (linear by default)
  28708. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28709. * @returns the list of animatables created for all nodes
  28710. * @example https://www.babylonjs-playground.com/#MH0VLI
  28711. */
  28712. 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[]>;
  28713. /**
  28714. * Creates a new animation, merges it with the existing animations and starts it
  28715. * @param name Name of the animation
  28716. * @param node Node which contains the scene that begins the animations
  28717. * @param targetProperty Specifies which property to animate
  28718. * @param framePerSecond The frames per second of the animation
  28719. * @param totalFrame The total number of frames
  28720. * @param from The frame at the beginning of the animation
  28721. * @param to The frame at the end of the animation
  28722. * @param loopMode Specifies the loop mode of the animation
  28723. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28724. * @param onAnimationEnd Callback to run once the animation is complete
  28725. * @returns Nullable animation
  28726. */
  28727. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28728. /**
  28729. * Transition property of an host to the target Value
  28730. * @param property The property to transition
  28731. * @param targetValue The target Value of the property
  28732. * @param host The object where the property to animate belongs
  28733. * @param scene Scene used to run the animation
  28734. * @param frameRate Framerate (in frame/s) to use
  28735. * @param transition The transition type we want to use
  28736. * @param duration The duration of the animation, in milliseconds
  28737. * @param onAnimationEnd Callback trigger at the end of the animation
  28738. * @returns Nullable animation
  28739. */
  28740. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28741. /**
  28742. * Return the array of runtime animations currently using this animation
  28743. */
  28744. readonly runtimeAnimations: RuntimeAnimation[];
  28745. /**
  28746. * Specifies if any of the runtime animations are currently running
  28747. */
  28748. readonly hasRunningRuntimeAnimations: boolean;
  28749. /**
  28750. * Initializes the animation
  28751. * @param name Name of the animation
  28752. * @param targetProperty Property to animate
  28753. * @param framePerSecond The frames per second of the animation
  28754. * @param dataType The data type of the animation
  28755. * @param loopMode The loop mode of the animation
  28756. * @param enableBlending Specifies if blending should be enabled
  28757. */
  28758. constructor(
  28759. /**Name of the animation */
  28760. name: string,
  28761. /**Property to animate */
  28762. targetProperty: string,
  28763. /**The frames per second of the animation */
  28764. framePerSecond: number,
  28765. /**The data type of the animation */
  28766. dataType: number,
  28767. /**The loop mode of the animation */
  28768. loopMode?: number | undefined,
  28769. /**Specifies if blending should be enabled */
  28770. enableBlending?: boolean | undefined);
  28771. /**
  28772. * Converts the animation to a string
  28773. * @param fullDetails support for multiple levels of logging within scene loading
  28774. * @returns String form of the animation
  28775. */
  28776. toString(fullDetails?: boolean): string;
  28777. /**
  28778. * Add an event to this animation
  28779. * @param event Event to add
  28780. */
  28781. addEvent(event: AnimationEvent): void;
  28782. /**
  28783. * Remove all events found at the given frame
  28784. * @param frame The frame to remove events from
  28785. */
  28786. removeEvents(frame: number): void;
  28787. /**
  28788. * Retrieves all the events from the animation
  28789. * @returns Events from the animation
  28790. */
  28791. getEvents(): AnimationEvent[];
  28792. /**
  28793. * Creates an animation range
  28794. * @param name Name of the animation range
  28795. * @param from Starting frame of the animation range
  28796. * @param to Ending frame of the animation
  28797. */
  28798. createRange(name: string, from: number, to: number): void;
  28799. /**
  28800. * Deletes an animation range by name
  28801. * @param name Name of the animation range to delete
  28802. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28803. */
  28804. deleteRange(name: string, deleteFrames?: boolean): void;
  28805. /**
  28806. * Gets the animation range by name, or null if not defined
  28807. * @param name Name of the animation range
  28808. * @returns Nullable animation range
  28809. */
  28810. getRange(name: string): Nullable<AnimationRange>;
  28811. /**
  28812. * Gets the key frames from the animation
  28813. * @returns The key frames of the animation
  28814. */
  28815. getKeys(): Array<IAnimationKey>;
  28816. /**
  28817. * Gets the highest frame rate of the animation
  28818. * @returns Highest frame rate of the animation
  28819. */
  28820. getHighestFrame(): number;
  28821. /**
  28822. * Gets the easing function of the animation
  28823. * @returns Easing function of the animation
  28824. */
  28825. getEasingFunction(): IEasingFunction;
  28826. /**
  28827. * Sets the easing function of the animation
  28828. * @param easingFunction A custom mathematical formula for animation
  28829. */
  28830. setEasingFunction(easingFunction: EasingFunction): void;
  28831. /**
  28832. * Interpolates a scalar linearly
  28833. * @param startValue Start value of the animation curve
  28834. * @param endValue End value of the animation curve
  28835. * @param gradient Scalar amount to interpolate
  28836. * @returns Interpolated scalar value
  28837. */
  28838. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28839. /**
  28840. * Interpolates a scalar cubically
  28841. * @param startValue Start value of the animation curve
  28842. * @param outTangent End tangent of the animation
  28843. * @param endValue End value of the animation curve
  28844. * @param inTangent Start tangent of the animation curve
  28845. * @param gradient Scalar amount to interpolate
  28846. * @returns Interpolated scalar value
  28847. */
  28848. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28849. /**
  28850. * Interpolates a quaternion using a spherical linear interpolation
  28851. * @param startValue Start value of the animation curve
  28852. * @param endValue End value of the animation curve
  28853. * @param gradient Scalar amount to interpolate
  28854. * @returns Interpolated quaternion value
  28855. */
  28856. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28857. /**
  28858. * Interpolates a quaternion cubically
  28859. * @param startValue Start value of the animation curve
  28860. * @param outTangent End tangent of the animation curve
  28861. * @param endValue End value of the animation curve
  28862. * @param inTangent Start tangent of the animation curve
  28863. * @param gradient Scalar amount to interpolate
  28864. * @returns Interpolated quaternion value
  28865. */
  28866. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28867. /**
  28868. * Interpolates a Vector3 linearl
  28869. * @param startValue Start value of the animation curve
  28870. * @param endValue End value of the animation curve
  28871. * @param gradient Scalar amount to interpolate
  28872. * @returns Interpolated scalar value
  28873. */
  28874. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28875. /**
  28876. * Interpolates a Vector3 cubically
  28877. * @param startValue Start value of the animation curve
  28878. * @param outTangent End tangent of the animation
  28879. * @param endValue End value of the animation curve
  28880. * @param inTangent Start tangent of the animation curve
  28881. * @param gradient Scalar amount to interpolate
  28882. * @returns InterpolatedVector3 value
  28883. */
  28884. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28885. /**
  28886. * Interpolates a Vector2 linearly
  28887. * @param startValue Start value of the animation curve
  28888. * @param endValue End value of the animation curve
  28889. * @param gradient Scalar amount to interpolate
  28890. * @returns Interpolated Vector2 value
  28891. */
  28892. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28893. /**
  28894. * Interpolates a Vector2 cubically
  28895. * @param startValue Start value of the animation curve
  28896. * @param outTangent End tangent of the animation
  28897. * @param endValue End value of the animation curve
  28898. * @param inTangent Start tangent of the animation curve
  28899. * @param gradient Scalar amount to interpolate
  28900. * @returns Interpolated Vector2 value
  28901. */
  28902. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28903. /**
  28904. * Interpolates a size linearly
  28905. * @param startValue Start value of the animation curve
  28906. * @param endValue End value of the animation curve
  28907. * @param gradient Scalar amount to interpolate
  28908. * @returns Interpolated Size value
  28909. */
  28910. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28911. /**
  28912. * Interpolates a Color3 linearly
  28913. * @param startValue Start value of the animation curve
  28914. * @param endValue End value of the animation curve
  28915. * @param gradient Scalar amount to interpolate
  28916. * @returns Interpolated Color3 value
  28917. */
  28918. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28919. /**
  28920. * Interpolates a Color4 linearly
  28921. * @param startValue Start value of the animation curve
  28922. * @param endValue End value of the animation curve
  28923. * @param gradient Scalar amount to interpolate
  28924. * @returns Interpolated Color3 value
  28925. */
  28926. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28927. /**
  28928. * @hidden Internal use only
  28929. */
  28930. _getKeyValue(value: any): any;
  28931. /**
  28932. * @hidden Internal use only
  28933. */
  28934. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28935. /**
  28936. * Defines the function to use to interpolate matrices
  28937. * @param startValue defines the start matrix
  28938. * @param endValue defines the end matrix
  28939. * @param gradient defines the gradient between both matrices
  28940. * @param result defines an optional target matrix where to store the interpolation
  28941. * @returns the interpolated matrix
  28942. */
  28943. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28944. /**
  28945. * Makes a copy of the animation
  28946. * @returns Cloned animation
  28947. */
  28948. clone(): Animation;
  28949. /**
  28950. * Sets the key frames of the animation
  28951. * @param values The animation key frames to set
  28952. */
  28953. setKeys(values: Array<IAnimationKey>): void;
  28954. /**
  28955. * Serializes the animation to an object
  28956. * @returns Serialized object
  28957. */
  28958. serialize(): any;
  28959. /**
  28960. * Float animation type
  28961. */
  28962. static readonly ANIMATIONTYPE_FLOAT: number;
  28963. /**
  28964. * Vector3 animation type
  28965. */
  28966. static readonly ANIMATIONTYPE_VECTOR3: number;
  28967. /**
  28968. * Quaternion animation type
  28969. */
  28970. static readonly ANIMATIONTYPE_QUATERNION: number;
  28971. /**
  28972. * Matrix animation type
  28973. */
  28974. static readonly ANIMATIONTYPE_MATRIX: number;
  28975. /**
  28976. * Color3 animation type
  28977. */
  28978. static readonly ANIMATIONTYPE_COLOR3: number;
  28979. /**
  28980. * Color3 animation type
  28981. */
  28982. static readonly ANIMATIONTYPE_COLOR4: number;
  28983. /**
  28984. * Vector2 animation type
  28985. */
  28986. static readonly ANIMATIONTYPE_VECTOR2: number;
  28987. /**
  28988. * Size animation type
  28989. */
  28990. static readonly ANIMATIONTYPE_SIZE: number;
  28991. /**
  28992. * Relative Loop Mode
  28993. */
  28994. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28995. /**
  28996. * Cycle Loop Mode
  28997. */
  28998. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28999. /**
  29000. * Constant Loop Mode
  29001. */
  29002. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29003. /** @hidden */
  29004. static _UniversalLerp(left: any, right: any, amount: number): any;
  29005. /**
  29006. * Parses an animation object and creates an animation
  29007. * @param parsedAnimation Parsed animation object
  29008. * @returns Animation object
  29009. */
  29010. static Parse(parsedAnimation: any): Animation;
  29011. /**
  29012. * Appends the serialized animations from the source animations
  29013. * @param source Source containing the animations
  29014. * @param destination Target to store the animations
  29015. */
  29016. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29017. }
  29018. }
  29019. declare module BABYLON {
  29020. /**
  29021. * Interface containing an array of animations
  29022. */
  29023. export interface IAnimatable {
  29024. /**
  29025. * Array of animations
  29026. */
  29027. animations: Nullable<Array<Animation>>;
  29028. }
  29029. }
  29030. declare module BABYLON {
  29031. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29032. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29033. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29034. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29035. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29036. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29037. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29038. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29039. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29040. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29041. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29042. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29043. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29044. /**
  29045. * Decorator used to define property that can be serialized as reference to a camera
  29046. * @param sourceName defines the name of the property to decorate
  29047. */
  29048. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29049. /**
  29050. * Class used to help serialization objects
  29051. */
  29052. export class SerializationHelper {
  29053. /** @hidden */
  29054. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29055. /** @hidden */
  29056. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29057. /** @hidden */
  29058. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29059. /** @hidden */
  29060. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29061. /**
  29062. * Appends the serialized animations from the source animations
  29063. * @param source Source containing the animations
  29064. * @param destination Target to store the animations
  29065. */
  29066. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29067. /**
  29068. * Static function used to serialized a specific entity
  29069. * @param entity defines the entity to serialize
  29070. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29071. * @returns a JSON compatible object representing the serialization of the entity
  29072. */
  29073. static Serialize<T>(entity: T, serializationObject?: any): any;
  29074. /**
  29075. * Creates a new entity from a serialization data object
  29076. * @param creationFunction defines a function used to instanciated the new entity
  29077. * @param source defines the source serialization data
  29078. * @param scene defines the hosting scene
  29079. * @param rootUrl defines the root url for resources
  29080. * @returns a new entity
  29081. */
  29082. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29083. /**
  29084. * Clones an object
  29085. * @param creationFunction defines the function used to instanciate the new object
  29086. * @param source defines the source object
  29087. * @returns the cloned object
  29088. */
  29089. static Clone<T>(creationFunction: () => T, source: T): T;
  29090. /**
  29091. * Instanciates a new object based on a source one (some data will be shared between both object)
  29092. * @param creationFunction defines the function used to instanciate the new object
  29093. * @param source defines the source object
  29094. * @returns the new object
  29095. */
  29096. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29097. }
  29098. }
  29099. declare module BABYLON {
  29100. /**
  29101. * Class used to manipulate GUIDs
  29102. */
  29103. export class GUID {
  29104. /**
  29105. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29106. * Be aware Math.random() could cause collisions, but:
  29107. * "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"
  29108. * @returns a pseudo random id
  29109. */
  29110. static RandomId(): string;
  29111. }
  29112. }
  29113. declare module BABYLON {
  29114. /**
  29115. * Base class of all the textures in babylon.
  29116. * It groups all the common properties the materials, post process, lights... might need
  29117. * in order to make a correct use of the texture.
  29118. */
  29119. export class BaseTexture implements IAnimatable {
  29120. /**
  29121. * Default anisotropic filtering level for the application.
  29122. * It is set to 4 as a good tradeoff between perf and quality.
  29123. */
  29124. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29125. /**
  29126. * Gets or sets the unique id of the texture
  29127. */
  29128. uniqueId: number;
  29129. /**
  29130. * Define the name of the texture.
  29131. */
  29132. name: string;
  29133. /**
  29134. * Gets or sets an object used to store user defined information.
  29135. */
  29136. metadata: any;
  29137. /**
  29138. * For internal use only. Please do not use.
  29139. */
  29140. reservedDataStore: any;
  29141. private _hasAlpha;
  29142. /**
  29143. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29144. */
  29145. hasAlpha: boolean;
  29146. /**
  29147. * Defines if the alpha value should be determined via the rgb values.
  29148. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29149. */
  29150. getAlphaFromRGB: boolean;
  29151. /**
  29152. * Intensity or strength of the texture.
  29153. * It is commonly used by materials to fine tune the intensity of the texture
  29154. */
  29155. level: number;
  29156. /**
  29157. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29158. * This is part of the texture as textures usually maps to one uv set.
  29159. */
  29160. coordinatesIndex: number;
  29161. private _coordinatesMode;
  29162. /**
  29163. * How a texture is mapped.
  29164. *
  29165. * | Value | Type | Description |
  29166. * | ----- | ----------------------------------- | ----------- |
  29167. * | 0 | EXPLICIT_MODE | |
  29168. * | 1 | SPHERICAL_MODE | |
  29169. * | 2 | PLANAR_MODE | |
  29170. * | 3 | CUBIC_MODE | |
  29171. * | 4 | PROJECTION_MODE | |
  29172. * | 5 | SKYBOX_MODE | |
  29173. * | 6 | INVCUBIC_MODE | |
  29174. * | 7 | EQUIRECTANGULAR_MODE | |
  29175. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29176. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29177. */
  29178. coordinatesMode: number;
  29179. /**
  29180. * | Value | Type | Description |
  29181. * | ----- | ------------------ | ----------- |
  29182. * | 0 | CLAMP_ADDRESSMODE | |
  29183. * | 1 | WRAP_ADDRESSMODE | |
  29184. * | 2 | MIRROR_ADDRESSMODE | |
  29185. */
  29186. wrapU: number;
  29187. /**
  29188. * | Value | Type | Description |
  29189. * | ----- | ------------------ | ----------- |
  29190. * | 0 | CLAMP_ADDRESSMODE | |
  29191. * | 1 | WRAP_ADDRESSMODE | |
  29192. * | 2 | MIRROR_ADDRESSMODE | |
  29193. */
  29194. wrapV: number;
  29195. /**
  29196. * | Value | Type | Description |
  29197. * | ----- | ------------------ | ----------- |
  29198. * | 0 | CLAMP_ADDRESSMODE | |
  29199. * | 1 | WRAP_ADDRESSMODE | |
  29200. * | 2 | MIRROR_ADDRESSMODE | |
  29201. */
  29202. wrapR: number;
  29203. /**
  29204. * With compliant hardware and browser (supporting anisotropic filtering)
  29205. * this defines the level of anisotropic filtering in the texture.
  29206. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29207. */
  29208. anisotropicFilteringLevel: number;
  29209. /**
  29210. * Define if the texture is a cube texture or if false a 2d texture.
  29211. */
  29212. isCube: boolean;
  29213. /**
  29214. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29215. */
  29216. is3D: boolean;
  29217. /**
  29218. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29219. */
  29220. is2DArray: boolean;
  29221. /**
  29222. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29223. * HDR texture are usually stored in linear space.
  29224. * This only impacts the PBR and Background materials
  29225. */
  29226. gammaSpace: boolean;
  29227. /**
  29228. * Gets or sets whether or not the texture contains RGBD data.
  29229. */
  29230. isRGBD: boolean;
  29231. /**
  29232. * Is Z inverted in the texture (useful in a cube texture).
  29233. */
  29234. invertZ: boolean;
  29235. /**
  29236. * Are mip maps generated for this texture or not.
  29237. */
  29238. readonly noMipmap: boolean;
  29239. /**
  29240. * @hidden
  29241. */
  29242. lodLevelInAlpha: boolean;
  29243. /**
  29244. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29245. */
  29246. lodGenerationOffset: number;
  29247. /**
  29248. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29249. */
  29250. lodGenerationScale: number;
  29251. /**
  29252. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29253. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29254. * average roughness values.
  29255. */
  29256. linearSpecularLOD: boolean;
  29257. /**
  29258. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29259. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29260. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29261. */
  29262. irradianceTexture: Nullable<BaseTexture>;
  29263. /**
  29264. * Define if the texture is a render target.
  29265. */
  29266. isRenderTarget: boolean;
  29267. /**
  29268. * Define the unique id of the texture in the scene.
  29269. */
  29270. readonly uid: string;
  29271. /**
  29272. * Return a string representation of the texture.
  29273. * @returns the texture as a string
  29274. */
  29275. toString(): string;
  29276. /**
  29277. * Get the class name of the texture.
  29278. * @returns "BaseTexture"
  29279. */
  29280. getClassName(): string;
  29281. /**
  29282. * Define the list of animation attached to the texture.
  29283. */
  29284. animations: Animation[];
  29285. /**
  29286. * An event triggered when the texture is disposed.
  29287. */
  29288. onDisposeObservable: Observable<BaseTexture>;
  29289. private _onDisposeObserver;
  29290. /**
  29291. * Callback triggered when the texture has been disposed.
  29292. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29293. */
  29294. onDispose: () => void;
  29295. /**
  29296. * Define the current state of the loading sequence when in delayed load mode.
  29297. */
  29298. delayLoadState: number;
  29299. private _scene;
  29300. /** @hidden */
  29301. _texture: Nullable<InternalTexture>;
  29302. private _uid;
  29303. /**
  29304. * Define if the texture is preventinga material to render or not.
  29305. * If not and the texture is not ready, the engine will use a default black texture instead.
  29306. */
  29307. readonly isBlocking: boolean;
  29308. /**
  29309. * Instantiates a new BaseTexture.
  29310. * Base class of all the textures in babylon.
  29311. * It groups all the common properties the materials, post process, lights... might need
  29312. * in order to make a correct use of the texture.
  29313. * @param scene Define the scene the texture blongs to
  29314. */
  29315. constructor(scene: Nullable<Scene>);
  29316. /**
  29317. * Get the scene the texture belongs to.
  29318. * @returns the scene or null if undefined
  29319. */
  29320. getScene(): Nullable<Scene>;
  29321. /**
  29322. * Get the texture transform matrix used to offset tile the texture for istance.
  29323. * @returns the transformation matrix
  29324. */
  29325. getTextureMatrix(): Matrix;
  29326. /**
  29327. * Get the texture reflection matrix used to rotate/transform the reflection.
  29328. * @returns the reflection matrix
  29329. */
  29330. getReflectionTextureMatrix(): Matrix;
  29331. /**
  29332. * Get the underlying lower level texture from Babylon.
  29333. * @returns the insternal texture
  29334. */
  29335. getInternalTexture(): Nullable<InternalTexture>;
  29336. /**
  29337. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29338. * @returns true if ready or not blocking
  29339. */
  29340. isReadyOrNotBlocking(): boolean;
  29341. /**
  29342. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29343. * @returns true if fully ready
  29344. */
  29345. isReady(): boolean;
  29346. private _cachedSize;
  29347. /**
  29348. * Get the size of the texture.
  29349. * @returns the texture size.
  29350. */
  29351. getSize(): ISize;
  29352. /**
  29353. * Get the base size of the texture.
  29354. * It can be different from the size if the texture has been resized for POT for instance
  29355. * @returns the base size
  29356. */
  29357. getBaseSize(): ISize;
  29358. /**
  29359. * Update the sampling mode of the texture.
  29360. * Default is Trilinear mode.
  29361. *
  29362. * | Value | Type | Description |
  29363. * | ----- | ------------------ | ----------- |
  29364. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29365. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29366. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29367. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29368. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29369. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29370. * | 7 | NEAREST_LINEAR | |
  29371. * | 8 | NEAREST_NEAREST | |
  29372. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29373. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29374. * | 11 | LINEAR_LINEAR | |
  29375. * | 12 | LINEAR_NEAREST | |
  29376. *
  29377. * > _mag_: magnification filter (close to the viewer)
  29378. * > _min_: minification filter (far from the viewer)
  29379. * > _mip_: filter used between mip map levels
  29380. *@param samplingMode Define the new sampling mode of the texture
  29381. */
  29382. updateSamplingMode(samplingMode: number): void;
  29383. /**
  29384. * Scales the texture if is `canRescale()`
  29385. * @param ratio the resize factor we want to use to rescale
  29386. */
  29387. scale(ratio: number): void;
  29388. /**
  29389. * Get if the texture can rescale.
  29390. */
  29391. readonly canRescale: boolean;
  29392. /** @hidden */
  29393. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29394. /** @hidden */
  29395. _rebuild(): void;
  29396. /**
  29397. * Triggers the load sequence in delayed load mode.
  29398. */
  29399. delayLoad(): void;
  29400. /**
  29401. * Clones the texture.
  29402. * @returns the cloned texture
  29403. */
  29404. clone(): Nullable<BaseTexture>;
  29405. /**
  29406. * Get the texture underlying type (INT, FLOAT...)
  29407. */
  29408. readonly textureType: number;
  29409. /**
  29410. * Get the texture underlying format (RGB, RGBA...)
  29411. */
  29412. readonly textureFormat: number;
  29413. /**
  29414. * Indicates that textures need to be re-calculated for all materials
  29415. */
  29416. protected _markAllSubMeshesAsTexturesDirty(): void;
  29417. /**
  29418. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29419. * This will returns an RGBA array buffer containing either in values (0-255) or
  29420. * float values (0-1) depending of the underlying buffer type.
  29421. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29422. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29423. * @param buffer defines a user defined buffer to fill with data (can be null)
  29424. * @returns The Array buffer containing the pixels data.
  29425. */
  29426. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29427. /**
  29428. * Release and destroy the underlying lower level texture aka internalTexture.
  29429. */
  29430. releaseInternalTexture(): void;
  29431. /** @hidden */
  29432. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29433. /** @hidden */
  29434. readonly _lodTextureMid: Nullable<BaseTexture>;
  29435. /** @hidden */
  29436. readonly _lodTextureLow: Nullable<BaseTexture>;
  29437. /**
  29438. * Dispose the texture and release its associated resources.
  29439. */
  29440. dispose(): void;
  29441. /**
  29442. * Serialize the texture into a JSON representation that can be parsed later on.
  29443. * @returns the JSON representation of the texture
  29444. */
  29445. serialize(): any;
  29446. /**
  29447. * Helper function to be called back once a list of texture contains only ready textures.
  29448. * @param textures Define the list of textures to wait for
  29449. * @param callback Define the callback triggered once the entire list will be ready
  29450. */
  29451. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29452. }
  29453. }
  29454. declare module BABYLON {
  29455. /**
  29456. * Options to be used when creating an effect.
  29457. */
  29458. export interface IEffectCreationOptions {
  29459. /**
  29460. * Atrributes that will be used in the shader.
  29461. */
  29462. attributes: string[];
  29463. /**
  29464. * Uniform varible names that will be set in the shader.
  29465. */
  29466. uniformsNames: string[];
  29467. /**
  29468. * Uniform buffer variable names that will be set in the shader.
  29469. */
  29470. uniformBuffersNames: string[];
  29471. /**
  29472. * Sampler texture variable names that will be set in the shader.
  29473. */
  29474. samplers: string[];
  29475. /**
  29476. * Define statements that will be set in the shader.
  29477. */
  29478. defines: any;
  29479. /**
  29480. * Possible fallbacks for this effect to improve performance when needed.
  29481. */
  29482. fallbacks: Nullable<IEffectFallbacks>;
  29483. /**
  29484. * Callback that will be called when the shader is compiled.
  29485. */
  29486. onCompiled: Nullable<(effect: Effect) => void>;
  29487. /**
  29488. * Callback that will be called if an error occurs during shader compilation.
  29489. */
  29490. onError: Nullable<(effect: Effect, errors: string) => void>;
  29491. /**
  29492. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29493. */
  29494. indexParameters?: any;
  29495. /**
  29496. * Max number of lights that can be used in the shader.
  29497. */
  29498. maxSimultaneousLights?: number;
  29499. /**
  29500. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29501. */
  29502. transformFeedbackVaryings?: Nullable<string[]>;
  29503. }
  29504. /**
  29505. * Effect containing vertex and fragment shader that can be executed on an object.
  29506. */
  29507. export class Effect implements IDisposable {
  29508. /**
  29509. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29510. */
  29511. static ShadersRepository: string;
  29512. /**
  29513. * Name of the effect.
  29514. */
  29515. name: any;
  29516. /**
  29517. * String container all the define statements that should be set on the shader.
  29518. */
  29519. defines: string;
  29520. /**
  29521. * Callback that will be called when the shader is compiled.
  29522. */
  29523. onCompiled: Nullable<(effect: Effect) => void>;
  29524. /**
  29525. * Callback that will be called if an error occurs during shader compilation.
  29526. */
  29527. onError: Nullable<(effect: Effect, errors: string) => void>;
  29528. /**
  29529. * Callback that will be called when effect is bound.
  29530. */
  29531. onBind: Nullable<(effect: Effect) => void>;
  29532. /**
  29533. * Unique ID of the effect.
  29534. */
  29535. uniqueId: number;
  29536. /**
  29537. * Observable that will be called when the shader is compiled.
  29538. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29539. */
  29540. onCompileObservable: Observable<Effect>;
  29541. /**
  29542. * Observable that will be called if an error occurs during shader compilation.
  29543. */
  29544. onErrorObservable: Observable<Effect>;
  29545. /** @hidden */
  29546. _onBindObservable: Nullable<Observable<Effect>>;
  29547. /**
  29548. * Observable that will be called when effect is bound.
  29549. */
  29550. readonly onBindObservable: Observable<Effect>;
  29551. /** @hidden */
  29552. _bonesComputationForcedToCPU: boolean;
  29553. private static _uniqueIdSeed;
  29554. private _engine;
  29555. private _uniformBuffersNames;
  29556. private _uniformsNames;
  29557. private _samplerList;
  29558. private _samplers;
  29559. private _isReady;
  29560. private _compilationError;
  29561. private _allFallbacksProcessed;
  29562. private _attributesNames;
  29563. private _attributes;
  29564. private _attributeLocationByName;
  29565. private _uniforms;
  29566. /**
  29567. * Key for the effect.
  29568. * @hidden
  29569. */
  29570. _key: string;
  29571. private _indexParameters;
  29572. private _fallbacks;
  29573. private _vertexSourceCode;
  29574. private _fragmentSourceCode;
  29575. private _vertexSourceCodeOverride;
  29576. private _fragmentSourceCodeOverride;
  29577. private _transformFeedbackVaryings;
  29578. /**
  29579. * Compiled shader to webGL program.
  29580. * @hidden
  29581. */
  29582. _pipelineContext: Nullable<IPipelineContext>;
  29583. private _valueCache;
  29584. private static _baseCache;
  29585. /**
  29586. * Instantiates an effect.
  29587. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29588. * @param baseName Name of the effect.
  29589. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29590. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29591. * @param samplers List of sampler variables that will be passed to the shader.
  29592. * @param engine Engine to be used to render the effect
  29593. * @param defines Define statements to be added to the shader.
  29594. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29595. * @param onCompiled Callback that will be called when the shader is compiled.
  29596. * @param onError Callback that will be called if an error occurs during shader compilation.
  29597. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29598. */
  29599. 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);
  29600. private _useFinalCode;
  29601. /**
  29602. * Unique key for this effect
  29603. */
  29604. readonly key: string;
  29605. /**
  29606. * If the effect has been compiled and prepared.
  29607. * @returns if the effect is compiled and prepared.
  29608. */
  29609. isReady(): boolean;
  29610. private _isReadyInternal;
  29611. /**
  29612. * The engine the effect was initialized with.
  29613. * @returns the engine.
  29614. */
  29615. getEngine(): Engine;
  29616. /**
  29617. * The pipeline context for this effect
  29618. * @returns the associated pipeline context
  29619. */
  29620. getPipelineContext(): Nullable<IPipelineContext>;
  29621. /**
  29622. * The set of names of attribute variables for the shader.
  29623. * @returns An array of attribute names.
  29624. */
  29625. getAttributesNames(): string[];
  29626. /**
  29627. * Returns the attribute at the given index.
  29628. * @param index The index of the attribute.
  29629. * @returns The location of the attribute.
  29630. */
  29631. getAttributeLocation(index: number): number;
  29632. /**
  29633. * Returns the attribute based on the name of the variable.
  29634. * @param name of the attribute to look up.
  29635. * @returns the attribute location.
  29636. */
  29637. getAttributeLocationByName(name: string): number;
  29638. /**
  29639. * The number of attributes.
  29640. * @returns the numnber of attributes.
  29641. */
  29642. getAttributesCount(): number;
  29643. /**
  29644. * Gets the index of a uniform variable.
  29645. * @param uniformName of the uniform to look up.
  29646. * @returns the index.
  29647. */
  29648. getUniformIndex(uniformName: string): number;
  29649. /**
  29650. * Returns the attribute based on the name of the variable.
  29651. * @param uniformName of the uniform to look up.
  29652. * @returns the location of the uniform.
  29653. */
  29654. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29655. /**
  29656. * Returns an array of sampler variable names
  29657. * @returns The array of sampler variable neames.
  29658. */
  29659. getSamplers(): string[];
  29660. /**
  29661. * The error from the last compilation.
  29662. * @returns the error string.
  29663. */
  29664. getCompilationError(): string;
  29665. /**
  29666. * Gets a boolean indicating that all fallbacks were used during compilation
  29667. * @returns true if all fallbacks were used
  29668. */
  29669. allFallbacksProcessed(): boolean;
  29670. /**
  29671. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29672. * @param func The callback to be used.
  29673. */
  29674. executeWhenCompiled(func: (effect: Effect) => void): void;
  29675. private _checkIsReady;
  29676. private _loadShader;
  29677. /**
  29678. * Recompiles the webGL program
  29679. * @param vertexSourceCode The source code for the vertex shader.
  29680. * @param fragmentSourceCode The source code for the fragment shader.
  29681. * @param onCompiled Callback called when completed.
  29682. * @param onError Callback called on error.
  29683. * @hidden
  29684. */
  29685. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29686. /**
  29687. * Prepares the effect
  29688. * @hidden
  29689. */
  29690. _prepareEffect(): void;
  29691. private _processCompilationErrors;
  29692. /**
  29693. * Checks if the effect is supported. (Must be called after compilation)
  29694. */
  29695. readonly isSupported: boolean;
  29696. /**
  29697. * Binds a texture to the engine to be used as output of the shader.
  29698. * @param channel Name of the output variable.
  29699. * @param texture Texture to bind.
  29700. * @hidden
  29701. */
  29702. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  29703. /**
  29704. * Sets a texture on the engine to be used in the shader.
  29705. * @param channel Name of the sampler variable.
  29706. * @param texture Texture to set.
  29707. */
  29708. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29709. /**
  29710. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29711. * @param channel Name of the sampler variable.
  29712. * @param texture Texture to set.
  29713. */
  29714. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29715. /**
  29716. * Sets an array of textures on the engine to be used in the shader.
  29717. * @param channel Name of the variable.
  29718. * @param textures Textures to set.
  29719. */
  29720. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29721. /**
  29722. * 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)
  29723. * @param channel Name of the sampler variable.
  29724. * @param postProcess Post process to get the input texture from.
  29725. */
  29726. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29727. /**
  29728. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29729. * 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)
  29730. * @param channel Name of the sampler variable.
  29731. * @param postProcess Post process to get the output texture from.
  29732. */
  29733. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29734. /** @hidden */
  29735. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29736. /** @hidden */
  29737. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29738. /** @hidden */
  29739. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29740. /** @hidden */
  29741. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29742. /**
  29743. * Binds a buffer to a uniform.
  29744. * @param buffer Buffer to bind.
  29745. * @param name Name of the uniform variable to bind to.
  29746. */
  29747. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29748. /**
  29749. * Binds block to a uniform.
  29750. * @param blockName Name of the block to bind.
  29751. * @param index Index to bind.
  29752. */
  29753. bindUniformBlock(blockName: string, index: number): void;
  29754. /**
  29755. * Sets an interger value on a uniform variable.
  29756. * @param uniformName Name of the variable.
  29757. * @param value Value to be set.
  29758. * @returns this effect.
  29759. */
  29760. setInt(uniformName: string, value: number): Effect;
  29761. /**
  29762. * Sets an int array on a uniform variable.
  29763. * @param uniformName Name of the variable.
  29764. * @param array array to be set.
  29765. * @returns this effect.
  29766. */
  29767. setIntArray(uniformName: string, array: Int32Array): Effect;
  29768. /**
  29769. * 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)
  29770. * @param uniformName Name of the variable.
  29771. * @param array array to be set.
  29772. * @returns this effect.
  29773. */
  29774. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29775. /**
  29776. * 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)
  29777. * @param uniformName Name of the variable.
  29778. * @param array array to be set.
  29779. * @returns this effect.
  29780. */
  29781. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29782. /**
  29783. * 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)
  29784. * @param uniformName Name of the variable.
  29785. * @param array array to be set.
  29786. * @returns this effect.
  29787. */
  29788. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29789. /**
  29790. * Sets an float array on a uniform variable.
  29791. * @param uniformName Name of the variable.
  29792. * @param array array to be set.
  29793. * @returns this effect.
  29794. */
  29795. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29796. /**
  29797. * 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)
  29798. * @param uniformName Name of the variable.
  29799. * @param array array to be set.
  29800. * @returns this effect.
  29801. */
  29802. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29803. /**
  29804. * 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)
  29805. * @param uniformName Name of the variable.
  29806. * @param array array to be set.
  29807. * @returns this effect.
  29808. */
  29809. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29810. /**
  29811. * 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)
  29812. * @param uniformName Name of the variable.
  29813. * @param array array to be set.
  29814. * @returns this effect.
  29815. */
  29816. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29817. /**
  29818. * Sets an array on a uniform variable.
  29819. * @param uniformName Name of the variable.
  29820. * @param array array to be set.
  29821. * @returns this effect.
  29822. */
  29823. setArray(uniformName: string, array: number[]): Effect;
  29824. /**
  29825. * 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)
  29826. * @param uniformName Name of the variable.
  29827. * @param array array to be set.
  29828. * @returns this effect.
  29829. */
  29830. setArray2(uniformName: string, array: number[]): Effect;
  29831. /**
  29832. * 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)
  29833. * @param uniformName Name of the variable.
  29834. * @param array array to be set.
  29835. * @returns this effect.
  29836. */
  29837. setArray3(uniformName: string, array: number[]): Effect;
  29838. /**
  29839. * 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)
  29840. * @param uniformName Name of the variable.
  29841. * @param array array to be set.
  29842. * @returns this effect.
  29843. */
  29844. setArray4(uniformName: string, array: number[]): Effect;
  29845. /**
  29846. * Sets matrices on a uniform variable.
  29847. * @param uniformName Name of the variable.
  29848. * @param matrices matrices to be set.
  29849. * @returns this effect.
  29850. */
  29851. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29852. /**
  29853. * Sets matrix on a uniform variable.
  29854. * @param uniformName Name of the variable.
  29855. * @param matrix matrix to be set.
  29856. * @returns this effect.
  29857. */
  29858. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29859. /**
  29860. * 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)
  29861. * @param uniformName Name of the variable.
  29862. * @param matrix matrix to be set.
  29863. * @returns this effect.
  29864. */
  29865. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29866. /**
  29867. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29868. * @param uniformName Name of the variable.
  29869. * @param matrix matrix to be set.
  29870. * @returns this effect.
  29871. */
  29872. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29873. /**
  29874. * Sets a float on a uniform variable.
  29875. * @param uniformName Name of the variable.
  29876. * @param value value to be set.
  29877. * @returns this effect.
  29878. */
  29879. setFloat(uniformName: string, value: number): Effect;
  29880. /**
  29881. * Sets a boolean on a uniform variable.
  29882. * @param uniformName Name of the variable.
  29883. * @param bool value to be set.
  29884. * @returns this effect.
  29885. */
  29886. setBool(uniformName: string, bool: boolean): Effect;
  29887. /**
  29888. * Sets a Vector2 on a uniform variable.
  29889. * @param uniformName Name of the variable.
  29890. * @param vector2 vector2 to be set.
  29891. * @returns this effect.
  29892. */
  29893. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29894. /**
  29895. * Sets a float2 on a uniform variable.
  29896. * @param uniformName Name of the variable.
  29897. * @param x First float in float2.
  29898. * @param y Second float in float2.
  29899. * @returns this effect.
  29900. */
  29901. setFloat2(uniformName: string, x: number, y: number): Effect;
  29902. /**
  29903. * Sets a Vector3 on a uniform variable.
  29904. * @param uniformName Name of the variable.
  29905. * @param vector3 Value to be set.
  29906. * @returns this effect.
  29907. */
  29908. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29909. /**
  29910. * Sets a float3 on a uniform variable.
  29911. * @param uniformName Name of the variable.
  29912. * @param x First float in float3.
  29913. * @param y Second float in float3.
  29914. * @param z Third float in float3.
  29915. * @returns this effect.
  29916. */
  29917. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29918. /**
  29919. * Sets a Vector4 on a uniform variable.
  29920. * @param uniformName Name of the variable.
  29921. * @param vector4 Value to be set.
  29922. * @returns this effect.
  29923. */
  29924. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29925. /**
  29926. * Sets a float4 on a uniform variable.
  29927. * @param uniformName Name of the variable.
  29928. * @param x First float in float4.
  29929. * @param y Second float in float4.
  29930. * @param z Third float in float4.
  29931. * @param w Fourth float in float4.
  29932. * @returns this effect.
  29933. */
  29934. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29935. /**
  29936. * Sets a Color3 on a uniform variable.
  29937. * @param uniformName Name of the variable.
  29938. * @param color3 Value to be set.
  29939. * @returns this effect.
  29940. */
  29941. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29942. /**
  29943. * Sets a Color4 on a uniform variable.
  29944. * @param uniformName Name of the variable.
  29945. * @param color3 Value to be set.
  29946. * @param alpha Alpha value to be set.
  29947. * @returns this effect.
  29948. */
  29949. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29950. /**
  29951. * Sets a Color4 on a uniform variable
  29952. * @param uniformName defines the name of the variable
  29953. * @param color4 defines the value to be set
  29954. * @returns this effect.
  29955. */
  29956. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29957. /** Release all associated resources */
  29958. dispose(): void;
  29959. /**
  29960. * This function will add a new shader to the shader store
  29961. * @param name the name of the shader
  29962. * @param pixelShader optional pixel shader content
  29963. * @param vertexShader optional vertex shader content
  29964. */
  29965. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29966. /**
  29967. * Store of each shader (The can be looked up using effect.key)
  29968. */
  29969. static ShadersStore: {
  29970. [key: string]: string;
  29971. };
  29972. /**
  29973. * Store of each included file for a shader (The can be looked up using effect.key)
  29974. */
  29975. static IncludesShadersStore: {
  29976. [key: string]: string;
  29977. };
  29978. /**
  29979. * Resets the cache of effects.
  29980. */
  29981. static ResetCache(): void;
  29982. }
  29983. }
  29984. declare module BABYLON {
  29985. /**
  29986. * Interface used to describe the capabilities of the engine relatively to the current browser
  29987. */
  29988. export interface EngineCapabilities {
  29989. /** Maximum textures units per fragment shader */
  29990. maxTexturesImageUnits: number;
  29991. /** Maximum texture units per vertex shader */
  29992. maxVertexTextureImageUnits: number;
  29993. /** Maximum textures units in the entire pipeline */
  29994. maxCombinedTexturesImageUnits: number;
  29995. /** Maximum texture size */
  29996. maxTextureSize: number;
  29997. /** Maximum texture samples */
  29998. maxSamples?: number;
  29999. /** Maximum cube texture size */
  30000. maxCubemapTextureSize: number;
  30001. /** Maximum render texture size */
  30002. maxRenderTextureSize: number;
  30003. /** Maximum number of vertex attributes */
  30004. maxVertexAttribs: number;
  30005. /** Maximum number of varyings */
  30006. maxVaryingVectors: number;
  30007. /** Maximum number of uniforms per vertex shader */
  30008. maxVertexUniformVectors: number;
  30009. /** Maximum number of uniforms per fragment shader */
  30010. maxFragmentUniformVectors: number;
  30011. /** Defines if standard derivates (dx/dy) are supported */
  30012. standardDerivatives: boolean;
  30013. /** Defines if s3tc texture compression is supported */
  30014. s3tc?: WEBGL_compressed_texture_s3tc;
  30015. /** Defines if pvrtc texture compression is supported */
  30016. pvrtc: any;
  30017. /** Defines if etc1 texture compression is supported */
  30018. etc1: any;
  30019. /** Defines if etc2 texture compression is supported */
  30020. etc2: any;
  30021. /** Defines if astc texture compression is supported */
  30022. astc: any;
  30023. /** Defines if float textures are supported */
  30024. textureFloat: boolean;
  30025. /** Defines if vertex array objects are supported */
  30026. vertexArrayObject: boolean;
  30027. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30028. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30029. /** Gets the maximum level of anisotropy supported */
  30030. maxAnisotropy: number;
  30031. /** Defines if instancing is supported */
  30032. instancedArrays: boolean;
  30033. /** Defines if 32 bits indices are supported */
  30034. uintIndices: boolean;
  30035. /** Defines if high precision shaders are supported */
  30036. highPrecisionShaderSupported: boolean;
  30037. /** Defines if depth reading in the fragment shader is supported */
  30038. fragmentDepthSupported: boolean;
  30039. /** Defines if float texture linear filtering is supported*/
  30040. textureFloatLinearFiltering: boolean;
  30041. /** Defines if rendering to float textures is supported */
  30042. textureFloatRender: boolean;
  30043. /** Defines if half float textures are supported*/
  30044. textureHalfFloat: boolean;
  30045. /** Defines if half float texture linear filtering is supported*/
  30046. textureHalfFloatLinearFiltering: boolean;
  30047. /** Defines if rendering to half float textures is supported */
  30048. textureHalfFloatRender: boolean;
  30049. /** Defines if textureLOD shader command is supported */
  30050. textureLOD: boolean;
  30051. /** Defines if draw buffers extension is supported */
  30052. drawBuffersExtension: boolean;
  30053. /** Defines if depth textures are supported */
  30054. depthTextureExtension: boolean;
  30055. /** Defines if float color buffer are supported */
  30056. colorBufferFloat: boolean;
  30057. /** Gets disjoint timer query extension (null if not supported) */
  30058. timerQuery?: EXT_disjoint_timer_query;
  30059. /** Defines if timestamp can be used with timer query */
  30060. canUseTimestampForTimerQuery: boolean;
  30061. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30062. multiview?: any;
  30063. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30064. oculusMultiview?: any;
  30065. /** Function used to let the system compiles shaders in background */
  30066. parallelShaderCompile?: {
  30067. COMPLETION_STATUS_KHR: number;
  30068. };
  30069. /** Max number of texture samples for MSAA */
  30070. maxMSAASamples: number;
  30071. /** Defines if the blend min max extension is supported */
  30072. blendMinMax: boolean;
  30073. }
  30074. }
  30075. declare module BABYLON {
  30076. /**
  30077. * @hidden
  30078. **/
  30079. export class DepthCullingState {
  30080. private _isDepthTestDirty;
  30081. private _isDepthMaskDirty;
  30082. private _isDepthFuncDirty;
  30083. private _isCullFaceDirty;
  30084. private _isCullDirty;
  30085. private _isZOffsetDirty;
  30086. private _isFrontFaceDirty;
  30087. private _depthTest;
  30088. private _depthMask;
  30089. private _depthFunc;
  30090. private _cull;
  30091. private _cullFace;
  30092. private _zOffset;
  30093. private _frontFace;
  30094. /**
  30095. * Initializes the state.
  30096. */
  30097. constructor();
  30098. readonly isDirty: boolean;
  30099. zOffset: number;
  30100. cullFace: Nullable<number>;
  30101. cull: Nullable<boolean>;
  30102. depthFunc: Nullable<number>;
  30103. depthMask: boolean;
  30104. depthTest: boolean;
  30105. frontFace: Nullable<number>;
  30106. reset(): void;
  30107. apply(gl: WebGLRenderingContext): void;
  30108. }
  30109. }
  30110. declare module BABYLON {
  30111. /**
  30112. * @hidden
  30113. **/
  30114. export class StencilState {
  30115. /** 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 */
  30116. static readonly ALWAYS: number;
  30117. /** Passed to stencilOperation to specify that stencil value must be kept */
  30118. static readonly KEEP: number;
  30119. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30120. static readonly REPLACE: number;
  30121. private _isStencilTestDirty;
  30122. private _isStencilMaskDirty;
  30123. private _isStencilFuncDirty;
  30124. private _isStencilOpDirty;
  30125. private _stencilTest;
  30126. private _stencilMask;
  30127. private _stencilFunc;
  30128. private _stencilFuncRef;
  30129. private _stencilFuncMask;
  30130. private _stencilOpStencilFail;
  30131. private _stencilOpDepthFail;
  30132. private _stencilOpStencilDepthPass;
  30133. readonly isDirty: boolean;
  30134. stencilFunc: number;
  30135. stencilFuncRef: number;
  30136. stencilFuncMask: number;
  30137. stencilOpStencilFail: number;
  30138. stencilOpDepthFail: number;
  30139. stencilOpStencilDepthPass: number;
  30140. stencilMask: number;
  30141. stencilTest: boolean;
  30142. constructor();
  30143. reset(): void;
  30144. apply(gl: WebGLRenderingContext): void;
  30145. }
  30146. }
  30147. declare module BABYLON {
  30148. /**
  30149. * @hidden
  30150. **/
  30151. export class AlphaState {
  30152. private _isAlphaBlendDirty;
  30153. private _isBlendFunctionParametersDirty;
  30154. private _isBlendEquationParametersDirty;
  30155. private _isBlendConstantsDirty;
  30156. private _alphaBlend;
  30157. private _blendFunctionParameters;
  30158. private _blendEquationParameters;
  30159. private _blendConstants;
  30160. /**
  30161. * Initializes the state.
  30162. */
  30163. constructor();
  30164. readonly isDirty: boolean;
  30165. alphaBlend: boolean;
  30166. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30167. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30168. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30169. reset(): void;
  30170. apply(gl: WebGLRenderingContext): void;
  30171. }
  30172. }
  30173. declare module BABYLON {
  30174. /** @hidden */
  30175. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30176. attributeProcessor(attribute: string): string;
  30177. varyingProcessor(varying: string, isFragment: boolean): string;
  30178. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30179. }
  30180. }
  30181. declare module BABYLON {
  30182. /**
  30183. * Interface for attribute information associated with buffer instanciation
  30184. */
  30185. export interface InstancingAttributeInfo {
  30186. /**
  30187. * Name of the GLSL attribute
  30188. * if attribute index is not specified, this is used to retrieve the index from the effect
  30189. */
  30190. attributeName: string;
  30191. /**
  30192. * Index/offset of the attribute in the vertex shader
  30193. * if not specified, this will be computes from the name.
  30194. */
  30195. index?: number;
  30196. /**
  30197. * size of the attribute, 1, 2, 3 or 4
  30198. */
  30199. attributeSize: number;
  30200. /**
  30201. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30202. */
  30203. offset: number;
  30204. /**
  30205. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30206. * default to 1
  30207. */
  30208. divisor?: number;
  30209. /**
  30210. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30211. * default is FLOAT
  30212. */
  30213. attributeType?: number;
  30214. /**
  30215. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30216. */
  30217. normalized?: boolean;
  30218. }
  30219. }
  30220. declare module BABYLON {
  30221. interface ThinEngine {
  30222. /**
  30223. * Update a video texture
  30224. * @param texture defines the texture to update
  30225. * @param video defines the video element to use
  30226. * @param invertY defines if data must be stored with Y axis inverted
  30227. */
  30228. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30229. }
  30230. }
  30231. declare module BABYLON {
  30232. /**
  30233. * Settings for finer control over video usage
  30234. */
  30235. export interface VideoTextureSettings {
  30236. /**
  30237. * Applies `autoplay` to video, if specified
  30238. */
  30239. autoPlay?: boolean;
  30240. /**
  30241. * Applies `loop` to video, if specified
  30242. */
  30243. loop?: boolean;
  30244. /**
  30245. * Automatically updates internal texture from video at every frame in the render loop
  30246. */
  30247. autoUpdateTexture: boolean;
  30248. /**
  30249. * Image src displayed during the video loading or until the user interacts with the video.
  30250. */
  30251. poster?: string;
  30252. }
  30253. /**
  30254. * If you want to display a video in your scene, this is the special texture for that.
  30255. * This special texture works similar to other textures, with the exception of a few parameters.
  30256. * @see https://doc.babylonjs.com/how_to/video_texture
  30257. */
  30258. export class VideoTexture extends Texture {
  30259. /**
  30260. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30261. */
  30262. readonly autoUpdateTexture: boolean;
  30263. /**
  30264. * The video instance used by the texture internally
  30265. */
  30266. readonly video: HTMLVideoElement;
  30267. private _onUserActionRequestedObservable;
  30268. /**
  30269. * Event triggerd when a dom action is required by the user to play the video.
  30270. * This happens due to recent changes in browser policies preventing video to auto start.
  30271. */
  30272. readonly onUserActionRequestedObservable: Observable<Texture>;
  30273. private _generateMipMaps;
  30274. private _engine;
  30275. private _stillImageCaptured;
  30276. private _displayingPosterTexture;
  30277. private _settings;
  30278. private _createInternalTextureOnEvent;
  30279. private _frameId;
  30280. /**
  30281. * Creates a video texture.
  30282. * If you want to display a video in your scene, this is the special texture for that.
  30283. * This special texture works similar to other textures, with the exception of a few parameters.
  30284. * @see https://doc.babylonjs.com/how_to/video_texture
  30285. * @param name optional name, will detect from video source, if not defined
  30286. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30287. * @param scene is obviously the current scene.
  30288. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30289. * @param invertY is false by default but can be used to invert video on Y axis
  30290. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30291. * @param settings allows finer control over video usage
  30292. */
  30293. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30294. private _getName;
  30295. private _getVideo;
  30296. private _createInternalTexture;
  30297. private reset;
  30298. /**
  30299. * @hidden Internal method to initiate `update`.
  30300. */
  30301. _rebuild(): void;
  30302. /**
  30303. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30304. */
  30305. update(): void;
  30306. /**
  30307. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30308. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30309. */
  30310. updateTexture(isVisible: boolean): void;
  30311. protected _updateInternalTexture: () => void;
  30312. /**
  30313. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30314. * @param url New url.
  30315. */
  30316. updateURL(url: string): void;
  30317. /**
  30318. * Dispose the texture and release its associated resources.
  30319. */
  30320. dispose(): void;
  30321. /**
  30322. * Creates a video texture straight from a stream.
  30323. * @param scene Define the scene the texture should be created in
  30324. * @param stream Define the stream the texture should be created from
  30325. * @returns The created video texture as a promise
  30326. */
  30327. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30328. /**
  30329. * Creates a video texture straight from your WebCam video feed.
  30330. * @param scene Define the scene the texture should be created in
  30331. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30332. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30333. * @returns The created video texture as a promise
  30334. */
  30335. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30336. minWidth: number;
  30337. maxWidth: number;
  30338. minHeight: number;
  30339. maxHeight: number;
  30340. deviceId: string;
  30341. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30342. /**
  30343. * Creates a video texture straight from your WebCam video feed.
  30344. * @param scene Define the scene the texture should be created in
  30345. * @param onReady Define a callback to triggered once the texture will be ready
  30346. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30347. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30348. */
  30349. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30350. minWidth: number;
  30351. maxWidth: number;
  30352. minHeight: number;
  30353. maxHeight: number;
  30354. deviceId: string;
  30355. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30356. }
  30357. }
  30358. declare module BABYLON {
  30359. /**
  30360. * Defines the interface used by objects working like Scene
  30361. * @hidden
  30362. */
  30363. interface ISceneLike {
  30364. _addPendingData(data: any): void;
  30365. _removePendingData(data: any): void;
  30366. offlineProvider: IOfflineProvider;
  30367. }
  30368. /** Interface defining initialization parameters for Engine class */
  30369. export interface EngineOptions extends WebGLContextAttributes {
  30370. /**
  30371. * Defines if the engine should no exceed a specified device ratio
  30372. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30373. */
  30374. limitDeviceRatio?: number;
  30375. /**
  30376. * Defines if webvr should be enabled automatically
  30377. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30378. */
  30379. autoEnableWebVR?: boolean;
  30380. /**
  30381. * Defines if webgl2 should be turned off even if supported
  30382. * @see http://doc.babylonjs.com/features/webgl2
  30383. */
  30384. disableWebGL2Support?: boolean;
  30385. /**
  30386. * Defines if webaudio should be initialized as well
  30387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30388. */
  30389. audioEngine?: boolean;
  30390. /**
  30391. * Defines if animations should run using a deterministic lock step
  30392. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30393. */
  30394. deterministicLockstep?: boolean;
  30395. /** Defines the maximum steps to use with deterministic lock step mode */
  30396. lockstepMaxSteps?: number;
  30397. /** Defines the seconds between each deterministic lock step */
  30398. timeStep?: number;
  30399. /**
  30400. * Defines that engine should ignore context lost events
  30401. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30402. */
  30403. doNotHandleContextLost?: boolean;
  30404. /**
  30405. * Defines that engine should ignore modifying touch action attribute and style
  30406. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30407. */
  30408. doNotHandleTouchAction?: boolean;
  30409. /**
  30410. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30411. */
  30412. useHighPrecisionFloats?: boolean;
  30413. }
  30414. /**
  30415. * The base engine class (root of all engines)
  30416. */
  30417. export class ThinEngine {
  30418. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30419. static ExceptionList: ({
  30420. key: string;
  30421. capture: string;
  30422. captureConstraint: number;
  30423. targets: string[];
  30424. } | {
  30425. key: string;
  30426. capture: null;
  30427. captureConstraint: null;
  30428. targets: string[];
  30429. })[];
  30430. /** @hidden */
  30431. static _TextureLoaders: IInternalTextureLoader[];
  30432. /**
  30433. * Returns the current npm package of the sdk
  30434. */
  30435. static readonly NpmPackage: string;
  30436. /**
  30437. * Returns the current version of the framework
  30438. */
  30439. static readonly Version: string;
  30440. /**
  30441. * Returns a string describing the current engine
  30442. */
  30443. readonly description: string;
  30444. /**
  30445. * Gets or sets the epsilon value used by collision engine
  30446. */
  30447. static CollisionsEpsilon: number;
  30448. /**
  30449. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30450. */
  30451. static ShadersRepository: string;
  30452. /**
  30453. * Gets or sets the textures that the engine should not attempt to load as compressed
  30454. */
  30455. protected _excludedCompressedTextures: string[];
  30456. /**
  30457. * Filters the compressed texture formats to only include
  30458. * files that are not included in the skippable list
  30459. *
  30460. * @param url the current extension
  30461. * @param textureFormatInUse the current compressed texture format
  30462. * @returns "format" string
  30463. */
  30464. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30465. /** @hidden */
  30466. _shaderProcessor: IShaderProcessor;
  30467. /**
  30468. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30469. */
  30470. forcePOTTextures: boolean;
  30471. /**
  30472. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30473. */
  30474. isFullscreen: boolean;
  30475. /**
  30476. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30477. */
  30478. cullBackFaces: boolean;
  30479. /**
  30480. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30481. */
  30482. renderEvenInBackground: boolean;
  30483. /**
  30484. * Gets or sets a boolean indicating that cache can be kept between frames
  30485. */
  30486. preventCacheWipeBetweenFrames: boolean;
  30487. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30488. validateShaderPrograms: boolean;
  30489. /**
  30490. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30491. * This can provide greater z depth for distant objects.
  30492. */
  30493. useReverseDepthBuffer: boolean;
  30494. /**
  30495. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30496. */
  30497. disableUniformBuffers: boolean;
  30498. /** @hidden */
  30499. _uniformBuffers: UniformBuffer[];
  30500. /**
  30501. * Gets a boolean indicating that the engine supports uniform buffers
  30502. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30503. */
  30504. readonly supportsUniformBuffers: boolean;
  30505. /** @hidden */
  30506. _gl: WebGLRenderingContext;
  30507. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30508. protected _windowIsBackground: boolean;
  30509. protected _webGLVersion: number;
  30510. protected _creationOptions: EngineOptions;
  30511. protected _highPrecisionShadersAllowed: boolean;
  30512. /** @hidden */
  30513. readonly _shouldUseHighPrecisionShader: boolean;
  30514. /**
  30515. * Gets a boolean indicating that only power of 2 textures are supported
  30516. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30517. */
  30518. readonly needPOTTextures: boolean;
  30519. /** @hidden */
  30520. _badOS: boolean;
  30521. /** @hidden */
  30522. _badDesktopOS: boolean;
  30523. private _hardwareScalingLevel;
  30524. /** @hidden */
  30525. _caps: EngineCapabilities;
  30526. private _isStencilEnable;
  30527. private _glVersion;
  30528. private _glRenderer;
  30529. private _glVendor;
  30530. /** @hidden */
  30531. _videoTextureSupported: boolean;
  30532. protected _renderingQueueLaunched: boolean;
  30533. protected _activeRenderLoops: (() => void)[];
  30534. /**
  30535. * Observable signaled when a context lost event is raised
  30536. */
  30537. onContextLostObservable: Observable<ThinEngine>;
  30538. /**
  30539. * Observable signaled when a context restored event is raised
  30540. */
  30541. onContextRestoredObservable: Observable<ThinEngine>;
  30542. private _onContextLost;
  30543. private _onContextRestored;
  30544. protected _contextWasLost: boolean;
  30545. /** @hidden */
  30546. _doNotHandleContextLost: boolean;
  30547. /**
  30548. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30549. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30550. */
  30551. doNotHandleContextLost: boolean;
  30552. /**
  30553. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30554. */
  30555. disableVertexArrayObjects: boolean;
  30556. /** @hidden */
  30557. protected _colorWrite: boolean;
  30558. /** @hidden */
  30559. protected _colorWriteChanged: boolean;
  30560. /** @hidden */
  30561. protected _depthCullingState: DepthCullingState;
  30562. /** @hidden */
  30563. protected _stencilState: StencilState;
  30564. /** @hidden */
  30565. _alphaState: AlphaState;
  30566. /** @hidden */
  30567. _alphaMode: number;
  30568. /** @hidden */
  30569. _alphaEquation: number;
  30570. /** @hidden */
  30571. _internalTexturesCache: InternalTexture[];
  30572. /** @hidden */
  30573. protected _activeChannel: number;
  30574. private _currentTextureChannel;
  30575. /** @hidden */
  30576. protected _boundTexturesCache: {
  30577. [key: string]: Nullable<InternalTexture>;
  30578. };
  30579. /** @hidden */
  30580. protected _currentEffect: Nullable<Effect>;
  30581. /** @hidden */
  30582. protected _currentProgram: Nullable<WebGLProgram>;
  30583. private _compiledEffects;
  30584. private _vertexAttribArraysEnabled;
  30585. /** @hidden */
  30586. protected _cachedViewport: Nullable<IViewportLike>;
  30587. private _cachedVertexArrayObject;
  30588. /** @hidden */
  30589. protected _cachedVertexBuffers: any;
  30590. /** @hidden */
  30591. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30592. /** @hidden */
  30593. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30594. /** @hidden */
  30595. _currentRenderTarget: Nullable<InternalTexture>;
  30596. private _uintIndicesCurrentlySet;
  30597. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30598. /** @hidden */
  30599. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30600. private _currentBufferPointers;
  30601. private _currentInstanceLocations;
  30602. private _currentInstanceBuffers;
  30603. private _textureUnits;
  30604. /** @hidden */
  30605. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30606. /** @hidden */
  30607. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30608. /** @hidden */
  30609. _boundRenderFunction: any;
  30610. private _vaoRecordInProgress;
  30611. private _mustWipeVertexAttributes;
  30612. private _emptyTexture;
  30613. private _emptyCubeTexture;
  30614. private _emptyTexture3D;
  30615. private _emptyTexture2DArray;
  30616. /** @hidden */
  30617. _frameHandler: number;
  30618. private _nextFreeTextureSlots;
  30619. private _maxSimultaneousTextures;
  30620. private _activeRequests;
  30621. protected _texturesSupported: string[];
  30622. /** @hidden */
  30623. _textureFormatInUse: Nullable<string>;
  30624. protected readonly _supportsHardwareTextureRescaling: boolean;
  30625. /**
  30626. * Gets the list of texture formats supported
  30627. */
  30628. readonly texturesSupported: Array<string>;
  30629. /**
  30630. * Gets the list of texture formats in use
  30631. */
  30632. readonly textureFormatInUse: Nullable<string>;
  30633. /**
  30634. * Gets the current viewport
  30635. */
  30636. readonly currentViewport: Nullable<IViewportLike>;
  30637. /**
  30638. * Gets the default empty texture
  30639. */
  30640. readonly emptyTexture: InternalTexture;
  30641. /**
  30642. * Gets the default empty 3D texture
  30643. */
  30644. readonly emptyTexture3D: InternalTexture;
  30645. /**
  30646. * Gets the default empty 2D array texture
  30647. */
  30648. readonly emptyTexture2DArray: InternalTexture;
  30649. /**
  30650. * Gets the default empty cube texture
  30651. */
  30652. readonly emptyCubeTexture: InternalTexture;
  30653. /**
  30654. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30655. */
  30656. readonly premultipliedAlpha: boolean;
  30657. /**
  30658. * Observable event triggered before each texture is initialized
  30659. */
  30660. onBeforeTextureInitObservable: Observable<Texture>;
  30661. /**
  30662. * Creates a new engine
  30663. * @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
  30664. * @param antialias defines enable antialiasing (default: false)
  30665. * @param options defines further options to be sent to the getContext() function
  30666. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30667. */
  30668. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30669. private _rebuildInternalTextures;
  30670. private _rebuildEffects;
  30671. /**
  30672. * Gets a boolean indicating if all created effects are ready
  30673. * @returns true if all effects are ready
  30674. */
  30675. areAllEffectsReady(): boolean;
  30676. protected _rebuildBuffers(): void;
  30677. private _initGLContext;
  30678. /**
  30679. * Gets version of the current webGL context
  30680. */
  30681. readonly webGLVersion: number;
  30682. /**
  30683. * Gets a string idenfifying the name of the class
  30684. * @returns "Engine" string
  30685. */
  30686. getClassName(): string;
  30687. /**
  30688. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30689. */
  30690. readonly isStencilEnable: boolean;
  30691. /** @hidden */
  30692. _prepareWorkingCanvas(): void;
  30693. /**
  30694. * Reset the texture cache to empty state
  30695. */
  30696. resetTextureCache(): void;
  30697. /**
  30698. * Gets an object containing information about the current webGL context
  30699. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30700. */
  30701. getGlInfo(): {
  30702. vendor: string;
  30703. renderer: string;
  30704. version: string;
  30705. };
  30706. /**
  30707. * Defines the hardware scaling level.
  30708. * By default the hardware scaling level is computed from the window device ratio.
  30709. * 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.
  30710. * @param level defines the level to use
  30711. */
  30712. setHardwareScalingLevel(level: number): void;
  30713. /**
  30714. * Gets the current hardware scaling level.
  30715. * By default the hardware scaling level is computed from the window device ratio.
  30716. * 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.
  30717. * @returns a number indicating the current hardware scaling level
  30718. */
  30719. getHardwareScalingLevel(): number;
  30720. /**
  30721. * Gets the list of loaded textures
  30722. * @returns an array containing all loaded textures
  30723. */
  30724. getLoadedTexturesCache(): InternalTexture[];
  30725. /**
  30726. * Gets the object containing all engine capabilities
  30727. * @returns the EngineCapabilities object
  30728. */
  30729. getCaps(): EngineCapabilities;
  30730. /**
  30731. * stop executing a render loop function and remove it from the execution array
  30732. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30733. */
  30734. stopRenderLoop(renderFunction?: () => void): void;
  30735. /** @hidden */
  30736. _renderLoop(): void;
  30737. /**
  30738. * Gets the HTML canvas attached with the current webGL context
  30739. * @returns a HTML canvas
  30740. */
  30741. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30742. /**
  30743. * Gets host window
  30744. * @returns the host window object
  30745. */
  30746. getHostWindow(): Nullable<Window>;
  30747. /**
  30748. * Gets the current render width
  30749. * @param useScreen defines if screen size must be used (or the current render target if any)
  30750. * @returns a number defining the current render width
  30751. */
  30752. getRenderWidth(useScreen?: boolean): number;
  30753. /**
  30754. * Gets the current render height
  30755. * @param useScreen defines if screen size must be used (or the current render target if any)
  30756. * @returns a number defining the current render height
  30757. */
  30758. getRenderHeight(useScreen?: boolean): number;
  30759. /**
  30760. * Can be used to override the current requestAnimationFrame requester.
  30761. * @hidden
  30762. */
  30763. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30764. /**
  30765. * Register and execute a render loop. The engine can have more than one render function
  30766. * @param renderFunction defines the function to continuously execute
  30767. */
  30768. runRenderLoop(renderFunction: () => void): void;
  30769. /**
  30770. * Clear the current render buffer or the current render target (if any is set up)
  30771. * @param color defines the color to use
  30772. * @param backBuffer defines if the back buffer must be cleared
  30773. * @param depth defines if the depth buffer must be cleared
  30774. * @param stencil defines if the stencil buffer must be cleared
  30775. */
  30776. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30777. private _viewportCached;
  30778. /** @hidden */
  30779. _viewport(x: number, y: number, width: number, height: number): void;
  30780. /**
  30781. * Set the WebGL's viewport
  30782. * @param viewport defines the viewport element to be used
  30783. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30784. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30785. */
  30786. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30787. /**
  30788. * Begin a new frame
  30789. */
  30790. beginFrame(): void;
  30791. /**
  30792. * Enf the current frame
  30793. */
  30794. endFrame(): void;
  30795. /**
  30796. * Resize the view according to the canvas' size
  30797. */
  30798. resize(): void;
  30799. /**
  30800. * Force a specific size of the canvas
  30801. * @param width defines the new canvas' width
  30802. * @param height defines the new canvas' height
  30803. */
  30804. setSize(width: number, height: number): void;
  30805. /**
  30806. * Binds the frame buffer to the specified texture.
  30807. * @param texture The texture to render to or null for the default canvas
  30808. * @param faceIndex The face of the texture to render to in case of cube texture
  30809. * @param requiredWidth The width of the target to render to
  30810. * @param requiredHeight The height of the target to render to
  30811. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30812. * @param depthStencilTexture The depth stencil texture to use to render
  30813. * @param lodLevel defines le lod level to bind to the frame buffer
  30814. */
  30815. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30816. /** @hidden */
  30817. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30818. /**
  30819. * Unbind the current render target texture from the webGL context
  30820. * @param texture defines the render target texture to unbind
  30821. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30822. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30823. */
  30824. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30825. /**
  30826. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30827. */
  30828. flushFramebuffer(): void;
  30829. /**
  30830. * Unbind the current render target and bind the default framebuffer
  30831. */
  30832. restoreDefaultFramebuffer(): void;
  30833. /** @hidden */
  30834. protected _resetVertexBufferBinding(): void;
  30835. /**
  30836. * Creates a vertex buffer
  30837. * @param data the data for the vertex buffer
  30838. * @returns the new WebGL static buffer
  30839. */
  30840. createVertexBuffer(data: DataArray): DataBuffer;
  30841. private _createVertexBuffer;
  30842. /**
  30843. * Creates a dynamic vertex buffer
  30844. * @param data the data for the dynamic vertex buffer
  30845. * @returns the new WebGL dynamic buffer
  30846. */
  30847. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30848. protected _resetIndexBufferBinding(): void;
  30849. /**
  30850. * Creates a new index buffer
  30851. * @param indices defines the content of the index buffer
  30852. * @param updatable defines if the index buffer must be updatable
  30853. * @returns a new webGL buffer
  30854. */
  30855. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30856. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30857. /**
  30858. * Bind a webGL buffer to the webGL context
  30859. * @param buffer defines the buffer to bind
  30860. */
  30861. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30862. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30863. private bindBuffer;
  30864. /**
  30865. * update the bound buffer with the given data
  30866. * @param data defines the data to update
  30867. */
  30868. updateArrayBuffer(data: Float32Array): void;
  30869. private _vertexAttribPointer;
  30870. private _bindIndexBufferWithCache;
  30871. private _bindVertexBuffersAttributes;
  30872. /**
  30873. * Records a vertex array object
  30874. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30875. * @param vertexBuffers defines the list of vertex buffers to store
  30876. * @param indexBuffer defines the index buffer to store
  30877. * @param effect defines the effect to store
  30878. * @returns the new vertex array object
  30879. */
  30880. recordVertexArrayObject(vertexBuffers: {
  30881. [key: string]: VertexBuffer;
  30882. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30883. /**
  30884. * Bind a specific vertex array object
  30885. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30886. * @param vertexArrayObject defines the vertex array object to bind
  30887. * @param indexBuffer defines the index buffer to bind
  30888. */
  30889. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30890. /**
  30891. * Bind webGl buffers directly to the webGL context
  30892. * @param vertexBuffer defines the vertex buffer to bind
  30893. * @param indexBuffer defines the index buffer to bind
  30894. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30895. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30896. * @param effect defines the effect associated with the vertex buffer
  30897. */
  30898. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30899. private _unbindVertexArrayObject;
  30900. /**
  30901. * Bind a list of vertex buffers to the webGL context
  30902. * @param vertexBuffers defines the list of vertex buffers to bind
  30903. * @param indexBuffer defines the index buffer to bind
  30904. * @param effect defines the effect associated with the vertex buffers
  30905. */
  30906. bindBuffers(vertexBuffers: {
  30907. [key: string]: Nullable<VertexBuffer>;
  30908. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30909. /**
  30910. * Unbind all instance attributes
  30911. */
  30912. unbindInstanceAttributes(): void;
  30913. /**
  30914. * Release and free the memory of a vertex array object
  30915. * @param vao defines the vertex array object to delete
  30916. */
  30917. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30918. /** @hidden */
  30919. _releaseBuffer(buffer: DataBuffer): boolean;
  30920. protected _deleteBuffer(buffer: DataBuffer): void;
  30921. /**
  30922. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30923. * @param instancesBuffer defines the webGL buffer to update and bind
  30924. * @param data defines the data to store in the buffer
  30925. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30926. */
  30927. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30928. /**
  30929. * Bind the content of a webGL buffer used with instanciation
  30930. * @param instancesBuffer defines the webGL buffer to bind
  30931. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  30932. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  30933. */
  30934. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  30935. /**
  30936. * Disable the instance attribute corresponding to the name in parameter
  30937. * @param name defines the name of the attribute to disable
  30938. */
  30939. disableInstanceAttributeByName(name: string): void;
  30940. /**
  30941. * Disable the instance attribute corresponding to the location in parameter
  30942. * @param attributeLocation defines the attribute location of the attribute to disable
  30943. */
  30944. disableInstanceAttribute(attributeLocation: number): void;
  30945. /**
  30946. * Disable the attribute corresponding to the location in parameter
  30947. * @param attributeLocation defines the attribute location of the attribute to disable
  30948. */
  30949. disableAttributeByIndex(attributeLocation: number): void;
  30950. /**
  30951. * Send a draw order
  30952. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30953. * @param indexStart defines the starting index
  30954. * @param indexCount defines the number of index to draw
  30955. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30956. */
  30957. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30958. /**
  30959. * Draw a list of points
  30960. * @param verticesStart defines the index of first vertex to draw
  30961. * @param verticesCount defines the count of vertices to draw
  30962. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30963. */
  30964. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30965. /**
  30966. * Draw a list of unindexed primitives
  30967. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30968. * @param verticesStart defines the index of first vertex to draw
  30969. * @param verticesCount defines the count of vertices to draw
  30970. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30971. */
  30972. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30973. /**
  30974. * Draw a list of indexed primitives
  30975. * @param fillMode defines the primitive to use
  30976. * @param indexStart defines the starting index
  30977. * @param indexCount defines the number of index to draw
  30978. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30979. */
  30980. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30981. /**
  30982. * Draw a list of unindexed primitives
  30983. * @param fillMode defines the primitive to use
  30984. * @param verticesStart defines the index of first vertex to draw
  30985. * @param verticesCount defines the count of vertices to draw
  30986. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30987. */
  30988. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30989. private _drawMode;
  30990. /** @hidden */
  30991. protected _reportDrawCall(): void;
  30992. /** @hidden */
  30993. _releaseEffect(effect: Effect): void;
  30994. /** @hidden */
  30995. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30996. /**
  30997. * Create a new effect (used to store vertex/fragment shaders)
  30998. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30999. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31000. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31001. * @param samplers defines an array of string used to represent textures
  31002. * @param defines defines the string containing the defines to use to compile the shaders
  31003. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31004. * @param onCompiled defines a function to call when the effect creation is successful
  31005. * @param onError defines a function to call when the effect creation has failed
  31006. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31007. * @returns the new Effect
  31008. */
  31009. 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;
  31010. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31011. private _compileShader;
  31012. private _compileRawShader;
  31013. /**
  31014. * Directly creates a webGL program
  31015. * @param pipelineContext defines the pipeline context to attach to
  31016. * @param vertexCode defines the vertex shader code to use
  31017. * @param fragmentCode defines the fragment shader code to use
  31018. * @param context defines the webGL context to use (if not set, the current one will be used)
  31019. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31020. * @returns the new webGL program
  31021. */
  31022. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31023. /**
  31024. * Creates a webGL program
  31025. * @param pipelineContext defines the pipeline context to attach to
  31026. * @param vertexCode defines the vertex shader code to use
  31027. * @param fragmentCode defines the fragment shader code to use
  31028. * @param defines defines the string containing the defines to use to compile the shaders
  31029. * @param context defines the webGL context to use (if not set, the current one will be used)
  31030. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31031. * @returns the new webGL program
  31032. */
  31033. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31034. /**
  31035. * Creates a new pipeline context
  31036. * @returns the new pipeline
  31037. */
  31038. createPipelineContext(): IPipelineContext;
  31039. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31040. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31041. /** @hidden */
  31042. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31043. /** @hidden */
  31044. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31045. /** @hidden */
  31046. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31047. /**
  31048. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31049. * @param pipelineContext defines the pipeline context to use
  31050. * @param uniformsNames defines the list of uniform names
  31051. * @returns an array of webGL uniform locations
  31052. */
  31053. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31054. /**
  31055. * Gets the lsit of active attributes for a given webGL program
  31056. * @param pipelineContext defines the pipeline context to use
  31057. * @param attributesNames defines the list of attribute names to get
  31058. * @returns an array of indices indicating the offset of each attribute
  31059. */
  31060. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31061. /**
  31062. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31063. * @param effect defines the effect to activate
  31064. */
  31065. enableEffect(effect: Nullable<Effect>): void;
  31066. /**
  31067. * Set the value of an uniform to a number (int)
  31068. * @param uniform defines the webGL uniform location where to store the value
  31069. * @param value defines the int number to store
  31070. */
  31071. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31072. /**
  31073. * Set the value of an uniform to an array of int32
  31074. * @param uniform defines the webGL uniform location where to store the value
  31075. * @param array defines the array of int32 to store
  31076. */
  31077. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31078. /**
  31079. * Set the value of an uniform to an array of int32 (stored as vec2)
  31080. * @param uniform defines the webGL uniform location where to store the value
  31081. * @param array defines the array of int32 to store
  31082. */
  31083. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31084. /**
  31085. * Set the value of an uniform to an array of int32 (stored as vec3)
  31086. * @param uniform defines the webGL uniform location where to store the value
  31087. * @param array defines the array of int32 to store
  31088. */
  31089. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31090. /**
  31091. * Set the value of an uniform to an array of int32 (stored as vec4)
  31092. * @param uniform defines the webGL uniform location where to store the value
  31093. * @param array defines the array of int32 to store
  31094. */
  31095. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31096. /**
  31097. * Set the value of an uniform to an array of number
  31098. * @param uniform defines the webGL uniform location where to store the value
  31099. * @param array defines the array of number to store
  31100. */
  31101. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31102. /**
  31103. * Set the value of an uniform to an array of number (stored as vec2)
  31104. * @param uniform defines the webGL uniform location where to store the value
  31105. * @param array defines the array of number to store
  31106. */
  31107. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31108. /**
  31109. * Set the value of an uniform to an array of number (stored as vec3)
  31110. * @param uniform defines the webGL uniform location where to store the value
  31111. * @param array defines the array of number to store
  31112. */
  31113. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31114. /**
  31115. * Set the value of an uniform to an array of number (stored as vec4)
  31116. * @param uniform defines the webGL uniform location where to store the value
  31117. * @param array defines the array of number to store
  31118. */
  31119. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31120. /**
  31121. * Set the value of an uniform to an array of float32 (stored as matrices)
  31122. * @param uniform defines the webGL uniform location where to store the value
  31123. * @param matrices defines the array of float32 to store
  31124. */
  31125. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31126. /**
  31127. * Set the value of an uniform to a matrix (3x3)
  31128. * @param uniform defines the webGL uniform location where to store the value
  31129. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31130. */
  31131. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31132. /**
  31133. * Set the value of an uniform to a matrix (2x2)
  31134. * @param uniform defines the webGL uniform location where to store the value
  31135. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31136. */
  31137. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31138. /**
  31139. * Set the value of an uniform to a number (float)
  31140. * @param uniform defines the webGL uniform location where to store the value
  31141. * @param value defines the float number to store
  31142. */
  31143. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31144. /**
  31145. * Set the value of an uniform to a vec2
  31146. * @param uniform defines the webGL uniform location where to store the value
  31147. * @param x defines the 1st component of the value
  31148. * @param y defines the 2nd component of the value
  31149. */
  31150. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31151. /**
  31152. * Set the value of an uniform to a vec3
  31153. * @param uniform defines the webGL uniform location where to store the value
  31154. * @param x defines the 1st component of the value
  31155. * @param y defines the 2nd component of the value
  31156. * @param z defines the 3rd component of the value
  31157. */
  31158. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31159. /**
  31160. * Set the value of an uniform to a vec4
  31161. * @param uniform defines the webGL uniform location where to store the value
  31162. * @param x defines the 1st component of the value
  31163. * @param y defines the 2nd component of the value
  31164. * @param z defines the 3rd component of the value
  31165. * @param w defines the 4th component of the value
  31166. */
  31167. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31168. /**
  31169. * Apply all cached states (depth, culling, stencil and alpha)
  31170. */
  31171. applyStates(): void;
  31172. /**
  31173. * Enable or disable color writing
  31174. * @param enable defines the state to set
  31175. */
  31176. setColorWrite(enable: boolean): void;
  31177. /**
  31178. * Gets a boolean indicating if color writing is enabled
  31179. * @returns the current color writing state
  31180. */
  31181. getColorWrite(): boolean;
  31182. /**
  31183. * Gets the depth culling state manager
  31184. */
  31185. readonly depthCullingState: DepthCullingState;
  31186. /**
  31187. * Gets the alpha state manager
  31188. */
  31189. readonly alphaState: AlphaState;
  31190. /**
  31191. * Gets the stencil state manager
  31192. */
  31193. readonly stencilState: StencilState;
  31194. /**
  31195. * Clears the list of texture accessible through engine.
  31196. * This can help preventing texture load conflict due to name collision.
  31197. */
  31198. clearInternalTexturesCache(): void;
  31199. /**
  31200. * Force the entire cache to be cleared
  31201. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31202. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31203. */
  31204. wipeCaches(bruteForce?: boolean): void;
  31205. /** @hidden */
  31206. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31207. min: number;
  31208. mag: number;
  31209. };
  31210. /** @hidden */
  31211. _createTexture(): WebGLTexture;
  31212. /**
  31213. * Usually called from Texture.ts.
  31214. * Passed information to create a WebGLTexture
  31215. * @param urlArg defines a value which contains one of the following:
  31216. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31217. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31218. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31219. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31220. * @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)
  31221. * @param scene needed for loading to the correct scene
  31222. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31223. * @param onLoad optional callback to be called upon successful completion
  31224. * @param onError optional callback to be called upon failure
  31225. * @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
  31226. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31227. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31228. * @param forcedExtension defines the extension to use to pick the right loader
  31229. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31230. * @param mimeType defines an optional mime type
  31231. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31232. */
  31233. 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>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  31234. /**
  31235. * @hidden
  31236. */
  31237. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31238. /**
  31239. * Creates a raw texture
  31240. * @param data defines the data to store in the texture
  31241. * @param width defines the width of the texture
  31242. * @param height defines the height of the texture
  31243. * @param format defines the format of the data
  31244. * @param generateMipMaps defines if the engine should generate the mip levels
  31245. * @param invertY defines if data must be stored with Y axis inverted
  31246. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31247. * @param compression defines the compression used (null by default)
  31248. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31249. * @returns the raw texture inside an InternalTexture
  31250. */
  31251. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31252. /**
  31253. * Creates a new raw cube texture
  31254. * @param data defines the array of data to use to create each face
  31255. * @param size defines the size of the textures
  31256. * @param format defines the format of the data
  31257. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31258. * @param generateMipMaps defines if the engine should generate the mip levels
  31259. * @param invertY defines if data must be stored with Y axis inverted
  31260. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31261. * @param compression defines the compression used (null by default)
  31262. * @returns the cube texture as an InternalTexture
  31263. */
  31264. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31265. /**
  31266. * Creates a new raw 3D texture
  31267. * @param data defines the data used to create the texture
  31268. * @param width defines the width of the texture
  31269. * @param height defines the height of the texture
  31270. * @param depth defines the depth of the texture
  31271. * @param format defines the format of the texture
  31272. * @param generateMipMaps defines if the engine must generate mip levels
  31273. * @param invertY defines if data must be stored with Y axis inverted
  31274. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31275. * @param compression defines the compressed used (can be null)
  31276. * @param textureType defines the compressed used (can be null)
  31277. * @returns a new raw 3D texture (stored in an InternalTexture)
  31278. */
  31279. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31280. /**
  31281. * Creates a new raw 2D array texture
  31282. * @param data defines the data used to create the texture
  31283. * @param width defines the width of the texture
  31284. * @param height defines the height of the texture
  31285. * @param depth defines the number of layers of the texture
  31286. * @param format defines the format of the texture
  31287. * @param generateMipMaps defines if the engine must generate mip levels
  31288. * @param invertY defines if data must be stored with Y axis inverted
  31289. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31290. * @param compression defines the compressed used (can be null)
  31291. * @param textureType defines the compressed used (can be null)
  31292. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31293. */
  31294. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31295. private _unpackFlipYCached;
  31296. /**
  31297. * In case you are sharing the context with other applications, it might
  31298. * be interested to not cache the unpack flip y state to ensure a consistent
  31299. * value would be set.
  31300. */
  31301. enableUnpackFlipYCached: boolean;
  31302. /** @hidden */
  31303. _unpackFlipY(value: boolean): void;
  31304. /** @hidden */
  31305. _getUnpackAlignement(): number;
  31306. private _getTextureTarget;
  31307. /**
  31308. * Update the sampling mode of a given texture
  31309. * @param samplingMode defines the required sampling mode
  31310. * @param texture defines the texture to update
  31311. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31312. */
  31313. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31314. /**
  31315. * Update the sampling mode of a given texture
  31316. * @param texture defines the texture to update
  31317. * @param wrapU defines the texture wrap mode of the u coordinates
  31318. * @param wrapV defines the texture wrap mode of the v coordinates
  31319. * @param wrapR defines the texture wrap mode of the r coordinates
  31320. */
  31321. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31322. /** @hidden */
  31323. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31324. width: number;
  31325. height: number;
  31326. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31327. /** @hidden */
  31328. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31329. /** @hidden */
  31330. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31331. /** @hidden */
  31332. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31333. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31334. private _prepareWebGLTexture;
  31335. /** @hidden */
  31336. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31337. private _getDepthStencilBuffer;
  31338. /** @hidden */
  31339. _releaseFramebufferObjects(texture: InternalTexture): void;
  31340. /** @hidden */
  31341. _releaseTexture(texture: InternalTexture): void;
  31342. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31343. protected _setProgram(program: WebGLProgram): void;
  31344. protected _boundUniforms: {
  31345. [key: number]: WebGLUniformLocation;
  31346. };
  31347. /**
  31348. * Binds an effect to the webGL context
  31349. * @param effect defines the effect to bind
  31350. */
  31351. bindSamplers(effect: Effect): void;
  31352. private _activateCurrentTexture;
  31353. /** @hidden */
  31354. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31355. /** @hidden */
  31356. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31357. /**
  31358. * Unbind all textures from the webGL context
  31359. */
  31360. unbindAllTextures(): void;
  31361. /**
  31362. * Sets a texture to the according uniform.
  31363. * @param channel The texture channel
  31364. * @param uniform The uniform to set
  31365. * @param texture The texture to apply
  31366. */
  31367. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31368. private _bindSamplerUniformToChannel;
  31369. private _getTextureWrapMode;
  31370. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31371. /**
  31372. * Sets an array of texture to the webGL context
  31373. * @param channel defines the channel where the texture array must be set
  31374. * @param uniform defines the associated uniform location
  31375. * @param textures defines the array of textures to bind
  31376. */
  31377. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31378. /** @hidden */
  31379. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31380. private _setTextureParameterFloat;
  31381. private _setTextureParameterInteger;
  31382. /**
  31383. * Unbind all vertex attributes from the webGL context
  31384. */
  31385. unbindAllAttributes(): void;
  31386. /**
  31387. * 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
  31388. */
  31389. releaseEffects(): void;
  31390. /**
  31391. * Dispose and release all associated resources
  31392. */
  31393. dispose(): void;
  31394. /**
  31395. * Attach a new callback raised when context lost event is fired
  31396. * @param callback defines the callback to call
  31397. */
  31398. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31399. /**
  31400. * Attach a new callback raised when context restored event is fired
  31401. * @param callback defines the callback to call
  31402. */
  31403. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31404. /**
  31405. * Get the current error code of the webGL context
  31406. * @returns the error code
  31407. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31408. */
  31409. getError(): number;
  31410. private _canRenderToFloatFramebuffer;
  31411. private _canRenderToHalfFloatFramebuffer;
  31412. private _canRenderToFramebuffer;
  31413. /** @hidden */
  31414. _getWebGLTextureType(type: number): number;
  31415. /** @hidden */
  31416. _getInternalFormat(format: number): number;
  31417. /** @hidden */
  31418. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31419. /** @hidden */
  31420. _getRGBAMultiSampleBufferFormat(type: number): number;
  31421. /** @hidden */
  31422. _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;
  31423. /**
  31424. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31425. * @param x defines the x coordinate of the rectangle where pixels must be read
  31426. * @param y defines the y coordinate of the rectangle where pixels must be read
  31427. * @param width defines the width of the rectangle where pixels must be read
  31428. * @param height defines the height of the rectangle where pixels must be read
  31429. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  31430. * @returns a Uint8Array containing RGBA colors
  31431. */
  31432. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31433. /**
  31434. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31435. * @returns true if the engine can be created
  31436. * @ignorenaming
  31437. */
  31438. static isSupported(): boolean;
  31439. /**
  31440. * Find the next highest power of two.
  31441. * @param x Number to start search from.
  31442. * @return Next highest power of two.
  31443. */
  31444. static CeilingPOT(x: number): number;
  31445. /**
  31446. * Find the next lowest power of two.
  31447. * @param x Number to start search from.
  31448. * @return Next lowest power of two.
  31449. */
  31450. static FloorPOT(x: number): number;
  31451. /**
  31452. * Find the nearest power of two.
  31453. * @param x Number to start search from.
  31454. * @return Next nearest power of two.
  31455. */
  31456. static NearestPOT(x: number): number;
  31457. /**
  31458. * Get the closest exponent of two
  31459. * @param value defines the value to approximate
  31460. * @param max defines the maximum value to return
  31461. * @param mode defines how to define the closest value
  31462. * @returns closest exponent of two of the given value
  31463. */
  31464. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31465. /**
  31466. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31467. * @param func - the function to be called
  31468. * @param requester - the object that will request the next frame. Falls back to window.
  31469. * @returns frame number
  31470. */
  31471. static QueueNewFrame(func: () => void, requester?: any): number;
  31472. /**
  31473. * Gets host document
  31474. * @returns the host document object
  31475. */
  31476. getHostDocument(): Document;
  31477. }
  31478. }
  31479. declare module BABYLON {
  31480. /**
  31481. * Class representing spherical harmonics coefficients to the 3rd degree
  31482. */
  31483. export class SphericalHarmonics {
  31484. /**
  31485. * Defines whether or not the harmonics have been prescaled for rendering.
  31486. */
  31487. preScaled: boolean;
  31488. /**
  31489. * The l0,0 coefficients of the spherical harmonics
  31490. */
  31491. l00: Vector3;
  31492. /**
  31493. * The l1,-1 coefficients of the spherical harmonics
  31494. */
  31495. l1_1: Vector3;
  31496. /**
  31497. * The l1,0 coefficients of the spherical harmonics
  31498. */
  31499. l10: Vector3;
  31500. /**
  31501. * The l1,1 coefficients of the spherical harmonics
  31502. */
  31503. l11: Vector3;
  31504. /**
  31505. * The l2,-2 coefficients of the spherical harmonics
  31506. */
  31507. l2_2: Vector3;
  31508. /**
  31509. * The l2,-1 coefficients of the spherical harmonics
  31510. */
  31511. l2_1: Vector3;
  31512. /**
  31513. * The l2,0 coefficients of the spherical harmonics
  31514. */
  31515. l20: Vector3;
  31516. /**
  31517. * The l2,1 coefficients of the spherical harmonics
  31518. */
  31519. l21: Vector3;
  31520. /**
  31521. * The l2,2 coefficients of the spherical harmonics
  31522. */
  31523. l22: Vector3;
  31524. /**
  31525. * Adds a light to the spherical harmonics
  31526. * @param direction the direction of the light
  31527. * @param color the color of the light
  31528. * @param deltaSolidAngle the delta solid angle of the light
  31529. */
  31530. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31531. /**
  31532. * Scales the spherical harmonics by the given amount
  31533. * @param scale the amount to scale
  31534. */
  31535. scaleInPlace(scale: number): void;
  31536. /**
  31537. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31538. *
  31539. * ```
  31540. * E_lm = A_l * L_lm
  31541. * ```
  31542. *
  31543. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31544. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31545. * the scaling factors are given in equation 9.
  31546. */
  31547. convertIncidentRadianceToIrradiance(): void;
  31548. /**
  31549. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31550. *
  31551. * ```
  31552. * L = (1/pi) * E * rho
  31553. * ```
  31554. *
  31555. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31556. */
  31557. convertIrradianceToLambertianRadiance(): void;
  31558. /**
  31559. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31560. * required operations at run time.
  31561. *
  31562. * This is simply done by scaling back the SH with Ylm constants parameter.
  31563. * The trigonometric part being applied by the shader at run time.
  31564. */
  31565. preScaleForRendering(): void;
  31566. /**
  31567. * Constructs a spherical harmonics from an array.
  31568. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31569. * @returns the spherical harmonics
  31570. */
  31571. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31572. /**
  31573. * Gets the spherical harmonics from polynomial
  31574. * @param polynomial the spherical polynomial
  31575. * @returns the spherical harmonics
  31576. */
  31577. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31578. }
  31579. /**
  31580. * Class representing spherical polynomial coefficients to the 3rd degree
  31581. */
  31582. export class SphericalPolynomial {
  31583. private _harmonics;
  31584. /**
  31585. * The spherical harmonics used to create the polynomials.
  31586. */
  31587. readonly preScaledHarmonics: SphericalHarmonics;
  31588. /**
  31589. * The x coefficients of the spherical polynomial
  31590. */
  31591. x: Vector3;
  31592. /**
  31593. * The y coefficients of the spherical polynomial
  31594. */
  31595. y: Vector3;
  31596. /**
  31597. * The z coefficients of the spherical polynomial
  31598. */
  31599. z: Vector3;
  31600. /**
  31601. * The xx coefficients of the spherical polynomial
  31602. */
  31603. xx: Vector3;
  31604. /**
  31605. * The yy coefficients of the spherical polynomial
  31606. */
  31607. yy: Vector3;
  31608. /**
  31609. * The zz coefficients of the spherical polynomial
  31610. */
  31611. zz: Vector3;
  31612. /**
  31613. * The xy coefficients of the spherical polynomial
  31614. */
  31615. xy: Vector3;
  31616. /**
  31617. * The yz coefficients of the spherical polynomial
  31618. */
  31619. yz: Vector3;
  31620. /**
  31621. * The zx coefficients of the spherical polynomial
  31622. */
  31623. zx: Vector3;
  31624. /**
  31625. * Adds an ambient color to the spherical polynomial
  31626. * @param color the color to add
  31627. */
  31628. addAmbient(color: Color3): void;
  31629. /**
  31630. * Scales the spherical polynomial by the given amount
  31631. * @param scale the amount to scale
  31632. */
  31633. scaleInPlace(scale: number): void;
  31634. /**
  31635. * Gets the spherical polynomial from harmonics
  31636. * @param harmonics the spherical harmonics
  31637. * @returns the spherical polynomial
  31638. */
  31639. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31640. /**
  31641. * Constructs a spherical polynomial from an array.
  31642. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31643. * @returns the spherical polynomial
  31644. */
  31645. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31646. }
  31647. }
  31648. declare module BABYLON {
  31649. /**
  31650. * Defines the source of the internal texture
  31651. */
  31652. export enum InternalTextureSource {
  31653. /**
  31654. * The source of the texture data is unknown
  31655. */
  31656. Unknown = 0,
  31657. /**
  31658. * Texture data comes from an URL
  31659. */
  31660. Url = 1,
  31661. /**
  31662. * Texture data is only used for temporary storage
  31663. */
  31664. Temp = 2,
  31665. /**
  31666. * Texture data comes from raw data (ArrayBuffer)
  31667. */
  31668. Raw = 3,
  31669. /**
  31670. * Texture content is dynamic (video or dynamic texture)
  31671. */
  31672. Dynamic = 4,
  31673. /**
  31674. * Texture content is generated by rendering to it
  31675. */
  31676. RenderTarget = 5,
  31677. /**
  31678. * Texture content is part of a multi render target process
  31679. */
  31680. MultiRenderTarget = 6,
  31681. /**
  31682. * Texture data comes from a cube data file
  31683. */
  31684. Cube = 7,
  31685. /**
  31686. * Texture data comes from a raw cube data
  31687. */
  31688. CubeRaw = 8,
  31689. /**
  31690. * Texture data come from a prefiltered cube data file
  31691. */
  31692. CubePrefiltered = 9,
  31693. /**
  31694. * Texture content is raw 3D data
  31695. */
  31696. Raw3D = 10,
  31697. /**
  31698. * Texture content is raw 2D array data
  31699. */
  31700. Raw2DArray = 11,
  31701. /**
  31702. * Texture content is a depth texture
  31703. */
  31704. Depth = 12,
  31705. /**
  31706. * Texture data comes from a raw cube data encoded with RGBD
  31707. */
  31708. CubeRawRGBD = 13
  31709. }
  31710. /**
  31711. * Class used to store data associated with WebGL texture data for the engine
  31712. * This class should not be used directly
  31713. */
  31714. export class InternalTexture {
  31715. /** @hidden */
  31716. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31717. /**
  31718. * Defines if the texture is ready
  31719. */
  31720. isReady: boolean;
  31721. /**
  31722. * Defines if the texture is a cube texture
  31723. */
  31724. isCube: boolean;
  31725. /**
  31726. * Defines if the texture contains 3D data
  31727. */
  31728. is3D: boolean;
  31729. /**
  31730. * Defines if the texture contains 2D array data
  31731. */
  31732. is2DArray: boolean;
  31733. /**
  31734. * Defines if the texture contains multiview data
  31735. */
  31736. isMultiview: boolean;
  31737. /**
  31738. * Gets the URL used to load this texture
  31739. */
  31740. url: string;
  31741. /**
  31742. * Gets the sampling mode of the texture
  31743. */
  31744. samplingMode: number;
  31745. /**
  31746. * Gets a boolean indicating if the texture needs mipmaps generation
  31747. */
  31748. generateMipMaps: boolean;
  31749. /**
  31750. * Gets the number of samples used by the texture (WebGL2+ only)
  31751. */
  31752. samples: number;
  31753. /**
  31754. * Gets the type of the texture (int, float...)
  31755. */
  31756. type: number;
  31757. /**
  31758. * Gets the format of the texture (RGB, RGBA...)
  31759. */
  31760. format: number;
  31761. /**
  31762. * Observable called when the texture is loaded
  31763. */
  31764. onLoadedObservable: Observable<InternalTexture>;
  31765. /**
  31766. * Gets the width of the texture
  31767. */
  31768. width: number;
  31769. /**
  31770. * Gets the height of the texture
  31771. */
  31772. height: number;
  31773. /**
  31774. * Gets the depth of the texture
  31775. */
  31776. depth: number;
  31777. /**
  31778. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31779. */
  31780. baseWidth: number;
  31781. /**
  31782. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31783. */
  31784. baseHeight: number;
  31785. /**
  31786. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31787. */
  31788. baseDepth: number;
  31789. /**
  31790. * Gets a boolean indicating if the texture is inverted on Y axis
  31791. */
  31792. invertY: boolean;
  31793. /** @hidden */
  31794. _invertVScale: boolean;
  31795. /** @hidden */
  31796. _associatedChannel: number;
  31797. /** @hidden */
  31798. _source: InternalTextureSource;
  31799. /** @hidden */
  31800. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31801. /** @hidden */
  31802. _bufferView: Nullable<ArrayBufferView>;
  31803. /** @hidden */
  31804. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31805. /** @hidden */
  31806. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31807. /** @hidden */
  31808. _size: number;
  31809. /** @hidden */
  31810. _extension: string;
  31811. /** @hidden */
  31812. _files: Nullable<string[]>;
  31813. /** @hidden */
  31814. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31815. /** @hidden */
  31816. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31817. /** @hidden */
  31818. _framebuffer: Nullable<WebGLFramebuffer>;
  31819. /** @hidden */
  31820. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31821. /** @hidden */
  31822. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31823. /** @hidden */
  31824. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31825. /** @hidden */
  31826. _attachments: Nullable<number[]>;
  31827. /** @hidden */
  31828. _cachedCoordinatesMode: Nullable<number>;
  31829. /** @hidden */
  31830. _cachedWrapU: Nullable<number>;
  31831. /** @hidden */
  31832. _cachedWrapV: Nullable<number>;
  31833. /** @hidden */
  31834. _cachedWrapR: Nullable<number>;
  31835. /** @hidden */
  31836. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31837. /** @hidden */
  31838. _isDisabled: boolean;
  31839. /** @hidden */
  31840. _compression: Nullable<string>;
  31841. /** @hidden */
  31842. _generateStencilBuffer: boolean;
  31843. /** @hidden */
  31844. _generateDepthBuffer: boolean;
  31845. /** @hidden */
  31846. _comparisonFunction: number;
  31847. /** @hidden */
  31848. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31849. /** @hidden */
  31850. _lodGenerationScale: number;
  31851. /** @hidden */
  31852. _lodGenerationOffset: number;
  31853. /** @hidden */
  31854. _colorTextureArray: Nullable<WebGLTexture>;
  31855. /** @hidden */
  31856. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31857. /** @hidden */
  31858. _lodTextureHigh: Nullable<BaseTexture>;
  31859. /** @hidden */
  31860. _lodTextureMid: Nullable<BaseTexture>;
  31861. /** @hidden */
  31862. _lodTextureLow: Nullable<BaseTexture>;
  31863. /** @hidden */
  31864. _isRGBD: boolean;
  31865. /** @hidden */
  31866. _linearSpecularLOD: boolean;
  31867. /** @hidden */
  31868. _irradianceTexture: Nullable<BaseTexture>;
  31869. /** @hidden */
  31870. _webGLTexture: Nullable<WebGLTexture>;
  31871. /** @hidden */
  31872. _references: number;
  31873. private _engine;
  31874. /**
  31875. * Gets the Engine the texture belongs to.
  31876. * @returns The babylon engine
  31877. */
  31878. getEngine(): ThinEngine;
  31879. /**
  31880. * Gets the data source type of the texture
  31881. */
  31882. readonly source: InternalTextureSource;
  31883. /**
  31884. * Creates a new InternalTexture
  31885. * @param engine defines the engine to use
  31886. * @param source defines the type of data that will be used
  31887. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31888. */
  31889. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31890. /**
  31891. * Increments the number of references (ie. the number of Texture that point to it)
  31892. */
  31893. incrementReferences(): void;
  31894. /**
  31895. * Change the size of the texture (not the size of the content)
  31896. * @param width defines the new width
  31897. * @param height defines the new height
  31898. * @param depth defines the new depth (1 by default)
  31899. */
  31900. updateSize(width: int, height: int, depth?: int): void;
  31901. /** @hidden */
  31902. _rebuild(): void;
  31903. /** @hidden */
  31904. _swapAndDie(target: InternalTexture): void;
  31905. /**
  31906. * Dispose the current allocated resources
  31907. */
  31908. dispose(): void;
  31909. }
  31910. }
  31911. declare module BABYLON {
  31912. /**
  31913. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31914. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31915. */
  31916. export class Analyser {
  31917. /**
  31918. * Gets or sets the smoothing
  31919. * @ignorenaming
  31920. */
  31921. SMOOTHING: number;
  31922. /**
  31923. * Gets or sets the FFT table size
  31924. * @ignorenaming
  31925. */
  31926. FFT_SIZE: number;
  31927. /**
  31928. * Gets or sets the bar graph amplitude
  31929. * @ignorenaming
  31930. */
  31931. BARGRAPHAMPLITUDE: number;
  31932. /**
  31933. * Gets or sets the position of the debug canvas
  31934. * @ignorenaming
  31935. */
  31936. DEBUGCANVASPOS: {
  31937. x: number;
  31938. y: number;
  31939. };
  31940. /**
  31941. * Gets or sets the debug canvas size
  31942. * @ignorenaming
  31943. */
  31944. DEBUGCANVASSIZE: {
  31945. width: number;
  31946. height: number;
  31947. };
  31948. private _byteFreqs;
  31949. private _byteTime;
  31950. private _floatFreqs;
  31951. private _webAudioAnalyser;
  31952. private _debugCanvas;
  31953. private _debugCanvasContext;
  31954. private _scene;
  31955. private _registerFunc;
  31956. private _audioEngine;
  31957. /**
  31958. * Creates a new analyser
  31959. * @param scene defines hosting scene
  31960. */
  31961. constructor(scene: Scene);
  31962. /**
  31963. * Get the number of data values you will have to play with for the visualization
  31964. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31965. * @returns a number
  31966. */
  31967. getFrequencyBinCount(): number;
  31968. /**
  31969. * Gets the current frequency data as a byte array
  31970. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31971. * @returns a Uint8Array
  31972. */
  31973. getByteFrequencyData(): Uint8Array;
  31974. /**
  31975. * Gets the current waveform as a byte array
  31976. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31977. * @returns a Uint8Array
  31978. */
  31979. getByteTimeDomainData(): Uint8Array;
  31980. /**
  31981. * Gets the current frequency data as a float array
  31982. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31983. * @returns a Float32Array
  31984. */
  31985. getFloatFrequencyData(): Float32Array;
  31986. /**
  31987. * Renders the debug canvas
  31988. */
  31989. drawDebugCanvas(): void;
  31990. /**
  31991. * Stops rendering the debug canvas and removes it
  31992. */
  31993. stopDebugCanvas(): void;
  31994. /**
  31995. * Connects two audio nodes
  31996. * @param inputAudioNode defines first node to connect
  31997. * @param outputAudioNode defines second node to connect
  31998. */
  31999. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32000. /**
  32001. * Releases all associated resources
  32002. */
  32003. dispose(): void;
  32004. }
  32005. }
  32006. declare module BABYLON {
  32007. /**
  32008. * This represents an audio engine and it is responsible
  32009. * to play, synchronize and analyse sounds throughout the application.
  32010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32011. */
  32012. export interface IAudioEngine extends IDisposable {
  32013. /**
  32014. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32015. */
  32016. readonly canUseWebAudio: boolean;
  32017. /**
  32018. * Gets the current AudioContext if available.
  32019. */
  32020. readonly audioContext: Nullable<AudioContext>;
  32021. /**
  32022. * The master gain node defines the global audio volume of your audio engine.
  32023. */
  32024. readonly masterGain: GainNode;
  32025. /**
  32026. * Gets whether or not mp3 are supported by your browser.
  32027. */
  32028. readonly isMP3supported: boolean;
  32029. /**
  32030. * Gets whether or not ogg are supported by your browser.
  32031. */
  32032. readonly isOGGsupported: boolean;
  32033. /**
  32034. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32035. * @ignoreNaming
  32036. */
  32037. WarnedWebAudioUnsupported: boolean;
  32038. /**
  32039. * Defines if the audio engine relies on a custom unlocked button.
  32040. * In this case, the embedded button will not be displayed.
  32041. */
  32042. useCustomUnlockedButton: boolean;
  32043. /**
  32044. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32045. */
  32046. readonly unlocked: boolean;
  32047. /**
  32048. * Event raised when audio has been unlocked on the browser.
  32049. */
  32050. onAudioUnlockedObservable: Observable<AudioEngine>;
  32051. /**
  32052. * Event raised when audio has been locked on the browser.
  32053. */
  32054. onAudioLockedObservable: Observable<AudioEngine>;
  32055. /**
  32056. * Flags the audio engine in Locked state.
  32057. * This happens due to new browser policies preventing audio to autoplay.
  32058. */
  32059. lock(): void;
  32060. /**
  32061. * Unlocks the audio engine once a user action has been done on the dom.
  32062. * This is helpful to resume play once browser policies have been satisfied.
  32063. */
  32064. unlock(): void;
  32065. }
  32066. /**
  32067. * This represents the default audio engine used in babylon.
  32068. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32070. */
  32071. export class AudioEngine implements IAudioEngine {
  32072. private _audioContext;
  32073. private _audioContextInitialized;
  32074. private _muteButton;
  32075. private _hostElement;
  32076. /**
  32077. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32078. */
  32079. canUseWebAudio: boolean;
  32080. /**
  32081. * The master gain node defines the global audio volume of your audio engine.
  32082. */
  32083. masterGain: GainNode;
  32084. /**
  32085. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32086. * @ignoreNaming
  32087. */
  32088. WarnedWebAudioUnsupported: boolean;
  32089. /**
  32090. * Gets whether or not mp3 are supported by your browser.
  32091. */
  32092. isMP3supported: boolean;
  32093. /**
  32094. * Gets whether or not ogg are supported by your browser.
  32095. */
  32096. isOGGsupported: boolean;
  32097. /**
  32098. * Gets whether audio has been unlocked on the device.
  32099. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32100. * a user interaction has happened.
  32101. */
  32102. unlocked: boolean;
  32103. /**
  32104. * Defines if the audio engine relies on a custom unlocked button.
  32105. * In this case, the embedded button will not be displayed.
  32106. */
  32107. useCustomUnlockedButton: boolean;
  32108. /**
  32109. * Event raised when audio has been unlocked on the browser.
  32110. */
  32111. onAudioUnlockedObservable: Observable<AudioEngine>;
  32112. /**
  32113. * Event raised when audio has been locked on the browser.
  32114. */
  32115. onAudioLockedObservable: Observable<AudioEngine>;
  32116. /**
  32117. * Gets the current AudioContext if available.
  32118. */
  32119. readonly audioContext: Nullable<AudioContext>;
  32120. private _connectedAnalyser;
  32121. /**
  32122. * Instantiates a new audio engine.
  32123. *
  32124. * There should be only one per page as some browsers restrict the number
  32125. * of audio contexts you can create.
  32126. * @param hostElement defines the host element where to display the mute icon if necessary
  32127. */
  32128. constructor(hostElement?: Nullable<HTMLElement>);
  32129. /**
  32130. * Flags the audio engine in Locked state.
  32131. * This happens due to new browser policies preventing audio to autoplay.
  32132. */
  32133. lock(): void;
  32134. /**
  32135. * Unlocks the audio engine once a user action has been done on the dom.
  32136. * This is helpful to resume play once browser policies have been satisfied.
  32137. */
  32138. unlock(): void;
  32139. private _resumeAudioContext;
  32140. private _initializeAudioContext;
  32141. private _tryToRun;
  32142. private _triggerRunningState;
  32143. private _triggerSuspendedState;
  32144. private _displayMuteButton;
  32145. private _moveButtonToTopLeft;
  32146. private _onResize;
  32147. private _hideMuteButton;
  32148. /**
  32149. * Destroy and release the resources associated with the audio ccontext.
  32150. */
  32151. dispose(): void;
  32152. /**
  32153. * Gets the global volume sets on the master gain.
  32154. * @returns the global volume if set or -1 otherwise
  32155. */
  32156. getGlobalVolume(): number;
  32157. /**
  32158. * Sets the global volume of your experience (sets on the master gain).
  32159. * @param newVolume Defines the new global volume of the application
  32160. */
  32161. setGlobalVolume(newVolume: number): void;
  32162. /**
  32163. * Connect the audio engine to an audio analyser allowing some amazing
  32164. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32166. * @param analyser The analyser to connect to the engine
  32167. */
  32168. connectToAnalyser(analyser: Analyser): void;
  32169. }
  32170. }
  32171. declare module BABYLON {
  32172. /**
  32173. * Interface used to present a loading screen while loading a scene
  32174. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32175. */
  32176. export interface ILoadingScreen {
  32177. /**
  32178. * Function called to display the loading screen
  32179. */
  32180. displayLoadingUI: () => void;
  32181. /**
  32182. * Function called to hide the loading screen
  32183. */
  32184. hideLoadingUI: () => void;
  32185. /**
  32186. * Gets or sets the color to use for the background
  32187. */
  32188. loadingUIBackgroundColor: string;
  32189. /**
  32190. * Gets or sets the text to display while loading
  32191. */
  32192. loadingUIText: string;
  32193. }
  32194. /**
  32195. * Class used for the default loading screen
  32196. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32197. */
  32198. export class DefaultLoadingScreen implements ILoadingScreen {
  32199. private _renderingCanvas;
  32200. private _loadingText;
  32201. private _loadingDivBackgroundColor;
  32202. private _loadingDiv;
  32203. private _loadingTextDiv;
  32204. /** Gets or sets the logo url to use for the default loading screen */
  32205. static DefaultLogoUrl: string;
  32206. /** Gets or sets the spinner url to use for the default loading screen */
  32207. static DefaultSpinnerUrl: string;
  32208. /**
  32209. * Creates a new default loading screen
  32210. * @param _renderingCanvas defines the canvas used to render the scene
  32211. * @param _loadingText defines the default text to display
  32212. * @param _loadingDivBackgroundColor defines the default background color
  32213. */
  32214. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32215. /**
  32216. * Function called to display the loading screen
  32217. */
  32218. displayLoadingUI(): void;
  32219. /**
  32220. * Function called to hide the loading screen
  32221. */
  32222. hideLoadingUI(): void;
  32223. /**
  32224. * Gets or sets the text to display while loading
  32225. */
  32226. loadingUIText: string;
  32227. /**
  32228. * Gets or sets the color to use for the background
  32229. */
  32230. loadingUIBackgroundColor: string;
  32231. private _resizeLoadingUI;
  32232. }
  32233. }
  32234. declare module BABYLON {
  32235. /**
  32236. * Interface for any object that can request an animation frame
  32237. */
  32238. export interface ICustomAnimationFrameRequester {
  32239. /**
  32240. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32241. */
  32242. renderFunction?: Function;
  32243. /**
  32244. * Called to request the next frame to render to
  32245. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32246. */
  32247. requestAnimationFrame: Function;
  32248. /**
  32249. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32250. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32251. */
  32252. requestID?: number;
  32253. }
  32254. }
  32255. declare module BABYLON {
  32256. /**
  32257. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32258. */
  32259. export class PerformanceMonitor {
  32260. private _enabled;
  32261. private _rollingFrameTime;
  32262. private _lastFrameTimeMs;
  32263. /**
  32264. * constructor
  32265. * @param frameSampleSize The number of samples required to saturate the sliding window
  32266. */
  32267. constructor(frameSampleSize?: number);
  32268. /**
  32269. * Samples current frame
  32270. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32271. */
  32272. sampleFrame(timeMs?: number): void;
  32273. /**
  32274. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32275. */
  32276. readonly averageFrameTime: number;
  32277. /**
  32278. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32279. */
  32280. readonly averageFrameTimeVariance: number;
  32281. /**
  32282. * Returns the frame time of the most recent frame
  32283. */
  32284. readonly instantaneousFrameTime: number;
  32285. /**
  32286. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32287. */
  32288. readonly averageFPS: number;
  32289. /**
  32290. * Returns the average framerate in frames per second using the most recent frame time
  32291. */
  32292. readonly instantaneousFPS: number;
  32293. /**
  32294. * Returns true if enough samples have been taken to completely fill the sliding window
  32295. */
  32296. readonly isSaturated: boolean;
  32297. /**
  32298. * Enables contributions to the sliding window sample set
  32299. */
  32300. enable(): void;
  32301. /**
  32302. * Disables contributions to the sliding window sample set
  32303. * Samples will not be interpolated over the disabled period
  32304. */
  32305. disable(): void;
  32306. /**
  32307. * Returns true if sampling is enabled
  32308. */
  32309. readonly isEnabled: boolean;
  32310. /**
  32311. * Resets performance monitor
  32312. */
  32313. reset(): void;
  32314. }
  32315. /**
  32316. * RollingAverage
  32317. *
  32318. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32319. */
  32320. export class RollingAverage {
  32321. /**
  32322. * Current average
  32323. */
  32324. average: number;
  32325. /**
  32326. * Current variance
  32327. */
  32328. variance: number;
  32329. protected _samples: Array<number>;
  32330. protected _sampleCount: number;
  32331. protected _pos: number;
  32332. protected _m2: number;
  32333. /**
  32334. * constructor
  32335. * @param length The number of samples required to saturate the sliding window
  32336. */
  32337. constructor(length: number);
  32338. /**
  32339. * Adds a sample to the sample set
  32340. * @param v The sample value
  32341. */
  32342. add(v: number): void;
  32343. /**
  32344. * Returns previously added values or null if outside of history or outside the sliding window domain
  32345. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32346. * @return Value previously recorded with add() or null if outside of range
  32347. */
  32348. history(i: number): number;
  32349. /**
  32350. * Returns true if enough samples have been taken to completely fill the sliding window
  32351. * @return true if sample-set saturated
  32352. */
  32353. isSaturated(): boolean;
  32354. /**
  32355. * Resets the rolling average (equivalent to 0 samples taken so far)
  32356. */
  32357. reset(): void;
  32358. /**
  32359. * Wraps a value around the sample range boundaries
  32360. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32361. * @return Wrapped position in sample range
  32362. */
  32363. protected _wrapPosition(i: number): number;
  32364. }
  32365. }
  32366. declare module BABYLON {
  32367. /**
  32368. * This class is used to track a performance counter which is number based.
  32369. * The user has access to many properties which give statistics of different nature.
  32370. *
  32371. * The implementer can track two kinds of Performance Counter: time and count.
  32372. * 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.
  32373. * 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.
  32374. */
  32375. export class PerfCounter {
  32376. /**
  32377. * Gets or sets a global boolean to turn on and off all the counters
  32378. */
  32379. static Enabled: boolean;
  32380. /**
  32381. * Returns the smallest value ever
  32382. */
  32383. readonly min: number;
  32384. /**
  32385. * Returns the biggest value ever
  32386. */
  32387. readonly max: number;
  32388. /**
  32389. * Returns the average value since the performance counter is running
  32390. */
  32391. readonly average: number;
  32392. /**
  32393. * Returns the average value of the last second the counter was monitored
  32394. */
  32395. readonly lastSecAverage: number;
  32396. /**
  32397. * Returns the current value
  32398. */
  32399. readonly current: number;
  32400. /**
  32401. * Gets the accumulated total
  32402. */
  32403. readonly total: number;
  32404. /**
  32405. * Gets the total value count
  32406. */
  32407. readonly count: number;
  32408. /**
  32409. * Creates a new counter
  32410. */
  32411. constructor();
  32412. /**
  32413. * Call this method to start monitoring a new frame.
  32414. * 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.
  32415. */
  32416. fetchNewFrame(): void;
  32417. /**
  32418. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32419. * @param newCount the count value to add to the monitored count
  32420. * @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.
  32421. */
  32422. addCount(newCount: number, fetchResult: boolean): void;
  32423. /**
  32424. * Start monitoring this performance counter
  32425. */
  32426. beginMonitoring(): void;
  32427. /**
  32428. * Compute the time lapsed since the previous beginMonitoring() call.
  32429. * @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
  32430. */
  32431. endMonitoring(newFrame?: boolean): void;
  32432. private _fetchResult;
  32433. private _startMonitoringTime;
  32434. private _min;
  32435. private _max;
  32436. private _average;
  32437. private _current;
  32438. private _totalValueCount;
  32439. private _totalAccumulated;
  32440. private _lastSecAverage;
  32441. private _lastSecAccumulated;
  32442. private _lastSecTime;
  32443. private _lastSecValueCount;
  32444. }
  32445. }
  32446. declare module BABYLON {
  32447. interface ThinEngine {
  32448. /**
  32449. * Sets alpha constants used by some alpha blending modes
  32450. * @param r defines the red component
  32451. * @param g defines the green component
  32452. * @param b defines the blue component
  32453. * @param a defines the alpha component
  32454. */
  32455. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32456. /**
  32457. * Sets the current alpha mode
  32458. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32459. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32460. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32461. */
  32462. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32463. /**
  32464. * Gets the current alpha mode
  32465. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32466. * @returns the current alpha mode
  32467. */
  32468. getAlphaMode(): number;
  32469. /**
  32470. * Sets the current alpha equation
  32471. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32472. */
  32473. setAlphaEquation(equation: number): void;
  32474. /**
  32475. * Gets the current alpha equation.
  32476. * @returns the current alpha equation
  32477. */
  32478. getAlphaEquation(): number;
  32479. }
  32480. }
  32481. declare module BABYLON {
  32482. /**
  32483. * Defines the interface used by display changed events
  32484. */
  32485. export interface IDisplayChangedEventArgs {
  32486. /** Gets the vrDisplay object (if any) */
  32487. vrDisplay: Nullable<any>;
  32488. /** Gets a boolean indicating if webVR is supported */
  32489. vrSupported: boolean;
  32490. }
  32491. /**
  32492. * Defines the interface used by objects containing a viewport (like a camera)
  32493. */
  32494. interface IViewportOwnerLike {
  32495. /**
  32496. * Gets or sets the viewport
  32497. */
  32498. viewport: IViewportLike;
  32499. }
  32500. /**
  32501. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32502. */
  32503. export class Engine extends ThinEngine {
  32504. /** Defines that alpha blending is disabled */
  32505. static readonly ALPHA_DISABLE: number;
  32506. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32507. static readonly ALPHA_ADD: number;
  32508. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32509. static readonly ALPHA_COMBINE: number;
  32510. /** Defines that alpha blending to DEST - SRC * DEST */
  32511. static readonly ALPHA_SUBTRACT: number;
  32512. /** Defines that alpha blending to SRC * DEST */
  32513. static readonly ALPHA_MULTIPLY: number;
  32514. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32515. static readonly ALPHA_MAXIMIZED: number;
  32516. /** Defines that alpha blending to SRC + DEST */
  32517. static readonly ALPHA_ONEONE: number;
  32518. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32519. static readonly ALPHA_PREMULTIPLIED: number;
  32520. /**
  32521. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32522. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32523. */
  32524. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32525. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32526. static readonly ALPHA_INTERPOLATE: number;
  32527. /**
  32528. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32529. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32530. */
  32531. static readonly ALPHA_SCREENMODE: number;
  32532. /** Defines that the ressource is not delayed*/
  32533. static readonly DELAYLOADSTATE_NONE: number;
  32534. /** Defines that the ressource was successfully delay loaded */
  32535. static readonly DELAYLOADSTATE_LOADED: number;
  32536. /** Defines that the ressource is currently delay loading */
  32537. static readonly DELAYLOADSTATE_LOADING: number;
  32538. /** Defines that the ressource is delayed and has not started loading */
  32539. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32540. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32541. static readonly NEVER: number;
  32542. /** 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 */
  32543. static readonly ALWAYS: number;
  32544. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32545. static readonly LESS: number;
  32546. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32547. static readonly EQUAL: number;
  32548. /** 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 */
  32549. static readonly LEQUAL: number;
  32550. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32551. static readonly GREATER: number;
  32552. /** 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 */
  32553. static readonly GEQUAL: number;
  32554. /** 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 */
  32555. static readonly NOTEQUAL: number;
  32556. /** Passed to stencilOperation to specify that stencil value must be kept */
  32557. static readonly KEEP: number;
  32558. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32559. static readonly REPLACE: number;
  32560. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32561. static readonly INCR: number;
  32562. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32563. static readonly DECR: number;
  32564. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32565. static readonly INVERT: number;
  32566. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32567. static readonly INCR_WRAP: number;
  32568. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32569. static readonly DECR_WRAP: number;
  32570. /** Texture is not repeating outside of 0..1 UVs */
  32571. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32572. /** Texture is repeating outside of 0..1 UVs */
  32573. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32574. /** Texture is repeating and mirrored */
  32575. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32576. /** ALPHA */
  32577. static readonly TEXTUREFORMAT_ALPHA: number;
  32578. /** LUMINANCE */
  32579. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32580. /** LUMINANCE_ALPHA */
  32581. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32582. /** RGB */
  32583. static readonly TEXTUREFORMAT_RGB: number;
  32584. /** RGBA */
  32585. static readonly TEXTUREFORMAT_RGBA: number;
  32586. /** RED */
  32587. static readonly TEXTUREFORMAT_RED: number;
  32588. /** RED (2nd reference) */
  32589. static readonly TEXTUREFORMAT_R: number;
  32590. /** RG */
  32591. static readonly TEXTUREFORMAT_RG: number;
  32592. /** RED_INTEGER */
  32593. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32594. /** RED_INTEGER (2nd reference) */
  32595. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32596. /** RG_INTEGER */
  32597. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32598. /** RGB_INTEGER */
  32599. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32600. /** RGBA_INTEGER */
  32601. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32602. /** UNSIGNED_BYTE */
  32603. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32604. /** UNSIGNED_BYTE (2nd reference) */
  32605. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32606. /** FLOAT */
  32607. static readonly TEXTURETYPE_FLOAT: number;
  32608. /** HALF_FLOAT */
  32609. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32610. /** BYTE */
  32611. static readonly TEXTURETYPE_BYTE: number;
  32612. /** SHORT */
  32613. static readonly TEXTURETYPE_SHORT: number;
  32614. /** UNSIGNED_SHORT */
  32615. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32616. /** INT */
  32617. static readonly TEXTURETYPE_INT: number;
  32618. /** UNSIGNED_INT */
  32619. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32620. /** UNSIGNED_SHORT_4_4_4_4 */
  32621. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32622. /** UNSIGNED_SHORT_5_5_5_1 */
  32623. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32624. /** UNSIGNED_SHORT_5_6_5 */
  32625. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32626. /** UNSIGNED_INT_2_10_10_10_REV */
  32627. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32628. /** UNSIGNED_INT_24_8 */
  32629. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32630. /** UNSIGNED_INT_10F_11F_11F_REV */
  32631. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32632. /** UNSIGNED_INT_5_9_9_9_REV */
  32633. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32634. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32635. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32636. /** nearest is mag = nearest and min = nearest and mip = linear */
  32637. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32638. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32639. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32640. /** Trilinear is mag = linear and min = linear and mip = linear */
  32641. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32642. /** nearest is mag = nearest and min = nearest and mip = linear */
  32643. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32644. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32645. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32646. /** Trilinear is mag = linear and min = linear and mip = linear */
  32647. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32648. /** mag = nearest and min = nearest and mip = nearest */
  32649. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32650. /** mag = nearest and min = linear and mip = nearest */
  32651. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32652. /** mag = nearest and min = linear and mip = linear */
  32653. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32654. /** mag = nearest and min = linear and mip = none */
  32655. static readonly TEXTURE_NEAREST_LINEAR: number;
  32656. /** mag = nearest and min = nearest and mip = none */
  32657. static readonly TEXTURE_NEAREST_NEAREST: number;
  32658. /** mag = linear and min = nearest and mip = nearest */
  32659. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32660. /** mag = linear and min = nearest and mip = linear */
  32661. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32662. /** mag = linear and min = linear and mip = none */
  32663. static readonly TEXTURE_LINEAR_LINEAR: number;
  32664. /** mag = linear and min = nearest and mip = none */
  32665. static readonly TEXTURE_LINEAR_NEAREST: number;
  32666. /** Explicit coordinates mode */
  32667. static readonly TEXTURE_EXPLICIT_MODE: number;
  32668. /** Spherical coordinates mode */
  32669. static readonly TEXTURE_SPHERICAL_MODE: number;
  32670. /** Planar coordinates mode */
  32671. static readonly TEXTURE_PLANAR_MODE: number;
  32672. /** Cubic coordinates mode */
  32673. static readonly TEXTURE_CUBIC_MODE: number;
  32674. /** Projection coordinates mode */
  32675. static readonly TEXTURE_PROJECTION_MODE: number;
  32676. /** Skybox coordinates mode */
  32677. static readonly TEXTURE_SKYBOX_MODE: number;
  32678. /** Inverse Cubic coordinates mode */
  32679. static readonly TEXTURE_INVCUBIC_MODE: number;
  32680. /** Equirectangular coordinates mode */
  32681. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32682. /** Equirectangular Fixed coordinates mode */
  32683. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32684. /** Equirectangular Fixed Mirrored coordinates mode */
  32685. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32686. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32687. static readonly SCALEMODE_FLOOR: number;
  32688. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32689. static readonly SCALEMODE_NEAREST: number;
  32690. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32691. static readonly SCALEMODE_CEILING: number;
  32692. /**
  32693. * Returns the current npm package of the sdk
  32694. */
  32695. static readonly NpmPackage: string;
  32696. /**
  32697. * Returns the current version of the framework
  32698. */
  32699. static readonly Version: string;
  32700. /** Gets the list of created engines */
  32701. static readonly Instances: Engine[];
  32702. /**
  32703. * Gets the latest created engine
  32704. */
  32705. static readonly LastCreatedEngine: Nullable<Engine>;
  32706. /**
  32707. * Gets the latest created scene
  32708. */
  32709. static readonly LastCreatedScene: Nullable<Scene>;
  32710. /**
  32711. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32712. * @param flag defines which part of the materials must be marked as dirty
  32713. * @param predicate defines a predicate used to filter which materials should be affected
  32714. */
  32715. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32716. /**
  32717. * Method called to create the default loading screen.
  32718. * This can be overriden in your own app.
  32719. * @param canvas The rendering canvas element
  32720. * @returns The loading screen
  32721. */
  32722. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32723. /**
  32724. * Method called to create the default rescale post process on each engine.
  32725. */
  32726. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32727. /**
  32728. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32729. **/
  32730. enableOfflineSupport: boolean;
  32731. /**
  32732. * 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)
  32733. **/
  32734. disableManifestCheck: boolean;
  32735. /**
  32736. * Gets the list of created scenes
  32737. */
  32738. scenes: Scene[];
  32739. /**
  32740. * Event raised when a new scene is created
  32741. */
  32742. onNewSceneAddedObservable: Observable<Scene>;
  32743. /**
  32744. * Gets the list of created postprocesses
  32745. */
  32746. postProcesses: PostProcess[];
  32747. /**
  32748. * Gets a boolean indicating if the pointer is currently locked
  32749. */
  32750. isPointerLock: boolean;
  32751. /**
  32752. * Observable event triggered each time the rendering canvas is resized
  32753. */
  32754. onResizeObservable: Observable<Engine>;
  32755. /**
  32756. * Observable event triggered each time the canvas loses focus
  32757. */
  32758. onCanvasBlurObservable: Observable<Engine>;
  32759. /**
  32760. * Observable event triggered each time the canvas gains focus
  32761. */
  32762. onCanvasFocusObservable: Observable<Engine>;
  32763. /**
  32764. * Observable event triggered each time the canvas receives pointerout event
  32765. */
  32766. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32767. /**
  32768. * Observable raised when the engine begins a new frame
  32769. */
  32770. onBeginFrameObservable: Observable<Engine>;
  32771. /**
  32772. * If set, will be used to request the next animation frame for the render loop
  32773. */
  32774. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32775. /**
  32776. * Observable raised when the engine ends the current frame
  32777. */
  32778. onEndFrameObservable: Observable<Engine>;
  32779. /**
  32780. * Observable raised when the engine is about to compile a shader
  32781. */
  32782. onBeforeShaderCompilationObservable: Observable<Engine>;
  32783. /**
  32784. * Observable raised when the engine has jsut compiled a shader
  32785. */
  32786. onAfterShaderCompilationObservable: Observable<Engine>;
  32787. /**
  32788. * Gets the audio engine
  32789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32790. * @ignorenaming
  32791. */
  32792. static audioEngine: IAudioEngine;
  32793. /**
  32794. * Default AudioEngine factory responsible of creating the Audio Engine.
  32795. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32796. */
  32797. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32798. /**
  32799. * Default offline support factory responsible of creating a tool used to store data locally.
  32800. * By default, this will create a Database object if the workload has been embedded.
  32801. */
  32802. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32803. private _loadingScreen;
  32804. private _pointerLockRequested;
  32805. private _dummyFramebuffer;
  32806. private _rescalePostProcess;
  32807. private _deterministicLockstep;
  32808. private _lockstepMaxSteps;
  32809. private _timeStep;
  32810. protected readonly _supportsHardwareTextureRescaling: boolean;
  32811. private _fps;
  32812. private _deltaTime;
  32813. /** @hidden */
  32814. _drawCalls: PerfCounter;
  32815. /**
  32816. * Turn this value on if you want to pause FPS computation when in background
  32817. */
  32818. disablePerformanceMonitorInBackground: boolean;
  32819. private _performanceMonitor;
  32820. /**
  32821. * Gets the performance monitor attached to this engine
  32822. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32823. */
  32824. readonly performanceMonitor: PerformanceMonitor;
  32825. private _onFocus;
  32826. private _onBlur;
  32827. private _onCanvasPointerOut;
  32828. private _onCanvasBlur;
  32829. private _onCanvasFocus;
  32830. private _onFullscreenChange;
  32831. private _onPointerLockChange;
  32832. /**
  32833. * Gets the HTML element used to attach event listeners
  32834. * @returns a HTML element
  32835. */
  32836. getInputElement(): Nullable<HTMLElement>;
  32837. /**
  32838. * Creates a new engine
  32839. * @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
  32840. * @param antialias defines enable antialiasing (default: false)
  32841. * @param options defines further options to be sent to the getContext() function
  32842. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32843. */
  32844. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32845. /**
  32846. * Gets current aspect ratio
  32847. * @param viewportOwner defines the camera to use to get the aspect ratio
  32848. * @param useScreen defines if screen size must be used (or the current render target if any)
  32849. * @returns a number defining the aspect ratio
  32850. */
  32851. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32852. /**
  32853. * Gets current screen aspect ratio
  32854. * @returns a number defining the aspect ratio
  32855. */
  32856. getScreenAspectRatio(): number;
  32857. /**
  32858. * Gets the client rect of the HTML canvas attached with the current webGL context
  32859. * @returns a client rectanglee
  32860. */
  32861. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32862. /**
  32863. * Gets the client rect of the HTML element used for events
  32864. * @returns a client rectanglee
  32865. */
  32866. getInputElementClientRect(): Nullable<ClientRect>;
  32867. /**
  32868. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32869. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32870. * @returns true if engine is in deterministic lock step mode
  32871. */
  32872. isDeterministicLockStep(): boolean;
  32873. /**
  32874. * Gets the max steps when engine is running in deterministic lock step
  32875. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32876. * @returns the max steps
  32877. */
  32878. getLockstepMaxSteps(): number;
  32879. /**
  32880. * Returns the time in ms between steps when using deterministic lock step.
  32881. * @returns time step in (ms)
  32882. */
  32883. getTimeStep(): number;
  32884. /**
  32885. * Force the mipmap generation for the given render target texture
  32886. * @param texture defines the render target texture to use
  32887. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  32888. */
  32889. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  32890. /** States */
  32891. /**
  32892. * Set various states to the webGL context
  32893. * @param culling defines backface culling state
  32894. * @param zOffset defines the value to apply to zOffset (0 by default)
  32895. * @param force defines if states must be applied even if cache is up to date
  32896. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32897. */
  32898. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32899. /**
  32900. * Set the z offset to apply to current rendering
  32901. * @param value defines the offset to apply
  32902. */
  32903. setZOffset(value: number): void;
  32904. /**
  32905. * Gets the current value of the zOffset
  32906. * @returns the current zOffset state
  32907. */
  32908. getZOffset(): number;
  32909. /**
  32910. * Enable or disable depth buffering
  32911. * @param enable defines the state to set
  32912. */
  32913. setDepthBuffer(enable: boolean): void;
  32914. /**
  32915. * Gets a boolean indicating if depth writing is enabled
  32916. * @returns the current depth writing state
  32917. */
  32918. getDepthWrite(): boolean;
  32919. /**
  32920. * Enable or disable depth writing
  32921. * @param enable defines the state to set
  32922. */
  32923. setDepthWrite(enable: boolean): void;
  32924. /**
  32925. * Gets a boolean indicating if stencil buffer is enabled
  32926. * @returns the current stencil buffer state
  32927. */
  32928. getStencilBuffer(): boolean;
  32929. /**
  32930. * Enable or disable the stencil buffer
  32931. * @param enable defines if the stencil buffer must be enabled or disabled
  32932. */
  32933. setStencilBuffer(enable: boolean): void;
  32934. /**
  32935. * Gets the current stencil mask
  32936. * @returns a number defining the new stencil mask to use
  32937. */
  32938. getStencilMask(): number;
  32939. /**
  32940. * Sets the current stencil mask
  32941. * @param mask defines the new stencil mask to use
  32942. */
  32943. setStencilMask(mask: number): void;
  32944. /**
  32945. * Gets the current stencil function
  32946. * @returns a number defining the stencil function to use
  32947. */
  32948. getStencilFunction(): number;
  32949. /**
  32950. * Gets the current stencil reference value
  32951. * @returns a number defining the stencil reference value to use
  32952. */
  32953. getStencilFunctionReference(): number;
  32954. /**
  32955. * Gets the current stencil mask
  32956. * @returns a number defining the stencil mask to use
  32957. */
  32958. getStencilFunctionMask(): number;
  32959. /**
  32960. * Sets the current stencil function
  32961. * @param stencilFunc defines the new stencil function to use
  32962. */
  32963. setStencilFunction(stencilFunc: number): void;
  32964. /**
  32965. * Sets the current stencil reference
  32966. * @param reference defines the new stencil reference to use
  32967. */
  32968. setStencilFunctionReference(reference: number): void;
  32969. /**
  32970. * Sets the current stencil mask
  32971. * @param mask defines the new stencil mask to use
  32972. */
  32973. setStencilFunctionMask(mask: number): void;
  32974. /**
  32975. * Gets the current stencil operation when stencil fails
  32976. * @returns a number defining stencil operation to use when stencil fails
  32977. */
  32978. getStencilOperationFail(): number;
  32979. /**
  32980. * Gets the current stencil operation when depth fails
  32981. * @returns a number defining stencil operation to use when depth fails
  32982. */
  32983. getStencilOperationDepthFail(): number;
  32984. /**
  32985. * Gets the current stencil operation when stencil passes
  32986. * @returns a number defining stencil operation to use when stencil passes
  32987. */
  32988. getStencilOperationPass(): number;
  32989. /**
  32990. * Sets the stencil operation to use when stencil fails
  32991. * @param operation defines the stencil operation to use when stencil fails
  32992. */
  32993. setStencilOperationFail(operation: number): void;
  32994. /**
  32995. * Sets the stencil operation to use when depth fails
  32996. * @param operation defines the stencil operation to use when depth fails
  32997. */
  32998. setStencilOperationDepthFail(operation: number): void;
  32999. /**
  33000. * Sets the stencil operation to use when stencil passes
  33001. * @param operation defines the stencil operation to use when stencil passes
  33002. */
  33003. setStencilOperationPass(operation: number): void;
  33004. /**
  33005. * Sets a boolean indicating if the dithering state is enabled or disabled
  33006. * @param value defines the dithering state
  33007. */
  33008. setDitheringState(value: boolean): void;
  33009. /**
  33010. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33011. * @param value defines the rasterizer state
  33012. */
  33013. setRasterizerState(value: boolean): void;
  33014. /**
  33015. * Gets the current depth function
  33016. * @returns a number defining the depth function
  33017. */
  33018. getDepthFunction(): Nullable<number>;
  33019. /**
  33020. * Sets the current depth function
  33021. * @param depthFunc defines the function to use
  33022. */
  33023. setDepthFunction(depthFunc: number): void;
  33024. /**
  33025. * Sets the current depth function to GREATER
  33026. */
  33027. setDepthFunctionToGreater(): void;
  33028. /**
  33029. * Sets the current depth function to GEQUAL
  33030. */
  33031. setDepthFunctionToGreaterOrEqual(): void;
  33032. /**
  33033. * Sets the current depth function to LESS
  33034. */
  33035. setDepthFunctionToLess(): void;
  33036. /**
  33037. * Sets the current depth function to LEQUAL
  33038. */
  33039. setDepthFunctionToLessOrEqual(): void;
  33040. private _cachedStencilBuffer;
  33041. private _cachedStencilFunction;
  33042. private _cachedStencilMask;
  33043. private _cachedStencilOperationPass;
  33044. private _cachedStencilOperationFail;
  33045. private _cachedStencilOperationDepthFail;
  33046. private _cachedStencilReference;
  33047. /**
  33048. * Caches the the state of the stencil buffer
  33049. */
  33050. cacheStencilState(): void;
  33051. /**
  33052. * Restores the state of the stencil buffer
  33053. */
  33054. restoreStencilState(): void;
  33055. /**
  33056. * Directly set the WebGL Viewport
  33057. * @param x defines the x coordinate of the viewport (in screen space)
  33058. * @param y defines the y coordinate of the viewport (in screen space)
  33059. * @param width defines the width of the viewport (in screen space)
  33060. * @param height defines the height of the viewport (in screen space)
  33061. * @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
  33062. */
  33063. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33064. /**
  33065. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33066. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33067. * @param y defines the y-coordinate of the corner of the clear rectangle
  33068. * @param width defines the width of the clear rectangle
  33069. * @param height defines the height of the clear rectangle
  33070. * @param clearColor defines the clear color
  33071. */
  33072. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33073. /**
  33074. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33075. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33076. * @param y defines the y-coordinate of the corner of the clear rectangle
  33077. * @param width defines the width of the clear rectangle
  33078. * @param height defines the height of the clear rectangle
  33079. */
  33080. enableScissor(x: number, y: number, width: number, height: number): void;
  33081. /**
  33082. * Disable previously set scissor test rectangle
  33083. */
  33084. disableScissor(): void;
  33085. protected _reportDrawCall(): void;
  33086. /**
  33087. * Initializes a webVR display and starts listening to display change events
  33088. * The onVRDisplayChangedObservable will be notified upon these changes
  33089. * @returns The onVRDisplayChangedObservable
  33090. */
  33091. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33092. /** @hidden */
  33093. _prepareVRComponent(): void;
  33094. /** @hidden */
  33095. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33096. /** @hidden */
  33097. _submitVRFrame(): void;
  33098. /**
  33099. * Call this function to leave webVR mode
  33100. * Will do nothing if webVR is not supported or if there is no webVR device
  33101. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33102. */
  33103. disableVR(): void;
  33104. /**
  33105. * Gets a boolean indicating that the system is in VR mode and is presenting
  33106. * @returns true if VR mode is engaged
  33107. */
  33108. isVRPresenting(): boolean;
  33109. /** @hidden */
  33110. _requestVRFrame(): void;
  33111. /** @hidden */
  33112. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33113. /**
  33114. * Gets the source code of the vertex shader associated with a specific webGL program
  33115. * @param program defines the program to use
  33116. * @returns a string containing the source code of the vertex shader associated with the program
  33117. */
  33118. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33119. /**
  33120. * Gets the source code of the fragment shader associated with a specific webGL program
  33121. * @param program defines the program to use
  33122. * @returns a string containing the source code of the fragment shader associated with the program
  33123. */
  33124. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33125. /**
  33126. * Sets a depth stencil texture from a render target to the according uniform.
  33127. * @param channel The texture channel
  33128. * @param uniform The uniform to set
  33129. * @param texture The render target texture containing the depth stencil texture to apply
  33130. */
  33131. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33132. /**
  33133. * Sets a texture to the webGL context from a postprocess
  33134. * @param channel defines the channel to use
  33135. * @param postProcess defines the source postprocess
  33136. */
  33137. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33138. /**
  33139. * Binds the output of the passed in post process to the texture channel specified
  33140. * @param channel The channel the texture should be bound to
  33141. * @param postProcess The post process which's output should be bound
  33142. */
  33143. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33144. /** @hidden */
  33145. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33146. protected _rebuildBuffers(): void;
  33147. /** @hidden */
  33148. _renderFrame(): void;
  33149. _renderLoop(): void;
  33150. /** @hidden */
  33151. _renderViews(): boolean;
  33152. /**
  33153. * Toggle full screen mode
  33154. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33155. */
  33156. switchFullscreen(requestPointerLock: boolean): void;
  33157. /**
  33158. * Enters full screen mode
  33159. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33160. */
  33161. enterFullscreen(requestPointerLock: boolean): void;
  33162. /**
  33163. * Exits full screen mode
  33164. */
  33165. exitFullscreen(): void;
  33166. /**
  33167. * Enters Pointerlock mode
  33168. */
  33169. enterPointerlock(): void;
  33170. /**
  33171. * Exits Pointerlock mode
  33172. */
  33173. exitPointerlock(): void;
  33174. /**
  33175. * Begin a new frame
  33176. */
  33177. beginFrame(): void;
  33178. /**
  33179. * Enf the current frame
  33180. */
  33181. endFrame(): void;
  33182. resize(): void;
  33183. /**
  33184. * Set the compressed texture format to use, based on the formats you have, and the formats
  33185. * supported by the hardware / browser.
  33186. *
  33187. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33188. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33189. * to API arguments needed to compressed textures. This puts the burden on the container
  33190. * generator to house the arcane code for determining these for current & future formats.
  33191. *
  33192. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33193. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33194. *
  33195. * Note: The result of this call is not taken into account when a texture is base64.
  33196. *
  33197. * @param formatsAvailable defines the list of those format families you have created
  33198. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33199. *
  33200. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33201. * @returns The extension selected.
  33202. */
  33203. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33204. /**
  33205. * Set the compressed texture extensions or file names to skip.
  33206. *
  33207. * @param skippedFiles defines the list of those texture files you want to skip
  33208. * Example: [".dds", ".env", "myfile.png"]
  33209. */
  33210. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33211. /**
  33212. * Force a specific size of the canvas
  33213. * @param width defines the new canvas' width
  33214. * @param height defines the new canvas' height
  33215. */
  33216. setSize(width: number, height: number): void;
  33217. /**
  33218. * Updates a dynamic vertex buffer.
  33219. * @param vertexBuffer the vertex buffer to update
  33220. * @param data the data used to update the vertex buffer
  33221. * @param byteOffset the byte offset of the data
  33222. * @param byteLength the byte length of the data
  33223. */
  33224. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33225. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33226. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33227. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33228. _releaseTexture(texture: InternalTexture): void;
  33229. /**
  33230. * @hidden
  33231. * Rescales a texture
  33232. * @param source input texutre
  33233. * @param destination destination texture
  33234. * @param scene scene to use to render the resize
  33235. * @param internalFormat format to use when resizing
  33236. * @param onComplete callback to be called when resize has completed
  33237. */
  33238. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33239. /**
  33240. * Gets the current framerate
  33241. * @returns a number representing the framerate
  33242. */
  33243. getFps(): number;
  33244. /**
  33245. * Gets the time spent between current and previous frame
  33246. * @returns a number representing the delta time in ms
  33247. */
  33248. getDeltaTime(): number;
  33249. private _measureFps;
  33250. /** @hidden */
  33251. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33252. /**
  33253. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33254. * @param renderTarget The render target to set the frame buffer for
  33255. */
  33256. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33257. /**
  33258. * Update a dynamic index buffer
  33259. * @param indexBuffer defines the target index buffer
  33260. * @param indices defines the data to update
  33261. * @param offset defines the offset in the target index buffer where update should start
  33262. */
  33263. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33264. /**
  33265. * Updates the sample count of a render target texture
  33266. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33267. * @param texture defines the texture to update
  33268. * @param samples defines the sample count to set
  33269. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33270. */
  33271. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33272. /**
  33273. * Updates a depth texture Comparison Mode and Function.
  33274. * If the comparison Function is equal to 0, the mode will be set to none.
  33275. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33276. * @param texture The texture to set the comparison function for
  33277. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33278. */
  33279. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33280. /**
  33281. * Creates a webGL buffer to use with instanciation
  33282. * @param capacity defines the size of the buffer
  33283. * @returns the webGL buffer
  33284. */
  33285. createInstancesBuffer(capacity: number): DataBuffer;
  33286. /**
  33287. * Delete a webGL buffer used with instanciation
  33288. * @param buffer defines the webGL buffer to delete
  33289. */
  33290. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33291. /** @hidden */
  33292. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33293. dispose(): void;
  33294. private _disableTouchAction;
  33295. /**
  33296. * Display the loading screen
  33297. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33298. */
  33299. displayLoadingUI(): void;
  33300. /**
  33301. * Hide the loading screen
  33302. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33303. */
  33304. hideLoadingUI(): void;
  33305. /**
  33306. * Gets the current loading screen object
  33307. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33308. */
  33309. /**
  33310. * Sets the current loading screen object
  33311. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33312. */
  33313. loadingScreen: ILoadingScreen;
  33314. /**
  33315. * Sets the current loading screen text
  33316. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33317. */
  33318. loadingUIText: string;
  33319. /**
  33320. * Sets the current loading screen background color
  33321. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33322. */
  33323. loadingUIBackgroundColor: string;
  33324. /** Pointerlock and fullscreen */
  33325. /**
  33326. * Ask the browser to promote the current element to pointerlock mode
  33327. * @param element defines the DOM element to promote
  33328. */
  33329. static _RequestPointerlock(element: HTMLElement): void;
  33330. /**
  33331. * Asks the browser to exit pointerlock mode
  33332. */
  33333. static _ExitPointerlock(): void;
  33334. /**
  33335. * Ask the browser to promote the current element to fullscreen rendering mode
  33336. * @param element defines the DOM element to promote
  33337. */
  33338. static _RequestFullscreen(element: HTMLElement): void;
  33339. /**
  33340. * Asks the browser to exit fullscreen mode
  33341. */
  33342. static _ExitFullscreen(): void;
  33343. }
  33344. }
  33345. declare module BABYLON {
  33346. /**
  33347. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33348. * during the life time of the application.
  33349. */
  33350. export class EngineStore {
  33351. /** Gets the list of created engines */
  33352. static Instances: Engine[];
  33353. /** @hidden */
  33354. static _LastCreatedScene: Nullable<Scene>;
  33355. /**
  33356. * Gets the latest created engine
  33357. */
  33358. static readonly LastCreatedEngine: Nullable<Engine>;
  33359. /**
  33360. * Gets the latest created scene
  33361. */
  33362. static readonly LastCreatedScene: Nullable<Scene>;
  33363. /**
  33364. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33365. * @ignorenaming
  33366. */
  33367. static UseFallbackTexture: boolean;
  33368. /**
  33369. * Texture content used if a texture cannot loaded
  33370. * @ignorenaming
  33371. */
  33372. static FallbackTexture: string;
  33373. }
  33374. }
  33375. declare module BABYLON {
  33376. /**
  33377. * Helper class that provides a small promise polyfill
  33378. */
  33379. export class PromisePolyfill {
  33380. /**
  33381. * Static function used to check if the polyfill is required
  33382. * If this is the case then the function will inject the polyfill to window.Promise
  33383. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33384. */
  33385. static Apply(force?: boolean): void;
  33386. }
  33387. }
  33388. declare module BABYLON {
  33389. /**
  33390. * Interface for screenshot methods with describe argument called `size` as object with options
  33391. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33392. */
  33393. export interface IScreenshotSize {
  33394. /**
  33395. * number in pixels for canvas height
  33396. */
  33397. height?: number;
  33398. /**
  33399. * multiplier allowing render at a higher or lower resolution
  33400. * If value is defined then height and width will be ignored and taken from camera
  33401. */
  33402. precision?: number;
  33403. /**
  33404. * number in pixels for canvas width
  33405. */
  33406. width?: number;
  33407. }
  33408. }
  33409. declare module BABYLON {
  33410. interface IColor4Like {
  33411. r: float;
  33412. g: float;
  33413. b: float;
  33414. a: float;
  33415. }
  33416. /**
  33417. * Class containing a set of static utilities functions
  33418. */
  33419. export class Tools {
  33420. /**
  33421. * Gets or sets the base URL to use to load assets
  33422. */
  33423. static BaseUrl: string;
  33424. /**
  33425. * Enable/Disable Custom HTTP Request Headers globally.
  33426. * default = false
  33427. * @see CustomRequestHeaders
  33428. */
  33429. static UseCustomRequestHeaders: boolean;
  33430. /**
  33431. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33432. * i.e. when loading files, where the server/service expects an Authorization header
  33433. */
  33434. static CustomRequestHeaders: {
  33435. [key: string]: string;
  33436. };
  33437. /**
  33438. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33439. */
  33440. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33441. /**
  33442. * Default behaviour for cors in the application.
  33443. * It can be a string if the expected behavior is identical in the entire app.
  33444. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33445. */
  33446. static CorsBehavior: string | ((url: string | string[]) => string);
  33447. /**
  33448. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33449. * @ignorenaming
  33450. */
  33451. static UseFallbackTexture: boolean;
  33452. /**
  33453. * Use this object to register external classes like custom textures or material
  33454. * to allow the laoders to instantiate them
  33455. */
  33456. static RegisteredExternalClasses: {
  33457. [key: string]: Object;
  33458. };
  33459. /**
  33460. * Texture content used if a texture cannot loaded
  33461. * @ignorenaming
  33462. */
  33463. static fallbackTexture: string;
  33464. /**
  33465. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33466. * @param u defines the coordinate on X axis
  33467. * @param v defines the coordinate on Y axis
  33468. * @param width defines the width of the source data
  33469. * @param height defines the height of the source data
  33470. * @param pixels defines the source byte array
  33471. * @param color defines the output color
  33472. */
  33473. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33474. /**
  33475. * Interpolates between a and b via alpha
  33476. * @param a The lower value (returned when alpha = 0)
  33477. * @param b The upper value (returned when alpha = 1)
  33478. * @param alpha The interpolation-factor
  33479. * @return The mixed value
  33480. */
  33481. static Mix(a: number, b: number, alpha: number): number;
  33482. /**
  33483. * Tries to instantiate a new object from a given class name
  33484. * @param className defines the class name to instantiate
  33485. * @returns the new object or null if the system was not able to do the instantiation
  33486. */
  33487. static Instantiate(className: string): any;
  33488. /**
  33489. * Provides a slice function that will work even on IE
  33490. * @param data defines the array to slice
  33491. * @param start defines the start of the data (optional)
  33492. * @param end defines the end of the data (optional)
  33493. * @returns the new sliced array
  33494. */
  33495. static Slice<T>(data: T, start?: number, end?: number): T;
  33496. /**
  33497. * Polyfill for setImmediate
  33498. * @param action defines the action to execute after the current execution block
  33499. */
  33500. static SetImmediate(action: () => void): void;
  33501. /**
  33502. * Function indicating if a number is an exponent of 2
  33503. * @param value defines the value to test
  33504. * @returns true if the value is an exponent of 2
  33505. */
  33506. static IsExponentOfTwo(value: number): boolean;
  33507. private static _tmpFloatArray;
  33508. /**
  33509. * Returns the nearest 32-bit single precision float representation of a Number
  33510. * @param value A Number. If the parameter is of a different type, it will get converted
  33511. * to a number or to NaN if it cannot be converted
  33512. * @returns number
  33513. */
  33514. static FloatRound(value: number): number;
  33515. /**
  33516. * Extracts the filename from a path
  33517. * @param path defines the path to use
  33518. * @returns the filename
  33519. */
  33520. static GetFilename(path: string): string;
  33521. /**
  33522. * Extracts the "folder" part of a path (everything before the filename).
  33523. * @param uri The URI to extract the info from
  33524. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33525. * @returns The "folder" part of the path
  33526. */
  33527. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33528. /**
  33529. * Extracts text content from a DOM element hierarchy
  33530. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33531. */
  33532. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33533. /**
  33534. * Convert an angle in radians to degrees
  33535. * @param angle defines the angle to convert
  33536. * @returns the angle in degrees
  33537. */
  33538. static ToDegrees(angle: number): number;
  33539. /**
  33540. * Convert an angle in degrees to radians
  33541. * @param angle defines the angle to convert
  33542. * @returns the angle in radians
  33543. */
  33544. static ToRadians(angle: number): number;
  33545. /**
  33546. * Returns an array if obj is not an array
  33547. * @param obj defines the object to evaluate as an array
  33548. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33549. * @returns either obj directly if obj is an array or a new array containing obj
  33550. */
  33551. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33552. /**
  33553. * Gets the pointer prefix to use
  33554. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33555. */
  33556. static GetPointerPrefix(): string;
  33557. /**
  33558. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33559. * @param url define the url we are trying
  33560. * @param element define the dom element where to configure the cors policy
  33561. */
  33562. static SetCorsBehavior(url: string | string[], element: {
  33563. crossOrigin: string | null;
  33564. }): void;
  33565. /**
  33566. * Removes unwanted characters from an url
  33567. * @param url defines the url to clean
  33568. * @returns the cleaned url
  33569. */
  33570. static CleanUrl(url: string): string;
  33571. /**
  33572. * Gets or sets a function used to pre-process url before using them to load assets
  33573. */
  33574. static PreprocessUrl: (url: string) => string;
  33575. /**
  33576. * Loads an image as an HTMLImageElement.
  33577. * @param input url string, ArrayBuffer, or Blob to load
  33578. * @param onLoad callback called when the image successfully loads
  33579. * @param onError callback called when the image fails to load
  33580. * @param offlineProvider offline provider for caching
  33581. * @param mimeType optional mime type
  33582. * @returns the HTMLImageElement of the loaded image
  33583. */
  33584. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33585. /**
  33586. * Loads a file from a url
  33587. * @param url url string, ArrayBuffer, or Blob to load
  33588. * @param onSuccess callback called when the file successfully loads
  33589. * @param onProgress callback called while file is loading (if the server supports this mode)
  33590. * @param offlineProvider defines the offline provider for caching
  33591. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33592. * @param onError callback called when the file fails to load
  33593. * @returns a file request object
  33594. */
  33595. 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;
  33596. /**
  33597. * Loads a file from a url
  33598. * @param url the file url to load
  33599. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33600. */
  33601. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33602. /**
  33603. * Load a script (identified by an url). When the url returns, the
  33604. * content of this file is added into a new script element, attached to the DOM (body element)
  33605. * @param scriptUrl defines the url of the script to laod
  33606. * @param onSuccess defines the callback called when the script is loaded
  33607. * @param onError defines the callback to call if an error occurs
  33608. * @param scriptId defines the id of the script element
  33609. */
  33610. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33611. /**
  33612. * Load an asynchronous script (identified by an url). When the url returns, the
  33613. * content of this file is added into a new script element, attached to the DOM (body element)
  33614. * @param scriptUrl defines the url of the script to laod
  33615. * @param scriptId defines the id of the script element
  33616. * @returns a promise request object
  33617. */
  33618. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33619. /**
  33620. * Loads a file from a blob
  33621. * @param fileToLoad defines the blob to use
  33622. * @param callback defines the callback to call when data is loaded
  33623. * @param progressCallback defines the callback to call during loading process
  33624. * @returns a file request object
  33625. */
  33626. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33627. /**
  33628. * Reads a file from a File object
  33629. * @param file defines the file to load
  33630. * @param onSuccess defines the callback to call when data is loaded
  33631. * @param onProgress defines the callback to call during loading process
  33632. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33633. * @param onError defines the callback to call when an error occurs
  33634. * @returns a file request object
  33635. */
  33636. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33637. /**
  33638. * Creates a data url from a given string content
  33639. * @param content defines the content to convert
  33640. * @returns the new data url link
  33641. */
  33642. static FileAsURL(content: string): string;
  33643. /**
  33644. * Format the given number to a specific decimal format
  33645. * @param value defines the number to format
  33646. * @param decimals defines the number of decimals to use
  33647. * @returns the formatted string
  33648. */
  33649. static Format(value: number, decimals?: number): string;
  33650. /**
  33651. * Tries to copy an object by duplicating every property
  33652. * @param source defines the source object
  33653. * @param destination defines the target object
  33654. * @param doNotCopyList defines a list of properties to avoid
  33655. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33656. */
  33657. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33658. /**
  33659. * Gets a boolean indicating if the given object has no own property
  33660. * @param obj defines the object to test
  33661. * @returns true if object has no own property
  33662. */
  33663. static IsEmpty(obj: any): boolean;
  33664. /**
  33665. * Function used to register events at window level
  33666. * @param windowElement defines the Window object to use
  33667. * @param events defines the events to register
  33668. */
  33669. static RegisterTopRootEvents(windowElement: Window, events: {
  33670. name: string;
  33671. handler: Nullable<(e: FocusEvent) => any>;
  33672. }[]): void;
  33673. /**
  33674. * Function used to unregister events from window level
  33675. * @param windowElement defines the Window object to use
  33676. * @param events defines the events to unregister
  33677. */
  33678. static UnregisterTopRootEvents(windowElement: Window, events: {
  33679. name: string;
  33680. handler: Nullable<(e: FocusEvent) => any>;
  33681. }[]): void;
  33682. /**
  33683. * @ignore
  33684. */
  33685. static _ScreenshotCanvas: HTMLCanvasElement;
  33686. /**
  33687. * Dumps the current bound framebuffer
  33688. * @param width defines the rendering width
  33689. * @param height defines the rendering height
  33690. * @param engine defines the hosting engine
  33691. * @param successCallback defines the callback triggered once the data are available
  33692. * @param mimeType defines the mime type of the result
  33693. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33694. */
  33695. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33696. /**
  33697. * Converts the canvas data to blob.
  33698. * This acts as a polyfill for browsers not supporting the to blob function.
  33699. * @param canvas Defines the canvas to extract the data from
  33700. * @param successCallback Defines the callback triggered once the data are available
  33701. * @param mimeType Defines the mime type of the result
  33702. */
  33703. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33704. /**
  33705. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33706. * @param successCallback defines the callback triggered once the data are available
  33707. * @param mimeType defines the mime type of the result
  33708. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33709. */
  33710. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33711. /**
  33712. * Downloads a blob in the browser
  33713. * @param blob defines the blob to download
  33714. * @param fileName defines the name of the downloaded file
  33715. */
  33716. static Download(blob: Blob, fileName: string): void;
  33717. /**
  33718. * Captures a screenshot of the current rendering
  33719. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33720. * @param engine defines the rendering engine
  33721. * @param camera defines the source camera
  33722. * @param size This parameter can be set to a single number or to an object with the
  33723. * following (optional) properties: precision, width, height. If a single number is passed,
  33724. * it will be used for both width and height. If an object is passed, the screenshot size
  33725. * will be derived from the parameters. The precision property is a multiplier allowing
  33726. * rendering at a higher or lower resolution
  33727. * @param successCallback defines the callback receives a single parameter which contains the
  33728. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33729. * src parameter of an <img> to display it
  33730. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33731. * Check your browser for supported MIME types
  33732. */
  33733. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33734. /**
  33735. * Captures a screenshot of the current rendering
  33736. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33737. * @param engine defines the rendering engine
  33738. * @param camera defines the source camera
  33739. * @param size This parameter can be set to a single number or to an object with the
  33740. * following (optional) properties: precision, width, height. If a single number is passed,
  33741. * it will be used for both width and height. If an object is passed, the screenshot size
  33742. * will be derived from the parameters. The precision property is a multiplier allowing
  33743. * rendering at a higher or lower resolution
  33744. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33745. * Check your browser for supported MIME types
  33746. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33747. * to the src parameter of an <img> to display it
  33748. */
  33749. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33750. /**
  33751. * Generates an image screenshot from the specified camera.
  33752. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33753. * @param engine The engine to use for rendering
  33754. * @param camera The camera to use for rendering
  33755. * @param size This parameter can be set to a single number or to an object with the
  33756. * following (optional) properties: precision, width, height. If a single number is passed,
  33757. * it will be used for both width and height. If an object is passed, the screenshot size
  33758. * will be derived from the parameters. The precision property is a multiplier allowing
  33759. * rendering at a higher or lower resolution
  33760. * @param successCallback The callback receives a single parameter which contains the
  33761. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33762. * src parameter of an <img> to display it
  33763. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33764. * Check your browser for supported MIME types
  33765. * @param samples Texture samples (default: 1)
  33766. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33767. * @param fileName A name for for the downloaded file.
  33768. */
  33769. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33770. /**
  33771. * Generates an image screenshot from the specified camera.
  33772. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33773. * @param engine The engine to use for rendering
  33774. * @param camera The camera to use for rendering
  33775. * @param size This parameter can be set to a single number or to an object with the
  33776. * following (optional) properties: precision, width, height. If a single number is passed,
  33777. * it will be used for both width and height. If an object is passed, the screenshot size
  33778. * will be derived from the parameters. The precision property is a multiplier allowing
  33779. * rendering at a higher or lower resolution
  33780. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33781. * Check your browser for supported MIME types
  33782. * @param samples Texture samples (default: 1)
  33783. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33784. * @param fileName A name for for the downloaded file.
  33785. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33786. * to the src parameter of an <img> to display it
  33787. */
  33788. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33789. /**
  33790. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33791. * Be aware Math.random() could cause collisions, but:
  33792. * "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"
  33793. * @returns a pseudo random id
  33794. */
  33795. static RandomId(): string;
  33796. /**
  33797. * Test if the given uri is a base64 string
  33798. * @param uri The uri to test
  33799. * @return True if the uri is a base64 string or false otherwise
  33800. */
  33801. static IsBase64(uri: string): boolean;
  33802. /**
  33803. * Decode the given base64 uri.
  33804. * @param uri The uri to decode
  33805. * @return The decoded base64 data.
  33806. */
  33807. static DecodeBase64(uri: string): ArrayBuffer;
  33808. /**
  33809. * Gets the absolute url.
  33810. * @param url the input url
  33811. * @return the absolute url
  33812. */
  33813. static GetAbsoluteUrl(url: string): string;
  33814. /**
  33815. * No log
  33816. */
  33817. static readonly NoneLogLevel: number;
  33818. /**
  33819. * Only message logs
  33820. */
  33821. static readonly MessageLogLevel: number;
  33822. /**
  33823. * Only warning logs
  33824. */
  33825. static readonly WarningLogLevel: number;
  33826. /**
  33827. * Only error logs
  33828. */
  33829. static readonly ErrorLogLevel: number;
  33830. /**
  33831. * All logs
  33832. */
  33833. static readonly AllLogLevel: number;
  33834. /**
  33835. * Gets a value indicating the number of loading errors
  33836. * @ignorenaming
  33837. */
  33838. static readonly errorsCount: number;
  33839. /**
  33840. * Callback called when a new log is added
  33841. */
  33842. static OnNewCacheEntry: (entry: string) => void;
  33843. /**
  33844. * Log a message to the console
  33845. * @param message defines the message to log
  33846. */
  33847. static Log(message: string): void;
  33848. /**
  33849. * Write a warning message to the console
  33850. * @param message defines the message to log
  33851. */
  33852. static Warn(message: string): void;
  33853. /**
  33854. * Write an error message to the console
  33855. * @param message defines the message to log
  33856. */
  33857. static Error(message: string): void;
  33858. /**
  33859. * Gets current log cache (list of logs)
  33860. */
  33861. static readonly LogCache: string;
  33862. /**
  33863. * Clears the log cache
  33864. */
  33865. static ClearLogCache(): void;
  33866. /**
  33867. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33868. */
  33869. static LogLevels: number;
  33870. /**
  33871. * Checks if the window object exists
  33872. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33873. */
  33874. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33875. /**
  33876. * No performance log
  33877. */
  33878. static readonly PerformanceNoneLogLevel: number;
  33879. /**
  33880. * Use user marks to log performance
  33881. */
  33882. static readonly PerformanceUserMarkLogLevel: number;
  33883. /**
  33884. * Log performance to the console
  33885. */
  33886. static readonly PerformanceConsoleLogLevel: number;
  33887. private static _performance;
  33888. /**
  33889. * Sets the current performance log level
  33890. */
  33891. static PerformanceLogLevel: number;
  33892. private static _StartPerformanceCounterDisabled;
  33893. private static _EndPerformanceCounterDisabled;
  33894. private static _StartUserMark;
  33895. private static _EndUserMark;
  33896. private static _StartPerformanceConsole;
  33897. private static _EndPerformanceConsole;
  33898. /**
  33899. * Starts a performance counter
  33900. */
  33901. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33902. /**
  33903. * Ends a specific performance coutner
  33904. */
  33905. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33906. /**
  33907. * Gets either window.performance.now() if supported or Date.now() else
  33908. */
  33909. static readonly Now: number;
  33910. /**
  33911. * This method will return the name of the class used to create the instance of the given object.
  33912. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33913. * @param object the object to get the class name from
  33914. * @param isType defines if the object is actually a type
  33915. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33916. */
  33917. static GetClassName(object: any, isType?: boolean): string;
  33918. /**
  33919. * Gets the first element of an array satisfying a given predicate
  33920. * @param array defines the array to browse
  33921. * @param predicate defines the predicate to use
  33922. * @returns null if not found or the element
  33923. */
  33924. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33925. /**
  33926. * This method will return the name of the full name of the class, including its owning module (if any).
  33927. * 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).
  33928. * @param object the object to get the class name from
  33929. * @param isType defines if the object is actually a type
  33930. * @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.
  33931. * @ignorenaming
  33932. */
  33933. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33934. /**
  33935. * Returns a promise that resolves after the given amount of time.
  33936. * @param delay Number of milliseconds to delay
  33937. * @returns Promise that resolves after the given amount of time
  33938. */
  33939. static DelayAsync(delay: number): Promise<void>;
  33940. }
  33941. /**
  33942. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33943. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33944. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33945. * @param name The name of the class, case should be preserved
  33946. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33947. */
  33948. export function className(name: string, module?: string): (target: Object) => void;
  33949. /**
  33950. * An implementation of a loop for asynchronous functions.
  33951. */
  33952. export class AsyncLoop {
  33953. /**
  33954. * Defines the number of iterations for the loop
  33955. */
  33956. iterations: number;
  33957. /**
  33958. * Defines the current index of the loop.
  33959. */
  33960. index: number;
  33961. private _done;
  33962. private _fn;
  33963. private _successCallback;
  33964. /**
  33965. * Constructor.
  33966. * @param iterations the number of iterations.
  33967. * @param func the function to run each iteration
  33968. * @param successCallback the callback that will be called upon succesful execution
  33969. * @param offset starting offset.
  33970. */
  33971. constructor(
  33972. /**
  33973. * Defines the number of iterations for the loop
  33974. */
  33975. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33976. /**
  33977. * Execute the next iteration. Must be called after the last iteration was finished.
  33978. */
  33979. executeNext(): void;
  33980. /**
  33981. * Break the loop and run the success callback.
  33982. */
  33983. breakLoop(): void;
  33984. /**
  33985. * Create and run an async loop.
  33986. * @param iterations the number of iterations.
  33987. * @param fn the function to run each iteration
  33988. * @param successCallback the callback that will be called upon succesful execution
  33989. * @param offset starting offset.
  33990. * @returns the created async loop object
  33991. */
  33992. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33993. /**
  33994. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33995. * @param iterations total number of iterations
  33996. * @param syncedIterations number of synchronous iterations in each async iteration.
  33997. * @param fn the function to call each iteration.
  33998. * @param callback a success call back that will be called when iterating stops.
  33999. * @param breakFunction a break condition (optional)
  34000. * @param timeout timeout settings for the setTimeout function. default - 0.
  34001. * @returns the created async loop object
  34002. */
  34003. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34004. }
  34005. }
  34006. declare module BABYLON {
  34007. /**
  34008. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34009. * The underlying implementation relies on an associative array to ensure the best performances.
  34010. * The value can be anything including 'null' but except 'undefined'
  34011. */
  34012. export class StringDictionary<T> {
  34013. /**
  34014. * This will clear this dictionary and copy the content from the 'source' one.
  34015. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34016. * @param source the dictionary to take the content from and copy to this dictionary
  34017. */
  34018. copyFrom(source: StringDictionary<T>): void;
  34019. /**
  34020. * Get a value based from its key
  34021. * @param key the given key to get the matching value from
  34022. * @return the value if found, otherwise undefined is returned
  34023. */
  34024. get(key: string): T | undefined;
  34025. /**
  34026. * Get a value from its key or add it if it doesn't exist.
  34027. * This method will ensure you that a given key/data will be present in the dictionary.
  34028. * @param key the given key to get the matching value from
  34029. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34030. * The factory will only be invoked if there's no data for the given key.
  34031. * @return the value corresponding to the key.
  34032. */
  34033. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34034. /**
  34035. * Get a value from its key if present in the dictionary otherwise add it
  34036. * @param key the key to get the value from
  34037. * @param val if there's no such key/value pair in the dictionary add it with this value
  34038. * @return the value corresponding to the key
  34039. */
  34040. getOrAdd(key: string, val: T): T;
  34041. /**
  34042. * Check if there's a given key in the dictionary
  34043. * @param key the key to check for
  34044. * @return true if the key is present, false otherwise
  34045. */
  34046. contains(key: string): boolean;
  34047. /**
  34048. * Add a new key and its corresponding value
  34049. * @param key the key to add
  34050. * @param value the value corresponding to the key
  34051. * @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
  34052. */
  34053. add(key: string, value: T): boolean;
  34054. /**
  34055. * Update a specific value associated to a key
  34056. * @param key defines the key to use
  34057. * @param value defines the value to store
  34058. * @returns true if the value was updated (or false if the key was not found)
  34059. */
  34060. set(key: string, value: T): boolean;
  34061. /**
  34062. * Get the element of the given key and remove it from the dictionary
  34063. * @param key defines the key to search
  34064. * @returns the value associated with the key or null if not found
  34065. */
  34066. getAndRemove(key: string): Nullable<T>;
  34067. /**
  34068. * Remove a key/value from the dictionary.
  34069. * @param key the key to remove
  34070. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34071. */
  34072. remove(key: string): boolean;
  34073. /**
  34074. * Clear the whole content of the dictionary
  34075. */
  34076. clear(): void;
  34077. /**
  34078. * Gets the current count
  34079. */
  34080. readonly count: number;
  34081. /**
  34082. * Execute a callback on each key/val of the dictionary.
  34083. * Note that you can remove any element in this dictionary in the callback implementation
  34084. * @param callback the callback to execute on a given key/value pair
  34085. */
  34086. forEach(callback: (key: string, val: T) => void): void;
  34087. /**
  34088. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34089. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34090. * Note that you can remove any element in this dictionary in the callback implementation
  34091. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34092. * @returns the first item
  34093. */
  34094. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34095. private _count;
  34096. private _data;
  34097. }
  34098. }
  34099. declare module BABYLON {
  34100. /** @hidden */
  34101. export interface ICollisionCoordinator {
  34102. createCollider(): Collider;
  34103. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34104. init(scene: Scene): void;
  34105. }
  34106. /** @hidden */
  34107. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34108. private _scene;
  34109. private _scaledPosition;
  34110. private _scaledVelocity;
  34111. private _finalPosition;
  34112. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34113. createCollider(): Collider;
  34114. init(scene: Scene): void;
  34115. private _collideWithWorld;
  34116. }
  34117. }
  34118. declare module BABYLON {
  34119. /**
  34120. * Class used to manage all inputs for the scene.
  34121. */
  34122. export class InputManager {
  34123. /** The distance in pixel that you have to move to prevent some events */
  34124. static DragMovementThreshold: number;
  34125. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34126. static LongPressDelay: number;
  34127. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34128. static DoubleClickDelay: number;
  34129. /** If you need to check double click without raising a single click at first click, enable this flag */
  34130. static ExclusiveDoubleClickMode: boolean;
  34131. private _wheelEventName;
  34132. private _onPointerMove;
  34133. private _onPointerDown;
  34134. private _onPointerUp;
  34135. private _initClickEvent;
  34136. private _initActionManager;
  34137. private _delayedSimpleClick;
  34138. private _delayedSimpleClickTimeout;
  34139. private _previousDelayedSimpleClickTimeout;
  34140. private _meshPickProceed;
  34141. private _previousButtonPressed;
  34142. private _currentPickResult;
  34143. private _previousPickResult;
  34144. private _totalPointersPressed;
  34145. private _doubleClickOccured;
  34146. private _pointerOverMesh;
  34147. private _pickedDownMesh;
  34148. private _pickedUpMesh;
  34149. private _pointerX;
  34150. private _pointerY;
  34151. private _unTranslatedPointerX;
  34152. private _unTranslatedPointerY;
  34153. private _startingPointerPosition;
  34154. private _previousStartingPointerPosition;
  34155. private _startingPointerTime;
  34156. private _previousStartingPointerTime;
  34157. private _pointerCaptures;
  34158. private _onKeyDown;
  34159. private _onKeyUp;
  34160. private _onCanvasFocusObserver;
  34161. private _onCanvasBlurObserver;
  34162. private _scene;
  34163. /**
  34164. * Creates a new InputManager
  34165. * @param scene defines the hosting scene
  34166. */
  34167. constructor(scene: Scene);
  34168. /**
  34169. * Gets the mesh that is currently under the pointer
  34170. */
  34171. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34172. /**
  34173. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34174. */
  34175. readonly unTranslatedPointer: Vector2;
  34176. /**
  34177. * Gets or sets the current on-screen X position of the pointer
  34178. */
  34179. pointerX: number;
  34180. /**
  34181. * Gets or sets the current on-screen Y position of the pointer
  34182. */
  34183. pointerY: number;
  34184. private _updatePointerPosition;
  34185. private _processPointerMove;
  34186. private _setRayOnPointerInfo;
  34187. private _checkPrePointerObservable;
  34188. /**
  34189. * Use this method to simulate a pointer move on a mesh
  34190. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34191. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34192. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34193. */
  34194. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34195. /**
  34196. * Use this method to simulate a pointer down on a mesh
  34197. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34198. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34199. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34200. */
  34201. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34202. private _processPointerDown;
  34203. /** @hidden */
  34204. _isPointerSwiping(): boolean;
  34205. /**
  34206. * Use this method to simulate a pointer up on a mesh
  34207. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34208. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34209. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34210. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34211. */
  34212. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34213. private _processPointerUp;
  34214. /**
  34215. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34216. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34217. * @returns true if the pointer was captured
  34218. */
  34219. isPointerCaptured(pointerId?: number): boolean;
  34220. /**
  34221. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34222. * @param attachUp defines if you want to attach events to pointerup
  34223. * @param attachDown defines if you want to attach events to pointerdown
  34224. * @param attachMove defines if you want to attach events to pointermove
  34225. */
  34226. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34227. /**
  34228. * Detaches all event handlers
  34229. */
  34230. detachControl(): void;
  34231. /**
  34232. * Force the value of meshUnderPointer
  34233. * @param mesh defines the mesh to use
  34234. */
  34235. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34236. /**
  34237. * Gets the mesh under the pointer
  34238. * @returns a Mesh or null if no mesh is under the pointer
  34239. */
  34240. getPointerOverMesh(): Nullable<AbstractMesh>;
  34241. }
  34242. }
  34243. declare module BABYLON {
  34244. /**
  34245. * Helper class used to generate session unique ID
  34246. */
  34247. export class UniqueIdGenerator {
  34248. private static _UniqueIdCounter;
  34249. /**
  34250. * Gets an unique (relatively to the current scene) Id
  34251. */
  34252. static readonly UniqueId: number;
  34253. }
  34254. }
  34255. declare module BABYLON {
  34256. /**
  34257. * This class defines the direct association between an animation and a target
  34258. */
  34259. export class TargetedAnimation {
  34260. /**
  34261. * Animation to perform
  34262. */
  34263. animation: Animation;
  34264. /**
  34265. * Target to animate
  34266. */
  34267. target: any;
  34268. /**
  34269. * Serialize the object
  34270. * @returns the JSON object representing the current entity
  34271. */
  34272. serialize(): any;
  34273. }
  34274. /**
  34275. * Use this class to create coordinated animations on multiple targets
  34276. */
  34277. export class AnimationGroup implements IDisposable {
  34278. /** The name of the animation group */
  34279. name: string;
  34280. private _scene;
  34281. private _targetedAnimations;
  34282. private _animatables;
  34283. private _from;
  34284. private _to;
  34285. private _isStarted;
  34286. private _isPaused;
  34287. private _speedRatio;
  34288. private _loopAnimation;
  34289. /**
  34290. * Gets or sets the unique id of the node
  34291. */
  34292. uniqueId: number;
  34293. /**
  34294. * This observable will notify when one animation have ended
  34295. */
  34296. onAnimationEndObservable: Observable<TargetedAnimation>;
  34297. /**
  34298. * Observer raised when one animation loops
  34299. */
  34300. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34301. /**
  34302. * Observer raised when all animations have looped
  34303. */
  34304. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34305. /**
  34306. * This observable will notify when all animations have ended.
  34307. */
  34308. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34309. /**
  34310. * This observable will notify when all animations have paused.
  34311. */
  34312. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34313. /**
  34314. * This observable will notify when all animations are playing.
  34315. */
  34316. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34317. /**
  34318. * Gets the first frame
  34319. */
  34320. readonly from: number;
  34321. /**
  34322. * Gets the last frame
  34323. */
  34324. readonly to: number;
  34325. /**
  34326. * Define if the animations are started
  34327. */
  34328. readonly isStarted: boolean;
  34329. /**
  34330. * Gets a value indicating that the current group is playing
  34331. */
  34332. readonly isPlaying: boolean;
  34333. /**
  34334. * Gets or sets the speed ratio to use for all animations
  34335. */
  34336. /**
  34337. * Gets or sets the speed ratio to use for all animations
  34338. */
  34339. speedRatio: number;
  34340. /**
  34341. * Gets or sets if all animations should loop or not
  34342. */
  34343. loopAnimation: boolean;
  34344. /**
  34345. * Gets the targeted animations for this animation group
  34346. */
  34347. readonly targetedAnimations: Array<TargetedAnimation>;
  34348. /**
  34349. * returning the list of animatables controlled by this animation group.
  34350. */
  34351. readonly animatables: Array<Animatable>;
  34352. /**
  34353. * Instantiates a new Animation Group.
  34354. * This helps managing several animations at once.
  34355. * @see http://doc.babylonjs.com/how_to/group
  34356. * @param name Defines the name of the group
  34357. * @param scene Defines the scene the group belongs to
  34358. */
  34359. constructor(
  34360. /** The name of the animation group */
  34361. name: string, scene?: Nullable<Scene>);
  34362. /**
  34363. * Add an animation (with its target) in the group
  34364. * @param animation defines the animation we want to add
  34365. * @param target defines the target of the animation
  34366. * @returns the TargetedAnimation object
  34367. */
  34368. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34369. /**
  34370. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34371. * It can add constant keys at begin or end
  34372. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34373. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34374. * @returns the animation group
  34375. */
  34376. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34377. private _animationLoopCount;
  34378. private _animationLoopFlags;
  34379. private _processLoop;
  34380. /**
  34381. * Start all animations on given targets
  34382. * @param loop defines if animations must loop
  34383. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34384. * @param from defines the from key (optional)
  34385. * @param to defines the to key (optional)
  34386. * @returns the current animation group
  34387. */
  34388. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34389. /**
  34390. * Pause all animations
  34391. * @returns the animation group
  34392. */
  34393. pause(): AnimationGroup;
  34394. /**
  34395. * Play all animations to initial state
  34396. * This function will start() the animations if they were not started or will restart() them if they were paused
  34397. * @param loop defines if animations must loop
  34398. * @returns the animation group
  34399. */
  34400. play(loop?: boolean): AnimationGroup;
  34401. /**
  34402. * Reset all animations to initial state
  34403. * @returns the animation group
  34404. */
  34405. reset(): AnimationGroup;
  34406. /**
  34407. * Restart animations from key 0
  34408. * @returns the animation group
  34409. */
  34410. restart(): AnimationGroup;
  34411. /**
  34412. * Stop all animations
  34413. * @returns the animation group
  34414. */
  34415. stop(): AnimationGroup;
  34416. /**
  34417. * Set animation weight for all animatables
  34418. * @param weight defines the weight to use
  34419. * @return the animationGroup
  34420. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34421. */
  34422. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34423. /**
  34424. * Synchronize and normalize all animatables with a source animatable
  34425. * @param root defines the root animatable to synchronize with
  34426. * @return the animationGroup
  34427. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34428. */
  34429. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34430. /**
  34431. * Goes to a specific frame in this animation group
  34432. * @param frame the frame number to go to
  34433. * @return the animationGroup
  34434. */
  34435. goToFrame(frame: number): AnimationGroup;
  34436. /**
  34437. * Dispose all associated resources
  34438. */
  34439. dispose(): void;
  34440. private _checkAnimationGroupEnded;
  34441. /**
  34442. * Clone the current animation group and returns a copy
  34443. * @param newName defines the name of the new group
  34444. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34445. * @returns the new aniamtion group
  34446. */
  34447. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34448. /**
  34449. * Serializes the animationGroup to an object
  34450. * @returns Serialized object
  34451. */
  34452. serialize(): any;
  34453. /**
  34454. * Returns a new AnimationGroup object parsed from the source provided.
  34455. * @param parsedAnimationGroup defines the source
  34456. * @param scene defines the scene that will receive the animationGroup
  34457. * @returns a new AnimationGroup
  34458. */
  34459. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34460. /**
  34461. * Returns the string "AnimationGroup"
  34462. * @returns "AnimationGroup"
  34463. */
  34464. getClassName(): string;
  34465. /**
  34466. * Creates a detailled string about the object
  34467. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34468. * @returns a string representing the object
  34469. */
  34470. toString(fullDetails?: boolean): string;
  34471. }
  34472. }
  34473. declare module BABYLON {
  34474. /**
  34475. * Define an interface for all classes that will hold resources
  34476. */
  34477. export interface IDisposable {
  34478. /**
  34479. * Releases all held resources
  34480. */
  34481. dispose(): void;
  34482. }
  34483. /** Interface defining initialization parameters for Scene class */
  34484. export interface SceneOptions {
  34485. /**
  34486. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34487. * It will improve performance when the number of geometries becomes important.
  34488. */
  34489. useGeometryUniqueIdsMap?: boolean;
  34490. /**
  34491. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34492. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34493. */
  34494. useMaterialMeshMap?: boolean;
  34495. /**
  34496. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34497. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34498. */
  34499. useClonedMeshhMap?: boolean;
  34500. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34501. virtual?: boolean;
  34502. }
  34503. /**
  34504. * Represents a scene to be rendered by the engine.
  34505. * @see http://doc.babylonjs.com/features/scene
  34506. */
  34507. export class Scene extends AbstractScene implements IAnimatable {
  34508. /** The fog is deactivated */
  34509. static readonly FOGMODE_NONE: number;
  34510. /** The fog density is following an exponential function */
  34511. static readonly FOGMODE_EXP: number;
  34512. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34513. static readonly FOGMODE_EXP2: number;
  34514. /** The fog density is following a linear function. */
  34515. static readonly FOGMODE_LINEAR: number;
  34516. /**
  34517. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34518. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34519. */
  34520. static MinDeltaTime: number;
  34521. /**
  34522. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34523. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34524. */
  34525. static MaxDeltaTime: number;
  34526. /**
  34527. * Factory used to create the default material.
  34528. * @param name The name of the material to create
  34529. * @param scene The scene to create the material for
  34530. * @returns The default material
  34531. */
  34532. static DefaultMaterialFactory(scene: Scene): Material;
  34533. /**
  34534. * Factory used to create the a collision coordinator.
  34535. * @returns The collision coordinator
  34536. */
  34537. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34538. /** @hidden */
  34539. _inputManager: InputManager;
  34540. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34541. cameraToUseForPointers: Nullable<Camera>;
  34542. /** @hidden */
  34543. readonly _isScene: boolean;
  34544. /**
  34545. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34546. */
  34547. autoClear: boolean;
  34548. /**
  34549. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34550. */
  34551. autoClearDepthAndStencil: boolean;
  34552. /**
  34553. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34554. */
  34555. clearColor: Color4;
  34556. /**
  34557. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34558. */
  34559. ambientColor: Color3;
  34560. /**
  34561. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34562. * It should only be one of the following (if not the default embedded one):
  34563. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34564. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34565. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34566. * The material properties need to be setup according to the type of texture in use.
  34567. */
  34568. environmentBRDFTexture: BaseTexture;
  34569. /** @hidden */
  34570. protected _environmentTexture: Nullable<BaseTexture>;
  34571. /**
  34572. * Texture used in all pbr material as the reflection texture.
  34573. * As in the majority of the scene they are the same (exception for multi room and so on),
  34574. * this is easier to reference from here than from all the materials.
  34575. */
  34576. /**
  34577. * Texture used in all pbr material as the reflection texture.
  34578. * As in the majority of the scene they are the same (exception for multi room and so on),
  34579. * this is easier to set here than in all the materials.
  34580. */
  34581. environmentTexture: Nullable<BaseTexture>;
  34582. /** @hidden */
  34583. protected _environmentIntensity: number;
  34584. /**
  34585. * Intensity of the environment in all pbr material.
  34586. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34587. * As in the majority of the scene they are the same (exception for multi room and so on),
  34588. * this is easier to reference from here than from all the materials.
  34589. */
  34590. /**
  34591. * Intensity of the environment in all pbr material.
  34592. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34593. * As in the majority of the scene they are the same (exception for multi room and so on),
  34594. * this is easier to set here than in all the materials.
  34595. */
  34596. environmentIntensity: number;
  34597. /** @hidden */
  34598. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34599. /**
  34600. * Default image processing configuration used either in the rendering
  34601. * Forward main pass or through the imageProcessingPostProcess if present.
  34602. * As in the majority of the scene they are the same (exception for multi camera),
  34603. * this is easier to reference from here than from all the materials and post process.
  34604. *
  34605. * No setter as we it is a shared configuration, you can set the values instead.
  34606. */
  34607. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34608. private _forceWireframe;
  34609. /**
  34610. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34611. */
  34612. forceWireframe: boolean;
  34613. private _forcePointsCloud;
  34614. /**
  34615. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34616. */
  34617. forcePointsCloud: boolean;
  34618. /**
  34619. * Gets or sets the active clipplane 1
  34620. */
  34621. clipPlane: Nullable<Plane>;
  34622. /**
  34623. * Gets or sets the active clipplane 2
  34624. */
  34625. clipPlane2: Nullable<Plane>;
  34626. /**
  34627. * Gets or sets the active clipplane 3
  34628. */
  34629. clipPlane3: Nullable<Plane>;
  34630. /**
  34631. * Gets or sets the active clipplane 4
  34632. */
  34633. clipPlane4: Nullable<Plane>;
  34634. /**
  34635. * Gets or sets a boolean indicating if animations are enabled
  34636. */
  34637. animationsEnabled: boolean;
  34638. private _animationPropertiesOverride;
  34639. /**
  34640. * Gets or sets the animation properties override
  34641. */
  34642. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34643. /**
  34644. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34645. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34646. */
  34647. useConstantAnimationDeltaTime: boolean;
  34648. /**
  34649. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34650. * Please note that it requires to run a ray cast through the scene on every frame
  34651. */
  34652. constantlyUpdateMeshUnderPointer: boolean;
  34653. /**
  34654. * Defines the HTML cursor to use when hovering over interactive elements
  34655. */
  34656. hoverCursor: string;
  34657. /**
  34658. * Defines the HTML default cursor to use (empty by default)
  34659. */
  34660. defaultCursor: string;
  34661. /**
  34662. * Defines wether cursors are handled by the scene.
  34663. */
  34664. doNotHandleCursors: boolean;
  34665. /**
  34666. * This is used to call preventDefault() on pointer down
  34667. * in order to block unwanted artifacts like system double clicks
  34668. */
  34669. preventDefaultOnPointerDown: boolean;
  34670. /**
  34671. * This is used to call preventDefault() on pointer up
  34672. * in order to block unwanted artifacts like system double clicks
  34673. */
  34674. preventDefaultOnPointerUp: boolean;
  34675. /**
  34676. * Gets or sets user defined metadata
  34677. */
  34678. metadata: any;
  34679. /**
  34680. * For internal use only. Please do not use.
  34681. */
  34682. reservedDataStore: any;
  34683. /**
  34684. * Gets the name of the plugin used to load this scene (null by default)
  34685. */
  34686. loadingPluginName: string;
  34687. /**
  34688. * Use this array to add regular expressions used to disable offline support for specific urls
  34689. */
  34690. disableOfflineSupportExceptionRules: RegExp[];
  34691. /**
  34692. * An event triggered when the scene is disposed.
  34693. */
  34694. onDisposeObservable: Observable<Scene>;
  34695. private _onDisposeObserver;
  34696. /** Sets a function to be executed when this scene is disposed. */
  34697. onDispose: () => void;
  34698. /**
  34699. * An event triggered before rendering the scene (right after animations and physics)
  34700. */
  34701. onBeforeRenderObservable: Observable<Scene>;
  34702. private _onBeforeRenderObserver;
  34703. /** Sets a function to be executed before rendering this scene */
  34704. beforeRender: Nullable<() => void>;
  34705. /**
  34706. * An event triggered after rendering the scene
  34707. */
  34708. onAfterRenderObservable: Observable<Scene>;
  34709. /**
  34710. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34711. */
  34712. onAfterRenderCameraObservable: Observable<Camera>;
  34713. private _onAfterRenderObserver;
  34714. /** Sets a function to be executed after rendering this scene */
  34715. afterRender: Nullable<() => void>;
  34716. /**
  34717. * An event triggered before animating the scene
  34718. */
  34719. onBeforeAnimationsObservable: Observable<Scene>;
  34720. /**
  34721. * An event triggered after animations processing
  34722. */
  34723. onAfterAnimationsObservable: Observable<Scene>;
  34724. /**
  34725. * An event triggered before draw calls are ready to be sent
  34726. */
  34727. onBeforeDrawPhaseObservable: Observable<Scene>;
  34728. /**
  34729. * An event triggered after draw calls have been sent
  34730. */
  34731. onAfterDrawPhaseObservable: Observable<Scene>;
  34732. /**
  34733. * An event triggered when the scene is ready
  34734. */
  34735. onReadyObservable: Observable<Scene>;
  34736. /**
  34737. * An event triggered before rendering a camera
  34738. */
  34739. onBeforeCameraRenderObservable: Observable<Camera>;
  34740. private _onBeforeCameraRenderObserver;
  34741. /** Sets a function to be executed before rendering a camera*/
  34742. beforeCameraRender: () => void;
  34743. /**
  34744. * An event triggered after rendering a camera
  34745. */
  34746. onAfterCameraRenderObservable: Observable<Camera>;
  34747. private _onAfterCameraRenderObserver;
  34748. /** Sets a function to be executed after rendering a camera*/
  34749. afterCameraRender: () => void;
  34750. /**
  34751. * An event triggered when active meshes evaluation is about to start
  34752. */
  34753. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34754. /**
  34755. * An event triggered when active meshes evaluation is done
  34756. */
  34757. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34758. /**
  34759. * An event triggered when particles rendering is about to start
  34760. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34761. */
  34762. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34763. /**
  34764. * An event triggered when particles rendering is done
  34765. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34766. */
  34767. onAfterParticlesRenderingObservable: Observable<Scene>;
  34768. /**
  34769. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34770. */
  34771. onDataLoadedObservable: Observable<Scene>;
  34772. /**
  34773. * An event triggered when a camera is created
  34774. */
  34775. onNewCameraAddedObservable: Observable<Camera>;
  34776. /**
  34777. * An event triggered when a camera is removed
  34778. */
  34779. onCameraRemovedObservable: Observable<Camera>;
  34780. /**
  34781. * An event triggered when a light is created
  34782. */
  34783. onNewLightAddedObservable: Observable<Light>;
  34784. /**
  34785. * An event triggered when a light is removed
  34786. */
  34787. onLightRemovedObservable: Observable<Light>;
  34788. /**
  34789. * An event triggered when a geometry is created
  34790. */
  34791. onNewGeometryAddedObservable: Observable<Geometry>;
  34792. /**
  34793. * An event triggered when a geometry is removed
  34794. */
  34795. onGeometryRemovedObservable: Observable<Geometry>;
  34796. /**
  34797. * An event triggered when a transform node is created
  34798. */
  34799. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34800. /**
  34801. * An event triggered when a transform node is removed
  34802. */
  34803. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34804. /**
  34805. * An event triggered when a mesh is created
  34806. */
  34807. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34808. /**
  34809. * An event triggered when a mesh is removed
  34810. */
  34811. onMeshRemovedObservable: Observable<AbstractMesh>;
  34812. /**
  34813. * An event triggered when a skeleton is created
  34814. */
  34815. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34816. /**
  34817. * An event triggered when a skeleton is removed
  34818. */
  34819. onSkeletonRemovedObservable: Observable<Skeleton>;
  34820. /**
  34821. * An event triggered when a material is created
  34822. */
  34823. onNewMaterialAddedObservable: Observable<Material>;
  34824. /**
  34825. * An event triggered when a material is removed
  34826. */
  34827. onMaterialRemovedObservable: Observable<Material>;
  34828. /**
  34829. * An event triggered when a texture is created
  34830. */
  34831. onNewTextureAddedObservable: Observable<BaseTexture>;
  34832. /**
  34833. * An event triggered when a texture is removed
  34834. */
  34835. onTextureRemovedObservable: Observable<BaseTexture>;
  34836. /**
  34837. * An event triggered when render targets are about to be rendered
  34838. * Can happen multiple times per frame.
  34839. */
  34840. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34841. /**
  34842. * An event triggered when render targets were rendered.
  34843. * Can happen multiple times per frame.
  34844. */
  34845. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34846. /**
  34847. * An event triggered before calculating deterministic simulation step
  34848. */
  34849. onBeforeStepObservable: Observable<Scene>;
  34850. /**
  34851. * An event triggered after calculating deterministic simulation step
  34852. */
  34853. onAfterStepObservable: Observable<Scene>;
  34854. /**
  34855. * An event triggered when the activeCamera property is updated
  34856. */
  34857. onActiveCameraChanged: Observable<Scene>;
  34858. /**
  34859. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34860. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34861. * 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)
  34862. */
  34863. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34864. /**
  34865. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34866. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34867. * 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)
  34868. */
  34869. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34870. /**
  34871. * This Observable will when a mesh has been imported into the scene.
  34872. */
  34873. onMeshImportedObservable: Observable<AbstractMesh>;
  34874. /**
  34875. * This Observable will when an animation file has been imported into the scene.
  34876. */
  34877. onAnimationFileImportedObservable: Observable<Scene>;
  34878. /**
  34879. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34880. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34881. */
  34882. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34883. /** @hidden */
  34884. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34885. /**
  34886. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34887. */
  34888. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34889. /**
  34890. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34891. */
  34892. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34893. /**
  34894. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34895. */
  34896. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34897. /** Callback called when a pointer move is detected */
  34898. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34899. /** Callback called when a pointer down is detected */
  34900. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34901. /** Callback called when a pointer up is detected */
  34902. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34903. /** Callback called when a pointer pick is detected */
  34904. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34905. /**
  34906. * 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).
  34907. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34908. */
  34909. onPrePointerObservable: Observable<PointerInfoPre>;
  34910. /**
  34911. * Observable event triggered each time an input event is received from the rendering canvas
  34912. */
  34913. onPointerObservable: Observable<PointerInfo>;
  34914. /**
  34915. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34916. */
  34917. readonly unTranslatedPointer: Vector2;
  34918. /**
  34919. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34920. */
  34921. static DragMovementThreshold: number;
  34922. /**
  34923. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34924. */
  34925. static LongPressDelay: number;
  34926. /**
  34927. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34928. */
  34929. static DoubleClickDelay: number;
  34930. /** If you need to check double click without raising a single click at first click, enable this flag */
  34931. static ExclusiveDoubleClickMode: boolean;
  34932. /** @hidden */
  34933. _mirroredCameraPosition: Nullable<Vector3>;
  34934. /**
  34935. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34936. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34937. */
  34938. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34939. /**
  34940. * Observable event triggered each time an keyboard event is received from the hosting window
  34941. */
  34942. onKeyboardObservable: Observable<KeyboardInfo>;
  34943. private _useRightHandedSystem;
  34944. /**
  34945. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34946. */
  34947. useRightHandedSystem: boolean;
  34948. private _timeAccumulator;
  34949. private _currentStepId;
  34950. private _currentInternalStep;
  34951. /**
  34952. * Sets the step Id used by deterministic lock step
  34953. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34954. * @param newStepId defines the step Id
  34955. */
  34956. setStepId(newStepId: number): void;
  34957. /**
  34958. * Gets the step Id used by deterministic lock step
  34959. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34960. * @returns the step Id
  34961. */
  34962. getStepId(): number;
  34963. /**
  34964. * Gets the internal step used by deterministic lock step
  34965. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34966. * @returns the internal step
  34967. */
  34968. getInternalStep(): number;
  34969. private _fogEnabled;
  34970. /**
  34971. * Gets or sets a boolean indicating if fog is enabled on this scene
  34972. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34973. * (Default is true)
  34974. */
  34975. fogEnabled: boolean;
  34976. private _fogMode;
  34977. /**
  34978. * Gets or sets the fog mode to use
  34979. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34980. * | mode | value |
  34981. * | --- | --- |
  34982. * | FOGMODE_NONE | 0 |
  34983. * | FOGMODE_EXP | 1 |
  34984. * | FOGMODE_EXP2 | 2 |
  34985. * | FOGMODE_LINEAR | 3 |
  34986. */
  34987. fogMode: number;
  34988. /**
  34989. * Gets or sets the fog color to use
  34990. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34991. * (Default is Color3(0.2, 0.2, 0.3))
  34992. */
  34993. fogColor: Color3;
  34994. /**
  34995. * Gets or sets the fog density to use
  34996. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34997. * (Default is 0.1)
  34998. */
  34999. fogDensity: number;
  35000. /**
  35001. * Gets or sets the fog start distance to use
  35002. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35003. * (Default is 0)
  35004. */
  35005. fogStart: number;
  35006. /**
  35007. * Gets or sets the fog end distance to use
  35008. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35009. * (Default is 1000)
  35010. */
  35011. fogEnd: number;
  35012. private _shadowsEnabled;
  35013. /**
  35014. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35015. */
  35016. shadowsEnabled: boolean;
  35017. private _lightsEnabled;
  35018. /**
  35019. * Gets or sets a boolean indicating if lights are enabled on this scene
  35020. */
  35021. lightsEnabled: boolean;
  35022. /** All of the active cameras added to this scene. */
  35023. activeCameras: Camera[];
  35024. /** @hidden */
  35025. _activeCamera: Nullable<Camera>;
  35026. /** Gets or sets the current active camera */
  35027. activeCamera: Nullable<Camera>;
  35028. private _defaultMaterial;
  35029. /** The default material used on meshes when no material is affected */
  35030. /** The default material used on meshes when no material is affected */
  35031. defaultMaterial: Material;
  35032. private _texturesEnabled;
  35033. /**
  35034. * Gets or sets a boolean indicating if textures are enabled on this scene
  35035. */
  35036. texturesEnabled: boolean;
  35037. /**
  35038. * Gets or sets a boolean indicating if particles are enabled on this scene
  35039. */
  35040. particlesEnabled: boolean;
  35041. /**
  35042. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35043. */
  35044. spritesEnabled: boolean;
  35045. private _skeletonsEnabled;
  35046. /**
  35047. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35048. */
  35049. skeletonsEnabled: boolean;
  35050. /**
  35051. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35052. */
  35053. lensFlaresEnabled: boolean;
  35054. /**
  35055. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35056. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35057. */
  35058. collisionsEnabled: boolean;
  35059. private _collisionCoordinator;
  35060. /** @hidden */
  35061. readonly collisionCoordinator: ICollisionCoordinator;
  35062. /**
  35063. * Defines the gravity applied to this scene (used only for collisions)
  35064. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35065. */
  35066. gravity: Vector3;
  35067. /**
  35068. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35069. */
  35070. postProcessesEnabled: boolean;
  35071. /**
  35072. * The list of postprocesses added to the scene
  35073. */
  35074. postProcesses: PostProcess[];
  35075. /**
  35076. * Gets the current postprocess manager
  35077. */
  35078. postProcessManager: PostProcessManager;
  35079. /**
  35080. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35081. */
  35082. renderTargetsEnabled: boolean;
  35083. /**
  35084. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35085. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35086. */
  35087. dumpNextRenderTargets: boolean;
  35088. /**
  35089. * The list of user defined render targets added to the scene
  35090. */
  35091. customRenderTargets: RenderTargetTexture[];
  35092. /**
  35093. * Defines if texture loading must be delayed
  35094. * If true, textures will only be loaded when they need to be rendered
  35095. */
  35096. useDelayedTextureLoading: boolean;
  35097. /**
  35098. * Gets the list of meshes imported to the scene through SceneLoader
  35099. */
  35100. importedMeshesFiles: String[];
  35101. /**
  35102. * Gets or sets a boolean indicating if probes are enabled on this scene
  35103. */
  35104. probesEnabled: boolean;
  35105. /**
  35106. * Gets or sets the current offline provider to use to store scene data
  35107. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35108. */
  35109. offlineProvider: IOfflineProvider;
  35110. /**
  35111. * Gets or sets the action manager associated with the scene
  35112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35113. */
  35114. actionManager: AbstractActionManager;
  35115. private _meshesForIntersections;
  35116. /**
  35117. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35118. */
  35119. proceduralTexturesEnabled: boolean;
  35120. private _engine;
  35121. private _totalVertices;
  35122. /** @hidden */
  35123. _activeIndices: PerfCounter;
  35124. /** @hidden */
  35125. _activeParticles: PerfCounter;
  35126. /** @hidden */
  35127. _activeBones: PerfCounter;
  35128. private _animationRatio;
  35129. /** @hidden */
  35130. _animationTimeLast: number;
  35131. /** @hidden */
  35132. _animationTime: number;
  35133. /**
  35134. * Gets or sets a general scale for animation speed
  35135. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35136. */
  35137. animationTimeScale: number;
  35138. /** @hidden */
  35139. _cachedMaterial: Nullable<Material>;
  35140. /** @hidden */
  35141. _cachedEffect: Nullable<Effect>;
  35142. /** @hidden */
  35143. _cachedVisibility: Nullable<number>;
  35144. private _renderId;
  35145. private _frameId;
  35146. private _executeWhenReadyTimeoutId;
  35147. private _intermediateRendering;
  35148. private _viewUpdateFlag;
  35149. private _projectionUpdateFlag;
  35150. /** @hidden */
  35151. _toBeDisposed: Nullable<IDisposable>[];
  35152. private _activeRequests;
  35153. /** @hidden */
  35154. _pendingData: any[];
  35155. private _isDisposed;
  35156. /**
  35157. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35158. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35159. */
  35160. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35161. private _activeMeshes;
  35162. private _processedMaterials;
  35163. private _renderTargets;
  35164. /** @hidden */
  35165. _activeParticleSystems: SmartArray<IParticleSystem>;
  35166. private _activeSkeletons;
  35167. private _softwareSkinnedMeshes;
  35168. private _renderingManager;
  35169. /** @hidden */
  35170. _activeAnimatables: Animatable[];
  35171. private _transformMatrix;
  35172. private _sceneUbo;
  35173. /** @hidden */
  35174. _viewMatrix: Matrix;
  35175. private _projectionMatrix;
  35176. /** @hidden */
  35177. _forcedViewPosition: Nullable<Vector3>;
  35178. /** @hidden */
  35179. _frustumPlanes: Plane[];
  35180. /**
  35181. * Gets the list of frustum planes (built from the active camera)
  35182. */
  35183. readonly frustumPlanes: Plane[];
  35184. /**
  35185. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35186. * This is useful if there are more lights that the maximum simulteanous authorized
  35187. */
  35188. requireLightSorting: boolean;
  35189. /** @hidden */
  35190. readonly useMaterialMeshMap: boolean;
  35191. /** @hidden */
  35192. readonly useClonedMeshhMap: boolean;
  35193. private _externalData;
  35194. private _uid;
  35195. /**
  35196. * @hidden
  35197. * Backing store of defined scene components.
  35198. */
  35199. _components: ISceneComponent[];
  35200. /**
  35201. * @hidden
  35202. * Backing store of defined scene components.
  35203. */
  35204. _serializableComponents: ISceneSerializableComponent[];
  35205. /**
  35206. * List of components to register on the next registration step.
  35207. */
  35208. private _transientComponents;
  35209. /**
  35210. * Registers the transient components if needed.
  35211. */
  35212. private _registerTransientComponents;
  35213. /**
  35214. * @hidden
  35215. * Add a component to the scene.
  35216. * Note that the ccomponent could be registered on th next frame if this is called after
  35217. * the register component stage.
  35218. * @param component Defines the component to add to the scene
  35219. */
  35220. _addComponent(component: ISceneComponent): void;
  35221. /**
  35222. * @hidden
  35223. * Gets a component from the scene.
  35224. * @param name defines the name of the component to retrieve
  35225. * @returns the component or null if not present
  35226. */
  35227. _getComponent(name: string): Nullable<ISceneComponent>;
  35228. /**
  35229. * @hidden
  35230. * Defines the actions happening before camera updates.
  35231. */
  35232. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35233. /**
  35234. * @hidden
  35235. * Defines the actions happening before clear the canvas.
  35236. */
  35237. _beforeClearStage: Stage<SimpleStageAction>;
  35238. /**
  35239. * @hidden
  35240. * Defines the actions when collecting render targets for the frame.
  35241. */
  35242. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35243. /**
  35244. * @hidden
  35245. * Defines the actions happening for one camera in the frame.
  35246. */
  35247. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35248. /**
  35249. * @hidden
  35250. * Defines the actions happening during the per mesh ready checks.
  35251. */
  35252. _isReadyForMeshStage: Stage<MeshStageAction>;
  35253. /**
  35254. * @hidden
  35255. * Defines the actions happening before evaluate active mesh checks.
  35256. */
  35257. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35258. /**
  35259. * @hidden
  35260. * Defines the actions happening during the evaluate sub mesh checks.
  35261. */
  35262. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35263. /**
  35264. * @hidden
  35265. * Defines the actions happening during the active mesh stage.
  35266. */
  35267. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35268. /**
  35269. * @hidden
  35270. * Defines the actions happening during the per camera render target step.
  35271. */
  35272. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35273. /**
  35274. * @hidden
  35275. * Defines the actions happening just before the active camera is drawing.
  35276. */
  35277. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35278. /**
  35279. * @hidden
  35280. * Defines the actions happening just before a render target is drawing.
  35281. */
  35282. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35283. /**
  35284. * @hidden
  35285. * Defines the actions happening just before a rendering group is drawing.
  35286. */
  35287. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35288. /**
  35289. * @hidden
  35290. * Defines the actions happening just before a mesh is drawing.
  35291. */
  35292. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35293. /**
  35294. * @hidden
  35295. * Defines the actions happening just after a mesh has been drawn.
  35296. */
  35297. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35298. /**
  35299. * @hidden
  35300. * Defines the actions happening just after a rendering group has been drawn.
  35301. */
  35302. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35303. /**
  35304. * @hidden
  35305. * Defines the actions happening just after the active camera has been drawn.
  35306. */
  35307. _afterCameraDrawStage: Stage<CameraStageAction>;
  35308. /**
  35309. * @hidden
  35310. * Defines the actions happening just after a render target has been drawn.
  35311. */
  35312. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35313. /**
  35314. * @hidden
  35315. * Defines the actions happening just after rendering all cameras and computing intersections.
  35316. */
  35317. _afterRenderStage: Stage<SimpleStageAction>;
  35318. /**
  35319. * @hidden
  35320. * Defines the actions happening when a pointer move event happens.
  35321. */
  35322. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35323. /**
  35324. * @hidden
  35325. * Defines the actions happening when a pointer down event happens.
  35326. */
  35327. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35328. /**
  35329. * @hidden
  35330. * Defines the actions happening when a pointer up event happens.
  35331. */
  35332. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35333. /**
  35334. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35335. */
  35336. private geometriesByUniqueId;
  35337. /**
  35338. * Creates a new Scene
  35339. * @param engine defines the engine to use to render this scene
  35340. * @param options defines the scene options
  35341. */
  35342. constructor(engine: Engine, options?: SceneOptions);
  35343. /**
  35344. * Gets a string idenfifying the name of the class
  35345. * @returns "Scene" string
  35346. */
  35347. getClassName(): string;
  35348. private _defaultMeshCandidates;
  35349. /**
  35350. * @hidden
  35351. */
  35352. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35353. private _defaultSubMeshCandidates;
  35354. /**
  35355. * @hidden
  35356. */
  35357. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35358. /**
  35359. * Sets the default candidate providers for the scene.
  35360. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35361. * and getCollidingSubMeshCandidates to their default function
  35362. */
  35363. setDefaultCandidateProviders(): void;
  35364. /**
  35365. * Gets the mesh that is currently under the pointer
  35366. */
  35367. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35368. /**
  35369. * Gets or sets the current on-screen X position of the pointer
  35370. */
  35371. pointerX: number;
  35372. /**
  35373. * Gets or sets the current on-screen Y position of the pointer
  35374. */
  35375. pointerY: number;
  35376. /**
  35377. * Gets the cached material (ie. the latest rendered one)
  35378. * @returns the cached material
  35379. */
  35380. getCachedMaterial(): Nullable<Material>;
  35381. /**
  35382. * Gets the cached effect (ie. the latest rendered one)
  35383. * @returns the cached effect
  35384. */
  35385. getCachedEffect(): Nullable<Effect>;
  35386. /**
  35387. * Gets the cached visibility state (ie. the latest rendered one)
  35388. * @returns the cached visibility state
  35389. */
  35390. getCachedVisibility(): Nullable<number>;
  35391. /**
  35392. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35393. * @param material defines the current material
  35394. * @param effect defines the current effect
  35395. * @param visibility defines the current visibility state
  35396. * @returns true if one parameter is not cached
  35397. */
  35398. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35399. /**
  35400. * Gets the engine associated with the scene
  35401. * @returns an Engine
  35402. */
  35403. getEngine(): Engine;
  35404. /**
  35405. * Gets the total number of vertices rendered per frame
  35406. * @returns the total number of vertices rendered per frame
  35407. */
  35408. getTotalVertices(): number;
  35409. /**
  35410. * Gets the performance counter for total vertices
  35411. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35412. */
  35413. readonly totalVerticesPerfCounter: PerfCounter;
  35414. /**
  35415. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35416. * @returns the total number of active indices rendered per frame
  35417. */
  35418. getActiveIndices(): number;
  35419. /**
  35420. * Gets the performance counter for active indices
  35421. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35422. */
  35423. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35424. /**
  35425. * Gets the total number of active particles rendered per frame
  35426. * @returns the total number of active particles rendered per frame
  35427. */
  35428. getActiveParticles(): number;
  35429. /**
  35430. * Gets the performance counter for active particles
  35431. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35432. */
  35433. readonly activeParticlesPerfCounter: PerfCounter;
  35434. /**
  35435. * Gets the total number of active bones rendered per frame
  35436. * @returns the total number of active bones rendered per frame
  35437. */
  35438. getActiveBones(): number;
  35439. /**
  35440. * Gets the performance counter for active bones
  35441. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35442. */
  35443. readonly activeBonesPerfCounter: PerfCounter;
  35444. /**
  35445. * Gets the array of active meshes
  35446. * @returns an array of AbstractMesh
  35447. */
  35448. getActiveMeshes(): SmartArray<AbstractMesh>;
  35449. /**
  35450. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35451. * @returns a number
  35452. */
  35453. getAnimationRatio(): number;
  35454. /**
  35455. * Gets an unique Id for the current render phase
  35456. * @returns a number
  35457. */
  35458. getRenderId(): number;
  35459. /**
  35460. * Gets an unique Id for the current frame
  35461. * @returns a number
  35462. */
  35463. getFrameId(): number;
  35464. /** Call this function if you want to manually increment the render Id*/
  35465. incrementRenderId(): void;
  35466. private _createUbo;
  35467. /**
  35468. * Use this method to simulate a pointer move on a mesh
  35469. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35470. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35471. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35472. * @returns the current scene
  35473. */
  35474. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35475. /**
  35476. * Use this method to simulate a pointer down on a mesh
  35477. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35478. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35479. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35480. * @returns the current scene
  35481. */
  35482. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35483. /**
  35484. * Use this method to simulate a pointer up on a mesh
  35485. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35486. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35487. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35488. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35489. * @returns the current scene
  35490. */
  35491. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35492. /**
  35493. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35494. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35495. * @returns true if the pointer was captured
  35496. */
  35497. isPointerCaptured(pointerId?: number): boolean;
  35498. /**
  35499. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35500. * @param attachUp defines if you want to attach events to pointerup
  35501. * @param attachDown defines if you want to attach events to pointerdown
  35502. * @param attachMove defines if you want to attach events to pointermove
  35503. */
  35504. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35505. /** Detaches all event handlers*/
  35506. detachControl(): void;
  35507. /**
  35508. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35509. * Delay loaded resources are not taking in account
  35510. * @return true if all required resources are ready
  35511. */
  35512. isReady(): boolean;
  35513. /** Resets all cached information relative to material (including effect and visibility) */
  35514. resetCachedMaterial(): void;
  35515. /**
  35516. * Registers a function to be called before every frame render
  35517. * @param func defines the function to register
  35518. */
  35519. registerBeforeRender(func: () => void): void;
  35520. /**
  35521. * Unregisters a function called before every frame render
  35522. * @param func defines the function to unregister
  35523. */
  35524. unregisterBeforeRender(func: () => void): void;
  35525. /**
  35526. * Registers a function to be called after every frame render
  35527. * @param func defines the function to register
  35528. */
  35529. registerAfterRender(func: () => void): void;
  35530. /**
  35531. * Unregisters a function called after every frame render
  35532. * @param func defines the function to unregister
  35533. */
  35534. unregisterAfterRender(func: () => void): void;
  35535. private _executeOnceBeforeRender;
  35536. /**
  35537. * The provided function will run before render once and will be disposed afterwards.
  35538. * A timeout delay can be provided so that the function will be executed in N ms.
  35539. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35540. * @param func The function to be executed.
  35541. * @param timeout optional delay in ms
  35542. */
  35543. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35544. /** @hidden */
  35545. _addPendingData(data: any): void;
  35546. /** @hidden */
  35547. _removePendingData(data: any): void;
  35548. /**
  35549. * Returns the number of items waiting to be loaded
  35550. * @returns the number of items waiting to be loaded
  35551. */
  35552. getWaitingItemsCount(): number;
  35553. /**
  35554. * Returns a boolean indicating if the scene is still loading data
  35555. */
  35556. readonly isLoading: boolean;
  35557. /**
  35558. * Registers a function to be executed when the scene is ready
  35559. * @param {Function} func - the function to be executed
  35560. */
  35561. executeWhenReady(func: () => void): void;
  35562. /**
  35563. * Returns a promise that resolves when the scene is ready
  35564. * @returns A promise that resolves when the scene is ready
  35565. */
  35566. whenReadyAsync(): Promise<void>;
  35567. /** @hidden */
  35568. _checkIsReady(): void;
  35569. /**
  35570. * Gets all animatable attached to the scene
  35571. */
  35572. readonly animatables: Animatable[];
  35573. /**
  35574. * Resets the last animation time frame.
  35575. * Useful to override when animations start running when loading a scene for the first time.
  35576. */
  35577. resetLastAnimationTimeFrame(): void;
  35578. /**
  35579. * Gets the current view matrix
  35580. * @returns a Matrix
  35581. */
  35582. getViewMatrix(): Matrix;
  35583. /**
  35584. * Gets the current projection matrix
  35585. * @returns a Matrix
  35586. */
  35587. getProjectionMatrix(): Matrix;
  35588. /**
  35589. * Gets the current transform matrix
  35590. * @returns a Matrix made of View * Projection
  35591. */
  35592. getTransformMatrix(): Matrix;
  35593. /**
  35594. * Sets the current transform matrix
  35595. * @param viewL defines the View matrix to use
  35596. * @param projectionL defines the Projection matrix to use
  35597. * @param viewR defines the right View matrix to use (if provided)
  35598. * @param projectionR defines the right Projection matrix to use (if provided)
  35599. */
  35600. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35601. /**
  35602. * Gets the uniform buffer used to store scene data
  35603. * @returns a UniformBuffer
  35604. */
  35605. getSceneUniformBuffer(): UniformBuffer;
  35606. /**
  35607. * Gets an unique (relatively to the current scene) Id
  35608. * @returns an unique number for the scene
  35609. */
  35610. getUniqueId(): number;
  35611. /**
  35612. * Add a mesh to the list of scene's meshes
  35613. * @param newMesh defines the mesh to add
  35614. * @param recursive if all child meshes should also be added to the scene
  35615. */
  35616. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35617. /**
  35618. * Remove a mesh for the list of scene's meshes
  35619. * @param toRemove defines the mesh to remove
  35620. * @param recursive if all child meshes should also be removed from the scene
  35621. * @returns the index where the mesh was in the mesh list
  35622. */
  35623. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35624. /**
  35625. * Add a transform node to the list of scene's transform nodes
  35626. * @param newTransformNode defines the transform node to add
  35627. */
  35628. addTransformNode(newTransformNode: TransformNode): void;
  35629. /**
  35630. * Remove a transform node for the list of scene's transform nodes
  35631. * @param toRemove defines the transform node to remove
  35632. * @returns the index where the transform node was in the transform node list
  35633. */
  35634. removeTransformNode(toRemove: TransformNode): number;
  35635. /**
  35636. * Remove a skeleton for the list of scene's skeletons
  35637. * @param toRemove defines the skeleton to remove
  35638. * @returns the index where the skeleton was in the skeleton list
  35639. */
  35640. removeSkeleton(toRemove: Skeleton): number;
  35641. /**
  35642. * Remove a morph target for the list of scene's morph targets
  35643. * @param toRemove defines the morph target to remove
  35644. * @returns the index where the morph target was in the morph target list
  35645. */
  35646. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35647. /**
  35648. * Remove a light for the list of scene's lights
  35649. * @param toRemove defines the light to remove
  35650. * @returns the index where the light was in the light list
  35651. */
  35652. removeLight(toRemove: Light): number;
  35653. /**
  35654. * Remove a camera for the list of scene's cameras
  35655. * @param toRemove defines the camera to remove
  35656. * @returns the index where the camera was in the camera list
  35657. */
  35658. removeCamera(toRemove: Camera): number;
  35659. /**
  35660. * Remove a particle system for the list of scene's particle systems
  35661. * @param toRemove defines the particle system to remove
  35662. * @returns the index where the particle system was in the particle system list
  35663. */
  35664. removeParticleSystem(toRemove: IParticleSystem): number;
  35665. /**
  35666. * Remove a animation for the list of scene's animations
  35667. * @param toRemove defines the animation to remove
  35668. * @returns the index where the animation was in the animation list
  35669. */
  35670. removeAnimation(toRemove: Animation): number;
  35671. /**
  35672. * Will stop the animation of the given target
  35673. * @param target - the target
  35674. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35675. * @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)
  35676. */
  35677. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35678. /**
  35679. * Removes the given animation group from this scene.
  35680. * @param toRemove The animation group to remove
  35681. * @returns The index of the removed animation group
  35682. */
  35683. removeAnimationGroup(toRemove: AnimationGroup): number;
  35684. /**
  35685. * Removes the given multi-material from this scene.
  35686. * @param toRemove The multi-material to remove
  35687. * @returns The index of the removed multi-material
  35688. */
  35689. removeMultiMaterial(toRemove: MultiMaterial): number;
  35690. /**
  35691. * Removes the given material from this scene.
  35692. * @param toRemove The material to remove
  35693. * @returns The index of the removed material
  35694. */
  35695. removeMaterial(toRemove: Material): number;
  35696. /**
  35697. * Removes the given action manager from this scene.
  35698. * @param toRemove The action manager to remove
  35699. * @returns The index of the removed action manager
  35700. */
  35701. removeActionManager(toRemove: AbstractActionManager): number;
  35702. /**
  35703. * Removes the given texture from this scene.
  35704. * @param toRemove The texture to remove
  35705. * @returns The index of the removed texture
  35706. */
  35707. removeTexture(toRemove: BaseTexture): number;
  35708. /**
  35709. * Adds the given light to this scene
  35710. * @param newLight The light to add
  35711. */
  35712. addLight(newLight: Light): void;
  35713. /**
  35714. * Sorts the list list based on light priorities
  35715. */
  35716. sortLightsByPriority(): void;
  35717. /**
  35718. * Adds the given camera to this scene
  35719. * @param newCamera The camera to add
  35720. */
  35721. addCamera(newCamera: Camera): void;
  35722. /**
  35723. * Adds the given skeleton to this scene
  35724. * @param newSkeleton The skeleton to add
  35725. */
  35726. addSkeleton(newSkeleton: Skeleton): void;
  35727. /**
  35728. * Adds the given particle system to this scene
  35729. * @param newParticleSystem The particle system to add
  35730. */
  35731. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35732. /**
  35733. * Adds the given animation to this scene
  35734. * @param newAnimation The animation to add
  35735. */
  35736. addAnimation(newAnimation: Animation): void;
  35737. /**
  35738. * Adds the given animation group to this scene.
  35739. * @param newAnimationGroup The animation group to add
  35740. */
  35741. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35742. /**
  35743. * Adds the given multi-material to this scene
  35744. * @param newMultiMaterial The multi-material to add
  35745. */
  35746. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35747. /**
  35748. * Adds the given material to this scene
  35749. * @param newMaterial The material to add
  35750. */
  35751. addMaterial(newMaterial: Material): void;
  35752. /**
  35753. * Adds the given morph target to this scene
  35754. * @param newMorphTargetManager The morph target to add
  35755. */
  35756. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35757. /**
  35758. * Adds the given geometry to this scene
  35759. * @param newGeometry The geometry to add
  35760. */
  35761. addGeometry(newGeometry: Geometry): void;
  35762. /**
  35763. * Adds the given action manager to this scene
  35764. * @param newActionManager The action manager to add
  35765. */
  35766. addActionManager(newActionManager: AbstractActionManager): void;
  35767. /**
  35768. * Adds the given texture to this scene.
  35769. * @param newTexture The texture to add
  35770. */
  35771. addTexture(newTexture: BaseTexture): void;
  35772. /**
  35773. * Switch active camera
  35774. * @param newCamera defines the new active camera
  35775. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35776. */
  35777. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35778. /**
  35779. * sets the active camera of the scene using its ID
  35780. * @param id defines the camera's ID
  35781. * @return the new active camera or null if none found.
  35782. */
  35783. setActiveCameraByID(id: string): Nullable<Camera>;
  35784. /**
  35785. * sets the active camera of the scene using its name
  35786. * @param name defines the camera's name
  35787. * @returns the new active camera or null if none found.
  35788. */
  35789. setActiveCameraByName(name: string): Nullable<Camera>;
  35790. /**
  35791. * get an animation group using its name
  35792. * @param name defines the material's name
  35793. * @return the animation group or null if none found.
  35794. */
  35795. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35796. /**
  35797. * Get a material using its unique id
  35798. * @param uniqueId defines the material's unique id
  35799. * @return the material or null if none found.
  35800. */
  35801. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35802. /**
  35803. * get a material using its id
  35804. * @param id defines the material's ID
  35805. * @return the material or null if none found.
  35806. */
  35807. getMaterialByID(id: string): Nullable<Material>;
  35808. /**
  35809. * Gets a the last added material using a given id
  35810. * @param id defines the material's ID
  35811. * @return the last material with the given id or null if none found.
  35812. */
  35813. getLastMaterialByID(id: string): Nullable<Material>;
  35814. /**
  35815. * Gets a material using its name
  35816. * @param name defines the material's name
  35817. * @return the material or null if none found.
  35818. */
  35819. getMaterialByName(name: string): Nullable<Material>;
  35820. /**
  35821. * Get a texture using its unique id
  35822. * @param uniqueId defines the texture's unique id
  35823. * @return the texture or null if none found.
  35824. */
  35825. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35826. /**
  35827. * Gets a camera using its id
  35828. * @param id defines the id to look for
  35829. * @returns the camera or null if not found
  35830. */
  35831. getCameraByID(id: string): Nullable<Camera>;
  35832. /**
  35833. * Gets a camera using its unique id
  35834. * @param uniqueId defines the unique id to look for
  35835. * @returns the camera or null if not found
  35836. */
  35837. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35838. /**
  35839. * Gets a camera using its name
  35840. * @param name defines the camera's name
  35841. * @return the camera or null if none found.
  35842. */
  35843. getCameraByName(name: string): Nullable<Camera>;
  35844. /**
  35845. * Gets a bone using its id
  35846. * @param id defines the bone's id
  35847. * @return the bone or null if not found
  35848. */
  35849. getBoneByID(id: string): Nullable<Bone>;
  35850. /**
  35851. * Gets a bone using its id
  35852. * @param name defines the bone's name
  35853. * @return the bone or null if not found
  35854. */
  35855. getBoneByName(name: string): Nullable<Bone>;
  35856. /**
  35857. * Gets a light node using its name
  35858. * @param name defines the the light's name
  35859. * @return the light or null if none found.
  35860. */
  35861. getLightByName(name: string): Nullable<Light>;
  35862. /**
  35863. * Gets a light node using its id
  35864. * @param id defines the light's id
  35865. * @return the light or null if none found.
  35866. */
  35867. getLightByID(id: string): Nullable<Light>;
  35868. /**
  35869. * Gets a light node using its scene-generated unique ID
  35870. * @param uniqueId defines the light's unique id
  35871. * @return the light or null if none found.
  35872. */
  35873. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35874. /**
  35875. * Gets a particle system by id
  35876. * @param id defines the particle system id
  35877. * @return the corresponding system or null if none found
  35878. */
  35879. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35880. /**
  35881. * Gets a geometry using its ID
  35882. * @param id defines the geometry's id
  35883. * @return the geometry or null if none found.
  35884. */
  35885. getGeometryByID(id: string): Nullable<Geometry>;
  35886. private _getGeometryByUniqueID;
  35887. /**
  35888. * Add a new geometry to this scene
  35889. * @param geometry defines the geometry to be added to the scene.
  35890. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35891. * @return a boolean defining if the geometry was added or not
  35892. */
  35893. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35894. /**
  35895. * Removes an existing geometry
  35896. * @param geometry defines the geometry to be removed from the scene
  35897. * @return a boolean defining if the geometry was removed or not
  35898. */
  35899. removeGeometry(geometry: Geometry): boolean;
  35900. /**
  35901. * Gets the list of geometries attached to the scene
  35902. * @returns an array of Geometry
  35903. */
  35904. getGeometries(): Geometry[];
  35905. /**
  35906. * Gets the first added mesh found of a given ID
  35907. * @param id defines the id to search for
  35908. * @return the mesh found or null if not found at all
  35909. */
  35910. getMeshByID(id: string): Nullable<AbstractMesh>;
  35911. /**
  35912. * Gets a list of meshes using their id
  35913. * @param id defines the id to search for
  35914. * @returns a list of meshes
  35915. */
  35916. getMeshesByID(id: string): Array<AbstractMesh>;
  35917. /**
  35918. * Gets the first added transform node found of a given ID
  35919. * @param id defines the id to search for
  35920. * @return the found transform node or null if not found at all.
  35921. */
  35922. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35923. /**
  35924. * Gets a transform node with its auto-generated unique id
  35925. * @param uniqueId efines the unique id to search for
  35926. * @return the found transform node or null if not found at all.
  35927. */
  35928. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35929. /**
  35930. * Gets a list of transform nodes using their id
  35931. * @param id defines the id to search for
  35932. * @returns a list of transform nodes
  35933. */
  35934. getTransformNodesByID(id: string): Array<TransformNode>;
  35935. /**
  35936. * Gets a mesh with its auto-generated unique id
  35937. * @param uniqueId defines the unique id to search for
  35938. * @return the found mesh or null if not found at all.
  35939. */
  35940. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35941. /**
  35942. * Gets a the last added mesh using a given id
  35943. * @param id defines the id to search for
  35944. * @return the found mesh or null if not found at all.
  35945. */
  35946. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35947. /**
  35948. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35949. * @param id defines the id to search for
  35950. * @return the found node or null if not found at all
  35951. */
  35952. getLastEntryByID(id: string): Nullable<Node>;
  35953. /**
  35954. * Gets a node (Mesh, Camera, Light) using a given id
  35955. * @param id defines the id to search for
  35956. * @return the found node or null if not found at all
  35957. */
  35958. getNodeByID(id: string): Nullable<Node>;
  35959. /**
  35960. * Gets a node (Mesh, Camera, Light) using a given name
  35961. * @param name defines the name to search for
  35962. * @return the found node or null if not found at all.
  35963. */
  35964. getNodeByName(name: string): Nullable<Node>;
  35965. /**
  35966. * Gets a mesh using a given name
  35967. * @param name defines the name to search for
  35968. * @return the found mesh or null if not found at all.
  35969. */
  35970. getMeshByName(name: string): Nullable<AbstractMesh>;
  35971. /**
  35972. * Gets a transform node using a given name
  35973. * @param name defines the name to search for
  35974. * @return the found transform node or null if not found at all.
  35975. */
  35976. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35977. /**
  35978. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35979. * @param id defines the id to search for
  35980. * @return the found skeleton or null if not found at all.
  35981. */
  35982. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35983. /**
  35984. * Gets a skeleton using a given auto generated unique id
  35985. * @param uniqueId defines the unique id to search for
  35986. * @return the found skeleton or null if not found at all.
  35987. */
  35988. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35989. /**
  35990. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35991. * @param id defines the id to search for
  35992. * @return the found skeleton or null if not found at all.
  35993. */
  35994. getSkeletonById(id: string): Nullable<Skeleton>;
  35995. /**
  35996. * Gets a skeleton using a given name
  35997. * @param name defines the name to search for
  35998. * @return the found skeleton or null if not found at all.
  35999. */
  36000. getSkeletonByName(name: string): Nullable<Skeleton>;
  36001. /**
  36002. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36003. * @param id defines the id to search for
  36004. * @return the found morph target manager or null if not found at all.
  36005. */
  36006. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36007. /**
  36008. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36009. * @param id defines the id to search for
  36010. * @return the found morph target or null if not found at all.
  36011. */
  36012. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36013. /**
  36014. * Gets a boolean indicating if the given mesh is active
  36015. * @param mesh defines the mesh to look for
  36016. * @returns true if the mesh is in the active list
  36017. */
  36018. isActiveMesh(mesh: AbstractMesh): boolean;
  36019. /**
  36020. * Return a unique id as a string which can serve as an identifier for the scene
  36021. */
  36022. readonly uid: string;
  36023. /**
  36024. * Add an externaly attached data from its key.
  36025. * This method call will fail and return false, if such key already exists.
  36026. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36027. * @param key the unique key that identifies the data
  36028. * @param data the data object to associate to the key for this Engine instance
  36029. * @return true if no such key were already present and the data was added successfully, false otherwise
  36030. */
  36031. addExternalData<T>(key: string, data: T): boolean;
  36032. /**
  36033. * Get an externaly attached data from its key
  36034. * @param key the unique key that identifies the data
  36035. * @return the associated data, if present (can be null), or undefined if not present
  36036. */
  36037. getExternalData<T>(key: string): Nullable<T>;
  36038. /**
  36039. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36040. * @param key the unique key that identifies the data
  36041. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36042. * @return the associated data, can be null if the factory returned null.
  36043. */
  36044. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36045. /**
  36046. * Remove an externaly attached data from the Engine instance
  36047. * @param key the unique key that identifies the data
  36048. * @return true if the data was successfully removed, false if it doesn't exist
  36049. */
  36050. removeExternalData(key: string): boolean;
  36051. private _evaluateSubMesh;
  36052. /**
  36053. * Clear the processed materials smart array preventing retention point in material dispose.
  36054. */
  36055. freeProcessedMaterials(): void;
  36056. private _preventFreeActiveMeshesAndRenderingGroups;
  36057. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36058. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36059. * when disposing several meshes in a row or a hierarchy of meshes.
  36060. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36061. */
  36062. blockfreeActiveMeshesAndRenderingGroups: boolean;
  36063. /**
  36064. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36065. */
  36066. freeActiveMeshes(): void;
  36067. /**
  36068. * Clear the info related to rendering groups preventing retention points during dispose.
  36069. */
  36070. freeRenderingGroups(): void;
  36071. /** @hidden */
  36072. _isInIntermediateRendering(): boolean;
  36073. /**
  36074. * Lambda returning the list of potentially active meshes.
  36075. */
  36076. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36077. /**
  36078. * Lambda returning the list of potentially active sub meshes.
  36079. */
  36080. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36081. /**
  36082. * Lambda returning the list of potentially intersecting sub meshes.
  36083. */
  36084. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36085. /**
  36086. * Lambda returning the list of potentially colliding sub meshes.
  36087. */
  36088. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36089. private _activeMeshesFrozen;
  36090. private _skipEvaluateActiveMeshesCompletely;
  36091. /**
  36092. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36093. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36094. * @returns the current scene
  36095. */
  36096. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36097. /**
  36098. * Use this function to restart evaluating active meshes on every frame
  36099. * @returns the current scene
  36100. */
  36101. unfreezeActiveMeshes(): Scene;
  36102. private _evaluateActiveMeshes;
  36103. private _activeMesh;
  36104. /**
  36105. * Update the transform matrix to update from the current active camera
  36106. * @param force defines a boolean used to force the update even if cache is up to date
  36107. */
  36108. updateTransformMatrix(force?: boolean): void;
  36109. private _bindFrameBuffer;
  36110. /** @hidden */
  36111. _allowPostProcessClearColor: boolean;
  36112. /** @hidden */
  36113. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36114. private _processSubCameras;
  36115. private _checkIntersections;
  36116. /** @hidden */
  36117. _advancePhysicsEngineStep(step: number): void;
  36118. /**
  36119. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36120. */
  36121. getDeterministicFrameTime: () => number;
  36122. /** @hidden */
  36123. _animate(): void;
  36124. /** Execute all animations (for a frame) */
  36125. animate(): void;
  36126. /**
  36127. * Render the scene
  36128. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36129. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36130. */
  36131. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36132. /**
  36133. * Freeze all materials
  36134. * A frozen material will not be updatable but should be faster to render
  36135. */
  36136. freezeMaterials(): void;
  36137. /**
  36138. * Unfreeze all materials
  36139. * A frozen material will not be updatable but should be faster to render
  36140. */
  36141. unfreezeMaterials(): void;
  36142. /**
  36143. * Releases all held ressources
  36144. */
  36145. dispose(): void;
  36146. /**
  36147. * Gets if the scene is already disposed
  36148. */
  36149. readonly isDisposed: boolean;
  36150. /**
  36151. * Call this function to reduce memory footprint of the scene.
  36152. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36153. */
  36154. clearCachedVertexData(): void;
  36155. /**
  36156. * This function will remove the local cached buffer data from texture.
  36157. * It will save memory but will prevent the texture from being rebuilt
  36158. */
  36159. cleanCachedTextureBuffer(): void;
  36160. /**
  36161. * Get the world extend vectors with an optional filter
  36162. *
  36163. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36164. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36165. */
  36166. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36167. min: Vector3;
  36168. max: Vector3;
  36169. };
  36170. /**
  36171. * Creates a ray that can be used to pick in the scene
  36172. * @param x defines the x coordinate of the origin (on-screen)
  36173. * @param y defines the y coordinate of the origin (on-screen)
  36174. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36175. * @param camera defines the camera to use for the picking
  36176. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36177. * @returns a Ray
  36178. */
  36179. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36180. /**
  36181. * Creates a ray that can be used to pick in the scene
  36182. * @param x defines the x coordinate of the origin (on-screen)
  36183. * @param y defines the y coordinate of the origin (on-screen)
  36184. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36185. * @param result defines the ray where to store the picking ray
  36186. * @param camera defines the camera to use for the picking
  36187. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36188. * @returns the current scene
  36189. */
  36190. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36191. /**
  36192. * Creates a ray that can be used to pick in the scene
  36193. * @param x defines the x coordinate of the origin (on-screen)
  36194. * @param y defines the y coordinate of the origin (on-screen)
  36195. * @param camera defines the camera to use for the picking
  36196. * @returns a Ray
  36197. */
  36198. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36199. /**
  36200. * Creates a ray that can be used to pick in the scene
  36201. * @param x defines the x coordinate of the origin (on-screen)
  36202. * @param y defines the y coordinate of the origin (on-screen)
  36203. * @param result defines the ray where to store the picking ray
  36204. * @param camera defines the camera to use for the picking
  36205. * @returns the current scene
  36206. */
  36207. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36208. /** Launch a ray to try to pick a mesh in the scene
  36209. * @param x position on screen
  36210. * @param y position on screen
  36211. * @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
  36212. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36213. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36214. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36215. * @returns a PickingInfo
  36216. */
  36217. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36218. /** Use the given ray to pick a mesh in the scene
  36219. * @param ray The ray to use to pick meshes
  36220. * @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
  36221. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36222. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36223. * @returns a PickingInfo
  36224. */
  36225. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36226. /**
  36227. * Launch a ray to try to pick a mesh in the scene
  36228. * @param x X position on screen
  36229. * @param y Y position on screen
  36230. * @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
  36231. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36232. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36233. * @returns an array of PickingInfo
  36234. */
  36235. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36236. /**
  36237. * Launch a ray to try to pick a mesh in the scene
  36238. * @param ray Ray to use
  36239. * @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
  36240. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36241. * @returns an array of PickingInfo
  36242. */
  36243. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36244. /**
  36245. * Force the value of meshUnderPointer
  36246. * @param mesh defines the mesh to use
  36247. */
  36248. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36249. /**
  36250. * Gets the mesh under the pointer
  36251. * @returns a Mesh or null if no mesh is under the pointer
  36252. */
  36253. getPointerOverMesh(): Nullable<AbstractMesh>;
  36254. /** @hidden */
  36255. _rebuildGeometries(): void;
  36256. /** @hidden */
  36257. _rebuildTextures(): void;
  36258. private _getByTags;
  36259. /**
  36260. * Get a list of meshes by tags
  36261. * @param tagsQuery defines the tags query to use
  36262. * @param forEach defines a predicate used to filter results
  36263. * @returns an array of Mesh
  36264. */
  36265. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36266. /**
  36267. * Get a list of cameras by tags
  36268. * @param tagsQuery defines the tags query to use
  36269. * @param forEach defines a predicate used to filter results
  36270. * @returns an array of Camera
  36271. */
  36272. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36273. /**
  36274. * Get a list of lights by tags
  36275. * @param tagsQuery defines the tags query to use
  36276. * @param forEach defines a predicate used to filter results
  36277. * @returns an array of Light
  36278. */
  36279. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36280. /**
  36281. * Get a list of materials by tags
  36282. * @param tagsQuery defines the tags query to use
  36283. * @param forEach defines a predicate used to filter results
  36284. * @returns an array of Material
  36285. */
  36286. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36287. /**
  36288. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36289. * This allowed control for front to back rendering or reversly depending of the special needs.
  36290. *
  36291. * @param renderingGroupId The rendering group id corresponding to its index
  36292. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36293. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36294. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36295. */
  36296. 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;
  36297. /**
  36298. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36299. *
  36300. * @param renderingGroupId The rendering group id corresponding to its index
  36301. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36302. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36303. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36304. */
  36305. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36306. /**
  36307. * Gets the current auto clear configuration for one rendering group of the rendering
  36308. * manager.
  36309. * @param index the rendering group index to get the information for
  36310. * @returns The auto clear setup for the requested rendering group
  36311. */
  36312. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36313. private _blockMaterialDirtyMechanism;
  36314. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36315. blockMaterialDirtyMechanism: boolean;
  36316. /**
  36317. * Will flag all materials as dirty to trigger new shader compilation
  36318. * @param flag defines the flag used to specify which material part must be marked as dirty
  36319. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36320. */
  36321. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36322. /** @hidden */
  36323. _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;
  36324. /** @hidden */
  36325. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36326. /** @hidden */
  36327. _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;
  36328. /** @hidden */
  36329. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36330. /** @hidden */
  36331. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36332. /** @hidden */
  36333. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36334. }
  36335. }
  36336. declare module BABYLON {
  36337. /**
  36338. * Set of assets to keep when moving a scene into an asset container.
  36339. */
  36340. export class KeepAssets extends AbstractScene {
  36341. }
  36342. /**
  36343. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36344. */
  36345. export class InstantiatedEntries {
  36346. /**
  36347. * List of new root nodes (eg. nodes with no parent)
  36348. */
  36349. rootNodes: TransformNode[];
  36350. /**
  36351. * List of new skeletons
  36352. */
  36353. skeletons: Skeleton[];
  36354. /**
  36355. * List of new animation groups
  36356. */
  36357. animationGroups: AnimationGroup[];
  36358. }
  36359. /**
  36360. * Container with a set of assets that can be added or removed from a scene.
  36361. */
  36362. export class AssetContainer extends AbstractScene {
  36363. /**
  36364. * The scene the AssetContainer belongs to.
  36365. */
  36366. scene: Scene;
  36367. /**
  36368. * Instantiates an AssetContainer.
  36369. * @param scene The scene the AssetContainer belongs to.
  36370. */
  36371. constructor(scene: Scene);
  36372. /**
  36373. * Instantiate or clone all meshes and add the new ones to the scene.
  36374. * Skeletons and animation groups will all be cloned
  36375. * @param nameFunction defines an optional function used to get new names for clones
  36376. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36377. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36378. */
  36379. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36380. /**
  36381. * Adds all the assets from the container to the scene.
  36382. */
  36383. addAllToScene(): void;
  36384. /**
  36385. * Removes all the assets in the container from the scene
  36386. */
  36387. removeAllFromScene(): void;
  36388. /**
  36389. * Disposes all the assets in the container
  36390. */
  36391. dispose(): void;
  36392. private _moveAssets;
  36393. /**
  36394. * Removes all the assets contained in the scene and adds them to the container.
  36395. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36396. */
  36397. moveAllFromScene(keepAssets?: KeepAssets): void;
  36398. /**
  36399. * 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.
  36400. * @returns the root mesh
  36401. */
  36402. createRootMesh(): Mesh;
  36403. /**
  36404. * Merge animations from this asset container into a scene
  36405. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36406. * @param animatables set of animatables to retarget to a node from the scene
  36407. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36408. */
  36409. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36410. }
  36411. }
  36412. declare module BABYLON {
  36413. /**
  36414. * Defines how the parser contract is defined.
  36415. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36416. */
  36417. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36418. /**
  36419. * Defines how the individual parser contract is defined.
  36420. * These parser can parse an individual asset
  36421. */
  36422. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36423. /**
  36424. * Base class of the scene acting as a container for the different elements composing a scene.
  36425. * This class is dynamically extended by the different components of the scene increasing
  36426. * flexibility and reducing coupling
  36427. */
  36428. export abstract class AbstractScene {
  36429. /**
  36430. * Stores the list of available parsers in the application.
  36431. */
  36432. private static _BabylonFileParsers;
  36433. /**
  36434. * Stores the list of available individual parsers in the application.
  36435. */
  36436. private static _IndividualBabylonFileParsers;
  36437. /**
  36438. * Adds a parser in the list of available ones
  36439. * @param name Defines the name of the parser
  36440. * @param parser Defines the parser to add
  36441. */
  36442. static AddParser(name: string, parser: BabylonFileParser): void;
  36443. /**
  36444. * Gets a general parser from the list of avaialble ones
  36445. * @param name Defines the name of the parser
  36446. * @returns the requested parser or null
  36447. */
  36448. static GetParser(name: string): Nullable<BabylonFileParser>;
  36449. /**
  36450. * Adds n individual parser in the list of available ones
  36451. * @param name Defines the name of the parser
  36452. * @param parser Defines the parser to add
  36453. */
  36454. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36455. /**
  36456. * Gets an individual parser from the list of avaialble ones
  36457. * @param name Defines the name of the parser
  36458. * @returns the requested parser or null
  36459. */
  36460. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36461. /**
  36462. * Parser json data and populate both a scene and its associated container object
  36463. * @param jsonData Defines the data to parse
  36464. * @param scene Defines the scene to parse the data for
  36465. * @param container Defines the container attached to the parsing sequence
  36466. * @param rootUrl Defines the root url of the data
  36467. */
  36468. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36469. /**
  36470. * Gets the list of root nodes (ie. nodes with no parent)
  36471. */
  36472. rootNodes: Node[];
  36473. /** All of the cameras added to this scene
  36474. * @see http://doc.babylonjs.com/babylon101/cameras
  36475. */
  36476. cameras: Camera[];
  36477. /**
  36478. * All of the lights added to this scene
  36479. * @see http://doc.babylonjs.com/babylon101/lights
  36480. */
  36481. lights: Light[];
  36482. /**
  36483. * All of the (abstract) meshes added to this scene
  36484. */
  36485. meshes: AbstractMesh[];
  36486. /**
  36487. * The list of skeletons added to the scene
  36488. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36489. */
  36490. skeletons: Skeleton[];
  36491. /**
  36492. * All of the particle systems added to this scene
  36493. * @see http://doc.babylonjs.com/babylon101/particles
  36494. */
  36495. particleSystems: IParticleSystem[];
  36496. /**
  36497. * Gets a list of Animations associated with the scene
  36498. */
  36499. animations: Animation[];
  36500. /**
  36501. * All of the animation groups added to this scene
  36502. * @see http://doc.babylonjs.com/how_to/group
  36503. */
  36504. animationGroups: AnimationGroup[];
  36505. /**
  36506. * All of the multi-materials added to this scene
  36507. * @see http://doc.babylonjs.com/how_to/multi_materials
  36508. */
  36509. multiMaterials: MultiMaterial[];
  36510. /**
  36511. * All of the materials added to this scene
  36512. * In the context of a Scene, it is not supposed to be modified manually.
  36513. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36514. * Note also that the order of the Material within the array is not significant and might change.
  36515. * @see http://doc.babylonjs.com/babylon101/materials
  36516. */
  36517. materials: Material[];
  36518. /**
  36519. * The list of morph target managers added to the scene
  36520. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36521. */
  36522. morphTargetManagers: MorphTargetManager[];
  36523. /**
  36524. * The list of geometries used in the scene.
  36525. */
  36526. geometries: Geometry[];
  36527. /**
  36528. * All of the tranform nodes added to this scene
  36529. * In the context of a Scene, it is not supposed to be modified manually.
  36530. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36531. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36532. * @see http://doc.babylonjs.com/how_to/transformnode
  36533. */
  36534. transformNodes: TransformNode[];
  36535. /**
  36536. * ActionManagers available on the scene.
  36537. */
  36538. actionManagers: AbstractActionManager[];
  36539. /**
  36540. * Textures to keep.
  36541. */
  36542. textures: BaseTexture[];
  36543. /**
  36544. * Environment texture for the scene
  36545. */
  36546. environmentTexture: Nullable<BaseTexture>;
  36547. /**
  36548. * @returns all meshes, lights, cameras, transformNodes and bones
  36549. */
  36550. getNodes(): Array<Node>;
  36551. }
  36552. }
  36553. declare module BABYLON {
  36554. /**
  36555. * Interface used to define options for Sound class
  36556. */
  36557. export interface ISoundOptions {
  36558. /**
  36559. * Does the sound autoplay once loaded.
  36560. */
  36561. autoplay?: boolean;
  36562. /**
  36563. * Does the sound loop after it finishes playing once.
  36564. */
  36565. loop?: boolean;
  36566. /**
  36567. * Sound's volume
  36568. */
  36569. volume?: number;
  36570. /**
  36571. * Is it a spatial sound?
  36572. */
  36573. spatialSound?: boolean;
  36574. /**
  36575. * Maximum distance to hear that sound
  36576. */
  36577. maxDistance?: number;
  36578. /**
  36579. * Uses user defined attenuation function
  36580. */
  36581. useCustomAttenuation?: boolean;
  36582. /**
  36583. * Define the roll off factor of spatial sounds.
  36584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36585. */
  36586. rolloffFactor?: number;
  36587. /**
  36588. * Define the reference distance the sound should be heard perfectly.
  36589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36590. */
  36591. refDistance?: number;
  36592. /**
  36593. * Define the distance attenuation model the sound will follow.
  36594. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36595. */
  36596. distanceModel?: string;
  36597. /**
  36598. * Defines the playback speed (1 by default)
  36599. */
  36600. playbackRate?: number;
  36601. /**
  36602. * Defines if the sound is from a streaming source
  36603. */
  36604. streaming?: boolean;
  36605. /**
  36606. * Defines an optional length (in seconds) inside the sound file
  36607. */
  36608. length?: number;
  36609. /**
  36610. * Defines an optional offset (in seconds) inside the sound file
  36611. */
  36612. offset?: number;
  36613. /**
  36614. * If true, URLs will not be required to state the audio file codec to use.
  36615. */
  36616. skipCodecCheck?: boolean;
  36617. }
  36618. /**
  36619. * Defines a sound that can be played in the application.
  36620. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36622. */
  36623. export class Sound {
  36624. /**
  36625. * The name of the sound in the scene.
  36626. */
  36627. name: string;
  36628. /**
  36629. * Does the sound autoplay once loaded.
  36630. */
  36631. autoplay: boolean;
  36632. /**
  36633. * Does the sound loop after it finishes playing once.
  36634. */
  36635. loop: boolean;
  36636. /**
  36637. * Does the sound use a custom attenuation curve to simulate the falloff
  36638. * happening when the source gets further away from the camera.
  36639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36640. */
  36641. useCustomAttenuation: boolean;
  36642. /**
  36643. * The sound track id this sound belongs to.
  36644. */
  36645. soundTrackId: number;
  36646. /**
  36647. * Is this sound currently played.
  36648. */
  36649. isPlaying: boolean;
  36650. /**
  36651. * Is this sound currently paused.
  36652. */
  36653. isPaused: boolean;
  36654. /**
  36655. * Does this sound enables spatial sound.
  36656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36657. */
  36658. spatialSound: boolean;
  36659. /**
  36660. * Define the reference distance the sound should be heard perfectly.
  36661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36662. */
  36663. refDistance: number;
  36664. /**
  36665. * Define the roll off factor of spatial sounds.
  36666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36667. */
  36668. rolloffFactor: number;
  36669. /**
  36670. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36672. */
  36673. maxDistance: number;
  36674. /**
  36675. * Define the distance attenuation model the sound will follow.
  36676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36677. */
  36678. distanceModel: string;
  36679. /**
  36680. * @hidden
  36681. * Back Compat
  36682. **/
  36683. onended: () => any;
  36684. /**
  36685. * Observable event when the current playing sound finishes.
  36686. */
  36687. onEndedObservable: Observable<Sound>;
  36688. private _panningModel;
  36689. private _playbackRate;
  36690. private _streaming;
  36691. private _startTime;
  36692. private _startOffset;
  36693. private _position;
  36694. /** @hidden */
  36695. _positionInEmitterSpace: boolean;
  36696. private _localDirection;
  36697. private _volume;
  36698. private _isReadyToPlay;
  36699. private _isDirectional;
  36700. private _readyToPlayCallback;
  36701. private _audioBuffer;
  36702. private _soundSource;
  36703. private _streamingSource;
  36704. private _soundPanner;
  36705. private _soundGain;
  36706. private _inputAudioNode;
  36707. private _outputAudioNode;
  36708. private _coneInnerAngle;
  36709. private _coneOuterAngle;
  36710. private _coneOuterGain;
  36711. private _scene;
  36712. private _connectedTransformNode;
  36713. private _customAttenuationFunction;
  36714. private _registerFunc;
  36715. private _isOutputConnected;
  36716. private _htmlAudioElement;
  36717. private _urlType;
  36718. private _length?;
  36719. private _offset?;
  36720. /** @hidden */
  36721. static _SceneComponentInitialization: (scene: Scene) => void;
  36722. /**
  36723. * Create a sound and attach it to a scene
  36724. * @param name Name of your sound
  36725. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36726. * @param scene defines the scene the sound belongs to
  36727. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36728. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36729. */
  36730. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36731. /**
  36732. * Release the sound and its associated resources
  36733. */
  36734. dispose(): void;
  36735. /**
  36736. * Gets if the sounds is ready to be played or not.
  36737. * @returns true if ready, otherwise false
  36738. */
  36739. isReady(): boolean;
  36740. private _soundLoaded;
  36741. /**
  36742. * Sets the data of the sound from an audiobuffer
  36743. * @param audioBuffer The audioBuffer containing the data
  36744. */
  36745. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36746. /**
  36747. * Updates the current sounds options such as maxdistance, loop...
  36748. * @param options A JSON object containing values named as the object properties
  36749. */
  36750. updateOptions(options: ISoundOptions): void;
  36751. private _createSpatialParameters;
  36752. private _updateSpatialParameters;
  36753. /**
  36754. * Switch the panning model to HRTF:
  36755. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36757. */
  36758. switchPanningModelToHRTF(): void;
  36759. /**
  36760. * Switch the panning model to Equal Power:
  36761. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36763. */
  36764. switchPanningModelToEqualPower(): void;
  36765. private _switchPanningModel;
  36766. /**
  36767. * Connect this sound to a sound track audio node like gain...
  36768. * @param soundTrackAudioNode the sound track audio node to connect to
  36769. */
  36770. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36771. /**
  36772. * Transform this sound into a directional source
  36773. * @param coneInnerAngle Size of the inner cone in degree
  36774. * @param coneOuterAngle Size of the outer cone in degree
  36775. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36776. */
  36777. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36778. /**
  36779. * Gets or sets the inner angle for the directional cone.
  36780. */
  36781. /**
  36782. * Gets or sets the inner angle for the directional cone.
  36783. */
  36784. directionalConeInnerAngle: number;
  36785. /**
  36786. * Gets or sets the outer angle for the directional cone.
  36787. */
  36788. /**
  36789. * Gets or sets the outer angle for the directional cone.
  36790. */
  36791. directionalConeOuterAngle: number;
  36792. /**
  36793. * Sets the position of the emitter if spatial sound is enabled
  36794. * @param newPosition Defines the new posisiton
  36795. */
  36796. setPosition(newPosition: Vector3): void;
  36797. /**
  36798. * Sets the local direction of the emitter if spatial sound is enabled
  36799. * @param newLocalDirection Defines the new local direction
  36800. */
  36801. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36802. private _updateDirection;
  36803. /** @hidden */
  36804. updateDistanceFromListener(): void;
  36805. /**
  36806. * Sets a new custom attenuation function for the sound.
  36807. * @param callback Defines the function used for the attenuation
  36808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36809. */
  36810. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36811. /**
  36812. * Play the sound
  36813. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36814. * @param offset (optional) Start the sound at a specific time in seconds
  36815. * @param length (optional) Sound duration (in seconds)
  36816. */
  36817. play(time?: number, offset?: number, length?: number): void;
  36818. private _onended;
  36819. /**
  36820. * Stop the sound
  36821. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36822. */
  36823. stop(time?: number): void;
  36824. /**
  36825. * Put the sound in pause
  36826. */
  36827. pause(): void;
  36828. /**
  36829. * Sets a dedicated volume for this sounds
  36830. * @param newVolume Define the new volume of the sound
  36831. * @param time Define time for gradual change to new volume
  36832. */
  36833. setVolume(newVolume: number, time?: number): void;
  36834. /**
  36835. * Set the sound play back rate
  36836. * @param newPlaybackRate Define the playback rate the sound should be played at
  36837. */
  36838. setPlaybackRate(newPlaybackRate: number): void;
  36839. /**
  36840. * Gets the volume of the sound.
  36841. * @returns the volume of the sound
  36842. */
  36843. getVolume(): number;
  36844. /**
  36845. * Attach the sound to a dedicated mesh
  36846. * @param transformNode The transform node to connect the sound with
  36847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36848. */
  36849. attachToMesh(transformNode: TransformNode): void;
  36850. /**
  36851. * Detach the sound from the previously attached mesh
  36852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36853. */
  36854. detachFromMesh(): void;
  36855. private _onRegisterAfterWorldMatrixUpdate;
  36856. /**
  36857. * Clone the current sound in the scene.
  36858. * @returns the new sound clone
  36859. */
  36860. clone(): Nullable<Sound>;
  36861. /**
  36862. * Gets the current underlying audio buffer containing the data
  36863. * @returns the audio buffer
  36864. */
  36865. getAudioBuffer(): Nullable<AudioBuffer>;
  36866. /**
  36867. * Serializes the Sound in a JSON representation
  36868. * @returns the JSON representation of the sound
  36869. */
  36870. serialize(): any;
  36871. /**
  36872. * Parse a JSON representation of a sound to innstantiate in a given scene
  36873. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36874. * @param scene Define the scene the new parsed sound should be created in
  36875. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36876. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36877. * @returns the newly parsed sound
  36878. */
  36879. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36880. }
  36881. }
  36882. declare module BABYLON {
  36883. /**
  36884. * This defines an action helpful to play a defined sound on a triggered action.
  36885. */
  36886. export class PlaySoundAction extends Action {
  36887. private _sound;
  36888. /**
  36889. * Instantiate the action
  36890. * @param triggerOptions defines the trigger options
  36891. * @param sound defines the sound to play
  36892. * @param condition defines the trigger related conditions
  36893. */
  36894. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36895. /** @hidden */
  36896. _prepare(): void;
  36897. /**
  36898. * Execute the action and play the sound.
  36899. */
  36900. execute(): void;
  36901. /**
  36902. * Serializes the actions and its related information.
  36903. * @param parent defines the object to serialize in
  36904. * @returns the serialized object
  36905. */
  36906. serialize(parent: any): any;
  36907. }
  36908. /**
  36909. * This defines an action helpful to stop a defined sound on a triggered action.
  36910. */
  36911. export class StopSoundAction extends Action {
  36912. private _sound;
  36913. /**
  36914. * Instantiate the action
  36915. * @param triggerOptions defines the trigger options
  36916. * @param sound defines the sound to stop
  36917. * @param condition defines the trigger related conditions
  36918. */
  36919. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36920. /** @hidden */
  36921. _prepare(): void;
  36922. /**
  36923. * Execute the action and stop the sound.
  36924. */
  36925. execute(): void;
  36926. /**
  36927. * Serializes the actions and its related information.
  36928. * @param parent defines the object to serialize in
  36929. * @returns the serialized object
  36930. */
  36931. serialize(parent: any): any;
  36932. }
  36933. }
  36934. declare module BABYLON {
  36935. /**
  36936. * This defines an action responsible to change the value of a property
  36937. * by interpolating between its current value and the newly set one once triggered.
  36938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36939. */
  36940. export class InterpolateValueAction extends Action {
  36941. /**
  36942. * Defines the path of the property where the value should be interpolated
  36943. */
  36944. propertyPath: string;
  36945. /**
  36946. * Defines the target value at the end of the interpolation.
  36947. */
  36948. value: any;
  36949. /**
  36950. * Defines the time it will take for the property to interpolate to the value.
  36951. */
  36952. duration: number;
  36953. /**
  36954. * Defines if the other scene animations should be stopped when the action has been triggered
  36955. */
  36956. stopOtherAnimations?: boolean;
  36957. /**
  36958. * Defines a callback raised once the interpolation animation has been done.
  36959. */
  36960. onInterpolationDone?: () => void;
  36961. /**
  36962. * Observable triggered once the interpolation animation has been done.
  36963. */
  36964. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36965. private _target;
  36966. private _effectiveTarget;
  36967. private _property;
  36968. /**
  36969. * Instantiate the action
  36970. * @param triggerOptions defines the trigger options
  36971. * @param target defines the object containing the value to interpolate
  36972. * @param propertyPath defines the path to the property in the target object
  36973. * @param value defines the target value at the end of the interpolation
  36974. * @param duration deines the time it will take for the property to interpolate to the value.
  36975. * @param condition defines the trigger related conditions
  36976. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36977. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36978. */
  36979. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36980. /** @hidden */
  36981. _prepare(): void;
  36982. /**
  36983. * Execute the action starts the value interpolation.
  36984. */
  36985. execute(): void;
  36986. /**
  36987. * Serializes the actions and its related information.
  36988. * @param parent defines the object to serialize in
  36989. * @returns the serialized object
  36990. */
  36991. serialize(parent: any): any;
  36992. }
  36993. }
  36994. declare module BABYLON {
  36995. /**
  36996. * Options allowed during the creation of a sound track.
  36997. */
  36998. export interface ISoundTrackOptions {
  36999. /**
  37000. * The volume the sound track should take during creation
  37001. */
  37002. volume?: number;
  37003. /**
  37004. * Define if the sound track is the main sound track of the scene
  37005. */
  37006. mainTrack?: boolean;
  37007. }
  37008. /**
  37009. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37010. * It will be also used in a future release to apply effects on a specific track.
  37011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37012. */
  37013. export class SoundTrack {
  37014. /**
  37015. * The unique identifier of the sound track in the scene.
  37016. */
  37017. id: number;
  37018. /**
  37019. * The list of sounds included in the sound track.
  37020. */
  37021. soundCollection: Array<Sound>;
  37022. private _outputAudioNode;
  37023. private _scene;
  37024. private _connectedAnalyser;
  37025. private _options;
  37026. private _isInitialized;
  37027. /**
  37028. * Creates a new sound track.
  37029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37030. * @param scene Define the scene the sound track belongs to
  37031. * @param options
  37032. */
  37033. constructor(scene: Scene, options?: ISoundTrackOptions);
  37034. private _initializeSoundTrackAudioGraph;
  37035. /**
  37036. * Release the sound track and its associated resources
  37037. */
  37038. dispose(): void;
  37039. /**
  37040. * Adds a sound to this sound track
  37041. * @param sound define the cound to add
  37042. * @ignoreNaming
  37043. */
  37044. AddSound(sound: Sound): void;
  37045. /**
  37046. * Removes a sound to this sound track
  37047. * @param sound define the cound to remove
  37048. * @ignoreNaming
  37049. */
  37050. RemoveSound(sound: Sound): void;
  37051. /**
  37052. * Set a global volume for the full sound track.
  37053. * @param newVolume Define the new volume of the sound track
  37054. */
  37055. setVolume(newVolume: number): void;
  37056. /**
  37057. * Switch the panning model to HRTF:
  37058. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37060. */
  37061. switchPanningModelToHRTF(): void;
  37062. /**
  37063. * Switch the panning model to Equal Power:
  37064. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37066. */
  37067. switchPanningModelToEqualPower(): void;
  37068. /**
  37069. * Connect the sound track to an audio analyser allowing some amazing
  37070. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37072. * @param analyser The analyser to connect to the engine
  37073. */
  37074. connectToAnalyser(analyser: Analyser): void;
  37075. }
  37076. }
  37077. declare module BABYLON {
  37078. interface AbstractScene {
  37079. /**
  37080. * The list of sounds used in the scene.
  37081. */
  37082. sounds: Nullable<Array<Sound>>;
  37083. }
  37084. interface Scene {
  37085. /**
  37086. * @hidden
  37087. * Backing field
  37088. */
  37089. _mainSoundTrack: SoundTrack;
  37090. /**
  37091. * The main sound track played by the scene.
  37092. * It cotains your primary collection of sounds.
  37093. */
  37094. mainSoundTrack: SoundTrack;
  37095. /**
  37096. * The list of sound tracks added to the scene
  37097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37098. */
  37099. soundTracks: Nullable<Array<SoundTrack>>;
  37100. /**
  37101. * Gets a sound using a given name
  37102. * @param name defines the name to search for
  37103. * @return the found sound or null if not found at all.
  37104. */
  37105. getSoundByName(name: string): Nullable<Sound>;
  37106. /**
  37107. * Gets or sets if audio support is enabled
  37108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37109. */
  37110. audioEnabled: boolean;
  37111. /**
  37112. * Gets or sets if audio will be output to headphones
  37113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37114. */
  37115. headphone: boolean;
  37116. /**
  37117. * Gets or sets custom audio listener position provider
  37118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37119. */
  37120. audioListenerPositionProvider: Nullable<() => Vector3>;
  37121. /**
  37122. * Gets or sets a refresh rate when using 3D audio positioning
  37123. */
  37124. audioPositioningRefreshRate: number;
  37125. }
  37126. /**
  37127. * Defines the sound scene component responsible to manage any sounds
  37128. * in a given scene.
  37129. */
  37130. export class AudioSceneComponent implements ISceneSerializableComponent {
  37131. /**
  37132. * The component name helpfull to identify the component in the list of scene components.
  37133. */
  37134. readonly name: string;
  37135. /**
  37136. * The scene the component belongs to.
  37137. */
  37138. scene: Scene;
  37139. private _audioEnabled;
  37140. /**
  37141. * Gets whether audio is enabled or not.
  37142. * Please use related enable/disable method to switch state.
  37143. */
  37144. readonly audioEnabled: boolean;
  37145. private _headphone;
  37146. /**
  37147. * Gets whether audio is outputing to headphone or not.
  37148. * Please use the according Switch methods to change output.
  37149. */
  37150. readonly headphone: boolean;
  37151. /**
  37152. * Gets or sets a refresh rate when using 3D audio positioning
  37153. */
  37154. audioPositioningRefreshRate: number;
  37155. private _audioListenerPositionProvider;
  37156. /**
  37157. * Gets the current audio listener position provider
  37158. */
  37159. /**
  37160. * Sets a custom listener position for all sounds in the scene
  37161. * By default, this is the position of the first active camera
  37162. */
  37163. audioListenerPositionProvider: Nullable<() => Vector3>;
  37164. /**
  37165. * Creates a new instance of the component for the given scene
  37166. * @param scene Defines the scene to register the component in
  37167. */
  37168. constructor(scene: Scene);
  37169. /**
  37170. * Registers the component in a given scene
  37171. */
  37172. register(): void;
  37173. /**
  37174. * Rebuilds the elements related to this component in case of
  37175. * context lost for instance.
  37176. */
  37177. rebuild(): void;
  37178. /**
  37179. * Serializes the component data to the specified json object
  37180. * @param serializationObject The object to serialize to
  37181. */
  37182. serialize(serializationObject: any): void;
  37183. /**
  37184. * Adds all the elements from the container to the scene
  37185. * @param container the container holding the elements
  37186. */
  37187. addFromContainer(container: AbstractScene): void;
  37188. /**
  37189. * Removes all the elements in the container from the scene
  37190. * @param container contains the elements to remove
  37191. * @param dispose if the removed element should be disposed (default: false)
  37192. */
  37193. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37194. /**
  37195. * Disposes the component and the associated ressources.
  37196. */
  37197. dispose(): void;
  37198. /**
  37199. * Disables audio in the associated scene.
  37200. */
  37201. disableAudio(): void;
  37202. /**
  37203. * Enables audio in the associated scene.
  37204. */
  37205. enableAudio(): void;
  37206. /**
  37207. * Switch audio to headphone output.
  37208. */
  37209. switchAudioModeForHeadphones(): void;
  37210. /**
  37211. * Switch audio to normal speakers.
  37212. */
  37213. switchAudioModeForNormalSpeakers(): void;
  37214. private _cachedCameraDirection;
  37215. private _cachedCameraPosition;
  37216. private _lastCheck;
  37217. private _afterRender;
  37218. }
  37219. }
  37220. declare module BABYLON {
  37221. /**
  37222. * Wraps one or more Sound objects and selects one with random weight for playback.
  37223. */
  37224. export class WeightedSound {
  37225. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37226. loop: boolean;
  37227. private _coneInnerAngle;
  37228. private _coneOuterAngle;
  37229. private _volume;
  37230. /** A Sound is currently playing. */
  37231. isPlaying: boolean;
  37232. /** A Sound is currently paused. */
  37233. isPaused: boolean;
  37234. private _sounds;
  37235. private _weights;
  37236. private _currentIndex?;
  37237. /**
  37238. * Creates a new WeightedSound from the list of sounds given.
  37239. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37240. * @param sounds Array of Sounds that will be selected from.
  37241. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37242. */
  37243. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37244. /**
  37245. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37246. */
  37247. /**
  37248. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37249. */
  37250. directionalConeInnerAngle: number;
  37251. /**
  37252. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37253. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37254. */
  37255. /**
  37256. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37257. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37258. */
  37259. directionalConeOuterAngle: number;
  37260. /**
  37261. * Playback volume.
  37262. */
  37263. /**
  37264. * Playback volume.
  37265. */
  37266. volume: number;
  37267. private _onended;
  37268. /**
  37269. * Suspend playback
  37270. */
  37271. pause(): void;
  37272. /**
  37273. * Stop playback
  37274. */
  37275. stop(): void;
  37276. /**
  37277. * Start playback.
  37278. * @param startOffset Position the clip head at a specific time in seconds.
  37279. */
  37280. play(startOffset?: number): void;
  37281. }
  37282. }
  37283. declare module BABYLON {
  37284. /**
  37285. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37286. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37287. */
  37288. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37289. /**
  37290. * Gets the name of the behavior.
  37291. */
  37292. readonly name: string;
  37293. /**
  37294. * The easing function used by animations
  37295. */
  37296. static EasingFunction: BackEase;
  37297. /**
  37298. * The easing mode used by animations
  37299. */
  37300. static EasingMode: number;
  37301. /**
  37302. * The duration of the animation, in milliseconds
  37303. */
  37304. transitionDuration: number;
  37305. /**
  37306. * Length of the distance animated by the transition when lower radius is reached
  37307. */
  37308. lowerRadiusTransitionRange: number;
  37309. /**
  37310. * Length of the distance animated by the transition when upper radius is reached
  37311. */
  37312. upperRadiusTransitionRange: number;
  37313. private _autoTransitionRange;
  37314. /**
  37315. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37316. */
  37317. /**
  37318. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37319. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37320. */
  37321. autoTransitionRange: boolean;
  37322. private _attachedCamera;
  37323. private _onAfterCheckInputsObserver;
  37324. private _onMeshTargetChangedObserver;
  37325. /**
  37326. * Initializes the behavior.
  37327. */
  37328. init(): void;
  37329. /**
  37330. * Attaches the behavior to its arc rotate camera.
  37331. * @param camera Defines the camera to attach the behavior to
  37332. */
  37333. attach(camera: ArcRotateCamera): void;
  37334. /**
  37335. * Detaches the behavior from its current arc rotate camera.
  37336. */
  37337. detach(): void;
  37338. private _radiusIsAnimating;
  37339. private _radiusBounceTransition;
  37340. private _animatables;
  37341. private _cachedWheelPrecision;
  37342. /**
  37343. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37344. * @param radiusLimit The limit to check against.
  37345. * @return Bool to indicate if at limit.
  37346. */
  37347. private _isRadiusAtLimit;
  37348. /**
  37349. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37350. * @param radiusDelta The delta by which to animate to. Can be negative.
  37351. */
  37352. private _applyBoundRadiusAnimation;
  37353. /**
  37354. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37355. */
  37356. protected _clearAnimationLocks(): void;
  37357. /**
  37358. * Stops and removes all animations that have been applied to the camera
  37359. */
  37360. stopAllAnimations(): void;
  37361. }
  37362. }
  37363. declare module BABYLON {
  37364. /**
  37365. * 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.
  37366. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37367. */
  37368. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37369. /**
  37370. * Gets the name of the behavior.
  37371. */
  37372. readonly name: string;
  37373. private _mode;
  37374. private _radiusScale;
  37375. private _positionScale;
  37376. private _defaultElevation;
  37377. private _elevationReturnTime;
  37378. private _elevationReturnWaitTime;
  37379. private _zoomStopsAnimation;
  37380. private _framingTime;
  37381. /**
  37382. * The easing function used by animations
  37383. */
  37384. static EasingFunction: ExponentialEase;
  37385. /**
  37386. * The easing mode used by animations
  37387. */
  37388. static EasingMode: number;
  37389. /**
  37390. * Sets the current mode used by the behavior
  37391. */
  37392. /**
  37393. * Gets current mode used by the behavior.
  37394. */
  37395. mode: number;
  37396. /**
  37397. * Sets the scale applied to the radius (1 by default)
  37398. */
  37399. /**
  37400. * Gets the scale applied to the radius
  37401. */
  37402. radiusScale: number;
  37403. /**
  37404. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37405. */
  37406. /**
  37407. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37408. */
  37409. positionScale: number;
  37410. /**
  37411. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37412. * behaviour is triggered, in radians.
  37413. */
  37414. /**
  37415. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37416. * behaviour is triggered, in radians.
  37417. */
  37418. defaultElevation: number;
  37419. /**
  37420. * Sets the time (in milliseconds) taken to return to the default beta position.
  37421. * Negative value indicates camera should not return to default.
  37422. */
  37423. /**
  37424. * Gets the time (in milliseconds) taken to return to the default beta position.
  37425. * Negative value indicates camera should not return to default.
  37426. */
  37427. elevationReturnTime: number;
  37428. /**
  37429. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37430. */
  37431. /**
  37432. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37433. */
  37434. elevationReturnWaitTime: number;
  37435. /**
  37436. * Sets the flag that indicates if user zooming should stop animation.
  37437. */
  37438. /**
  37439. * Gets the flag that indicates if user zooming should stop animation.
  37440. */
  37441. zoomStopsAnimation: boolean;
  37442. /**
  37443. * Sets the transition time when framing the mesh, in milliseconds
  37444. */
  37445. /**
  37446. * Gets the transition time when framing the mesh, in milliseconds
  37447. */
  37448. framingTime: number;
  37449. /**
  37450. * Define if the behavior should automatically change the configured
  37451. * camera limits and sensibilities.
  37452. */
  37453. autoCorrectCameraLimitsAndSensibility: boolean;
  37454. private _onPrePointerObservableObserver;
  37455. private _onAfterCheckInputsObserver;
  37456. private _onMeshTargetChangedObserver;
  37457. private _attachedCamera;
  37458. private _isPointerDown;
  37459. private _lastInteractionTime;
  37460. /**
  37461. * Initializes the behavior.
  37462. */
  37463. init(): void;
  37464. /**
  37465. * Attaches the behavior to its arc rotate camera.
  37466. * @param camera Defines the camera to attach the behavior to
  37467. */
  37468. attach(camera: ArcRotateCamera): void;
  37469. /**
  37470. * Detaches the behavior from its current arc rotate camera.
  37471. */
  37472. detach(): void;
  37473. private _animatables;
  37474. private _betaIsAnimating;
  37475. private _betaTransition;
  37476. private _radiusTransition;
  37477. private _vectorTransition;
  37478. /**
  37479. * Targets the given mesh and updates zoom level accordingly.
  37480. * @param mesh The mesh to target.
  37481. * @param radius Optional. If a cached radius position already exists, overrides default.
  37482. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37483. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37484. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37485. */
  37486. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37487. /**
  37488. * Targets the given mesh with its children and updates zoom level accordingly.
  37489. * @param mesh The mesh to target.
  37490. * @param radius Optional. If a cached radius position already exists, overrides default.
  37491. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37492. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37493. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37494. */
  37495. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37496. /**
  37497. * Targets the given meshes with their children and updates zoom level accordingly.
  37498. * @param meshes The mesh to target.
  37499. * @param radius Optional. If a cached radius position already exists, overrides default.
  37500. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37501. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37502. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37503. */
  37504. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37505. /**
  37506. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37507. * @param minimumWorld Determines the smaller position of the bounding box extend
  37508. * @param maximumWorld Determines the bigger position of the bounding box extend
  37509. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37510. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37511. */
  37512. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37513. /**
  37514. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37515. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37516. * frustum width.
  37517. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37518. * to fully enclose the mesh in the viewing frustum.
  37519. */
  37520. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37521. /**
  37522. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37523. * is automatically returned to its default position (expected to be above ground plane).
  37524. */
  37525. private _maintainCameraAboveGround;
  37526. /**
  37527. * Returns the frustum slope based on the canvas ratio and camera FOV
  37528. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37529. */
  37530. private _getFrustumSlope;
  37531. /**
  37532. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37533. */
  37534. private _clearAnimationLocks;
  37535. /**
  37536. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37537. */
  37538. private _applyUserInteraction;
  37539. /**
  37540. * Stops and removes all animations that have been applied to the camera
  37541. */
  37542. stopAllAnimations(): void;
  37543. /**
  37544. * Gets a value indicating if the user is moving the camera
  37545. */
  37546. readonly isUserIsMoving: boolean;
  37547. /**
  37548. * The camera can move all the way towards the mesh.
  37549. */
  37550. static IgnoreBoundsSizeMode: number;
  37551. /**
  37552. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37553. */
  37554. static FitFrustumSidesMode: number;
  37555. }
  37556. }
  37557. declare module BABYLON {
  37558. /**
  37559. * Base class for Camera Pointer Inputs.
  37560. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37561. * for example usage.
  37562. */
  37563. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37564. /**
  37565. * Defines the camera the input is attached to.
  37566. */
  37567. abstract camera: Camera;
  37568. /**
  37569. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37570. */
  37571. protected _altKey: boolean;
  37572. protected _ctrlKey: boolean;
  37573. protected _metaKey: boolean;
  37574. protected _shiftKey: boolean;
  37575. /**
  37576. * Which mouse buttons were pressed at time of last mouse event.
  37577. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37578. */
  37579. protected _buttonsPressed: number;
  37580. /**
  37581. * Defines the buttons associated with the input to handle camera move.
  37582. */
  37583. buttons: number[];
  37584. /**
  37585. * Attach the input controls to a specific dom element to get the input from.
  37586. * @param element Defines the element the controls should be listened from
  37587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37588. */
  37589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37590. /**
  37591. * Detach the current controls from the specified dom element.
  37592. * @param element Defines the element to stop listening the inputs from
  37593. */
  37594. detachControl(element: Nullable<HTMLElement>): void;
  37595. /**
  37596. * Gets the class name of the current input.
  37597. * @returns the class name
  37598. */
  37599. getClassName(): string;
  37600. /**
  37601. * Get the friendly name associated with the input class.
  37602. * @returns the input friendly name
  37603. */
  37604. getSimpleName(): string;
  37605. /**
  37606. * Called on pointer POINTERDOUBLETAP event.
  37607. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37608. */
  37609. protected onDoubleTap(type: string): void;
  37610. /**
  37611. * Called on pointer POINTERMOVE event if only a single touch is active.
  37612. * Override this method to provide functionality.
  37613. */
  37614. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37615. /**
  37616. * Called on pointer POINTERMOVE event if multiple touches are active.
  37617. * Override this method to provide functionality.
  37618. */
  37619. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37620. /**
  37621. * Called on JS contextmenu event.
  37622. * Override this method to provide functionality.
  37623. */
  37624. protected onContextMenu(evt: PointerEvent): void;
  37625. /**
  37626. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37627. * press.
  37628. * Override this method to provide functionality.
  37629. */
  37630. protected onButtonDown(evt: PointerEvent): void;
  37631. /**
  37632. * Called each time a new POINTERUP event occurs. Ie, for each button
  37633. * release.
  37634. * Override this method to provide functionality.
  37635. */
  37636. protected onButtonUp(evt: PointerEvent): void;
  37637. /**
  37638. * Called when window becomes inactive.
  37639. * Override this method to provide functionality.
  37640. */
  37641. protected onLostFocus(): void;
  37642. private _pointerInput;
  37643. private _observer;
  37644. private _onLostFocus;
  37645. private pointA;
  37646. private pointB;
  37647. }
  37648. }
  37649. declare module BABYLON {
  37650. /**
  37651. * Manage the pointers inputs to control an arc rotate camera.
  37652. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37653. */
  37654. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37655. /**
  37656. * Defines the camera the input is attached to.
  37657. */
  37658. camera: ArcRotateCamera;
  37659. /**
  37660. * Gets the class name of the current input.
  37661. * @returns the class name
  37662. */
  37663. getClassName(): string;
  37664. /**
  37665. * Defines the buttons associated with the input to handle camera move.
  37666. */
  37667. buttons: number[];
  37668. /**
  37669. * Defines the pointer angular sensibility along the X axis or how fast is
  37670. * the camera rotating.
  37671. */
  37672. angularSensibilityX: number;
  37673. /**
  37674. * Defines the pointer angular sensibility along the Y axis or how fast is
  37675. * the camera rotating.
  37676. */
  37677. angularSensibilityY: number;
  37678. /**
  37679. * Defines the pointer pinch precision or how fast is the camera zooming.
  37680. */
  37681. pinchPrecision: number;
  37682. /**
  37683. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37684. * from 0.
  37685. * It defines the percentage of current camera.radius to use as delta when
  37686. * pinch zoom is used.
  37687. */
  37688. pinchDeltaPercentage: number;
  37689. /**
  37690. * Defines the pointer panning sensibility or how fast is the camera moving.
  37691. */
  37692. panningSensibility: number;
  37693. /**
  37694. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37695. */
  37696. multiTouchPanning: boolean;
  37697. /**
  37698. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37699. * zoom (pinch) through multitouch.
  37700. */
  37701. multiTouchPanAndZoom: boolean;
  37702. /**
  37703. * Revers pinch action direction.
  37704. */
  37705. pinchInwards: boolean;
  37706. private _isPanClick;
  37707. private _twoFingerActivityCount;
  37708. private _isPinching;
  37709. /**
  37710. * Called on pointer POINTERMOVE event if only a single touch is active.
  37711. */
  37712. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37713. /**
  37714. * Called on pointer POINTERDOUBLETAP event.
  37715. */
  37716. protected onDoubleTap(type: string): void;
  37717. /**
  37718. * Called on pointer POINTERMOVE event if multiple touches are active.
  37719. */
  37720. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37721. /**
  37722. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37723. * press.
  37724. */
  37725. protected onButtonDown(evt: PointerEvent): void;
  37726. /**
  37727. * Called each time a new POINTERUP event occurs. Ie, for each button
  37728. * release.
  37729. */
  37730. protected onButtonUp(evt: PointerEvent): void;
  37731. /**
  37732. * Called when window becomes inactive.
  37733. */
  37734. protected onLostFocus(): void;
  37735. }
  37736. }
  37737. declare module BABYLON {
  37738. /**
  37739. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37741. */
  37742. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37743. /**
  37744. * Defines the camera the input is attached to.
  37745. */
  37746. camera: ArcRotateCamera;
  37747. /**
  37748. * Defines the list of key codes associated with the up action (increase alpha)
  37749. */
  37750. keysUp: number[];
  37751. /**
  37752. * Defines the list of key codes associated with the down action (decrease alpha)
  37753. */
  37754. keysDown: number[];
  37755. /**
  37756. * Defines the list of key codes associated with the left action (increase beta)
  37757. */
  37758. keysLeft: number[];
  37759. /**
  37760. * Defines the list of key codes associated with the right action (decrease beta)
  37761. */
  37762. keysRight: number[];
  37763. /**
  37764. * Defines the list of key codes associated with the reset action.
  37765. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37766. */
  37767. keysReset: number[];
  37768. /**
  37769. * Defines the panning sensibility of the inputs.
  37770. * (How fast is the camera paning)
  37771. */
  37772. panningSensibility: number;
  37773. /**
  37774. * Defines the zooming sensibility of the inputs.
  37775. * (How fast is the camera zooming)
  37776. */
  37777. zoomingSensibility: number;
  37778. /**
  37779. * Defines wether maintaining the alt key down switch the movement mode from
  37780. * orientation to zoom.
  37781. */
  37782. useAltToZoom: boolean;
  37783. /**
  37784. * Rotation speed of the camera
  37785. */
  37786. angularSpeed: number;
  37787. private _keys;
  37788. private _ctrlPressed;
  37789. private _altPressed;
  37790. private _onCanvasBlurObserver;
  37791. private _onKeyboardObserver;
  37792. private _engine;
  37793. private _scene;
  37794. /**
  37795. * Attach the input controls to a specific dom element to get the input from.
  37796. * @param element Defines the element the controls should be listened from
  37797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37798. */
  37799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37800. /**
  37801. * Detach the current controls from the specified dom element.
  37802. * @param element Defines the element to stop listening the inputs from
  37803. */
  37804. detachControl(element: Nullable<HTMLElement>): void;
  37805. /**
  37806. * Update the current camera state depending on the inputs that have been used this frame.
  37807. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37808. */
  37809. checkInputs(): void;
  37810. /**
  37811. * Gets the class name of the current intput.
  37812. * @returns the class name
  37813. */
  37814. getClassName(): string;
  37815. /**
  37816. * Get the friendly name associated with the input class.
  37817. * @returns the input friendly name
  37818. */
  37819. getSimpleName(): string;
  37820. }
  37821. }
  37822. declare module BABYLON {
  37823. /**
  37824. * Manage the mouse wheel inputs to control an arc rotate camera.
  37825. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37826. */
  37827. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37828. /**
  37829. * Defines the camera the input is attached to.
  37830. */
  37831. camera: ArcRotateCamera;
  37832. /**
  37833. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37834. */
  37835. wheelPrecision: number;
  37836. /**
  37837. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37838. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37839. */
  37840. wheelDeltaPercentage: number;
  37841. private _wheel;
  37842. private _observer;
  37843. private computeDeltaFromMouseWheelLegacyEvent;
  37844. /**
  37845. * Attach the input controls to a specific dom element to get the input from.
  37846. * @param element Defines the element the controls should be listened from
  37847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37848. */
  37849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37850. /**
  37851. * Detach the current controls from the specified dom element.
  37852. * @param element Defines the element to stop listening the inputs from
  37853. */
  37854. detachControl(element: Nullable<HTMLElement>): void;
  37855. /**
  37856. * Gets the class name of the current intput.
  37857. * @returns the class name
  37858. */
  37859. getClassName(): string;
  37860. /**
  37861. * Get the friendly name associated with the input class.
  37862. * @returns the input friendly name
  37863. */
  37864. getSimpleName(): string;
  37865. }
  37866. }
  37867. declare module BABYLON {
  37868. /**
  37869. * Default Inputs manager for the ArcRotateCamera.
  37870. * It groups all the default supported inputs for ease of use.
  37871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37872. */
  37873. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37874. /**
  37875. * Instantiates a new ArcRotateCameraInputsManager.
  37876. * @param camera Defines the camera the inputs belong to
  37877. */
  37878. constructor(camera: ArcRotateCamera);
  37879. /**
  37880. * Add mouse wheel input support to the input manager.
  37881. * @returns the current input manager
  37882. */
  37883. addMouseWheel(): ArcRotateCameraInputsManager;
  37884. /**
  37885. * Add pointers input support to the input manager.
  37886. * @returns the current input manager
  37887. */
  37888. addPointers(): ArcRotateCameraInputsManager;
  37889. /**
  37890. * Add keyboard input support to the input manager.
  37891. * @returns the current input manager
  37892. */
  37893. addKeyboard(): ArcRotateCameraInputsManager;
  37894. }
  37895. }
  37896. declare module BABYLON {
  37897. /**
  37898. * This represents an orbital type of camera.
  37899. *
  37900. * 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.
  37901. * 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.
  37902. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37903. */
  37904. export class ArcRotateCamera extends TargetCamera {
  37905. /**
  37906. * Defines the rotation angle of the camera along the longitudinal axis.
  37907. */
  37908. alpha: number;
  37909. /**
  37910. * Defines the rotation angle of the camera along the latitudinal axis.
  37911. */
  37912. beta: number;
  37913. /**
  37914. * Defines the radius of the camera from it s target point.
  37915. */
  37916. radius: number;
  37917. protected _target: Vector3;
  37918. protected _targetHost: Nullable<AbstractMesh>;
  37919. /**
  37920. * Defines the target point of the camera.
  37921. * The camera looks towards it form the radius distance.
  37922. */
  37923. target: Vector3;
  37924. /**
  37925. * Define the current local position of the camera in the scene
  37926. */
  37927. position: Vector3;
  37928. protected _upVector: Vector3;
  37929. protected _upToYMatrix: Matrix;
  37930. protected _YToUpMatrix: Matrix;
  37931. /**
  37932. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37933. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37934. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37935. */
  37936. upVector: Vector3;
  37937. /**
  37938. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37939. */
  37940. setMatUp(): void;
  37941. /**
  37942. * Current inertia value on the longitudinal axis.
  37943. * The bigger this number the longer it will take for the camera to stop.
  37944. */
  37945. inertialAlphaOffset: number;
  37946. /**
  37947. * Current inertia value on the latitudinal axis.
  37948. * The bigger this number the longer it will take for the camera to stop.
  37949. */
  37950. inertialBetaOffset: number;
  37951. /**
  37952. * Current inertia value on the radius axis.
  37953. * The bigger this number the longer it will take for the camera to stop.
  37954. */
  37955. inertialRadiusOffset: number;
  37956. /**
  37957. * Minimum allowed angle on the longitudinal axis.
  37958. * This can help limiting how the Camera is able to move in the scene.
  37959. */
  37960. lowerAlphaLimit: Nullable<number>;
  37961. /**
  37962. * Maximum allowed angle on the longitudinal axis.
  37963. * This can help limiting how the Camera is able to move in the scene.
  37964. */
  37965. upperAlphaLimit: Nullable<number>;
  37966. /**
  37967. * Minimum allowed angle on the latitudinal axis.
  37968. * This can help limiting how the Camera is able to move in the scene.
  37969. */
  37970. lowerBetaLimit: number;
  37971. /**
  37972. * Maximum allowed angle on the latitudinal axis.
  37973. * This can help limiting how the Camera is able to move in the scene.
  37974. */
  37975. upperBetaLimit: number;
  37976. /**
  37977. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37978. * This can help limiting how the Camera is able to move in the scene.
  37979. */
  37980. lowerRadiusLimit: Nullable<number>;
  37981. /**
  37982. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37983. * This can help limiting how the Camera is able to move in the scene.
  37984. */
  37985. upperRadiusLimit: Nullable<number>;
  37986. /**
  37987. * Defines the current inertia value used during panning of the camera along the X axis.
  37988. */
  37989. inertialPanningX: number;
  37990. /**
  37991. * Defines the current inertia value used during panning of the camera along the Y axis.
  37992. */
  37993. inertialPanningY: number;
  37994. /**
  37995. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37996. * Basically if your fingers moves away from more than this distance you will be considered
  37997. * in pinch mode.
  37998. */
  37999. pinchToPanMaxDistance: number;
  38000. /**
  38001. * Defines the maximum distance the camera can pan.
  38002. * This could help keeping the cammera always in your scene.
  38003. */
  38004. panningDistanceLimit: Nullable<number>;
  38005. /**
  38006. * Defines the target of the camera before paning.
  38007. */
  38008. panningOriginTarget: Vector3;
  38009. /**
  38010. * Defines the value of the inertia used during panning.
  38011. * 0 would mean stop inertia and one would mean no decelleration at all.
  38012. */
  38013. panningInertia: number;
  38014. /**
  38015. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38016. */
  38017. angularSensibilityX: number;
  38018. /**
  38019. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38020. */
  38021. angularSensibilityY: number;
  38022. /**
  38023. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38024. */
  38025. pinchPrecision: number;
  38026. /**
  38027. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38028. * It will be used instead of pinchDeltaPrecision if different from 0.
  38029. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38030. */
  38031. pinchDeltaPercentage: number;
  38032. /**
  38033. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38034. */
  38035. panningSensibility: number;
  38036. /**
  38037. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38038. */
  38039. keysUp: number[];
  38040. /**
  38041. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38042. */
  38043. keysDown: number[];
  38044. /**
  38045. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38046. */
  38047. keysLeft: number[];
  38048. /**
  38049. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38050. */
  38051. keysRight: number[];
  38052. /**
  38053. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38054. */
  38055. wheelPrecision: number;
  38056. /**
  38057. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38058. * It will be used instead of pinchDeltaPrecision if different from 0.
  38059. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38060. */
  38061. wheelDeltaPercentage: number;
  38062. /**
  38063. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38064. */
  38065. zoomOnFactor: number;
  38066. /**
  38067. * Defines a screen offset for the camera position.
  38068. */
  38069. targetScreenOffset: Vector2;
  38070. /**
  38071. * Allows the camera to be completely reversed.
  38072. * If false the camera can not arrive upside down.
  38073. */
  38074. allowUpsideDown: boolean;
  38075. /**
  38076. * Define if double tap/click is used to restore the previously saved state of the camera.
  38077. */
  38078. useInputToRestoreState: boolean;
  38079. /** @hidden */
  38080. _viewMatrix: Matrix;
  38081. /** @hidden */
  38082. _useCtrlForPanning: boolean;
  38083. /** @hidden */
  38084. _panningMouseButton: number;
  38085. /**
  38086. * Defines the input associated to the camera.
  38087. */
  38088. inputs: ArcRotateCameraInputsManager;
  38089. /** @hidden */
  38090. _reset: () => void;
  38091. /**
  38092. * Defines the allowed panning axis.
  38093. */
  38094. panningAxis: Vector3;
  38095. protected _localDirection: Vector3;
  38096. protected _transformedDirection: Vector3;
  38097. private _bouncingBehavior;
  38098. /**
  38099. * Gets the bouncing behavior of the camera if it has been enabled.
  38100. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38101. */
  38102. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38103. /**
  38104. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38105. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38106. */
  38107. useBouncingBehavior: boolean;
  38108. private _framingBehavior;
  38109. /**
  38110. * Gets the framing behavior of the camera if it has been enabled.
  38111. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38112. */
  38113. readonly framingBehavior: Nullable<FramingBehavior>;
  38114. /**
  38115. * Defines if the framing behavior of the camera is enabled on the camera.
  38116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38117. */
  38118. useFramingBehavior: boolean;
  38119. private _autoRotationBehavior;
  38120. /**
  38121. * Gets the auto rotation behavior of the camera if it has been enabled.
  38122. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38123. */
  38124. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38125. /**
  38126. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38127. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38128. */
  38129. useAutoRotationBehavior: boolean;
  38130. /**
  38131. * Observable triggered when the mesh target has been changed on the camera.
  38132. */
  38133. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38134. /**
  38135. * Event raised when the camera is colliding with a mesh.
  38136. */
  38137. onCollide: (collidedMesh: AbstractMesh) => void;
  38138. /**
  38139. * Defines whether the camera should check collision with the objects oh the scene.
  38140. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38141. */
  38142. checkCollisions: boolean;
  38143. /**
  38144. * Defines the collision radius of the camera.
  38145. * This simulates a sphere around the camera.
  38146. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38147. */
  38148. collisionRadius: Vector3;
  38149. protected _collider: Collider;
  38150. protected _previousPosition: Vector3;
  38151. protected _collisionVelocity: Vector3;
  38152. protected _newPosition: Vector3;
  38153. protected _previousAlpha: number;
  38154. protected _previousBeta: number;
  38155. protected _previousRadius: number;
  38156. protected _collisionTriggered: boolean;
  38157. protected _targetBoundingCenter: Nullable<Vector3>;
  38158. private _computationVector;
  38159. /**
  38160. * Instantiates a new ArcRotateCamera in a given scene
  38161. * @param name Defines the name of the camera
  38162. * @param alpha Defines the camera rotation along the logitudinal axis
  38163. * @param beta Defines the camera rotation along the latitudinal axis
  38164. * @param radius Defines the camera distance from its target
  38165. * @param target Defines the camera target
  38166. * @param scene Defines the scene the camera belongs to
  38167. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38168. */
  38169. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38170. /** @hidden */
  38171. _initCache(): void;
  38172. /** @hidden */
  38173. _updateCache(ignoreParentClass?: boolean): void;
  38174. protected _getTargetPosition(): Vector3;
  38175. private _storedAlpha;
  38176. private _storedBeta;
  38177. private _storedRadius;
  38178. private _storedTarget;
  38179. private _storedTargetScreenOffset;
  38180. /**
  38181. * Stores the current state of the camera (alpha, beta, radius and target)
  38182. * @returns the camera itself
  38183. */
  38184. storeState(): Camera;
  38185. /**
  38186. * @hidden
  38187. * Restored camera state. You must call storeState() first
  38188. */
  38189. _restoreStateValues(): boolean;
  38190. /** @hidden */
  38191. _isSynchronizedViewMatrix(): boolean;
  38192. /**
  38193. * Attached controls to the current camera.
  38194. * @param element Defines the element the controls should be listened from
  38195. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38196. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38197. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38198. */
  38199. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38200. /**
  38201. * Detach the current controls from the camera.
  38202. * The camera will stop reacting to inputs.
  38203. * @param element Defines the element to stop listening the inputs from
  38204. */
  38205. detachControl(element: HTMLElement): void;
  38206. /** @hidden */
  38207. _checkInputs(): void;
  38208. protected _checkLimits(): void;
  38209. /**
  38210. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38211. */
  38212. rebuildAnglesAndRadius(): void;
  38213. /**
  38214. * Use a position to define the current camera related information like alpha, beta and radius
  38215. * @param position Defines the position to set the camera at
  38216. */
  38217. setPosition(position: Vector3): void;
  38218. /**
  38219. * Defines the target the camera should look at.
  38220. * This will automatically adapt alpha beta and radius to fit within the new target.
  38221. * @param target Defines the new target as a Vector or a mesh
  38222. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38223. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38224. */
  38225. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38226. /** @hidden */
  38227. _getViewMatrix(): Matrix;
  38228. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38229. /**
  38230. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38231. * @param meshes Defines the mesh to zoom on
  38232. * @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)
  38233. */
  38234. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38235. /**
  38236. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38237. * The target will be changed but the radius
  38238. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38239. * @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)
  38240. */
  38241. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38242. min: Vector3;
  38243. max: Vector3;
  38244. distance: number;
  38245. }, doNotUpdateMaxZ?: boolean): void;
  38246. /**
  38247. * @override
  38248. * Override Camera.createRigCamera
  38249. */
  38250. createRigCamera(name: string, cameraIndex: number): Camera;
  38251. /**
  38252. * @hidden
  38253. * @override
  38254. * Override Camera._updateRigCameras
  38255. */
  38256. _updateRigCameras(): void;
  38257. /**
  38258. * Destroy the camera and release the current resources hold by it.
  38259. */
  38260. dispose(): void;
  38261. /**
  38262. * Gets the current object class name.
  38263. * @return the class name
  38264. */
  38265. getClassName(): string;
  38266. }
  38267. }
  38268. declare module BABYLON {
  38269. /**
  38270. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38271. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38272. */
  38273. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38274. /**
  38275. * Gets the name of the behavior.
  38276. */
  38277. readonly name: string;
  38278. private _zoomStopsAnimation;
  38279. private _idleRotationSpeed;
  38280. private _idleRotationWaitTime;
  38281. private _idleRotationSpinupTime;
  38282. /**
  38283. * Sets the flag that indicates if user zooming should stop animation.
  38284. */
  38285. /**
  38286. * Gets the flag that indicates if user zooming should stop animation.
  38287. */
  38288. zoomStopsAnimation: boolean;
  38289. /**
  38290. * Sets the default speed at which the camera rotates around the model.
  38291. */
  38292. /**
  38293. * Gets the default speed at which the camera rotates around the model.
  38294. */
  38295. idleRotationSpeed: number;
  38296. /**
  38297. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38298. */
  38299. /**
  38300. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38301. */
  38302. idleRotationWaitTime: number;
  38303. /**
  38304. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38305. */
  38306. /**
  38307. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38308. */
  38309. idleRotationSpinupTime: number;
  38310. /**
  38311. * Gets a value indicating if the camera is currently rotating because of this behavior
  38312. */
  38313. readonly rotationInProgress: boolean;
  38314. private _onPrePointerObservableObserver;
  38315. private _onAfterCheckInputsObserver;
  38316. private _attachedCamera;
  38317. private _isPointerDown;
  38318. private _lastFrameTime;
  38319. private _lastInteractionTime;
  38320. private _cameraRotationSpeed;
  38321. /**
  38322. * Initializes the behavior.
  38323. */
  38324. init(): void;
  38325. /**
  38326. * Attaches the behavior to its arc rotate camera.
  38327. * @param camera Defines the camera to attach the behavior to
  38328. */
  38329. attach(camera: ArcRotateCamera): void;
  38330. /**
  38331. * Detaches the behavior from its current arc rotate camera.
  38332. */
  38333. detach(): void;
  38334. /**
  38335. * Returns true if user is scrolling.
  38336. * @return true if user is scrolling.
  38337. */
  38338. private _userIsZooming;
  38339. private _lastFrameRadius;
  38340. private _shouldAnimationStopForInteraction;
  38341. /**
  38342. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38343. */
  38344. private _applyUserInteraction;
  38345. private _userIsMoving;
  38346. }
  38347. }
  38348. declare module BABYLON {
  38349. /**
  38350. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38351. */
  38352. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38353. private ui;
  38354. /**
  38355. * The name of the behavior
  38356. */
  38357. name: string;
  38358. /**
  38359. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38360. */
  38361. distanceAwayFromFace: number;
  38362. /**
  38363. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38364. */
  38365. distanceAwayFromBottomOfFace: number;
  38366. private _faceVectors;
  38367. private _target;
  38368. private _scene;
  38369. private _onRenderObserver;
  38370. private _tmpMatrix;
  38371. private _tmpVector;
  38372. /**
  38373. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38374. * @param ui The transform node that should be attched to the mesh
  38375. */
  38376. constructor(ui: TransformNode);
  38377. /**
  38378. * Initializes the behavior
  38379. */
  38380. init(): void;
  38381. private _closestFace;
  38382. private _zeroVector;
  38383. private _lookAtTmpMatrix;
  38384. private _lookAtToRef;
  38385. /**
  38386. * Attaches the AttachToBoxBehavior to the passed in mesh
  38387. * @param target The mesh that the specified node will be attached to
  38388. */
  38389. attach(target: Mesh): void;
  38390. /**
  38391. * Detaches the behavior from the mesh
  38392. */
  38393. detach(): void;
  38394. }
  38395. }
  38396. declare module BABYLON {
  38397. /**
  38398. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38399. */
  38400. export class FadeInOutBehavior implements Behavior<Mesh> {
  38401. /**
  38402. * Time in milliseconds to delay before fading in (Default: 0)
  38403. */
  38404. delay: number;
  38405. /**
  38406. * Time in milliseconds for the mesh to fade in (Default: 300)
  38407. */
  38408. fadeInTime: number;
  38409. private _millisecondsPerFrame;
  38410. private _hovered;
  38411. private _hoverValue;
  38412. private _ownerNode;
  38413. /**
  38414. * Instatiates the FadeInOutBehavior
  38415. */
  38416. constructor();
  38417. /**
  38418. * The name of the behavior
  38419. */
  38420. readonly name: string;
  38421. /**
  38422. * Initializes the behavior
  38423. */
  38424. init(): void;
  38425. /**
  38426. * Attaches the fade behavior on the passed in mesh
  38427. * @param ownerNode The mesh that will be faded in/out once attached
  38428. */
  38429. attach(ownerNode: Mesh): void;
  38430. /**
  38431. * Detaches the behavior from the mesh
  38432. */
  38433. detach(): void;
  38434. /**
  38435. * Triggers the mesh to begin fading in or out
  38436. * @param value if the object should fade in or out (true to fade in)
  38437. */
  38438. fadeIn(value: boolean): void;
  38439. private _update;
  38440. private _setAllVisibility;
  38441. }
  38442. }
  38443. declare module BABYLON {
  38444. /**
  38445. * Class containing a set of static utilities functions for managing Pivots
  38446. * @hidden
  38447. */
  38448. export class PivotTools {
  38449. private static _PivotCached;
  38450. private static _OldPivotPoint;
  38451. private static _PivotTranslation;
  38452. private static _PivotTmpVector;
  38453. /** @hidden */
  38454. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38455. /** @hidden */
  38456. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38457. }
  38458. }
  38459. declare module BABYLON {
  38460. /**
  38461. * Class containing static functions to help procedurally build meshes
  38462. */
  38463. export class PlaneBuilder {
  38464. /**
  38465. * Creates a plane mesh
  38466. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38467. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38468. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38470. * * 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
  38471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38472. * @param name defines the name of the mesh
  38473. * @param options defines the options used to create the mesh
  38474. * @param scene defines the hosting scene
  38475. * @returns the plane mesh
  38476. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38477. */
  38478. static CreatePlane(name: string, options: {
  38479. size?: number;
  38480. width?: number;
  38481. height?: number;
  38482. sideOrientation?: number;
  38483. frontUVs?: Vector4;
  38484. backUVs?: Vector4;
  38485. updatable?: boolean;
  38486. sourcePlane?: Plane;
  38487. }, scene?: Nullable<Scene>): Mesh;
  38488. }
  38489. }
  38490. declare module BABYLON {
  38491. /**
  38492. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38493. */
  38494. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38495. private static _AnyMouseID;
  38496. /**
  38497. * Abstract mesh the behavior is set on
  38498. */
  38499. attachedNode: AbstractMesh;
  38500. private _dragPlane;
  38501. private _scene;
  38502. private _pointerObserver;
  38503. private _beforeRenderObserver;
  38504. private static _planeScene;
  38505. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38506. /**
  38507. * 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)
  38508. */
  38509. maxDragAngle: number;
  38510. /**
  38511. * @hidden
  38512. */
  38513. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38514. /**
  38515. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38516. */
  38517. currentDraggingPointerID: number;
  38518. /**
  38519. * The last position where the pointer hit the drag plane in world space
  38520. */
  38521. lastDragPosition: Vector3;
  38522. /**
  38523. * If the behavior is currently in a dragging state
  38524. */
  38525. dragging: boolean;
  38526. /**
  38527. * 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)
  38528. */
  38529. dragDeltaRatio: number;
  38530. /**
  38531. * If the drag plane orientation should be updated during the dragging (Default: true)
  38532. */
  38533. updateDragPlane: boolean;
  38534. private _debugMode;
  38535. private _moving;
  38536. /**
  38537. * Fires each time the attached mesh is dragged with the pointer
  38538. * * delta between last drag position and current drag position in world space
  38539. * * dragDistance along the drag axis
  38540. * * dragPlaneNormal normal of the current drag plane used during the drag
  38541. * * dragPlanePoint in world space where the drag intersects the drag plane
  38542. */
  38543. onDragObservable: Observable<{
  38544. delta: Vector3;
  38545. dragPlanePoint: Vector3;
  38546. dragPlaneNormal: Vector3;
  38547. dragDistance: number;
  38548. pointerId: number;
  38549. }>;
  38550. /**
  38551. * Fires each time a drag begins (eg. mouse down on mesh)
  38552. */
  38553. onDragStartObservable: Observable<{
  38554. dragPlanePoint: Vector3;
  38555. pointerId: number;
  38556. }>;
  38557. /**
  38558. * Fires each time a drag ends (eg. mouse release after drag)
  38559. */
  38560. onDragEndObservable: Observable<{
  38561. dragPlanePoint: Vector3;
  38562. pointerId: number;
  38563. }>;
  38564. /**
  38565. * If the attached mesh should be moved when dragged
  38566. */
  38567. moveAttached: boolean;
  38568. /**
  38569. * If the drag behavior will react to drag events (Default: true)
  38570. */
  38571. enabled: boolean;
  38572. /**
  38573. * If pointer events should start and release the drag (Default: true)
  38574. */
  38575. startAndReleaseDragOnPointerEvents: boolean;
  38576. /**
  38577. * If camera controls should be detached during the drag
  38578. */
  38579. detachCameraControls: boolean;
  38580. /**
  38581. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38582. */
  38583. useObjectOrienationForDragging: boolean;
  38584. private _options;
  38585. /**
  38586. * Gets the options used by the behavior
  38587. */
  38588. /**
  38589. * Sets the options used by the behavior
  38590. */
  38591. options: {
  38592. dragAxis?: Vector3;
  38593. dragPlaneNormal?: Vector3;
  38594. };
  38595. /**
  38596. * Creates a pointer drag behavior that can be attached to a mesh
  38597. * @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)
  38598. */
  38599. constructor(options?: {
  38600. dragAxis?: Vector3;
  38601. dragPlaneNormal?: Vector3;
  38602. });
  38603. /**
  38604. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38605. */
  38606. validateDrag: (targetPosition: Vector3) => boolean;
  38607. /**
  38608. * The name of the behavior
  38609. */
  38610. readonly name: string;
  38611. /**
  38612. * Initializes the behavior
  38613. */
  38614. init(): void;
  38615. private _tmpVector;
  38616. private _alternatePickedPoint;
  38617. private _worldDragAxis;
  38618. private _targetPosition;
  38619. private _attachedElement;
  38620. /**
  38621. * Attaches the drag behavior the passed in mesh
  38622. * @param ownerNode The mesh that will be dragged around once attached
  38623. * @param predicate Predicate to use for pick filtering
  38624. */
  38625. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38626. /**
  38627. * Force relase the drag action by code.
  38628. */
  38629. releaseDrag(): void;
  38630. private _startDragRay;
  38631. private _lastPointerRay;
  38632. /**
  38633. * Simulates the start of a pointer drag event on the behavior
  38634. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38635. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38636. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38637. */
  38638. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38639. private _startDrag;
  38640. private _dragDelta;
  38641. private _moveDrag;
  38642. private _pickWithRayOnDragPlane;
  38643. private _pointA;
  38644. private _pointB;
  38645. private _pointC;
  38646. private _lineA;
  38647. private _lineB;
  38648. private _localAxis;
  38649. private _lookAt;
  38650. private _updateDragPlanePosition;
  38651. /**
  38652. * Detaches the behavior from the mesh
  38653. */
  38654. detach(): void;
  38655. }
  38656. }
  38657. declare module BABYLON {
  38658. /**
  38659. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38660. */
  38661. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38662. private _dragBehaviorA;
  38663. private _dragBehaviorB;
  38664. private _startDistance;
  38665. private _initialScale;
  38666. private _targetScale;
  38667. private _ownerNode;
  38668. private _sceneRenderObserver;
  38669. /**
  38670. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38671. */
  38672. constructor();
  38673. /**
  38674. * The name of the behavior
  38675. */
  38676. readonly name: string;
  38677. /**
  38678. * Initializes the behavior
  38679. */
  38680. init(): void;
  38681. private _getCurrentDistance;
  38682. /**
  38683. * Attaches the scale behavior the passed in mesh
  38684. * @param ownerNode The mesh that will be scaled around once attached
  38685. */
  38686. attach(ownerNode: Mesh): void;
  38687. /**
  38688. * Detaches the behavior from the mesh
  38689. */
  38690. detach(): void;
  38691. }
  38692. }
  38693. declare module BABYLON {
  38694. /**
  38695. * 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
  38696. */
  38697. export class SixDofDragBehavior implements Behavior<Mesh> {
  38698. private static _virtualScene;
  38699. private _ownerNode;
  38700. private _sceneRenderObserver;
  38701. private _scene;
  38702. private _targetPosition;
  38703. private _virtualOriginMesh;
  38704. private _virtualDragMesh;
  38705. private _pointerObserver;
  38706. private _moving;
  38707. private _startingOrientation;
  38708. /**
  38709. * 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)
  38710. */
  38711. private zDragFactor;
  38712. /**
  38713. * If the object should rotate to face the drag origin
  38714. */
  38715. rotateDraggedObject: boolean;
  38716. /**
  38717. * If the behavior is currently in a dragging state
  38718. */
  38719. dragging: boolean;
  38720. /**
  38721. * 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)
  38722. */
  38723. dragDeltaRatio: number;
  38724. /**
  38725. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38726. */
  38727. currentDraggingPointerID: number;
  38728. /**
  38729. * If camera controls should be detached during the drag
  38730. */
  38731. detachCameraControls: boolean;
  38732. /**
  38733. * Fires each time a drag starts
  38734. */
  38735. onDragStartObservable: Observable<{}>;
  38736. /**
  38737. * Fires each time a drag ends (eg. mouse release after drag)
  38738. */
  38739. onDragEndObservable: Observable<{}>;
  38740. /**
  38741. * 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
  38742. */
  38743. constructor();
  38744. /**
  38745. * The name of the behavior
  38746. */
  38747. readonly name: string;
  38748. /**
  38749. * Initializes the behavior
  38750. */
  38751. init(): void;
  38752. /**
  38753. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38754. */
  38755. private readonly _pointerCamera;
  38756. /**
  38757. * Attaches the scale behavior the passed in mesh
  38758. * @param ownerNode The mesh that will be scaled around once attached
  38759. */
  38760. attach(ownerNode: Mesh): void;
  38761. /**
  38762. * Detaches the behavior from the mesh
  38763. */
  38764. detach(): void;
  38765. }
  38766. }
  38767. declare module BABYLON {
  38768. /**
  38769. * Class used to apply inverse kinematics to bones
  38770. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38771. */
  38772. export class BoneIKController {
  38773. private static _tmpVecs;
  38774. private static _tmpQuat;
  38775. private static _tmpMats;
  38776. /**
  38777. * Gets or sets the target mesh
  38778. */
  38779. targetMesh: AbstractMesh;
  38780. /** Gets or sets the mesh used as pole */
  38781. poleTargetMesh: AbstractMesh;
  38782. /**
  38783. * Gets or sets the bone used as pole
  38784. */
  38785. poleTargetBone: Nullable<Bone>;
  38786. /**
  38787. * Gets or sets the target position
  38788. */
  38789. targetPosition: Vector3;
  38790. /**
  38791. * Gets or sets the pole target position
  38792. */
  38793. poleTargetPosition: Vector3;
  38794. /**
  38795. * Gets or sets the pole target local offset
  38796. */
  38797. poleTargetLocalOffset: Vector3;
  38798. /**
  38799. * Gets or sets the pole angle
  38800. */
  38801. poleAngle: number;
  38802. /**
  38803. * Gets or sets the mesh associated with the controller
  38804. */
  38805. mesh: AbstractMesh;
  38806. /**
  38807. * 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)
  38808. */
  38809. slerpAmount: number;
  38810. private _bone1Quat;
  38811. private _bone1Mat;
  38812. private _bone2Ang;
  38813. private _bone1;
  38814. private _bone2;
  38815. private _bone1Length;
  38816. private _bone2Length;
  38817. private _maxAngle;
  38818. private _maxReach;
  38819. private _rightHandedSystem;
  38820. private _bendAxis;
  38821. private _slerping;
  38822. private _adjustRoll;
  38823. /**
  38824. * Gets or sets maximum allowed angle
  38825. */
  38826. maxAngle: number;
  38827. /**
  38828. * Creates a new BoneIKController
  38829. * @param mesh defines the mesh to control
  38830. * @param bone defines the bone to control
  38831. * @param options defines options to set up the controller
  38832. */
  38833. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38834. targetMesh?: AbstractMesh;
  38835. poleTargetMesh?: AbstractMesh;
  38836. poleTargetBone?: Bone;
  38837. poleTargetLocalOffset?: Vector3;
  38838. poleAngle?: number;
  38839. bendAxis?: Vector3;
  38840. maxAngle?: number;
  38841. slerpAmount?: number;
  38842. });
  38843. private _setMaxAngle;
  38844. /**
  38845. * Force the controller to update the bones
  38846. */
  38847. update(): void;
  38848. }
  38849. }
  38850. declare module BABYLON {
  38851. /**
  38852. * Class used to make a bone look toward a point in space
  38853. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38854. */
  38855. export class BoneLookController {
  38856. private static _tmpVecs;
  38857. private static _tmpQuat;
  38858. private static _tmpMats;
  38859. /**
  38860. * The target Vector3 that the bone will look at
  38861. */
  38862. target: Vector3;
  38863. /**
  38864. * The mesh that the bone is attached to
  38865. */
  38866. mesh: AbstractMesh;
  38867. /**
  38868. * The bone that will be looking to the target
  38869. */
  38870. bone: Bone;
  38871. /**
  38872. * The up axis of the coordinate system that is used when the bone is rotated
  38873. */
  38874. upAxis: Vector3;
  38875. /**
  38876. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38877. */
  38878. upAxisSpace: Space;
  38879. /**
  38880. * Used to make an adjustment to the yaw of the bone
  38881. */
  38882. adjustYaw: number;
  38883. /**
  38884. * Used to make an adjustment to the pitch of the bone
  38885. */
  38886. adjustPitch: number;
  38887. /**
  38888. * Used to make an adjustment to the roll of the bone
  38889. */
  38890. adjustRoll: number;
  38891. /**
  38892. * 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)
  38893. */
  38894. slerpAmount: number;
  38895. private _minYaw;
  38896. private _maxYaw;
  38897. private _minPitch;
  38898. private _maxPitch;
  38899. private _minYawSin;
  38900. private _minYawCos;
  38901. private _maxYawSin;
  38902. private _maxYawCos;
  38903. private _midYawConstraint;
  38904. private _minPitchTan;
  38905. private _maxPitchTan;
  38906. private _boneQuat;
  38907. private _slerping;
  38908. private _transformYawPitch;
  38909. private _transformYawPitchInv;
  38910. private _firstFrameSkipped;
  38911. private _yawRange;
  38912. private _fowardAxis;
  38913. /**
  38914. * Gets or sets the minimum yaw angle that the bone can look to
  38915. */
  38916. minYaw: number;
  38917. /**
  38918. * Gets or sets the maximum yaw angle that the bone can look to
  38919. */
  38920. maxYaw: number;
  38921. /**
  38922. * Gets or sets the minimum pitch angle that the bone can look to
  38923. */
  38924. minPitch: number;
  38925. /**
  38926. * Gets or sets the maximum pitch angle that the bone can look to
  38927. */
  38928. maxPitch: number;
  38929. /**
  38930. * Create a BoneLookController
  38931. * @param mesh the mesh that the bone belongs to
  38932. * @param bone the bone that will be looking to the target
  38933. * @param target the target Vector3 to look at
  38934. * @param options optional settings:
  38935. * * maxYaw: the maximum angle the bone will yaw to
  38936. * * minYaw: the minimum angle the bone will yaw to
  38937. * * maxPitch: the maximum angle the bone will pitch to
  38938. * * minPitch: the minimum angle the bone will yaw to
  38939. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38940. * * upAxis: the up axis of the coordinate system
  38941. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38942. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38943. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38944. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38945. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38946. * * adjustRoll: used to make an adjustment to the roll of the bone
  38947. **/
  38948. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38949. maxYaw?: number;
  38950. minYaw?: number;
  38951. maxPitch?: number;
  38952. minPitch?: number;
  38953. slerpAmount?: number;
  38954. upAxis?: Vector3;
  38955. upAxisSpace?: Space;
  38956. yawAxis?: Vector3;
  38957. pitchAxis?: Vector3;
  38958. adjustYaw?: number;
  38959. adjustPitch?: number;
  38960. adjustRoll?: number;
  38961. });
  38962. /**
  38963. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38964. */
  38965. update(): void;
  38966. private _getAngleDiff;
  38967. private _getAngleBetween;
  38968. private _isAngleBetween;
  38969. }
  38970. }
  38971. declare module BABYLON {
  38972. /**
  38973. * Manage the gamepad inputs to control an arc rotate camera.
  38974. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38975. */
  38976. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38977. /**
  38978. * Defines the camera the input is attached to.
  38979. */
  38980. camera: ArcRotateCamera;
  38981. /**
  38982. * Defines the gamepad the input is gathering event from.
  38983. */
  38984. gamepad: Nullable<Gamepad>;
  38985. /**
  38986. * Defines the gamepad rotation sensiblity.
  38987. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38988. */
  38989. gamepadRotationSensibility: number;
  38990. /**
  38991. * Defines the gamepad move sensiblity.
  38992. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38993. */
  38994. gamepadMoveSensibility: number;
  38995. private _yAxisScale;
  38996. /**
  38997. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38998. */
  38999. invertYAxis: boolean;
  39000. private _onGamepadConnectedObserver;
  39001. private _onGamepadDisconnectedObserver;
  39002. /**
  39003. * Attach the input controls to a specific dom element to get the input from.
  39004. * @param element Defines the element the controls should be listened from
  39005. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39006. */
  39007. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39008. /**
  39009. * Detach the current controls from the specified dom element.
  39010. * @param element Defines the element to stop listening the inputs from
  39011. */
  39012. detachControl(element: Nullable<HTMLElement>): void;
  39013. /**
  39014. * Update the current camera state depending on the inputs that have been used this frame.
  39015. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39016. */
  39017. checkInputs(): void;
  39018. /**
  39019. * Gets the class name of the current intput.
  39020. * @returns the class name
  39021. */
  39022. getClassName(): string;
  39023. /**
  39024. * Get the friendly name associated with the input class.
  39025. * @returns the input friendly name
  39026. */
  39027. getSimpleName(): string;
  39028. }
  39029. }
  39030. declare module BABYLON {
  39031. interface ArcRotateCameraInputsManager {
  39032. /**
  39033. * Add orientation input support to the input manager.
  39034. * @returns the current input manager
  39035. */
  39036. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39037. }
  39038. /**
  39039. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39041. */
  39042. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39043. /**
  39044. * Defines the camera the input is attached to.
  39045. */
  39046. camera: ArcRotateCamera;
  39047. /**
  39048. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39049. */
  39050. alphaCorrection: number;
  39051. /**
  39052. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39053. */
  39054. gammaCorrection: number;
  39055. private _alpha;
  39056. private _gamma;
  39057. private _dirty;
  39058. private _deviceOrientationHandler;
  39059. /**
  39060. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39061. */
  39062. constructor();
  39063. /**
  39064. * Attach the input controls to a specific dom element to get the input from.
  39065. * @param element Defines the element the controls should be listened from
  39066. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39067. */
  39068. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39069. /** @hidden */
  39070. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39071. /**
  39072. * Update the current camera state depending on the inputs that have been used this frame.
  39073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39074. */
  39075. checkInputs(): void;
  39076. /**
  39077. * Detach the current controls from the specified dom element.
  39078. * @param element Defines the element to stop listening the inputs from
  39079. */
  39080. detachControl(element: Nullable<HTMLElement>): void;
  39081. /**
  39082. * Gets the class name of the current intput.
  39083. * @returns the class name
  39084. */
  39085. getClassName(): string;
  39086. /**
  39087. * Get the friendly name associated with the input class.
  39088. * @returns the input friendly name
  39089. */
  39090. getSimpleName(): string;
  39091. }
  39092. }
  39093. declare module BABYLON {
  39094. /**
  39095. * Listen to mouse events to control the camera.
  39096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39097. */
  39098. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39099. /**
  39100. * Defines the camera the input is attached to.
  39101. */
  39102. camera: FlyCamera;
  39103. /**
  39104. * Defines if touch is enabled. (Default is true.)
  39105. */
  39106. touchEnabled: boolean;
  39107. /**
  39108. * Defines the buttons associated with the input to handle camera rotation.
  39109. */
  39110. buttons: number[];
  39111. /**
  39112. * Assign buttons for Yaw control.
  39113. */
  39114. buttonsYaw: number[];
  39115. /**
  39116. * Assign buttons for Pitch control.
  39117. */
  39118. buttonsPitch: number[];
  39119. /**
  39120. * Assign buttons for Roll control.
  39121. */
  39122. buttonsRoll: number[];
  39123. /**
  39124. * Detect if any button is being pressed while mouse is moved.
  39125. * -1 = Mouse locked.
  39126. * 0 = Left button.
  39127. * 1 = Middle Button.
  39128. * 2 = Right Button.
  39129. */
  39130. activeButton: number;
  39131. /**
  39132. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39133. * Higher values reduce its sensitivity.
  39134. */
  39135. angularSensibility: number;
  39136. private _mousemoveCallback;
  39137. private _observer;
  39138. private _rollObserver;
  39139. private previousPosition;
  39140. private noPreventDefault;
  39141. private element;
  39142. /**
  39143. * Listen to mouse events to control the camera.
  39144. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39146. */
  39147. constructor(touchEnabled?: boolean);
  39148. /**
  39149. * Attach the mouse control to the HTML DOM element.
  39150. * @param element Defines the element that listens to the input events.
  39151. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39152. */
  39153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39154. /**
  39155. * Detach the current controls from the specified dom element.
  39156. * @param element Defines the element to stop listening the inputs from
  39157. */
  39158. detachControl(element: Nullable<HTMLElement>): void;
  39159. /**
  39160. * Gets the class name of the current input.
  39161. * @returns the class name.
  39162. */
  39163. getClassName(): string;
  39164. /**
  39165. * Get the friendly name associated with the input class.
  39166. * @returns the input's friendly name.
  39167. */
  39168. getSimpleName(): string;
  39169. private _pointerInput;
  39170. private _onMouseMove;
  39171. /**
  39172. * Rotate camera by mouse offset.
  39173. */
  39174. private rotateCamera;
  39175. }
  39176. }
  39177. declare module BABYLON {
  39178. /**
  39179. * Default Inputs manager for the FlyCamera.
  39180. * It groups all the default supported inputs for ease of use.
  39181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39182. */
  39183. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39184. /**
  39185. * Instantiates a new FlyCameraInputsManager.
  39186. * @param camera Defines the camera the inputs belong to.
  39187. */
  39188. constructor(camera: FlyCamera);
  39189. /**
  39190. * Add keyboard input support to the input manager.
  39191. * @returns the new FlyCameraKeyboardMoveInput().
  39192. */
  39193. addKeyboard(): FlyCameraInputsManager;
  39194. /**
  39195. * Add mouse input support to the input manager.
  39196. * @param touchEnabled Enable touch screen support.
  39197. * @returns the new FlyCameraMouseInput().
  39198. */
  39199. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39200. }
  39201. }
  39202. declare module BABYLON {
  39203. /**
  39204. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39205. * such as in a 3D Space Shooter or a Flight Simulator.
  39206. */
  39207. export class FlyCamera extends TargetCamera {
  39208. /**
  39209. * Define the collision ellipsoid of the camera.
  39210. * This is helpful for simulating a camera body, like a player's body.
  39211. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39212. */
  39213. ellipsoid: Vector3;
  39214. /**
  39215. * Define an offset for the position of the ellipsoid around the camera.
  39216. * This can be helpful if the camera is attached away from the player's body center,
  39217. * such as at its head.
  39218. */
  39219. ellipsoidOffset: Vector3;
  39220. /**
  39221. * Enable or disable collisions of the camera with the rest of the scene objects.
  39222. */
  39223. checkCollisions: boolean;
  39224. /**
  39225. * Enable or disable gravity on the camera.
  39226. */
  39227. applyGravity: boolean;
  39228. /**
  39229. * Define the current direction the camera is moving to.
  39230. */
  39231. cameraDirection: Vector3;
  39232. /**
  39233. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39234. * This overrides and empties cameraRotation.
  39235. */
  39236. rotationQuaternion: Quaternion;
  39237. /**
  39238. * Track Roll to maintain the wanted Rolling when looking around.
  39239. */
  39240. _trackRoll: number;
  39241. /**
  39242. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39243. */
  39244. rollCorrect: number;
  39245. /**
  39246. * Mimic a banked turn, Rolling the camera when Yawing.
  39247. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39248. */
  39249. bankedTurn: boolean;
  39250. /**
  39251. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39252. */
  39253. bankedTurnLimit: number;
  39254. /**
  39255. * Value of 0 disables the banked Roll.
  39256. * Value of 1 is equal to the Yaw angle in radians.
  39257. */
  39258. bankedTurnMultiplier: number;
  39259. /**
  39260. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39261. */
  39262. inputs: FlyCameraInputsManager;
  39263. /**
  39264. * Gets the input sensibility for mouse input.
  39265. * Higher values reduce sensitivity.
  39266. */
  39267. /**
  39268. * Sets the input sensibility for a mouse input.
  39269. * Higher values reduce sensitivity.
  39270. */
  39271. angularSensibility: number;
  39272. /**
  39273. * Get the keys for camera movement forward.
  39274. */
  39275. /**
  39276. * Set the keys for camera movement forward.
  39277. */
  39278. keysForward: number[];
  39279. /**
  39280. * Get the keys for camera movement backward.
  39281. */
  39282. keysBackward: number[];
  39283. /**
  39284. * Get the keys for camera movement up.
  39285. */
  39286. /**
  39287. * Set the keys for camera movement up.
  39288. */
  39289. keysUp: number[];
  39290. /**
  39291. * Get the keys for camera movement down.
  39292. */
  39293. /**
  39294. * Set the keys for camera movement down.
  39295. */
  39296. keysDown: number[];
  39297. /**
  39298. * Get the keys for camera movement left.
  39299. */
  39300. /**
  39301. * Set the keys for camera movement left.
  39302. */
  39303. keysLeft: number[];
  39304. /**
  39305. * Set the keys for camera movement right.
  39306. */
  39307. /**
  39308. * Set the keys for camera movement right.
  39309. */
  39310. keysRight: number[];
  39311. /**
  39312. * Event raised when the camera collides with a mesh in the scene.
  39313. */
  39314. onCollide: (collidedMesh: AbstractMesh) => void;
  39315. private _collider;
  39316. private _needMoveForGravity;
  39317. private _oldPosition;
  39318. private _diffPosition;
  39319. private _newPosition;
  39320. /** @hidden */
  39321. _localDirection: Vector3;
  39322. /** @hidden */
  39323. _transformedDirection: Vector3;
  39324. /**
  39325. * Instantiates a FlyCamera.
  39326. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39327. * such as in a 3D Space Shooter or a Flight Simulator.
  39328. * @param name Define the name of the camera in the scene.
  39329. * @param position Define the starting position of the camera in the scene.
  39330. * @param scene Define the scene the camera belongs to.
  39331. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39332. */
  39333. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39334. /**
  39335. * Attach a control to the HTML DOM element.
  39336. * @param element Defines the element that listens to the input events.
  39337. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39338. */
  39339. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39340. /**
  39341. * Detach a control from the HTML DOM element.
  39342. * The camera will stop reacting to that input.
  39343. * @param element Defines the element that listens to the input events.
  39344. */
  39345. detachControl(element: HTMLElement): void;
  39346. private _collisionMask;
  39347. /**
  39348. * Get the mask that the camera ignores in collision events.
  39349. */
  39350. /**
  39351. * Set the mask that the camera ignores in collision events.
  39352. */
  39353. collisionMask: number;
  39354. /** @hidden */
  39355. _collideWithWorld(displacement: Vector3): void;
  39356. /** @hidden */
  39357. private _onCollisionPositionChange;
  39358. /** @hidden */
  39359. _checkInputs(): void;
  39360. /** @hidden */
  39361. _decideIfNeedsToMove(): boolean;
  39362. /** @hidden */
  39363. _updatePosition(): void;
  39364. /**
  39365. * Restore the Roll to its target value at the rate specified.
  39366. * @param rate - Higher means slower restoring.
  39367. * @hidden
  39368. */
  39369. restoreRoll(rate: number): void;
  39370. /**
  39371. * Destroy the camera and release the current resources held by it.
  39372. */
  39373. dispose(): void;
  39374. /**
  39375. * Get the current object class name.
  39376. * @returns the class name.
  39377. */
  39378. getClassName(): string;
  39379. }
  39380. }
  39381. declare module BABYLON {
  39382. /**
  39383. * Listen to keyboard events to control the camera.
  39384. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39385. */
  39386. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39387. /**
  39388. * Defines the camera the input is attached to.
  39389. */
  39390. camera: FlyCamera;
  39391. /**
  39392. * The list of keyboard keys used to control the forward move of the camera.
  39393. */
  39394. keysForward: number[];
  39395. /**
  39396. * The list of keyboard keys used to control the backward move of the camera.
  39397. */
  39398. keysBackward: number[];
  39399. /**
  39400. * The list of keyboard keys used to control the forward move of the camera.
  39401. */
  39402. keysUp: number[];
  39403. /**
  39404. * The list of keyboard keys used to control the backward move of the camera.
  39405. */
  39406. keysDown: number[];
  39407. /**
  39408. * The list of keyboard keys used to control the right strafe move of the camera.
  39409. */
  39410. keysRight: number[];
  39411. /**
  39412. * The list of keyboard keys used to control the left strafe move of the camera.
  39413. */
  39414. keysLeft: number[];
  39415. private _keys;
  39416. private _onCanvasBlurObserver;
  39417. private _onKeyboardObserver;
  39418. private _engine;
  39419. private _scene;
  39420. /**
  39421. * Attach the input controls to a specific dom element to get the input from.
  39422. * @param element Defines the element the controls should be listened from
  39423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39424. */
  39425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39426. /**
  39427. * Detach the current controls from the specified dom element.
  39428. * @param element Defines the element to stop listening the inputs from
  39429. */
  39430. detachControl(element: Nullable<HTMLElement>): void;
  39431. /**
  39432. * Gets the class name of the current intput.
  39433. * @returns the class name
  39434. */
  39435. getClassName(): string;
  39436. /** @hidden */
  39437. _onLostFocus(e: FocusEvent): void;
  39438. /**
  39439. * Get the friendly name associated with the input class.
  39440. * @returns the input friendly name
  39441. */
  39442. getSimpleName(): string;
  39443. /**
  39444. * Update the current camera state depending on the inputs that have been used this frame.
  39445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39446. */
  39447. checkInputs(): void;
  39448. }
  39449. }
  39450. declare module BABYLON {
  39451. /**
  39452. * Manage the mouse wheel inputs to control a follow camera.
  39453. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39454. */
  39455. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39456. /**
  39457. * Defines the camera the input is attached to.
  39458. */
  39459. camera: FollowCamera;
  39460. /**
  39461. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39462. */
  39463. axisControlRadius: boolean;
  39464. /**
  39465. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39466. */
  39467. axisControlHeight: boolean;
  39468. /**
  39469. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39470. */
  39471. axisControlRotation: boolean;
  39472. /**
  39473. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39474. * relation to mouseWheel events.
  39475. */
  39476. wheelPrecision: number;
  39477. /**
  39478. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39479. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39480. */
  39481. wheelDeltaPercentage: number;
  39482. private _wheel;
  39483. private _observer;
  39484. /**
  39485. * Attach the input controls to a specific dom element to get the input from.
  39486. * @param element Defines the element the controls should be listened from
  39487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39488. */
  39489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39490. /**
  39491. * Detach the current controls from the specified dom element.
  39492. * @param element Defines the element to stop listening the inputs from
  39493. */
  39494. detachControl(element: Nullable<HTMLElement>): void;
  39495. /**
  39496. * Gets the class name of the current intput.
  39497. * @returns the class name
  39498. */
  39499. getClassName(): string;
  39500. /**
  39501. * Get the friendly name associated with the input class.
  39502. * @returns the input friendly name
  39503. */
  39504. getSimpleName(): string;
  39505. }
  39506. }
  39507. declare module BABYLON {
  39508. /**
  39509. * Manage the pointers inputs to control an follow camera.
  39510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39511. */
  39512. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39513. /**
  39514. * Defines the camera the input is attached to.
  39515. */
  39516. camera: FollowCamera;
  39517. /**
  39518. * Gets the class name of the current input.
  39519. * @returns the class name
  39520. */
  39521. getClassName(): string;
  39522. /**
  39523. * Defines the pointer angular sensibility along the X axis or how fast is
  39524. * the camera rotating.
  39525. * A negative number will reverse the axis direction.
  39526. */
  39527. angularSensibilityX: number;
  39528. /**
  39529. * Defines the pointer angular sensibility along the Y axis or how fast is
  39530. * the camera rotating.
  39531. * A negative number will reverse the axis direction.
  39532. */
  39533. angularSensibilityY: number;
  39534. /**
  39535. * Defines the pointer pinch precision or how fast is the camera zooming.
  39536. * A negative number will reverse the axis direction.
  39537. */
  39538. pinchPrecision: number;
  39539. /**
  39540. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39541. * from 0.
  39542. * It defines the percentage of current camera.radius to use as delta when
  39543. * pinch zoom is used.
  39544. */
  39545. pinchDeltaPercentage: number;
  39546. /**
  39547. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39548. */
  39549. axisXControlRadius: boolean;
  39550. /**
  39551. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39552. */
  39553. axisXControlHeight: boolean;
  39554. /**
  39555. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39556. */
  39557. axisXControlRotation: boolean;
  39558. /**
  39559. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39560. */
  39561. axisYControlRadius: boolean;
  39562. /**
  39563. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39564. */
  39565. axisYControlHeight: boolean;
  39566. /**
  39567. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39568. */
  39569. axisYControlRotation: boolean;
  39570. /**
  39571. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39572. */
  39573. axisPinchControlRadius: boolean;
  39574. /**
  39575. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39576. */
  39577. axisPinchControlHeight: boolean;
  39578. /**
  39579. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39580. */
  39581. axisPinchControlRotation: boolean;
  39582. /**
  39583. * Log error messages if basic misconfiguration has occurred.
  39584. */
  39585. warningEnable: boolean;
  39586. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39587. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39588. private _warningCounter;
  39589. private _warning;
  39590. }
  39591. }
  39592. declare module BABYLON {
  39593. /**
  39594. * Default Inputs manager for the FollowCamera.
  39595. * It groups all the default supported inputs for ease of use.
  39596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39597. */
  39598. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39599. /**
  39600. * Instantiates a new FollowCameraInputsManager.
  39601. * @param camera Defines the camera the inputs belong to
  39602. */
  39603. constructor(camera: FollowCamera);
  39604. /**
  39605. * Add keyboard input support to the input manager.
  39606. * @returns the current input manager
  39607. */
  39608. addKeyboard(): FollowCameraInputsManager;
  39609. /**
  39610. * Add mouse wheel input support to the input manager.
  39611. * @returns the current input manager
  39612. */
  39613. addMouseWheel(): FollowCameraInputsManager;
  39614. /**
  39615. * Add pointers input support to the input manager.
  39616. * @returns the current input manager
  39617. */
  39618. addPointers(): FollowCameraInputsManager;
  39619. /**
  39620. * Add orientation input support to the input manager.
  39621. * @returns the current input manager
  39622. */
  39623. addVRDeviceOrientation(): FollowCameraInputsManager;
  39624. }
  39625. }
  39626. declare module BABYLON {
  39627. /**
  39628. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39629. * an arc rotate version arcFollowCamera are available.
  39630. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39631. */
  39632. export class FollowCamera extends TargetCamera {
  39633. /**
  39634. * Distance the follow camera should follow an object at
  39635. */
  39636. radius: number;
  39637. /**
  39638. * Minimum allowed distance of the camera to the axis of rotation
  39639. * (The camera can not get closer).
  39640. * This can help limiting how the Camera is able to move in the scene.
  39641. */
  39642. lowerRadiusLimit: Nullable<number>;
  39643. /**
  39644. * Maximum allowed distance of the camera to the axis of rotation
  39645. * (The camera can not get further).
  39646. * This can help limiting how the Camera is able to move in the scene.
  39647. */
  39648. upperRadiusLimit: Nullable<number>;
  39649. /**
  39650. * Define a rotation offset between the camera and the object it follows
  39651. */
  39652. rotationOffset: number;
  39653. /**
  39654. * Minimum allowed angle to camera position relative to target object.
  39655. * This can help limiting how the Camera is able to move in the scene.
  39656. */
  39657. lowerRotationOffsetLimit: Nullable<number>;
  39658. /**
  39659. * Maximum allowed angle to camera position relative to target object.
  39660. * This can help limiting how the Camera is able to move in the scene.
  39661. */
  39662. upperRotationOffsetLimit: Nullable<number>;
  39663. /**
  39664. * Define a height offset between the camera and the object it follows.
  39665. * It can help following an object from the top (like a car chaing a plane)
  39666. */
  39667. heightOffset: number;
  39668. /**
  39669. * Minimum allowed height of camera position relative to target object.
  39670. * This can help limiting how the Camera is able to move in the scene.
  39671. */
  39672. lowerHeightOffsetLimit: Nullable<number>;
  39673. /**
  39674. * Maximum allowed height of camera position relative to target object.
  39675. * This can help limiting how the Camera is able to move in the scene.
  39676. */
  39677. upperHeightOffsetLimit: Nullable<number>;
  39678. /**
  39679. * Define how fast the camera can accelerate to follow it s target.
  39680. */
  39681. cameraAcceleration: number;
  39682. /**
  39683. * Define the speed limit of the camera following an object.
  39684. */
  39685. maxCameraSpeed: number;
  39686. /**
  39687. * Define the target of the camera.
  39688. */
  39689. lockedTarget: Nullable<AbstractMesh>;
  39690. /**
  39691. * Defines the input associated with the camera.
  39692. */
  39693. inputs: FollowCameraInputsManager;
  39694. /**
  39695. * Instantiates the follow camera.
  39696. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39697. * @param name Define the name of the camera in the scene
  39698. * @param position Define the position of the camera
  39699. * @param scene Define the scene the camera belong to
  39700. * @param lockedTarget Define the target of the camera
  39701. */
  39702. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39703. private _follow;
  39704. /**
  39705. * Attached controls to the current camera.
  39706. * @param element Defines the element the controls should be listened from
  39707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39708. */
  39709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39710. /**
  39711. * Detach the current controls from the camera.
  39712. * The camera will stop reacting to inputs.
  39713. * @param element Defines the element to stop listening the inputs from
  39714. */
  39715. detachControl(element: HTMLElement): void;
  39716. /** @hidden */
  39717. _checkInputs(): void;
  39718. private _checkLimits;
  39719. /**
  39720. * Gets the camera class name.
  39721. * @returns the class name
  39722. */
  39723. getClassName(): string;
  39724. }
  39725. /**
  39726. * Arc Rotate version of the follow camera.
  39727. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39728. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39729. */
  39730. export class ArcFollowCamera extends TargetCamera {
  39731. /** The longitudinal angle of the camera */
  39732. alpha: number;
  39733. /** The latitudinal angle of the camera */
  39734. beta: number;
  39735. /** The radius of the camera from its target */
  39736. radius: number;
  39737. /** Define the camera target (the messh it should follow) */
  39738. target: Nullable<AbstractMesh>;
  39739. private _cartesianCoordinates;
  39740. /**
  39741. * Instantiates a new ArcFollowCamera
  39742. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39743. * @param name Define the name of the camera
  39744. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39745. * @param beta Define the rotation angle of the camera around the elevation axis
  39746. * @param radius Define the radius of the camera from its target point
  39747. * @param target Define the target of the camera
  39748. * @param scene Define the scene the camera belongs to
  39749. */
  39750. constructor(name: string,
  39751. /** The longitudinal angle of the camera */
  39752. alpha: number,
  39753. /** The latitudinal angle of the camera */
  39754. beta: number,
  39755. /** The radius of the camera from its target */
  39756. radius: number,
  39757. /** Define the camera target (the messh it should follow) */
  39758. target: Nullable<AbstractMesh>, scene: Scene);
  39759. private _follow;
  39760. /** @hidden */
  39761. _checkInputs(): void;
  39762. /**
  39763. * Returns the class name of the object.
  39764. * It is mostly used internally for serialization purposes.
  39765. */
  39766. getClassName(): string;
  39767. }
  39768. }
  39769. declare module BABYLON {
  39770. /**
  39771. * Manage the keyboard inputs to control the movement of a follow camera.
  39772. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39773. */
  39774. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39775. /**
  39776. * Defines the camera the input is attached to.
  39777. */
  39778. camera: FollowCamera;
  39779. /**
  39780. * Defines the list of key codes associated with the up action (increase heightOffset)
  39781. */
  39782. keysHeightOffsetIncr: number[];
  39783. /**
  39784. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39785. */
  39786. keysHeightOffsetDecr: number[];
  39787. /**
  39788. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39789. */
  39790. keysHeightOffsetModifierAlt: boolean;
  39791. /**
  39792. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39793. */
  39794. keysHeightOffsetModifierCtrl: boolean;
  39795. /**
  39796. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39797. */
  39798. keysHeightOffsetModifierShift: boolean;
  39799. /**
  39800. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39801. */
  39802. keysRotationOffsetIncr: number[];
  39803. /**
  39804. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39805. */
  39806. keysRotationOffsetDecr: number[];
  39807. /**
  39808. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39809. */
  39810. keysRotationOffsetModifierAlt: boolean;
  39811. /**
  39812. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39813. */
  39814. keysRotationOffsetModifierCtrl: boolean;
  39815. /**
  39816. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39817. */
  39818. keysRotationOffsetModifierShift: boolean;
  39819. /**
  39820. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39821. */
  39822. keysRadiusIncr: number[];
  39823. /**
  39824. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39825. */
  39826. keysRadiusDecr: number[];
  39827. /**
  39828. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39829. */
  39830. keysRadiusModifierAlt: boolean;
  39831. /**
  39832. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39833. */
  39834. keysRadiusModifierCtrl: boolean;
  39835. /**
  39836. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39837. */
  39838. keysRadiusModifierShift: boolean;
  39839. /**
  39840. * Defines the rate of change of heightOffset.
  39841. */
  39842. heightSensibility: number;
  39843. /**
  39844. * Defines the rate of change of rotationOffset.
  39845. */
  39846. rotationSensibility: number;
  39847. /**
  39848. * Defines the rate of change of radius.
  39849. */
  39850. radiusSensibility: number;
  39851. private _keys;
  39852. private _ctrlPressed;
  39853. private _altPressed;
  39854. private _shiftPressed;
  39855. private _onCanvasBlurObserver;
  39856. private _onKeyboardObserver;
  39857. private _engine;
  39858. private _scene;
  39859. /**
  39860. * Attach the input controls to a specific dom element to get the input from.
  39861. * @param element Defines the element the controls should be listened from
  39862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39863. */
  39864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39865. /**
  39866. * Detach the current controls from the specified dom element.
  39867. * @param element Defines the element to stop listening the inputs from
  39868. */
  39869. detachControl(element: Nullable<HTMLElement>): void;
  39870. /**
  39871. * Update the current camera state depending on the inputs that have been used this frame.
  39872. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39873. */
  39874. checkInputs(): void;
  39875. /**
  39876. * Gets the class name of the current input.
  39877. * @returns the class name
  39878. */
  39879. getClassName(): string;
  39880. /**
  39881. * Get the friendly name associated with the input class.
  39882. * @returns the input friendly name
  39883. */
  39884. getSimpleName(): string;
  39885. /**
  39886. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39887. * allow modification of the heightOffset value.
  39888. */
  39889. private _modifierHeightOffset;
  39890. /**
  39891. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39892. * allow modification of the rotationOffset value.
  39893. */
  39894. private _modifierRotationOffset;
  39895. /**
  39896. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39897. * allow modification of the radius value.
  39898. */
  39899. private _modifierRadius;
  39900. }
  39901. }
  39902. declare module BABYLON {
  39903. interface FreeCameraInputsManager {
  39904. /**
  39905. * @hidden
  39906. */
  39907. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39908. /**
  39909. * Add orientation input support to the input manager.
  39910. * @returns the current input manager
  39911. */
  39912. addDeviceOrientation(): FreeCameraInputsManager;
  39913. }
  39914. /**
  39915. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39916. * Screen rotation is taken into account.
  39917. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39918. */
  39919. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39920. private _camera;
  39921. private _screenOrientationAngle;
  39922. private _constantTranform;
  39923. private _screenQuaternion;
  39924. private _alpha;
  39925. private _beta;
  39926. private _gamma;
  39927. /**
  39928. * Can be used to detect if a device orientation sensor is available on a device
  39929. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39930. * @returns a promise that will resolve on orientation change
  39931. */
  39932. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39933. /**
  39934. * @hidden
  39935. */
  39936. _onDeviceOrientationChangedObservable: Observable<void>;
  39937. /**
  39938. * Instantiates a new input
  39939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39940. */
  39941. constructor();
  39942. /**
  39943. * Define the camera controlled by the input.
  39944. */
  39945. camera: FreeCamera;
  39946. /**
  39947. * Attach the input controls to a specific dom element to get the input from.
  39948. * @param element Defines the element the controls should be listened from
  39949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39950. */
  39951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39952. private _orientationChanged;
  39953. private _deviceOrientation;
  39954. /**
  39955. * Detach the current controls from the specified dom element.
  39956. * @param element Defines the element to stop listening the inputs from
  39957. */
  39958. detachControl(element: Nullable<HTMLElement>): void;
  39959. /**
  39960. * Update the current camera state depending on the inputs that have been used this frame.
  39961. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39962. */
  39963. checkInputs(): void;
  39964. /**
  39965. * Gets the class name of the current intput.
  39966. * @returns the class name
  39967. */
  39968. getClassName(): string;
  39969. /**
  39970. * Get the friendly name associated with the input class.
  39971. * @returns the input friendly name
  39972. */
  39973. getSimpleName(): string;
  39974. }
  39975. }
  39976. declare module BABYLON {
  39977. /**
  39978. * Manage the gamepad inputs to control a free camera.
  39979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39980. */
  39981. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39982. /**
  39983. * Define the camera the input is attached to.
  39984. */
  39985. camera: FreeCamera;
  39986. /**
  39987. * Define the Gamepad controlling the input
  39988. */
  39989. gamepad: Nullable<Gamepad>;
  39990. /**
  39991. * Defines the gamepad rotation sensiblity.
  39992. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39993. */
  39994. gamepadAngularSensibility: number;
  39995. /**
  39996. * Defines the gamepad move sensiblity.
  39997. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39998. */
  39999. gamepadMoveSensibility: number;
  40000. private _yAxisScale;
  40001. /**
  40002. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40003. */
  40004. invertYAxis: boolean;
  40005. private _onGamepadConnectedObserver;
  40006. private _onGamepadDisconnectedObserver;
  40007. private _cameraTransform;
  40008. private _deltaTransform;
  40009. private _vector3;
  40010. private _vector2;
  40011. /**
  40012. * Attach the input controls to a specific dom element to get the input from.
  40013. * @param element Defines the element the controls should be listened from
  40014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40015. */
  40016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40017. /**
  40018. * Detach the current controls from the specified dom element.
  40019. * @param element Defines the element to stop listening the inputs from
  40020. */
  40021. detachControl(element: Nullable<HTMLElement>): void;
  40022. /**
  40023. * Update the current camera state depending on the inputs that have been used this frame.
  40024. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40025. */
  40026. checkInputs(): void;
  40027. /**
  40028. * Gets the class name of the current intput.
  40029. * @returns the class name
  40030. */
  40031. getClassName(): string;
  40032. /**
  40033. * Get the friendly name associated with the input class.
  40034. * @returns the input friendly name
  40035. */
  40036. getSimpleName(): string;
  40037. }
  40038. }
  40039. declare module BABYLON {
  40040. /**
  40041. * Defines the potential axis of a Joystick
  40042. */
  40043. export enum JoystickAxis {
  40044. /** X axis */
  40045. X = 0,
  40046. /** Y axis */
  40047. Y = 1,
  40048. /** Z axis */
  40049. Z = 2
  40050. }
  40051. /**
  40052. * Class used to define virtual joystick (used in touch mode)
  40053. */
  40054. export class VirtualJoystick {
  40055. /**
  40056. * Gets or sets a boolean indicating that left and right values must be inverted
  40057. */
  40058. reverseLeftRight: boolean;
  40059. /**
  40060. * Gets or sets a boolean indicating that up and down values must be inverted
  40061. */
  40062. reverseUpDown: boolean;
  40063. /**
  40064. * Gets the offset value for the position (ie. the change of the position value)
  40065. */
  40066. deltaPosition: Vector3;
  40067. /**
  40068. * Gets a boolean indicating if the virtual joystick was pressed
  40069. */
  40070. pressed: boolean;
  40071. /**
  40072. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40073. */
  40074. static Canvas: Nullable<HTMLCanvasElement>;
  40075. private static _globalJoystickIndex;
  40076. private static vjCanvasContext;
  40077. private static vjCanvasWidth;
  40078. private static vjCanvasHeight;
  40079. private static halfWidth;
  40080. private _action;
  40081. private _axisTargetedByLeftAndRight;
  40082. private _axisTargetedByUpAndDown;
  40083. private _joystickSensibility;
  40084. private _inversedSensibility;
  40085. private _joystickPointerID;
  40086. private _joystickColor;
  40087. private _joystickPointerPos;
  40088. private _joystickPreviousPointerPos;
  40089. private _joystickPointerStartPos;
  40090. private _deltaJoystickVector;
  40091. private _leftJoystick;
  40092. private _touches;
  40093. private _onPointerDownHandlerRef;
  40094. private _onPointerMoveHandlerRef;
  40095. private _onPointerUpHandlerRef;
  40096. private _onResize;
  40097. /**
  40098. * Creates a new virtual joystick
  40099. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40100. */
  40101. constructor(leftJoystick?: boolean);
  40102. /**
  40103. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40104. * @param newJoystickSensibility defines the new sensibility
  40105. */
  40106. setJoystickSensibility(newJoystickSensibility: number): void;
  40107. private _onPointerDown;
  40108. private _onPointerMove;
  40109. private _onPointerUp;
  40110. /**
  40111. * Change the color of the virtual joystick
  40112. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40113. */
  40114. setJoystickColor(newColor: string): void;
  40115. /**
  40116. * Defines a callback to call when the joystick is touched
  40117. * @param action defines the callback
  40118. */
  40119. setActionOnTouch(action: () => any): void;
  40120. /**
  40121. * Defines which axis you'd like to control for left & right
  40122. * @param axis defines the axis to use
  40123. */
  40124. setAxisForLeftRight(axis: JoystickAxis): void;
  40125. /**
  40126. * Defines which axis you'd like to control for up & down
  40127. * @param axis defines the axis to use
  40128. */
  40129. setAxisForUpDown(axis: JoystickAxis): void;
  40130. private _drawVirtualJoystick;
  40131. /**
  40132. * Release internal HTML canvas
  40133. */
  40134. releaseCanvas(): void;
  40135. }
  40136. }
  40137. declare module BABYLON {
  40138. interface FreeCameraInputsManager {
  40139. /**
  40140. * Add virtual joystick input support to the input manager.
  40141. * @returns the current input manager
  40142. */
  40143. addVirtualJoystick(): FreeCameraInputsManager;
  40144. }
  40145. /**
  40146. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40147. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40148. */
  40149. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40150. /**
  40151. * Defines the camera the input is attached to.
  40152. */
  40153. camera: FreeCamera;
  40154. private _leftjoystick;
  40155. private _rightjoystick;
  40156. /**
  40157. * Gets the left stick of the virtual joystick.
  40158. * @returns The virtual Joystick
  40159. */
  40160. getLeftJoystick(): VirtualJoystick;
  40161. /**
  40162. * Gets the right stick of the virtual joystick.
  40163. * @returns The virtual Joystick
  40164. */
  40165. getRightJoystick(): VirtualJoystick;
  40166. /**
  40167. * Update the current camera state depending on the inputs that have been used this frame.
  40168. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40169. */
  40170. checkInputs(): void;
  40171. /**
  40172. * Attach the input controls to a specific dom element to get the input from.
  40173. * @param element Defines the element the controls should be listened from
  40174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40175. */
  40176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40177. /**
  40178. * Detach the current controls from the specified dom element.
  40179. * @param element Defines the element to stop listening the inputs from
  40180. */
  40181. detachControl(element: Nullable<HTMLElement>): void;
  40182. /**
  40183. * Gets the class name of the current intput.
  40184. * @returns the class name
  40185. */
  40186. getClassName(): string;
  40187. /**
  40188. * Get the friendly name associated with the input class.
  40189. * @returns the input friendly name
  40190. */
  40191. getSimpleName(): string;
  40192. }
  40193. }
  40194. declare module BABYLON {
  40195. /**
  40196. * This represents a FPS type of camera controlled by touch.
  40197. * This is like a universal camera minus the Gamepad controls.
  40198. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40199. */
  40200. export class TouchCamera extends FreeCamera {
  40201. /**
  40202. * Defines the touch sensibility for rotation.
  40203. * The higher the faster.
  40204. */
  40205. touchAngularSensibility: number;
  40206. /**
  40207. * Defines the touch sensibility for move.
  40208. * The higher the faster.
  40209. */
  40210. touchMoveSensibility: number;
  40211. /**
  40212. * Instantiates a new touch camera.
  40213. * This represents a FPS type of camera controlled by touch.
  40214. * This is like a universal camera minus the Gamepad controls.
  40215. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40216. * @param name Define the name of the camera in the scene
  40217. * @param position Define the start position of the camera in the scene
  40218. * @param scene Define the scene the camera belongs to
  40219. */
  40220. constructor(name: string, position: Vector3, scene: Scene);
  40221. /**
  40222. * Gets the current object class name.
  40223. * @return the class name
  40224. */
  40225. getClassName(): string;
  40226. /** @hidden */
  40227. _setupInputs(): void;
  40228. }
  40229. }
  40230. declare module BABYLON {
  40231. /**
  40232. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40233. * being tilted forward or back and left or right.
  40234. */
  40235. export class DeviceOrientationCamera extends FreeCamera {
  40236. private _initialQuaternion;
  40237. private _quaternionCache;
  40238. private _tmpDragQuaternion;
  40239. private _disablePointerInputWhenUsingDeviceOrientation;
  40240. /**
  40241. * Creates a new device orientation camera
  40242. * @param name The name of the camera
  40243. * @param position The start position camera
  40244. * @param scene The scene the camera belongs to
  40245. */
  40246. constructor(name: string, position: Vector3, scene: Scene);
  40247. /**
  40248. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40249. */
  40250. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40251. private _dragFactor;
  40252. /**
  40253. * Enabled turning on the y axis when the orientation sensor is active
  40254. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40255. */
  40256. enableHorizontalDragging(dragFactor?: number): void;
  40257. /**
  40258. * Gets the current instance class name ("DeviceOrientationCamera").
  40259. * This helps avoiding instanceof at run time.
  40260. * @returns the class name
  40261. */
  40262. getClassName(): string;
  40263. /**
  40264. * @hidden
  40265. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40266. */
  40267. _checkInputs(): void;
  40268. /**
  40269. * Reset the camera to its default orientation on the specified axis only.
  40270. * @param axis The axis to reset
  40271. */
  40272. resetToCurrentRotation(axis?: Axis): void;
  40273. }
  40274. }
  40275. declare module BABYLON {
  40276. /**
  40277. * Defines supported buttons for XBox360 compatible gamepads
  40278. */
  40279. export enum Xbox360Button {
  40280. /** A */
  40281. A = 0,
  40282. /** B */
  40283. B = 1,
  40284. /** X */
  40285. X = 2,
  40286. /** Y */
  40287. Y = 3,
  40288. /** Start */
  40289. Start = 4,
  40290. /** Back */
  40291. Back = 5,
  40292. /** Left button */
  40293. LB = 6,
  40294. /** Right button */
  40295. RB = 7,
  40296. /** Left stick */
  40297. LeftStick = 8,
  40298. /** Right stick */
  40299. RightStick = 9
  40300. }
  40301. /** Defines values for XBox360 DPad */
  40302. export enum Xbox360Dpad {
  40303. /** Up */
  40304. Up = 0,
  40305. /** Down */
  40306. Down = 1,
  40307. /** Left */
  40308. Left = 2,
  40309. /** Right */
  40310. Right = 3
  40311. }
  40312. /**
  40313. * Defines a XBox360 gamepad
  40314. */
  40315. export class Xbox360Pad extends Gamepad {
  40316. private _leftTrigger;
  40317. private _rightTrigger;
  40318. private _onlefttriggerchanged;
  40319. private _onrighttriggerchanged;
  40320. private _onbuttondown;
  40321. private _onbuttonup;
  40322. private _ondpaddown;
  40323. private _ondpadup;
  40324. /** Observable raised when a button is pressed */
  40325. onButtonDownObservable: Observable<Xbox360Button>;
  40326. /** Observable raised when a button is released */
  40327. onButtonUpObservable: Observable<Xbox360Button>;
  40328. /** Observable raised when a pad is pressed */
  40329. onPadDownObservable: Observable<Xbox360Dpad>;
  40330. /** Observable raised when a pad is released */
  40331. onPadUpObservable: Observable<Xbox360Dpad>;
  40332. private _buttonA;
  40333. private _buttonB;
  40334. private _buttonX;
  40335. private _buttonY;
  40336. private _buttonBack;
  40337. private _buttonStart;
  40338. private _buttonLB;
  40339. private _buttonRB;
  40340. private _buttonLeftStick;
  40341. private _buttonRightStick;
  40342. private _dPadUp;
  40343. private _dPadDown;
  40344. private _dPadLeft;
  40345. private _dPadRight;
  40346. private _isXboxOnePad;
  40347. /**
  40348. * Creates a new XBox360 gamepad object
  40349. * @param id defines the id of this gamepad
  40350. * @param index defines its index
  40351. * @param gamepad defines the internal HTML gamepad object
  40352. * @param xboxOne defines if it is a XBox One gamepad
  40353. */
  40354. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40355. /**
  40356. * Defines the callback to call when left trigger is pressed
  40357. * @param callback defines the callback to use
  40358. */
  40359. onlefttriggerchanged(callback: (value: number) => void): void;
  40360. /**
  40361. * Defines the callback to call when right trigger is pressed
  40362. * @param callback defines the callback to use
  40363. */
  40364. onrighttriggerchanged(callback: (value: number) => void): void;
  40365. /**
  40366. * Gets the left trigger value
  40367. */
  40368. /**
  40369. * Sets the left trigger value
  40370. */
  40371. leftTrigger: number;
  40372. /**
  40373. * Gets the right trigger value
  40374. */
  40375. /**
  40376. * Sets the right trigger value
  40377. */
  40378. rightTrigger: number;
  40379. /**
  40380. * Defines the callback to call when a button is pressed
  40381. * @param callback defines the callback to use
  40382. */
  40383. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40384. /**
  40385. * Defines the callback to call when a button is released
  40386. * @param callback defines the callback to use
  40387. */
  40388. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40389. /**
  40390. * Defines the callback to call when a pad is pressed
  40391. * @param callback defines the callback to use
  40392. */
  40393. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40394. /**
  40395. * Defines the callback to call when a pad is released
  40396. * @param callback defines the callback to use
  40397. */
  40398. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40399. private _setButtonValue;
  40400. private _setDPadValue;
  40401. /**
  40402. * Gets the value of the `A` button
  40403. */
  40404. /**
  40405. * Sets the value of the `A` button
  40406. */
  40407. buttonA: number;
  40408. /**
  40409. * Gets the value of the `B` button
  40410. */
  40411. /**
  40412. * Sets the value of the `B` button
  40413. */
  40414. buttonB: number;
  40415. /**
  40416. * Gets the value of the `X` button
  40417. */
  40418. /**
  40419. * Sets the value of the `X` button
  40420. */
  40421. buttonX: number;
  40422. /**
  40423. * Gets the value of the `Y` button
  40424. */
  40425. /**
  40426. * Sets the value of the `Y` button
  40427. */
  40428. buttonY: number;
  40429. /**
  40430. * Gets the value of the `Start` button
  40431. */
  40432. /**
  40433. * Sets the value of the `Start` button
  40434. */
  40435. buttonStart: number;
  40436. /**
  40437. * Gets the value of the `Back` button
  40438. */
  40439. /**
  40440. * Sets the value of the `Back` button
  40441. */
  40442. buttonBack: number;
  40443. /**
  40444. * Gets the value of the `Left` button
  40445. */
  40446. /**
  40447. * Sets the value of the `Left` button
  40448. */
  40449. buttonLB: number;
  40450. /**
  40451. * Gets the value of the `Right` button
  40452. */
  40453. /**
  40454. * Sets the value of the `Right` button
  40455. */
  40456. buttonRB: number;
  40457. /**
  40458. * Gets the value of the Left joystick
  40459. */
  40460. /**
  40461. * Sets the value of the Left joystick
  40462. */
  40463. buttonLeftStick: number;
  40464. /**
  40465. * Gets the value of the Right joystick
  40466. */
  40467. /**
  40468. * Sets the value of the Right joystick
  40469. */
  40470. buttonRightStick: number;
  40471. /**
  40472. * Gets the value of D-pad up
  40473. */
  40474. /**
  40475. * Sets the value of D-pad up
  40476. */
  40477. dPadUp: number;
  40478. /**
  40479. * Gets the value of D-pad down
  40480. */
  40481. /**
  40482. * Sets the value of D-pad down
  40483. */
  40484. dPadDown: number;
  40485. /**
  40486. * Gets the value of D-pad left
  40487. */
  40488. /**
  40489. * Sets the value of D-pad left
  40490. */
  40491. dPadLeft: number;
  40492. /**
  40493. * Gets the value of D-pad right
  40494. */
  40495. /**
  40496. * Sets the value of D-pad right
  40497. */
  40498. dPadRight: number;
  40499. /**
  40500. * Force the gamepad to synchronize with device values
  40501. */
  40502. update(): void;
  40503. /**
  40504. * Disposes the gamepad
  40505. */
  40506. dispose(): void;
  40507. }
  40508. }
  40509. declare module BABYLON {
  40510. /**
  40511. * Defines supported buttons for DualShock compatible gamepads
  40512. */
  40513. export enum DualShockButton {
  40514. /** Cross */
  40515. Cross = 0,
  40516. /** Circle */
  40517. Circle = 1,
  40518. /** Square */
  40519. Square = 2,
  40520. /** Triangle */
  40521. Triangle = 3,
  40522. /** Options */
  40523. Options = 4,
  40524. /** Share */
  40525. Share = 5,
  40526. /** L1 */
  40527. L1 = 6,
  40528. /** R1 */
  40529. R1 = 7,
  40530. /** Left stick */
  40531. LeftStick = 8,
  40532. /** Right stick */
  40533. RightStick = 9
  40534. }
  40535. /** Defines values for DualShock DPad */
  40536. export enum DualShockDpad {
  40537. /** Up */
  40538. Up = 0,
  40539. /** Down */
  40540. Down = 1,
  40541. /** Left */
  40542. Left = 2,
  40543. /** Right */
  40544. Right = 3
  40545. }
  40546. /**
  40547. * Defines a DualShock gamepad
  40548. */
  40549. export class DualShockPad extends Gamepad {
  40550. private _leftTrigger;
  40551. private _rightTrigger;
  40552. private _onlefttriggerchanged;
  40553. private _onrighttriggerchanged;
  40554. private _onbuttondown;
  40555. private _onbuttonup;
  40556. private _ondpaddown;
  40557. private _ondpadup;
  40558. /** Observable raised when a button is pressed */
  40559. onButtonDownObservable: Observable<DualShockButton>;
  40560. /** Observable raised when a button is released */
  40561. onButtonUpObservable: Observable<DualShockButton>;
  40562. /** Observable raised when a pad is pressed */
  40563. onPadDownObservable: Observable<DualShockDpad>;
  40564. /** Observable raised when a pad is released */
  40565. onPadUpObservable: Observable<DualShockDpad>;
  40566. private _buttonCross;
  40567. private _buttonCircle;
  40568. private _buttonSquare;
  40569. private _buttonTriangle;
  40570. private _buttonShare;
  40571. private _buttonOptions;
  40572. private _buttonL1;
  40573. private _buttonR1;
  40574. private _buttonLeftStick;
  40575. private _buttonRightStick;
  40576. private _dPadUp;
  40577. private _dPadDown;
  40578. private _dPadLeft;
  40579. private _dPadRight;
  40580. /**
  40581. * Creates a new DualShock gamepad object
  40582. * @param id defines the id of this gamepad
  40583. * @param index defines its index
  40584. * @param gamepad defines the internal HTML gamepad object
  40585. */
  40586. constructor(id: string, index: number, gamepad: any);
  40587. /**
  40588. * Defines the callback to call when left trigger is pressed
  40589. * @param callback defines the callback to use
  40590. */
  40591. onlefttriggerchanged(callback: (value: number) => void): void;
  40592. /**
  40593. * Defines the callback to call when right trigger is pressed
  40594. * @param callback defines the callback to use
  40595. */
  40596. onrighttriggerchanged(callback: (value: number) => void): void;
  40597. /**
  40598. * Gets the left trigger value
  40599. */
  40600. /**
  40601. * Sets the left trigger value
  40602. */
  40603. leftTrigger: number;
  40604. /**
  40605. * Gets the right trigger value
  40606. */
  40607. /**
  40608. * Sets the right trigger value
  40609. */
  40610. rightTrigger: number;
  40611. /**
  40612. * Defines the callback to call when a button is pressed
  40613. * @param callback defines the callback to use
  40614. */
  40615. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40616. /**
  40617. * Defines the callback to call when a button is released
  40618. * @param callback defines the callback to use
  40619. */
  40620. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40621. /**
  40622. * Defines the callback to call when a pad is pressed
  40623. * @param callback defines the callback to use
  40624. */
  40625. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40626. /**
  40627. * Defines the callback to call when a pad is released
  40628. * @param callback defines the callback to use
  40629. */
  40630. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40631. private _setButtonValue;
  40632. private _setDPadValue;
  40633. /**
  40634. * Gets the value of the `Cross` button
  40635. */
  40636. /**
  40637. * Sets the value of the `Cross` button
  40638. */
  40639. buttonCross: number;
  40640. /**
  40641. * Gets the value of the `Circle` button
  40642. */
  40643. /**
  40644. * Sets the value of the `Circle` button
  40645. */
  40646. buttonCircle: number;
  40647. /**
  40648. * Gets the value of the `Square` button
  40649. */
  40650. /**
  40651. * Sets the value of the `Square` button
  40652. */
  40653. buttonSquare: number;
  40654. /**
  40655. * Gets the value of the `Triangle` button
  40656. */
  40657. /**
  40658. * Sets the value of the `Triangle` button
  40659. */
  40660. buttonTriangle: number;
  40661. /**
  40662. * Gets the value of the `Options` button
  40663. */
  40664. /**
  40665. * Sets the value of the `Options` button
  40666. */
  40667. buttonOptions: number;
  40668. /**
  40669. * Gets the value of the `Share` button
  40670. */
  40671. /**
  40672. * Sets the value of the `Share` button
  40673. */
  40674. buttonShare: number;
  40675. /**
  40676. * Gets the value of the `L1` button
  40677. */
  40678. /**
  40679. * Sets the value of the `L1` button
  40680. */
  40681. buttonL1: number;
  40682. /**
  40683. * Gets the value of the `R1` button
  40684. */
  40685. /**
  40686. * Sets the value of the `R1` button
  40687. */
  40688. buttonR1: number;
  40689. /**
  40690. * Gets the value of the Left joystick
  40691. */
  40692. /**
  40693. * Sets the value of the Left joystick
  40694. */
  40695. buttonLeftStick: number;
  40696. /**
  40697. * Gets the value of the Right joystick
  40698. */
  40699. /**
  40700. * Sets the value of the Right joystick
  40701. */
  40702. buttonRightStick: number;
  40703. /**
  40704. * Gets the value of D-pad up
  40705. */
  40706. /**
  40707. * Sets the value of D-pad up
  40708. */
  40709. dPadUp: number;
  40710. /**
  40711. * Gets the value of D-pad down
  40712. */
  40713. /**
  40714. * Sets the value of D-pad down
  40715. */
  40716. dPadDown: number;
  40717. /**
  40718. * Gets the value of D-pad left
  40719. */
  40720. /**
  40721. * Sets the value of D-pad left
  40722. */
  40723. dPadLeft: number;
  40724. /**
  40725. * Gets the value of D-pad right
  40726. */
  40727. /**
  40728. * Sets the value of D-pad right
  40729. */
  40730. dPadRight: number;
  40731. /**
  40732. * Force the gamepad to synchronize with device values
  40733. */
  40734. update(): void;
  40735. /**
  40736. * Disposes the gamepad
  40737. */
  40738. dispose(): void;
  40739. }
  40740. }
  40741. declare module BABYLON {
  40742. /**
  40743. * Manager for handling gamepads
  40744. */
  40745. export class GamepadManager {
  40746. private _scene?;
  40747. private _babylonGamepads;
  40748. private _oneGamepadConnected;
  40749. /** @hidden */
  40750. _isMonitoring: boolean;
  40751. private _gamepadEventSupported;
  40752. private _gamepadSupport;
  40753. /**
  40754. * observable to be triggered when the gamepad controller has been connected
  40755. */
  40756. onGamepadConnectedObservable: Observable<Gamepad>;
  40757. /**
  40758. * observable to be triggered when the gamepad controller has been disconnected
  40759. */
  40760. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40761. private _onGamepadConnectedEvent;
  40762. private _onGamepadDisconnectedEvent;
  40763. /**
  40764. * Initializes the gamepad manager
  40765. * @param _scene BabylonJS scene
  40766. */
  40767. constructor(_scene?: Scene | undefined);
  40768. /**
  40769. * The gamepads in the game pad manager
  40770. */
  40771. readonly gamepads: Gamepad[];
  40772. /**
  40773. * Get the gamepad controllers based on type
  40774. * @param type The type of gamepad controller
  40775. * @returns Nullable gamepad
  40776. */
  40777. getGamepadByType(type?: number): Nullable<Gamepad>;
  40778. /**
  40779. * Disposes the gamepad manager
  40780. */
  40781. dispose(): void;
  40782. private _addNewGamepad;
  40783. private _startMonitoringGamepads;
  40784. private _stopMonitoringGamepads;
  40785. /** @hidden */
  40786. _checkGamepadsStatus(): void;
  40787. private _updateGamepadObjects;
  40788. }
  40789. }
  40790. declare module BABYLON {
  40791. interface Scene {
  40792. /** @hidden */
  40793. _gamepadManager: Nullable<GamepadManager>;
  40794. /**
  40795. * Gets the gamepad manager associated with the scene
  40796. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40797. */
  40798. gamepadManager: GamepadManager;
  40799. }
  40800. /**
  40801. * Interface representing a free camera inputs manager
  40802. */
  40803. interface FreeCameraInputsManager {
  40804. /**
  40805. * Adds gamepad input support to the FreeCameraInputsManager.
  40806. * @returns the FreeCameraInputsManager
  40807. */
  40808. addGamepad(): FreeCameraInputsManager;
  40809. }
  40810. /**
  40811. * Interface representing an arc rotate camera inputs manager
  40812. */
  40813. interface ArcRotateCameraInputsManager {
  40814. /**
  40815. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40816. * @returns the camera inputs manager
  40817. */
  40818. addGamepad(): ArcRotateCameraInputsManager;
  40819. }
  40820. /**
  40821. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40822. */
  40823. export class GamepadSystemSceneComponent implements ISceneComponent {
  40824. /**
  40825. * The component name helpfull to identify the component in the list of scene components.
  40826. */
  40827. readonly name: string;
  40828. /**
  40829. * The scene the component belongs to.
  40830. */
  40831. scene: Scene;
  40832. /**
  40833. * Creates a new instance of the component for the given scene
  40834. * @param scene Defines the scene to register the component in
  40835. */
  40836. constructor(scene: Scene);
  40837. /**
  40838. * Registers the component in a given scene
  40839. */
  40840. register(): void;
  40841. /**
  40842. * Rebuilds the elements related to this component in case of
  40843. * context lost for instance.
  40844. */
  40845. rebuild(): void;
  40846. /**
  40847. * Disposes the component and the associated ressources
  40848. */
  40849. dispose(): void;
  40850. private _beforeCameraUpdate;
  40851. }
  40852. }
  40853. declare module BABYLON {
  40854. /**
  40855. * 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,
  40856. * which still works and will still be found in many Playgrounds.
  40857. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40858. */
  40859. export class UniversalCamera extends TouchCamera {
  40860. /**
  40861. * Defines the gamepad rotation sensiblity.
  40862. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40863. */
  40864. gamepadAngularSensibility: number;
  40865. /**
  40866. * Defines the gamepad move sensiblity.
  40867. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40868. */
  40869. gamepadMoveSensibility: number;
  40870. /**
  40871. * 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,
  40872. * which still works and will still be found in many Playgrounds.
  40873. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40874. * @param name Define the name of the camera in the scene
  40875. * @param position Define the start position of the camera in the scene
  40876. * @param scene Define the scene the camera belongs to
  40877. */
  40878. constructor(name: string, position: Vector3, scene: Scene);
  40879. /**
  40880. * Gets the current object class name.
  40881. * @return the class name
  40882. */
  40883. getClassName(): string;
  40884. }
  40885. }
  40886. declare module BABYLON {
  40887. /**
  40888. * This represents a FPS type of camera. This is only here for back compat purpose.
  40889. * Please use the UniversalCamera instead as both are identical.
  40890. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40891. */
  40892. export class GamepadCamera extends UniversalCamera {
  40893. /**
  40894. * Instantiates a new Gamepad Camera
  40895. * This represents a FPS type of camera. This is only here for back compat purpose.
  40896. * Please use the UniversalCamera instead as both are identical.
  40897. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40898. * @param name Define the name of the camera in the scene
  40899. * @param position Define the start position of the camera in the scene
  40900. * @param scene Define the scene the camera belongs to
  40901. */
  40902. constructor(name: string, position: Vector3, scene: Scene);
  40903. /**
  40904. * Gets the current object class name.
  40905. * @return the class name
  40906. */
  40907. getClassName(): string;
  40908. }
  40909. }
  40910. declare module BABYLON {
  40911. /** @hidden */
  40912. export var passPixelShader: {
  40913. name: string;
  40914. shader: string;
  40915. };
  40916. }
  40917. declare module BABYLON {
  40918. /** @hidden */
  40919. export var passCubePixelShader: {
  40920. name: string;
  40921. shader: string;
  40922. };
  40923. }
  40924. declare module BABYLON {
  40925. /**
  40926. * PassPostProcess which produces an output the same as it's input
  40927. */
  40928. export class PassPostProcess extends PostProcess {
  40929. /**
  40930. * Creates the PassPostProcess
  40931. * @param name The name of the effect.
  40932. * @param options The required width/height ratio to downsize to before computing the render pass.
  40933. * @param camera The camera to apply the render pass to.
  40934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40935. * @param engine The engine which the post process will be applied. (default: current engine)
  40936. * @param reusable If the post process can be reused on the same frame. (default: false)
  40937. * @param textureType The type of texture to be used when performing the post processing.
  40938. * @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)
  40939. */
  40940. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40941. }
  40942. /**
  40943. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40944. */
  40945. export class PassCubePostProcess extends PostProcess {
  40946. private _face;
  40947. /**
  40948. * Gets or sets the cube face to display.
  40949. * * 0 is +X
  40950. * * 1 is -X
  40951. * * 2 is +Y
  40952. * * 3 is -Y
  40953. * * 4 is +Z
  40954. * * 5 is -Z
  40955. */
  40956. face: number;
  40957. /**
  40958. * Creates the PassCubePostProcess
  40959. * @param name The name of the effect.
  40960. * @param options The required width/height ratio to downsize to before computing the render pass.
  40961. * @param camera The camera to apply the render pass to.
  40962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40963. * @param engine The engine which the post process will be applied. (default: current engine)
  40964. * @param reusable If the post process can be reused on the same frame. (default: false)
  40965. * @param textureType The type of texture to be used when performing the post processing.
  40966. * @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)
  40967. */
  40968. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40969. }
  40970. }
  40971. declare module BABYLON {
  40972. /** @hidden */
  40973. export var anaglyphPixelShader: {
  40974. name: string;
  40975. shader: string;
  40976. };
  40977. }
  40978. declare module BABYLON {
  40979. /**
  40980. * Postprocess used to generate anaglyphic rendering
  40981. */
  40982. export class AnaglyphPostProcess extends PostProcess {
  40983. private _passedProcess;
  40984. /**
  40985. * Creates a new AnaglyphPostProcess
  40986. * @param name defines postprocess name
  40987. * @param options defines creation options or target ratio scale
  40988. * @param rigCameras defines cameras using this postprocess
  40989. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40990. * @param engine defines hosting engine
  40991. * @param reusable defines if the postprocess will be reused multiple times per frame
  40992. */
  40993. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40994. }
  40995. }
  40996. declare module BABYLON {
  40997. /**
  40998. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40999. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41000. */
  41001. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41002. /**
  41003. * Creates a new AnaglyphArcRotateCamera
  41004. * @param name defines camera name
  41005. * @param alpha defines alpha angle (in radians)
  41006. * @param beta defines beta angle (in radians)
  41007. * @param radius defines radius
  41008. * @param target defines camera target
  41009. * @param interaxialDistance defines distance between each color axis
  41010. * @param scene defines the hosting scene
  41011. */
  41012. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41013. /**
  41014. * Gets camera class name
  41015. * @returns AnaglyphArcRotateCamera
  41016. */
  41017. getClassName(): string;
  41018. }
  41019. }
  41020. declare module BABYLON {
  41021. /**
  41022. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41023. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41024. */
  41025. export class AnaglyphFreeCamera extends FreeCamera {
  41026. /**
  41027. * Creates a new AnaglyphFreeCamera
  41028. * @param name defines camera name
  41029. * @param position defines initial position
  41030. * @param interaxialDistance defines distance between each color axis
  41031. * @param scene defines the hosting scene
  41032. */
  41033. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41034. /**
  41035. * Gets camera class name
  41036. * @returns AnaglyphFreeCamera
  41037. */
  41038. getClassName(): string;
  41039. }
  41040. }
  41041. declare module BABYLON {
  41042. /**
  41043. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41044. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41045. */
  41046. export class AnaglyphGamepadCamera extends GamepadCamera {
  41047. /**
  41048. * Creates a new AnaglyphGamepadCamera
  41049. * @param name defines camera name
  41050. * @param position defines initial position
  41051. * @param interaxialDistance defines distance between each color axis
  41052. * @param scene defines the hosting scene
  41053. */
  41054. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41055. /**
  41056. * Gets camera class name
  41057. * @returns AnaglyphGamepadCamera
  41058. */
  41059. getClassName(): string;
  41060. }
  41061. }
  41062. declare module BABYLON {
  41063. /**
  41064. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41065. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41066. */
  41067. export class AnaglyphUniversalCamera extends UniversalCamera {
  41068. /**
  41069. * Creates a new AnaglyphUniversalCamera
  41070. * @param name defines camera name
  41071. * @param position defines initial position
  41072. * @param interaxialDistance defines distance between each color axis
  41073. * @param scene defines the hosting scene
  41074. */
  41075. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41076. /**
  41077. * Gets camera class name
  41078. * @returns AnaglyphUniversalCamera
  41079. */
  41080. getClassName(): string;
  41081. }
  41082. }
  41083. declare module BABYLON {
  41084. /** @hidden */
  41085. export var stereoscopicInterlacePixelShader: {
  41086. name: string;
  41087. shader: string;
  41088. };
  41089. }
  41090. declare module BABYLON {
  41091. /**
  41092. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41093. */
  41094. export class StereoscopicInterlacePostProcess extends PostProcess {
  41095. private _stepSize;
  41096. private _passedProcess;
  41097. /**
  41098. * Initializes a StereoscopicInterlacePostProcess
  41099. * @param name The name of the effect.
  41100. * @param rigCameras The rig cameras to be appled to the post process
  41101. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41103. * @param engine The engine which the post process will be applied. (default: current engine)
  41104. * @param reusable If the post process can be reused on the same frame. (default: false)
  41105. */
  41106. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41107. }
  41108. }
  41109. declare module BABYLON {
  41110. /**
  41111. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41112. * @see http://doc.babylonjs.com/features/cameras
  41113. */
  41114. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41115. /**
  41116. * Creates a new StereoscopicArcRotateCamera
  41117. * @param name defines camera name
  41118. * @param alpha defines alpha angle (in radians)
  41119. * @param beta defines beta angle (in radians)
  41120. * @param radius defines radius
  41121. * @param target defines camera target
  41122. * @param interaxialDistance defines distance between each color axis
  41123. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41124. * @param scene defines the hosting scene
  41125. */
  41126. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41127. /**
  41128. * Gets camera class name
  41129. * @returns StereoscopicArcRotateCamera
  41130. */
  41131. getClassName(): string;
  41132. }
  41133. }
  41134. declare module BABYLON {
  41135. /**
  41136. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41137. * @see http://doc.babylonjs.com/features/cameras
  41138. */
  41139. export class StereoscopicFreeCamera extends FreeCamera {
  41140. /**
  41141. * Creates a new StereoscopicFreeCamera
  41142. * @param name defines camera name
  41143. * @param position defines initial position
  41144. * @param interaxialDistance defines distance between each color axis
  41145. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41146. * @param scene defines the hosting scene
  41147. */
  41148. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41149. /**
  41150. * Gets camera class name
  41151. * @returns StereoscopicFreeCamera
  41152. */
  41153. getClassName(): string;
  41154. }
  41155. }
  41156. declare module BABYLON {
  41157. /**
  41158. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41159. * @see http://doc.babylonjs.com/features/cameras
  41160. */
  41161. export class StereoscopicGamepadCamera extends GamepadCamera {
  41162. /**
  41163. * Creates a new StereoscopicGamepadCamera
  41164. * @param name defines camera name
  41165. * @param position defines initial position
  41166. * @param interaxialDistance defines distance between each color axis
  41167. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41168. * @param scene defines the hosting scene
  41169. */
  41170. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41171. /**
  41172. * Gets camera class name
  41173. * @returns StereoscopicGamepadCamera
  41174. */
  41175. getClassName(): string;
  41176. }
  41177. }
  41178. declare module BABYLON {
  41179. /**
  41180. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41181. * @see http://doc.babylonjs.com/features/cameras
  41182. */
  41183. export class StereoscopicUniversalCamera extends UniversalCamera {
  41184. /**
  41185. * Creates a new StereoscopicUniversalCamera
  41186. * @param name defines camera name
  41187. * @param position defines initial position
  41188. * @param interaxialDistance defines distance between each color axis
  41189. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41190. * @param scene defines the hosting scene
  41191. */
  41192. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41193. /**
  41194. * Gets camera class name
  41195. * @returns StereoscopicUniversalCamera
  41196. */
  41197. getClassName(): string;
  41198. }
  41199. }
  41200. declare module BABYLON {
  41201. /**
  41202. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41203. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41204. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41205. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41206. */
  41207. export class VirtualJoysticksCamera extends FreeCamera {
  41208. /**
  41209. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41210. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41211. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41212. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41213. * @param name Define the name of the camera in the scene
  41214. * @param position Define the start position of the camera in the scene
  41215. * @param scene Define the scene the camera belongs to
  41216. */
  41217. constructor(name: string, position: Vector3, scene: Scene);
  41218. /**
  41219. * Gets the current object class name.
  41220. * @return the class name
  41221. */
  41222. getClassName(): string;
  41223. }
  41224. }
  41225. declare module BABYLON {
  41226. /**
  41227. * This represents all the required metrics to create a VR camera.
  41228. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41229. */
  41230. export class VRCameraMetrics {
  41231. /**
  41232. * Define the horizontal resolution off the screen.
  41233. */
  41234. hResolution: number;
  41235. /**
  41236. * Define the vertical resolution off the screen.
  41237. */
  41238. vResolution: number;
  41239. /**
  41240. * Define the horizontal screen size.
  41241. */
  41242. hScreenSize: number;
  41243. /**
  41244. * Define the vertical screen size.
  41245. */
  41246. vScreenSize: number;
  41247. /**
  41248. * Define the vertical screen center position.
  41249. */
  41250. vScreenCenter: number;
  41251. /**
  41252. * Define the distance of the eyes to the screen.
  41253. */
  41254. eyeToScreenDistance: number;
  41255. /**
  41256. * Define the distance between both lenses
  41257. */
  41258. lensSeparationDistance: number;
  41259. /**
  41260. * Define the distance between both viewer's eyes.
  41261. */
  41262. interpupillaryDistance: number;
  41263. /**
  41264. * Define the distortion factor of the VR postprocess.
  41265. * Please, touch with care.
  41266. */
  41267. distortionK: number[];
  41268. /**
  41269. * Define the chromatic aberration correction factors for the VR post process.
  41270. */
  41271. chromaAbCorrection: number[];
  41272. /**
  41273. * Define the scale factor of the post process.
  41274. * The smaller the better but the slower.
  41275. */
  41276. postProcessScaleFactor: number;
  41277. /**
  41278. * Define an offset for the lens center.
  41279. */
  41280. lensCenterOffset: number;
  41281. /**
  41282. * Define if the current vr camera should compensate the distortion of the lense or not.
  41283. */
  41284. compensateDistortion: boolean;
  41285. /**
  41286. * Defines if multiview should be enabled when rendering (Default: false)
  41287. */
  41288. multiviewEnabled: boolean;
  41289. /**
  41290. * Gets the rendering aspect ratio based on the provided resolutions.
  41291. */
  41292. readonly aspectRatio: number;
  41293. /**
  41294. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41295. */
  41296. readonly aspectRatioFov: number;
  41297. /**
  41298. * @hidden
  41299. */
  41300. readonly leftHMatrix: Matrix;
  41301. /**
  41302. * @hidden
  41303. */
  41304. readonly rightHMatrix: Matrix;
  41305. /**
  41306. * @hidden
  41307. */
  41308. readonly leftPreViewMatrix: Matrix;
  41309. /**
  41310. * @hidden
  41311. */
  41312. readonly rightPreViewMatrix: Matrix;
  41313. /**
  41314. * Get the default VRMetrics based on the most generic setup.
  41315. * @returns the default vr metrics
  41316. */
  41317. static GetDefault(): VRCameraMetrics;
  41318. }
  41319. }
  41320. declare module BABYLON {
  41321. /** @hidden */
  41322. export var vrDistortionCorrectionPixelShader: {
  41323. name: string;
  41324. shader: string;
  41325. };
  41326. }
  41327. declare module BABYLON {
  41328. /**
  41329. * VRDistortionCorrectionPostProcess used for mobile VR
  41330. */
  41331. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41332. private _isRightEye;
  41333. private _distortionFactors;
  41334. private _postProcessScaleFactor;
  41335. private _lensCenterOffset;
  41336. private _scaleIn;
  41337. private _scaleFactor;
  41338. private _lensCenter;
  41339. /**
  41340. * Initializes the VRDistortionCorrectionPostProcess
  41341. * @param name The name of the effect.
  41342. * @param camera The camera to apply the render pass to.
  41343. * @param isRightEye If this is for the right eye distortion
  41344. * @param vrMetrics All the required metrics for the VR camera
  41345. */
  41346. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41347. }
  41348. }
  41349. declare module BABYLON {
  41350. /**
  41351. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41352. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41353. */
  41354. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41355. /**
  41356. * Creates a new VRDeviceOrientationArcRotateCamera
  41357. * @param name defines camera name
  41358. * @param alpha defines the camera rotation along the logitudinal axis
  41359. * @param beta defines the camera rotation along the latitudinal axis
  41360. * @param radius defines the camera distance from its target
  41361. * @param target defines the camera target
  41362. * @param scene defines the scene the camera belongs to
  41363. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41364. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41365. */
  41366. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41367. /**
  41368. * Gets camera class name
  41369. * @returns VRDeviceOrientationArcRotateCamera
  41370. */
  41371. getClassName(): string;
  41372. }
  41373. }
  41374. declare module BABYLON {
  41375. /**
  41376. * Camera used to simulate VR rendering (based on FreeCamera)
  41377. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41378. */
  41379. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41380. /**
  41381. * Creates a new VRDeviceOrientationFreeCamera
  41382. * @param name defines camera name
  41383. * @param position defines the start position of the camera
  41384. * @param scene defines the scene the camera belongs to
  41385. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41386. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41387. */
  41388. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41389. /**
  41390. * Gets camera class name
  41391. * @returns VRDeviceOrientationFreeCamera
  41392. */
  41393. getClassName(): string;
  41394. }
  41395. }
  41396. declare module BABYLON {
  41397. /**
  41398. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41399. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41400. */
  41401. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41402. /**
  41403. * Creates a new VRDeviceOrientationGamepadCamera
  41404. * @param name defines camera name
  41405. * @param position defines the start position of the camera
  41406. * @param scene defines the scene the camera belongs to
  41407. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41408. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41409. */
  41410. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41411. /**
  41412. * Gets camera class name
  41413. * @returns VRDeviceOrientationGamepadCamera
  41414. */
  41415. getClassName(): string;
  41416. }
  41417. }
  41418. declare module BABYLON {
  41419. /** @hidden */
  41420. export var imageProcessingPixelShader: {
  41421. name: string;
  41422. shader: string;
  41423. };
  41424. }
  41425. declare module BABYLON {
  41426. /**
  41427. * ImageProcessingPostProcess
  41428. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41429. */
  41430. export class ImageProcessingPostProcess extends PostProcess {
  41431. /**
  41432. * Default configuration related to image processing available in the PBR Material.
  41433. */
  41434. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41435. /**
  41436. * Gets the image processing configuration used either in this material.
  41437. */
  41438. /**
  41439. * Sets the Default image processing configuration used either in the this material.
  41440. *
  41441. * If sets to null, the scene one is in use.
  41442. */
  41443. imageProcessingConfiguration: ImageProcessingConfiguration;
  41444. /**
  41445. * Keep track of the image processing observer to allow dispose and replace.
  41446. */
  41447. private _imageProcessingObserver;
  41448. /**
  41449. * Attaches a new image processing configuration to the PBR Material.
  41450. * @param configuration
  41451. */
  41452. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41453. /**
  41454. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41455. */
  41456. /**
  41457. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41458. */
  41459. colorCurves: Nullable<ColorCurves>;
  41460. /**
  41461. * Gets wether the color curves effect is enabled.
  41462. */
  41463. /**
  41464. * Sets wether the color curves effect is enabled.
  41465. */
  41466. colorCurvesEnabled: boolean;
  41467. /**
  41468. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41469. */
  41470. /**
  41471. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41472. */
  41473. colorGradingTexture: Nullable<BaseTexture>;
  41474. /**
  41475. * Gets wether the color grading effect is enabled.
  41476. */
  41477. /**
  41478. * Gets wether the color grading effect is enabled.
  41479. */
  41480. colorGradingEnabled: boolean;
  41481. /**
  41482. * Gets exposure used in the effect.
  41483. */
  41484. /**
  41485. * Sets exposure used in the effect.
  41486. */
  41487. exposure: number;
  41488. /**
  41489. * Gets wether tonemapping is enabled or not.
  41490. */
  41491. /**
  41492. * Sets wether tonemapping is enabled or not
  41493. */
  41494. toneMappingEnabled: boolean;
  41495. /**
  41496. * Gets the type of tone mapping effect.
  41497. */
  41498. /**
  41499. * Sets the type of tone mapping effect.
  41500. */
  41501. toneMappingType: number;
  41502. /**
  41503. * Gets contrast used in the effect.
  41504. */
  41505. /**
  41506. * Sets contrast used in the effect.
  41507. */
  41508. contrast: number;
  41509. /**
  41510. * Gets Vignette stretch size.
  41511. */
  41512. /**
  41513. * Sets Vignette stretch size.
  41514. */
  41515. vignetteStretch: number;
  41516. /**
  41517. * Gets Vignette centre X Offset.
  41518. */
  41519. /**
  41520. * Sets Vignette centre X Offset.
  41521. */
  41522. vignetteCentreX: number;
  41523. /**
  41524. * Gets Vignette centre Y Offset.
  41525. */
  41526. /**
  41527. * Sets Vignette centre Y Offset.
  41528. */
  41529. vignetteCentreY: number;
  41530. /**
  41531. * Gets Vignette weight or intensity of the vignette effect.
  41532. */
  41533. /**
  41534. * Sets Vignette weight or intensity of the vignette effect.
  41535. */
  41536. vignetteWeight: number;
  41537. /**
  41538. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41539. * if vignetteEnabled is set to true.
  41540. */
  41541. /**
  41542. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41543. * if vignetteEnabled is set to true.
  41544. */
  41545. vignetteColor: Color4;
  41546. /**
  41547. * Gets Camera field of view used by the Vignette effect.
  41548. */
  41549. /**
  41550. * Sets Camera field of view used by the Vignette effect.
  41551. */
  41552. vignetteCameraFov: number;
  41553. /**
  41554. * Gets the vignette blend mode allowing different kind of effect.
  41555. */
  41556. /**
  41557. * Sets the vignette blend mode allowing different kind of effect.
  41558. */
  41559. vignetteBlendMode: number;
  41560. /**
  41561. * Gets wether the vignette effect is enabled.
  41562. */
  41563. /**
  41564. * Sets wether the vignette effect is enabled.
  41565. */
  41566. vignetteEnabled: boolean;
  41567. private _fromLinearSpace;
  41568. /**
  41569. * Gets wether the input of the processing is in Gamma or Linear Space.
  41570. */
  41571. /**
  41572. * Sets wether the input of the processing is in Gamma or Linear Space.
  41573. */
  41574. fromLinearSpace: boolean;
  41575. /**
  41576. * Defines cache preventing GC.
  41577. */
  41578. private _defines;
  41579. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41580. /**
  41581. * "ImageProcessingPostProcess"
  41582. * @returns "ImageProcessingPostProcess"
  41583. */
  41584. getClassName(): string;
  41585. protected _updateParameters(): void;
  41586. dispose(camera?: Camera): void;
  41587. }
  41588. }
  41589. declare module BABYLON {
  41590. /**
  41591. * Class containing static functions to help procedurally build meshes
  41592. */
  41593. export class GroundBuilder {
  41594. /**
  41595. * Creates a ground mesh
  41596. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41597. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41599. * @param name defines the name of the mesh
  41600. * @param options defines the options used to create the mesh
  41601. * @param scene defines the hosting scene
  41602. * @returns the ground mesh
  41603. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41604. */
  41605. static CreateGround(name: string, options: {
  41606. width?: number;
  41607. height?: number;
  41608. subdivisions?: number;
  41609. subdivisionsX?: number;
  41610. subdivisionsY?: number;
  41611. updatable?: boolean;
  41612. }, scene: any): Mesh;
  41613. /**
  41614. * Creates a tiled ground mesh
  41615. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41616. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41617. * * 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
  41618. * * 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
  41619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41620. * @param name defines the name of the mesh
  41621. * @param options defines the options used to create the mesh
  41622. * @param scene defines the hosting scene
  41623. * @returns the tiled ground mesh
  41624. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41625. */
  41626. static CreateTiledGround(name: string, options: {
  41627. xmin: number;
  41628. zmin: number;
  41629. xmax: number;
  41630. zmax: number;
  41631. subdivisions?: {
  41632. w: number;
  41633. h: number;
  41634. };
  41635. precision?: {
  41636. w: number;
  41637. h: number;
  41638. };
  41639. updatable?: boolean;
  41640. }, scene?: Nullable<Scene>): Mesh;
  41641. /**
  41642. * Creates a ground mesh from a height map
  41643. * * The parameter `url` sets the URL of the height map image resource.
  41644. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41645. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41646. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41647. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41648. * * 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.
  41649. * * 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).
  41650. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41652. * @param name defines the name of the mesh
  41653. * @param url defines the url to the height map
  41654. * @param options defines the options used to create the mesh
  41655. * @param scene defines the hosting scene
  41656. * @returns the ground mesh
  41657. * @see https://doc.babylonjs.com/babylon101/height_map
  41658. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41659. */
  41660. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41661. width?: number;
  41662. height?: number;
  41663. subdivisions?: number;
  41664. minHeight?: number;
  41665. maxHeight?: number;
  41666. colorFilter?: Color3;
  41667. alphaFilter?: number;
  41668. updatable?: boolean;
  41669. onReady?: (mesh: GroundMesh) => void;
  41670. }, scene?: Nullable<Scene>): GroundMesh;
  41671. }
  41672. }
  41673. declare module BABYLON {
  41674. /**
  41675. * Class containing static functions to help procedurally build meshes
  41676. */
  41677. export class TorusBuilder {
  41678. /**
  41679. * Creates a torus mesh
  41680. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41681. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41682. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41684. * * 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
  41685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41686. * @param name defines the name of the mesh
  41687. * @param options defines the options used to create the mesh
  41688. * @param scene defines the hosting scene
  41689. * @returns the torus mesh
  41690. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41691. */
  41692. static CreateTorus(name: string, options: {
  41693. diameter?: number;
  41694. thickness?: number;
  41695. tessellation?: number;
  41696. updatable?: boolean;
  41697. sideOrientation?: number;
  41698. frontUVs?: Vector4;
  41699. backUVs?: Vector4;
  41700. }, scene: any): Mesh;
  41701. }
  41702. }
  41703. declare module BABYLON {
  41704. /**
  41705. * Class containing static functions to help procedurally build meshes
  41706. */
  41707. export class CylinderBuilder {
  41708. /**
  41709. * Creates a cylinder or a cone mesh
  41710. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41711. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41712. * * 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.
  41713. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41714. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41715. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41716. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41717. * * 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).
  41718. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41719. * * 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).
  41720. * * 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
  41721. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41722. * * 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
  41723. * * 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.
  41724. * * If `enclose` is false, a ring surface is one element.
  41725. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41726. * * 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
  41727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41728. * * 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
  41729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41730. * @param name defines the name of the mesh
  41731. * @param options defines the options used to create the mesh
  41732. * @param scene defines the hosting scene
  41733. * @returns the cylinder mesh
  41734. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41735. */
  41736. static CreateCylinder(name: string, options: {
  41737. height?: number;
  41738. diameterTop?: number;
  41739. diameterBottom?: number;
  41740. diameter?: number;
  41741. tessellation?: number;
  41742. subdivisions?: number;
  41743. arc?: number;
  41744. faceColors?: Color4[];
  41745. faceUV?: Vector4[];
  41746. updatable?: boolean;
  41747. hasRings?: boolean;
  41748. enclose?: boolean;
  41749. cap?: number;
  41750. sideOrientation?: number;
  41751. frontUVs?: Vector4;
  41752. backUVs?: Vector4;
  41753. }, scene: any): Mesh;
  41754. }
  41755. }
  41756. declare module BABYLON {
  41757. /**
  41758. * States of the webXR experience
  41759. */
  41760. export enum WebXRState {
  41761. /**
  41762. * Transitioning to being in XR mode
  41763. */
  41764. ENTERING_XR = 0,
  41765. /**
  41766. * Transitioning to non XR mode
  41767. */
  41768. EXITING_XR = 1,
  41769. /**
  41770. * In XR mode and presenting
  41771. */
  41772. IN_XR = 2,
  41773. /**
  41774. * Not entered XR mode
  41775. */
  41776. NOT_IN_XR = 3
  41777. }
  41778. /**
  41779. * Abstraction of the XR render target
  41780. */
  41781. export interface WebXRRenderTarget extends IDisposable {
  41782. /**
  41783. * xrpresent context of the canvas which can be used to display/mirror xr content
  41784. */
  41785. canvasContext: WebGLRenderingContext;
  41786. /**
  41787. * xr layer for the canvas
  41788. */
  41789. xrLayer: Nullable<XRWebGLLayer>;
  41790. /**
  41791. * Initializes the xr layer for the session
  41792. * @param xrSession xr session
  41793. * @returns a promise that will resolve once the XR Layer has been created
  41794. */
  41795. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  41796. }
  41797. }
  41798. declare module BABYLON {
  41799. /**
  41800. * COnfiguration object for WebXR output canvas
  41801. */
  41802. export class WebXRManagedOutputCanvasOptions {
  41803. /**
  41804. * Options for this XR Layer output
  41805. */
  41806. canvasOptions: XRWebGLLayerOptions;
  41807. /**
  41808. * CSS styling for a newly created canvas (if not provided)
  41809. */
  41810. newCanvasCssStyle?: string;
  41811. /**
  41812. * Get the default values of the configuration object
  41813. * @returns default values of this configuration object
  41814. */
  41815. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  41816. }
  41817. /**
  41818. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41819. */
  41820. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  41821. private configuration;
  41822. private _engine;
  41823. private _canvas;
  41824. /**
  41825. * xrpresent context of the canvas which can be used to display/mirror xr content
  41826. */
  41827. canvasContext: WebGLRenderingContext;
  41828. /**
  41829. * xr layer for the canvas
  41830. */
  41831. xrLayer: Nullable<XRWebGLLayer>;
  41832. /**
  41833. * Initializes the xr layer for the session
  41834. * @param xrSession xr session
  41835. * @returns a promise that will resolve once the XR Layer has been created
  41836. */
  41837. initializeXRLayerAsync(xrSession: any): any;
  41838. /**
  41839. * Initializes the canvas to be added/removed upon entering/exiting xr
  41840. * @param engine the Babylon engine
  41841. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41842. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  41843. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  41844. */
  41845. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  41846. /**
  41847. * Disposes of the object
  41848. */
  41849. dispose(): void;
  41850. private _setManagedOutputCanvas;
  41851. private _addCanvas;
  41852. private _removeCanvas;
  41853. }
  41854. }
  41855. declare module BABYLON {
  41856. /**
  41857. * Manages an XRSession to work with Babylon's engine
  41858. * @see https://doc.babylonjs.com/how_to/webxr
  41859. */
  41860. export class WebXRSessionManager implements IDisposable {
  41861. /** The scene which the session should be created for */
  41862. scene: Scene;
  41863. /**
  41864. * Fires every time a new xrFrame arrives which can be used to update the camera
  41865. */
  41866. onXRFrameObservable: Observable<XRFrame>;
  41867. /**
  41868. * Fires when the xr session is ended either by the device or manually done
  41869. */
  41870. onXRSessionEnded: Observable<any>;
  41871. /**
  41872. * Fires when the xr session is ended either by the device or manually done
  41873. */
  41874. onXRSessionInit: Observable<XRSession>;
  41875. /**
  41876. * Underlying xr session
  41877. */
  41878. session: XRSession;
  41879. /**
  41880. * Type of reference space used when creating the session
  41881. */
  41882. referenceSpace: XRReferenceSpace;
  41883. /**
  41884. * Current XR frame
  41885. */
  41886. currentFrame: Nullable<XRFrame>;
  41887. /** WebXR timestamp updated every frame */
  41888. currentTimestamp: number;
  41889. private _xrNavigator;
  41890. private baseLayer;
  41891. private _rttProvider;
  41892. private _sessionEnded;
  41893. /**
  41894. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41895. * @param scene The scene which the session should be created for
  41896. */
  41897. constructor(
  41898. /** The scene which the session should be created for */
  41899. scene: Scene);
  41900. /**
  41901. * Initializes the manager
  41902. * After initialization enterXR can be called to start an XR session
  41903. * @returns Promise which resolves after it is initialized
  41904. */
  41905. initializeAsync(): Promise<void>;
  41906. /**
  41907. * Initializes an xr session
  41908. * @param xrSessionMode mode to initialize
  41909. * @param optionalFeatures defines optional values to pass to the session builder
  41910. * @returns a promise which will resolve once the session has been initialized
  41911. */
  41912. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  41913. /**
  41914. * Sets the reference space on the xr session
  41915. * @param referenceSpace space to set
  41916. * @returns a promise that will resolve once the reference space has been set
  41917. */
  41918. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41919. /**
  41920. * Updates the render state of the session
  41921. * @param state state to set
  41922. * @returns a promise that resolves once the render state has been updated
  41923. */
  41924. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41925. /**
  41926. * Starts rendering to the xr layer
  41927. * @returns a promise that will resolve once rendering has started
  41928. */
  41929. startRenderingToXRAsync(): Promise<void>;
  41930. /**
  41931. * Gets the correct render target texture to be rendered this frame for this eye
  41932. * @param eye the eye for which to get the render target
  41933. * @returns the render target for the specified eye
  41934. */
  41935. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  41936. /**
  41937. * Stops the xrSession and restores the renderloop
  41938. * @returns Promise which resolves after it exits XR
  41939. */
  41940. exitXRAsync(): Promise<void>;
  41941. /**
  41942. * Checks if a session would be supported for the creation options specified
  41943. * @param sessionMode session mode to check if supported eg. immersive-vr
  41944. * @returns true if supported
  41945. */
  41946. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  41947. /**
  41948. * Creates a WebXRRenderTarget object for the XR session
  41949. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  41950. * @param options optional options to provide when creating a new render target
  41951. * @returns a WebXR render target to which the session can render
  41952. */
  41953. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  41954. /**
  41955. * @hidden
  41956. * Converts the render layer of xrSession to a render target
  41957. * @param session session to create render target for
  41958. * @param scene scene the new render target should be created for
  41959. * @param baseLayer the webgl layer to create the render target for
  41960. */
  41961. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41962. /**
  41963. * Disposes of the session manager
  41964. */
  41965. dispose(): void;
  41966. /**
  41967. * Gets a promise returning true when fullfiled if the given session mode is supported
  41968. * @param sessionMode defines the session to test
  41969. * @returns a promise
  41970. */
  41971. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  41972. }
  41973. }
  41974. declare module BABYLON {
  41975. /**
  41976. * WebXR Camera which holds the views for the xrSession
  41977. * @see https://doc.babylonjs.com/how_to/webxr
  41978. */
  41979. export class WebXRCamera extends FreeCamera {
  41980. /**
  41981. * Is the camera in debug mode. Used when using an emulator
  41982. */
  41983. debugMode: boolean;
  41984. /**
  41985. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41986. * @param name the name of the camera
  41987. * @param scene the scene to add the camera to
  41988. */
  41989. constructor(name: string, scene: Scene);
  41990. private _updateNumberOfRigCameras;
  41991. /** @hidden */
  41992. _updateForDualEyeDebugging(): void;
  41993. /**
  41994. * Updates the cameras position from the current pose information of the XR session
  41995. * @param xrSessionManager the session containing pose information
  41996. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41997. */
  41998. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41999. }
  42000. }
  42001. declare module BABYLON {
  42002. /**
  42003. * Defining the interface required for a (webxr) feature
  42004. */
  42005. export interface IWebXRFeature extends IDisposable {
  42006. /**
  42007. * Attach the feature to the session
  42008. * Will usually be called by the features manager
  42009. *
  42010. * @returns true if successful.
  42011. */
  42012. attach(): boolean;
  42013. /**
  42014. * Detach the feature from the session
  42015. * Will usually be called by the features manager
  42016. *
  42017. * @returns true if successful.
  42018. */
  42019. detach(): boolean;
  42020. }
  42021. /**
  42022. * Defining the constructor of a feature. Used to register the modules.
  42023. */
  42024. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42025. /**
  42026. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42027. * It is mainly used in AR sessions.
  42028. *
  42029. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42030. */
  42031. export class WebXRFeaturesManager implements IDisposable {
  42032. private _xrSessionManager;
  42033. private static readonly _AvailableFeatures;
  42034. /**
  42035. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42036. * Mainly used internally.
  42037. *
  42038. * @param featureName the name of the feature to register
  42039. * @param constructorFunction the function used to construct the module
  42040. * @param version the (babylon) version of the module
  42041. * @param stable is that a stable version of this module
  42042. */
  42043. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42044. /**
  42045. * Returns a constructor of a specific feature.
  42046. *
  42047. * @param featureName the name of the feature to construct
  42048. * @param version the version of the feature to load
  42049. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42050. * @param options optional options provided to the module.
  42051. * @returns a function that, when called, will return a new instance of this feature
  42052. */
  42053. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42054. /**
  42055. * Return the latest unstable version of this feature
  42056. * @param featureName the name of the feature to search
  42057. * @returns the version number. if not found will return -1
  42058. */
  42059. static GetLatestVersionOfFeature(featureName: string): number;
  42060. /**
  42061. * Return the latest stable version of this feature
  42062. * @param featureName the name of the feature to search
  42063. * @returns the version number. if not found will return -1
  42064. */
  42065. static GetStableVersionOfFeature(featureName: string): number;
  42066. /**
  42067. * Can be used to return the list of features currently registered
  42068. *
  42069. * @returns an Array of available features
  42070. */
  42071. static GetAvailableFeatures(): string[];
  42072. /**
  42073. * Gets the versions available for a specific feature
  42074. * @param featureName the name of the feature
  42075. * @returns an array with the available versions
  42076. */
  42077. static GetAvailableVersions(featureName: string): string[];
  42078. private _features;
  42079. /**
  42080. * constructs a new features manages.
  42081. *
  42082. * @param _xrSessionManager an instance of WebXRSessionManager
  42083. */
  42084. constructor(_xrSessionManager: WebXRSessionManager);
  42085. /**
  42086. * 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.
  42087. *
  42088. * @param featureName the name of the feature to load or the class of the feature
  42089. * @param version optional version to load. if not provided the latest version will be enabled
  42090. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42091. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42092. * @returns a new constructed feature or throws an error if feature not found.
  42093. */
  42094. enableFeature(featureName: string | {
  42095. Name: string;
  42096. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42097. /**
  42098. * Used to disable an already-enabled feature
  42099. * @param featureName the feature to disable
  42100. * @returns true if disable was successful
  42101. */
  42102. disableFeature(featureName: string | {
  42103. Name: string;
  42104. }): boolean;
  42105. /**
  42106. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42107. * Can be used during a session to start a feature
  42108. * @param featureName the name of feature to attach
  42109. */
  42110. attachFeature(featureName: string): void;
  42111. /**
  42112. * Can be used inside a session or when the session ends to detach a specific feature
  42113. * @param featureName the name of the feature to detach
  42114. */
  42115. detachFeature(featureName: string): void;
  42116. /**
  42117. * Get the list of enabled features
  42118. * @returns an array of enabled features
  42119. */
  42120. getEnabledFeatures(): string[];
  42121. /**
  42122. * get the implementation of an enabled feature.
  42123. * @param featureName the name of the feature to load
  42124. * @returns the feature class, if found
  42125. */
  42126. getEnabledFeature(featureName: string): IWebXRFeature;
  42127. /**
  42128. * dispose this features manager
  42129. */
  42130. dispose(): void;
  42131. }
  42132. }
  42133. declare module BABYLON {
  42134. /**
  42135. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42136. * @see https://doc.babylonjs.com/how_to/webxr
  42137. */
  42138. export class WebXRExperienceHelper implements IDisposable {
  42139. private scene;
  42140. /**
  42141. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  42142. */
  42143. container: AbstractMesh;
  42144. /**
  42145. * Camera used to render xr content
  42146. */
  42147. camera: WebXRCamera;
  42148. /**
  42149. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42150. */
  42151. state: WebXRState;
  42152. private _setState;
  42153. private static _TmpVector;
  42154. /**
  42155. * Fires when the state of the experience helper has changed
  42156. */
  42157. onStateChangedObservable: Observable<WebXRState>;
  42158. /** Session manager used to keep track of xr session */
  42159. sessionManager: WebXRSessionManager;
  42160. /** A features manager for this xr session */
  42161. featuresManager: WebXRFeaturesManager;
  42162. private _nonVRCamera;
  42163. private _originalSceneAutoClear;
  42164. private _supported;
  42165. /**
  42166. * Creates the experience helper
  42167. * @param scene the scene to attach the experience helper to
  42168. * @returns a promise for the experience helper
  42169. */
  42170. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42171. /**
  42172. * Creates a WebXRExperienceHelper
  42173. * @param scene The scene the helper should be created in
  42174. */
  42175. private constructor();
  42176. /**
  42177. * Exits XR mode and returns the scene to its original state
  42178. * @returns promise that resolves after xr mode has exited
  42179. */
  42180. exitXRAsync(): Promise<void>;
  42181. /**
  42182. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42183. * @param sessionMode options for the XR session
  42184. * @param referenceSpaceType frame of reference of the XR session
  42185. * @param renderTarget the output canvas that will be used to enter XR mode
  42186. * @returns promise that resolves after xr mode has entered
  42187. */
  42188. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42189. /**
  42190. * Updates the global position of the camera by moving the camera's container
  42191. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42192. * @param position The desired global position of the camera
  42193. */
  42194. setPositionOfCameraUsingContainer(position: Vector3): void;
  42195. /**
  42196. * Rotates the xr camera by rotating the camera's container around the camera's position
  42197. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42198. * @param rotation the desired quaternion rotation to apply to the camera
  42199. */
  42200. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42201. /**
  42202. * Disposes of the experience helper
  42203. */
  42204. dispose(): void;
  42205. }
  42206. }
  42207. declare module BABYLON {
  42208. /**
  42209. * Represents an XR input
  42210. */
  42211. export class WebXRController {
  42212. private scene;
  42213. /** The underlying input source for the controller */
  42214. inputSource: XRInputSource;
  42215. private parentContainer;
  42216. /**
  42217. * 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
  42218. */
  42219. grip?: AbstractMesh;
  42220. /**
  42221. * Pointer which can be used to select objects or attach a visible laser to
  42222. */
  42223. pointer: AbstractMesh;
  42224. private _gamepadMode;
  42225. /**
  42226. * If available, this is the gamepad object related to this controller.
  42227. * Using this object it is possible to get click events and trackpad changes of the
  42228. * webxr controller that is currently being used.
  42229. */
  42230. gamepadController?: WebVRController;
  42231. /**
  42232. * Event that fires when the controller is removed/disposed
  42233. */
  42234. onDisposeObservable: Observable<{}>;
  42235. private _tmpQuaternion;
  42236. private _tmpVector;
  42237. /**
  42238. * Creates the controller
  42239. * @see https://doc.babylonjs.com/how_to/webxr
  42240. * @param scene the scene which the controller should be associated to
  42241. * @param inputSource the underlying input source for the controller
  42242. * @param parentContainer parent that the controller meshes should be children of
  42243. */
  42244. constructor(scene: Scene,
  42245. /** The underlying input source for the controller */
  42246. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42247. /**
  42248. * Updates the controller pose based on the given XRFrame
  42249. * @param xrFrame xr frame to update the pose with
  42250. * @param referenceSpace reference space to use
  42251. */
  42252. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42253. /**
  42254. * Gets a world space ray coming from the controller
  42255. * @param result the resulting ray
  42256. */
  42257. getWorldPointerRayToRef(result: Ray): void;
  42258. /**
  42259. * Get the scene associated with this controller
  42260. * @returns the scene object
  42261. */
  42262. getScene(): Scene;
  42263. /**
  42264. * Disposes of the object
  42265. */
  42266. dispose(): void;
  42267. }
  42268. }
  42269. declare module BABYLON {
  42270. /**
  42271. * XR input used to track XR inputs such as controllers/rays
  42272. */
  42273. export class WebXRInput implements IDisposable {
  42274. /**
  42275. * Base experience the input listens to
  42276. */
  42277. baseExperience: WebXRExperienceHelper;
  42278. /**
  42279. * XR controllers being tracked
  42280. */
  42281. controllers: Array<WebXRController>;
  42282. private _frameObserver;
  42283. private _stateObserver;
  42284. /**
  42285. * Event when a controller has been connected/added
  42286. */
  42287. onControllerAddedObservable: Observable<WebXRController>;
  42288. /**
  42289. * Event when a controller has been removed/disconnected
  42290. */
  42291. onControllerRemovedObservable: Observable<WebXRController>;
  42292. /**
  42293. * Initializes the WebXRInput
  42294. * @param baseExperience experience helper which the input should be created for
  42295. */
  42296. constructor(
  42297. /**
  42298. * Base experience the input listens to
  42299. */
  42300. baseExperience: WebXRExperienceHelper);
  42301. private _onInputSourcesChange;
  42302. private _addAndRemoveControllers;
  42303. /**
  42304. * Disposes of the object
  42305. */
  42306. dispose(): void;
  42307. }
  42308. }
  42309. declare module BABYLON {
  42310. /**
  42311. * Class used to represent data loading progression
  42312. */
  42313. export class SceneLoaderProgressEvent {
  42314. /** defines if data length to load can be evaluated */
  42315. readonly lengthComputable: boolean;
  42316. /** defines the loaded data length */
  42317. readonly loaded: number;
  42318. /** defines the data length to load */
  42319. readonly total: number;
  42320. /**
  42321. * Create a new progress event
  42322. * @param lengthComputable defines if data length to load can be evaluated
  42323. * @param loaded defines the loaded data length
  42324. * @param total defines the data length to load
  42325. */
  42326. constructor(
  42327. /** defines if data length to load can be evaluated */
  42328. lengthComputable: boolean,
  42329. /** defines the loaded data length */
  42330. loaded: number,
  42331. /** defines the data length to load */
  42332. total: number);
  42333. /**
  42334. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42335. * @param event defines the source event
  42336. * @returns a new SceneLoaderProgressEvent
  42337. */
  42338. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42339. }
  42340. /**
  42341. * Interface used by SceneLoader plugins to define supported file extensions
  42342. */
  42343. export interface ISceneLoaderPluginExtensions {
  42344. /**
  42345. * Defines the list of supported extensions
  42346. */
  42347. [extension: string]: {
  42348. isBinary: boolean;
  42349. };
  42350. }
  42351. /**
  42352. * Interface used by SceneLoader plugin factory
  42353. */
  42354. export interface ISceneLoaderPluginFactory {
  42355. /**
  42356. * Defines the name of the factory
  42357. */
  42358. name: string;
  42359. /**
  42360. * Function called to create a new plugin
  42361. * @return the new plugin
  42362. */
  42363. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42364. /**
  42365. * The callback that returns true if the data can be directly loaded.
  42366. * @param data string containing the file data
  42367. * @returns if the data can be loaded directly
  42368. */
  42369. canDirectLoad?(data: string): boolean;
  42370. }
  42371. /**
  42372. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42373. */
  42374. export interface ISceneLoaderPluginBase {
  42375. /**
  42376. * The friendly name of this plugin.
  42377. */
  42378. name: string;
  42379. /**
  42380. * The file extensions supported by this plugin.
  42381. */
  42382. extensions: string | ISceneLoaderPluginExtensions;
  42383. /**
  42384. * The callback called when loading from a url.
  42385. * @param scene scene loading this url
  42386. * @param url url to load
  42387. * @param onSuccess callback called when the file successfully loads
  42388. * @param onProgress callback called while file is loading (if the server supports this mode)
  42389. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42390. * @param onError callback called when the file fails to load
  42391. * @returns a file request object
  42392. */
  42393. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42394. /**
  42395. * The callback called when loading from a file object.
  42396. * @param scene scene loading this file
  42397. * @param file defines the file to load
  42398. * @param onSuccess defines the callback to call when data is loaded
  42399. * @param onProgress defines the callback to call during loading process
  42400. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42401. * @param onError defines the callback to call when an error occurs
  42402. * @returns a file request object
  42403. */
  42404. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42405. /**
  42406. * The callback that returns true if the data can be directly loaded.
  42407. * @param data string containing the file data
  42408. * @returns if the data can be loaded directly
  42409. */
  42410. canDirectLoad?(data: string): boolean;
  42411. /**
  42412. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42413. * @param scene scene loading this data
  42414. * @param data string containing the data
  42415. * @returns data to pass to the plugin
  42416. */
  42417. directLoad?(scene: Scene, data: string): any;
  42418. /**
  42419. * The callback that allows custom handling of the root url based on the response url.
  42420. * @param rootUrl the original root url
  42421. * @param responseURL the response url if available
  42422. * @returns the new root url
  42423. */
  42424. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42425. }
  42426. /**
  42427. * Interface used to define a SceneLoader plugin
  42428. */
  42429. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42430. /**
  42431. * Import meshes into a scene.
  42432. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42433. * @param scene The scene to import into
  42434. * @param data The data to import
  42435. * @param rootUrl The root url for scene and resources
  42436. * @param meshes The meshes array to import into
  42437. * @param particleSystems The particle systems array to import into
  42438. * @param skeletons The skeletons array to import into
  42439. * @param onError The callback when import fails
  42440. * @returns True if successful or false otherwise
  42441. */
  42442. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42443. /**
  42444. * Load into a scene.
  42445. * @param scene The scene to load into
  42446. * @param data The data to import
  42447. * @param rootUrl The root url for scene and resources
  42448. * @param onError The callback when import fails
  42449. * @returns True if successful or false otherwise
  42450. */
  42451. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42452. /**
  42453. * Load into an asset container.
  42454. * @param scene The scene to load into
  42455. * @param data The data to import
  42456. * @param rootUrl The root url for scene and resources
  42457. * @param onError The callback when import fails
  42458. * @returns The loaded asset container
  42459. */
  42460. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42461. }
  42462. /**
  42463. * Interface used to define an async SceneLoader plugin
  42464. */
  42465. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42466. /**
  42467. * Import meshes into a scene.
  42468. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42469. * @param scene The scene to import into
  42470. * @param data The data to import
  42471. * @param rootUrl The root url for scene and resources
  42472. * @param onProgress The callback when the load progresses
  42473. * @param fileName Defines the name of the file to load
  42474. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42475. */
  42476. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42477. meshes: AbstractMesh[];
  42478. particleSystems: IParticleSystem[];
  42479. skeletons: Skeleton[];
  42480. animationGroups: AnimationGroup[];
  42481. }>;
  42482. /**
  42483. * Load into a scene.
  42484. * @param scene The scene to load into
  42485. * @param data The data to import
  42486. * @param rootUrl The root url for scene and resources
  42487. * @param onProgress The callback when the load progresses
  42488. * @param fileName Defines the name of the file to load
  42489. * @returns Nothing
  42490. */
  42491. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42492. /**
  42493. * Load into an asset container.
  42494. * @param scene The scene to load into
  42495. * @param data The data to import
  42496. * @param rootUrl The root url for scene and resources
  42497. * @param onProgress The callback when the load progresses
  42498. * @param fileName Defines the name of the file to load
  42499. * @returns The loaded asset container
  42500. */
  42501. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42502. }
  42503. /**
  42504. * Mode that determines how to handle old animation groups before loading new ones.
  42505. */
  42506. export enum SceneLoaderAnimationGroupLoadingMode {
  42507. /**
  42508. * Reset all old animations to initial state then dispose them.
  42509. */
  42510. Clean = 0,
  42511. /**
  42512. * Stop all old animations.
  42513. */
  42514. Stop = 1,
  42515. /**
  42516. * Restart old animations from first frame.
  42517. */
  42518. Sync = 2,
  42519. /**
  42520. * Old animations remains untouched.
  42521. */
  42522. NoSync = 3
  42523. }
  42524. /**
  42525. * Class used to load scene from various file formats using registered plugins
  42526. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42527. */
  42528. export class SceneLoader {
  42529. /**
  42530. * No logging while loading
  42531. */
  42532. static readonly NO_LOGGING: number;
  42533. /**
  42534. * Minimal logging while loading
  42535. */
  42536. static readonly MINIMAL_LOGGING: number;
  42537. /**
  42538. * Summary logging while loading
  42539. */
  42540. static readonly SUMMARY_LOGGING: number;
  42541. /**
  42542. * Detailled logging while loading
  42543. */
  42544. static readonly DETAILED_LOGGING: number;
  42545. /**
  42546. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42547. */
  42548. static ForceFullSceneLoadingForIncremental: boolean;
  42549. /**
  42550. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42551. */
  42552. static ShowLoadingScreen: boolean;
  42553. /**
  42554. * Defines the current logging level (while loading the scene)
  42555. * @ignorenaming
  42556. */
  42557. static loggingLevel: number;
  42558. /**
  42559. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42560. */
  42561. static CleanBoneMatrixWeights: boolean;
  42562. /**
  42563. * Event raised when a plugin is used to load a scene
  42564. */
  42565. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42566. private static _registeredPlugins;
  42567. private static _getDefaultPlugin;
  42568. private static _getPluginForExtension;
  42569. private static _getPluginForDirectLoad;
  42570. private static _getPluginForFilename;
  42571. private static _getDirectLoad;
  42572. private static _loadData;
  42573. private static _getFileInfo;
  42574. /**
  42575. * Gets a plugin that can load the given extension
  42576. * @param extension defines the extension to load
  42577. * @returns a plugin or null if none works
  42578. */
  42579. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42580. /**
  42581. * Gets a boolean indicating that the given extension can be loaded
  42582. * @param extension defines the extension to load
  42583. * @returns true if the extension is supported
  42584. */
  42585. static IsPluginForExtensionAvailable(extension: string): boolean;
  42586. /**
  42587. * Adds a new plugin to the list of registered plugins
  42588. * @param plugin defines the plugin to add
  42589. */
  42590. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42591. /**
  42592. * Import meshes into a scene
  42593. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42594. * @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)
  42595. * @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)
  42596. * @param scene the instance of BABYLON.Scene to append to
  42597. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42598. * @param onProgress a callback with a progress event for each file being loaded
  42599. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42600. * @param pluginExtension the extension used to determine the plugin
  42601. * @returns The loaded plugin
  42602. */
  42603. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42604. /**
  42605. * Import meshes into a scene
  42606. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42607. * @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)
  42608. * @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)
  42609. * @param scene the instance of BABYLON.Scene to append to
  42610. * @param onProgress a callback with a progress event for each file being loaded
  42611. * @param pluginExtension the extension used to determine the plugin
  42612. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42613. */
  42614. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42615. meshes: AbstractMesh[];
  42616. particleSystems: IParticleSystem[];
  42617. skeletons: Skeleton[];
  42618. animationGroups: AnimationGroup[];
  42619. }>;
  42620. /**
  42621. * Load a scene
  42622. * @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)
  42623. * @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)
  42624. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42625. * @param onSuccess a callback with the scene when import succeeds
  42626. * @param onProgress a callback with a progress event for each file being loaded
  42627. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42628. * @param pluginExtension the extension used to determine the plugin
  42629. * @returns The loaded plugin
  42630. */
  42631. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42632. /**
  42633. * Load a scene
  42634. * @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)
  42635. * @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)
  42636. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42637. * @param onProgress a callback with a progress event for each file being loaded
  42638. * @param pluginExtension the extension used to determine the plugin
  42639. * @returns The loaded scene
  42640. */
  42641. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42642. /**
  42643. * Append a scene
  42644. * @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)
  42645. * @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)
  42646. * @param scene is the instance of BABYLON.Scene to append to
  42647. * @param onSuccess a callback with the scene when import succeeds
  42648. * @param onProgress a callback with a progress event for each file being loaded
  42649. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42650. * @param pluginExtension the extension used to determine the plugin
  42651. * @returns The loaded plugin
  42652. */
  42653. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42654. /**
  42655. * Append a scene
  42656. * @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)
  42657. * @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)
  42658. * @param scene is the instance of BABYLON.Scene to append to
  42659. * @param onProgress a callback with a progress event for each file being loaded
  42660. * @param pluginExtension the extension used to determine the plugin
  42661. * @returns The given scene
  42662. */
  42663. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42664. /**
  42665. * Load a scene into an asset container
  42666. * @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)
  42667. * @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)
  42668. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42669. * @param onSuccess a callback with the scene when import succeeds
  42670. * @param onProgress a callback with a progress event for each file being loaded
  42671. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42672. * @param pluginExtension the extension used to determine the plugin
  42673. * @returns The loaded plugin
  42674. */
  42675. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42676. /**
  42677. * Load a scene into an asset container
  42678. * @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)
  42679. * @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)
  42680. * @param scene is the instance of Scene to append to
  42681. * @param onProgress a callback with a progress event for each file being loaded
  42682. * @param pluginExtension the extension used to determine the plugin
  42683. * @returns The loaded asset container
  42684. */
  42685. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42686. /**
  42687. * Import animations from a file into a scene
  42688. * @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)
  42689. * @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)
  42690. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42691. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  42692. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  42693. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  42694. * @param onSuccess a callback with the scene when import succeeds
  42695. * @param onProgress a callback with a progress event for each file being loaded
  42696. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42697. */
  42698. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  42699. /**
  42700. * Import animations from a file into a scene
  42701. * @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)
  42702. * @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)
  42703. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42704. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  42705. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  42706. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  42707. * @param onSuccess a callback with the scene when import succeeds
  42708. * @param onProgress a callback with a progress event for each file being loaded
  42709. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42710. * @returns the updated scene with imported animations
  42711. */
  42712. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  42713. }
  42714. }
  42715. declare module BABYLON {
  42716. /**
  42717. * Generic Controller
  42718. */
  42719. export class GenericController extends WebVRController {
  42720. /**
  42721. * Base Url for the controller model.
  42722. */
  42723. static readonly MODEL_BASE_URL: string;
  42724. /**
  42725. * File name for the controller model.
  42726. */
  42727. static readonly MODEL_FILENAME: string;
  42728. /**
  42729. * Creates a new GenericController from a gamepad
  42730. * @param vrGamepad the gamepad that the controller should be created from
  42731. */
  42732. constructor(vrGamepad: any);
  42733. /**
  42734. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42735. * @param scene scene in which to add meshes
  42736. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42737. */
  42738. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42739. /**
  42740. * Called once for each button that changed state since the last frame
  42741. * @param buttonIdx Which button index changed
  42742. * @param state New state of the button
  42743. * @param changes Which properties on the state changed since last frame
  42744. */
  42745. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42746. }
  42747. }
  42748. declare module BABYLON {
  42749. /**
  42750. * Defines the WindowsMotionController object that the state of the windows motion controller
  42751. */
  42752. export class WindowsMotionController extends WebVRController {
  42753. /**
  42754. * The base url used to load the left and right controller models
  42755. */
  42756. static MODEL_BASE_URL: string;
  42757. /**
  42758. * The name of the left controller model file
  42759. */
  42760. static MODEL_LEFT_FILENAME: string;
  42761. /**
  42762. * The name of the right controller model file
  42763. */
  42764. static MODEL_RIGHT_FILENAME: string;
  42765. /**
  42766. * The controller name prefix for this controller type
  42767. */
  42768. static readonly GAMEPAD_ID_PREFIX: string;
  42769. /**
  42770. * The controller id pattern for this controller type
  42771. */
  42772. private static readonly GAMEPAD_ID_PATTERN;
  42773. private _loadedMeshInfo;
  42774. protected readonly _mapping: {
  42775. buttons: string[];
  42776. buttonMeshNames: {
  42777. 'trigger': string;
  42778. 'menu': string;
  42779. 'grip': string;
  42780. 'thumbstick': string;
  42781. 'trackpad': string;
  42782. };
  42783. buttonObservableNames: {
  42784. 'trigger': string;
  42785. 'menu': string;
  42786. 'grip': string;
  42787. 'thumbstick': string;
  42788. 'trackpad': string;
  42789. };
  42790. axisMeshNames: string[];
  42791. pointingPoseMeshName: string;
  42792. };
  42793. /**
  42794. * Fired when the trackpad on this controller is clicked
  42795. */
  42796. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42797. /**
  42798. * Fired when the trackpad on this controller is modified
  42799. */
  42800. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42801. /**
  42802. * The current x and y values of this controller's trackpad
  42803. */
  42804. trackpad: StickValues;
  42805. /**
  42806. * Creates a new WindowsMotionController from a gamepad
  42807. * @param vrGamepad the gamepad that the controller should be created from
  42808. */
  42809. constructor(vrGamepad: any);
  42810. /**
  42811. * Fired when the trigger on this controller is modified
  42812. */
  42813. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42814. /**
  42815. * Fired when the menu button on this controller is modified
  42816. */
  42817. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42818. /**
  42819. * Fired when the grip button on this controller is modified
  42820. */
  42821. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42822. /**
  42823. * Fired when the thumbstick button on this controller is modified
  42824. */
  42825. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42826. /**
  42827. * Fired when the touchpad button on this controller is modified
  42828. */
  42829. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42830. /**
  42831. * Fired when the touchpad values on this controller are modified
  42832. */
  42833. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42834. protected _updateTrackpad(): void;
  42835. /**
  42836. * Called once per frame by the engine.
  42837. */
  42838. update(): void;
  42839. /**
  42840. * Called once for each button that changed state since the last frame
  42841. * @param buttonIdx Which button index changed
  42842. * @param state New state of the button
  42843. * @param changes Which properties on the state changed since last frame
  42844. */
  42845. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42846. /**
  42847. * Moves the buttons on the controller mesh based on their current state
  42848. * @param buttonName the name of the button to move
  42849. * @param buttonValue the value of the button which determines the buttons new position
  42850. */
  42851. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42852. /**
  42853. * Moves the axis on the controller mesh based on its current state
  42854. * @param axis the index of the axis
  42855. * @param axisValue the value of the axis which determines the meshes new position
  42856. * @hidden
  42857. */
  42858. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42859. /**
  42860. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42861. * @param scene scene in which to add meshes
  42862. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42863. */
  42864. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42865. /**
  42866. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42867. * can be transformed by button presses and axes values, based on this._mapping.
  42868. *
  42869. * @param scene scene in which the meshes exist
  42870. * @param meshes list of meshes that make up the controller model to process
  42871. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42872. */
  42873. private processModel;
  42874. private createMeshInfo;
  42875. /**
  42876. * Gets the ray of the controller in the direction the controller is pointing
  42877. * @param length the length the resulting ray should be
  42878. * @returns a ray in the direction the controller is pointing
  42879. */
  42880. getForwardRay(length?: number): Ray;
  42881. /**
  42882. * Disposes of the controller
  42883. */
  42884. dispose(): void;
  42885. }
  42886. /**
  42887. * This class represents a new windows motion controller in XR.
  42888. */
  42889. export class XRWindowsMotionController extends WindowsMotionController {
  42890. /**
  42891. * Changing the original WIndowsMotionController mapping to fir the new mapping
  42892. */
  42893. protected readonly _mapping: {
  42894. buttons: string[];
  42895. buttonMeshNames: {
  42896. 'trigger': string;
  42897. 'menu': string;
  42898. 'grip': string;
  42899. 'thumbstick': string;
  42900. 'trackpad': string;
  42901. };
  42902. buttonObservableNames: {
  42903. 'trigger': string;
  42904. 'menu': string;
  42905. 'grip': string;
  42906. 'thumbstick': string;
  42907. 'trackpad': string;
  42908. };
  42909. axisMeshNames: string[];
  42910. pointingPoseMeshName: string;
  42911. };
  42912. /**
  42913. * Construct a new XR-Based windows motion controller
  42914. *
  42915. * @param gamepadInfo the gamepad object from the browser
  42916. */
  42917. constructor(gamepadInfo: any);
  42918. /**
  42919. * holds the thumbstick values (X,Y)
  42920. */
  42921. thumbstickValues: StickValues;
  42922. /**
  42923. * Fired when the thumbstick on this controller is clicked
  42924. */
  42925. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  42926. /**
  42927. * Fired when the thumbstick on this controller is modified
  42928. */
  42929. onThumbstickValuesChangedObservable: Observable<StickValues>;
  42930. /**
  42931. * Fired when the touchpad button on this controller is modified
  42932. */
  42933. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42934. /**
  42935. * Fired when the touchpad values on this controller are modified
  42936. */
  42937. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42938. /**
  42939. * Fired when the thumbstick button on this controller is modified
  42940. * here to prevent breaking changes
  42941. */
  42942. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42943. /**
  42944. * updating the thumbstick(!) and not the trackpad.
  42945. * This is named this way due to the difference between WebVR and XR and to avoid
  42946. * changing the parent class.
  42947. */
  42948. protected _updateTrackpad(): void;
  42949. /**
  42950. * Disposes the class with joy
  42951. */
  42952. dispose(): void;
  42953. }
  42954. }
  42955. declare module BABYLON {
  42956. /**
  42957. * Oculus Touch Controller
  42958. */
  42959. export class OculusTouchController extends WebVRController {
  42960. /**
  42961. * Base Url for the controller model.
  42962. */
  42963. static MODEL_BASE_URL: string;
  42964. /**
  42965. * File name for the left controller model.
  42966. */
  42967. static MODEL_LEFT_FILENAME: string;
  42968. /**
  42969. * File name for the right controller model.
  42970. */
  42971. static MODEL_RIGHT_FILENAME: string;
  42972. /**
  42973. * Base Url for the Quest controller model.
  42974. */
  42975. static QUEST_MODEL_BASE_URL: string;
  42976. /**
  42977. * @hidden
  42978. * If the controllers are running on a device that needs the updated Quest controller models
  42979. */
  42980. static _IsQuest: boolean;
  42981. /**
  42982. * Fired when the secondary trigger on this controller is modified
  42983. */
  42984. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42985. /**
  42986. * Fired when the thumb rest on this controller is modified
  42987. */
  42988. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42989. /**
  42990. * Creates a new OculusTouchController from a gamepad
  42991. * @param vrGamepad the gamepad that the controller should be created from
  42992. */
  42993. constructor(vrGamepad: any);
  42994. /**
  42995. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42996. * @param scene scene in which to add meshes
  42997. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42998. */
  42999. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43000. /**
  43001. * Fired when the A button on this controller is modified
  43002. */
  43003. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43004. /**
  43005. * Fired when the B button on this controller is modified
  43006. */
  43007. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43008. /**
  43009. * Fired when the X button on this controller is modified
  43010. */
  43011. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43012. /**
  43013. * Fired when the Y button on this controller is modified
  43014. */
  43015. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43016. /**
  43017. * Called once for each button that changed state since the last frame
  43018. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43019. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43020. * 2) secondary trigger (same)
  43021. * 3) A (right) X (left), touch, pressed = value
  43022. * 4) B / Y
  43023. * 5) thumb rest
  43024. * @param buttonIdx Which button index changed
  43025. * @param state New state of the button
  43026. * @param changes Which properties on the state changed since last frame
  43027. */
  43028. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43029. }
  43030. }
  43031. declare module BABYLON {
  43032. /**
  43033. * Vive Controller
  43034. */
  43035. export class ViveController extends WebVRController {
  43036. /**
  43037. * Base Url for the controller model.
  43038. */
  43039. static MODEL_BASE_URL: string;
  43040. /**
  43041. * File name for the controller model.
  43042. */
  43043. static MODEL_FILENAME: string;
  43044. /**
  43045. * Creates a new ViveController from a gamepad
  43046. * @param vrGamepad the gamepad that the controller should be created from
  43047. */
  43048. constructor(vrGamepad: any);
  43049. /**
  43050. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43051. * @param scene scene in which to add meshes
  43052. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43053. */
  43054. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43055. /**
  43056. * Fired when the left button on this controller is modified
  43057. */
  43058. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43059. /**
  43060. * Fired when the right button on this controller is modified
  43061. */
  43062. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43063. /**
  43064. * Fired when the menu button on this controller is modified
  43065. */
  43066. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43067. /**
  43068. * Called once for each button that changed state since the last frame
  43069. * Vive mapping:
  43070. * 0: touchpad
  43071. * 1: trigger
  43072. * 2: left AND right buttons
  43073. * 3: menu button
  43074. * @param buttonIdx Which button index changed
  43075. * @param state New state of the button
  43076. * @param changes Which properties on the state changed since last frame
  43077. */
  43078. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43079. }
  43080. }
  43081. declare module BABYLON {
  43082. /**
  43083. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43084. */
  43085. export class WebXRControllerModelLoader {
  43086. /**
  43087. * an observable that triggers when a new model (the mesh itself) was initialized.
  43088. * To know when the mesh was loaded use the controller's own modelLoaded() method
  43089. */
  43090. onControllerModelLoaded: Observable<WebXRController>;
  43091. /**
  43092. * Creates the WebXRControllerModelLoader
  43093. * @param input xr input that creates the controllers
  43094. */
  43095. constructor(input: WebXRInput);
  43096. }
  43097. }
  43098. declare module BABYLON {
  43099. /**
  43100. * Handles pointer input automatically for the pointer of XR controllers
  43101. */
  43102. export class WebXRControllerPointerSelection {
  43103. private static _idCounter;
  43104. private _tmpRay;
  43105. /**
  43106. * Creates a WebXRControllerPointerSelection
  43107. * @param input input manager to setup pointer selection
  43108. */
  43109. constructor(input: WebXRInput);
  43110. private _convertNormalToDirectionOfRay;
  43111. private _updatePointerDistance;
  43112. }
  43113. }
  43114. declare module BABYLON {
  43115. /**
  43116. * Enables teleportation
  43117. */
  43118. export class WebXRControllerTeleportation {
  43119. private _teleportationFillColor;
  43120. private _teleportationBorderColor;
  43121. private _tmpRay;
  43122. private _tmpVector;
  43123. /**
  43124. * when set to true (default) teleportation will wait for thumbstick changes.
  43125. * When set to false teleportation will be disabled.
  43126. *
  43127. * If set to false while teleporting results can be unexpected.
  43128. */
  43129. enabled: boolean;
  43130. /**
  43131. * Creates a WebXRControllerTeleportation
  43132. * @param input input manager to add teleportation to
  43133. * @param floorMeshes floormeshes which can be teleported to
  43134. */
  43135. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43136. }
  43137. }
  43138. declare module BABYLON {
  43139. /**
  43140. * Button which can be used to enter a different mode of XR
  43141. */
  43142. export class WebXREnterExitUIButton {
  43143. /** button element */
  43144. element: HTMLElement;
  43145. /** XR initialization options for the button */
  43146. sessionMode: XRSessionMode;
  43147. /** Reference space type */
  43148. referenceSpaceType: XRReferenceSpaceType;
  43149. /**
  43150. * Creates a WebXREnterExitUIButton
  43151. * @param element button element
  43152. * @param sessionMode XR initialization session mode
  43153. * @param referenceSpaceType the type of reference space to be used
  43154. */
  43155. constructor(
  43156. /** button element */
  43157. element: HTMLElement,
  43158. /** XR initialization options for the button */
  43159. sessionMode: XRSessionMode,
  43160. /** Reference space type */
  43161. referenceSpaceType: XRReferenceSpaceType);
  43162. /**
  43163. * Overwritable function which can be used to update the button's visuals when the state changes
  43164. * @param activeButton the current active button in the UI
  43165. */
  43166. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43167. }
  43168. /**
  43169. * Options to create the webXR UI
  43170. */
  43171. export class WebXREnterExitUIOptions {
  43172. /**
  43173. * Context to enter xr with
  43174. */
  43175. renderTarget?: Nullable<WebXRRenderTarget>;
  43176. /**
  43177. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43178. */
  43179. customButtons?: Array<WebXREnterExitUIButton>;
  43180. /**
  43181. * A session mode to use when creating the default button.
  43182. * Default is immersive-vr
  43183. */
  43184. sessionMode?: XRSessionMode;
  43185. /**
  43186. * A reference space type to use when creating the default button.
  43187. * Default is local-floor
  43188. */
  43189. referenceSpaceType?: XRReferenceSpaceType;
  43190. }
  43191. /**
  43192. * UI to allow the user to enter/exit XR mode
  43193. */
  43194. export class WebXREnterExitUI implements IDisposable {
  43195. private scene;
  43196. /** version of the options passed to this UI */
  43197. options: WebXREnterExitUIOptions;
  43198. private _overlay;
  43199. private _buttons;
  43200. private _activeButton;
  43201. /**
  43202. * Fired every time the active button is changed.
  43203. *
  43204. * When xr is entered via a button that launches xr that button will be the callback parameter
  43205. *
  43206. * When exiting xr the callback parameter will be null)
  43207. */
  43208. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43209. /**
  43210. * Creates UI to allow the user to enter/exit XR mode
  43211. * @param scene the scene to add the ui to
  43212. * @param helper the xr experience helper to enter/exit xr with
  43213. * @param options options to configure the UI
  43214. * @returns the created ui
  43215. */
  43216. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43217. /**
  43218. *
  43219. * @param scene babylon scene object to use
  43220. * @param options (read-only) version of the options passed to this UI
  43221. */
  43222. private constructor();
  43223. private _updateButtons;
  43224. /**
  43225. * Disposes of the object
  43226. */
  43227. dispose(): void;
  43228. }
  43229. }
  43230. declare module BABYLON {
  43231. /**
  43232. * Options for the default xr helper
  43233. */
  43234. export class WebXRDefaultExperienceOptions {
  43235. /**
  43236. * Floor meshes that should be used for teleporting
  43237. */
  43238. floorMeshes: Array<AbstractMesh>;
  43239. /**
  43240. * Enable or disable default UI to enter XR
  43241. */
  43242. disableDefaultUI?: boolean;
  43243. /**
  43244. * optional configuration for the output canvas
  43245. */
  43246. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  43247. /**
  43248. * optional UI options. This can be used among other to change session mode and reference space type
  43249. */
  43250. uiOptions?: WebXREnterExitUIOptions;
  43251. }
  43252. /**
  43253. * Default experience which provides a similar setup to the previous webVRExperience
  43254. */
  43255. export class WebXRDefaultExperience {
  43256. /**
  43257. * Base experience
  43258. */
  43259. baseExperience: WebXRExperienceHelper;
  43260. /**
  43261. * Input experience extension
  43262. */
  43263. input: WebXRInput;
  43264. /**
  43265. * Loads the controller models
  43266. */
  43267. controllerModelLoader: WebXRControllerModelLoader;
  43268. /**
  43269. * Enables laser pointer and selection
  43270. */
  43271. pointerSelection: WebXRControllerPointerSelection;
  43272. /**
  43273. * Enables teleportation
  43274. */
  43275. teleportation: WebXRControllerTeleportation;
  43276. /**
  43277. * Enables ui for entering/exiting xr
  43278. */
  43279. enterExitUI: WebXREnterExitUI;
  43280. /**
  43281. * Default target xr should render to
  43282. */
  43283. renderTarget: WebXRRenderTarget;
  43284. /**
  43285. * Creates the default xr experience
  43286. * @param scene scene
  43287. * @param options options for basic configuration
  43288. * @returns resulting WebXRDefaultExperience
  43289. */
  43290. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  43291. private constructor();
  43292. /**
  43293. * DIsposes of the experience helper
  43294. */
  43295. dispose(): void;
  43296. }
  43297. }
  43298. declare module BABYLON {
  43299. /**
  43300. * Options to modify the vr teleportation behavior.
  43301. */
  43302. export interface VRTeleportationOptions {
  43303. /**
  43304. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43305. */
  43306. floorMeshName?: string;
  43307. /**
  43308. * A list of meshes to be used as the teleportation floor. (default: empty)
  43309. */
  43310. floorMeshes?: Mesh[];
  43311. /**
  43312. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43313. */
  43314. teleportationMode?: number;
  43315. /**
  43316. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43317. */
  43318. teleportationTime?: number;
  43319. /**
  43320. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43321. */
  43322. teleportationSpeed?: number;
  43323. /**
  43324. * The easing function used in the animation or null for Linear. (default CircleEase)
  43325. */
  43326. easingFunction?: EasingFunction;
  43327. }
  43328. /**
  43329. * Options to modify the vr experience helper's behavior.
  43330. */
  43331. export interface VRExperienceHelperOptions extends WebVROptions {
  43332. /**
  43333. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43334. */
  43335. createDeviceOrientationCamera?: boolean;
  43336. /**
  43337. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43338. */
  43339. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43340. /**
  43341. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43342. */
  43343. laserToggle?: boolean;
  43344. /**
  43345. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43346. */
  43347. floorMeshes?: Mesh[];
  43348. /**
  43349. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43350. */
  43351. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43352. /**
  43353. * Defines if WebXR should be used instead of WebVR (if available)
  43354. */
  43355. useXR?: boolean;
  43356. }
  43357. /**
  43358. * Event containing information after VR has been entered
  43359. */
  43360. export class OnAfterEnteringVRObservableEvent {
  43361. /**
  43362. * If entering vr was successful
  43363. */
  43364. success: boolean;
  43365. }
  43366. /**
  43367. * Helps to quickly add VR support to an existing scene.
  43368. * See http://doc.babylonjs.com/how_to/webvr_helper
  43369. */
  43370. export class VRExperienceHelper {
  43371. /** Options to modify the vr experience helper's behavior. */
  43372. webVROptions: VRExperienceHelperOptions;
  43373. private _scene;
  43374. private _position;
  43375. private _btnVR;
  43376. private _btnVRDisplayed;
  43377. private _webVRsupported;
  43378. private _webVRready;
  43379. private _webVRrequesting;
  43380. private _webVRpresenting;
  43381. private _hasEnteredVR;
  43382. private _fullscreenVRpresenting;
  43383. private _inputElement;
  43384. private _webVRCamera;
  43385. private _vrDeviceOrientationCamera;
  43386. private _deviceOrientationCamera;
  43387. private _existingCamera;
  43388. private _onKeyDown;
  43389. private _onVrDisplayPresentChange;
  43390. private _onVRDisplayChanged;
  43391. private _onVRRequestPresentStart;
  43392. private _onVRRequestPresentComplete;
  43393. /**
  43394. * 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)
  43395. */
  43396. enableGazeEvenWhenNoPointerLock: boolean;
  43397. /**
  43398. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43399. */
  43400. exitVROnDoubleTap: boolean;
  43401. /**
  43402. * Observable raised right before entering VR.
  43403. */
  43404. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43405. /**
  43406. * Observable raised when entering VR has completed.
  43407. */
  43408. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43409. /**
  43410. * Observable raised when exiting VR.
  43411. */
  43412. onExitingVRObservable: Observable<VRExperienceHelper>;
  43413. /**
  43414. * Observable raised when controller mesh is loaded.
  43415. */
  43416. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43417. /** Return this.onEnteringVRObservable
  43418. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43419. */
  43420. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43421. /** Return this.onExitingVRObservable
  43422. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43423. */
  43424. readonly onExitingVR: Observable<VRExperienceHelper>;
  43425. /** Return this.onControllerMeshLoadedObservable
  43426. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43427. */
  43428. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43429. private _rayLength;
  43430. private _useCustomVRButton;
  43431. private _teleportationRequested;
  43432. private _teleportActive;
  43433. private _floorMeshName;
  43434. private _floorMeshesCollection;
  43435. private _teleportationMode;
  43436. private _teleportationTime;
  43437. private _teleportationSpeed;
  43438. private _teleportationEasing;
  43439. private _rotationAllowed;
  43440. private _teleportBackwardsVector;
  43441. private _teleportationTarget;
  43442. private _isDefaultTeleportationTarget;
  43443. private _postProcessMove;
  43444. private _teleportationFillColor;
  43445. private _teleportationBorderColor;
  43446. private _rotationAngle;
  43447. private _haloCenter;
  43448. private _cameraGazer;
  43449. private _padSensibilityUp;
  43450. private _padSensibilityDown;
  43451. private _leftController;
  43452. private _rightController;
  43453. /**
  43454. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43455. */
  43456. onNewMeshSelected: Observable<AbstractMesh>;
  43457. /**
  43458. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43459. * This observable will provide the mesh and the controller used to select the mesh
  43460. */
  43461. onMeshSelectedWithController: Observable<{
  43462. mesh: AbstractMesh;
  43463. controller: WebVRController;
  43464. }>;
  43465. /**
  43466. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43467. */
  43468. onNewMeshPicked: Observable<PickingInfo>;
  43469. private _circleEase;
  43470. /**
  43471. * Observable raised before camera teleportation
  43472. */
  43473. onBeforeCameraTeleport: Observable<Vector3>;
  43474. /**
  43475. * Observable raised after camera teleportation
  43476. */
  43477. onAfterCameraTeleport: Observable<Vector3>;
  43478. /**
  43479. * Observable raised when current selected mesh gets unselected
  43480. */
  43481. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43482. private _raySelectionPredicate;
  43483. /**
  43484. * To be optionaly changed by user to define custom ray selection
  43485. */
  43486. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43487. /**
  43488. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43489. */
  43490. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43491. /**
  43492. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43493. */
  43494. teleportationEnabled: boolean;
  43495. private _defaultHeight;
  43496. private _teleportationInitialized;
  43497. private _interactionsEnabled;
  43498. private _interactionsRequested;
  43499. private _displayGaze;
  43500. private _displayLaserPointer;
  43501. /**
  43502. * The mesh used to display where the user is going to teleport.
  43503. */
  43504. /**
  43505. * Sets the mesh to be used to display where the user is going to teleport.
  43506. */
  43507. teleportationTarget: Mesh;
  43508. /**
  43509. * 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
  43510. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43511. * See http://doc.babylonjs.com/resources/baking_transformations
  43512. */
  43513. gazeTrackerMesh: Mesh;
  43514. /**
  43515. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43516. */
  43517. updateGazeTrackerScale: boolean;
  43518. /**
  43519. * If the gaze trackers color should be updated when selecting meshes
  43520. */
  43521. updateGazeTrackerColor: boolean;
  43522. /**
  43523. * If the controller laser color should be updated when selecting meshes
  43524. */
  43525. updateControllerLaserColor: boolean;
  43526. /**
  43527. * The gaze tracking mesh corresponding to the left controller
  43528. */
  43529. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43530. /**
  43531. * The gaze tracking mesh corresponding to the right controller
  43532. */
  43533. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43534. /**
  43535. * If the ray of the gaze should be displayed.
  43536. */
  43537. /**
  43538. * Sets if the ray of the gaze should be displayed.
  43539. */
  43540. displayGaze: boolean;
  43541. /**
  43542. * If the ray of the LaserPointer should be displayed.
  43543. */
  43544. /**
  43545. * Sets if the ray of the LaserPointer should be displayed.
  43546. */
  43547. displayLaserPointer: boolean;
  43548. /**
  43549. * The deviceOrientationCamera used as the camera when not in VR.
  43550. */
  43551. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43552. /**
  43553. * Based on the current WebVR support, returns the current VR camera used.
  43554. */
  43555. readonly currentVRCamera: Nullable<Camera>;
  43556. /**
  43557. * The webVRCamera which is used when in VR.
  43558. */
  43559. readonly webVRCamera: WebVRFreeCamera;
  43560. /**
  43561. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43562. */
  43563. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43564. /**
  43565. * The html button that is used to trigger entering into VR.
  43566. */
  43567. readonly vrButton: Nullable<HTMLButtonElement>;
  43568. private readonly _teleportationRequestInitiated;
  43569. /**
  43570. * Defines wether or not Pointer lock should be requested when switching to
  43571. * full screen.
  43572. */
  43573. requestPointerLockOnFullScreen: boolean;
  43574. /**
  43575. * If asking to force XR, this will be populated with the default xr experience
  43576. */
  43577. xr: WebXRDefaultExperience;
  43578. /**
  43579. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  43580. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  43581. */
  43582. xrTestDone: boolean;
  43583. /**
  43584. * Instantiates a VRExperienceHelper.
  43585. * Helps to quickly add VR support to an existing scene.
  43586. * @param scene The scene the VRExperienceHelper belongs to.
  43587. * @param webVROptions Options to modify the vr experience helper's behavior.
  43588. */
  43589. constructor(scene: Scene,
  43590. /** Options to modify the vr experience helper's behavior. */
  43591. webVROptions?: VRExperienceHelperOptions);
  43592. private completeVRInit;
  43593. private _onDefaultMeshLoaded;
  43594. private _onResize;
  43595. private _onFullscreenChange;
  43596. /**
  43597. * Gets a value indicating if we are currently in VR mode.
  43598. */
  43599. readonly isInVRMode: boolean;
  43600. private onVrDisplayPresentChange;
  43601. private onVRDisplayChanged;
  43602. private moveButtonToBottomRight;
  43603. private displayVRButton;
  43604. private updateButtonVisibility;
  43605. private _cachedAngularSensibility;
  43606. /**
  43607. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43608. * Otherwise, will use the fullscreen API.
  43609. */
  43610. enterVR(): void;
  43611. /**
  43612. * Attempt to exit VR, or fullscreen.
  43613. */
  43614. exitVR(): void;
  43615. /**
  43616. * The position of the vr experience helper.
  43617. */
  43618. /**
  43619. * Sets the position of the vr experience helper.
  43620. */
  43621. position: Vector3;
  43622. /**
  43623. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43624. */
  43625. enableInteractions(): void;
  43626. private readonly _noControllerIsActive;
  43627. private beforeRender;
  43628. private _isTeleportationFloor;
  43629. /**
  43630. * Adds a floor mesh to be used for teleportation.
  43631. * @param floorMesh the mesh to be used for teleportation.
  43632. */
  43633. addFloorMesh(floorMesh: Mesh): void;
  43634. /**
  43635. * Removes a floor mesh from being used for teleportation.
  43636. * @param floorMesh the mesh to be removed.
  43637. */
  43638. removeFloorMesh(floorMesh: Mesh): void;
  43639. /**
  43640. * Enables interactions and teleportation using the VR controllers and gaze.
  43641. * @param vrTeleportationOptions options to modify teleportation behavior.
  43642. */
  43643. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43644. private _onNewGamepadConnected;
  43645. private _tryEnableInteractionOnController;
  43646. private _onNewGamepadDisconnected;
  43647. private _enableInteractionOnController;
  43648. private _checkTeleportWithRay;
  43649. private _checkRotate;
  43650. private _checkTeleportBackwards;
  43651. private _enableTeleportationOnController;
  43652. private _createTeleportationCircles;
  43653. private _displayTeleportationTarget;
  43654. private _hideTeleportationTarget;
  43655. private _rotateCamera;
  43656. private _moveTeleportationSelectorTo;
  43657. private _workingVector;
  43658. private _workingQuaternion;
  43659. private _workingMatrix;
  43660. /**
  43661. * Time Constant Teleportation Mode
  43662. */
  43663. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  43664. /**
  43665. * Speed Constant Teleportation Mode
  43666. */
  43667. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  43668. /**
  43669. * Teleports the users feet to the desired location
  43670. * @param location The location where the user's feet should be placed
  43671. */
  43672. teleportCamera(location: Vector3): void;
  43673. private _convertNormalToDirectionOfRay;
  43674. private _castRayAndSelectObject;
  43675. private _notifySelectedMeshUnselected;
  43676. /**
  43677. * Sets the color of the laser ray from the vr controllers.
  43678. * @param color new color for the ray.
  43679. */
  43680. changeLaserColor(color: Color3): void;
  43681. /**
  43682. * Sets the color of the ray from the vr headsets gaze.
  43683. * @param color new color for the ray.
  43684. */
  43685. changeGazeColor(color: Color3): void;
  43686. /**
  43687. * Exits VR and disposes of the vr experience helper
  43688. */
  43689. dispose(): void;
  43690. /**
  43691. * Gets the name of the VRExperienceHelper class
  43692. * @returns "VRExperienceHelper"
  43693. */
  43694. getClassName(): string;
  43695. }
  43696. }
  43697. declare module BABYLON {
  43698. /**
  43699. * Options used for hit testing
  43700. */
  43701. export interface IWebXRHitTestOptions {
  43702. /**
  43703. * Only test when user interacted with the scene. Default - hit test every frame
  43704. */
  43705. testOnPointerDownOnly?: boolean;
  43706. /**
  43707. * The node to use to transform the local results to world coordinates
  43708. */
  43709. worldParentNode?: TransformNode;
  43710. }
  43711. /**
  43712. * Interface defining the babylon result of raycasting/hit-test
  43713. */
  43714. export interface IWebXRHitResult {
  43715. /**
  43716. * The native hit test result
  43717. */
  43718. xrHitResult: XRHitResult;
  43719. /**
  43720. * Transformation matrix that can be applied to a node that will put it in the hit point location
  43721. */
  43722. transformationMatrix: Matrix;
  43723. }
  43724. /**
  43725. * The currently-working hit-test module.
  43726. * Hit test (or raycasting) is used to interact with the real world.
  43727. * For further information read here - https://github.com/immersive-web/hit-test
  43728. */
  43729. export class WebXRHitTestLegacy implements IWebXRFeature {
  43730. private _xrSessionManager;
  43731. /**
  43732. * options to use when constructing this feature
  43733. */
  43734. readonly options: IWebXRHitTestOptions;
  43735. /**
  43736. * The module's name
  43737. */
  43738. static readonly Name: string;
  43739. /**
  43740. * The (Babylon) version of this module.
  43741. * This is an integer representing the implementation version.
  43742. * This number does not correspond to the webxr specs version
  43743. */
  43744. static readonly Version: number;
  43745. /**
  43746. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  43747. * @param event the (select) event to use to select with
  43748. * @param referenceSpace the reference space to use for this hit test
  43749. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  43750. */
  43751. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  43752. /**
  43753. * execute a hit test with an XR Ray
  43754. *
  43755. * @param xrSession a native xrSession that will execute this hit test
  43756. * @param xrRay the ray (position and direction) to use for raycasting
  43757. * @param referenceSpace native XR reference space to use for the hit-test
  43758. * @param filter filter function that will filter the results
  43759. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  43760. */
  43761. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  43762. /**
  43763. * Triggered when new babylon (transformed) hit test results are available
  43764. */
  43765. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  43766. /**
  43767. * Creates a new instance of the (legacy version) hit test feature
  43768. * @param _xrSessionManager an instance of WebXRSessionManager
  43769. * @param options options to use when constructing this feature
  43770. */
  43771. constructor(_xrSessionManager: WebXRSessionManager,
  43772. /**
  43773. * options to use when constructing this feature
  43774. */
  43775. options?: IWebXRHitTestOptions);
  43776. private _onSelectEnabled;
  43777. private _xrFrameObserver;
  43778. private _attached;
  43779. /**
  43780. * Populated with the last native XR Hit Results
  43781. */
  43782. lastNativeXRHitResults: XRHitResult[];
  43783. /**
  43784. * attach this feature
  43785. * Will usually be called by the features manager
  43786. *
  43787. * @returns true if successful.
  43788. */
  43789. attach(): boolean;
  43790. /**
  43791. * detach this feature.
  43792. * Will usually be called by the features manager
  43793. *
  43794. * @returns true if successful.
  43795. */
  43796. detach(): boolean;
  43797. private _onHitTestResults;
  43798. private _onSelect;
  43799. /**
  43800. * Dispose this feature and all of the resources attached
  43801. */
  43802. dispose(): void;
  43803. }
  43804. }
  43805. declare module BABYLON {
  43806. /**
  43807. * Options used in the plane detector module
  43808. */
  43809. export interface IWebXRPlaneDetectorOptions {
  43810. /**
  43811. * The node to use to transform the local results to world coordinates
  43812. */
  43813. worldParentNode?: TransformNode;
  43814. }
  43815. /**
  43816. * A babylon interface for a webxr plane.
  43817. * A Plane is actually a polygon, built from N points in space
  43818. */
  43819. export interface IWebXRPlane {
  43820. /**
  43821. * a babylon-assigned ID for this polygon
  43822. */
  43823. id: number;
  43824. /**
  43825. * the native xr-plane object
  43826. */
  43827. xrPlane: XRPlane;
  43828. /**
  43829. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  43830. */
  43831. polygonDefinition: Array<Vector3>;
  43832. /**
  43833. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  43834. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  43835. */
  43836. transformationMatrix: Matrix;
  43837. }
  43838. /**
  43839. * The plane detector is used to detect planes in the real world when in AR
  43840. * For more information see https://github.com/immersive-web/real-world-geometry/
  43841. */
  43842. export class WebXRPlaneDetector implements IWebXRFeature {
  43843. private _xrSessionManager;
  43844. private _options;
  43845. /**
  43846. * The module's name
  43847. */
  43848. static readonly Name: string;
  43849. /**
  43850. * The (Babylon) version of this module.
  43851. * This is an integer representing the implementation version.
  43852. * This number does not correspond to the webxr specs version
  43853. */
  43854. static readonly Version: number;
  43855. /**
  43856. * Observers registered here will be executed when a new plane was added to the session
  43857. */
  43858. onPlaneAddedObservable: Observable<IWebXRPlane>;
  43859. /**
  43860. * Observers registered here will be executed when a plane is no longer detected in the session
  43861. */
  43862. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  43863. /**
  43864. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  43865. * This can execute N times every frame
  43866. */
  43867. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  43868. private _enabled;
  43869. private _attached;
  43870. private _detectedPlanes;
  43871. private _lastFrameDetected;
  43872. private _observerTracked;
  43873. /**
  43874. * construct a new Plane Detector
  43875. * @param _xrSessionManager an instance of xr Session manager
  43876. * @param _options configuration to use when constructing this feature
  43877. */
  43878. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  43879. /**
  43880. * attach this feature
  43881. * Will usually be called by the features manager
  43882. *
  43883. * @returns true if successful.
  43884. */
  43885. attach(): boolean;
  43886. /**
  43887. * detach this feature.
  43888. * Will usually be called by the features manager
  43889. *
  43890. * @returns true if successful.
  43891. */
  43892. detach(): boolean;
  43893. /**
  43894. * Dispose this feature and all of the resources attached
  43895. */
  43896. dispose(): void;
  43897. private _updatePlaneWithXRPlane;
  43898. /**
  43899. * avoiding using Array.find for global support.
  43900. * @param xrPlane the plane to find in the array
  43901. */
  43902. private findIndexInPlaneArray;
  43903. }
  43904. }
  43905. declare module BABYLON {
  43906. /**
  43907. * Configuration options of the anchor system
  43908. */
  43909. export interface IWebXRAnchorSystemOptions {
  43910. /**
  43911. * a node that will be used to convert local to world coordinates
  43912. */
  43913. worldParentNode?: TransformNode;
  43914. /**
  43915. * should the anchor system use plane detection.
  43916. * If set to true, the plane-detection feature should be set using setPlaneDetector
  43917. */
  43918. usePlaneDetection?: boolean;
  43919. /**
  43920. * Should a new anchor be added every time a select event is triggered
  43921. */
  43922. addAnchorOnSelect?: boolean;
  43923. }
  43924. /**
  43925. * A babylon container for an XR Anchor
  43926. */
  43927. export interface IWebXRAnchor {
  43928. /**
  43929. * A babylon-assigned ID for this anchor
  43930. */
  43931. id: number;
  43932. /**
  43933. * The native anchor object
  43934. */
  43935. xrAnchor: XRAnchor;
  43936. /**
  43937. * Transformation matrix to apply to an object attached to this anchor
  43938. */
  43939. transformationMatrix: Matrix;
  43940. }
  43941. /**
  43942. * An implementation of the anchor system of WebXR.
  43943. * Note that the current documented implementation is not available in any browser. Future implementations
  43944. * will use the frame to create an anchor and not the session or a detected plane
  43945. * For further information see https://github.com/immersive-web/anchors/
  43946. */
  43947. export class WebXRAnchorSystem implements IWebXRFeature {
  43948. private _xrSessionManager;
  43949. private _options;
  43950. /**
  43951. * The module's name
  43952. */
  43953. static readonly Name: string;
  43954. /**
  43955. * The (Babylon) version of this module.
  43956. * This is an integer representing the implementation version.
  43957. * This number does not correspond to the webxr specs version
  43958. */
  43959. static readonly Version: number;
  43960. /**
  43961. * Observers registered here will be executed when a new anchor was added to the session
  43962. */
  43963. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  43964. /**
  43965. * Observers registered here will be executed when an existing anchor updates
  43966. * This can execute N times every frame
  43967. */
  43968. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  43969. /**
  43970. * Observers registered here will be executed when an anchor was removed from the session
  43971. */
  43972. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  43973. private _planeDetector;
  43974. private _hitTestModule;
  43975. private _enabled;
  43976. private _attached;
  43977. private _trackedAnchors;
  43978. private _lastFrameDetected;
  43979. private _observerTracked;
  43980. /**
  43981. * constructs a new anchor system
  43982. * @param _xrSessionManager an instance of WebXRSessionManager
  43983. * @param _options configuration object for this feature
  43984. */
  43985. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  43986. /**
  43987. * set the plane detector to use in order to create anchors from frames
  43988. * @param planeDetector the plane-detector module to use
  43989. * @param enable enable plane-anchors. default is true
  43990. */
  43991. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  43992. /**
  43993. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  43994. * @param hitTestModule the hit-test module to use.
  43995. */
  43996. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  43997. /**
  43998. * attach this feature
  43999. * Will usually be called by the features manager
  44000. *
  44001. * @returns true if successful.
  44002. */
  44003. attach(): boolean;
  44004. /**
  44005. * detach this feature.
  44006. * Will usually be called by the features manager
  44007. *
  44008. * @returns true if successful.
  44009. */
  44010. detach(): boolean;
  44011. /**
  44012. * Dispose this feature and all of the resources attached
  44013. */
  44014. dispose(): void;
  44015. private _onSelect;
  44016. /**
  44017. * Add anchor at a specific XR point.
  44018. *
  44019. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  44020. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  44021. * @returns a promise the fulfills when the anchor was created
  44022. */
  44023. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  44024. private _updateAnchorWithXRFrame;
  44025. /**
  44026. * avoiding using Array.find for global support.
  44027. * @param xrAnchor the plane to find in the array
  44028. */
  44029. private _findIndexInAnchorArray;
  44030. }
  44031. }
  44032. declare module BABYLON {
  44033. /**
  44034. * Options interface for the background remover plugin
  44035. */
  44036. export interface IWebXRBackgroundRemoverOptions {
  44037. /**
  44038. * don't disable the environment helper
  44039. */
  44040. ignoreEnvironmentHelper?: boolean;
  44041. /**
  44042. * flags to configure the removal of the environment helper.
  44043. * If not set, the entire background will be removed. If set, flags should be set as well.
  44044. */
  44045. environmentHelperRemovalFlags?: {
  44046. /**
  44047. * Should the skybox be removed (default false)
  44048. */
  44049. skyBox?: boolean;
  44050. /**
  44051. * Should the ground be removed (default false)
  44052. */
  44053. ground?: boolean;
  44054. };
  44055. /**
  44056. * Further background meshes to disable when entering AR
  44057. */
  44058. backgroundMeshes?: AbstractMesh[];
  44059. }
  44060. /**
  44061. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  44062. */
  44063. export class WebXRBackgroundRemover implements IWebXRFeature {
  44064. private _xrSessionManager;
  44065. /**
  44066. * read-only options to be used in this module
  44067. */
  44068. readonly options: IWebXRBackgroundRemoverOptions;
  44069. /**
  44070. * The module's name
  44071. */
  44072. static readonly Name: string;
  44073. /**
  44074. * The (Babylon) version of this module.
  44075. * This is an integer representing the implementation version.
  44076. * This number does not correspond to the webxr specs version
  44077. */
  44078. static readonly Version: number;
  44079. /**
  44080. * registered observers will be triggered when the background state changes
  44081. */
  44082. onBackgroundStateChangedObservable: Observable<boolean>;
  44083. /**
  44084. * constructs a new background remover module
  44085. * @param _xrSessionManager the session manager for this module
  44086. * @param options read-only options to be used in this module
  44087. */
  44088. constructor(_xrSessionManager: WebXRSessionManager,
  44089. /**
  44090. * read-only options to be used in this module
  44091. */
  44092. options?: IWebXRBackgroundRemoverOptions);
  44093. /**
  44094. * attach this feature
  44095. * Will usually be called by the features manager
  44096. *
  44097. * @returns true if successful.
  44098. */
  44099. attach(): boolean;
  44100. /**
  44101. * detach this feature.
  44102. * Will usually be called by the features manager
  44103. *
  44104. * @returns true if successful.
  44105. */
  44106. detach(): boolean;
  44107. private _setBackgroundState;
  44108. /**
  44109. * Dispose this feature and all of the resources attached
  44110. */
  44111. dispose(): void;
  44112. }
  44113. }
  44114. declare module BABYLON {
  44115. /**
  44116. * Contains an array of blocks representing the octree
  44117. */
  44118. export interface IOctreeContainer<T> {
  44119. /**
  44120. * Blocks within the octree
  44121. */
  44122. blocks: Array<OctreeBlock<T>>;
  44123. }
  44124. /**
  44125. * Class used to store a cell in an octree
  44126. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44127. */
  44128. export class OctreeBlock<T> {
  44129. /**
  44130. * Gets the content of the current block
  44131. */
  44132. entries: T[];
  44133. /**
  44134. * Gets the list of block children
  44135. */
  44136. blocks: Array<OctreeBlock<T>>;
  44137. private _depth;
  44138. private _maxDepth;
  44139. private _capacity;
  44140. private _minPoint;
  44141. private _maxPoint;
  44142. private _boundingVectors;
  44143. private _creationFunc;
  44144. /**
  44145. * Creates a new block
  44146. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44147. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44148. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44149. * @param depth defines the current depth of this block in the octree
  44150. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44151. * @param creationFunc defines a callback to call when an element is added to the block
  44152. */
  44153. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44154. /**
  44155. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44156. */
  44157. readonly capacity: number;
  44158. /**
  44159. * Gets the minimum vector (in world space) of the block's bounding box
  44160. */
  44161. readonly minPoint: Vector3;
  44162. /**
  44163. * Gets the maximum vector (in world space) of the block's bounding box
  44164. */
  44165. readonly maxPoint: Vector3;
  44166. /**
  44167. * Add a new element to this block
  44168. * @param entry defines the element to add
  44169. */
  44170. addEntry(entry: T): void;
  44171. /**
  44172. * Remove an element from this block
  44173. * @param entry defines the element to remove
  44174. */
  44175. removeEntry(entry: T): void;
  44176. /**
  44177. * Add an array of elements to this block
  44178. * @param entries defines the array of elements to add
  44179. */
  44180. addEntries(entries: T[]): void;
  44181. /**
  44182. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44183. * @param frustumPlanes defines the frustum planes to test
  44184. * @param selection defines the array to store current content if selection is positive
  44185. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44186. */
  44187. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44188. /**
  44189. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44190. * @param sphereCenter defines the bounding sphere center
  44191. * @param sphereRadius defines the bounding sphere radius
  44192. * @param selection defines the array to store current content if selection is positive
  44193. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44194. */
  44195. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44196. /**
  44197. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44198. * @param ray defines the ray to test with
  44199. * @param selection defines the array to store current content if selection is positive
  44200. */
  44201. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44202. /**
  44203. * Subdivide the content into child blocks (this block will then be empty)
  44204. */
  44205. createInnerBlocks(): void;
  44206. /**
  44207. * @hidden
  44208. */
  44209. 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;
  44210. }
  44211. }
  44212. declare module BABYLON {
  44213. /**
  44214. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44215. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44216. */
  44217. export class Octree<T> {
  44218. /** 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.) */
  44219. maxDepth: number;
  44220. /**
  44221. * Blocks within the octree containing objects
  44222. */
  44223. blocks: Array<OctreeBlock<T>>;
  44224. /**
  44225. * Content stored in the octree
  44226. */
  44227. dynamicContent: T[];
  44228. private _maxBlockCapacity;
  44229. private _selectionContent;
  44230. private _creationFunc;
  44231. /**
  44232. * Creates a octree
  44233. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44234. * @param creationFunc function to be used to instatiate the octree
  44235. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44236. * @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.)
  44237. */
  44238. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44239. /** 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.) */
  44240. maxDepth?: number);
  44241. /**
  44242. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44243. * @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);
  44244. * @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);
  44245. * @param entries meshes to be added to the octree blocks
  44246. */
  44247. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44248. /**
  44249. * Adds a mesh to the octree
  44250. * @param entry Mesh to add to the octree
  44251. */
  44252. addMesh(entry: T): void;
  44253. /**
  44254. * Remove an element from the octree
  44255. * @param entry defines the element to remove
  44256. */
  44257. removeMesh(entry: T): void;
  44258. /**
  44259. * Selects an array of meshes within the frustum
  44260. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44261. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44262. * @returns array of meshes within the frustum
  44263. */
  44264. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44265. /**
  44266. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44267. * @param sphereCenter defines the bounding sphere center
  44268. * @param sphereRadius defines the bounding sphere radius
  44269. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44270. * @returns an array of objects that intersect the sphere
  44271. */
  44272. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44273. /**
  44274. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44275. * @param ray defines the ray to test with
  44276. * @returns array of intersected objects
  44277. */
  44278. intersectsRay(ray: Ray): SmartArray<T>;
  44279. /**
  44280. * Adds a mesh into the octree block if it intersects the block
  44281. */
  44282. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44283. /**
  44284. * Adds a submesh into the octree block if it intersects the block
  44285. */
  44286. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44287. }
  44288. }
  44289. declare module BABYLON {
  44290. interface Scene {
  44291. /**
  44292. * @hidden
  44293. * Backing Filed
  44294. */
  44295. _selectionOctree: Octree<AbstractMesh>;
  44296. /**
  44297. * Gets the octree used to boost mesh selection (picking)
  44298. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44299. */
  44300. selectionOctree: Octree<AbstractMesh>;
  44301. /**
  44302. * Creates or updates the octree used to boost selection (picking)
  44303. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44304. * @param maxCapacity defines the maximum capacity per leaf
  44305. * @param maxDepth defines the maximum depth of the octree
  44306. * @returns an octree of AbstractMesh
  44307. */
  44308. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44309. }
  44310. interface AbstractMesh {
  44311. /**
  44312. * @hidden
  44313. * Backing Field
  44314. */
  44315. _submeshesOctree: Octree<SubMesh>;
  44316. /**
  44317. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44318. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44319. * @param maxCapacity defines the maximum size of each block (64 by default)
  44320. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44321. * @returns the new octree
  44322. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44323. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44324. */
  44325. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44326. }
  44327. /**
  44328. * Defines the octree scene component responsible to manage any octrees
  44329. * in a given scene.
  44330. */
  44331. export class OctreeSceneComponent {
  44332. /**
  44333. * The component name help to identify the component in the list of scene components.
  44334. */
  44335. readonly name: string;
  44336. /**
  44337. * The scene the component belongs to.
  44338. */
  44339. scene: Scene;
  44340. /**
  44341. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44342. */
  44343. readonly checksIsEnabled: boolean;
  44344. /**
  44345. * Creates a new instance of the component for the given scene
  44346. * @param scene Defines the scene to register the component in
  44347. */
  44348. constructor(scene: Scene);
  44349. /**
  44350. * Registers the component in a given scene
  44351. */
  44352. register(): void;
  44353. /**
  44354. * Return the list of active meshes
  44355. * @returns the list of active meshes
  44356. */
  44357. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44358. /**
  44359. * Return the list of active sub meshes
  44360. * @param mesh The mesh to get the candidates sub meshes from
  44361. * @returns the list of active sub meshes
  44362. */
  44363. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44364. private _tempRay;
  44365. /**
  44366. * Return the list of sub meshes intersecting with a given local ray
  44367. * @param mesh defines the mesh to find the submesh for
  44368. * @param localRay defines the ray in local space
  44369. * @returns the list of intersecting sub meshes
  44370. */
  44371. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44372. /**
  44373. * Return the list of sub meshes colliding with a collider
  44374. * @param mesh defines the mesh to find the submesh for
  44375. * @param collider defines the collider to evaluate the collision against
  44376. * @returns the list of colliding sub meshes
  44377. */
  44378. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44379. /**
  44380. * Rebuilds the elements related to this component in case of
  44381. * context lost for instance.
  44382. */
  44383. rebuild(): void;
  44384. /**
  44385. * Disposes the component and the associated ressources.
  44386. */
  44387. dispose(): void;
  44388. }
  44389. }
  44390. declare module BABYLON {
  44391. /**
  44392. * Renders a layer on top of an existing scene
  44393. */
  44394. export class UtilityLayerRenderer implements IDisposable {
  44395. /** the original scene that will be rendered on top of */
  44396. originalScene: Scene;
  44397. private _pointerCaptures;
  44398. private _lastPointerEvents;
  44399. private static _DefaultUtilityLayer;
  44400. private static _DefaultKeepDepthUtilityLayer;
  44401. private _sharedGizmoLight;
  44402. private _renderCamera;
  44403. /**
  44404. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44405. * @returns the camera that is used when rendering the utility layer
  44406. */
  44407. getRenderCamera(): Nullable<Camera>;
  44408. /**
  44409. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44410. * @param cam the camera that should be used when rendering the utility layer
  44411. */
  44412. setRenderCamera(cam: Nullable<Camera>): void;
  44413. /**
  44414. * @hidden
  44415. * Light which used by gizmos to get light shading
  44416. */
  44417. _getSharedGizmoLight(): HemisphericLight;
  44418. /**
  44419. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44420. */
  44421. pickUtilitySceneFirst: boolean;
  44422. /**
  44423. * 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)
  44424. */
  44425. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44426. /**
  44427. * 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)
  44428. */
  44429. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44430. /**
  44431. * The scene that is rendered on top of the original scene
  44432. */
  44433. utilityLayerScene: Scene;
  44434. /**
  44435. * If the utility layer should automatically be rendered on top of existing scene
  44436. */
  44437. shouldRender: boolean;
  44438. /**
  44439. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44440. */
  44441. onlyCheckPointerDownEvents: boolean;
  44442. /**
  44443. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44444. */
  44445. processAllEvents: boolean;
  44446. /**
  44447. * Observable raised when the pointer move from the utility layer scene to the main scene
  44448. */
  44449. onPointerOutObservable: Observable<number>;
  44450. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44451. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44452. private _afterRenderObserver;
  44453. private _sceneDisposeObserver;
  44454. private _originalPointerObserver;
  44455. /**
  44456. * Instantiates a UtilityLayerRenderer
  44457. * @param originalScene the original scene that will be rendered on top of
  44458. * @param handleEvents boolean indicating if the utility layer should handle events
  44459. */
  44460. constructor(
  44461. /** the original scene that will be rendered on top of */
  44462. originalScene: Scene, handleEvents?: boolean);
  44463. private _notifyObservers;
  44464. /**
  44465. * Renders the utility layers scene on top of the original scene
  44466. */
  44467. render(): void;
  44468. /**
  44469. * Disposes of the renderer
  44470. */
  44471. dispose(): void;
  44472. private _updateCamera;
  44473. }
  44474. }
  44475. declare module BABYLON {
  44476. /**
  44477. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44478. */
  44479. export class Gizmo implements IDisposable {
  44480. /** The utility layer the gizmo will be added to */
  44481. gizmoLayer: UtilityLayerRenderer;
  44482. /**
  44483. * The root mesh of the gizmo
  44484. */
  44485. _rootMesh: Mesh;
  44486. private _attachedMesh;
  44487. /**
  44488. * Ratio for the scale of the gizmo (Default: 1)
  44489. */
  44490. scaleRatio: number;
  44491. /**
  44492. * If a custom mesh has been set (Default: false)
  44493. */
  44494. protected _customMeshSet: boolean;
  44495. /**
  44496. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44497. * * When set, interactions will be enabled
  44498. */
  44499. attachedMesh: Nullable<AbstractMesh>;
  44500. /**
  44501. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44502. * @param mesh The mesh to replace the default mesh of the gizmo
  44503. */
  44504. setCustomMesh(mesh: Mesh): void;
  44505. /**
  44506. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44507. */
  44508. updateGizmoRotationToMatchAttachedMesh: boolean;
  44509. /**
  44510. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44511. */
  44512. updateGizmoPositionToMatchAttachedMesh: boolean;
  44513. /**
  44514. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44515. */
  44516. updateScale: boolean;
  44517. protected _interactionsEnabled: boolean;
  44518. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44519. private _beforeRenderObserver;
  44520. private _tempVector;
  44521. /**
  44522. * Creates a gizmo
  44523. * @param gizmoLayer The utility layer the gizmo will be added to
  44524. */
  44525. constructor(
  44526. /** The utility layer the gizmo will be added to */
  44527. gizmoLayer?: UtilityLayerRenderer);
  44528. /**
  44529. * Updates the gizmo to match the attached mesh's position/rotation
  44530. */
  44531. protected _update(): void;
  44532. /**
  44533. * Disposes of the gizmo
  44534. */
  44535. dispose(): void;
  44536. }
  44537. }
  44538. declare module BABYLON {
  44539. /**
  44540. * Single plane drag gizmo
  44541. */
  44542. export class PlaneDragGizmo extends Gizmo {
  44543. /**
  44544. * Drag behavior responsible for the gizmos dragging interactions
  44545. */
  44546. dragBehavior: PointerDragBehavior;
  44547. private _pointerObserver;
  44548. /**
  44549. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44550. */
  44551. snapDistance: number;
  44552. /**
  44553. * Event that fires each time the gizmo snaps to a new location.
  44554. * * snapDistance is the the change in distance
  44555. */
  44556. onSnapObservable: Observable<{
  44557. snapDistance: number;
  44558. }>;
  44559. private _plane;
  44560. private _coloredMaterial;
  44561. private _hoverMaterial;
  44562. private _isEnabled;
  44563. private _parent;
  44564. /** @hidden */
  44565. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44566. /** @hidden */
  44567. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44568. /**
  44569. * Creates a PlaneDragGizmo
  44570. * @param gizmoLayer The utility layer the gizmo will be added to
  44571. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44572. * @param color The color of the gizmo
  44573. */
  44574. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44575. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44576. /**
  44577. * If the gizmo is enabled
  44578. */
  44579. isEnabled: boolean;
  44580. /**
  44581. * Disposes of the gizmo
  44582. */
  44583. dispose(): void;
  44584. }
  44585. }
  44586. declare module BABYLON {
  44587. /**
  44588. * Gizmo that enables dragging a mesh along 3 axis
  44589. */
  44590. export class PositionGizmo extends Gizmo {
  44591. /**
  44592. * Internal gizmo used for interactions on the x axis
  44593. */
  44594. xGizmo: AxisDragGizmo;
  44595. /**
  44596. * Internal gizmo used for interactions on the y axis
  44597. */
  44598. yGizmo: AxisDragGizmo;
  44599. /**
  44600. * Internal gizmo used for interactions on the z axis
  44601. */
  44602. zGizmo: AxisDragGizmo;
  44603. /**
  44604. * Internal gizmo used for interactions on the yz plane
  44605. */
  44606. xPlaneGizmo: PlaneDragGizmo;
  44607. /**
  44608. * Internal gizmo used for interactions on the xz plane
  44609. */
  44610. yPlaneGizmo: PlaneDragGizmo;
  44611. /**
  44612. * Internal gizmo used for interactions on the xy plane
  44613. */
  44614. zPlaneGizmo: PlaneDragGizmo;
  44615. /**
  44616. * private variables
  44617. */
  44618. private _meshAttached;
  44619. private _updateGizmoRotationToMatchAttachedMesh;
  44620. private _snapDistance;
  44621. private _scaleRatio;
  44622. /** Fires an event when any of it's sub gizmos are dragged */
  44623. onDragStartObservable: Observable<unknown>;
  44624. /** Fires an event when any of it's sub gizmos are released from dragging */
  44625. onDragEndObservable: Observable<unknown>;
  44626. /**
  44627. * If set to true, planar drag is enabled
  44628. */
  44629. private _planarGizmoEnabled;
  44630. attachedMesh: Nullable<AbstractMesh>;
  44631. /**
  44632. * Creates a PositionGizmo
  44633. * @param gizmoLayer The utility layer the gizmo will be added to
  44634. */
  44635. constructor(gizmoLayer?: UtilityLayerRenderer);
  44636. /**
  44637. * If the planar drag gizmo is enabled
  44638. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44639. */
  44640. planarGizmoEnabled: boolean;
  44641. updateGizmoRotationToMatchAttachedMesh: boolean;
  44642. /**
  44643. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44644. */
  44645. snapDistance: number;
  44646. /**
  44647. * Ratio for the scale of the gizmo (Default: 1)
  44648. */
  44649. scaleRatio: number;
  44650. /**
  44651. * Disposes of the gizmo
  44652. */
  44653. dispose(): void;
  44654. /**
  44655. * CustomMeshes are not supported by this gizmo
  44656. * @param mesh The mesh to replace the default mesh of the gizmo
  44657. */
  44658. setCustomMesh(mesh: Mesh): void;
  44659. }
  44660. }
  44661. declare module BABYLON {
  44662. /**
  44663. * Single axis drag gizmo
  44664. */
  44665. export class AxisDragGizmo extends Gizmo {
  44666. /**
  44667. * Drag behavior responsible for the gizmos dragging interactions
  44668. */
  44669. dragBehavior: PointerDragBehavior;
  44670. private _pointerObserver;
  44671. /**
  44672. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44673. */
  44674. snapDistance: number;
  44675. /**
  44676. * Event that fires each time the gizmo snaps to a new location.
  44677. * * snapDistance is the the change in distance
  44678. */
  44679. onSnapObservable: Observable<{
  44680. snapDistance: number;
  44681. }>;
  44682. private _isEnabled;
  44683. private _parent;
  44684. private _arrow;
  44685. private _coloredMaterial;
  44686. private _hoverMaterial;
  44687. /** @hidden */
  44688. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44689. /** @hidden */
  44690. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44691. /**
  44692. * Creates an AxisDragGizmo
  44693. * @param gizmoLayer The utility layer the gizmo will be added to
  44694. * @param dragAxis The axis which the gizmo will be able to drag on
  44695. * @param color The color of the gizmo
  44696. */
  44697. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44698. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44699. /**
  44700. * If the gizmo is enabled
  44701. */
  44702. isEnabled: boolean;
  44703. /**
  44704. * Disposes of the gizmo
  44705. */
  44706. dispose(): void;
  44707. }
  44708. }
  44709. declare module BABYLON.Debug {
  44710. /**
  44711. * The Axes viewer will show 3 axes in a specific point in space
  44712. */
  44713. export class AxesViewer {
  44714. private _xAxis;
  44715. private _yAxis;
  44716. private _zAxis;
  44717. private _scaleLinesFactor;
  44718. private _instanced;
  44719. /**
  44720. * Gets the hosting scene
  44721. */
  44722. scene: Scene;
  44723. /**
  44724. * Gets or sets a number used to scale line length
  44725. */
  44726. scaleLines: number;
  44727. /** Gets the node hierarchy used to render x-axis */
  44728. readonly xAxis: TransformNode;
  44729. /** Gets the node hierarchy used to render y-axis */
  44730. readonly yAxis: TransformNode;
  44731. /** Gets the node hierarchy used to render z-axis */
  44732. readonly zAxis: TransformNode;
  44733. /**
  44734. * Creates a new AxesViewer
  44735. * @param scene defines the hosting scene
  44736. * @param scaleLines defines a number used to scale line length (1 by default)
  44737. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44738. * @param xAxis defines the node hierarchy used to render the x-axis
  44739. * @param yAxis defines the node hierarchy used to render the y-axis
  44740. * @param zAxis defines the node hierarchy used to render the z-axis
  44741. */
  44742. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44743. /**
  44744. * Force the viewer to update
  44745. * @param position defines the position of the viewer
  44746. * @param xaxis defines the x axis of the viewer
  44747. * @param yaxis defines the y axis of the viewer
  44748. * @param zaxis defines the z axis of the viewer
  44749. */
  44750. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44751. /**
  44752. * Creates an instance of this axes viewer.
  44753. * @returns a new axes viewer with instanced meshes
  44754. */
  44755. createInstance(): AxesViewer;
  44756. /** Releases resources */
  44757. dispose(): void;
  44758. private static _SetRenderingGroupId;
  44759. }
  44760. }
  44761. declare module BABYLON.Debug {
  44762. /**
  44763. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44764. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44765. */
  44766. export class BoneAxesViewer extends AxesViewer {
  44767. /**
  44768. * Gets or sets the target mesh where to display the axes viewer
  44769. */
  44770. mesh: Nullable<Mesh>;
  44771. /**
  44772. * Gets or sets the target bone where to display the axes viewer
  44773. */
  44774. bone: Nullable<Bone>;
  44775. /** Gets current position */
  44776. pos: Vector3;
  44777. /** Gets direction of X axis */
  44778. xaxis: Vector3;
  44779. /** Gets direction of Y axis */
  44780. yaxis: Vector3;
  44781. /** Gets direction of Z axis */
  44782. zaxis: Vector3;
  44783. /**
  44784. * Creates a new BoneAxesViewer
  44785. * @param scene defines the hosting scene
  44786. * @param bone defines the target bone
  44787. * @param mesh defines the target mesh
  44788. * @param scaleLines defines a scaling factor for line length (1 by default)
  44789. */
  44790. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44791. /**
  44792. * Force the viewer to update
  44793. */
  44794. update(): void;
  44795. /** Releases resources */
  44796. dispose(): void;
  44797. }
  44798. }
  44799. declare module BABYLON {
  44800. /**
  44801. * Interface used to define scene explorer extensibility option
  44802. */
  44803. export interface IExplorerExtensibilityOption {
  44804. /**
  44805. * Define the option label
  44806. */
  44807. label: string;
  44808. /**
  44809. * Defines the action to execute on click
  44810. */
  44811. action: (entity: any) => void;
  44812. }
  44813. /**
  44814. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44815. */
  44816. export interface IExplorerExtensibilityGroup {
  44817. /**
  44818. * Defines a predicate to test if a given type mut be extended
  44819. */
  44820. predicate: (entity: any) => boolean;
  44821. /**
  44822. * Gets the list of options added to a type
  44823. */
  44824. entries: IExplorerExtensibilityOption[];
  44825. }
  44826. /**
  44827. * Interface used to define the options to use to create the Inspector
  44828. */
  44829. export interface IInspectorOptions {
  44830. /**
  44831. * Display in overlay mode (default: false)
  44832. */
  44833. overlay?: boolean;
  44834. /**
  44835. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44836. */
  44837. globalRoot?: HTMLElement;
  44838. /**
  44839. * Display the Scene explorer
  44840. */
  44841. showExplorer?: boolean;
  44842. /**
  44843. * Display the property inspector
  44844. */
  44845. showInspector?: boolean;
  44846. /**
  44847. * Display in embed mode (both panes on the right)
  44848. */
  44849. embedMode?: boolean;
  44850. /**
  44851. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44852. */
  44853. handleResize?: boolean;
  44854. /**
  44855. * Allow the panes to popup (default: true)
  44856. */
  44857. enablePopup?: boolean;
  44858. /**
  44859. * Allow the panes to be closed by users (default: true)
  44860. */
  44861. enableClose?: boolean;
  44862. /**
  44863. * Optional list of extensibility entries
  44864. */
  44865. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44866. /**
  44867. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44868. */
  44869. inspectorURL?: string;
  44870. /**
  44871. * Optional initial tab (default to DebugLayerTab.Properties)
  44872. */
  44873. initialTab?: DebugLayerTab;
  44874. }
  44875. interface Scene {
  44876. /**
  44877. * @hidden
  44878. * Backing field
  44879. */
  44880. _debugLayer: DebugLayer;
  44881. /**
  44882. * Gets the debug layer (aka Inspector) associated with the scene
  44883. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44884. */
  44885. debugLayer: DebugLayer;
  44886. }
  44887. /**
  44888. * Enum of inspector action tab
  44889. */
  44890. export enum DebugLayerTab {
  44891. /**
  44892. * Properties tag (default)
  44893. */
  44894. Properties = 0,
  44895. /**
  44896. * Debug tab
  44897. */
  44898. Debug = 1,
  44899. /**
  44900. * Statistics tab
  44901. */
  44902. Statistics = 2,
  44903. /**
  44904. * Tools tab
  44905. */
  44906. Tools = 3,
  44907. /**
  44908. * Settings tab
  44909. */
  44910. Settings = 4
  44911. }
  44912. /**
  44913. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44914. * what is happening in your scene
  44915. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44916. */
  44917. export class DebugLayer {
  44918. /**
  44919. * Define the url to get the inspector script from.
  44920. * By default it uses the babylonjs CDN.
  44921. * @ignoreNaming
  44922. */
  44923. static InspectorURL: string;
  44924. private _scene;
  44925. private BJSINSPECTOR;
  44926. private _onPropertyChangedObservable?;
  44927. /**
  44928. * Observable triggered when a property is changed through the inspector.
  44929. */
  44930. readonly onPropertyChangedObservable: any;
  44931. /**
  44932. * Instantiates a new debug layer.
  44933. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44934. * what is happening in your scene
  44935. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44936. * @param scene Defines the scene to inspect
  44937. */
  44938. constructor(scene: Scene);
  44939. /** Creates the inspector window. */
  44940. private _createInspector;
  44941. /**
  44942. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44943. * @param entity defines the entity to select
  44944. * @param lineContainerTitle defines the specific block to highlight
  44945. */
  44946. select(entity: any, lineContainerTitle?: string): void;
  44947. /** Get the inspector from bundle or global */
  44948. private _getGlobalInspector;
  44949. /**
  44950. * Get if the inspector is visible or not.
  44951. * @returns true if visible otherwise, false
  44952. */
  44953. isVisible(): boolean;
  44954. /**
  44955. * Hide the inspector and close its window.
  44956. */
  44957. hide(): void;
  44958. /**
  44959. * Launch the debugLayer.
  44960. * @param config Define the configuration of the inspector
  44961. * @return a promise fulfilled when the debug layer is visible
  44962. */
  44963. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44964. }
  44965. }
  44966. declare module BABYLON {
  44967. /**
  44968. * Class containing static functions to help procedurally build meshes
  44969. */
  44970. export class BoxBuilder {
  44971. /**
  44972. * Creates a box mesh
  44973. * * The parameter `size` sets the size (float) of each box side (default 1)
  44974. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44975. * * 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)
  44976. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44978. * * 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
  44979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44980. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44981. * @param name defines the name of the mesh
  44982. * @param options defines the options used to create the mesh
  44983. * @param scene defines the hosting scene
  44984. * @returns the box mesh
  44985. */
  44986. static CreateBox(name: string, options: {
  44987. size?: number;
  44988. width?: number;
  44989. height?: number;
  44990. depth?: number;
  44991. faceUV?: Vector4[];
  44992. faceColors?: Color4[];
  44993. sideOrientation?: number;
  44994. frontUVs?: Vector4;
  44995. backUVs?: Vector4;
  44996. wrap?: boolean;
  44997. topBaseAt?: number;
  44998. bottomBaseAt?: number;
  44999. updatable?: boolean;
  45000. }, scene?: Nullable<Scene>): Mesh;
  45001. }
  45002. }
  45003. declare module BABYLON {
  45004. /**
  45005. * Class containing static functions to help procedurally build meshes
  45006. */
  45007. export class SphereBuilder {
  45008. /**
  45009. * Creates a sphere mesh
  45010. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45011. * * 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`)
  45012. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45013. * * 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
  45014. * * 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)
  45015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45016. * * 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
  45017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45018. * @param name defines the name of the mesh
  45019. * @param options defines the options used to create the mesh
  45020. * @param scene defines the hosting scene
  45021. * @returns the sphere mesh
  45022. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45023. */
  45024. static CreateSphere(name: string, options: {
  45025. segments?: number;
  45026. diameter?: number;
  45027. diameterX?: number;
  45028. diameterY?: number;
  45029. diameterZ?: number;
  45030. arc?: number;
  45031. slice?: number;
  45032. sideOrientation?: number;
  45033. frontUVs?: Vector4;
  45034. backUVs?: Vector4;
  45035. updatable?: boolean;
  45036. }, scene?: Nullable<Scene>): Mesh;
  45037. }
  45038. }
  45039. declare module BABYLON.Debug {
  45040. /**
  45041. * Used to show the physics impostor around the specific mesh
  45042. */
  45043. export class PhysicsViewer {
  45044. /** @hidden */
  45045. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45046. /** @hidden */
  45047. protected _meshes: Array<Nullable<AbstractMesh>>;
  45048. /** @hidden */
  45049. protected _scene: Nullable<Scene>;
  45050. /** @hidden */
  45051. protected _numMeshes: number;
  45052. /** @hidden */
  45053. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45054. private _renderFunction;
  45055. private _utilityLayer;
  45056. private _debugBoxMesh;
  45057. private _debugSphereMesh;
  45058. private _debugCylinderMesh;
  45059. private _debugMaterial;
  45060. private _debugMeshMeshes;
  45061. /**
  45062. * Creates a new PhysicsViewer
  45063. * @param scene defines the hosting scene
  45064. */
  45065. constructor(scene: Scene);
  45066. /** @hidden */
  45067. protected _updateDebugMeshes(): void;
  45068. /**
  45069. * Renders a specified physic impostor
  45070. * @param impostor defines the impostor to render
  45071. * @param targetMesh defines the mesh represented by the impostor
  45072. * @returns the new debug mesh used to render the impostor
  45073. */
  45074. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45075. /**
  45076. * Hides a specified physic impostor
  45077. * @param impostor defines the impostor to hide
  45078. */
  45079. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45080. private _getDebugMaterial;
  45081. private _getDebugBoxMesh;
  45082. private _getDebugSphereMesh;
  45083. private _getDebugCylinderMesh;
  45084. private _getDebugMeshMesh;
  45085. private _getDebugMesh;
  45086. /** Releases all resources */
  45087. dispose(): void;
  45088. }
  45089. }
  45090. declare module BABYLON {
  45091. /**
  45092. * Class containing static functions to help procedurally build meshes
  45093. */
  45094. export class LinesBuilder {
  45095. /**
  45096. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45097. * * 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
  45098. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45099. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45100. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45101. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45102. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45103. * * 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
  45104. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45107. * @param name defines the name of the new line system
  45108. * @param options defines the options used to create the line system
  45109. * @param scene defines the hosting scene
  45110. * @returns a new line system mesh
  45111. */
  45112. static CreateLineSystem(name: string, options: {
  45113. lines: Vector3[][];
  45114. updatable?: boolean;
  45115. instance?: Nullable<LinesMesh>;
  45116. colors?: Nullable<Color4[][]>;
  45117. useVertexAlpha?: boolean;
  45118. }, scene: Nullable<Scene>): LinesMesh;
  45119. /**
  45120. * Creates a line mesh
  45121. * 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
  45122. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45123. * * The parameter `points` is an array successive Vector3
  45124. * * 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
  45125. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45126. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45127. * * When updating an instance, remember that only point positions can change, not the number of points
  45128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45130. * @param name defines the name of the new line system
  45131. * @param options defines the options used to create the line system
  45132. * @param scene defines the hosting scene
  45133. * @returns a new line mesh
  45134. */
  45135. static CreateLines(name: string, options: {
  45136. points: Vector3[];
  45137. updatable?: boolean;
  45138. instance?: Nullable<LinesMesh>;
  45139. colors?: Color4[];
  45140. useVertexAlpha?: boolean;
  45141. }, scene?: Nullable<Scene>): LinesMesh;
  45142. /**
  45143. * Creates a dashed line mesh
  45144. * * 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
  45145. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45146. * * The parameter `points` is an array successive Vector3
  45147. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45148. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45149. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45150. * * 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
  45151. * * When updating an instance, remember that only point positions can change, not the number of points
  45152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45153. * @param name defines the name of the mesh
  45154. * @param options defines the options used to create the mesh
  45155. * @param scene defines the hosting scene
  45156. * @returns the dashed line mesh
  45157. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45158. */
  45159. static CreateDashedLines(name: string, options: {
  45160. points: Vector3[];
  45161. dashSize?: number;
  45162. gapSize?: number;
  45163. dashNb?: number;
  45164. updatable?: boolean;
  45165. instance?: LinesMesh;
  45166. }, scene?: Nullable<Scene>): LinesMesh;
  45167. }
  45168. }
  45169. declare module BABYLON {
  45170. /**
  45171. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45172. * in order to better appreciate the issue one might have.
  45173. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45174. */
  45175. export class RayHelper {
  45176. /**
  45177. * Defines the ray we are currently tryin to visualize.
  45178. */
  45179. ray: Nullable<Ray>;
  45180. private _renderPoints;
  45181. private _renderLine;
  45182. private _renderFunction;
  45183. private _scene;
  45184. private _updateToMeshFunction;
  45185. private _attachedToMesh;
  45186. private _meshSpaceDirection;
  45187. private _meshSpaceOrigin;
  45188. /**
  45189. * Helper function to create a colored helper in a scene in one line.
  45190. * @param ray Defines the ray we are currently tryin to visualize
  45191. * @param scene Defines the scene the ray is used in
  45192. * @param color Defines the color we want to see the ray in
  45193. * @returns The newly created ray helper.
  45194. */
  45195. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45196. /**
  45197. * Instantiate a new ray helper.
  45198. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45199. * in order to better appreciate the issue one might have.
  45200. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45201. * @param ray Defines the ray we are currently tryin to visualize
  45202. */
  45203. constructor(ray: Ray);
  45204. /**
  45205. * Shows the ray we are willing to debug.
  45206. * @param scene Defines the scene the ray needs to be rendered in
  45207. * @param color Defines the color the ray needs to be rendered in
  45208. */
  45209. show(scene: Scene, color?: Color3): void;
  45210. /**
  45211. * Hides the ray we are debugging.
  45212. */
  45213. hide(): void;
  45214. private _render;
  45215. /**
  45216. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45217. * @param mesh Defines the mesh we want the helper attached to
  45218. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45219. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45220. * @param length Defines the length of the ray
  45221. */
  45222. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45223. /**
  45224. * Detach the ray helper from the mesh it has previously been attached to.
  45225. */
  45226. detachFromMesh(): void;
  45227. private _updateToMesh;
  45228. /**
  45229. * Dispose the helper and release its associated resources.
  45230. */
  45231. dispose(): void;
  45232. }
  45233. }
  45234. declare module BABYLON.Debug {
  45235. /**
  45236. * Class used to render a debug view of a given skeleton
  45237. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45238. */
  45239. export class SkeletonViewer {
  45240. /** defines the skeleton to render */
  45241. skeleton: Skeleton;
  45242. /** defines the mesh attached to the skeleton */
  45243. mesh: AbstractMesh;
  45244. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45245. autoUpdateBonesMatrices: boolean;
  45246. /** defines the rendering group id to use with the viewer */
  45247. renderingGroupId: number;
  45248. /** Gets or sets the color used to render the skeleton */
  45249. color: Color3;
  45250. private _scene;
  45251. private _debugLines;
  45252. private _debugMesh;
  45253. private _isEnabled;
  45254. private _renderFunction;
  45255. private _utilityLayer;
  45256. /**
  45257. * Returns the mesh used to render the bones
  45258. */
  45259. readonly debugMesh: Nullable<LinesMesh>;
  45260. /**
  45261. * Creates a new SkeletonViewer
  45262. * @param skeleton defines the skeleton to render
  45263. * @param mesh defines the mesh attached to the skeleton
  45264. * @param scene defines the hosting scene
  45265. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45266. * @param renderingGroupId defines the rendering group id to use with the viewer
  45267. */
  45268. constructor(
  45269. /** defines the skeleton to render */
  45270. skeleton: Skeleton,
  45271. /** defines the mesh attached to the skeleton */
  45272. mesh: AbstractMesh, scene: Scene,
  45273. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45274. autoUpdateBonesMatrices?: boolean,
  45275. /** defines the rendering group id to use with the viewer */
  45276. renderingGroupId?: number);
  45277. /** Gets or sets a boolean indicating if the viewer is enabled */
  45278. isEnabled: boolean;
  45279. private _getBonePosition;
  45280. private _getLinesForBonesWithLength;
  45281. private _getLinesForBonesNoLength;
  45282. /** Update the viewer to sync with current skeleton state */
  45283. update(): void;
  45284. /** Release associated resources */
  45285. dispose(): void;
  45286. }
  45287. }
  45288. declare module BABYLON {
  45289. /**
  45290. * Options to create the null engine
  45291. */
  45292. export class NullEngineOptions {
  45293. /**
  45294. * Render width (Default: 512)
  45295. */
  45296. renderWidth: number;
  45297. /**
  45298. * Render height (Default: 256)
  45299. */
  45300. renderHeight: number;
  45301. /**
  45302. * Texture size (Default: 512)
  45303. */
  45304. textureSize: number;
  45305. /**
  45306. * If delta time between frames should be constant
  45307. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45308. */
  45309. deterministicLockstep: boolean;
  45310. /**
  45311. * Maximum about of steps between frames (Default: 4)
  45312. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45313. */
  45314. lockstepMaxSteps: number;
  45315. }
  45316. /**
  45317. * The null engine class provides support for headless version of babylon.js.
  45318. * This can be used in server side scenario or for testing purposes
  45319. */
  45320. export class NullEngine extends Engine {
  45321. private _options;
  45322. /**
  45323. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45324. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45325. * @returns true if engine is in deterministic lock step mode
  45326. */
  45327. isDeterministicLockStep(): boolean;
  45328. /**
  45329. * Gets the max steps when engine is running in deterministic lock step
  45330. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45331. * @returns the max steps
  45332. */
  45333. getLockstepMaxSteps(): number;
  45334. /**
  45335. * Gets the current hardware scaling level.
  45336. * By default the hardware scaling level is computed from the window device ratio.
  45337. * 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.
  45338. * @returns a number indicating the current hardware scaling level
  45339. */
  45340. getHardwareScalingLevel(): number;
  45341. constructor(options?: NullEngineOptions);
  45342. /**
  45343. * Creates a vertex buffer
  45344. * @param vertices the data for the vertex buffer
  45345. * @returns the new WebGL static buffer
  45346. */
  45347. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45348. /**
  45349. * Creates a new index buffer
  45350. * @param indices defines the content of the index buffer
  45351. * @param updatable defines if the index buffer must be updatable
  45352. * @returns a new webGL buffer
  45353. */
  45354. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45355. /**
  45356. * Clear the current render buffer or the current render target (if any is set up)
  45357. * @param color defines the color to use
  45358. * @param backBuffer defines if the back buffer must be cleared
  45359. * @param depth defines if the depth buffer must be cleared
  45360. * @param stencil defines if the stencil buffer must be cleared
  45361. */
  45362. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45363. /**
  45364. * Gets the current render width
  45365. * @param useScreen defines if screen size must be used (or the current render target if any)
  45366. * @returns a number defining the current render width
  45367. */
  45368. getRenderWidth(useScreen?: boolean): number;
  45369. /**
  45370. * Gets the current render height
  45371. * @param useScreen defines if screen size must be used (or the current render target if any)
  45372. * @returns a number defining the current render height
  45373. */
  45374. getRenderHeight(useScreen?: boolean): number;
  45375. /**
  45376. * Set the WebGL's viewport
  45377. * @param viewport defines the viewport element to be used
  45378. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45379. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45380. */
  45381. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45382. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45383. /**
  45384. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45385. * @param pipelineContext defines the pipeline context to use
  45386. * @param uniformsNames defines the list of uniform names
  45387. * @returns an array of webGL uniform locations
  45388. */
  45389. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45390. /**
  45391. * Gets the lsit of active attributes for a given webGL program
  45392. * @param pipelineContext defines the pipeline context to use
  45393. * @param attributesNames defines the list of attribute names to get
  45394. * @returns an array of indices indicating the offset of each attribute
  45395. */
  45396. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45397. /**
  45398. * Binds an effect to the webGL context
  45399. * @param effect defines the effect to bind
  45400. */
  45401. bindSamplers(effect: Effect): void;
  45402. /**
  45403. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45404. * @param effect defines the effect to activate
  45405. */
  45406. enableEffect(effect: Effect): void;
  45407. /**
  45408. * Set various states to the webGL context
  45409. * @param culling defines backface culling state
  45410. * @param zOffset defines the value to apply to zOffset (0 by default)
  45411. * @param force defines if states must be applied even if cache is up to date
  45412. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45413. */
  45414. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45415. /**
  45416. * Set the value of an uniform to an array of int32
  45417. * @param uniform defines the webGL uniform location where to store the value
  45418. * @param array defines the array of int32 to store
  45419. */
  45420. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45421. /**
  45422. * Set the value of an uniform to an array of int32 (stored as vec2)
  45423. * @param uniform defines the webGL uniform location where to store the value
  45424. * @param array defines the array of int32 to store
  45425. */
  45426. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45427. /**
  45428. * Set the value of an uniform to an array of int32 (stored as vec3)
  45429. * @param uniform defines the webGL uniform location where to store the value
  45430. * @param array defines the array of int32 to store
  45431. */
  45432. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45433. /**
  45434. * Set the value of an uniform to an array of int32 (stored as vec4)
  45435. * @param uniform defines the webGL uniform location where to store the value
  45436. * @param array defines the array of int32 to store
  45437. */
  45438. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45439. /**
  45440. * Set the value of an uniform to an array of float32
  45441. * @param uniform defines the webGL uniform location where to store the value
  45442. * @param array defines the array of float32 to store
  45443. */
  45444. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45445. /**
  45446. * Set the value of an uniform to an array of float32 (stored as vec2)
  45447. * @param uniform defines the webGL uniform location where to store the value
  45448. * @param array defines the array of float32 to store
  45449. */
  45450. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45451. /**
  45452. * Set the value of an uniform to an array of float32 (stored as vec3)
  45453. * @param uniform defines the webGL uniform location where to store the value
  45454. * @param array defines the array of float32 to store
  45455. */
  45456. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45457. /**
  45458. * Set the value of an uniform to an array of float32 (stored as vec4)
  45459. * @param uniform defines the webGL uniform location where to store the value
  45460. * @param array defines the array of float32 to store
  45461. */
  45462. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45463. /**
  45464. * Set the value of an uniform to an array of number
  45465. * @param uniform defines the webGL uniform location where to store the value
  45466. * @param array defines the array of number to store
  45467. */
  45468. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45469. /**
  45470. * Set the value of an uniform to an array of number (stored as vec2)
  45471. * @param uniform defines the webGL uniform location where to store the value
  45472. * @param array defines the array of number to store
  45473. */
  45474. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45475. /**
  45476. * Set the value of an uniform to an array of number (stored as vec3)
  45477. * @param uniform defines the webGL uniform location where to store the value
  45478. * @param array defines the array of number to store
  45479. */
  45480. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45481. /**
  45482. * Set the value of an uniform to an array of number (stored as vec4)
  45483. * @param uniform defines the webGL uniform location where to store the value
  45484. * @param array defines the array of number to store
  45485. */
  45486. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45487. /**
  45488. * Set the value of an uniform to an array of float32 (stored as matrices)
  45489. * @param uniform defines the webGL uniform location where to store the value
  45490. * @param matrices defines the array of float32 to store
  45491. */
  45492. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45493. /**
  45494. * Set the value of an uniform to a matrix (3x3)
  45495. * @param uniform defines the webGL uniform location where to store the value
  45496. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45497. */
  45498. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45499. /**
  45500. * Set the value of an uniform to a matrix (2x2)
  45501. * @param uniform defines the webGL uniform location where to store the value
  45502. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45503. */
  45504. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45505. /**
  45506. * Set the value of an uniform to a number (float)
  45507. * @param uniform defines the webGL uniform location where to store the value
  45508. * @param value defines the float number to store
  45509. */
  45510. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45511. /**
  45512. * Set the value of an uniform to a vec2
  45513. * @param uniform defines the webGL uniform location where to store the value
  45514. * @param x defines the 1st component of the value
  45515. * @param y defines the 2nd component of the value
  45516. */
  45517. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45518. /**
  45519. * Set the value of an uniform to a vec3
  45520. * @param uniform defines the webGL uniform location where to store the value
  45521. * @param x defines the 1st component of the value
  45522. * @param y defines the 2nd component of the value
  45523. * @param z defines the 3rd component of the value
  45524. */
  45525. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45526. /**
  45527. * Set the value of an uniform to a boolean
  45528. * @param uniform defines the webGL uniform location where to store the value
  45529. * @param bool defines the boolean to store
  45530. */
  45531. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45532. /**
  45533. * Set the value of an uniform to a vec4
  45534. * @param uniform defines the webGL uniform location where to store the value
  45535. * @param x defines the 1st component of the value
  45536. * @param y defines the 2nd component of the value
  45537. * @param z defines the 3rd component of the value
  45538. * @param w defines the 4th component of the value
  45539. */
  45540. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45541. /**
  45542. * Sets the current alpha mode
  45543. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45544. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45545. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45546. */
  45547. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45548. /**
  45549. * Bind webGl buffers directly to the webGL context
  45550. * @param vertexBuffers defines the vertex buffer to bind
  45551. * @param indexBuffer defines the index buffer to bind
  45552. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45553. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45554. * @param effect defines the effect associated with the vertex buffer
  45555. */
  45556. bindBuffers(vertexBuffers: {
  45557. [key: string]: VertexBuffer;
  45558. }, indexBuffer: DataBuffer, effect: Effect): void;
  45559. /**
  45560. * Force the entire cache to be cleared
  45561. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45562. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45563. */
  45564. wipeCaches(bruteForce?: boolean): void;
  45565. /**
  45566. * Send a draw order
  45567. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45568. * @param indexStart defines the starting index
  45569. * @param indexCount defines the number of index to draw
  45570. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45571. */
  45572. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45573. /**
  45574. * Draw a list of indexed primitives
  45575. * @param fillMode defines the primitive to use
  45576. * @param indexStart defines the starting index
  45577. * @param indexCount defines the number of index to draw
  45578. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45579. */
  45580. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45581. /**
  45582. * Draw a list of unindexed primitives
  45583. * @param fillMode defines the primitive to use
  45584. * @param verticesStart defines the index of first vertex to draw
  45585. * @param verticesCount defines the count of vertices to draw
  45586. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45587. */
  45588. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45589. /** @hidden */
  45590. _createTexture(): WebGLTexture;
  45591. /** @hidden */
  45592. _releaseTexture(texture: InternalTexture): void;
  45593. /**
  45594. * Usually called from Texture.ts.
  45595. * Passed information to create a WebGLTexture
  45596. * @param urlArg defines a value which contains one of the following:
  45597. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45598. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45599. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45600. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45601. * @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)
  45602. * @param scene needed for loading to the correct scene
  45603. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45604. * @param onLoad optional callback to be called upon successful completion
  45605. * @param onError optional callback to be called upon failure
  45606. * @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
  45607. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45608. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45609. * @param forcedExtension defines the extension to use to pick the right loader
  45610. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45611. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45612. */
  45613. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  45614. /**
  45615. * Creates a new render target texture
  45616. * @param size defines the size of the texture
  45617. * @param options defines the options used to create the texture
  45618. * @returns a new render target texture stored in an InternalTexture
  45619. */
  45620. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45621. /**
  45622. * Update the sampling mode of a given texture
  45623. * @param samplingMode defines the required sampling mode
  45624. * @param texture defines the texture to update
  45625. */
  45626. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45627. /**
  45628. * Binds the frame buffer to the specified texture.
  45629. * @param texture The texture to render to or null for the default canvas
  45630. * @param faceIndex The face of the texture to render to in case of cube texture
  45631. * @param requiredWidth The width of the target to render to
  45632. * @param requiredHeight The height of the target to render to
  45633. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45634. * @param depthStencilTexture The depth stencil texture to use to render
  45635. * @param lodLevel defines le lod level to bind to the frame buffer
  45636. */
  45637. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45638. /**
  45639. * Unbind the current render target texture from the webGL context
  45640. * @param texture defines the render target texture to unbind
  45641. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45642. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45643. */
  45644. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45645. /**
  45646. * Creates a dynamic vertex buffer
  45647. * @param vertices the data for the dynamic vertex buffer
  45648. * @returns the new WebGL dynamic buffer
  45649. */
  45650. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45651. /**
  45652. * Update the content of a dynamic texture
  45653. * @param texture defines the texture to update
  45654. * @param canvas defines the canvas containing the source
  45655. * @param invertY defines if data must be stored with Y axis inverted
  45656. * @param premulAlpha defines if alpha is stored as premultiplied
  45657. * @param format defines the format of the data
  45658. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45659. */
  45660. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45661. /**
  45662. * Gets a boolean indicating if all created effects are ready
  45663. * @returns true if all effects are ready
  45664. */
  45665. areAllEffectsReady(): boolean;
  45666. /**
  45667. * @hidden
  45668. * Get the current error code of the webGL context
  45669. * @returns the error code
  45670. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45671. */
  45672. getError(): number;
  45673. /** @hidden */
  45674. _getUnpackAlignement(): number;
  45675. /** @hidden */
  45676. _unpackFlipY(value: boolean): void;
  45677. /**
  45678. * Update a dynamic index buffer
  45679. * @param indexBuffer defines the target index buffer
  45680. * @param indices defines the data to update
  45681. * @param offset defines the offset in the target index buffer where update should start
  45682. */
  45683. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45684. /**
  45685. * Updates a dynamic vertex buffer.
  45686. * @param vertexBuffer the vertex buffer to update
  45687. * @param vertices the data used to update the vertex buffer
  45688. * @param byteOffset the byte offset of the data (optional)
  45689. * @param byteLength the byte length of the data (optional)
  45690. */
  45691. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45692. /** @hidden */
  45693. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45694. /** @hidden */
  45695. _bindTexture(channel: number, texture: InternalTexture): void;
  45696. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45697. /**
  45698. * 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
  45699. */
  45700. releaseEffects(): void;
  45701. displayLoadingUI(): void;
  45702. hideLoadingUI(): void;
  45703. /** @hidden */
  45704. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45705. /** @hidden */
  45706. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45707. /** @hidden */
  45708. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45709. /** @hidden */
  45710. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45711. }
  45712. }
  45713. declare module BABYLON {
  45714. /** @hidden */
  45715. export class _OcclusionDataStorage {
  45716. /** @hidden */
  45717. occlusionInternalRetryCounter: number;
  45718. /** @hidden */
  45719. isOcclusionQueryInProgress: boolean;
  45720. /** @hidden */
  45721. isOccluded: boolean;
  45722. /** @hidden */
  45723. occlusionRetryCount: number;
  45724. /** @hidden */
  45725. occlusionType: number;
  45726. /** @hidden */
  45727. occlusionQueryAlgorithmType: number;
  45728. }
  45729. interface Engine {
  45730. /**
  45731. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45732. * @return the new query
  45733. */
  45734. createQuery(): WebGLQuery;
  45735. /**
  45736. * Delete and release a webGL query
  45737. * @param query defines the query to delete
  45738. * @return the current engine
  45739. */
  45740. deleteQuery(query: WebGLQuery): Engine;
  45741. /**
  45742. * Check if a given query has resolved and got its value
  45743. * @param query defines the query to check
  45744. * @returns true if the query got its value
  45745. */
  45746. isQueryResultAvailable(query: WebGLQuery): boolean;
  45747. /**
  45748. * Gets the value of a given query
  45749. * @param query defines the query to check
  45750. * @returns the value of the query
  45751. */
  45752. getQueryResult(query: WebGLQuery): number;
  45753. /**
  45754. * Initiates an occlusion query
  45755. * @param algorithmType defines the algorithm to use
  45756. * @param query defines the query to use
  45757. * @returns the current engine
  45758. * @see http://doc.babylonjs.com/features/occlusionquery
  45759. */
  45760. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45761. /**
  45762. * Ends an occlusion query
  45763. * @see http://doc.babylonjs.com/features/occlusionquery
  45764. * @param algorithmType defines the algorithm to use
  45765. * @returns the current engine
  45766. */
  45767. endOcclusionQuery(algorithmType: number): Engine;
  45768. /**
  45769. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45770. * Please note that only one query can be issued at a time
  45771. * @returns a time token used to track the time span
  45772. */
  45773. startTimeQuery(): Nullable<_TimeToken>;
  45774. /**
  45775. * Ends a time query
  45776. * @param token defines the token used to measure the time span
  45777. * @returns the time spent (in ns)
  45778. */
  45779. endTimeQuery(token: _TimeToken): int;
  45780. /** @hidden */
  45781. _currentNonTimestampToken: Nullable<_TimeToken>;
  45782. /** @hidden */
  45783. _createTimeQuery(): WebGLQuery;
  45784. /** @hidden */
  45785. _deleteTimeQuery(query: WebGLQuery): void;
  45786. /** @hidden */
  45787. _getGlAlgorithmType(algorithmType: number): number;
  45788. /** @hidden */
  45789. _getTimeQueryResult(query: WebGLQuery): any;
  45790. /** @hidden */
  45791. _getTimeQueryAvailability(query: WebGLQuery): any;
  45792. }
  45793. interface AbstractMesh {
  45794. /**
  45795. * Backing filed
  45796. * @hidden
  45797. */
  45798. __occlusionDataStorage: _OcclusionDataStorage;
  45799. /**
  45800. * Access property
  45801. * @hidden
  45802. */
  45803. _occlusionDataStorage: _OcclusionDataStorage;
  45804. /**
  45805. * 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.
  45806. * The default value is -1 which means don't break the query and wait till the result
  45807. * @see http://doc.babylonjs.com/features/occlusionquery
  45808. */
  45809. occlusionRetryCount: number;
  45810. /**
  45811. * 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:
  45812. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45813. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45814. * * 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.
  45815. * @see http://doc.babylonjs.com/features/occlusionquery
  45816. */
  45817. occlusionType: number;
  45818. /**
  45819. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45820. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45821. * * 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.
  45822. * @see http://doc.babylonjs.com/features/occlusionquery
  45823. */
  45824. occlusionQueryAlgorithmType: number;
  45825. /**
  45826. * 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
  45827. * @see http://doc.babylonjs.com/features/occlusionquery
  45828. */
  45829. isOccluded: boolean;
  45830. /**
  45831. * Flag to check the progress status of the query
  45832. * @see http://doc.babylonjs.com/features/occlusionquery
  45833. */
  45834. isOcclusionQueryInProgress: boolean;
  45835. }
  45836. }
  45837. declare module BABYLON {
  45838. /** @hidden */
  45839. export var _forceTransformFeedbackToBundle: boolean;
  45840. interface Engine {
  45841. /**
  45842. * Creates a webGL transform feedback object
  45843. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45844. * @returns the webGL transform feedback object
  45845. */
  45846. createTransformFeedback(): WebGLTransformFeedback;
  45847. /**
  45848. * Delete a webGL transform feedback object
  45849. * @param value defines the webGL transform feedback object to delete
  45850. */
  45851. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45852. /**
  45853. * Bind a webGL transform feedback object to the webgl context
  45854. * @param value defines the webGL transform feedback object to bind
  45855. */
  45856. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45857. /**
  45858. * Begins a transform feedback operation
  45859. * @param usePoints defines if points or triangles must be used
  45860. */
  45861. beginTransformFeedback(usePoints: boolean): void;
  45862. /**
  45863. * Ends a transform feedback operation
  45864. */
  45865. endTransformFeedback(): void;
  45866. /**
  45867. * Specify the varyings to use with transform feedback
  45868. * @param program defines the associated webGL program
  45869. * @param value defines the list of strings representing the varying names
  45870. */
  45871. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45872. /**
  45873. * Bind a webGL buffer for a transform feedback operation
  45874. * @param value defines the webGL buffer to bind
  45875. */
  45876. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45877. }
  45878. }
  45879. declare module BABYLON {
  45880. /**
  45881. * Creation options of the multi render target texture.
  45882. */
  45883. export interface IMultiRenderTargetOptions {
  45884. /**
  45885. * Define if the texture needs to create mip maps after render.
  45886. */
  45887. generateMipMaps?: boolean;
  45888. /**
  45889. * Define the types of all the draw buffers we want to create
  45890. */
  45891. types?: number[];
  45892. /**
  45893. * Define the sampling modes of all the draw buffers we want to create
  45894. */
  45895. samplingModes?: number[];
  45896. /**
  45897. * Define if a depth buffer is required
  45898. */
  45899. generateDepthBuffer?: boolean;
  45900. /**
  45901. * Define if a stencil buffer is required
  45902. */
  45903. generateStencilBuffer?: boolean;
  45904. /**
  45905. * Define if a depth texture is required instead of a depth buffer
  45906. */
  45907. generateDepthTexture?: boolean;
  45908. /**
  45909. * Define the number of desired draw buffers
  45910. */
  45911. textureCount?: number;
  45912. /**
  45913. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45914. */
  45915. doNotChangeAspectRatio?: boolean;
  45916. /**
  45917. * Define the default type of the buffers we are creating
  45918. */
  45919. defaultType?: number;
  45920. }
  45921. /**
  45922. * A multi render target, like a render target provides the ability to render to a texture.
  45923. * Unlike the render target, it can render to several draw buffers in one draw.
  45924. * This is specially interesting in deferred rendering or for any effects requiring more than
  45925. * just one color from a single pass.
  45926. */
  45927. export class MultiRenderTarget extends RenderTargetTexture {
  45928. private _internalTextures;
  45929. private _textures;
  45930. private _multiRenderTargetOptions;
  45931. /**
  45932. * Get if draw buffers are currently supported by the used hardware and browser.
  45933. */
  45934. readonly isSupported: boolean;
  45935. /**
  45936. * Get the list of textures generated by the multi render target.
  45937. */
  45938. readonly textures: Texture[];
  45939. /**
  45940. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45941. */
  45942. readonly depthTexture: Texture;
  45943. /**
  45944. * Set the wrapping mode on U of all the textures we are rendering to.
  45945. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45946. */
  45947. wrapU: number;
  45948. /**
  45949. * Set the wrapping mode on V of all the textures we are rendering to.
  45950. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45951. */
  45952. wrapV: number;
  45953. /**
  45954. * Instantiate a new multi render target texture.
  45955. * A multi render target, like a render target provides the ability to render to a texture.
  45956. * Unlike the render target, it can render to several draw buffers in one draw.
  45957. * This is specially interesting in deferred rendering or for any effects requiring more than
  45958. * just one color from a single pass.
  45959. * @param name Define the name of the texture
  45960. * @param size Define the size of the buffers to render to
  45961. * @param count Define the number of target we are rendering into
  45962. * @param scene Define the scene the texture belongs to
  45963. * @param options Define the options used to create the multi render target
  45964. */
  45965. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45966. /** @hidden */
  45967. _rebuild(): void;
  45968. private _createInternalTextures;
  45969. private _createTextures;
  45970. /**
  45971. * Define the number of samples used if MSAA is enabled.
  45972. */
  45973. samples: number;
  45974. /**
  45975. * Resize all the textures in the multi render target.
  45976. * Be carrefull as it will recreate all the data in the new texture.
  45977. * @param size Define the new size
  45978. */
  45979. resize(size: any): void;
  45980. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45981. /**
  45982. * Dispose the render targets and their associated resources
  45983. */
  45984. dispose(): void;
  45985. /**
  45986. * Release all the underlying texture used as draw buffers.
  45987. */
  45988. releaseInternalTextures(): void;
  45989. }
  45990. }
  45991. declare module BABYLON {
  45992. interface ThinEngine {
  45993. /**
  45994. * Unbind a list of render target textures from the webGL context
  45995. * This is used only when drawBuffer extension or webGL2 are active
  45996. * @param textures defines the render target textures to unbind
  45997. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45998. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45999. */
  46000. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46001. /**
  46002. * Create a multi render target texture
  46003. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46004. * @param size defines the size of the texture
  46005. * @param options defines the creation options
  46006. * @returns the cube texture as an InternalTexture
  46007. */
  46008. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46009. /**
  46010. * Update the sample count for a given multiple render target texture
  46011. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46012. * @param textures defines the textures to update
  46013. * @param samples defines the sample count to set
  46014. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46015. */
  46016. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46017. }
  46018. }
  46019. declare module BABYLON {
  46020. /**
  46021. * Class used to define an additional view for the engine
  46022. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46023. */
  46024. export class EngineView {
  46025. /** Defines the canvas where to render the view */
  46026. target: HTMLCanvasElement;
  46027. /** Defines an optional camera used to render the view (will use active camera else) */
  46028. camera?: Camera;
  46029. }
  46030. interface Engine {
  46031. /**
  46032. * Gets or sets the HTML element to use for attaching events
  46033. */
  46034. inputElement: Nullable<HTMLElement>;
  46035. /**
  46036. * Gets the current engine view
  46037. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46038. */
  46039. activeView: Nullable<EngineView>;
  46040. /** Gets or sets the list of views */
  46041. views: EngineView[];
  46042. /**
  46043. * Register a new child canvas
  46044. * @param canvas defines the canvas to register
  46045. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46046. * @returns the associated view
  46047. */
  46048. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46049. /**
  46050. * Remove a registered child canvas
  46051. * @param canvas defines the canvas to remove
  46052. * @returns the current engine
  46053. */
  46054. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46055. }
  46056. }
  46057. declare module BABYLON {
  46058. /**
  46059. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46060. */
  46061. export interface CubeMapInfo {
  46062. /**
  46063. * The pixel array for the front face.
  46064. * This is stored in format, left to right, up to down format.
  46065. */
  46066. front: Nullable<ArrayBufferView>;
  46067. /**
  46068. * The pixel array for the back face.
  46069. * This is stored in format, left to right, up to down format.
  46070. */
  46071. back: Nullable<ArrayBufferView>;
  46072. /**
  46073. * The pixel array for the left face.
  46074. * This is stored in format, left to right, up to down format.
  46075. */
  46076. left: Nullable<ArrayBufferView>;
  46077. /**
  46078. * The pixel array for the right face.
  46079. * This is stored in format, left to right, up to down format.
  46080. */
  46081. right: Nullable<ArrayBufferView>;
  46082. /**
  46083. * The pixel array for the up face.
  46084. * This is stored in format, left to right, up to down format.
  46085. */
  46086. up: Nullable<ArrayBufferView>;
  46087. /**
  46088. * The pixel array for the down face.
  46089. * This is stored in format, left to right, up to down format.
  46090. */
  46091. down: Nullable<ArrayBufferView>;
  46092. /**
  46093. * The size of the cubemap stored.
  46094. *
  46095. * Each faces will be size * size pixels.
  46096. */
  46097. size: number;
  46098. /**
  46099. * The format of the texture.
  46100. *
  46101. * RGBA, RGB.
  46102. */
  46103. format: number;
  46104. /**
  46105. * The type of the texture data.
  46106. *
  46107. * UNSIGNED_INT, FLOAT.
  46108. */
  46109. type: number;
  46110. /**
  46111. * Specifies whether the texture is in gamma space.
  46112. */
  46113. gammaSpace: boolean;
  46114. }
  46115. /**
  46116. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46117. */
  46118. export class PanoramaToCubeMapTools {
  46119. private static FACE_FRONT;
  46120. private static FACE_BACK;
  46121. private static FACE_RIGHT;
  46122. private static FACE_LEFT;
  46123. private static FACE_DOWN;
  46124. private static FACE_UP;
  46125. /**
  46126. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46127. *
  46128. * @param float32Array The source data.
  46129. * @param inputWidth The width of the input panorama.
  46130. * @param inputHeight The height of the input panorama.
  46131. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46132. * @return The cubemap data
  46133. */
  46134. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46135. private static CreateCubemapTexture;
  46136. private static CalcProjectionSpherical;
  46137. }
  46138. }
  46139. declare module BABYLON {
  46140. /**
  46141. * Helper class dealing with the extraction of spherical polynomial dataArray
  46142. * from a cube map.
  46143. */
  46144. export class CubeMapToSphericalPolynomialTools {
  46145. private static FileFaces;
  46146. /**
  46147. * Converts a texture to the according Spherical Polynomial data.
  46148. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46149. *
  46150. * @param texture The texture to extract the information from.
  46151. * @return The Spherical Polynomial data.
  46152. */
  46153. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46154. /**
  46155. * Converts a cubemap to the according Spherical Polynomial data.
  46156. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46157. *
  46158. * @param cubeInfo The Cube map to extract the information from.
  46159. * @return The Spherical Polynomial data.
  46160. */
  46161. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46162. }
  46163. }
  46164. declare module BABYLON {
  46165. interface BaseTexture {
  46166. /**
  46167. * Get the polynomial representation of the texture data.
  46168. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46169. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46170. */
  46171. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46172. }
  46173. }
  46174. declare module BABYLON {
  46175. /** @hidden */
  46176. export var rgbdEncodePixelShader: {
  46177. name: string;
  46178. shader: string;
  46179. };
  46180. }
  46181. declare module BABYLON {
  46182. /** @hidden */
  46183. export var rgbdDecodePixelShader: {
  46184. name: string;
  46185. shader: string;
  46186. };
  46187. }
  46188. declare module BABYLON {
  46189. /**
  46190. * Raw texture data and descriptor sufficient for WebGL texture upload
  46191. */
  46192. export interface EnvironmentTextureInfo {
  46193. /**
  46194. * Version of the environment map
  46195. */
  46196. version: number;
  46197. /**
  46198. * Width of image
  46199. */
  46200. width: number;
  46201. /**
  46202. * Irradiance information stored in the file.
  46203. */
  46204. irradiance: any;
  46205. /**
  46206. * Specular information stored in the file.
  46207. */
  46208. specular: any;
  46209. }
  46210. /**
  46211. * Defines One Image in the file. It requires only the position in the file
  46212. * as well as the length.
  46213. */
  46214. interface BufferImageData {
  46215. /**
  46216. * Length of the image data.
  46217. */
  46218. length: number;
  46219. /**
  46220. * Position of the data from the null terminator delimiting the end of the JSON.
  46221. */
  46222. position: number;
  46223. }
  46224. /**
  46225. * Defines the specular data enclosed in the file.
  46226. * This corresponds to the version 1 of the data.
  46227. */
  46228. export interface EnvironmentTextureSpecularInfoV1 {
  46229. /**
  46230. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46231. */
  46232. specularDataPosition?: number;
  46233. /**
  46234. * This contains all the images data needed to reconstruct the cubemap.
  46235. */
  46236. mipmaps: Array<BufferImageData>;
  46237. /**
  46238. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46239. */
  46240. lodGenerationScale: number;
  46241. }
  46242. /**
  46243. * Sets of helpers addressing the serialization and deserialization of environment texture
  46244. * stored in a BabylonJS env file.
  46245. * Those files are usually stored as .env files.
  46246. */
  46247. export class EnvironmentTextureTools {
  46248. /**
  46249. * Magic number identifying the env file.
  46250. */
  46251. private static _MagicBytes;
  46252. /**
  46253. * Gets the environment info from an env file.
  46254. * @param data The array buffer containing the .env bytes.
  46255. * @returns the environment file info (the json header) if successfully parsed.
  46256. */
  46257. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46258. /**
  46259. * Creates an environment texture from a loaded cube texture.
  46260. * @param texture defines the cube texture to convert in env file
  46261. * @return a promise containing the environment data if succesfull.
  46262. */
  46263. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46264. /**
  46265. * Creates a JSON representation of the spherical data.
  46266. * @param texture defines the texture containing the polynomials
  46267. * @return the JSON representation of the spherical info
  46268. */
  46269. private static _CreateEnvTextureIrradiance;
  46270. /**
  46271. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46272. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46273. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46274. * @return the views described by info providing access to the underlying buffer
  46275. */
  46276. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46277. /**
  46278. * Uploads the texture info contained in the env file to the GPU.
  46279. * @param texture defines the internal texture to upload to
  46280. * @param arrayBuffer defines the buffer cotaining the data to load
  46281. * @param info defines the texture info retrieved through the GetEnvInfo method
  46282. * @returns a promise
  46283. */
  46284. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46285. private static _OnImageReadyAsync;
  46286. /**
  46287. * Uploads the levels of image data to the GPU.
  46288. * @param texture defines the internal texture to upload to
  46289. * @param imageData defines the array buffer views of image data [mipmap][face]
  46290. * @returns a promise
  46291. */
  46292. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46293. /**
  46294. * Uploads spherical polynomials information to the texture.
  46295. * @param texture defines the texture we are trying to upload the information to
  46296. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46297. */
  46298. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46299. /** @hidden */
  46300. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46301. }
  46302. }
  46303. declare module BABYLON {
  46304. /**
  46305. * Contains position and normal vectors for a vertex
  46306. */
  46307. export class PositionNormalVertex {
  46308. /** the position of the vertex (defaut: 0,0,0) */
  46309. position: Vector3;
  46310. /** the normal of the vertex (defaut: 0,1,0) */
  46311. normal: Vector3;
  46312. /**
  46313. * Creates a PositionNormalVertex
  46314. * @param position the position of the vertex (defaut: 0,0,0)
  46315. * @param normal the normal of the vertex (defaut: 0,1,0)
  46316. */
  46317. constructor(
  46318. /** the position of the vertex (defaut: 0,0,0) */
  46319. position?: Vector3,
  46320. /** the normal of the vertex (defaut: 0,1,0) */
  46321. normal?: Vector3);
  46322. /**
  46323. * Clones the PositionNormalVertex
  46324. * @returns the cloned PositionNormalVertex
  46325. */
  46326. clone(): PositionNormalVertex;
  46327. }
  46328. /**
  46329. * Contains position, normal and uv vectors for a vertex
  46330. */
  46331. export class PositionNormalTextureVertex {
  46332. /** the position of the vertex (defaut: 0,0,0) */
  46333. position: Vector3;
  46334. /** the normal of the vertex (defaut: 0,1,0) */
  46335. normal: Vector3;
  46336. /** the uv of the vertex (default: 0,0) */
  46337. uv: Vector2;
  46338. /**
  46339. * Creates a PositionNormalTextureVertex
  46340. * @param position the position of the vertex (defaut: 0,0,0)
  46341. * @param normal the normal of the vertex (defaut: 0,1,0)
  46342. * @param uv the uv of the vertex (default: 0,0)
  46343. */
  46344. constructor(
  46345. /** the position of the vertex (defaut: 0,0,0) */
  46346. position?: Vector3,
  46347. /** the normal of the vertex (defaut: 0,1,0) */
  46348. normal?: Vector3,
  46349. /** the uv of the vertex (default: 0,0) */
  46350. uv?: Vector2);
  46351. /**
  46352. * Clones the PositionNormalTextureVertex
  46353. * @returns the cloned PositionNormalTextureVertex
  46354. */
  46355. clone(): PositionNormalTextureVertex;
  46356. }
  46357. }
  46358. declare module BABYLON {
  46359. /** @hidden */
  46360. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46361. private _genericAttributeLocation;
  46362. private _varyingLocationCount;
  46363. private _varyingLocationMap;
  46364. private _replacements;
  46365. private _textureCount;
  46366. private _uniforms;
  46367. lineProcessor(line: string): string;
  46368. attributeProcessor(attribute: string): string;
  46369. varyingProcessor(varying: string, isFragment: boolean): string;
  46370. uniformProcessor(uniform: string): string;
  46371. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46372. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46373. }
  46374. }
  46375. declare module BABYLON {
  46376. /**
  46377. * Container for accessors for natively-stored mesh data buffers.
  46378. */
  46379. class NativeDataBuffer extends DataBuffer {
  46380. /**
  46381. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46382. */
  46383. nativeIndexBuffer?: any;
  46384. /**
  46385. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46386. */
  46387. nativeVertexBuffer?: any;
  46388. }
  46389. /** @hidden */
  46390. class NativeTexture extends InternalTexture {
  46391. getInternalTexture(): InternalTexture;
  46392. getViewCount(): number;
  46393. }
  46394. /** @hidden */
  46395. export class NativeEngine extends Engine {
  46396. private readonly _native;
  46397. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  46398. private readonly INVALID_HANDLE;
  46399. getHardwareScalingLevel(): number;
  46400. constructor();
  46401. /**
  46402. * Can be used to override the current requestAnimationFrame requester.
  46403. * @hidden
  46404. */
  46405. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46406. /**
  46407. * Override default engine behavior.
  46408. * @param color
  46409. * @param backBuffer
  46410. * @param depth
  46411. * @param stencil
  46412. */
  46413. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46414. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46415. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46416. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46417. recordVertexArrayObject(vertexBuffers: {
  46418. [key: string]: VertexBuffer;
  46419. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46420. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46421. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46422. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46423. /**
  46424. * Draw a list of indexed primitives
  46425. * @param fillMode defines the primitive to use
  46426. * @param indexStart defines the starting index
  46427. * @param indexCount defines the number of index to draw
  46428. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46429. */
  46430. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46431. /**
  46432. * Draw a list of unindexed primitives
  46433. * @param fillMode defines the primitive to use
  46434. * @param verticesStart defines the index of first vertex to draw
  46435. * @param verticesCount defines the count of vertices to draw
  46436. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46437. */
  46438. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46439. createPipelineContext(): IPipelineContext;
  46440. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46441. /** @hidden */
  46442. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46443. /** @hidden */
  46444. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46445. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46446. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46447. protected _setProgram(program: WebGLProgram): void;
  46448. _releaseEffect(effect: Effect): void;
  46449. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46450. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46451. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46452. bindSamplers(effect: Effect): void;
  46453. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46454. getRenderWidth(useScreen?: boolean): number;
  46455. getRenderHeight(useScreen?: boolean): number;
  46456. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46457. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46458. /**
  46459. * Set the z offset to apply to current rendering
  46460. * @param value defines the offset to apply
  46461. */
  46462. setZOffset(value: number): void;
  46463. /**
  46464. * Gets the current value of the zOffset
  46465. * @returns the current zOffset state
  46466. */
  46467. getZOffset(): number;
  46468. /**
  46469. * Enable or disable depth buffering
  46470. * @param enable defines the state to set
  46471. */
  46472. setDepthBuffer(enable: boolean): void;
  46473. /**
  46474. * Gets a boolean indicating if depth writing is enabled
  46475. * @returns the current depth writing state
  46476. */
  46477. getDepthWrite(): boolean;
  46478. /**
  46479. * Enable or disable depth writing
  46480. * @param enable defines the state to set
  46481. */
  46482. setDepthWrite(enable: boolean): void;
  46483. /**
  46484. * Enable or disable color writing
  46485. * @param enable defines the state to set
  46486. */
  46487. setColorWrite(enable: boolean): void;
  46488. /**
  46489. * Gets a boolean indicating if color writing is enabled
  46490. * @returns the current color writing state
  46491. */
  46492. getColorWrite(): boolean;
  46493. /**
  46494. * Sets alpha constants used by some alpha blending modes
  46495. * @param r defines the red component
  46496. * @param g defines the green component
  46497. * @param b defines the blue component
  46498. * @param a defines the alpha component
  46499. */
  46500. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46501. /**
  46502. * Sets the current alpha mode
  46503. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46504. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46505. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46506. */
  46507. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46508. /**
  46509. * Gets the current alpha mode
  46510. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46511. * @returns the current alpha mode
  46512. */
  46513. getAlphaMode(): number;
  46514. setInt(uniform: WebGLUniformLocation, int: number): void;
  46515. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46516. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46517. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46518. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46519. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46520. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46521. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46522. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46523. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46524. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46525. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46526. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46527. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46528. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46529. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46530. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46531. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46532. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46533. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46534. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46535. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46536. wipeCaches(bruteForce?: boolean): void;
  46537. _createTexture(): WebGLTexture;
  46538. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46539. /**
  46540. * Usually called from BABYLON.Texture.ts.
  46541. * Passed information to create a WebGLTexture
  46542. * @param urlArg defines a value which contains one of the following:
  46543. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46544. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46545. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46546. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46547. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46548. * @param scene needed for loading to the correct scene
  46549. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46550. * @param onLoad optional callback to be called upon successful completion
  46551. * @param onError optional callback to be called upon failure
  46552. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46553. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46554. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46555. * @param forcedExtension defines the extension to use to pick the right loader
  46556. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46557. */
  46558. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  46559. /**
  46560. * Creates a cube texture
  46561. * @param rootUrl defines the url where the files to load is located
  46562. * @param scene defines the current scene
  46563. * @param files defines the list of files to load (1 per face)
  46564. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46565. * @param onLoad defines an optional callback raised when the texture is loaded
  46566. * @param onError defines an optional callback raised if there is an issue to load the texture
  46567. * @param format defines the format of the data
  46568. * @param forcedExtension defines the extension to use to pick the right loader
  46569. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46570. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46571. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46572. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46573. * @returns the cube texture as an InternalTexture
  46574. */
  46575. 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;
  46576. private _getSamplingFilter;
  46577. private static _GetNativeTextureFormat;
  46578. createRenderTargetTexture(size: number | {
  46579. width: number;
  46580. height: number;
  46581. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  46582. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46583. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46584. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46585. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46586. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46587. /**
  46588. * Updates a dynamic vertex buffer.
  46589. * @param vertexBuffer the vertex buffer to update
  46590. * @param data the data used to update the vertex buffer
  46591. * @param byteOffset the byte offset of the data (optional)
  46592. * @param byteLength the byte length of the data (optional)
  46593. */
  46594. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46595. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46596. private _updateAnisotropicLevel;
  46597. private _getAddressMode;
  46598. /** @hidden */
  46599. _bindTexture(channel: number, texture: InternalTexture): void;
  46600. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46601. releaseEffects(): void;
  46602. /** @hidden */
  46603. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46604. /** @hidden */
  46605. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46606. /** @hidden */
  46607. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46608. /** @hidden */
  46609. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46610. }
  46611. }
  46612. declare module BABYLON {
  46613. /**
  46614. * Gather the list of clipboard event types as constants.
  46615. */
  46616. export class ClipboardEventTypes {
  46617. /**
  46618. * The clipboard event is fired when a copy command is active (pressed).
  46619. */
  46620. static readonly COPY: number;
  46621. /**
  46622. * The clipboard event is fired when a cut command is active (pressed).
  46623. */
  46624. static readonly CUT: number;
  46625. /**
  46626. * The clipboard event is fired when a paste command is active (pressed).
  46627. */
  46628. static readonly PASTE: number;
  46629. }
  46630. /**
  46631. * This class is used to store clipboard related info for the onClipboardObservable event.
  46632. */
  46633. export class ClipboardInfo {
  46634. /**
  46635. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46636. */
  46637. type: number;
  46638. /**
  46639. * Defines the related dom event
  46640. */
  46641. event: ClipboardEvent;
  46642. /**
  46643. *Creates an instance of ClipboardInfo.
  46644. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46645. * @param event Defines the related dom event
  46646. */
  46647. constructor(
  46648. /**
  46649. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46650. */
  46651. type: number,
  46652. /**
  46653. * Defines the related dom event
  46654. */
  46655. event: ClipboardEvent);
  46656. /**
  46657. * Get the clipboard event's type from the keycode.
  46658. * @param keyCode Defines the keyCode for the current keyboard event.
  46659. * @return {number}
  46660. */
  46661. static GetTypeFromCharacter(keyCode: number): number;
  46662. }
  46663. }
  46664. declare module BABYLON {
  46665. /**
  46666. * Google Daydream controller
  46667. */
  46668. export class DaydreamController extends WebVRController {
  46669. /**
  46670. * Base Url for the controller model.
  46671. */
  46672. static MODEL_BASE_URL: string;
  46673. /**
  46674. * File name for the controller model.
  46675. */
  46676. static MODEL_FILENAME: string;
  46677. /**
  46678. * Gamepad Id prefix used to identify Daydream Controller.
  46679. */
  46680. static readonly GAMEPAD_ID_PREFIX: string;
  46681. /**
  46682. * Creates a new DaydreamController from a gamepad
  46683. * @param vrGamepad the gamepad that the controller should be created from
  46684. */
  46685. constructor(vrGamepad: any);
  46686. /**
  46687. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46688. * @param scene scene in which to add meshes
  46689. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46690. */
  46691. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46692. /**
  46693. * Called once for each button that changed state since the last frame
  46694. * @param buttonIdx Which button index changed
  46695. * @param state New state of the button
  46696. * @param changes Which properties on the state changed since last frame
  46697. */
  46698. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46699. }
  46700. }
  46701. declare module BABYLON {
  46702. /**
  46703. * Gear VR Controller
  46704. */
  46705. export class GearVRController extends WebVRController {
  46706. /**
  46707. * Base Url for the controller model.
  46708. */
  46709. static MODEL_BASE_URL: string;
  46710. /**
  46711. * File name for the controller model.
  46712. */
  46713. static MODEL_FILENAME: string;
  46714. /**
  46715. * Gamepad Id prefix used to identify this controller.
  46716. */
  46717. static readonly GAMEPAD_ID_PREFIX: string;
  46718. private readonly _buttonIndexToObservableNameMap;
  46719. /**
  46720. * Creates a new GearVRController from a gamepad
  46721. * @param vrGamepad the gamepad that the controller should be created from
  46722. */
  46723. constructor(vrGamepad: any);
  46724. /**
  46725. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46726. * @param scene scene in which to add meshes
  46727. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46728. */
  46729. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46730. /**
  46731. * Called once for each button that changed state since the last frame
  46732. * @param buttonIdx Which button index changed
  46733. * @param state New state of the button
  46734. * @param changes Which properties on the state changed since last frame
  46735. */
  46736. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46737. }
  46738. }
  46739. declare module BABYLON {
  46740. /**
  46741. * Class containing static functions to help procedurally build meshes
  46742. */
  46743. export class PolyhedronBuilder {
  46744. /**
  46745. * Creates a polyhedron mesh
  46746. * * 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
  46747. * * The parameter `size` (positive float, default 1) sets the polygon size
  46748. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46749. * * 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`
  46750. * * 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
  46751. * * 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)`)
  46752. * * 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
  46753. * * 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
  46754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46755. * * 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
  46756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46757. * @param name defines the name of the mesh
  46758. * @param options defines the options used to create the mesh
  46759. * @param scene defines the hosting scene
  46760. * @returns the polyhedron mesh
  46761. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46762. */
  46763. static CreatePolyhedron(name: string, options: {
  46764. type?: number;
  46765. size?: number;
  46766. sizeX?: number;
  46767. sizeY?: number;
  46768. sizeZ?: number;
  46769. custom?: any;
  46770. faceUV?: Vector4[];
  46771. faceColors?: Color4[];
  46772. flat?: boolean;
  46773. updatable?: boolean;
  46774. sideOrientation?: number;
  46775. frontUVs?: Vector4;
  46776. backUVs?: Vector4;
  46777. }, scene?: Nullable<Scene>): Mesh;
  46778. }
  46779. }
  46780. declare module BABYLON {
  46781. /**
  46782. * Gizmo that enables scaling a mesh along 3 axis
  46783. */
  46784. export class ScaleGizmo extends Gizmo {
  46785. /**
  46786. * Internal gizmo used for interactions on the x axis
  46787. */
  46788. xGizmo: AxisScaleGizmo;
  46789. /**
  46790. * Internal gizmo used for interactions on the y axis
  46791. */
  46792. yGizmo: AxisScaleGizmo;
  46793. /**
  46794. * Internal gizmo used for interactions on the z axis
  46795. */
  46796. zGizmo: AxisScaleGizmo;
  46797. /**
  46798. * Internal gizmo used to scale all axis equally
  46799. */
  46800. uniformScaleGizmo: AxisScaleGizmo;
  46801. private _meshAttached;
  46802. private _updateGizmoRotationToMatchAttachedMesh;
  46803. private _snapDistance;
  46804. private _scaleRatio;
  46805. private _uniformScalingMesh;
  46806. private _octahedron;
  46807. private _sensitivity;
  46808. /** Fires an event when any of it's sub gizmos are dragged */
  46809. onDragStartObservable: Observable<unknown>;
  46810. /** Fires an event when any of it's sub gizmos are released from dragging */
  46811. onDragEndObservable: Observable<unknown>;
  46812. attachedMesh: Nullable<AbstractMesh>;
  46813. /**
  46814. * Creates a ScaleGizmo
  46815. * @param gizmoLayer The utility layer the gizmo will be added to
  46816. */
  46817. constructor(gizmoLayer?: UtilityLayerRenderer);
  46818. updateGizmoRotationToMatchAttachedMesh: boolean;
  46819. /**
  46820. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46821. */
  46822. snapDistance: number;
  46823. /**
  46824. * Ratio for the scale of the gizmo (Default: 1)
  46825. */
  46826. scaleRatio: number;
  46827. /**
  46828. * Sensitivity factor for dragging (Default: 1)
  46829. */
  46830. sensitivity: number;
  46831. /**
  46832. * Disposes of the gizmo
  46833. */
  46834. dispose(): void;
  46835. }
  46836. }
  46837. declare module BABYLON {
  46838. /**
  46839. * Single axis scale gizmo
  46840. */
  46841. export class AxisScaleGizmo extends Gizmo {
  46842. /**
  46843. * Drag behavior responsible for the gizmos dragging interactions
  46844. */
  46845. dragBehavior: PointerDragBehavior;
  46846. private _pointerObserver;
  46847. /**
  46848. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46849. */
  46850. snapDistance: number;
  46851. /**
  46852. * Event that fires each time the gizmo snaps to a new location.
  46853. * * snapDistance is the the change in distance
  46854. */
  46855. onSnapObservable: Observable<{
  46856. snapDistance: number;
  46857. }>;
  46858. /**
  46859. * If the scaling operation should be done on all axis (default: false)
  46860. */
  46861. uniformScaling: boolean;
  46862. /**
  46863. * Custom sensitivity value for the drag strength
  46864. */
  46865. sensitivity: number;
  46866. private _isEnabled;
  46867. private _parent;
  46868. private _arrow;
  46869. private _coloredMaterial;
  46870. private _hoverMaterial;
  46871. /**
  46872. * Creates an AxisScaleGizmo
  46873. * @param gizmoLayer The utility layer the gizmo will be added to
  46874. * @param dragAxis The axis which the gizmo will be able to scale on
  46875. * @param color The color of the gizmo
  46876. */
  46877. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46878. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46879. /**
  46880. * If the gizmo is enabled
  46881. */
  46882. isEnabled: boolean;
  46883. /**
  46884. * Disposes of the gizmo
  46885. */
  46886. dispose(): void;
  46887. /**
  46888. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46889. * @param mesh The mesh to replace the default mesh of the gizmo
  46890. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46891. */
  46892. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46893. }
  46894. }
  46895. declare module BABYLON {
  46896. /**
  46897. * Bounding box gizmo
  46898. */
  46899. export class BoundingBoxGizmo extends Gizmo {
  46900. private _lineBoundingBox;
  46901. private _rotateSpheresParent;
  46902. private _scaleBoxesParent;
  46903. private _boundingDimensions;
  46904. private _renderObserver;
  46905. private _pointerObserver;
  46906. private _scaleDragSpeed;
  46907. private _tmpQuaternion;
  46908. private _tmpVector;
  46909. private _tmpRotationMatrix;
  46910. /**
  46911. * 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)
  46912. */
  46913. ignoreChildren: boolean;
  46914. /**
  46915. * 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)
  46916. */
  46917. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46918. /**
  46919. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46920. */
  46921. rotationSphereSize: number;
  46922. /**
  46923. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46924. */
  46925. scaleBoxSize: number;
  46926. /**
  46927. * 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)
  46928. */
  46929. fixedDragMeshScreenSize: boolean;
  46930. /**
  46931. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46932. */
  46933. fixedDragMeshScreenSizeDistanceFactor: number;
  46934. /**
  46935. * Fired when a rotation sphere or scale box is dragged
  46936. */
  46937. onDragStartObservable: Observable<{}>;
  46938. /**
  46939. * Fired when a scale box is dragged
  46940. */
  46941. onScaleBoxDragObservable: Observable<{}>;
  46942. /**
  46943. * Fired when a scale box drag is ended
  46944. */
  46945. onScaleBoxDragEndObservable: Observable<{}>;
  46946. /**
  46947. * Fired when a rotation sphere is dragged
  46948. */
  46949. onRotationSphereDragObservable: Observable<{}>;
  46950. /**
  46951. * Fired when a rotation sphere drag is ended
  46952. */
  46953. onRotationSphereDragEndObservable: Observable<{}>;
  46954. /**
  46955. * 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)
  46956. */
  46957. scalePivot: Nullable<Vector3>;
  46958. /**
  46959. * Mesh used as a pivot to rotate the attached mesh
  46960. */
  46961. private _anchorMesh;
  46962. private _existingMeshScale;
  46963. private _dragMesh;
  46964. private pointerDragBehavior;
  46965. private coloredMaterial;
  46966. private hoverColoredMaterial;
  46967. /**
  46968. * Sets the color of the bounding box gizmo
  46969. * @param color the color to set
  46970. */
  46971. setColor(color: Color3): void;
  46972. /**
  46973. * Creates an BoundingBoxGizmo
  46974. * @param gizmoLayer The utility layer the gizmo will be added to
  46975. * @param color The color of the gizmo
  46976. */
  46977. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46978. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46979. private _selectNode;
  46980. /**
  46981. * Updates the bounding box information for the Gizmo
  46982. */
  46983. updateBoundingBox(): void;
  46984. private _updateRotationSpheres;
  46985. private _updateScaleBoxes;
  46986. /**
  46987. * Enables rotation on the specified axis and disables rotation on the others
  46988. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46989. */
  46990. setEnabledRotationAxis(axis: string): void;
  46991. /**
  46992. * Enables/disables scaling
  46993. * @param enable if scaling should be enabled
  46994. */
  46995. setEnabledScaling(enable: boolean): void;
  46996. private _updateDummy;
  46997. /**
  46998. * Enables a pointer drag behavior on the bounding box of the gizmo
  46999. */
  47000. enableDragBehavior(): void;
  47001. /**
  47002. * Disposes of the gizmo
  47003. */
  47004. dispose(): void;
  47005. /**
  47006. * 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)
  47007. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47008. * @returns the bounding box mesh with the passed in mesh as a child
  47009. */
  47010. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47011. /**
  47012. * CustomMeshes are not supported by this gizmo
  47013. * @param mesh The mesh to replace the default mesh of the gizmo
  47014. */
  47015. setCustomMesh(mesh: Mesh): void;
  47016. }
  47017. }
  47018. declare module BABYLON {
  47019. /**
  47020. * Single plane rotation gizmo
  47021. */
  47022. export class PlaneRotationGizmo extends Gizmo {
  47023. /**
  47024. * Drag behavior responsible for the gizmos dragging interactions
  47025. */
  47026. dragBehavior: PointerDragBehavior;
  47027. private _pointerObserver;
  47028. /**
  47029. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47030. */
  47031. snapDistance: number;
  47032. /**
  47033. * Event that fires each time the gizmo snaps to a new location.
  47034. * * snapDistance is the the change in distance
  47035. */
  47036. onSnapObservable: Observable<{
  47037. snapDistance: number;
  47038. }>;
  47039. private _isEnabled;
  47040. private _parent;
  47041. /**
  47042. * Creates a PlaneRotationGizmo
  47043. * @param gizmoLayer The utility layer the gizmo will be added to
  47044. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47045. * @param color The color of the gizmo
  47046. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47047. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47048. */
  47049. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47050. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47051. /**
  47052. * If the gizmo is enabled
  47053. */
  47054. isEnabled: boolean;
  47055. /**
  47056. * Disposes of the gizmo
  47057. */
  47058. dispose(): void;
  47059. }
  47060. }
  47061. declare module BABYLON {
  47062. /**
  47063. * Gizmo that enables rotating a mesh along 3 axis
  47064. */
  47065. export class RotationGizmo extends Gizmo {
  47066. /**
  47067. * Internal gizmo used for interactions on the x axis
  47068. */
  47069. xGizmo: PlaneRotationGizmo;
  47070. /**
  47071. * Internal gizmo used for interactions on the y axis
  47072. */
  47073. yGizmo: PlaneRotationGizmo;
  47074. /**
  47075. * Internal gizmo used for interactions on the z axis
  47076. */
  47077. zGizmo: PlaneRotationGizmo;
  47078. /** Fires an event when any of it's sub gizmos are dragged */
  47079. onDragStartObservable: Observable<unknown>;
  47080. /** Fires an event when any of it's sub gizmos are released from dragging */
  47081. onDragEndObservable: Observable<unknown>;
  47082. private _meshAttached;
  47083. attachedMesh: Nullable<AbstractMesh>;
  47084. /**
  47085. * Creates a RotationGizmo
  47086. * @param gizmoLayer The utility layer the gizmo will be added to
  47087. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47088. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47089. */
  47090. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47091. updateGizmoRotationToMatchAttachedMesh: boolean;
  47092. /**
  47093. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47094. */
  47095. snapDistance: number;
  47096. /**
  47097. * Ratio for the scale of the gizmo (Default: 1)
  47098. */
  47099. scaleRatio: number;
  47100. /**
  47101. * Disposes of the gizmo
  47102. */
  47103. dispose(): void;
  47104. /**
  47105. * CustomMeshes are not supported by this gizmo
  47106. * @param mesh The mesh to replace the default mesh of the gizmo
  47107. */
  47108. setCustomMesh(mesh: Mesh): void;
  47109. }
  47110. }
  47111. declare module BABYLON {
  47112. /**
  47113. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47114. */
  47115. export class GizmoManager implements IDisposable {
  47116. private scene;
  47117. /**
  47118. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47119. */
  47120. gizmos: {
  47121. positionGizmo: Nullable<PositionGizmo>;
  47122. rotationGizmo: Nullable<RotationGizmo>;
  47123. scaleGizmo: Nullable<ScaleGizmo>;
  47124. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47125. };
  47126. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47127. clearGizmoOnEmptyPointerEvent: boolean;
  47128. /** Fires an event when the manager is attached to a mesh */
  47129. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47130. private _gizmosEnabled;
  47131. private _pointerObserver;
  47132. private _attachedMesh;
  47133. private _boundingBoxColor;
  47134. private _defaultUtilityLayer;
  47135. private _defaultKeepDepthUtilityLayer;
  47136. /**
  47137. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47138. */
  47139. boundingBoxDragBehavior: SixDofDragBehavior;
  47140. /**
  47141. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47142. */
  47143. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47144. /**
  47145. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47146. */
  47147. usePointerToAttachGizmos: boolean;
  47148. /**
  47149. * Utility layer that the bounding box gizmo belongs to
  47150. */
  47151. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47152. /**
  47153. * Utility layer that all gizmos besides bounding box belong to
  47154. */
  47155. readonly utilityLayer: UtilityLayerRenderer;
  47156. /**
  47157. * Instatiates a gizmo manager
  47158. * @param scene the scene to overlay the gizmos on top of
  47159. */
  47160. constructor(scene: Scene);
  47161. /**
  47162. * Attaches a set of gizmos to the specified mesh
  47163. * @param mesh The mesh the gizmo's should be attached to
  47164. */
  47165. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47166. /**
  47167. * If the position gizmo is enabled
  47168. */
  47169. positionGizmoEnabled: boolean;
  47170. /**
  47171. * If the rotation gizmo is enabled
  47172. */
  47173. rotationGizmoEnabled: boolean;
  47174. /**
  47175. * If the scale gizmo is enabled
  47176. */
  47177. scaleGizmoEnabled: boolean;
  47178. /**
  47179. * If the boundingBox gizmo is enabled
  47180. */
  47181. boundingBoxGizmoEnabled: boolean;
  47182. /**
  47183. * Disposes of the gizmo manager
  47184. */
  47185. dispose(): void;
  47186. }
  47187. }
  47188. declare module BABYLON {
  47189. /**
  47190. * A directional light is defined by a direction (what a surprise!).
  47191. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47192. * 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.
  47193. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47194. */
  47195. export class DirectionalLight extends ShadowLight {
  47196. private _shadowFrustumSize;
  47197. /**
  47198. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47199. */
  47200. /**
  47201. * Specifies a fix frustum size for the shadow generation.
  47202. */
  47203. shadowFrustumSize: number;
  47204. private _shadowOrthoScale;
  47205. /**
  47206. * Gets the shadow projection scale against the optimal computed one.
  47207. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47208. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47209. */
  47210. /**
  47211. * Sets the shadow projection scale against the optimal computed one.
  47212. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47213. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47214. */
  47215. shadowOrthoScale: number;
  47216. /**
  47217. * Automatically compute the projection matrix to best fit (including all the casters)
  47218. * on each frame.
  47219. */
  47220. autoUpdateExtends: boolean;
  47221. private _orthoLeft;
  47222. private _orthoRight;
  47223. private _orthoTop;
  47224. private _orthoBottom;
  47225. /**
  47226. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47227. * The directional light is emitted from everywhere in the given direction.
  47228. * It can cast shadows.
  47229. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47230. * @param name The friendly name of the light
  47231. * @param direction The direction of the light
  47232. * @param scene The scene the light belongs to
  47233. */
  47234. constructor(name: string, direction: Vector3, scene: Scene);
  47235. /**
  47236. * Returns the string "DirectionalLight".
  47237. * @return The class name
  47238. */
  47239. getClassName(): string;
  47240. /**
  47241. * Returns the integer 1.
  47242. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47243. */
  47244. getTypeID(): number;
  47245. /**
  47246. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47247. * Returns the DirectionalLight Shadow projection matrix.
  47248. */
  47249. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47250. /**
  47251. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47252. * Returns the DirectionalLight Shadow projection matrix.
  47253. */
  47254. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47255. /**
  47256. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47257. * Returns the DirectionalLight Shadow projection matrix.
  47258. */
  47259. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47260. protected _buildUniformLayout(): void;
  47261. /**
  47262. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47263. * @param effect The effect to update
  47264. * @param lightIndex The index of the light in the effect to update
  47265. * @returns The directional light
  47266. */
  47267. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47268. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47269. /**
  47270. * Gets the minZ used for shadow according to both the scene and the light.
  47271. *
  47272. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47273. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47274. * @param activeCamera The camera we are returning the min for
  47275. * @returns the depth min z
  47276. */
  47277. getDepthMinZ(activeCamera: Camera): number;
  47278. /**
  47279. * Gets the maxZ used for shadow according to both the scene and the light.
  47280. *
  47281. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47282. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47283. * @param activeCamera The camera we are returning the max for
  47284. * @returns the depth max z
  47285. */
  47286. getDepthMaxZ(activeCamera: Camera): number;
  47287. /**
  47288. * Prepares the list of defines specific to the light type.
  47289. * @param defines the list of defines
  47290. * @param lightIndex defines the index of the light for the effect
  47291. */
  47292. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47293. }
  47294. }
  47295. declare module BABYLON {
  47296. /**
  47297. * Class containing static functions to help procedurally build meshes
  47298. */
  47299. export class HemisphereBuilder {
  47300. /**
  47301. * Creates a hemisphere mesh
  47302. * @param name defines the name of the mesh
  47303. * @param options defines the options used to create the mesh
  47304. * @param scene defines the hosting scene
  47305. * @returns the hemisphere mesh
  47306. */
  47307. static CreateHemisphere(name: string, options: {
  47308. segments?: number;
  47309. diameter?: number;
  47310. sideOrientation?: number;
  47311. }, scene: any): Mesh;
  47312. }
  47313. }
  47314. declare module BABYLON {
  47315. /**
  47316. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47317. * These values define a cone of light starting from the position, emitting toward the direction.
  47318. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47319. * and the exponent defines the speed of the decay of the light with distance (reach).
  47320. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47321. */
  47322. export class SpotLight extends ShadowLight {
  47323. private _angle;
  47324. private _innerAngle;
  47325. private _cosHalfAngle;
  47326. private _lightAngleScale;
  47327. private _lightAngleOffset;
  47328. /**
  47329. * Gets the cone angle of the spot light in Radians.
  47330. */
  47331. /**
  47332. * Sets the cone angle of the spot light in Radians.
  47333. */
  47334. angle: number;
  47335. /**
  47336. * Only used in gltf falloff mode, this defines the angle where
  47337. * the directional falloff will start before cutting at angle which could be seen
  47338. * as outer angle.
  47339. */
  47340. /**
  47341. * Only used in gltf falloff mode, this defines the angle where
  47342. * the directional falloff will start before cutting at angle which could be seen
  47343. * as outer angle.
  47344. */
  47345. innerAngle: number;
  47346. private _shadowAngleScale;
  47347. /**
  47348. * Allows scaling the angle of the light for shadow generation only.
  47349. */
  47350. /**
  47351. * Allows scaling the angle of the light for shadow generation only.
  47352. */
  47353. shadowAngleScale: number;
  47354. /**
  47355. * The light decay speed with the distance from the emission spot.
  47356. */
  47357. exponent: number;
  47358. private _projectionTextureMatrix;
  47359. /**
  47360. * Allows reading the projecton texture
  47361. */
  47362. readonly projectionTextureMatrix: Matrix;
  47363. protected _projectionTextureLightNear: number;
  47364. /**
  47365. * Gets the near clip of the Spotlight for texture projection.
  47366. */
  47367. /**
  47368. * Sets the near clip of the Spotlight for texture projection.
  47369. */
  47370. projectionTextureLightNear: number;
  47371. protected _projectionTextureLightFar: number;
  47372. /**
  47373. * Gets the far clip of the Spotlight for texture projection.
  47374. */
  47375. /**
  47376. * Sets the far clip of the Spotlight for texture projection.
  47377. */
  47378. projectionTextureLightFar: number;
  47379. protected _projectionTextureUpDirection: Vector3;
  47380. /**
  47381. * Gets the Up vector of the Spotlight for texture projection.
  47382. */
  47383. /**
  47384. * Sets the Up vector of the Spotlight for texture projection.
  47385. */
  47386. projectionTextureUpDirection: Vector3;
  47387. private _projectionTexture;
  47388. /**
  47389. * Gets the projection texture of the light.
  47390. */
  47391. /**
  47392. * Sets the projection texture of the light.
  47393. */
  47394. projectionTexture: Nullable<BaseTexture>;
  47395. private _projectionTextureViewLightDirty;
  47396. private _projectionTextureProjectionLightDirty;
  47397. private _projectionTextureDirty;
  47398. private _projectionTextureViewTargetVector;
  47399. private _projectionTextureViewLightMatrix;
  47400. private _projectionTextureProjectionLightMatrix;
  47401. private _projectionTextureScalingMatrix;
  47402. /**
  47403. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47404. * It can cast shadows.
  47405. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47406. * @param name The light friendly name
  47407. * @param position The position of the spot light in the scene
  47408. * @param direction The direction of the light in the scene
  47409. * @param angle The cone angle of the light in Radians
  47410. * @param exponent The light decay speed with the distance from the emission spot
  47411. * @param scene The scene the lights belongs to
  47412. */
  47413. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47414. /**
  47415. * Returns the string "SpotLight".
  47416. * @returns the class name
  47417. */
  47418. getClassName(): string;
  47419. /**
  47420. * Returns the integer 2.
  47421. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47422. */
  47423. getTypeID(): number;
  47424. /**
  47425. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47426. */
  47427. protected _setDirection(value: Vector3): void;
  47428. /**
  47429. * Overrides the position setter to recompute the projection texture view light Matrix.
  47430. */
  47431. protected _setPosition(value: Vector3): void;
  47432. /**
  47433. * 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.
  47434. * Returns the SpotLight.
  47435. */
  47436. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47437. protected _computeProjectionTextureViewLightMatrix(): void;
  47438. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47439. /**
  47440. * Main function for light texture projection matrix computing.
  47441. */
  47442. protected _computeProjectionTextureMatrix(): void;
  47443. protected _buildUniformLayout(): void;
  47444. private _computeAngleValues;
  47445. /**
  47446. * Sets the passed Effect "effect" with the Light textures.
  47447. * @param effect The effect to update
  47448. * @param lightIndex The index of the light in the effect to update
  47449. * @returns The light
  47450. */
  47451. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  47452. /**
  47453. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47454. * @param effect The effect to update
  47455. * @param lightIndex The index of the light in the effect to update
  47456. * @returns The spot light
  47457. */
  47458. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47459. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47460. /**
  47461. * Disposes the light and the associated resources.
  47462. */
  47463. dispose(): void;
  47464. /**
  47465. * Prepares the list of defines specific to the light type.
  47466. * @param defines the list of defines
  47467. * @param lightIndex defines the index of the light for the effect
  47468. */
  47469. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47470. }
  47471. }
  47472. declare module BABYLON {
  47473. /**
  47474. * Gizmo that enables viewing a light
  47475. */
  47476. export class LightGizmo extends Gizmo {
  47477. private _lightMesh;
  47478. private _material;
  47479. private _cachedPosition;
  47480. private _cachedForward;
  47481. private _attachedMeshParent;
  47482. /**
  47483. * Creates a LightGizmo
  47484. * @param gizmoLayer The utility layer the gizmo will be added to
  47485. */
  47486. constructor(gizmoLayer?: UtilityLayerRenderer);
  47487. private _light;
  47488. /**
  47489. * The light that the gizmo is attached to
  47490. */
  47491. light: Nullable<Light>;
  47492. /**
  47493. * Gets the material used to render the light gizmo
  47494. */
  47495. readonly material: StandardMaterial;
  47496. /**
  47497. * @hidden
  47498. * Updates the gizmo to match the attached mesh's position/rotation
  47499. */
  47500. protected _update(): void;
  47501. private static _Scale;
  47502. /**
  47503. * Creates the lines for a light mesh
  47504. */
  47505. private static _CreateLightLines;
  47506. /**
  47507. * Disposes of the light gizmo
  47508. */
  47509. dispose(): void;
  47510. private static _CreateHemisphericLightMesh;
  47511. private static _CreatePointLightMesh;
  47512. private static _CreateSpotLightMesh;
  47513. private static _CreateDirectionalLightMesh;
  47514. }
  47515. }
  47516. declare module BABYLON {
  47517. /** @hidden */
  47518. export var backgroundFragmentDeclaration: {
  47519. name: string;
  47520. shader: string;
  47521. };
  47522. }
  47523. declare module BABYLON {
  47524. /** @hidden */
  47525. export var backgroundUboDeclaration: {
  47526. name: string;
  47527. shader: string;
  47528. };
  47529. }
  47530. declare module BABYLON {
  47531. /** @hidden */
  47532. export var backgroundPixelShader: {
  47533. name: string;
  47534. shader: string;
  47535. };
  47536. }
  47537. declare module BABYLON {
  47538. /** @hidden */
  47539. export var backgroundVertexDeclaration: {
  47540. name: string;
  47541. shader: string;
  47542. };
  47543. }
  47544. declare module BABYLON {
  47545. /** @hidden */
  47546. export var backgroundVertexShader: {
  47547. name: string;
  47548. shader: string;
  47549. };
  47550. }
  47551. declare module BABYLON {
  47552. /**
  47553. * Background material used to create an efficient environement around your scene.
  47554. */
  47555. export class BackgroundMaterial extends PushMaterial {
  47556. /**
  47557. * Standard reflectance value at parallel view angle.
  47558. */
  47559. static StandardReflectance0: number;
  47560. /**
  47561. * Standard reflectance value at grazing angle.
  47562. */
  47563. static StandardReflectance90: number;
  47564. protected _primaryColor: Color3;
  47565. /**
  47566. * Key light Color (multiply against the environement texture)
  47567. */
  47568. primaryColor: Color3;
  47569. protected __perceptualColor: Nullable<Color3>;
  47570. /**
  47571. * Experimental Internal Use Only.
  47572. *
  47573. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47574. * This acts as a helper to set the primary color to a more "human friendly" value.
  47575. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47576. * output color as close as possible from the chosen value.
  47577. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47578. * part of lighting setup.)
  47579. */
  47580. _perceptualColor: Nullable<Color3>;
  47581. protected _primaryColorShadowLevel: float;
  47582. /**
  47583. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47584. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47585. */
  47586. primaryColorShadowLevel: float;
  47587. protected _primaryColorHighlightLevel: float;
  47588. /**
  47589. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47590. * The primary color is used at the level chosen to define what the white area would look.
  47591. */
  47592. primaryColorHighlightLevel: float;
  47593. protected _reflectionTexture: Nullable<BaseTexture>;
  47594. /**
  47595. * Reflection Texture used in the material.
  47596. * Should be author in a specific way for the best result (refer to the documentation).
  47597. */
  47598. reflectionTexture: Nullable<BaseTexture>;
  47599. protected _reflectionBlur: float;
  47600. /**
  47601. * Reflection Texture level of blur.
  47602. *
  47603. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47604. * texture twice.
  47605. */
  47606. reflectionBlur: float;
  47607. protected _diffuseTexture: Nullable<BaseTexture>;
  47608. /**
  47609. * Diffuse Texture used in the material.
  47610. * Should be author in a specific way for the best result (refer to the documentation).
  47611. */
  47612. diffuseTexture: Nullable<BaseTexture>;
  47613. protected _shadowLights: Nullable<IShadowLight[]>;
  47614. /**
  47615. * Specify the list of lights casting shadow on the material.
  47616. * All scene shadow lights will be included if null.
  47617. */
  47618. shadowLights: Nullable<IShadowLight[]>;
  47619. protected _shadowLevel: float;
  47620. /**
  47621. * Helps adjusting the shadow to a softer level if required.
  47622. * 0 means black shadows and 1 means no shadows.
  47623. */
  47624. shadowLevel: float;
  47625. protected _sceneCenter: Vector3;
  47626. /**
  47627. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47628. * It is usually zero but might be interesting to modify according to your setup.
  47629. */
  47630. sceneCenter: Vector3;
  47631. protected _opacityFresnel: boolean;
  47632. /**
  47633. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47634. * This helps ensuring a nice transition when the camera goes under the ground.
  47635. */
  47636. opacityFresnel: boolean;
  47637. protected _reflectionFresnel: boolean;
  47638. /**
  47639. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47640. * This helps adding a mirror texture on the ground.
  47641. */
  47642. reflectionFresnel: boolean;
  47643. protected _reflectionFalloffDistance: number;
  47644. /**
  47645. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47646. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47647. */
  47648. reflectionFalloffDistance: number;
  47649. protected _reflectionAmount: number;
  47650. /**
  47651. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47652. */
  47653. reflectionAmount: number;
  47654. protected _reflectionReflectance0: number;
  47655. /**
  47656. * This specifies the weight of the reflection at grazing angle.
  47657. */
  47658. reflectionReflectance0: number;
  47659. protected _reflectionReflectance90: number;
  47660. /**
  47661. * This specifies the weight of the reflection at a perpendicular point of view.
  47662. */
  47663. reflectionReflectance90: number;
  47664. /**
  47665. * Sets the reflection reflectance fresnel values according to the default standard
  47666. * empirically know to work well :-)
  47667. */
  47668. reflectionStandardFresnelWeight: number;
  47669. protected _useRGBColor: boolean;
  47670. /**
  47671. * Helps to directly use the maps channels instead of their level.
  47672. */
  47673. useRGBColor: boolean;
  47674. protected _enableNoise: boolean;
  47675. /**
  47676. * This helps reducing the banding effect that could occur on the background.
  47677. */
  47678. enableNoise: boolean;
  47679. /**
  47680. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47681. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47682. * Recommended to be keep at 1.0 except for special cases.
  47683. */
  47684. fovMultiplier: number;
  47685. private _fovMultiplier;
  47686. /**
  47687. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47688. */
  47689. useEquirectangularFOV: boolean;
  47690. private _maxSimultaneousLights;
  47691. /**
  47692. * Number of Simultaneous lights allowed on the material.
  47693. */
  47694. maxSimultaneousLights: int;
  47695. /**
  47696. * Default configuration related to image processing available in the Background Material.
  47697. */
  47698. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47699. /**
  47700. * Keep track of the image processing observer to allow dispose and replace.
  47701. */
  47702. private _imageProcessingObserver;
  47703. /**
  47704. * Attaches a new image processing configuration to the PBR Material.
  47705. * @param configuration (if null the scene configuration will be use)
  47706. */
  47707. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47708. /**
  47709. * Gets the image processing configuration used either in this material.
  47710. */
  47711. /**
  47712. * Sets the Default image processing configuration used either in the this material.
  47713. *
  47714. * If sets to null, the scene one is in use.
  47715. */
  47716. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47717. /**
  47718. * Gets wether the color curves effect is enabled.
  47719. */
  47720. /**
  47721. * Sets wether the color curves effect is enabled.
  47722. */
  47723. cameraColorCurvesEnabled: boolean;
  47724. /**
  47725. * Gets wether the color grading effect is enabled.
  47726. */
  47727. /**
  47728. * Gets wether the color grading effect is enabled.
  47729. */
  47730. cameraColorGradingEnabled: boolean;
  47731. /**
  47732. * Gets wether tonemapping is enabled or not.
  47733. */
  47734. /**
  47735. * Sets wether tonemapping is enabled or not
  47736. */
  47737. cameraToneMappingEnabled: boolean;
  47738. /**
  47739. * The camera exposure used on this material.
  47740. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47741. * This corresponds to a photographic exposure.
  47742. */
  47743. /**
  47744. * The camera exposure used on this material.
  47745. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47746. * This corresponds to a photographic exposure.
  47747. */
  47748. cameraExposure: float;
  47749. /**
  47750. * Gets The camera contrast used on this material.
  47751. */
  47752. /**
  47753. * Sets The camera contrast used on this material.
  47754. */
  47755. cameraContrast: float;
  47756. /**
  47757. * Gets the Color Grading 2D Lookup Texture.
  47758. */
  47759. /**
  47760. * Sets the Color Grading 2D Lookup Texture.
  47761. */
  47762. cameraColorGradingTexture: Nullable<BaseTexture>;
  47763. /**
  47764. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47765. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47766. * 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;
  47767. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47768. */
  47769. /**
  47770. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47771. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47772. * 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;
  47773. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47774. */
  47775. cameraColorCurves: Nullable<ColorCurves>;
  47776. /**
  47777. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47778. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47779. */
  47780. switchToBGR: boolean;
  47781. private _renderTargets;
  47782. private _reflectionControls;
  47783. private _white;
  47784. private _primaryShadowColor;
  47785. private _primaryHighlightColor;
  47786. /**
  47787. * Instantiates a Background Material in the given scene
  47788. * @param name The friendly name of the material
  47789. * @param scene The scene to add the material to
  47790. */
  47791. constructor(name: string, scene: Scene);
  47792. /**
  47793. * Gets a boolean indicating that current material needs to register RTT
  47794. */
  47795. readonly hasRenderTargetTextures: boolean;
  47796. /**
  47797. * The entire material has been created in order to prevent overdraw.
  47798. * @returns false
  47799. */
  47800. needAlphaTesting(): boolean;
  47801. /**
  47802. * The entire material has been created in order to prevent overdraw.
  47803. * @returns true if blending is enable
  47804. */
  47805. needAlphaBlending(): boolean;
  47806. /**
  47807. * Checks wether the material is ready to be rendered for a given mesh.
  47808. * @param mesh The mesh to render
  47809. * @param subMesh The submesh to check against
  47810. * @param useInstances Specify wether or not the material is used with instances
  47811. * @returns true if all the dependencies are ready (Textures, Effects...)
  47812. */
  47813. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47814. /**
  47815. * Compute the primary color according to the chosen perceptual color.
  47816. */
  47817. private _computePrimaryColorFromPerceptualColor;
  47818. /**
  47819. * Compute the highlights and shadow colors according to their chosen levels.
  47820. */
  47821. private _computePrimaryColors;
  47822. /**
  47823. * Build the uniform buffer used in the material.
  47824. */
  47825. buildUniformLayout(): void;
  47826. /**
  47827. * Unbind the material.
  47828. */
  47829. unbind(): void;
  47830. /**
  47831. * Bind only the world matrix to the material.
  47832. * @param world The world matrix to bind.
  47833. */
  47834. bindOnlyWorldMatrix(world: Matrix): void;
  47835. /**
  47836. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47837. * @param world The world matrix to bind.
  47838. * @param subMesh The submesh to bind for.
  47839. */
  47840. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47841. /**
  47842. * Checks to see if a texture is used in the material.
  47843. * @param texture - Base texture to use.
  47844. * @returns - Boolean specifying if a texture is used in the material.
  47845. */
  47846. hasTexture(texture: BaseTexture): boolean;
  47847. /**
  47848. * Dispose the material.
  47849. * @param forceDisposeEffect Force disposal of the associated effect.
  47850. * @param forceDisposeTextures Force disposal of the associated textures.
  47851. */
  47852. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47853. /**
  47854. * Clones the material.
  47855. * @param name The cloned name.
  47856. * @returns The cloned material.
  47857. */
  47858. clone(name: string): BackgroundMaterial;
  47859. /**
  47860. * Serializes the current material to its JSON representation.
  47861. * @returns The JSON representation.
  47862. */
  47863. serialize(): any;
  47864. /**
  47865. * Gets the class name of the material
  47866. * @returns "BackgroundMaterial"
  47867. */
  47868. getClassName(): string;
  47869. /**
  47870. * Parse a JSON input to create back a background material.
  47871. * @param source The JSON data to parse
  47872. * @param scene The scene to create the parsed material in
  47873. * @param rootUrl The root url of the assets the material depends upon
  47874. * @returns the instantiated BackgroundMaterial.
  47875. */
  47876. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47877. }
  47878. }
  47879. declare module BABYLON {
  47880. /**
  47881. * Represents the different options available during the creation of
  47882. * a Environment helper.
  47883. *
  47884. * This can control the default ground, skybox and image processing setup of your scene.
  47885. */
  47886. export interface IEnvironmentHelperOptions {
  47887. /**
  47888. * Specifies wether or not to create a ground.
  47889. * True by default.
  47890. */
  47891. createGround: boolean;
  47892. /**
  47893. * Specifies the ground size.
  47894. * 15 by default.
  47895. */
  47896. groundSize: number;
  47897. /**
  47898. * The texture used on the ground for the main color.
  47899. * Comes from the BabylonJS CDN by default.
  47900. *
  47901. * Remarks: Can be either a texture or a url.
  47902. */
  47903. groundTexture: string | BaseTexture;
  47904. /**
  47905. * The color mixed in the ground texture by default.
  47906. * BabylonJS clearColor by default.
  47907. */
  47908. groundColor: Color3;
  47909. /**
  47910. * Specifies the ground opacity.
  47911. * 1 by default.
  47912. */
  47913. groundOpacity: number;
  47914. /**
  47915. * Enables the ground to receive shadows.
  47916. * True by default.
  47917. */
  47918. enableGroundShadow: boolean;
  47919. /**
  47920. * Helps preventing the shadow to be fully black on the ground.
  47921. * 0.5 by default.
  47922. */
  47923. groundShadowLevel: number;
  47924. /**
  47925. * Creates a mirror texture attach to the ground.
  47926. * false by default.
  47927. */
  47928. enableGroundMirror: boolean;
  47929. /**
  47930. * Specifies the ground mirror size ratio.
  47931. * 0.3 by default as the default kernel is 64.
  47932. */
  47933. groundMirrorSizeRatio: number;
  47934. /**
  47935. * Specifies the ground mirror blur kernel size.
  47936. * 64 by default.
  47937. */
  47938. groundMirrorBlurKernel: number;
  47939. /**
  47940. * Specifies the ground mirror visibility amount.
  47941. * 1 by default
  47942. */
  47943. groundMirrorAmount: number;
  47944. /**
  47945. * Specifies the ground mirror reflectance weight.
  47946. * This uses the standard weight of the background material to setup the fresnel effect
  47947. * of the mirror.
  47948. * 1 by default.
  47949. */
  47950. groundMirrorFresnelWeight: number;
  47951. /**
  47952. * Specifies the ground mirror Falloff distance.
  47953. * This can helps reducing the size of the reflection.
  47954. * 0 by Default.
  47955. */
  47956. groundMirrorFallOffDistance: number;
  47957. /**
  47958. * Specifies the ground mirror texture type.
  47959. * Unsigned Int by Default.
  47960. */
  47961. groundMirrorTextureType: number;
  47962. /**
  47963. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47964. * the shown objects.
  47965. */
  47966. groundYBias: number;
  47967. /**
  47968. * Specifies wether or not to create a skybox.
  47969. * True by default.
  47970. */
  47971. createSkybox: boolean;
  47972. /**
  47973. * Specifies the skybox size.
  47974. * 20 by default.
  47975. */
  47976. skyboxSize: number;
  47977. /**
  47978. * The texture used on the skybox for the main color.
  47979. * Comes from the BabylonJS CDN by default.
  47980. *
  47981. * Remarks: Can be either a texture or a url.
  47982. */
  47983. skyboxTexture: string | BaseTexture;
  47984. /**
  47985. * The color mixed in the skybox texture by default.
  47986. * BabylonJS clearColor by default.
  47987. */
  47988. skyboxColor: Color3;
  47989. /**
  47990. * The background rotation around the Y axis of the scene.
  47991. * This helps aligning the key lights of your scene with the background.
  47992. * 0 by default.
  47993. */
  47994. backgroundYRotation: number;
  47995. /**
  47996. * Compute automatically the size of the elements to best fit with the scene.
  47997. */
  47998. sizeAuto: boolean;
  47999. /**
  48000. * Default position of the rootMesh if autoSize is not true.
  48001. */
  48002. rootPosition: Vector3;
  48003. /**
  48004. * Sets up the image processing in the scene.
  48005. * true by default.
  48006. */
  48007. setupImageProcessing: boolean;
  48008. /**
  48009. * The texture used as your environment texture in the scene.
  48010. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48011. *
  48012. * Remarks: Can be either a texture or a url.
  48013. */
  48014. environmentTexture: string | BaseTexture;
  48015. /**
  48016. * The value of the exposure to apply to the scene.
  48017. * 0.6 by default if setupImageProcessing is true.
  48018. */
  48019. cameraExposure: number;
  48020. /**
  48021. * The value of the contrast to apply to the scene.
  48022. * 1.6 by default if setupImageProcessing is true.
  48023. */
  48024. cameraContrast: number;
  48025. /**
  48026. * Specifies wether or not tonemapping should be enabled in the scene.
  48027. * true by default if setupImageProcessing is true.
  48028. */
  48029. toneMappingEnabled: boolean;
  48030. }
  48031. /**
  48032. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48033. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48034. * It also helps with the default setup of your imageProcessing configuration.
  48035. */
  48036. export class EnvironmentHelper {
  48037. /**
  48038. * Default ground texture URL.
  48039. */
  48040. private static _groundTextureCDNUrl;
  48041. /**
  48042. * Default skybox texture URL.
  48043. */
  48044. private static _skyboxTextureCDNUrl;
  48045. /**
  48046. * Default environment texture URL.
  48047. */
  48048. private static _environmentTextureCDNUrl;
  48049. /**
  48050. * Creates the default options for the helper.
  48051. */
  48052. private static _getDefaultOptions;
  48053. private _rootMesh;
  48054. /**
  48055. * Gets the root mesh created by the helper.
  48056. */
  48057. readonly rootMesh: Mesh;
  48058. private _skybox;
  48059. /**
  48060. * Gets the skybox created by the helper.
  48061. */
  48062. readonly skybox: Nullable<Mesh>;
  48063. private _skyboxTexture;
  48064. /**
  48065. * Gets the skybox texture created by the helper.
  48066. */
  48067. readonly skyboxTexture: Nullable<BaseTexture>;
  48068. private _skyboxMaterial;
  48069. /**
  48070. * Gets the skybox material created by the helper.
  48071. */
  48072. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48073. private _ground;
  48074. /**
  48075. * Gets the ground mesh created by the helper.
  48076. */
  48077. readonly ground: Nullable<Mesh>;
  48078. private _groundTexture;
  48079. /**
  48080. * Gets the ground texture created by the helper.
  48081. */
  48082. readonly groundTexture: Nullable<BaseTexture>;
  48083. private _groundMirror;
  48084. /**
  48085. * Gets the ground mirror created by the helper.
  48086. */
  48087. readonly groundMirror: Nullable<MirrorTexture>;
  48088. /**
  48089. * Gets the ground mirror render list to helps pushing the meshes
  48090. * you wish in the ground reflection.
  48091. */
  48092. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48093. private _groundMaterial;
  48094. /**
  48095. * Gets the ground material created by the helper.
  48096. */
  48097. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48098. /**
  48099. * Stores the creation options.
  48100. */
  48101. private readonly _scene;
  48102. private _options;
  48103. /**
  48104. * This observable will be notified with any error during the creation of the environment,
  48105. * mainly texture creation errors.
  48106. */
  48107. onErrorObservable: Observable<{
  48108. message?: string;
  48109. exception?: any;
  48110. }>;
  48111. /**
  48112. * constructor
  48113. * @param options Defines the options we want to customize the helper
  48114. * @param scene The scene to add the material to
  48115. */
  48116. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48117. /**
  48118. * Updates the background according to the new options
  48119. * @param options
  48120. */
  48121. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48122. /**
  48123. * Sets the primary color of all the available elements.
  48124. * @param color the main color to affect to the ground and the background
  48125. */
  48126. setMainColor(color: Color3): void;
  48127. /**
  48128. * Setup the image processing according to the specified options.
  48129. */
  48130. private _setupImageProcessing;
  48131. /**
  48132. * Setup the environment texture according to the specified options.
  48133. */
  48134. private _setupEnvironmentTexture;
  48135. /**
  48136. * Setup the background according to the specified options.
  48137. */
  48138. private _setupBackground;
  48139. /**
  48140. * Get the scene sizes according to the setup.
  48141. */
  48142. private _getSceneSize;
  48143. /**
  48144. * Setup the ground according to the specified options.
  48145. */
  48146. private _setupGround;
  48147. /**
  48148. * Setup the ground material according to the specified options.
  48149. */
  48150. private _setupGroundMaterial;
  48151. /**
  48152. * Setup the ground diffuse texture according to the specified options.
  48153. */
  48154. private _setupGroundDiffuseTexture;
  48155. /**
  48156. * Setup the ground mirror texture according to the specified options.
  48157. */
  48158. private _setupGroundMirrorTexture;
  48159. /**
  48160. * Setup the ground to receive the mirror texture.
  48161. */
  48162. private _setupMirrorInGroundMaterial;
  48163. /**
  48164. * Setup the skybox according to the specified options.
  48165. */
  48166. private _setupSkybox;
  48167. /**
  48168. * Setup the skybox material according to the specified options.
  48169. */
  48170. private _setupSkyboxMaterial;
  48171. /**
  48172. * Setup the skybox reflection texture according to the specified options.
  48173. */
  48174. private _setupSkyboxReflectionTexture;
  48175. private _errorHandler;
  48176. /**
  48177. * Dispose all the elements created by the Helper.
  48178. */
  48179. dispose(): void;
  48180. }
  48181. }
  48182. declare module BABYLON {
  48183. /**
  48184. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48185. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48186. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48187. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48188. */
  48189. export class PhotoDome extends TransformNode {
  48190. /**
  48191. * Define the image as a Monoscopic panoramic 360 image.
  48192. */
  48193. static readonly MODE_MONOSCOPIC: number;
  48194. /**
  48195. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48196. */
  48197. static readonly MODE_TOPBOTTOM: number;
  48198. /**
  48199. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48200. */
  48201. static readonly MODE_SIDEBYSIDE: number;
  48202. private _useDirectMapping;
  48203. /**
  48204. * The texture being displayed on the sphere
  48205. */
  48206. protected _photoTexture: Texture;
  48207. /**
  48208. * Gets or sets the texture being displayed on the sphere
  48209. */
  48210. photoTexture: Texture;
  48211. /**
  48212. * Observable raised when an error occured while loading the 360 image
  48213. */
  48214. onLoadErrorObservable: Observable<string>;
  48215. /**
  48216. * The skybox material
  48217. */
  48218. protected _material: BackgroundMaterial;
  48219. /**
  48220. * The surface used for the skybox
  48221. */
  48222. protected _mesh: Mesh;
  48223. /**
  48224. * Gets the mesh used for the skybox.
  48225. */
  48226. readonly mesh: Mesh;
  48227. /**
  48228. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48229. * Also see the options.resolution property.
  48230. */
  48231. fovMultiplier: number;
  48232. private _imageMode;
  48233. /**
  48234. * Gets or set the current video mode for the video. It can be:
  48235. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48236. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48237. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48238. */
  48239. imageMode: number;
  48240. /**
  48241. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48242. * @param name Element's name, child elements will append suffixes for their own names.
  48243. * @param urlsOfPhoto defines the url of the photo to display
  48244. * @param options defines an object containing optional or exposed sub element properties
  48245. * @param onError defines a callback called when an error occured while loading the texture
  48246. */
  48247. constructor(name: string, urlOfPhoto: string, options: {
  48248. resolution?: number;
  48249. size?: number;
  48250. useDirectMapping?: boolean;
  48251. faceForward?: boolean;
  48252. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48253. private _onBeforeCameraRenderObserver;
  48254. private _changeImageMode;
  48255. /**
  48256. * Releases resources associated with this node.
  48257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48259. */
  48260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48261. }
  48262. }
  48263. declare module BABYLON {
  48264. /**
  48265. * Class used to host RGBD texture specific utilities
  48266. */
  48267. export class RGBDTextureTools {
  48268. /**
  48269. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48270. * @param texture the texture to expand.
  48271. */
  48272. static ExpandRGBDTexture(texture: Texture): void;
  48273. }
  48274. }
  48275. declare module BABYLON {
  48276. /**
  48277. * Class used to host texture specific utilities
  48278. */
  48279. export class BRDFTextureTools {
  48280. /**
  48281. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48282. * @param scene defines the hosting scene
  48283. * @returns the environment BRDF texture
  48284. */
  48285. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48286. private static _environmentBRDFBase64Texture;
  48287. }
  48288. }
  48289. declare module BABYLON {
  48290. /**
  48291. * @hidden
  48292. */
  48293. export interface IMaterialClearCoatDefines {
  48294. CLEARCOAT: boolean;
  48295. CLEARCOAT_DEFAULTIOR: boolean;
  48296. CLEARCOAT_TEXTURE: boolean;
  48297. CLEARCOAT_TEXTUREDIRECTUV: number;
  48298. CLEARCOAT_BUMP: boolean;
  48299. CLEARCOAT_BUMPDIRECTUV: number;
  48300. CLEARCOAT_TINT: boolean;
  48301. CLEARCOAT_TINT_TEXTURE: boolean;
  48302. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48303. /** @hidden */
  48304. _areTexturesDirty: boolean;
  48305. }
  48306. /**
  48307. * Define the code related to the clear coat parameters of the pbr material.
  48308. */
  48309. export class PBRClearCoatConfiguration {
  48310. /**
  48311. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48312. * The default fits with a polyurethane material.
  48313. */
  48314. private static readonly _DefaultIndexOfRefraction;
  48315. private _isEnabled;
  48316. /**
  48317. * Defines if the clear coat is enabled in the material.
  48318. */
  48319. isEnabled: boolean;
  48320. /**
  48321. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48322. */
  48323. intensity: number;
  48324. /**
  48325. * Defines the clear coat layer roughness.
  48326. */
  48327. roughness: number;
  48328. private _indexOfRefraction;
  48329. /**
  48330. * Defines the index of refraction of the clear coat.
  48331. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48332. * The default fits with a polyurethane material.
  48333. * Changing the default value is more performance intensive.
  48334. */
  48335. indexOfRefraction: number;
  48336. private _texture;
  48337. /**
  48338. * Stores the clear coat values in a texture.
  48339. */
  48340. texture: Nullable<BaseTexture>;
  48341. private _bumpTexture;
  48342. /**
  48343. * Define the clear coat specific bump texture.
  48344. */
  48345. bumpTexture: Nullable<BaseTexture>;
  48346. private _isTintEnabled;
  48347. /**
  48348. * Defines if the clear coat tint is enabled in the material.
  48349. */
  48350. isTintEnabled: boolean;
  48351. /**
  48352. * Defines the clear coat tint of the material.
  48353. * This is only use if tint is enabled
  48354. */
  48355. tintColor: Color3;
  48356. /**
  48357. * Defines the distance at which the tint color should be found in the
  48358. * clear coat media.
  48359. * This is only use if tint is enabled
  48360. */
  48361. tintColorAtDistance: number;
  48362. /**
  48363. * Defines the clear coat layer thickness.
  48364. * This is only use if tint is enabled
  48365. */
  48366. tintThickness: number;
  48367. private _tintTexture;
  48368. /**
  48369. * Stores the clear tint values in a texture.
  48370. * rgb is tint
  48371. * a is a thickness factor
  48372. */
  48373. tintTexture: Nullable<BaseTexture>;
  48374. /** @hidden */
  48375. private _internalMarkAllSubMeshesAsTexturesDirty;
  48376. /** @hidden */
  48377. _markAllSubMeshesAsTexturesDirty(): void;
  48378. /**
  48379. * Instantiate a new istance of clear coat configuration.
  48380. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48381. */
  48382. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48383. /**
  48384. * Gets wehter the submesh is ready to be used or not.
  48385. * @param defines the list of "defines" to update.
  48386. * @param scene defines the scene the material belongs to.
  48387. * @param engine defines the engine the material belongs to.
  48388. * @param disableBumpMap defines wether the material disables bump or not.
  48389. * @returns - boolean indicating that the submesh is ready or not.
  48390. */
  48391. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48392. /**
  48393. * Checks to see if a texture is used in the material.
  48394. * @param defines the list of "defines" to update.
  48395. * @param scene defines the scene to the material belongs to.
  48396. */
  48397. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48398. /**
  48399. * Binds the material data.
  48400. * @param uniformBuffer defines the Uniform buffer to fill in.
  48401. * @param scene defines the scene the material belongs to.
  48402. * @param engine defines the engine the material belongs to.
  48403. * @param disableBumpMap defines wether the material disables bump or not.
  48404. * @param isFrozen defines wether the material is frozen or not.
  48405. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48406. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48407. */
  48408. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48409. /**
  48410. * Checks to see if a texture is used in the material.
  48411. * @param texture - Base texture to use.
  48412. * @returns - Boolean specifying if a texture is used in the material.
  48413. */
  48414. hasTexture(texture: BaseTexture): boolean;
  48415. /**
  48416. * Returns an array of the actively used textures.
  48417. * @param activeTextures Array of BaseTextures
  48418. */
  48419. getActiveTextures(activeTextures: BaseTexture[]): void;
  48420. /**
  48421. * Returns the animatable textures.
  48422. * @param animatables Array of animatable textures.
  48423. */
  48424. getAnimatables(animatables: IAnimatable[]): void;
  48425. /**
  48426. * Disposes the resources of the material.
  48427. * @param forceDisposeTextures - Forces the disposal of all textures.
  48428. */
  48429. dispose(forceDisposeTextures?: boolean): void;
  48430. /**
  48431. * Get the current class name of the texture useful for serialization or dynamic coding.
  48432. * @returns "PBRClearCoatConfiguration"
  48433. */
  48434. getClassName(): string;
  48435. /**
  48436. * Add fallbacks to the effect fallbacks list.
  48437. * @param defines defines the Base texture to use.
  48438. * @param fallbacks defines the current fallback list.
  48439. * @param currentRank defines the current fallback rank.
  48440. * @returns the new fallback rank.
  48441. */
  48442. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48443. /**
  48444. * Add the required uniforms to the current list.
  48445. * @param uniforms defines the current uniform list.
  48446. */
  48447. static AddUniforms(uniforms: string[]): void;
  48448. /**
  48449. * Add the required samplers to the current list.
  48450. * @param samplers defines the current sampler list.
  48451. */
  48452. static AddSamplers(samplers: string[]): void;
  48453. /**
  48454. * Add the required uniforms to the current buffer.
  48455. * @param uniformBuffer defines the current uniform buffer.
  48456. */
  48457. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48458. /**
  48459. * Makes a duplicate of the current configuration into another one.
  48460. * @param clearCoatConfiguration define the config where to copy the info
  48461. */
  48462. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48463. /**
  48464. * Serializes this clear coat configuration.
  48465. * @returns - An object with the serialized config.
  48466. */
  48467. serialize(): any;
  48468. /**
  48469. * Parses a anisotropy Configuration from a serialized object.
  48470. * @param source - Serialized object.
  48471. * @param scene Defines the scene we are parsing for
  48472. * @param rootUrl Defines the rootUrl to load from
  48473. */
  48474. parse(source: any, scene: Scene, rootUrl: string): void;
  48475. }
  48476. }
  48477. declare module BABYLON {
  48478. /**
  48479. * @hidden
  48480. */
  48481. export interface IMaterialAnisotropicDefines {
  48482. ANISOTROPIC: boolean;
  48483. ANISOTROPIC_TEXTURE: boolean;
  48484. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48485. MAINUV1: boolean;
  48486. _areTexturesDirty: boolean;
  48487. _needUVs: boolean;
  48488. }
  48489. /**
  48490. * Define the code related to the anisotropic parameters of the pbr material.
  48491. */
  48492. export class PBRAnisotropicConfiguration {
  48493. private _isEnabled;
  48494. /**
  48495. * Defines if the anisotropy is enabled in the material.
  48496. */
  48497. isEnabled: boolean;
  48498. /**
  48499. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48500. */
  48501. intensity: number;
  48502. /**
  48503. * Defines if the effect is along the tangents, bitangents or in between.
  48504. * By default, the effect is "strectching" the highlights along the tangents.
  48505. */
  48506. direction: Vector2;
  48507. private _texture;
  48508. /**
  48509. * Stores the anisotropy values in a texture.
  48510. * rg is direction (like normal from -1 to 1)
  48511. * b is a intensity
  48512. */
  48513. texture: Nullable<BaseTexture>;
  48514. /** @hidden */
  48515. private _internalMarkAllSubMeshesAsTexturesDirty;
  48516. /** @hidden */
  48517. _markAllSubMeshesAsTexturesDirty(): void;
  48518. /**
  48519. * Instantiate a new istance of anisotropy configuration.
  48520. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48521. */
  48522. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48523. /**
  48524. * Specifies that the submesh is ready to be used.
  48525. * @param defines the list of "defines" to update.
  48526. * @param scene defines the scene the material belongs to.
  48527. * @returns - boolean indicating that the submesh is ready or not.
  48528. */
  48529. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48530. /**
  48531. * Checks to see if a texture is used in the material.
  48532. * @param defines the list of "defines" to update.
  48533. * @param mesh the mesh we are preparing the defines for.
  48534. * @param scene defines the scene the material belongs to.
  48535. */
  48536. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48537. /**
  48538. * Binds the material data.
  48539. * @param uniformBuffer defines the Uniform buffer to fill in.
  48540. * @param scene defines the scene the material belongs to.
  48541. * @param isFrozen defines wether the material is frozen or not.
  48542. */
  48543. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48544. /**
  48545. * Checks to see if a texture is used in the material.
  48546. * @param texture - Base texture to use.
  48547. * @returns - Boolean specifying if a texture is used in the material.
  48548. */
  48549. hasTexture(texture: BaseTexture): boolean;
  48550. /**
  48551. * Returns an array of the actively used textures.
  48552. * @param activeTextures Array of BaseTextures
  48553. */
  48554. getActiveTextures(activeTextures: BaseTexture[]): void;
  48555. /**
  48556. * Returns the animatable textures.
  48557. * @param animatables Array of animatable textures.
  48558. */
  48559. getAnimatables(animatables: IAnimatable[]): void;
  48560. /**
  48561. * Disposes the resources of the material.
  48562. * @param forceDisposeTextures - Forces the disposal of all textures.
  48563. */
  48564. dispose(forceDisposeTextures?: boolean): void;
  48565. /**
  48566. * Get the current class name of the texture useful for serialization or dynamic coding.
  48567. * @returns "PBRAnisotropicConfiguration"
  48568. */
  48569. getClassName(): string;
  48570. /**
  48571. * Add fallbacks to the effect fallbacks list.
  48572. * @param defines defines the Base texture to use.
  48573. * @param fallbacks defines the current fallback list.
  48574. * @param currentRank defines the current fallback rank.
  48575. * @returns the new fallback rank.
  48576. */
  48577. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48578. /**
  48579. * Add the required uniforms to the current list.
  48580. * @param uniforms defines the current uniform list.
  48581. */
  48582. static AddUniforms(uniforms: string[]): void;
  48583. /**
  48584. * Add the required uniforms to the current buffer.
  48585. * @param uniformBuffer defines the current uniform buffer.
  48586. */
  48587. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48588. /**
  48589. * Add the required samplers to the current list.
  48590. * @param samplers defines the current sampler list.
  48591. */
  48592. static AddSamplers(samplers: string[]): void;
  48593. /**
  48594. * Makes a duplicate of the current configuration into another one.
  48595. * @param anisotropicConfiguration define the config where to copy the info
  48596. */
  48597. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48598. /**
  48599. * Serializes this anisotropy configuration.
  48600. * @returns - An object with the serialized config.
  48601. */
  48602. serialize(): any;
  48603. /**
  48604. * Parses a anisotropy Configuration from a serialized object.
  48605. * @param source - Serialized object.
  48606. * @param scene Defines the scene we are parsing for
  48607. * @param rootUrl Defines the rootUrl to load from
  48608. */
  48609. parse(source: any, scene: Scene, rootUrl: string): void;
  48610. }
  48611. }
  48612. declare module BABYLON {
  48613. /**
  48614. * @hidden
  48615. */
  48616. export interface IMaterialBRDFDefines {
  48617. BRDF_V_HEIGHT_CORRELATED: boolean;
  48618. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48619. SPHERICAL_HARMONICS: boolean;
  48620. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48621. /** @hidden */
  48622. _areMiscDirty: boolean;
  48623. }
  48624. /**
  48625. * Define the code related to the BRDF parameters of the pbr material.
  48626. */
  48627. export class PBRBRDFConfiguration {
  48628. /**
  48629. * Default value used for the energy conservation.
  48630. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48631. */
  48632. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48633. /**
  48634. * Default value used for the Smith Visibility Height Correlated mode.
  48635. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48636. */
  48637. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48638. /**
  48639. * Default value used for the IBL diffuse part.
  48640. * This can help switching back to the polynomials mode globally which is a tiny bit
  48641. * less GPU intensive at the drawback of a lower quality.
  48642. */
  48643. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48644. /**
  48645. * Default value used for activating energy conservation for the specular workflow.
  48646. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48647. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48648. */
  48649. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48650. private _useEnergyConservation;
  48651. /**
  48652. * Defines if the material uses energy conservation.
  48653. */
  48654. useEnergyConservation: boolean;
  48655. private _useSmithVisibilityHeightCorrelated;
  48656. /**
  48657. * LEGACY Mode set to false
  48658. * Defines if the material uses height smith correlated visibility term.
  48659. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48660. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48661. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48662. * Not relying on height correlated will also disable energy conservation.
  48663. */
  48664. useSmithVisibilityHeightCorrelated: boolean;
  48665. private _useSphericalHarmonics;
  48666. /**
  48667. * LEGACY Mode set to false
  48668. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48669. * diffuse part of the IBL.
  48670. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48671. * to the ground truth.
  48672. */
  48673. useSphericalHarmonics: boolean;
  48674. private _useSpecularGlossinessInputEnergyConservation;
  48675. /**
  48676. * Defines if the material uses energy conservation, when the specular workflow is active.
  48677. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48678. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48679. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48680. */
  48681. useSpecularGlossinessInputEnergyConservation: boolean;
  48682. /** @hidden */
  48683. private _internalMarkAllSubMeshesAsMiscDirty;
  48684. /** @hidden */
  48685. _markAllSubMeshesAsMiscDirty(): void;
  48686. /**
  48687. * Instantiate a new istance of clear coat configuration.
  48688. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48689. */
  48690. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48691. /**
  48692. * Checks to see if a texture is used in the material.
  48693. * @param defines the list of "defines" to update.
  48694. */
  48695. prepareDefines(defines: IMaterialBRDFDefines): void;
  48696. /**
  48697. * Get the current class name of the texture useful for serialization or dynamic coding.
  48698. * @returns "PBRClearCoatConfiguration"
  48699. */
  48700. getClassName(): string;
  48701. /**
  48702. * Makes a duplicate of the current configuration into another one.
  48703. * @param brdfConfiguration define the config where to copy the info
  48704. */
  48705. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48706. /**
  48707. * Serializes this BRDF configuration.
  48708. * @returns - An object with the serialized config.
  48709. */
  48710. serialize(): any;
  48711. /**
  48712. * Parses a anisotropy Configuration from a serialized object.
  48713. * @param source - Serialized object.
  48714. * @param scene Defines the scene we are parsing for
  48715. * @param rootUrl Defines the rootUrl to load from
  48716. */
  48717. parse(source: any, scene: Scene, rootUrl: string): void;
  48718. }
  48719. }
  48720. declare module BABYLON {
  48721. /**
  48722. * @hidden
  48723. */
  48724. export interface IMaterialSheenDefines {
  48725. SHEEN: boolean;
  48726. SHEEN_TEXTURE: boolean;
  48727. SHEEN_TEXTUREDIRECTUV: number;
  48728. SHEEN_LINKWITHALBEDO: boolean;
  48729. /** @hidden */
  48730. _areTexturesDirty: boolean;
  48731. }
  48732. /**
  48733. * Define the code related to the Sheen parameters of the pbr material.
  48734. */
  48735. export class PBRSheenConfiguration {
  48736. private _isEnabled;
  48737. /**
  48738. * Defines if the material uses sheen.
  48739. */
  48740. isEnabled: boolean;
  48741. private _linkSheenWithAlbedo;
  48742. /**
  48743. * Defines if the sheen is linked to the sheen color.
  48744. */
  48745. linkSheenWithAlbedo: boolean;
  48746. /**
  48747. * Defines the sheen intensity.
  48748. */
  48749. intensity: number;
  48750. /**
  48751. * Defines the sheen color.
  48752. */
  48753. color: Color3;
  48754. private _texture;
  48755. /**
  48756. * Stores the sheen tint values in a texture.
  48757. * rgb is tint
  48758. * a is a intensity
  48759. */
  48760. texture: Nullable<BaseTexture>;
  48761. /** @hidden */
  48762. private _internalMarkAllSubMeshesAsTexturesDirty;
  48763. /** @hidden */
  48764. _markAllSubMeshesAsTexturesDirty(): void;
  48765. /**
  48766. * Instantiate a new istance of clear coat configuration.
  48767. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48768. */
  48769. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48770. /**
  48771. * Specifies that the submesh is ready to be used.
  48772. * @param defines the list of "defines" to update.
  48773. * @param scene defines the scene the material belongs to.
  48774. * @returns - boolean indicating that the submesh is ready or not.
  48775. */
  48776. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48777. /**
  48778. * Checks to see if a texture is used in the material.
  48779. * @param defines the list of "defines" to update.
  48780. * @param scene defines the scene the material belongs to.
  48781. */
  48782. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48783. /**
  48784. * Binds the material data.
  48785. * @param uniformBuffer defines the Uniform buffer to fill in.
  48786. * @param scene defines the scene the material belongs to.
  48787. * @param isFrozen defines wether the material is frozen or not.
  48788. */
  48789. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48790. /**
  48791. * Checks to see if a texture is used in the material.
  48792. * @param texture - Base texture to use.
  48793. * @returns - Boolean specifying if a texture is used in the material.
  48794. */
  48795. hasTexture(texture: BaseTexture): boolean;
  48796. /**
  48797. * Returns an array of the actively used textures.
  48798. * @param activeTextures Array of BaseTextures
  48799. */
  48800. getActiveTextures(activeTextures: BaseTexture[]): void;
  48801. /**
  48802. * Returns the animatable textures.
  48803. * @param animatables Array of animatable textures.
  48804. */
  48805. getAnimatables(animatables: IAnimatable[]): void;
  48806. /**
  48807. * Disposes the resources of the material.
  48808. * @param forceDisposeTextures - Forces the disposal of all textures.
  48809. */
  48810. dispose(forceDisposeTextures?: boolean): void;
  48811. /**
  48812. * Get the current class name of the texture useful for serialization or dynamic coding.
  48813. * @returns "PBRSheenConfiguration"
  48814. */
  48815. getClassName(): string;
  48816. /**
  48817. * Add fallbacks to the effect fallbacks list.
  48818. * @param defines defines the Base texture to use.
  48819. * @param fallbacks defines the current fallback list.
  48820. * @param currentRank defines the current fallback rank.
  48821. * @returns the new fallback rank.
  48822. */
  48823. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48824. /**
  48825. * Add the required uniforms to the current list.
  48826. * @param uniforms defines the current uniform list.
  48827. */
  48828. static AddUniforms(uniforms: string[]): void;
  48829. /**
  48830. * Add the required uniforms to the current buffer.
  48831. * @param uniformBuffer defines the current uniform buffer.
  48832. */
  48833. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48834. /**
  48835. * Add the required samplers to the current list.
  48836. * @param samplers defines the current sampler list.
  48837. */
  48838. static AddSamplers(samplers: string[]): void;
  48839. /**
  48840. * Makes a duplicate of the current configuration into another one.
  48841. * @param sheenConfiguration define the config where to copy the info
  48842. */
  48843. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48844. /**
  48845. * Serializes this BRDF configuration.
  48846. * @returns - An object with the serialized config.
  48847. */
  48848. serialize(): any;
  48849. /**
  48850. * Parses a anisotropy Configuration from a serialized object.
  48851. * @param source - Serialized object.
  48852. * @param scene Defines the scene we are parsing for
  48853. * @param rootUrl Defines the rootUrl to load from
  48854. */
  48855. parse(source: any, scene: Scene, rootUrl: string): void;
  48856. }
  48857. }
  48858. declare module BABYLON {
  48859. /**
  48860. * @hidden
  48861. */
  48862. export interface IMaterialSubSurfaceDefines {
  48863. SUBSURFACE: boolean;
  48864. SS_REFRACTION: boolean;
  48865. SS_TRANSLUCENCY: boolean;
  48866. SS_SCATERRING: boolean;
  48867. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48868. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48869. SS_REFRACTIONMAP_3D: boolean;
  48870. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48871. SS_LODINREFRACTIONALPHA: boolean;
  48872. SS_GAMMAREFRACTION: boolean;
  48873. SS_RGBDREFRACTION: boolean;
  48874. SS_LINEARSPECULARREFRACTION: boolean;
  48875. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48876. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48877. /** @hidden */
  48878. _areTexturesDirty: boolean;
  48879. }
  48880. /**
  48881. * Define the code related to the sub surface parameters of the pbr material.
  48882. */
  48883. export class PBRSubSurfaceConfiguration {
  48884. private _isRefractionEnabled;
  48885. /**
  48886. * Defines if the refraction is enabled in the material.
  48887. */
  48888. isRefractionEnabled: boolean;
  48889. private _isTranslucencyEnabled;
  48890. /**
  48891. * Defines if the translucency is enabled in the material.
  48892. */
  48893. isTranslucencyEnabled: boolean;
  48894. private _isScatteringEnabled;
  48895. /**
  48896. * Defines the refraction intensity of the material.
  48897. * The refraction when enabled replaces the Diffuse part of the material.
  48898. * The intensity helps transitionning between diffuse and refraction.
  48899. */
  48900. refractionIntensity: number;
  48901. /**
  48902. * Defines the translucency intensity of the material.
  48903. * When translucency has been enabled, this defines how much of the "translucency"
  48904. * is addded to the diffuse part of the material.
  48905. */
  48906. translucencyIntensity: number;
  48907. /**
  48908. * Defines the scattering intensity of the material.
  48909. * When scattering has been enabled, this defines how much of the "scattered light"
  48910. * is addded to the diffuse part of the material.
  48911. */
  48912. scatteringIntensity: number;
  48913. private _thicknessTexture;
  48914. /**
  48915. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48916. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48917. * 0 would mean minimumThickness
  48918. * 1 would mean maximumThickness
  48919. * The other channels might be use as a mask to vary the different effects intensity.
  48920. */
  48921. thicknessTexture: Nullable<BaseTexture>;
  48922. private _refractionTexture;
  48923. /**
  48924. * Defines the texture to use for refraction.
  48925. */
  48926. refractionTexture: Nullable<BaseTexture>;
  48927. private _indexOfRefraction;
  48928. /**
  48929. * Defines the index of refraction used in the material.
  48930. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48931. */
  48932. indexOfRefraction: number;
  48933. private _invertRefractionY;
  48934. /**
  48935. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48936. */
  48937. invertRefractionY: boolean;
  48938. private _linkRefractionWithTransparency;
  48939. /**
  48940. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48941. * Materials half opaque for instance using refraction could benefit from this control.
  48942. */
  48943. linkRefractionWithTransparency: boolean;
  48944. /**
  48945. * Defines the minimum thickness stored in the thickness map.
  48946. * If no thickness map is defined, this value will be used to simulate thickness.
  48947. */
  48948. minimumThickness: number;
  48949. /**
  48950. * Defines the maximum thickness stored in the thickness map.
  48951. */
  48952. maximumThickness: number;
  48953. /**
  48954. * Defines the volume tint of the material.
  48955. * This is used for both translucency and scattering.
  48956. */
  48957. tintColor: Color3;
  48958. /**
  48959. * Defines the distance at which the tint color should be found in the media.
  48960. * This is used for refraction only.
  48961. */
  48962. tintColorAtDistance: number;
  48963. /**
  48964. * Defines how far each channel transmit through the media.
  48965. * It is defined as a color to simplify it selection.
  48966. */
  48967. diffusionDistance: Color3;
  48968. private _useMaskFromThicknessTexture;
  48969. /**
  48970. * Stores the intensity of the different subsurface effects in the thickness texture.
  48971. * * the green channel is the translucency intensity.
  48972. * * the blue channel is the scattering intensity.
  48973. * * the alpha channel is the refraction intensity.
  48974. */
  48975. useMaskFromThicknessTexture: boolean;
  48976. /** @hidden */
  48977. private _internalMarkAllSubMeshesAsTexturesDirty;
  48978. /** @hidden */
  48979. _markAllSubMeshesAsTexturesDirty(): void;
  48980. /**
  48981. * Instantiate a new istance of sub surface configuration.
  48982. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48983. */
  48984. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48985. /**
  48986. * Gets wehter the submesh is ready to be used or not.
  48987. * @param defines the list of "defines" to update.
  48988. * @param scene defines the scene the material belongs to.
  48989. * @returns - boolean indicating that the submesh is ready or not.
  48990. */
  48991. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48992. /**
  48993. * Checks to see if a texture is used in the material.
  48994. * @param defines the list of "defines" to update.
  48995. * @param scene defines the scene to the material belongs to.
  48996. */
  48997. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48998. /**
  48999. * Binds the material data.
  49000. * @param uniformBuffer defines the Uniform buffer to fill in.
  49001. * @param scene defines the scene the material belongs to.
  49002. * @param engine defines the engine the material belongs to.
  49003. * @param isFrozen defines wether the material is frozen or not.
  49004. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49005. */
  49006. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49007. /**
  49008. * Unbinds the material from the mesh.
  49009. * @param activeEffect defines the effect that should be unbound from.
  49010. * @returns true if unbound, otherwise false
  49011. */
  49012. unbind(activeEffect: Effect): boolean;
  49013. /**
  49014. * Returns the texture used for refraction or null if none is used.
  49015. * @param scene defines the scene the material belongs to.
  49016. * @returns - Refraction texture if present. If no refraction texture and refraction
  49017. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49018. */
  49019. private _getRefractionTexture;
  49020. /**
  49021. * Returns true if alpha blending should be disabled.
  49022. */
  49023. readonly disableAlphaBlending: boolean;
  49024. /**
  49025. * Fills the list of render target textures.
  49026. * @param renderTargets the list of render targets to update
  49027. */
  49028. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49029. /**
  49030. * Checks to see if a texture is used in the material.
  49031. * @param texture - Base texture to use.
  49032. * @returns - Boolean specifying if a texture is used in the material.
  49033. */
  49034. hasTexture(texture: BaseTexture): boolean;
  49035. /**
  49036. * Gets a boolean indicating that current material needs to register RTT
  49037. * @returns true if this uses a render target otherwise false.
  49038. */
  49039. hasRenderTargetTextures(): boolean;
  49040. /**
  49041. * Returns an array of the actively used textures.
  49042. * @param activeTextures Array of BaseTextures
  49043. */
  49044. getActiveTextures(activeTextures: BaseTexture[]): void;
  49045. /**
  49046. * Returns the animatable textures.
  49047. * @param animatables Array of animatable textures.
  49048. */
  49049. getAnimatables(animatables: IAnimatable[]): void;
  49050. /**
  49051. * Disposes the resources of the material.
  49052. * @param forceDisposeTextures - Forces the disposal of all textures.
  49053. */
  49054. dispose(forceDisposeTextures?: boolean): void;
  49055. /**
  49056. * Get the current class name of the texture useful for serialization or dynamic coding.
  49057. * @returns "PBRSubSurfaceConfiguration"
  49058. */
  49059. getClassName(): string;
  49060. /**
  49061. * Add fallbacks to the effect fallbacks list.
  49062. * @param defines defines the Base texture to use.
  49063. * @param fallbacks defines the current fallback list.
  49064. * @param currentRank defines the current fallback rank.
  49065. * @returns the new fallback rank.
  49066. */
  49067. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49068. /**
  49069. * Add the required uniforms to the current list.
  49070. * @param uniforms defines the current uniform list.
  49071. */
  49072. static AddUniforms(uniforms: string[]): void;
  49073. /**
  49074. * Add the required samplers to the current list.
  49075. * @param samplers defines the current sampler list.
  49076. */
  49077. static AddSamplers(samplers: string[]): void;
  49078. /**
  49079. * Add the required uniforms to the current buffer.
  49080. * @param uniformBuffer defines the current uniform buffer.
  49081. */
  49082. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49083. /**
  49084. * Makes a duplicate of the current configuration into another one.
  49085. * @param configuration define the config where to copy the info
  49086. */
  49087. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49088. /**
  49089. * Serializes this Sub Surface configuration.
  49090. * @returns - An object with the serialized config.
  49091. */
  49092. serialize(): any;
  49093. /**
  49094. * Parses a anisotropy Configuration from a serialized object.
  49095. * @param source - Serialized object.
  49096. * @param scene Defines the scene we are parsing for
  49097. * @param rootUrl Defines the rootUrl to load from
  49098. */
  49099. parse(source: any, scene: Scene, rootUrl: string): void;
  49100. }
  49101. }
  49102. declare module BABYLON {
  49103. /** @hidden */
  49104. export var pbrFragmentDeclaration: {
  49105. name: string;
  49106. shader: string;
  49107. };
  49108. }
  49109. declare module BABYLON {
  49110. /** @hidden */
  49111. export var pbrUboDeclaration: {
  49112. name: string;
  49113. shader: string;
  49114. };
  49115. }
  49116. declare module BABYLON {
  49117. /** @hidden */
  49118. export var pbrFragmentExtraDeclaration: {
  49119. name: string;
  49120. shader: string;
  49121. };
  49122. }
  49123. declare module BABYLON {
  49124. /** @hidden */
  49125. export var pbrFragmentSamplersDeclaration: {
  49126. name: string;
  49127. shader: string;
  49128. };
  49129. }
  49130. declare module BABYLON {
  49131. /** @hidden */
  49132. export var pbrHelperFunctions: {
  49133. name: string;
  49134. shader: string;
  49135. };
  49136. }
  49137. declare module BABYLON {
  49138. /** @hidden */
  49139. export var harmonicsFunctions: {
  49140. name: string;
  49141. shader: string;
  49142. };
  49143. }
  49144. declare module BABYLON {
  49145. /** @hidden */
  49146. export var pbrDirectLightingSetupFunctions: {
  49147. name: string;
  49148. shader: string;
  49149. };
  49150. }
  49151. declare module BABYLON {
  49152. /** @hidden */
  49153. export var pbrDirectLightingFalloffFunctions: {
  49154. name: string;
  49155. shader: string;
  49156. };
  49157. }
  49158. declare module BABYLON {
  49159. /** @hidden */
  49160. export var pbrBRDFFunctions: {
  49161. name: string;
  49162. shader: string;
  49163. };
  49164. }
  49165. declare module BABYLON {
  49166. /** @hidden */
  49167. export var pbrDirectLightingFunctions: {
  49168. name: string;
  49169. shader: string;
  49170. };
  49171. }
  49172. declare module BABYLON {
  49173. /** @hidden */
  49174. export var pbrIBLFunctions: {
  49175. name: string;
  49176. shader: string;
  49177. };
  49178. }
  49179. declare module BABYLON {
  49180. /** @hidden */
  49181. export var pbrDebug: {
  49182. name: string;
  49183. shader: string;
  49184. };
  49185. }
  49186. declare module BABYLON {
  49187. /** @hidden */
  49188. export var pbrPixelShader: {
  49189. name: string;
  49190. shader: string;
  49191. };
  49192. }
  49193. declare module BABYLON {
  49194. /** @hidden */
  49195. export var pbrVertexDeclaration: {
  49196. name: string;
  49197. shader: string;
  49198. };
  49199. }
  49200. declare module BABYLON {
  49201. /** @hidden */
  49202. export var pbrVertexShader: {
  49203. name: string;
  49204. shader: string;
  49205. };
  49206. }
  49207. declare module BABYLON {
  49208. /**
  49209. * Manages the defines for the PBR Material.
  49210. * @hidden
  49211. */
  49212. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49213. PBR: boolean;
  49214. MAINUV1: boolean;
  49215. MAINUV2: boolean;
  49216. UV1: boolean;
  49217. UV2: boolean;
  49218. ALBEDO: boolean;
  49219. ALBEDODIRECTUV: number;
  49220. VERTEXCOLOR: boolean;
  49221. AMBIENT: boolean;
  49222. AMBIENTDIRECTUV: number;
  49223. AMBIENTINGRAYSCALE: boolean;
  49224. OPACITY: boolean;
  49225. VERTEXALPHA: boolean;
  49226. OPACITYDIRECTUV: number;
  49227. OPACITYRGB: boolean;
  49228. ALPHATEST: boolean;
  49229. DEPTHPREPASS: boolean;
  49230. ALPHABLEND: boolean;
  49231. ALPHAFROMALBEDO: boolean;
  49232. ALPHATESTVALUE: string;
  49233. SPECULAROVERALPHA: boolean;
  49234. RADIANCEOVERALPHA: boolean;
  49235. ALPHAFRESNEL: boolean;
  49236. LINEARALPHAFRESNEL: boolean;
  49237. PREMULTIPLYALPHA: boolean;
  49238. EMISSIVE: boolean;
  49239. EMISSIVEDIRECTUV: number;
  49240. REFLECTIVITY: boolean;
  49241. REFLECTIVITYDIRECTUV: number;
  49242. SPECULARTERM: boolean;
  49243. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49244. MICROSURFACEAUTOMATIC: boolean;
  49245. LODBASEDMICROSFURACE: boolean;
  49246. MICROSURFACEMAP: boolean;
  49247. MICROSURFACEMAPDIRECTUV: number;
  49248. METALLICWORKFLOW: boolean;
  49249. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49250. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49251. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49252. AOSTOREINMETALMAPRED: boolean;
  49253. METALLICF0FACTORFROMMETALLICMAP: boolean;
  49254. ENVIRONMENTBRDF: boolean;
  49255. ENVIRONMENTBRDF_RGBD: boolean;
  49256. NORMAL: boolean;
  49257. TANGENT: boolean;
  49258. BUMP: boolean;
  49259. BUMPDIRECTUV: number;
  49260. OBJECTSPACE_NORMALMAP: boolean;
  49261. PARALLAX: boolean;
  49262. PARALLAXOCCLUSION: boolean;
  49263. NORMALXYSCALE: boolean;
  49264. LIGHTMAP: boolean;
  49265. LIGHTMAPDIRECTUV: number;
  49266. USELIGHTMAPASSHADOWMAP: boolean;
  49267. GAMMALIGHTMAP: boolean;
  49268. RGBDLIGHTMAP: boolean;
  49269. REFLECTION: boolean;
  49270. REFLECTIONMAP_3D: boolean;
  49271. REFLECTIONMAP_SPHERICAL: boolean;
  49272. REFLECTIONMAP_PLANAR: boolean;
  49273. REFLECTIONMAP_CUBIC: boolean;
  49274. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49275. REFLECTIONMAP_PROJECTION: boolean;
  49276. REFLECTIONMAP_SKYBOX: boolean;
  49277. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49278. REFLECTIONMAP_EXPLICIT: boolean;
  49279. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49280. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49281. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49282. INVERTCUBICMAP: boolean;
  49283. USESPHERICALFROMREFLECTIONMAP: boolean;
  49284. USEIRRADIANCEMAP: boolean;
  49285. SPHERICAL_HARMONICS: boolean;
  49286. USESPHERICALINVERTEX: boolean;
  49287. REFLECTIONMAP_OPPOSITEZ: boolean;
  49288. LODINREFLECTIONALPHA: boolean;
  49289. GAMMAREFLECTION: boolean;
  49290. RGBDREFLECTION: boolean;
  49291. LINEARSPECULARREFLECTION: boolean;
  49292. RADIANCEOCCLUSION: boolean;
  49293. HORIZONOCCLUSION: boolean;
  49294. INSTANCES: boolean;
  49295. NUM_BONE_INFLUENCERS: number;
  49296. BonesPerMesh: number;
  49297. BONETEXTURE: boolean;
  49298. NONUNIFORMSCALING: boolean;
  49299. MORPHTARGETS: boolean;
  49300. MORPHTARGETS_NORMAL: boolean;
  49301. MORPHTARGETS_TANGENT: boolean;
  49302. MORPHTARGETS_UV: boolean;
  49303. NUM_MORPH_INFLUENCERS: number;
  49304. IMAGEPROCESSING: boolean;
  49305. VIGNETTE: boolean;
  49306. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49307. VIGNETTEBLENDMODEOPAQUE: boolean;
  49308. TONEMAPPING: boolean;
  49309. TONEMAPPING_ACES: boolean;
  49310. CONTRAST: boolean;
  49311. COLORCURVES: boolean;
  49312. COLORGRADING: boolean;
  49313. COLORGRADING3D: boolean;
  49314. SAMPLER3DGREENDEPTH: boolean;
  49315. SAMPLER3DBGRMAP: boolean;
  49316. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49317. EXPOSURE: boolean;
  49318. MULTIVIEW: boolean;
  49319. USEPHYSICALLIGHTFALLOFF: boolean;
  49320. USEGLTFLIGHTFALLOFF: boolean;
  49321. TWOSIDEDLIGHTING: boolean;
  49322. SHADOWFLOAT: boolean;
  49323. CLIPPLANE: boolean;
  49324. CLIPPLANE2: boolean;
  49325. CLIPPLANE3: boolean;
  49326. CLIPPLANE4: boolean;
  49327. POINTSIZE: boolean;
  49328. FOG: boolean;
  49329. LOGARITHMICDEPTH: boolean;
  49330. FORCENORMALFORWARD: boolean;
  49331. SPECULARAA: boolean;
  49332. CLEARCOAT: boolean;
  49333. CLEARCOAT_DEFAULTIOR: boolean;
  49334. CLEARCOAT_TEXTURE: boolean;
  49335. CLEARCOAT_TEXTUREDIRECTUV: number;
  49336. CLEARCOAT_BUMP: boolean;
  49337. CLEARCOAT_BUMPDIRECTUV: number;
  49338. CLEARCOAT_TINT: boolean;
  49339. CLEARCOAT_TINT_TEXTURE: boolean;
  49340. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49341. ANISOTROPIC: boolean;
  49342. ANISOTROPIC_TEXTURE: boolean;
  49343. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49344. BRDF_V_HEIGHT_CORRELATED: boolean;
  49345. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49346. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49347. SHEEN: boolean;
  49348. SHEEN_TEXTURE: boolean;
  49349. SHEEN_TEXTUREDIRECTUV: number;
  49350. SHEEN_LINKWITHALBEDO: boolean;
  49351. SUBSURFACE: boolean;
  49352. SS_REFRACTION: boolean;
  49353. SS_TRANSLUCENCY: boolean;
  49354. SS_SCATERRING: boolean;
  49355. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49356. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49357. SS_REFRACTIONMAP_3D: boolean;
  49358. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49359. SS_LODINREFRACTIONALPHA: boolean;
  49360. SS_GAMMAREFRACTION: boolean;
  49361. SS_RGBDREFRACTION: boolean;
  49362. SS_LINEARSPECULARREFRACTION: boolean;
  49363. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49364. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49365. UNLIT: boolean;
  49366. DEBUGMODE: number;
  49367. /**
  49368. * Initializes the PBR Material defines.
  49369. */
  49370. constructor();
  49371. /**
  49372. * Resets the PBR Material defines.
  49373. */
  49374. reset(): void;
  49375. }
  49376. /**
  49377. * The Physically based material base class of BJS.
  49378. *
  49379. * This offers the main features of a standard PBR material.
  49380. * For more information, please refer to the documentation :
  49381. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49382. */
  49383. export abstract class PBRBaseMaterial extends PushMaterial {
  49384. /**
  49385. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49386. */
  49387. static readonly PBRMATERIAL_OPAQUE: number;
  49388. /**
  49389. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49390. */
  49391. static readonly PBRMATERIAL_ALPHATEST: number;
  49392. /**
  49393. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49394. */
  49395. static readonly PBRMATERIAL_ALPHABLEND: number;
  49396. /**
  49397. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49398. * They are also discarded below the alpha cutoff threshold to improve performances.
  49399. */
  49400. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49401. /**
  49402. * Defines the default value of how much AO map is occluding the analytical lights
  49403. * (point spot...).
  49404. */
  49405. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49406. /**
  49407. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49408. */
  49409. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49410. /**
  49411. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49412. * to enhance interoperability with other engines.
  49413. */
  49414. static readonly LIGHTFALLOFF_GLTF: number;
  49415. /**
  49416. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49417. * to enhance interoperability with other materials.
  49418. */
  49419. static readonly LIGHTFALLOFF_STANDARD: number;
  49420. /**
  49421. * Intensity of the direct lights e.g. the four lights available in your scene.
  49422. * This impacts both the direct diffuse and specular highlights.
  49423. */
  49424. protected _directIntensity: number;
  49425. /**
  49426. * Intensity of the emissive part of the material.
  49427. * This helps controlling the emissive effect without modifying the emissive color.
  49428. */
  49429. protected _emissiveIntensity: number;
  49430. /**
  49431. * Intensity of the environment e.g. how much the environment will light the object
  49432. * either through harmonics for rough material or through the refelction for shiny ones.
  49433. */
  49434. protected _environmentIntensity: number;
  49435. /**
  49436. * This is a special control allowing the reduction of the specular highlights coming from the
  49437. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49438. */
  49439. protected _specularIntensity: number;
  49440. /**
  49441. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49442. */
  49443. private _lightingInfos;
  49444. /**
  49445. * Debug Control allowing disabling the bump map on this material.
  49446. */
  49447. protected _disableBumpMap: boolean;
  49448. /**
  49449. * AKA Diffuse Texture in standard nomenclature.
  49450. */
  49451. protected _albedoTexture: Nullable<BaseTexture>;
  49452. /**
  49453. * AKA Occlusion Texture in other nomenclature.
  49454. */
  49455. protected _ambientTexture: Nullable<BaseTexture>;
  49456. /**
  49457. * AKA Occlusion Texture Intensity in other nomenclature.
  49458. */
  49459. protected _ambientTextureStrength: number;
  49460. /**
  49461. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49462. * 1 means it completely occludes it
  49463. * 0 mean it has no impact
  49464. */
  49465. protected _ambientTextureImpactOnAnalyticalLights: number;
  49466. /**
  49467. * Stores the alpha values in a texture.
  49468. */
  49469. protected _opacityTexture: Nullable<BaseTexture>;
  49470. /**
  49471. * Stores the reflection values in a texture.
  49472. */
  49473. protected _reflectionTexture: Nullable<BaseTexture>;
  49474. /**
  49475. * Stores the emissive values in a texture.
  49476. */
  49477. protected _emissiveTexture: Nullable<BaseTexture>;
  49478. /**
  49479. * AKA Specular texture in other nomenclature.
  49480. */
  49481. protected _reflectivityTexture: Nullable<BaseTexture>;
  49482. /**
  49483. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49484. */
  49485. protected _metallicTexture: Nullable<BaseTexture>;
  49486. /**
  49487. * Specifies the metallic scalar of the metallic/roughness workflow.
  49488. * Can also be used to scale the metalness values of the metallic texture.
  49489. */
  49490. protected _metallic: Nullable<number>;
  49491. /**
  49492. * Specifies the roughness scalar of the metallic/roughness workflow.
  49493. * Can also be used to scale the roughness values of the metallic texture.
  49494. */
  49495. protected _roughness: Nullable<number>;
  49496. /**
  49497. * Specifies the an F0 factor to help configuring the material F0.
  49498. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  49499. * to 0.5 the previously hard coded value stays the same.
  49500. * Can also be used to scale the F0 values of the metallic texture.
  49501. */
  49502. protected _metallicF0Factor: number;
  49503. /**
  49504. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  49505. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  49506. * your expectation as it multiplies with the texture data.
  49507. */
  49508. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  49509. /**
  49510. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49511. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49512. */
  49513. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49514. /**
  49515. * Stores surface normal data used to displace a mesh in a texture.
  49516. */
  49517. protected _bumpTexture: Nullable<BaseTexture>;
  49518. /**
  49519. * Stores the pre-calculated light information of a mesh in a texture.
  49520. */
  49521. protected _lightmapTexture: Nullable<BaseTexture>;
  49522. /**
  49523. * The color of a material in ambient lighting.
  49524. */
  49525. protected _ambientColor: Color3;
  49526. /**
  49527. * AKA Diffuse Color in other nomenclature.
  49528. */
  49529. protected _albedoColor: Color3;
  49530. /**
  49531. * AKA Specular Color in other nomenclature.
  49532. */
  49533. protected _reflectivityColor: Color3;
  49534. /**
  49535. * The color applied when light is reflected from a material.
  49536. */
  49537. protected _reflectionColor: Color3;
  49538. /**
  49539. * The color applied when light is emitted from a material.
  49540. */
  49541. protected _emissiveColor: Color3;
  49542. /**
  49543. * AKA Glossiness in other nomenclature.
  49544. */
  49545. protected _microSurface: number;
  49546. /**
  49547. * Specifies that the material will use the light map as a show map.
  49548. */
  49549. protected _useLightmapAsShadowmap: boolean;
  49550. /**
  49551. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49552. * makes the reflect vector face the model (under horizon).
  49553. */
  49554. protected _useHorizonOcclusion: boolean;
  49555. /**
  49556. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49557. * too much the area relying on ambient texture to define their ambient occlusion.
  49558. */
  49559. protected _useRadianceOcclusion: boolean;
  49560. /**
  49561. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49562. */
  49563. protected _useAlphaFromAlbedoTexture: boolean;
  49564. /**
  49565. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49566. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49567. */
  49568. protected _useSpecularOverAlpha: boolean;
  49569. /**
  49570. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49571. */
  49572. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49573. /**
  49574. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49575. */
  49576. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49577. /**
  49578. * Specifies if the metallic texture contains the roughness information in its green channel.
  49579. */
  49580. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49581. /**
  49582. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49583. */
  49584. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49585. /**
  49586. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49587. */
  49588. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49589. /**
  49590. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49591. */
  49592. protected _useAmbientInGrayScale: boolean;
  49593. /**
  49594. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49595. * The material will try to infer what glossiness each pixel should be.
  49596. */
  49597. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49598. /**
  49599. * Defines the falloff type used in this material.
  49600. * It by default is Physical.
  49601. */
  49602. protected _lightFalloff: number;
  49603. /**
  49604. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49605. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49606. */
  49607. protected _useRadianceOverAlpha: boolean;
  49608. /**
  49609. * Allows using an object space normal map (instead of tangent space).
  49610. */
  49611. protected _useObjectSpaceNormalMap: boolean;
  49612. /**
  49613. * Allows using the bump map in parallax mode.
  49614. */
  49615. protected _useParallax: boolean;
  49616. /**
  49617. * Allows using the bump map in parallax occlusion mode.
  49618. */
  49619. protected _useParallaxOcclusion: boolean;
  49620. /**
  49621. * Controls the scale bias of the parallax mode.
  49622. */
  49623. protected _parallaxScaleBias: number;
  49624. /**
  49625. * If sets to true, disables all the lights affecting the material.
  49626. */
  49627. protected _disableLighting: boolean;
  49628. /**
  49629. * Number of Simultaneous lights allowed on the material.
  49630. */
  49631. protected _maxSimultaneousLights: number;
  49632. /**
  49633. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49634. */
  49635. protected _invertNormalMapX: boolean;
  49636. /**
  49637. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49638. */
  49639. protected _invertNormalMapY: boolean;
  49640. /**
  49641. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49642. */
  49643. protected _twoSidedLighting: boolean;
  49644. /**
  49645. * Defines the alpha limits in alpha test mode.
  49646. */
  49647. protected _alphaCutOff: number;
  49648. /**
  49649. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49650. */
  49651. protected _forceAlphaTest: boolean;
  49652. /**
  49653. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49654. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49655. */
  49656. protected _useAlphaFresnel: boolean;
  49657. /**
  49658. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49659. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49660. */
  49661. protected _useLinearAlphaFresnel: boolean;
  49662. /**
  49663. * The transparency mode of the material.
  49664. */
  49665. protected _transparencyMode: Nullable<number>;
  49666. /**
  49667. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49668. * from cos thetav and roughness:
  49669. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49670. */
  49671. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49672. /**
  49673. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49674. */
  49675. protected _forceIrradianceInFragment: boolean;
  49676. /**
  49677. * Force normal to face away from face.
  49678. */
  49679. protected _forceNormalForward: boolean;
  49680. /**
  49681. * Enables specular anti aliasing in the PBR shader.
  49682. * It will both interacts on the Geometry for analytical and IBL lighting.
  49683. * It also prefilter the roughness map based on the bump values.
  49684. */
  49685. protected _enableSpecularAntiAliasing: boolean;
  49686. /**
  49687. * Default configuration related to image processing available in the PBR Material.
  49688. */
  49689. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49690. /**
  49691. * Keep track of the image processing observer to allow dispose and replace.
  49692. */
  49693. private _imageProcessingObserver;
  49694. /**
  49695. * Attaches a new image processing configuration to the PBR Material.
  49696. * @param configuration
  49697. */
  49698. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49699. /**
  49700. * Stores the available render targets.
  49701. */
  49702. private _renderTargets;
  49703. /**
  49704. * Sets the global ambient color for the material used in lighting calculations.
  49705. */
  49706. private _globalAmbientColor;
  49707. /**
  49708. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49709. */
  49710. private _useLogarithmicDepth;
  49711. /**
  49712. * If set to true, no lighting calculations will be applied.
  49713. */
  49714. private _unlit;
  49715. private _debugMode;
  49716. /**
  49717. * @hidden
  49718. * This is reserved for the inspector.
  49719. * Defines the material debug mode.
  49720. * It helps seeing only some components of the material while troubleshooting.
  49721. */
  49722. debugMode: number;
  49723. /**
  49724. * @hidden
  49725. * This is reserved for the inspector.
  49726. * Specify from where on screen the debug mode should start.
  49727. * The value goes from -1 (full screen) to 1 (not visible)
  49728. * It helps with side by side comparison against the final render
  49729. * This defaults to -1
  49730. */
  49731. private debugLimit;
  49732. /**
  49733. * @hidden
  49734. * This is reserved for the inspector.
  49735. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49736. * You can use the factor to better multiply the final value.
  49737. */
  49738. private debugFactor;
  49739. /**
  49740. * Defines the clear coat layer parameters for the material.
  49741. */
  49742. readonly clearCoat: PBRClearCoatConfiguration;
  49743. /**
  49744. * Defines the anisotropic parameters for the material.
  49745. */
  49746. readonly anisotropy: PBRAnisotropicConfiguration;
  49747. /**
  49748. * Defines the BRDF parameters for the material.
  49749. */
  49750. readonly brdf: PBRBRDFConfiguration;
  49751. /**
  49752. * Defines the Sheen parameters for the material.
  49753. */
  49754. readonly sheen: PBRSheenConfiguration;
  49755. /**
  49756. * Defines the SubSurface parameters for the material.
  49757. */
  49758. readonly subSurface: PBRSubSurfaceConfiguration;
  49759. /**
  49760. * Custom callback helping to override the default shader used in the material.
  49761. */
  49762. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49763. protected _rebuildInParallel: boolean;
  49764. /**
  49765. * Instantiates a new PBRMaterial instance.
  49766. *
  49767. * @param name The material name
  49768. * @param scene The scene the material will be use in.
  49769. */
  49770. constructor(name: string, scene: Scene);
  49771. /**
  49772. * Gets a boolean indicating that current material needs to register RTT
  49773. */
  49774. readonly hasRenderTargetTextures: boolean;
  49775. /**
  49776. * Gets the name of the material class.
  49777. */
  49778. getClassName(): string;
  49779. /**
  49780. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49781. */
  49782. /**
  49783. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49784. */
  49785. useLogarithmicDepth: boolean;
  49786. /**
  49787. * Gets the current transparency mode.
  49788. */
  49789. /**
  49790. * Sets the transparency mode of the material.
  49791. *
  49792. * | Value | Type | Description |
  49793. * | ----- | ----------------------------------- | ----------- |
  49794. * | 0 | OPAQUE | |
  49795. * | 1 | ALPHATEST | |
  49796. * | 2 | ALPHABLEND | |
  49797. * | 3 | ALPHATESTANDBLEND | |
  49798. *
  49799. */
  49800. transparencyMode: Nullable<number>;
  49801. /**
  49802. * Returns true if alpha blending should be disabled.
  49803. */
  49804. private readonly _disableAlphaBlending;
  49805. /**
  49806. * Specifies whether or not this material should be rendered in alpha blend mode.
  49807. */
  49808. needAlphaBlending(): boolean;
  49809. /**
  49810. * Specifies if the mesh will require alpha blending.
  49811. * @param mesh - BJS mesh.
  49812. */
  49813. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49814. /**
  49815. * Specifies whether or not this material should be rendered in alpha test mode.
  49816. */
  49817. needAlphaTesting(): boolean;
  49818. /**
  49819. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49820. */
  49821. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49822. /**
  49823. * Gets the texture used for the alpha test.
  49824. */
  49825. getAlphaTestTexture(): Nullable<BaseTexture>;
  49826. /**
  49827. * Specifies that the submesh is ready to be used.
  49828. * @param mesh - BJS mesh.
  49829. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49830. * @param useInstances - Specifies that instances should be used.
  49831. * @returns - boolean indicating that the submesh is ready or not.
  49832. */
  49833. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49834. /**
  49835. * Specifies if the material uses metallic roughness workflow.
  49836. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49837. */
  49838. isMetallicWorkflow(): boolean;
  49839. private _prepareEffect;
  49840. private _prepareDefines;
  49841. /**
  49842. * Force shader compilation
  49843. */
  49844. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  49845. /**
  49846. * Initializes the uniform buffer layout for the shader.
  49847. */
  49848. buildUniformLayout(): void;
  49849. /**
  49850. * Unbinds the material from the mesh
  49851. */
  49852. unbind(): void;
  49853. /**
  49854. * Binds the submesh data.
  49855. * @param world - The world matrix.
  49856. * @param mesh - The BJS mesh.
  49857. * @param subMesh - A submesh of the BJS mesh.
  49858. */
  49859. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49860. /**
  49861. * Returns the animatable textures.
  49862. * @returns - Array of animatable textures.
  49863. */
  49864. getAnimatables(): IAnimatable[];
  49865. /**
  49866. * Returns the texture used for reflections.
  49867. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49868. */
  49869. private _getReflectionTexture;
  49870. /**
  49871. * Returns an array of the actively used textures.
  49872. * @returns - Array of BaseTextures
  49873. */
  49874. getActiveTextures(): BaseTexture[];
  49875. /**
  49876. * Checks to see if a texture is used in the material.
  49877. * @param texture - Base texture to use.
  49878. * @returns - Boolean specifying if a texture is used in the material.
  49879. */
  49880. hasTexture(texture: BaseTexture): boolean;
  49881. /**
  49882. * Disposes the resources of the material.
  49883. * @param forceDisposeEffect - Forces the disposal of effects.
  49884. * @param forceDisposeTextures - Forces the disposal of all textures.
  49885. */
  49886. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49887. }
  49888. }
  49889. declare module BABYLON {
  49890. /**
  49891. * The Physically based material of BJS.
  49892. *
  49893. * This offers the main features of a standard PBR material.
  49894. * For more information, please refer to the documentation :
  49895. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49896. */
  49897. export class PBRMaterial extends PBRBaseMaterial {
  49898. /**
  49899. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49900. */
  49901. static readonly PBRMATERIAL_OPAQUE: number;
  49902. /**
  49903. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49904. */
  49905. static readonly PBRMATERIAL_ALPHATEST: number;
  49906. /**
  49907. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49908. */
  49909. static readonly PBRMATERIAL_ALPHABLEND: number;
  49910. /**
  49911. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49912. * They are also discarded below the alpha cutoff threshold to improve performances.
  49913. */
  49914. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49915. /**
  49916. * Defines the default value of how much AO map is occluding the analytical lights
  49917. * (point spot...).
  49918. */
  49919. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49920. /**
  49921. * Intensity of the direct lights e.g. the four lights available in your scene.
  49922. * This impacts both the direct diffuse and specular highlights.
  49923. */
  49924. directIntensity: number;
  49925. /**
  49926. * Intensity of the emissive part of the material.
  49927. * This helps controlling the emissive effect without modifying the emissive color.
  49928. */
  49929. emissiveIntensity: number;
  49930. /**
  49931. * Intensity of the environment e.g. how much the environment will light the object
  49932. * either through harmonics for rough material or through the refelction for shiny ones.
  49933. */
  49934. environmentIntensity: number;
  49935. /**
  49936. * This is a special control allowing the reduction of the specular highlights coming from the
  49937. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49938. */
  49939. specularIntensity: number;
  49940. /**
  49941. * Debug Control allowing disabling the bump map on this material.
  49942. */
  49943. disableBumpMap: boolean;
  49944. /**
  49945. * AKA Diffuse Texture in standard nomenclature.
  49946. */
  49947. albedoTexture: BaseTexture;
  49948. /**
  49949. * AKA Occlusion Texture in other nomenclature.
  49950. */
  49951. ambientTexture: BaseTexture;
  49952. /**
  49953. * AKA Occlusion Texture Intensity in other nomenclature.
  49954. */
  49955. ambientTextureStrength: number;
  49956. /**
  49957. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49958. * 1 means it completely occludes it
  49959. * 0 mean it has no impact
  49960. */
  49961. ambientTextureImpactOnAnalyticalLights: number;
  49962. /**
  49963. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  49964. */
  49965. opacityTexture: BaseTexture;
  49966. /**
  49967. * Stores the reflection values in a texture.
  49968. */
  49969. reflectionTexture: Nullable<BaseTexture>;
  49970. /**
  49971. * Stores the emissive values in a texture.
  49972. */
  49973. emissiveTexture: BaseTexture;
  49974. /**
  49975. * AKA Specular texture in other nomenclature.
  49976. */
  49977. reflectivityTexture: BaseTexture;
  49978. /**
  49979. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49980. */
  49981. metallicTexture: BaseTexture;
  49982. /**
  49983. * Specifies the metallic scalar of the metallic/roughness workflow.
  49984. * Can also be used to scale the metalness values of the metallic texture.
  49985. */
  49986. metallic: Nullable<number>;
  49987. /**
  49988. * Specifies the roughness scalar of the metallic/roughness workflow.
  49989. * Can also be used to scale the roughness values of the metallic texture.
  49990. */
  49991. roughness: Nullable<number>;
  49992. /**
  49993. * Specifies the an F0 factor to help configuring the material F0.
  49994. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  49995. * to 0.5 the previously hard coded value stays the same.
  49996. * Can also be used to scale the F0 values of the metallic texture.
  49997. */
  49998. metallicF0Factor: number;
  49999. /**
  50000. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50001. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50002. * your expectation as it multiplies with the texture data.
  50003. */
  50004. useMetallicF0FactorFromMetallicTexture: boolean;
  50005. /**
  50006. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50007. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50008. */
  50009. microSurfaceTexture: BaseTexture;
  50010. /**
  50011. * Stores surface normal data used to displace a mesh in a texture.
  50012. */
  50013. bumpTexture: BaseTexture;
  50014. /**
  50015. * Stores the pre-calculated light information of a mesh in a texture.
  50016. */
  50017. lightmapTexture: BaseTexture;
  50018. /**
  50019. * Stores the refracted light information in a texture.
  50020. */
  50021. refractionTexture: Nullable<BaseTexture>;
  50022. /**
  50023. * The color of a material in ambient lighting.
  50024. */
  50025. ambientColor: Color3;
  50026. /**
  50027. * AKA Diffuse Color in other nomenclature.
  50028. */
  50029. albedoColor: Color3;
  50030. /**
  50031. * AKA Specular Color in other nomenclature.
  50032. */
  50033. reflectivityColor: Color3;
  50034. /**
  50035. * The color reflected from the material.
  50036. */
  50037. reflectionColor: Color3;
  50038. /**
  50039. * The color emitted from the material.
  50040. */
  50041. emissiveColor: Color3;
  50042. /**
  50043. * AKA Glossiness in other nomenclature.
  50044. */
  50045. microSurface: number;
  50046. /**
  50047. * source material index of refraction (IOR)' / 'destination material IOR.
  50048. */
  50049. indexOfRefraction: number;
  50050. /**
  50051. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50052. */
  50053. invertRefractionY: boolean;
  50054. /**
  50055. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50056. * Materials half opaque for instance using refraction could benefit from this control.
  50057. */
  50058. linkRefractionWithTransparency: boolean;
  50059. /**
  50060. * If true, the light map contains occlusion information instead of lighting info.
  50061. */
  50062. useLightmapAsShadowmap: boolean;
  50063. /**
  50064. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50065. */
  50066. useAlphaFromAlbedoTexture: boolean;
  50067. /**
  50068. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50069. */
  50070. forceAlphaTest: boolean;
  50071. /**
  50072. * Defines the alpha limits in alpha test mode.
  50073. */
  50074. alphaCutOff: number;
  50075. /**
  50076. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50077. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50078. */
  50079. useSpecularOverAlpha: boolean;
  50080. /**
  50081. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50082. */
  50083. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50084. /**
  50085. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50086. */
  50087. useRoughnessFromMetallicTextureAlpha: boolean;
  50088. /**
  50089. * Specifies if the metallic texture contains the roughness information in its green channel.
  50090. */
  50091. useRoughnessFromMetallicTextureGreen: boolean;
  50092. /**
  50093. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50094. */
  50095. useMetallnessFromMetallicTextureBlue: boolean;
  50096. /**
  50097. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50098. */
  50099. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50100. /**
  50101. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50102. */
  50103. useAmbientInGrayScale: boolean;
  50104. /**
  50105. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50106. * The material will try to infer what glossiness each pixel should be.
  50107. */
  50108. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50109. /**
  50110. * BJS is using an harcoded light falloff based on a manually sets up range.
  50111. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50112. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50113. */
  50114. /**
  50115. * BJS is using an harcoded light falloff based on a manually sets up range.
  50116. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50117. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50118. */
  50119. usePhysicalLightFalloff: boolean;
  50120. /**
  50121. * In order to support the falloff compatibility with gltf, a special mode has been added
  50122. * to reproduce the gltf light falloff.
  50123. */
  50124. /**
  50125. * In order to support the falloff compatibility with gltf, a special mode has been added
  50126. * to reproduce the gltf light falloff.
  50127. */
  50128. useGLTFLightFalloff: boolean;
  50129. /**
  50130. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50131. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50132. */
  50133. useRadianceOverAlpha: boolean;
  50134. /**
  50135. * Allows using an object space normal map (instead of tangent space).
  50136. */
  50137. useObjectSpaceNormalMap: boolean;
  50138. /**
  50139. * Allows using the bump map in parallax mode.
  50140. */
  50141. useParallax: boolean;
  50142. /**
  50143. * Allows using the bump map in parallax occlusion mode.
  50144. */
  50145. useParallaxOcclusion: boolean;
  50146. /**
  50147. * Controls the scale bias of the parallax mode.
  50148. */
  50149. parallaxScaleBias: number;
  50150. /**
  50151. * If sets to true, disables all the lights affecting the material.
  50152. */
  50153. disableLighting: boolean;
  50154. /**
  50155. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50156. */
  50157. forceIrradianceInFragment: boolean;
  50158. /**
  50159. * Number of Simultaneous lights allowed on the material.
  50160. */
  50161. maxSimultaneousLights: number;
  50162. /**
  50163. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50164. */
  50165. invertNormalMapX: boolean;
  50166. /**
  50167. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50168. */
  50169. invertNormalMapY: boolean;
  50170. /**
  50171. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50172. */
  50173. twoSidedLighting: boolean;
  50174. /**
  50175. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50176. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50177. */
  50178. useAlphaFresnel: boolean;
  50179. /**
  50180. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50181. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50182. */
  50183. useLinearAlphaFresnel: boolean;
  50184. /**
  50185. * Let user defines the brdf lookup texture used for IBL.
  50186. * A default 8bit version is embedded but you could point at :
  50187. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50188. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50189. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50190. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50191. */
  50192. environmentBRDFTexture: Nullable<BaseTexture>;
  50193. /**
  50194. * Force normal to face away from face.
  50195. */
  50196. forceNormalForward: boolean;
  50197. /**
  50198. * Enables specular anti aliasing in the PBR shader.
  50199. * It will both interacts on the Geometry for analytical and IBL lighting.
  50200. * It also prefilter the roughness map based on the bump values.
  50201. */
  50202. enableSpecularAntiAliasing: boolean;
  50203. /**
  50204. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50205. * makes the reflect vector face the model (under horizon).
  50206. */
  50207. useHorizonOcclusion: boolean;
  50208. /**
  50209. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50210. * too much the area relying on ambient texture to define their ambient occlusion.
  50211. */
  50212. useRadianceOcclusion: boolean;
  50213. /**
  50214. * If set to true, no lighting calculations will be applied.
  50215. */
  50216. unlit: boolean;
  50217. /**
  50218. * Gets the image processing configuration used either in this material.
  50219. */
  50220. /**
  50221. * Sets the Default image processing configuration used either in the this material.
  50222. *
  50223. * If sets to null, the scene one is in use.
  50224. */
  50225. imageProcessingConfiguration: ImageProcessingConfiguration;
  50226. /**
  50227. * Gets wether the color curves effect is enabled.
  50228. */
  50229. /**
  50230. * Sets wether the color curves effect is enabled.
  50231. */
  50232. cameraColorCurvesEnabled: boolean;
  50233. /**
  50234. * Gets wether the color grading effect is enabled.
  50235. */
  50236. /**
  50237. * Gets wether the color grading effect is enabled.
  50238. */
  50239. cameraColorGradingEnabled: boolean;
  50240. /**
  50241. * Gets wether tonemapping is enabled or not.
  50242. */
  50243. /**
  50244. * Sets wether tonemapping is enabled or not
  50245. */
  50246. cameraToneMappingEnabled: boolean;
  50247. /**
  50248. * The camera exposure used on this material.
  50249. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50250. * This corresponds to a photographic exposure.
  50251. */
  50252. /**
  50253. * The camera exposure used on this material.
  50254. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50255. * This corresponds to a photographic exposure.
  50256. */
  50257. cameraExposure: number;
  50258. /**
  50259. * Gets The camera contrast used on this material.
  50260. */
  50261. /**
  50262. * Sets The camera contrast used on this material.
  50263. */
  50264. cameraContrast: number;
  50265. /**
  50266. * Gets the Color Grading 2D Lookup Texture.
  50267. */
  50268. /**
  50269. * Sets the Color Grading 2D Lookup Texture.
  50270. */
  50271. cameraColorGradingTexture: Nullable<BaseTexture>;
  50272. /**
  50273. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50274. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50275. * 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;
  50276. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50277. */
  50278. /**
  50279. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50280. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50281. * 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;
  50282. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50283. */
  50284. cameraColorCurves: Nullable<ColorCurves>;
  50285. /**
  50286. * Instantiates a new PBRMaterial instance.
  50287. *
  50288. * @param name The material name
  50289. * @param scene The scene the material will be use in.
  50290. */
  50291. constructor(name: string, scene: Scene);
  50292. /**
  50293. * Returns the name of this material class.
  50294. */
  50295. getClassName(): string;
  50296. /**
  50297. * Makes a duplicate of the current material.
  50298. * @param name - name to use for the new material.
  50299. */
  50300. clone(name: string): PBRMaterial;
  50301. /**
  50302. * Serializes this PBR Material.
  50303. * @returns - An object with the serialized material.
  50304. */
  50305. serialize(): any;
  50306. /**
  50307. * Parses a PBR Material from a serialized object.
  50308. * @param source - Serialized object.
  50309. * @param scene - BJS scene instance.
  50310. * @param rootUrl - url for the scene object
  50311. * @returns - PBRMaterial
  50312. */
  50313. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50314. }
  50315. }
  50316. declare module BABYLON {
  50317. /**
  50318. * Direct draw surface info
  50319. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50320. */
  50321. export interface DDSInfo {
  50322. /**
  50323. * Width of the texture
  50324. */
  50325. width: number;
  50326. /**
  50327. * Width of the texture
  50328. */
  50329. height: number;
  50330. /**
  50331. * Number of Mipmaps for the texture
  50332. * @see https://en.wikipedia.org/wiki/Mipmap
  50333. */
  50334. mipmapCount: number;
  50335. /**
  50336. * If the textures format is a known fourCC format
  50337. * @see https://www.fourcc.org/
  50338. */
  50339. isFourCC: boolean;
  50340. /**
  50341. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50342. */
  50343. isRGB: boolean;
  50344. /**
  50345. * If the texture is a lumincance format
  50346. */
  50347. isLuminance: boolean;
  50348. /**
  50349. * If this is a cube texture
  50350. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50351. */
  50352. isCube: boolean;
  50353. /**
  50354. * If the texture is a compressed format eg. FOURCC_DXT1
  50355. */
  50356. isCompressed: boolean;
  50357. /**
  50358. * The dxgiFormat of the texture
  50359. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50360. */
  50361. dxgiFormat: number;
  50362. /**
  50363. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50364. */
  50365. textureType: number;
  50366. /**
  50367. * Sphericle polynomial created for the dds texture
  50368. */
  50369. sphericalPolynomial?: SphericalPolynomial;
  50370. }
  50371. /**
  50372. * Class used to provide DDS decompression tools
  50373. */
  50374. export class DDSTools {
  50375. /**
  50376. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50377. */
  50378. static StoreLODInAlphaChannel: boolean;
  50379. /**
  50380. * Gets DDS information from an array buffer
  50381. * @param arrayBuffer defines the array buffer to read data from
  50382. * @returns the DDS information
  50383. */
  50384. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50385. private static _FloatView;
  50386. private static _Int32View;
  50387. private static _ToHalfFloat;
  50388. private static _FromHalfFloat;
  50389. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50390. private static _GetHalfFloatRGBAArrayBuffer;
  50391. private static _GetFloatRGBAArrayBuffer;
  50392. private static _GetFloatAsUIntRGBAArrayBuffer;
  50393. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50394. private static _GetRGBAArrayBuffer;
  50395. private static _ExtractLongWordOrder;
  50396. private static _GetRGBArrayBuffer;
  50397. private static _GetLuminanceArrayBuffer;
  50398. /**
  50399. * Uploads DDS Levels to a Babylon Texture
  50400. * @hidden
  50401. */
  50402. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50403. }
  50404. interface ThinEngine {
  50405. /**
  50406. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50407. * @param rootUrl defines the url where the file to load is located
  50408. * @param scene defines the current scene
  50409. * @param lodScale defines scale to apply to the mip map selection
  50410. * @param lodOffset defines offset to apply to the mip map selection
  50411. * @param onLoad defines an optional callback raised when the texture is loaded
  50412. * @param onError defines an optional callback raised if there is an issue to load the texture
  50413. * @param format defines the format of the data
  50414. * @param forcedExtension defines the extension to use to pick the right loader
  50415. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50416. * @returns the cube texture as an InternalTexture
  50417. */
  50418. 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;
  50419. }
  50420. }
  50421. declare module BABYLON {
  50422. /**
  50423. * Implementation of the DDS Texture Loader.
  50424. * @hidden
  50425. */
  50426. export class _DDSTextureLoader implements IInternalTextureLoader {
  50427. /**
  50428. * Defines wether the loader supports cascade loading the different faces.
  50429. */
  50430. readonly supportCascades: boolean;
  50431. /**
  50432. * This returns if the loader support the current file information.
  50433. * @param extension defines the file extension of the file being loaded
  50434. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50435. * @param fallback defines the fallback internal texture if any
  50436. * @param isBase64 defines whether the texture is encoded as a base64
  50437. * @param isBuffer defines whether the texture data are stored as a buffer
  50438. * @returns true if the loader can load the specified file
  50439. */
  50440. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50441. /**
  50442. * Transform the url before loading if required.
  50443. * @param rootUrl the url of the texture
  50444. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50445. * @returns the transformed texture
  50446. */
  50447. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50448. /**
  50449. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50450. * @param rootUrl the url of the texture
  50451. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50452. * @returns the fallback texture
  50453. */
  50454. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50455. /**
  50456. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50457. * @param data contains the texture data
  50458. * @param texture defines the BabylonJS internal texture
  50459. * @param createPolynomials will be true if polynomials have been requested
  50460. * @param onLoad defines the callback to trigger once the texture is ready
  50461. * @param onError defines the callback to trigger in case of error
  50462. */
  50463. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50464. /**
  50465. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50466. * @param data contains the texture data
  50467. * @param texture defines the BabylonJS internal texture
  50468. * @param callback defines the method to call once ready to upload
  50469. */
  50470. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50471. }
  50472. }
  50473. declare module BABYLON {
  50474. /**
  50475. * Implementation of the ENV Texture Loader.
  50476. * @hidden
  50477. */
  50478. export class _ENVTextureLoader implements IInternalTextureLoader {
  50479. /**
  50480. * Defines wether the loader supports cascade loading the different faces.
  50481. */
  50482. readonly supportCascades: boolean;
  50483. /**
  50484. * This returns if the loader support the current file information.
  50485. * @param extension defines the file extension of the file being loaded
  50486. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50487. * @param fallback defines the fallback internal texture if any
  50488. * @param isBase64 defines whether the texture is encoded as a base64
  50489. * @param isBuffer defines whether the texture data are stored as a buffer
  50490. * @returns true if the loader can load the specified file
  50491. */
  50492. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50493. /**
  50494. * Transform the url before loading if required.
  50495. * @param rootUrl the url of the texture
  50496. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50497. * @returns the transformed texture
  50498. */
  50499. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50500. /**
  50501. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50502. * @param rootUrl the url of the texture
  50503. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50504. * @returns the fallback texture
  50505. */
  50506. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50507. /**
  50508. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50509. * @param data contains the texture data
  50510. * @param texture defines the BabylonJS internal texture
  50511. * @param createPolynomials will be true if polynomials have been requested
  50512. * @param onLoad defines the callback to trigger once the texture is ready
  50513. * @param onError defines the callback to trigger in case of error
  50514. */
  50515. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50516. /**
  50517. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50518. * @param data contains the texture data
  50519. * @param texture defines the BabylonJS internal texture
  50520. * @param callback defines the method to call once ready to upload
  50521. */
  50522. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50523. }
  50524. }
  50525. declare module BABYLON {
  50526. /**
  50527. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50528. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50529. */
  50530. export class KhronosTextureContainer {
  50531. /** contents of the KTX container file */
  50532. arrayBuffer: any;
  50533. private static HEADER_LEN;
  50534. private static COMPRESSED_2D;
  50535. private static COMPRESSED_3D;
  50536. private static TEX_2D;
  50537. private static TEX_3D;
  50538. /**
  50539. * Gets the openGL type
  50540. */
  50541. glType: number;
  50542. /**
  50543. * Gets the openGL type size
  50544. */
  50545. glTypeSize: number;
  50546. /**
  50547. * Gets the openGL format
  50548. */
  50549. glFormat: number;
  50550. /**
  50551. * Gets the openGL internal format
  50552. */
  50553. glInternalFormat: number;
  50554. /**
  50555. * Gets the base internal format
  50556. */
  50557. glBaseInternalFormat: number;
  50558. /**
  50559. * Gets image width in pixel
  50560. */
  50561. pixelWidth: number;
  50562. /**
  50563. * Gets image height in pixel
  50564. */
  50565. pixelHeight: number;
  50566. /**
  50567. * Gets image depth in pixels
  50568. */
  50569. pixelDepth: number;
  50570. /**
  50571. * Gets the number of array elements
  50572. */
  50573. numberOfArrayElements: number;
  50574. /**
  50575. * Gets the number of faces
  50576. */
  50577. numberOfFaces: number;
  50578. /**
  50579. * Gets the number of mipmap levels
  50580. */
  50581. numberOfMipmapLevels: number;
  50582. /**
  50583. * Gets the bytes of key value data
  50584. */
  50585. bytesOfKeyValueData: number;
  50586. /**
  50587. * Gets the load type
  50588. */
  50589. loadType: number;
  50590. /**
  50591. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50592. */
  50593. isInvalid: boolean;
  50594. /**
  50595. * Creates a new KhronosTextureContainer
  50596. * @param arrayBuffer contents of the KTX container file
  50597. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50598. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50599. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50600. */
  50601. constructor(
  50602. /** contents of the KTX container file */
  50603. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50604. /**
  50605. * Uploads KTX content to a Babylon Texture.
  50606. * It is assumed that the texture has already been created & is currently bound
  50607. * @hidden
  50608. */
  50609. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50610. private _upload2DCompressedLevels;
  50611. }
  50612. }
  50613. declare module BABYLON {
  50614. /**
  50615. * Implementation of the KTX Texture Loader.
  50616. * @hidden
  50617. */
  50618. export class _KTXTextureLoader implements IInternalTextureLoader {
  50619. /**
  50620. * Defines wether the loader supports cascade loading the different faces.
  50621. */
  50622. readonly supportCascades: boolean;
  50623. /**
  50624. * This returns if the loader support the current file information.
  50625. * @param extension defines the file extension of the file being loaded
  50626. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50627. * @param fallback defines the fallback internal texture if any
  50628. * @param isBase64 defines whether the texture is encoded as a base64
  50629. * @param isBuffer defines whether the texture data are stored as a buffer
  50630. * @returns true if the loader can load the specified file
  50631. */
  50632. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50633. /**
  50634. * Transform the url before loading if required.
  50635. * @param rootUrl the url of the texture
  50636. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50637. * @returns the transformed texture
  50638. */
  50639. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50640. /**
  50641. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50642. * @param rootUrl the url of the texture
  50643. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50644. * @returns the fallback texture
  50645. */
  50646. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50647. /**
  50648. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50649. * @param data contains the texture data
  50650. * @param texture defines the BabylonJS internal texture
  50651. * @param createPolynomials will be true if polynomials have been requested
  50652. * @param onLoad defines the callback to trigger once the texture is ready
  50653. * @param onError defines the callback to trigger in case of error
  50654. */
  50655. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50656. /**
  50657. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50658. * @param data contains the texture data
  50659. * @param texture defines the BabylonJS internal texture
  50660. * @param callback defines the method to call once ready to upload
  50661. */
  50662. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50663. }
  50664. }
  50665. declare module BABYLON {
  50666. /** @hidden */
  50667. export var _forceSceneHelpersToBundle: boolean;
  50668. interface Scene {
  50669. /**
  50670. * Creates a default light for the scene.
  50671. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50672. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50673. */
  50674. createDefaultLight(replace?: boolean): void;
  50675. /**
  50676. * Creates a default camera for the scene.
  50677. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50678. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50679. * @param replace has default false, when true replaces the active camera in the scene
  50680. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50681. */
  50682. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50683. /**
  50684. * Creates a default camera and a default light.
  50685. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50686. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50687. * @param replace has the default false, when true replaces the active camera/light in the scene
  50688. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50689. */
  50690. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50691. /**
  50692. * Creates a new sky box
  50693. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50694. * @param environmentTexture defines the texture to use as environment texture
  50695. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50696. * @param scale defines the overall scale of the skybox
  50697. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50698. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50699. * @returns a new mesh holding the sky box
  50700. */
  50701. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50702. /**
  50703. * Creates a new environment
  50704. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50705. * @param options defines the options you can use to configure the environment
  50706. * @returns the new EnvironmentHelper
  50707. */
  50708. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50709. /**
  50710. * Creates a new VREXperienceHelper
  50711. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50712. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50713. * @returns a new VREXperienceHelper
  50714. */
  50715. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50716. /**
  50717. * Creates a new WebXRDefaultExperience
  50718. * @see http://doc.babylonjs.com/how_to/webxr
  50719. * @param options experience options
  50720. * @returns a promise for a new WebXRDefaultExperience
  50721. */
  50722. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50723. }
  50724. }
  50725. declare module BABYLON {
  50726. /**
  50727. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50728. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50729. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50730. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50731. */
  50732. export class VideoDome extends TransformNode {
  50733. /**
  50734. * Define the video source as a Monoscopic panoramic 360 video.
  50735. */
  50736. static readonly MODE_MONOSCOPIC: number;
  50737. /**
  50738. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50739. */
  50740. static readonly MODE_TOPBOTTOM: number;
  50741. /**
  50742. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50743. */
  50744. static readonly MODE_SIDEBYSIDE: number;
  50745. private _halfDome;
  50746. private _useDirectMapping;
  50747. /**
  50748. * The video texture being displayed on the sphere
  50749. */
  50750. protected _videoTexture: VideoTexture;
  50751. /**
  50752. * Gets the video texture being displayed on the sphere
  50753. */
  50754. readonly videoTexture: VideoTexture;
  50755. /**
  50756. * The skybox material
  50757. */
  50758. protected _material: BackgroundMaterial;
  50759. /**
  50760. * The surface used for the skybox
  50761. */
  50762. protected _mesh: Mesh;
  50763. /**
  50764. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50765. */
  50766. private _halfDomeMask;
  50767. /**
  50768. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50769. * Also see the options.resolution property.
  50770. */
  50771. fovMultiplier: number;
  50772. private _videoMode;
  50773. /**
  50774. * Gets or set the current video mode for the video. It can be:
  50775. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50776. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50777. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50778. */
  50779. videoMode: number;
  50780. /**
  50781. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50782. *
  50783. */
  50784. /**
  50785. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50786. */
  50787. halfDome: boolean;
  50788. /**
  50789. * Oberserver used in Stereoscopic VR Mode.
  50790. */
  50791. private _onBeforeCameraRenderObserver;
  50792. /**
  50793. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50794. * @param name Element's name, child elements will append suffixes for their own names.
  50795. * @param urlsOrVideo defines the url(s) or the video element to use
  50796. * @param options An object containing optional or exposed sub element properties
  50797. */
  50798. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50799. resolution?: number;
  50800. clickToPlay?: boolean;
  50801. autoPlay?: boolean;
  50802. loop?: boolean;
  50803. size?: number;
  50804. poster?: string;
  50805. faceForward?: boolean;
  50806. useDirectMapping?: boolean;
  50807. halfDomeMode?: boolean;
  50808. }, scene: Scene);
  50809. private _changeVideoMode;
  50810. /**
  50811. * Releases resources associated with this node.
  50812. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50813. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50814. */
  50815. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50816. }
  50817. }
  50818. declare module BABYLON {
  50819. /**
  50820. * This class can be used to get instrumentation data from a Babylon engine
  50821. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50822. */
  50823. export class EngineInstrumentation implements IDisposable {
  50824. /**
  50825. * Define the instrumented engine.
  50826. */
  50827. engine: Engine;
  50828. private _captureGPUFrameTime;
  50829. private _gpuFrameTimeToken;
  50830. private _gpuFrameTime;
  50831. private _captureShaderCompilationTime;
  50832. private _shaderCompilationTime;
  50833. private _onBeginFrameObserver;
  50834. private _onEndFrameObserver;
  50835. private _onBeforeShaderCompilationObserver;
  50836. private _onAfterShaderCompilationObserver;
  50837. /**
  50838. * Gets the perf counter used for GPU frame time
  50839. */
  50840. readonly gpuFrameTimeCounter: PerfCounter;
  50841. /**
  50842. * Gets the GPU frame time capture status
  50843. */
  50844. /**
  50845. * Enable or disable the GPU frame time capture
  50846. */
  50847. captureGPUFrameTime: boolean;
  50848. /**
  50849. * Gets the perf counter used for shader compilation time
  50850. */
  50851. readonly shaderCompilationTimeCounter: PerfCounter;
  50852. /**
  50853. * Gets the shader compilation time capture status
  50854. */
  50855. /**
  50856. * Enable or disable the shader compilation time capture
  50857. */
  50858. captureShaderCompilationTime: boolean;
  50859. /**
  50860. * Instantiates a new engine instrumentation.
  50861. * This class can be used to get instrumentation data from a Babylon engine
  50862. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50863. * @param engine Defines the engine to instrument
  50864. */
  50865. constructor(
  50866. /**
  50867. * Define the instrumented engine.
  50868. */
  50869. engine: Engine);
  50870. /**
  50871. * Dispose and release associated resources.
  50872. */
  50873. dispose(): void;
  50874. }
  50875. }
  50876. declare module BABYLON {
  50877. /**
  50878. * This class can be used to get instrumentation data from a Babylon engine
  50879. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50880. */
  50881. export class SceneInstrumentation implements IDisposable {
  50882. /**
  50883. * Defines the scene to instrument
  50884. */
  50885. scene: Scene;
  50886. private _captureActiveMeshesEvaluationTime;
  50887. private _activeMeshesEvaluationTime;
  50888. private _captureRenderTargetsRenderTime;
  50889. private _renderTargetsRenderTime;
  50890. private _captureFrameTime;
  50891. private _frameTime;
  50892. private _captureRenderTime;
  50893. private _renderTime;
  50894. private _captureInterFrameTime;
  50895. private _interFrameTime;
  50896. private _captureParticlesRenderTime;
  50897. private _particlesRenderTime;
  50898. private _captureSpritesRenderTime;
  50899. private _spritesRenderTime;
  50900. private _capturePhysicsTime;
  50901. private _physicsTime;
  50902. private _captureAnimationsTime;
  50903. private _animationsTime;
  50904. private _captureCameraRenderTime;
  50905. private _cameraRenderTime;
  50906. private _onBeforeActiveMeshesEvaluationObserver;
  50907. private _onAfterActiveMeshesEvaluationObserver;
  50908. private _onBeforeRenderTargetsRenderObserver;
  50909. private _onAfterRenderTargetsRenderObserver;
  50910. private _onAfterRenderObserver;
  50911. private _onBeforeDrawPhaseObserver;
  50912. private _onAfterDrawPhaseObserver;
  50913. private _onBeforeAnimationsObserver;
  50914. private _onBeforeParticlesRenderingObserver;
  50915. private _onAfterParticlesRenderingObserver;
  50916. private _onBeforeSpritesRenderingObserver;
  50917. private _onAfterSpritesRenderingObserver;
  50918. private _onBeforePhysicsObserver;
  50919. private _onAfterPhysicsObserver;
  50920. private _onAfterAnimationsObserver;
  50921. private _onBeforeCameraRenderObserver;
  50922. private _onAfterCameraRenderObserver;
  50923. /**
  50924. * Gets the perf counter used for active meshes evaluation time
  50925. */
  50926. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50927. /**
  50928. * Gets the active meshes evaluation time capture status
  50929. */
  50930. /**
  50931. * Enable or disable the active meshes evaluation time capture
  50932. */
  50933. captureActiveMeshesEvaluationTime: boolean;
  50934. /**
  50935. * Gets the perf counter used for render targets render time
  50936. */
  50937. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50938. /**
  50939. * Gets the render targets render time capture status
  50940. */
  50941. /**
  50942. * Enable or disable the render targets render time capture
  50943. */
  50944. captureRenderTargetsRenderTime: boolean;
  50945. /**
  50946. * Gets the perf counter used for particles render time
  50947. */
  50948. readonly particlesRenderTimeCounter: PerfCounter;
  50949. /**
  50950. * Gets the particles render time capture status
  50951. */
  50952. /**
  50953. * Enable or disable the particles render time capture
  50954. */
  50955. captureParticlesRenderTime: boolean;
  50956. /**
  50957. * Gets the perf counter used for sprites render time
  50958. */
  50959. readonly spritesRenderTimeCounter: PerfCounter;
  50960. /**
  50961. * Gets the sprites render time capture status
  50962. */
  50963. /**
  50964. * Enable or disable the sprites render time capture
  50965. */
  50966. captureSpritesRenderTime: boolean;
  50967. /**
  50968. * Gets the perf counter used for physics time
  50969. */
  50970. readonly physicsTimeCounter: PerfCounter;
  50971. /**
  50972. * Gets the physics time capture status
  50973. */
  50974. /**
  50975. * Enable or disable the physics time capture
  50976. */
  50977. capturePhysicsTime: boolean;
  50978. /**
  50979. * Gets the perf counter used for animations time
  50980. */
  50981. readonly animationsTimeCounter: PerfCounter;
  50982. /**
  50983. * Gets the animations time capture status
  50984. */
  50985. /**
  50986. * Enable or disable the animations time capture
  50987. */
  50988. captureAnimationsTime: boolean;
  50989. /**
  50990. * Gets the perf counter used for frame time capture
  50991. */
  50992. readonly frameTimeCounter: PerfCounter;
  50993. /**
  50994. * Gets the frame time capture status
  50995. */
  50996. /**
  50997. * Enable or disable the frame time capture
  50998. */
  50999. captureFrameTime: boolean;
  51000. /**
  51001. * Gets the perf counter used for inter-frames time capture
  51002. */
  51003. readonly interFrameTimeCounter: PerfCounter;
  51004. /**
  51005. * Gets the inter-frames time capture status
  51006. */
  51007. /**
  51008. * Enable or disable the inter-frames time capture
  51009. */
  51010. captureInterFrameTime: boolean;
  51011. /**
  51012. * Gets the perf counter used for render time capture
  51013. */
  51014. readonly renderTimeCounter: PerfCounter;
  51015. /**
  51016. * Gets the render time capture status
  51017. */
  51018. /**
  51019. * Enable or disable the render time capture
  51020. */
  51021. captureRenderTime: boolean;
  51022. /**
  51023. * Gets the perf counter used for camera render time capture
  51024. */
  51025. readonly cameraRenderTimeCounter: PerfCounter;
  51026. /**
  51027. * Gets the camera render time capture status
  51028. */
  51029. /**
  51030. * Enable or disable the camera render time capture
  51031. */
  51032. captureCameraRenderTime: boolean;
  51033. /**
  51034. * Gets the perf counter used for draw calls
  51035. */
  51036. readonly drawCallsCounter: PerfCounter;
  51037. /**
  51038. * Instantiates a new scene instrumentation.
  51039. * This class can be used to get instrumentation data from a Babylon engine
  51040. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51041. * @param scene Defines the scene to instrument
  51042. */
  51043. constructor(
  51044. /**
  51045. * Defines the scene to instrument
  51046. */
  51047. scene: Scene);
  51048. /**
  51049. * Dispose and release associated resources.
  51050. */
  51051. dispose(): void;
  51052. }
  51053. }
  51054. declare module BABYLON {
  51055. /** @hidden */
  51056. export var glowMapGenerationPixelShader: {
  51057. name: string;
  51058. shader: string;
  51059. };
  51060. }
  51061. declare module BABYLON {
  51062. /** @hidden */
  51063. export var glowMapGenerationVertexShader: {
  51064. name: string;
  51065. shader: string;
  51066. };
  51067. }
  51068. declare module BABYLON {
  51069. /**
  51070. * Effect layer options. This helps customizing the behaviour
  51071. * of the effect layer.
  51072. */
  51073. export interface IEffectLayerOptions {
  51074. /**
  51075. * Multiplication factor apply to the canvas size to compute the render target size
  51076. * used to generated the objects (the smaller the faster).
  51077. */
  51078. mainTextureRatio: number;
  51079. /**
  51080. * Enforces a fixed size texture to ensure effect stability across devices.
  51081. */
  51082. mainTextureFixedSize?: number;
  51083. /**
  51084. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51085. */
  51086. alphaBlendingMode: number;
  51087. /**
  51088. * The camera attached to the layer.
  51089. */
  51090. camera: Nullable<Camera>;
  51091. /**
  51092. * The rendering group to draw the layer in.
  51093. */
  51094. renderingGroupId: number;
  51095. }
  51096. /**
  51097. * The effect layer Helps adding post process effect blended with the main pass.
  51098. *
  51099. * This can be for instance use to generate glow or higlight effects on the scene.
  51100. *
  51101. * The effect layer class can not be used directly and is intented to inherited from to be
  51102. * customized per effects.
  51103. */
  51104. export abstract class EffectLayer {
  51105. private _vertexBuffers;
  51106. private _indexBuffer;
  51107. private _cachedDefines;
  51108. private _effectLayerMapGenerationEffect;
  51109. private _effectLayerOptions;
  51110. private _mergeEffect;
  51111. protected _scene: Scene;
  51112. protected _engine: Engine;
  51113. protected _maxSize: number;
  51114. protected _mainTextureDesiredSize: ISize;
  51115. protected _mainTexture: RenderTargetTexture;
  51116. protected _shouldRender: boolean;
  51117. protected _postProcesses: PostProcess[];
  51118. protected _textures: BaseTexture[];
  51119. protected _emissiveTextureAndColor: {
  51120. texture: Nullable<BaseTexture>;
  51121. color: Color4;
  51122. };
  51123. /**
  51124. * The name of the layer
  51125. */
  51126. name: string;
  51127. /**
  51128. * The clear color of the texture used to generate the glow map.
  51129. */
  51130. neutralColor: Color4;
  51131. /**
  51132. * Specifies wether the highlight layer is enabled or not.
  51133. */
  51134. isEnabled: boolean;
  51135. /**
  51136. * Gets the camera attached to the layer.
  51137. */
  51138. readonly camera: Nullable<Camera>;
  51139. /**
  51140. * Gets the rendering group id the layer should render in.
  51141. */
  51142. renderingGroupId: number;
  51143. /**
  51144. * An event triggered when the effect layer has been disposed.
  51145. */
  51146. onDisposeObservable: Observable<EffectLayer>;
  51147. /**
  51148. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51149. */
  51150. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51151. /**
  51152. * An event triggered when the generated texture is being merged in the scene.
  51153. */
  51154. onBeforeComposeObservable: Observable<EffectLayer>;
  51155. /**
  51156. * An event triggered when the mesh is rendered into the effect render target.
  51157. */
  51158. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  51159. /**
  51160. * An event triggered after the mesh has been rendered into the effect render target.
  51161. */
  51162. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  51163. /**
  51164. * An event triggered when the generated texture has been merged in the scene.
  51165. */
  51166. onAfterComposeObservable: Observable<EffectLayer>;
  51167. /**
  51168. * An event triggered when the efffect layer changes its size.
  51169. */
  51170. onSizeChangedObservable: Observable<EffectLayer>;
  51171. /** @hidden */
  51172. static _SceneComponentInitialization: (scene: Scene) => void;
  51173. /**
  51174. * Instantiates a new effect Layer and references it in the scene.
  51175. * @param name The name of the layer
  51176. * @param scene The scene to use the layer in
  51177. */
  51178. constructor(
  51179. /** The Friendly of the effect in the scene */
  51180. name: string, scene: Scene);
  51181. /**
  51182. * Get the effect name of the layer.
  51183. * @return The effect name
  51184. */
  51185. abstract getEffectName(): string;
  51186. /**
  51187. * Checks for the readiness of the element composing the layer.
  51188. * @param subMesh the mesh to check for
  51189. * @param useInstances specify wether or not to use instances to render the mesh
  51190. * @return true if ready otherwise, false
  51191. */
  51192. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51193. /**
  51194. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51195. * @returns true if the effect requires stencil during the main canvas render pass.
  51196. */
  51197. abstract needStencil(): boolean;
  51198. /**
  51199. * Create the merge effect. This is the shader use to blit the information back
  51200. * to the main canvas at the end of the scene rendering.
  51201. * @returns The effect containing the shader used to merge the effect on the main canvas
  51202. */
  51203. protected abstract _createMergeEffect(): Effect;
  51204. /**
  51205. * Creates the render target textures and post processes used in the effect layer.
  51206. */
  51207. protected abstract _createTextureAndPostProcesses(): void;
  51208. /**
  51209. * Implementation specific of rendering the generating effect on the main canvas.
  51210. * @param effect The effect used to render through
  51211. */
  51212. protected abstract _internalRender(effect: Effect): void;
  51213. /**
  51214. * Sets the required values for both the emissive texture and and the main color.
  51215. */
  51216. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51217. /**
  51218. * Free any resources and references associated to a mesh.
  51219. * Internal use
  51220. * @param mesh The mesh to free.
  51221. */
  51222. abstract _disposeMesh(mesh: Mesh): void;
  51223. /**
  51224. * Serializes this layer (Glow or Highlight for example)
  51225. * @returns a serialized layer object
  51226. */
  51227. abstract serialize?(): any;
  51228. /**
  51229. * Initializes the effect layer with the required options.
  51230. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51231. */
  51232. protected _init(options: Partial<IEffectLayerOptions>): void;
  51233. /**
  51234. * Generates the index buffer of the full screen quad blending to the main canvas.
  51235. */
  51236. private _generateIndexBuffer;
  51237. /**
  51238. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51239. */
  51240. private _generateVertexBuffer;
  51241. /**
  51242. * Sets the main texture desired size which is the closest power of two
  51243. * of the engine canvas size.
  51244. */
  51245. private _setMainTextureSize;
  51246. /**
  51247. * Creates the main texture for the effect layer.
  51248. */
  51249. protected _createMainTexture(): void;
  51250. /**
  51251. * Adds specific effects defines.
  51252. * @param defines The defines to add specifics to.
  51253. */
  51254. protected _addCustomEffectDefines(defines: string[]): void;
  51255. /**
  51256. * Checks for the readiness of the element composing the layer.
  51257. * @param subMesh the mesh to check for
  51258. * @param useInstances specify wether or not to use instances to render the mesh
  51259. * @param emissiveTexture the associated emissive texture used to generate the glow
  51260. * @return true if ready otherwise, false
  51261. */
  51262. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51263. /**
  51264. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51265. */
  51266. render(): void;
  51267. /**
  51268. * Determine if a given mesh will be used in the current effect.
  51269. * @param mesh mesh to test
  51270. * @returns true if the mesh will be used
  51271. */
  51272. hasMesh(mesh: AbstractMesh): boolean;
  51273. /**
  51274. * Returns true if the layer contains information to display, otherwise false.
  51275. * @returns true if the glow layer should be rendered
  51276. */
  51277. shouldRender(): boolean;
  51278. /**
  51279. * Returns true if the mesh should render, otherwise false.
  51280. * @param mesh The mesh to render
  51281. * @returns true if it should render otherwise false
  51282. */
  51283. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51284. /**
  51285. * Returns true if the mesh can be rendered, otherwise false.
  51286. * @param mesh The mesh to render
  51287. * @param material The material used on the mesh
  51288. * @returns true if it can be rendered otherwise false
  51289. */
  51290. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51291. /**
  51292. * Returns true if the mesh should render, otherwise false.
  51293. * @param mesh The mesh to render
  51294. * @returns true if it should render otherwise false
  51295. */
  51296. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51297. /**
  51298. * Renders the submesh passed in parameter to the generation map.
  51299. */
  51300. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51301. /**
  51302. * Defines wether the current material of the mesh should be use to render the effect.
  51303. * @param mesh defines the current mesh to render
  51304. */
  51305. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  51306. /**
  51307. * Rebuild the required buffers.
  51308. * @hidden Internal use only.
  51309. */
  51310. _rebuild(): void;
  51311. /**
  51312. * Dispose only the render target textures and post process.
  51313. */
  51314. private _disposeTextureAndPostProcesses;
  51315. /**
  51316. * Dispose the highlight layer and free resources.
  51317. */
  51318. dispose(): void;
  51319. /**
  51320. * Gets the class name of the effect layer
  51321. * @returns the string with the class name of the effect layer
  51322. */
  51323. getClassName(): string;
  51324. /**
  51325. * Creates an effect layer from parsed effect layer data
  51326. * @param parsedEffectLayer defines effect layer data
  51327. * @param scene defines the current scene
  51328. * @param rootUrl defines the root URL containing the effect layer information
  51329. * @returns a parsed effect Layer
  51330. */
  51331. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51332. }
  51333. }
  51334. declare module BABYLON {
  51335. interface AbstractScene {
  51336. /**
  51337. * The list of effect layers (highlights/glow) added to the scene
  51338. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51339. * @see http://doc.babylonjs.com/how_to/glow_layer
  51340. */
  51341. effectLayers: Array<EffectLayer>;
  51342. /**
  51343. * Removes the given effect layer from this scene.
  51344. * @param toRemove defines the effect layer to remove
  51345. * @returns the index of the removed effect layer
  51346. */
  51347. removeEffectLayer(toRemove: EffectLayer): number;
  51348. /**
  51349. * Adds the given effect layer to this scene
  51350. * @param newEffectLayer defines the effect layer to add
  51351. */
  51352. addEffectLayer(newEffectLayer: EffectLayer): void;
  51353. }
  51354. /**
  51355. * Defines the layer scene component responsible to manage any effect layers
  51356. * in a given scene.
  51357. */
  51358. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51359. /**
  51360. * The component name helpfull to identify the component in the list of scene components.
  51361. */
  51362. readonly name: string;
  51363. /**
  51364. * The scene the component belongs to.
  51365. */
  51366. scene: Scene;
  51367. private _engine;
  51368. private _renderEffects;
  51369. private _needStencil;
  51370. private _previousStencilState;
  51371. /**
  51372. * Creates a new instance of the component for the given scene
  51373. * @param scene Defines the scene to register the component in
  51374. */
  51375. constructor(scene: Scene);
  51376. /**
  51377. * Registers the component in a given scene
  51378. */
  51379. register(): void;
  51380. /**
  51381. * Rebuilds the elements related to this component in case of
  51382. * context lost for instance.
  51383. */
  51384. rebuild(): void;
  51385. /**
  51386. * Serializes the component data to the specified json object
  51387. * @param serializationObject The object to serialize to
  51388. */
  51389. serialize(serializationObject: any): void;
  51390. /**
  51391. * Adds all the elements from the container to the scene
  51392. * @param container the container holding the elements
  51393. */
  51394. addFromContainer(container: AbstractScene): void;
  51395. /**
  51396. * Removes all the elements in the container from the scene
  51397. * @param container contains the elements to remove
  51398. * @param dispose if the removed element should be disposed (default: false)
  51399. */
  51400. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51401. /**
  51402. * Disposes the component and the associated ressources.
  51403. */
  51404. dispose(): void;
  51405. private _isReadyForMesh;
  51406. private _renderMainTexture;
  51407. private _setStencil;
  51408. private _setStencilBack;
  51409. private _draw;
  51410. private _drawCamera;
  51411. private _drawRenderingGroup;
  51412. }
  51413. }
  51414. declare module BABYLON {
  51415. /** @hidden */
  51416. export var glowMapMergePixelShader: {
  51417. name: string;
  51418. shader: string;
  51419. };
  51420. }
  51421. declare module BABYLON {
  51422. /** @hidden */
  51423. export var glowMapMergeVertexShader: {
  51424. name: string;
  51425. shader: string;
  51426. };
  51427. }
  51428. declare module BABYLON {
  51429. interface AbstractScene {
  51430. /**
  51431. * Return a the first highlight layer of the scene with a given name.
  51432. * @param name The name of the highlight layer to look for.
  51433. * @return The highlight layer if found otherwise null.
  51434. */
  51435. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51436. }
  51437. /**
  51438. * Glow layer options. This helps customizing the behaviour
  51439. * of the glow layer.
  51440. */
  51441. export interface IGlowLayerOptions {
  51442. /**
  51443. * Multiplication factor apply to the canvas size to compute the render target size
  51444. * used to generated the glowing objects (the smaller the faster).
  51445. */
  51446. mainTextureRatio: number;
  51447. /**
  51448. * Enforces a fixed size texture to ensure resize independant blur.
  51449. */
  51450. mainTextureFixedSize?: number;
  51451. /**
  51452. * How big is the kernel of the blur texture.
  51453. */
  51454. blurKernelSize: number;
  51455. /**
  51456. * The camera attached to the layer.
  51457. */
  51458. camera: Nullable<Camera>;
  51459. /**
  51460. * Enable MSAA by chosing the number of samples.
  51461. */
  51462. mainTextureSamples?: number;
  51463. /**
  51464. * The rendering group to draw the layer in.
  51465. */
  51466. renderingGroupId: number;
  51467. }
  51468. /**
  51469. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51470. *
  51471. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  51472. *
  51473. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51474. */
  51475. export class GlowLayer extends EffectLayer {
  51476. /**
  51477. * Effect Name of the layer.
  51478. */
  51479. static readonly EffectName: string;
  51480. /**
  51481. * The default blur kernel size used for the glow.
  51482. */
  51483. static DefaultBlurKernelSize: number;
  51484. /**
  51485. * The default texture size ratio used for the glow.
  51486. */
  51487. static DefaultTextureRatio: number;
  51488. /**
  51489. * Sets the kernel size of the blur.
  51490. */
  51491. /**
  51492. * Gets the kernel size of the blur.
  51493. */
  51494. blurKernelSize: number;
  51495. /**
  51496. * Sets the glow intensity.
  51497. */
  51498. /**
  51499. * Gets the glow intensity.
  51500. */
  51501. intensity: number;
  51502. private _options;
  51503. private _intensity;
  51504. private _horizontalBlurPostprocess1;
  51505. private _verticalBlurPostprocess1;
  51506. private _horizontalBlurPostprocess2;
  51507. private _verticalBlurPostprocess2;
  51508. private _blurTexture1;
  51509. private _blurTexture2;
  51510. private _postProcesses1;
  51511. private _postProcesses2;
  51512. private _includedOnlyMeshes;
  51513. private _excludedMeshes;
  51514. private _meshesUsingTheirOwnMaterials;
  51515. /**
  51516. * Callback used to let the user override the color selection on a per mesh basis
  51517. */
  51518. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51519. /**
  51520. * Callback used to let the user override the texture selection on a per mesh basis
  51521. */
  51522. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51523. /**
  51524. * Instantiates a new glow Layer and references it to the scene.
  51525. * @param name The name of the layer
  51526. * @param scene The scene to use the layer in
  51527. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51528. */
  51529. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51530. /**
  51531. * Get the effect name of the layer.
  51532. * @return The effect name
  51533. */
  51534. getEffectName(): string;
  51535. /**
  51536. * Create the merge effect. This is the shader use to blit the information back
  51537. * to the main canvas at the end of the scene rendering.
  51538. */
  51539. protected _createMergeEffect(): Effect;
  51540. /**
  51541. * Creates the render target textures and post processes used in the glow layer.
  51542. */
  51543. protected _createTextureAndPostProcesses(): void;
  51544. /**
  51545. * Checks for the readiness of the element composing the layer.
  51546. * @param subMesh the mesh to check for
  51547. * @param useInstances specify wether or not to use instances to render the mesh
  51548. * @param emissiveTexture the associated emissive texture used to generate the glow
  51549. * @return true if ready otherwise, false
  51550. */
  51551. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51552. /**
  51553. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51554. */
  51555. needStencil(): boolean;
  51556. /**
  51557. * Returns true if the mesh can be rendered, otherwise false.
  51558. * @param mesh The mesh to render
  51559. * @param material The material used on the mesh
  51560. * @returns true if it can be rendered otherwise false
  51561. */
  51562. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51563. /**
  51564. * Implementation specific of rendering the generating effect on the main canvas.
  51565. * @param effect The effect used to render through
  51566. */
  51567. protected _internalRender(effect: Effect): void;
  51568. /**
  51569. * Sets the required values for both the emissive texture and and the main color.
  51570. */
  51571. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51572. /**
  51573. * Returns true if the mesh should render, otherwise false.
  51574. * @param mesh The mesh to render
  51575. * @returns true if it should render otherwise false
  51576. */
  51577. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51578. /**
  51579. * Adds specific effects defines.
  51580. * @param defines The defines to add specifics to.
  51581. */
  51582. protected _addCustomEffectDefines(defines: string[]): void;
  51583. /**
  51584. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51585. * @param mesh The mesh to exclude from the glow layer
  51586. */
  51587. addExcludedMesh(mesh: Mesh): void;
  51588. /**
  51589. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51590. * @param mesh The mesh to remove
  51591. */
  51592. removeExcludedMesh(mesh: Mesh): void;
  51593. /**
  51594. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51595. * @param mesh The mesh to include in the glow layer
  51596. */
  51597. addIncludedOnlyMesh(mesh: Mesh): void;
  51598. /**
  51599. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51600. * @param mesh The mesh to remove
  51601. */
  51602. removeIncludedOnlyMesh(mesh: Mesh): void;
  51603. /**
  51604. * Determine if a given mesh will be used in the glow layer
  51605. * @param mesh The mesh to test
  51606. * @returns true if the mesh will be highlighted by the current glow layer
  51607. */
  51608. hasMesh(mesh: AbstractMesh): boolean;
  51609. /**
  51610. * Defines wether the current material of the mesh should be use to render the effect.
  51611. * @param mesh defines the current mesh to render
  51612. */
  51613. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  51614. /**
  51615. * Add a mesh to be rendered through its own material and not with emissive only.
  51616. * @param mesh The mesh for which we need to use its material
  51617. */
  51618. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  51619. /**
  51620. * Remove a mesh from being rendered through its own material and not with emissive only.
  51621. * @param mesh The mesh for which we need to not use its material
  51622. */
  51623. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  51624. /**
  51625. * Free any resources and references associated to a mesh.
  51626. * Internal use
  51627. * @param mesh The mesh to free.
  51628. * @hidden
  51629. */
  51630. _disposeMesh(mesh: Mesh): void;
  51631. /**
  51632. * Gets the class name of the effect layer
  51633. * @returns the string with the class name of the effect layer
  51634. */
  51635. getClassName(): string;
  51636. /**
  51637. * Serializes this glow layer
  51638. * @returns a serialized glow layer object
  51639. */
  51640. serialize(): any;
  51641. /**
  51642. * Creates a Glow Layer from parsed glow layer data
  51643. * @param parsedGlowLayer defines glow layer data
  51644. * @param scene defines the current scene
  51645. * @param rootUrl defines the root URL containing the glow layer information
  51646. * @returns a parsed Glow Layer
  51647. */
  51648. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51649. }
  51650. }
  51651. declare module BABYLON {
  51652. /** @hidden */
  51653. export var glowBlurPostProcessPixelShader: {
  51654. name: string;
  51655. shader: string;
  51656. };
  51657. }
  51658. declare module BABYLON {
  51659. interface AbstractScene {
  51660. /**
  51661. * Return a the first highlight layer of the scene with a given name.
  51662. * @param name The name of the highlight layer to look for.
  51663. * @return The highlight layer if found otherwise null.
  51664. */
  51665. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51666. }
  51667. /**
  51668. * Highlight layer options. This helps customizing the behaviour
  51669. * of the highlight layer.
  51670. */
  51671. export interface IHighlightLayerOptions {
  51672. /**
  51673. * Multiplication factor apply to the canvas size to compute the render target size
  51674. * used to generated the glowing objects (the smaller the faster).
  51675. */
  51676. mainTextureRatio: number;
  51677. /**
  51678. * Enforces a fixed size texture to ensure resize independant blur.
  51679. */
  51680. mainTextureFixedSize?: number;
  51681. /**
  51682. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51683. * of the picture to blur (the smaller the faster).
  51684. */
  51685. blurTextureSizeRatio: number;
  51686. /**
  51687. * How big in texel of the blur texture is the vertical blur.
  51688. */
  51689. blurVerticalSize: number;
  51690. /**
  51691. * How big in texel of the blur texture is the horizontal blur.
  51692. */
  51693. blurHorizontalSize: number;
  51694. /**
  51695. * Alpha blending mode used to apply the blur. Default is combine.
  51696. */
  51697. alphaBlendingMode: number;
  51698. /**
  51699. * The camera attached to the layer.
  51700. */
  51701. camera: Nullable<Camera>;
  51702. /**
  51703. * Should we display highlight as a solid stroke?
  51704. */
  51705. isStroke?: boolean;
  51706. /**
  51707. * The rendering group to draw the layer in.
  51708. */
  51709. renderingGroupId: number;
  51710. }
  51711. /**
  51712. * The highlight layer Helps adding a glow effect around a mesh.
  51713. *
  51714. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  51715. * glowy meshes to your scene.
  51716. *
  51717. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51718. */
  51719. export class HighlightLayer extends EffectLayer {
  51720. name: string;
  51721. /**
  51722. * Effect Name of the highlight layer.
  51723. */
  51724. static readonly EffectName: string;
  51725. /**
  51726. * The neutral color used during the preparation of the glow effect.
  51727. * This is black by default as the blend operation is a blend operation.
  51728. */
  51729. static NeutralColor: Color4;
  51730. /**
  51731. * Stencil value used for glowing meshes.
  51732. */
  51733. static GlowingMeshStencilReference: number;
  51734. /**
  51735. * Stencil value used for the other meshes in the scene.
  51736. */
  51737. static NormalMeshStencilReference: number;
  51738. /**
  51739. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51740. */
  51741. innerGlow: boolean;
  51742. /**
  51743. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51744. */
  51745. outerGlow: boolean;
  51746. /**
  51747. * Specifies the horizontal size of the blur.
  51748. */
  51749. /**
  51750. * Gets the horizontal size of the blur.
  51751. */
  51752. blurHorizontalSize: number;
  51753. /**
  51754. * Specifies the vertical size of the blur.
  51755. */
  51756. /**
  51757. * Gets the vertical size of the blur.
  51758. */
  51759. blurVerticalSize: number;
  51760. /**
  51761. * An event triggered when the highlight layer is being blurred.
  51762. */
  51763. onBeforeBlurObservable: Observable<HighlightLayer>;
  51764. /**
  51765. * An event triggered when the highlight layer has been blurred.
  51766. */
  51767. onAfterBlurObservable: Observable<HighlightLayer>;
  51768. private _instanceGlowingMeshStencilReference;
  51769. private _options;
  51770. private _downSamplePostprocess;
  51771. private _horizontalBlurPostprocess;
  51772. private _verticalBlurPostprocess;
  51773. private _blurTexture;
  51774. private _meshes;
  51775. private _excludedMeshes;
  51776. /**
  51777. * Instantiates a new highlight Layer and references it to the scene..
  51778. * @param name The name of the layer
  51779. * @param scene The scene to use the layer in
  51780. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51781. */
  51782. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51783. /**
  51784. * Get the effect name of the layer.
  51785. * @return The effect name
  51786. */
  51787. getEffectName(): string;
  51788. /**
  51789. * Create the merge effect. This is the shader use to blit the information back
  51790. * to the main canvas at the end of the scene rendering.
  51791. */
  51792. protected _createMergeEffect(): Effect;
  51793. /**
  51794. * Creates the render target textures and post processes used in the highlight layer.
  51795. */
  51796. protected _createTextureAndPostProcesses(): void;
  51797. /**
  51798. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51799. */
  51800. needStencil(): boolean;
  51801. /**
  51802. * Checks for the readiness of the element composing the layer.
  51803. * @param subMesh the mesh to check for
  51804. * @param useInstances specify wether or not to use instances to render the mesh
  51805. * @param emissiveTexture the associated emissive texture used to generate the glow
  51806. * @return true if ready otherwise, false
  51807. */
  51808. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51809. /**
  51810. * Implementation specific of rendering the generating effect on the main canvas.
  51811. * @param effect The effect used to render through
  51812. */
  51813. protected _internalRender(effect: Effect): void;
  51814. /**
  51815. * Returns true if the layer contains information to display, otherwise false.
  51816. */
  51817. shouldRender(): boolean;
  51818. /**
  51819. * Returns true if the mesh should render, otherwise false.
  51820. * @param mesh The mesh to render
  51821. * @returns true if it should render otherwise false
  51822. */
  51823. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51824. /**
  51825. * Sets the required values for both the emissive texture and and the main color.
  51826. */
  51827. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51828. /**
  51829. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51830. * @param mesh The mesh to exclude from the highlight layer
  51831. */
  51832. addExcludedMesh(mesh: Mesh): void;
  51833. /**
  51834. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51835. * @param mesh The mesh to highlight
  51836. */
  51837. removeExcludedMesh(mesh: Mesh): void;
  51838. /**
  51839. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51840. * @param mesh mesh to test
  51841. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51842. */
  51843. hasMesh(mesh: AbstractMesh): boolean;
  51844. /**
  51845. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51846. * @param mesh The mesh to highlight
  51847. * @param color The color of the highlight
  51848. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51849. */
  51850. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51851. /**
  51852. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51853. * @param mesh The mesh to highlight
  51854. */
  51855. removeMesh(mesh: Mesh): void;
  51856. /**
  51857. * Force the stencil to the normal expected value for none glowing parts
  51858. */
  51859. private _defaultStencilReference;
  51860. /**
  51861. * Free any resources and references associated to a mesh.
  51862. * Internal use
  51863. * @param mesh The mesh to free.
  51864. * @hidden
  51865. */
  51866. _disposeMesh(mesh: Mesh): void;
  51867. /**
  51868. * Dispose the highlight layer and free resources.
  51869. */
  51870. dispose(): void;
  51871. /**
  51872. * Gets the class name of the effect layer
  51873. * @returns the string with the class name of the effect layer
  51874. */
  51875. getClassName(): string;
  51876. /**
  51877. * Serializes this Highlight layer
  51878. * @returns a serialized Highlight layer object
  51879. */
  51880. serialize(): any;
  51881. /**
  51882. * Creates a Highlight layer from parsed Highlight layer data
  51883. * @param parsedHightlightLayer defines the Highlight layer data
  51884. * @param scene defines the current scene
  51885. * @param rootUrl defines the root URL containing the Highlight layer information
  51886. * @returns a parsed Highlight layer
  51887. */
  51888. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51889. }
  51890. }
  51891. declare module BABYLON {
  51892. interface AbstractScene {
  51893. /**
  51894. * The list of layers (background and foreground) of the scene
  51895. */
  51896. layers: Array<Layer>;
  51897. }
  51898. /**
  51899. * Defines the layer scene component responsible to manage any layers
  51900. * in a given scene.
  51901. */
  51902. export class LayerSceneComponent implements ISceneComponent {
  51903. /**
  51904. * The component name helpfull to identify the component in the list of scene components.
  51905. */
  51906. readonly name: string;
  51907. /**
  51908. * The scene the component belongs to.
  51909. */
  51910. scene: Scene;
  51911. private _engine;
  51912. /**
  51913. * Creates a new instance of the component for the given scene
  51914. * @param scene Defines the scene to register the component in
  51915. */
  51916. constructor(scene: Scene);
  51917. /**
  51918. * Registers the component in a given scene
  51919. */
  51920. register(): void;
  51921. /**
  51922. * Rebuilds the elements related to this component in case of
  51923. * context lost for instance.
  51924. */
  51925. rebuild(): void;
  51926. /**
  51927. * Disposes the component and the associated ressources.
  51928. */
  51929. dispose(): void;
  51930. private _draw;
  51931. private _drawCameraPredicate;
  51932. private _drawCameraBackground;
  51933. private _drawCameraForeground;
  51934. private _drawRenderTargetPredicate;
  51935. private _drawRenderTargetBackground;
  51936. private _drawRenderTargetForeground;
  51937. /**
  51938. * Adds all the elements from the container to the scene
  51939. * @param container the container holding the elements
  51940. */
  51941. addFromContainer(container: AbstractScene): void;
  51942. /**
  51943. * Removes all the elements in the container from the scene
  51944. * @param container contains the elements to remove
  51945. * @param dispose if the removed element should be disposed (default: false)
  51946. */
  51947. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51948. }
  51949. }
  51950. declare module BABYLON {
  51951. /** @hidden */
  51952. export var layerPixelShader: {
  51953. name: string;
  51954. shader: string;
  51955. };
  51956. }
  51957. declare module BABYLON {
  51958. /** @hidden */
  51959. export var layerVertexShader: {
  51960. name: string;
  51961. shader: string;
  51962. };
  51963. }
  51964. declare module BABYLON {
  51965. /**
  51966. * This represents a full screen 2d layer.
  51967. * This can be useful to display a picture in the background of your scene for instance.
  51968. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51969. */
  51970. export class Layer {
  51971. /**
  51972. * Define the name of the layer.
  51973. */
  51974. name: string;
  51975. /**
  51976. * Define the texture the layer should display.
  51977. */
  51978. texture: Nullable<Texture>;
  51979. /**
  51980. * Is the layer in background or foreground.
  51981. */
  51982. isBackground: boolean;
  51983. /**
  51984. * Define the color of the layer (instead of texture).
  51985. */
  51986. color: Color4;
  51987. /**
  51988. * Define the scale of the layer in order to zoom in out of the texture.
  51989. */
  51990. scale: Vector2;
  51991. /**
  51992. * Define an offset for the layer in order to shift the texture.
  51993. */
  51994. offset: Vector2;
  51995. /**
  51996. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51997. */
  51998. alphaBlendingMode: number;
  51999. /**
  52000. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52001. * Alpha test will not mix with the background color in case of transparency.
  52002. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52003. */
  52004. alphaTest: boolean;
  52005. /**
  52006. * Define a mask to restrict the layer to only some of the scene cameras.
  52007. */
  52008. layerMask: number;
  52009. /**
  52010. * Define the list of render target the layer is visible into.
  52011. */
  52012. renderTargetTextures: RenderTargetTexture[];
  52013. /**
  52014. * Define if the layer is only used in renderTarget or if it also
  52015. * renders in the main frame buffer of the canvas.
  52016. */
  52017. renderOnlyInRenderTargetTextures: boolean;
  52018. private _scene;
  52019. private _vertexBuffers;
  52020. private _indexBuffer;
  52021. private _effect;
  52022. private _previousDefines;
  52023. /**
  52024. * An event triggered when the layer is disposed.
  52025. */
  52026. onDisposeObservable: Observable<Layer>;
  52027. private _onDisposeObserver;
  52028. /**
  52029. * Back compatibility with callback before the onDisposeObservable existed.
  52030. * The set callback will be triggered when the layer has been disposed.
  52031. */
  52032. onDispose: () => void;
  52033. /**
  52034. * An event triggered before rendering the scene
  52035. */
  52036. onBeforeRenderObservable: Observable<Layer>;
  52037. private _onBeforeRenderObserver;
  52038. /**
  52039. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52040. * The set callback will be triggered just before rendering the layer.
  52041. */
  52042. onBeforeRender: () => void;
  52043. /**
  52044. * An event triggered after rendering the scene
  52045. */
  52046. onAfterRenderObservable: Observable<Layer>;
  52047. private _onAfterRenderObserver;
  52048. /**
  52049. * Back compatibility with callback before the onAfterRenderObservable existed.
  52050. * The set callback will be triggered just after rendering the layer.
  52051. */
  52052. onAfterRender: () => void;
  52053. /**
  52054. * Instantiates a new layer.
  52055. * This represents a full screen 2d layer.
  52056. * This can be useful to display a picture in the background of your scene for instance.
  52057. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52058. * @param name Define the name of the layer in the scene
  52059. * @param imgUrl Define the url of the texture to display in the layer
  52060. * @param scene Define the scene the layer belongs to
  52061. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52062. * @param color Defines a color for the layer
  52063. */
  52064. constructor(
  52065. /**
  52066. * Define the name of the layer.
  52067. */
  52068. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52069. private _createIndexBuffer;
  52070. /** @hidden */
  52071. _rebuild(): void;
  52072. /**
  52073. * Renders the layer in the scene.
  52074. */
  52075. render(): void;
  52076. /**
  52077. * Disposes and releases the associated ressources.
  52078. */
  52079. dispose(): void;
  52080. }
  52081. }
  52082. declare module BABYLON {
  52083. /** @hidden */
  52084. export var lensFlarePixelShader: {
  52085. name: string;
  52086. shader: string;
  52087. };
  52088. }
  52089. declare module BABYLON {
  52090. /** @hidden */
  52091. export var lensFlareVertexShader: {
  52092. name: string;
  52093. shader: string;
  52094. };
  52095. }
  52096. declare module BABYLON {
  52097. /**
  52098. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52099. * It is usually composed of several `lensFlare`.
  52100. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52101. */
  52102. export class LensFlareSystem {
  52103. /**
  52104. * Define the name of the lens flare system
  52105. */
  52106. name: string;
  52107. /**
  52108. * List of lens flares used in this system.
  52109. */
  52110. lensFlares: LensFlare[];
  52111. /**
  52112. * Define a limit from the border the lens flare can be visible.
  52113. */
  52114. borderLimit: number;
  52115. /**
  52116. * Define a viewport border we do not want to see the lens flare in.
  52117. */
  52118. viewportBorder: number;
  52119. /**
  52120. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52121. */
  52122. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52123. /**
  52124. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52125. */
  52126. layerMask: number;
  52127. /**
  52128. * Define the id of the lens flare system in the scene.
  52129. * (equal to name by default)
  52130. */
  52131. id: string;
  52132. private _scene;
  52133. private _emitter;
  52134. private _vertexBuffers;
  52135. private _indexBuffer;
  52136. private _effect;
  52137. private _positionX;
  52138. private _positionY;
  52139. private _isEnabled;
  52140. /** @hidden */
  52141. static _SceneComponentInitialization: (scene: Scene) => void;
  52142. /**
  52143. * Instantiates a lens flare system.
  52144. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52145. * It is usually composed of several `lensFlare`.
  52146. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52147. * @param name Define the name of the lens flare system in the scene
  52148. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52149. * @param scene Define the scene the lens flare system belongs to
  52150. */
  52151. constructor(
  52152. /**
  52153. * Define the name of the lens flare system
  52154. */
  52155. name: string, emitter: any, scene: Scene);
  52156. /**
  52157. * Define if the lens flare system is enabled.
  52158. */
  52159. isEnabled: boolean;
  52160. /**
  52161. * Get the scene the effects belongs to.
  52162. * @returns the scene holding the lens flare system
  52163. */
  52164. getScene(): Scene;
  52165. /**
  52166. * Get the emitter of the lens flare system.
  52167. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52168. * @returns the emitter of the lens flare system
  52169. */
  52170. getEmitter(): any;
  52171. /**
  52172. * Set the emitter of the lens flare system.
  52173. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52174. * @param newEmitter Define the new emitter of the system
  52175. */
  52176. setEmitter(newEmitter: any): void;
  52177. /**
  52178. * Get the lens flare system emitter position.
  52179. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52180. * @returns the position
  52181. */
  52182. getEmitterPosition(): Vector3;
  52183. /**
  52184. * @hidden
  52185. */
  52186. computeEffectivePosition(globalViewport: Viewport): boolean;
  52187. /** @hidden */
  52188. _isVisible(): boolean;
  52189. /**
  52190. * @hidden
  52191. */
  52192. render(): boolean;
  52193. /**
  52194. * Dispose and release the lens flare with its associated resources.
  52195. */
  52196. dispose(): void;
  52197. /**
  52198. * Parse a lens flare system from a JSON repressentation
  52199. * @param parsedLensFlareSystem Define the JSON to parse
  52200. * @param scene Define the scene the parsed system should be instantiated in
  52201. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52202. * @returns the parsed system
  52203. */
  52204. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52205. /**
  52206. * Serialize the current Lens Flare System into a JSON representation.
  52207. * @returns the serialized JSON
  52208. */
  52209. serialize(): any;
  52210. }
  52211. }
  52212. declare module BABYLON {
  52213. /**
  52214. * This represents one of the lens effect in a `lensFlareSystem`.
  52215. * It controls one of the indiviual texture used in the effect.
  52216. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52217. */
  52218. export class LensFlare {
  52219. /**
  52220. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52221. */
  52222. size: number;
  52223. /**
  52224. * 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.
  52225. */
  52226. position: number;
  52227. /**
  52228. * Define the lens color.
  52229. */
  52230. color: Color3;
  52231. /**
  52232. * Define the lens texture.
  52233. */
  52234. texture: Nullable<Texture>;
  52235. /**
  52236. * Define the alpha mode to render this particular lens.
  52237. */
  52238. alphaMode: number;
  52239. private _system;
  52240. /**
  52241. * Creates a new Lens Flare.
  52242. * This represents one of the lens effect in a `lensFlareSystem`.
  52243. * It controls one of the indiviual texture used in the effect.
  52244. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52245. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52246. * @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.
  52247. * @param color Define the lens color
  52248. * @param imgUrl Define the lens texture url
  52249. * @param system Define the `lensFlareSystem` this flare is part of
  52250. * @returns The newly created Lens Flare
  52251. */
  52252. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52253. /**
  52254. * Instantiates a new Lens Flare.
  52255. * This represents one of the lens effect in a `lensFlareSystem`.
  52256. * It controls one of the indiviual texture used in the effect.
  52257. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52258. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52259. * @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.
  52260. * @param color Define the lens color
  52261. * @param imgUrl Define the lens texture url
  52262. * @param system Define the `lensFlareSystem` this flare is part of
  52263. */
  52264. constructor(
  52265. /**
  52266. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52267. */
  52268. size: number,
  52269. /**
  52270. * 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.
  52271. */
  52272. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52273. /**
  52274. * Dispose and release the lens flare with its associated resources.
  52275. */
  52276. dispose(): void;
  52277. }
  52278. }
  52279. declare module BABYLON {
  52280. interface AbstractScene {
  52281. /**
  52282. * The list of lens flare system added to the scene
  52283. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52284. */
  52285. lensFlareSystems: Array<LensFlareSystem>;
  52286. /**
  52287. * Removes the given lens flare system from this scene.
  52288. * @param toRemove The lens flare system to remove
  52289. * @returns The index of the removed lens flare system
  52290. */
  52291. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52292. /**
  52293. * Adds the given lens flare system to this scene
  52294. * @param newLensFlareSystem The lens flare system to add
  52295. */
  52296. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52297. /**
  52298. * Gets a lens flare system using its name
  52299. * @param name defines the name to look for
  52300. * @returns the lens flare system or null if not found
  52301. */
  52302. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52303. /**
  52304. * Gets a lens flare system using its id
  52305. * @param id defines the id to look for
  52306. * @returns the lens flare system or null if not found
  52307. */
  52308. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52309. }
  52310. /**
  52311. * Defines the lens flare scene component responsible to manage any lens flares
  52312. * in a given scene.
  52313. */
  52314. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52315. /**
  52316. * The component name helpfull to identify the component in the list of scene components.
  52317. */
  52318. readonly name: string;
  52319. /**
  52320. * The scene the component belongs to.
  52321. */
  52322. scene: Scene;
  52323. /**
  52324. * Creates a new instance of the component for the given scene
  52325. * @param scene Defines the scene to register the component in
  52326. */
  52327. constructor(scene: Scene);
  52328. /**
  52329. * Registers the component in a given scene
  52330. */
  52331. register(): void;
  52332. /**
  52333. * Rebuilds the elements related to this component in case of
  52334. * context lost for instance.
  52335. */
  52336. rebuild(): void;
  52337. /**
  52338. * Adds all the elements from the container to the scene
  52339. * @param container the container holding the elements
  52340. */
  52341. addFromContainer(container: AbstractScene): void;
  52342. /**
  52343. * Removes all the elements in the container from the scene
  52344. * @param container contains the elements to remove
  52345. * @param dispose if the removed element should be disposed (default: false)
  52346. */
  52347. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52348. /**
  52349. * Serializes the component data to the specified json object
  52350. * @param serializationObject The object to serialize to
  52351. */
  52352. serialize(serializationObject: any): void;
  52353. /**
  52354. * Disposes the component and the associated ressources.
  52355. */
  52356. dispose(): void;
  52357. private _draw;
  52358. }
  52359. }
  52360. declare module BABYLON {
  52361. /**
  52362. * Defines the shadow generator component responsible to manage any shadow generators
  52363. * in a given scene.
  52364. */
  52365. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52366. /**
  52367. * The component name helpfull to identify the component in the list of scene components.
  52368. */
  52369. readonly name: string;
  52370. /**
  52371. * The scene the component belongs to.
  52372. */
  52373. scene: Scene;
  52374. /**
  52375. * Creates a new instance of the component for the given scene
  52376. * @param scene Defines the scene to register the component in
  52377. */
  52378. constructor(scene: Scene);
  52379. /**
  52380. * Registers the component in a given scene
  52381. */
  52382. register(): void;
  52383. /**
  52384. * Rebuilds the elements related to this component in case of
  52385. * context lost for instance.
  52386. */
  52387. rebuild(): void;
  52388. /**
  52389. * Serializes the component data to the specified json object
  52390. * @param serializationObject The object to serialize to
  52391. */
  52392. serialize(serializationObject: any): void;
  52393. /**
  52394. * Adds all the elements from the container to the scene
  52395. * @param container the container holding the elements
  52396. */
  52397. addFromContainer(container: AbstractScene): void;
  52398. /**
  52399. * Removes all the elements in the container from the scene
  52400. * @param container contains the elements to remove
  52401. * @param dispose if the removed element should be disposed (default: false)
  52402. */
  52403. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52404. /**
  52405. * Rebuilds the elements related to this component in case of
  52406. * context lost for instance.
  52407. */
  52408. dispose(): void;
  52409. private _gatherRenderTargets;
  52410. }
  52411. }
  52412. declare module BABYLON {
  52413. /**
  52414. * A point light is a light defined by an unique point in world space.
  52415. * The light is emitted in every direction from this point.
  52416. * A good example of a point light is a standard light bulb.
  52417. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52418. */
  52419. export class PointLight extends ShadowLight {
  52420. private _shadowAngle;
  52421. /**
  52422. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52423. * This specifies what angle the shadow will use to be created.
  52424. *
  52425. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52426. */
  52427. /**
  52428. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52429. * This specifies what angle the shadow will use to be created.
  52430. *
  52431. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52432. */
  52433. shadowAngle: number;
  52434. /**
  52435. * Gets the direction if it has been set.
  52436. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52437. */
  52438. /**
  52439. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52440. */
  52441. direction: Vector3;
  52442. /**
  52443. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52444. * A PointLight emits the light in every direction.
  52445. * It can cast shadows.
  52446. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52447. * ```javascript
  52448. * var pointLight = new PointLight("pl", camera.position, scene);
  52449. * ```
  52450. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52451. * @param name The light friendly name
  52452. * @param position The position of the point light in the scene
  52453. * @param scene The scene the lights belongs to
  52454. */
  52455. constructor(name: string, position: Vector3, scene: Scene);
  52456. /**
  52457. * Returns the string "PointLight"
  52458. * @returns the class name
  52459. */
  52460. getClassName(): string;
  52461. /**
  52462. * Returns the integer 0.
  52463. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52464. */
  52465. getTypeID(): number;
  52466. /**
  52467. * Specifies wether or not the shadowmap should be a cube texture.
  52468. * @returns true if the shadowmap needs to be a cube texture.
  52469. */
  52470. needCube(): boolean;
  52471. /**
  52472. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52473. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52474. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52475. */
  52476. getShadowDirection(faceIndex?: number): Vector3;
  52477. /**
  52478. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52479. * - fov = PI / 2
  52480. * - aspect ratio : 1.0
  52481. * - z-near and far equal to the active camera minZ and maxZ.
  52482. * Returns the PointLight.
  52483. */
  52484. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52485. protected _buildUniformLayout(): void;
  52486. /**
  52487. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52488. * @param effect The effect to update
  52489. * @param lightIndex The index of the light in the effect to update
  52490. * @returns The point light
  52491. */
  52492. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52493. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52494. /**
  52495. * Prepares the list of defines specific to the light type.
  52496. * @param defines the list of defines
  52497. * @param lightIndex defines the index of the light for the effect
  52498. */
  52499. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52500. }
  52501. }
  52502. declare module BABYLON {
  52503. /**
  52504. * Header information of HDR texture files.
  52505. */
  52506. export interface HDRInfo {
  52507. /**
  52508. * The height of the texture in pixels.
  52509. */
  52510. height: number;
  52511. /**
  52512. * The width of the texture in pixels.
  52513. */
  52514. width: number;
  52515. /**
  52516. * The index of the beginning of the data in the binary file.
  52517. */
  52518. dataPosition: number;
  52519. }
  52520. /**
  52521. * This groups tools to convert HDR texture to native colors array.
  52522. */
  52523. export class HDRTools {
  52524. private static Ldexp;
  52525. private static Rgbe2float;
  52526. private static readStringLine;
  52527. /**
  52528. * Reads header information from an RGBE texture stored in a native array.
  52529. * More information on this format are available here:
  52530. * https://en.wikipedia.org/wiki/RGBE_image_format
  52531. *
  52532. * @param uint8array The binary file stored in native array.
  52533. * @return The header information.
  52534. */
  52535. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52536. /**
  52537. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52538. * This RGBE texture needs to store the information as a panorama.
  52539. *
  52540. * More information on this format are available here:
  52541. * https://en.wikipedia.org/wiki/RGBE_image_format
  52542. *
  52543. * @param buffer The binary file stored in an array buffer.
  52544. * @param size The expected size of the extracted cubemap.
  52545. * @return The Cube Map information.
  52546. */
  52547. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52548. /**
  52549. * Returns the pixels data extracted from an RGBE texture.
  52550. * This pixels will be stored left to right up to down in the R G B order in one array.
  52551. *
  52552. * More information on this format are available here:
  52553. * https://en.wikipedia.org/wiki/RGBE_image_format
  52554. *
  52555. * @param uint8array The binary file stored in an array buffer.
  52556. * @param hdrInfo The header information of the file.
  52557. * @return The pixels data in RGB right to left up to down order.
  52558. */
  52559. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52560. private static RGBE_ReadPixels_RLE;
  52561. }
  52562. }
  52563. declare module BABYLON {
  52564. /**
  52565. * This represents a texture coming from an HDR input.
  52566. *
  52567. * The only supported format is currently panorama picture stored in RGBE format.
  52568. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52569. */
  52570. export class HDRCubeTexture extends BaseTexture {
  52571. private static _facesMapping;
  52572. private _generateHarmonics;
  52573. private _noMipmap;
  52574. private _textureMatrix;
  52575. private _size;
  52576. private _onLoad;
  52577. private _onError;
  52578. /**
  52579. * The texture URL.
  52580. */
  52581. url: string;
  52582. /**
  52583. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52584. */
  52585. coordinatesMode: number;
  52586. protected _isBlocking: boolean;
  52587. /**
  52588. * Sets wether or not the texture is blocking during loading.
  52589. */
  52590. /**
  52591. * Gets wether or not the texture is blocking during loading.
  52592. */
  52593. isBlocking: boolean;
  52594. protected _rotationY: number;
  52595. /**
  52596. * Sets texture matrix rotation angle around Y axis in radians.
  52597. */
  52598. /**
  52599. * Gets texture matrix rotation angle around Y axis radians.
  52600. */
  52601. rotationY: number;
  52602. /**
  52603. * Gets or sets the center of the bounding box associated with the cube texture
  52604. * It must define where the camera used to render the texture was set
  52605. */
  52606. boundingBoxPosition: Vector3;
  52607. private _boundingBoxSize;
  52608. /**
  52609. * Gets or sets the size of the bounding box associated with the cube texture
  52610. * When defined, the cubemap will switch to local mode
  52611. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52612. * @example https://www.babylonjs-playground.com/#RNASML
  52613. */
  52614. boundingBoxSize: Vector3;
  52615. /**
  52616. * Instantiates an HDRTexture from the following parameters.
  52617. *
  52618. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52619. * @param scene The scene the texture will be used in
  52620. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52621. * @param noMipmap Forces to not generate the mipmap if true
  52622. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52623. * @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)
  52624. * @param reserved Reserved flag for internal use.
  52625. */
  52626. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52627. /**
  52628. * Get the current class name of the texture useful for serialization or dynamic coding.
  52629. * @returns "HDRCubeTexture"
  52630. */
  52631. getClassName(): string;
  52632. /**
  52633. * Occurs when the file is raw .hdr file.
  52634. */
  52635. private loadTexture;
  52636. clone(): HDRCubeTexture;
  52637. delayLoad(): void;
  52638. /**
  52639. * Get the texture reflection matrix used to rotate/transform the reflection.
  52640. * @returns the reflection matrix
  52641. */
  52642. getReflectionTextureMatrix(): Matrix;
  52643. /**
  52644. * Set the texture reflection matrix used to rotate/transform the reflection.
  52645. * @param value Define the reflection matrix to set
  52646. */
  52647. setReflectionTextureMatrix(value: Matrix): void;
  52648. /**
  52649. * Parses a JSON representation of an HDR Texture in order to create the texture
  52650. * @param parsedTexture Define the JSON representation
  52651. * @param scene Define the scene the texture should be created in
  52652. * @param rootUrl Define the root url in case we need to load relative dependencies
  52653. * @returns the newly created texture after parsing
  52654. */
  52655. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52656. serialize(): any;
  52657. }
  52658. }
  52659. declare module BABYLON {
  52660. /**
  52661. * Class used to control physics engine
  52662. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52663. */
  52664. export class PhysicsEngine implements IPhysicsEngine {
  52665. private _physicsPlugin;
  52666. /**
  52667. * Global value used to control the smallest number supported by the simulation
  52668. */
  52669. static Epsilon: number;
  52670. private _impostors;
  52671. private _joints;
  52672. private _subTimeStep;
  52673. /**
  52674. * Gets the gravity vector used by the simulation
  52675. */
  52676. gravity: Vector3;
  52677. /**
  52678. * Factory used to create the default physics plugin.
  52679. * @returns The default physics plugin
  52680. */
  52681. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52682. /**
  52683. * Creates a new Physics Engine
  52684. * @param gravity defines the gravity vector used by the simulation
  52685. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52686. */
  52687. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52688. /**
  52689. * Sets the gravity vector used by the simulation
  52690. * @param gravity defines the gravity vector to use
  52691. */
  52692. setGravity(gravity: Vector3): void;
  52693. /**
  52694. * Set the time step of the physics engine.
  52695. * Default is 1/60.
  52696. * To slow it down, enter 1/600 for example.
  52697. * To speed it up, 1/30
  52698. * @param newTimeStep defines the new timestep to apply to this world.
  52699. */
  52700. setTimeStep(newTimeStep?: number): void;
  52701. /**
  52702. * Get the time step of the physics engine.
  52703. * @returns the current time step
  52704. */
  52705. getTimeStep(): number;
  52706. /**
  52707. * Set the sub time step of the physics engine.
  52708. * Default is 0 meaning there is no sub steps
  52709. * To increase physics resolution precision, set a small value (like 1 ms)
  52710. * @param subTimeStep defines the new sub timestep used for physics resolution.
  52711. */
  52712. setSubTimeStep(subTimeStep?: number): void;
  52713. /**
  52714. * Get the sub time step of the physics engine.
  52715. * @returns the current sub time step
  52716. */
  52717. getSubTimeStep(): number;
  52718. /**
  52719. * Release all resources
  52720. */
  52721. dispose(): void;
  52722. /**
  52723. * Gets the name of the current physics plugin
  52724. * @returns the name of the plugin
  52725. */
  52726. getPhysicsPluginName(): string;
  52727. /**
  52728. * Adding a new impostor for the impostor tracking.
  52729. * This will be done by the impostor itself.
  52730. * @param impostor the impostor to add
  52731. */
  52732. addImpostor(impostor: PhysicsImpostor): void;
  52733. /**
  52734. * Remove an impostor from the engine.
  52735. * This impostor and its mesh will not longer be updated by the physics engine.
  52736. * @param impostor the impostor to remove
  52737. */
  52738. removeImpostor(impostor: PhysicsImpostor): void;
  52739. /**
  52740. * Add a joint to the physics engine
  52741. * @param mainImpostor defines the main impostor to which the joint is added.
  52742. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52743. * @param joint defines the joint that will connect both impostors.
  52744. */
  52745. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52746. /**
  52747. * Removes a joint from the simulation
  52748. * @param mainImpostor defines the impostor used with the joint
  52749. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52750. * @param joint defines the joint to remove
  52751. */
  52752. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52753. /**
  52754. * Called by the scene. No need to call it.
  52755. * @param delta defines the timespam between frames
  52756. */
  52757. _step(delta: number): void;
  52758. /**
  52759. * Gets the current plugin used to run the simulation
  52760. * @returns current plugin
  52761. */
  52762. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52763. /**
  52764. * Gets the list of physic impostors
  52765. * @returns an array of PhysicsImpostor
  52766. */
  52767. getImpostors(): Array<PhysicsImpostor>;
  52768. /**
  52769. * Gets the impostor for a physics enabled object
  52770. * @param object defines the object impersonated by the impostor
  52771. * @returns the PhysicsImpostor or null if not found
  52772. */
  52773. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52774. /**
  52775. * Gets the impostor for a physics body object
  52776. * @param body defines physics body used by the impostor
  52777. * @returns the PhysicsImpostor or null if not found
  52778. */
  52779. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52780. /**
  52781. * Does a raycast in the physics world
  52782. * @param from when should the ray start?
  52783. * @param to when should the ray end?
  52784. * @returns PhysicsRaycastResult
  52785. */
  52786. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52787. }
  52788. }
  52789. declare module BABYLON {
  52790. /** @hidden */
  52791. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52792. private _useDeltaForWorldStep;
  52793. world: any;
  52794. name: string;
  52795. private _physicsMaterials;
  52796. private _fixedTimeStep;
  52797. private _cannonRaycastResult;
  52798. private _raycastResult;
  52799. private _physicsBodysToRemoveAfterStep;
  52800. BJSCANNON: any;
  52801. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52802. setGravity(gravity: Vector3): void;
  52803. setTimeStep(timeStep: number): void;
  52804. getTimeStep(): number;
  52805. executeStep(delta: number): void;
  52806. private _removeMarkedPhysicsBodiesFromWorld;
  52807. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52808. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52809. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52810. private _processChildMeshes;
  52811. removePhysicsBody(impostor: PhysicsImpostor): void;
  52812. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52813. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52814. private _addMaterial;
  52815. private _checkWithEpsilon;
  52816. private _createShape;
  52817. private _createHeightmap;
  52818. private _minus90X;
  52819. private _plus90X;
  52820. private _tmpPosition;
  52821. private _tmpDeltaPosition;
  52822. private _tmpUnityRotation;
  52823. private _updatePhysicsBodyTransformation;
  52824. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52825. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52826. isSupported(): boolean;
  52827. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52828. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52829. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52830. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52831. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52832. getBodyMass(impostor: PhysicsImpostor): number;
  52833. getBodyFriction(impostor: PhysicsImpostor): number;
  52834. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52835. getBodyRestitution(impostor: PhysicsImpostor): number;
  52836. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52837. sleepBody(impostor: PhysicsImpostor): void;
  52838. wakeUpBody(impostor: PhysicsImpostor): void;
  52839. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52840. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52841. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52842. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52843. getRadius(impostor: PhysicsImpostor): number;
  52844. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52845. dispose(): void;
  52846. private _extendNamespace;
  52847. /**
  52848. * Does a raycast in the physics world
  52849. * @param from when should the ray start?
  52850. * @param to when should the ray end?
  52851. * @returns PhysicsRaycastResult
  52852. */
  52853. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52854. }
  52855. }
  52856. declare module BABYLON {
  52857. /** @hidden */
  52858. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52859. world: any;
  52860. name: string;
  52861. BJSOIMO: any;
  52862. private _raycastResult;
  52863. constructor(iterations?: number, oimoInjection?: any);
  52864. setGravity(gravity: Vector3): void;
  52865. setTimeStep(timeStep: number): void;
  52866. getTimeStep(): number;
  52867. private _tmpImpostorsArray;
  52868. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52869. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52870. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52871. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52872. private _tmpPositionVector;
  52873. removePhysicsBody(impostor: PhysicsImpostor): void;
  52874. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52875. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52876. isSupported(): boolean;
  52877. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52878. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52879. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52880. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52881. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52882. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52883. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52884. getBodyMass(impostor: PhysicsImpostor): number;
  52885. getBodyFriction(impostor: PhysicsImpostor): number;
  52886. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52887. getBodyRestitution(impostor: PhysicsImpostor): number;
  52888. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52889. sleepBody(impostor: PhysicsImpostor): void;
  52890. wakeUpBody(impostor: PhysicsImpostor): void;
  52891. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52892. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52893. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52894. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52895. getRadius(impostor: PhysicsImpostor): number;
  52896. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52897. dispose(): void;
  52898. /**
  52899. * Does a raycast in the physics world
  52900. * @param from when should the ray start?
  52901. * @param to when should the ray end?
  52902. * @returns PhysicsRaycastResult
  52903. */
  52904. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52905. }
  52906. }
  52907. declare module BABYLON {
  52908. /**
  52909. * Class containing static functions to help procedurally build meshes
  52910. */
  52911. export class RibbonBuilder {
  52912. /**
  52913. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52914. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52915. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52916. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52917. * * 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
  52918. * * 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
  52919. * * 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
  52920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52921. * * 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
  52922. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52923. * * 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
  52924. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52925. * * 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
  52926. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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 ribbon mesh
  52932. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52933. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52934. */
  52935. static CreateRibbon(name: string, options: {
  52936. pathArray: Vector3[][];
  52937. closeArray?: boolean;
  52938. closePath?: boolean;
  52939. offset?: number;
  52940. updatable?: boolean;
  52941. sideOrientation?: number;
  52942. frontUVs?: Vector4;
  52943. backUVs?: Vector4;
  52944. instance?: Mesh;
  52945. invertUV?: boolean;
  52946. uvs?: Vector2[];
  52947. colors?: Color4[];
  52948. }, scene?: Nullable<Scene>): Mesh;
  52949. }
  52950. }
  52951. declare module BABYLON {
  52952. /**
  52953. * Class containing static functions to help procedurally build meshes
  52954. */
  52955. export class ShapeBuilder {
  52956. /**
  52957. * 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.
  52958. * * 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.
  52959. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52960. * * 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.
  52961. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52962. * * 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
  52963. * * 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
  52964. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52966. * * 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
  52967. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52969. * @param name defines the name of the mesh
  52970. * @param options defines the options used to create the mesh
  52971. * @param scene defines the hosting scene
  52972. * @returns the extruded shape mesh
  52973. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52974. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52975. */
  52976. static ExtrudeShape(name: string, options: {
  52977. shape: Vector3[];
  52978. path: Vector3[];
  52979. scale?: number;
  52980. rotation?: number;
  52981. cap?: number;
  52982. updatable?: boolean;
  52983. sideOrientation?: number;
  52984. frontUVs?: Vector4;
  52985. backUVs?: Vector4;
  52986. instance?: Mesh;
  52987. invertUV?: boolean;
  52988. }, scene?: Nullable<Scene>): Mesh;
  52989. /**
  52990. * Creates an custom extruded shape mesh.
  52991. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52992. * * 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.
  52993. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52994. * * 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
  52995. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52996. * * 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
  52997. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52998. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52999. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53000. * * 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
  53001. * * 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
  53002. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53004. * * 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
  53005. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53007. * @param name defines the name of the mesh
  53008. * @param options defines the options used to create the mesh
  53009. * @param scene defines the hosting scene
  53010. * @returns the custom extruded shape mesh
  53011. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53012. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53013. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53014. */
  53015. static ExtrudeShapeCustom(name: string, options: {
  53016. shape: Vector3[];
  53017. path: Vector3[];
  53018. scaleFunction?: any;
  53019. rotationFunction?: any;
  53020. ribbonCloseArray?: boolean;
  53021. ribbonClosePath?: boolean;
  53022. cap?: number;
  53023. updatable?: boolean;
  53024. sideOrientation?: number;
  53025. frontUVs?: Vector4;
  53026. backUVs?: Vector4;
  53027. instance?: Mesh;
  53028. invertUV?: boolean;
  53029. }, scene?: Nullable<Scene>): Mesh;
  53030. private static _ExtrudeShapeGeneric;
  53031. }
  53032. }
  53033. declare module BABYLON {
  53034. /**
  53035. * AmmoJS Physics plugin
  53036. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53037. * @see https://github.com/kripken/ammo.js/
  53038. */
  53039. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53040. private _useDeltaForWorldStep;
  53041. /**
  53042. * Reference to the Ammo library
  53043. */
  53044. bjsAMMO: any;
  53045. /**
  53046. * Created ammoJS world which physics bodies are added to
  53047. */
  53048. world: any;
  53049. /**
  53050. * Name of the plugin
  53051. */
  53052. name: string;
  53053. private _timeStep;
  53054. private _fixedTimeStep;
  53055. private _maxSteps;
  53056. private _tmpQuaternion;
  53057. private _tmpAmmoTransform;
  53058. private _tmpAmmoQuaternion;
  53059. private _tmpAmmoConcreteContactResultCallback;
  53060. private _collisionConfiguration;
  53061. private _dispatcher;
  53062. private _overlappingPairCache;
  53063. private _solver;
  53064. private _softBodySolver;
  53065. private _tmpAmmoVectorA;
  53066. private _tmpAmmoVectorB;
  53067. private _tmpAmmoVectorC;
  53068. private _tmpAmmoVectorD;
  53069. private _tmpContactCallbackResult;
  53070. private _tmpAmmoVectorRCA;
  53071. private _tmpAmmoVectorRCB;
  53072. private _raycastResult;
  53073. private static readonly DISABLE_COLLISION_FLAG;
  53074. private static readonly KINEMATIC_FLAG;
  53075. private static readonly DISABLE_DEACTIVATION_FLAG;
  53076. /**
  53077. * Initializes the ammoJS plugin
  53078. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53079. * @param ammoInjection can be used to inject your own ammo reference
  53080. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53081. */
  53082. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53083. /**
  53084. * Sets the gravity of the physics world (m/(s^2))
  53085. * @param gravity Gravity to set
  53086. */
  53087. setGravity(gravity: Vector3): void;
  53088. /**
  53089. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53090. * @param timeStep timestep to use in seconds
  53091. */
  53092. setTimeStep(timeStep: number): void;
  53093. /**
  53094. * 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)
  53095. * @param fixedTimeStep fixedTimeStep to use in seconds
  53096. */
  53097. setFixedTimeStep(fixedTimeStep: number): void;
  53098. /**
  53099. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53100. * @param maxSteps the maximum number of steps by the physics engine per frame
  53101. */
  53102. setMaxSteps(maxSteps: number): void;
  53103. /**
  53104. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53105. * @returns the current timestep in seconds
  53106. */
  53107. getTimeStep(): number;
  53108. /**
  53109. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  53110. */
  53111. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  53112. private _isImpostorInContact;
  53113. private _isImpostorPairInContact;
  53114. private _stepSimulation;
  53115. /**
  53116. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53117. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53118. * After the step the babylon meshes are set to the position of the physics imposters
  53119. * @param delta amount of time to step forward
  53120. * @param impostors array of imposters to update before/after the step
  53121. */
  53122. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53123. /**
  53124. * Update babylon mesh to match physics world object
  53125. * @param impostor imposter to match
  53126. */
  53127. private _afterSoftStep;
  53128. /**
  53129. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53130. * @param impostor imposter to match
  53131. */
  53132. private _ropeStep;
  53133. /**
  53134. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53135. * @param impostor imposter to match
  53136. */
  53137. private _softbodyOrClothStep;
  53138. private _tmpVector;
  53139. private _tmpMatrix;
  53140. /**
  53141. * Applies an impulse on the imposter
  53142. * @param impostor imposter to apply impulse to
  53143. * @param force amount of force to be applied to the imposter
  53144. * @param contactPoint the location to apply the impulse on the imposter
  53145. */
  53146. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53147. /**
  53148. * Applies a force on the imposter
  53149. * @param impostor imposter to apply force
  53150. * @param force amount of force to be applied to the imposter
  53151. * @param contactPoint the location to apply the force on the imposter
  53152. */
  53153. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53154. /**
  53155. * Creates a physics body using the plugin
  53156. * @param impostor the imposter to create the physics body on
  53157. */
  53158. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53159. /**
  53160. * Removes the physics body from the imposter and disposes of the body's memory
  53161. * @param impostor imposter to remove the physics body from
  53162. */
  53163. removePhysicsBody(impostor: PhysicsImpostor): void;
  53164. /**
  53165. * Generates a joint
  53166. * @param impostorJoint the imposter joint to create the joint with
  53167. */
  53168. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53169. /**
  53170. * Removes a joint
  53171. * @param impostorJoint the imposter joint to remove the joint from
  53172. */
  53173. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53174. private _addMeshVerts;
  53175. /**
  53176. * Initialise the soft body vertices to match its object's (mesh) vertices
  53177. * Softbody vertices (nodes) are in world space and to match this
  53178. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53179. * @param impostor to create the softbody for
  53180. */
  53181. private _softVertexData;
  53182. /**
  53183. * Create an impostor's soft body
  53184. * @param impostor to create the softbody for
  53185. */
  53186. private _createSoftbody;
  53187. /**
  53188. * Create cloth for an impostor
  53189. * @param impostor to create the softbody for
  53190. */
  53191. private _createCloth;
  53192. /**
  53193. * Create rope for an impostor
  53194. * @param impostor to create the softbody for
  53195. */
  53196. private _createRope;
  53197. /**
  53198. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  53199. * @param impostor to create the custom physics shape for
  53200. */
  53201. private _createCustom;
  53202. private _addHullVerts;
  53203. private _createShape;
  53204. /**
  53205. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53206. * @param impostor imposter containing the physics body and babylon object
  53207. */
  53208. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53209. /**
  53210. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53211. * @param impostor imposter containing the physics body and babylon object
  53212. * @param newPosition new position
  53213. * @param newRotation new rotation
  53214. */
  53215. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53216. /**
  53217. * If this plugin is supported
  53218. * @returns true if its supported
  53219. */
  53220. isSupported(): boolean;
  53221. /**
  53222. * Sets the linear velocity of the physics body
  53223. * @param impostor imposter to set the velocity on
  53224. * @param velocity velocity to set
  53225. */
  53226. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53227. /**
  53228. * Sets the angular velocity of the physics body
  53229. * @param impostor imposter to set the velocity on
  53230. * @param velocity velocity to set
  53231. */
  53232. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53233. /**
  53234. * gets the linear velocity
  53235. * @param impostor imposter to get linear velocity from
  53236. * @returns linear velocity
  53237. */
  53238. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53239. /**
  53240. * gets the angular velocity
  53241. * @param impostor imposter to get angular velocity from
  53242. * @returns angular velocity
  53243. */
  53244. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53245. /**
  53246. * Sets the mass of physics body
  53247. * @param impostor imposter to set the mass on
  53248. * @param mass mass to set
  53249. */
  53250. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53251. /**
  53252. * Gets the mass of the physics body
  53253. * @param impostor imposter to get the mass from
  53254. * @returns mass
  53255. */
  53256. getBodyMass(impostor: PhysicsImpostor): number;
  53257. /**
  53258. * Gets friction of the impostor
  53259. * @param impostor impostor to get friction from
  53260. * @returns friction value
  53261. */
  53262. getBodyFriction(impostor: PhysicsImpostor): number;
  53263. /**
  53264. * Sets friction of the impostor
  53265. * @param impostor impostor to set friction on
  53266. * @param friction friction value
  53267. */
  53268. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53269. /**
  53270. * Gets restitution of the impostor
  53271. * @param impostor impostor to get restitution from
  53272. * @returns restitution value
  53273. */
  53274. getBodyRestitution(impostor: PhysicsImpostor): number;
  53275. /**
  53276. * Sets resitution of the impostor
  53277. * @param impostor impostor to set resitution on
  53278. * @param restitution resitution value
  53279. */
  53280. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53281. /**
  53282. * Gets pressure inside the impostor
  53283. * @param impostor impostor to get pressure from
  53284. * @returns pressure value
  53285. */
  53286. getBodyPressure(impostor: PhysicsImpostor): number;
  53287. /**
  53288. * Sets pressure inside a soft body impostor
  53289. * Cloth and rope must remain 0 pressure
  53290. * @param impostor impostor to set pressure on
  53291. * @param pressure pressure value
  53292. */
  53293. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53294. /**
  53295. * Gets stiffness of the impostor
  53296. * @param impostor impostor to get stiffness from
  53297. * @returns pressure value
  53298. */
  53299. getBodyStiffness(impostor: PhysicsImpostor): number;
  53300. /**
  53301. * Sets stiffness of the impostor
  53302. * @param impostor impostor to set stiffness on
  53303. * @param stiffness stiffness value from 0 to 1
  53304. */
  53305. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53306. /**
  53307. * Gets velocityIterations of the impostor
  53308. * @param impostor impostor to get velocity iterations from
  53309. * @returns velocityIterations value
  53310. */
  53311. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53312. /**
  53313. * Sets velocityIterations of the impostor
  53314. * @param impostor impostor to set velocity iterations on
  53315. * @param velocityIterations velocityIterations value
  53316. */
  53317. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53318. /**
  53319. * Gets positionIterations of the impostor
  53320. * @param impostor impostor to get position iterations from
  53321. * @returns positionIterations value
  53322. */
  53323. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53324. /**
  53325. * Sets positionIterations of the impostor
  53326. * @param impostor impostor to set position on
  53327. * @param positionIterations positionIterations value
  53328. */
  53329. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53330. /**
  53331. * Append an anchor to a cloth object
  53332. * @param impostor is the cloth impostor to add anchor to
  53333. * @param otherImpostor is the rigid impostor to anchor to
  53334. * @param width ratio across width from 0 to 1
  53335. * @param height ratio up height from 0 to 1
  53336. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53337. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53338. */
  53339. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53340. /**
  53341. * Append an hook to a rope object
  53342. * @param impostor is the rope impostor to add hook to
  53343. * @param otherImpostor is the rigid impostor to hook to
  53344. * @param length ratio along the rope from 0 to 1
  53345. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53346. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53347. */
  53348. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53349. /**
  53350. * Sleeps the physics body and stops it from being active
  53351. * @param impostor impostor to sleep
  53352. */
  53353. sleepBody(impostor: PhysicsImpostor): void;
  53354. /**
  53355. * Activates the physics body
  53356. * @param impostor impostor to activate
  53357. */
  53358. wakeUpBody(impostor: PhysicsImpostor): void;
  53359. /**
  53360. * Updates the distance parameters of the joint
  53361. * @param joint joint to update
  53362. * @param maxDistance maximum distance of the joint
  53363. * @param minDistance minimum distance of the joint
  53364. */
  53365. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53366. /**
  53367. * Sets a motor on the joint
  53368. * @param joint joint to set motor on
  53369. * @param speed speed of the motor
  53370. * @param maxForce maximum force of the motor
  53371. * @param motorIndex index of the motor
  53372. */
  53373. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53374. /**
  53375. * Sets the motors limit
  53376. * @param joint joint to set limit on
  53377. * @param upperLimit upper limit
  53378. * @param lowerLimit lower limit
  53379. */
  53380. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53381. /**
  53382. * Syncs the position and rotation of a mesh with the impostor
  53383. * @param mesh mesh to sync
  53384. * @param impostor impostor to update the mesh with
  53385. */
  53386. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53387. /**
  53388. * Gets the radius of the impostor
  53389. * @param impostor impostor to get radius from
  53390. * @returns the radius
  53391. */
  53392. getRadius(impostor: PhysicsImpostor): number;
  53393. /**
  53394. * Gets the box size of the impostor
  53395. * @param impostor impostor to get box size from
  53396. * @param result the resulting box size
  53397. */
  53398. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53399. /**
  53400. * Disposes of the impostor
  53401. */
  53402. dispose(): void;
  53403. /**
  53404. * Does a raycast in the physics world
  53405. * @param from when should the ray start?
  53406. * @param to when should the ray end?
  53407. * @returns PhysicsRaycastResult
  53408. */
  53409. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53410. }
  53411. }
  53412. declare module BABYLON {
  53413. interface AbstractScene {
  53414. /**
  53415. * The list of reflection probes added to the scene
  53416. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53417. */
  53418. reflectionProbes: Array<ReflectionProbe>;
  53419. /**
  53420. * Removes the given reflection probe from this scene.
  53421. * @param toRemove The reflection probe to remove
  53422. * @returns The index of the removed reflection probe
  53423. */
  53424. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53425. /**
  53426. * Adds the given reflection probe to this scene.
  53427. * @param newReflectionProbe The reflection probe to add
  53428. */
  53429. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53430. }
  53431. /**
  53432. * Class used to generate realtime reflection / refraction cube textures
  53433. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53434. */
  53435. export class ReflectionProbe {
  53436. /** defines the name of the probe */
  53437. name: string;
  53438. private _scene;
  53439. private _renderTargetTexture;
  53440. private _projectionMatrix;
  53441. private _viewMatrix;
  53442. private _target;
  53443. private _add;
  53444. private _attachedMesh;
  53445. private _invertYAxis;
  53446. /** Gets or sets probe position (center of the cube map) */
  53447. position: Vector3;
  53448. /**
  53449. * Creates a new reflection probe
  53450. * @param name defines the name of the probe
  53451. * @param size defines the texture resolution (for each face)
  53452. * @param scene defines the hosting scene
  53453. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53454. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53455. */
  53456. constructor(
  53457. /** defines the name of the probe */
  53458. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53459. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53460. samples: number;
  53461. /** Gets or sets the refresh rate to use (on every frame by default) */
  53462. refreshRate: number;
  53463. /**
  53464. * Gets the hosting scene
  53465. * @returns a Scene
  53466. */
  53467. getScene(): Scene;
  53468. /** Gets the internal CubeTexture used to render to */
  53469. readonly cubeTexture: RenderTargetTexture;
  53470. /** Gets the list of meshes to render */
  53471. readonly renderList: Nullable<AbstractMesh[]>;
  53472. /**
  53473. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53474. * @param mesh defines the mesh to attach to
  53475. */
  53476. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53477. /**
  53478. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53479. * @param renderingGroupId The rendering group id corresponding to its index
  53480. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53481. */
  53482. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53483. /**
  53484. * Clean all associated resources
  53485. */
  53486. dispose(): void;
  53487. /**
  53488. * Converts the reflection probe information to a readable string for debug purpose.
  53489. * @param fullDetails Supports for multiple levels of logging within scene loading
  53490. * @returns the human readable reflection probe info
  53491. */
  53492. toString(fullDetails?: boolean): string;
  53493. /**
  53494. * Get the class name of the relfection probe.
  53495. * @returns "ReflectionProbe"
  53496. */
  53497. getClassName(): string;
  53498. /**
  53499. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53500. * @returns The JSON representation of the texture
  53501. */
  53502. serialize(): any;
  53503. /**
  53504. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53505. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53506. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53507. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53508. * @returns The parsed reflection probe if successful
  53509. */
  53510. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53511. }
  53512. }
  53513. declare module BABYLON {
  53514. /** @hidden */
  53515. export var _BabylonLoaderRegistered: boolean;
  53516. /**
  53517. * Helps setting up some configuration for the babylon file loader.
  53518. */
  53519. export class BabylonFileLoaderConfiguration {
  53520. /**
  53521. * The loader does not allow injecting custom physix engine into the plugins.
  53522. * Unfortunately in ES6, we need to manually inject them into the plugin.
  53523. * So you could set this variable to your engine import to make it work.
  53524. */
  53525. static LoaderInjectedPhysicsEngine: any;
  53526. }
  53527. }
  53528. declare module BABYLON {
  53529. /**
  53530. * The Physically based simple base material of BJS.
  53531. *
  53532. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53533. * It is used as the base class for both the specGloss and metalRough conventions.
  53534. */
  53535. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53536. /**
  53537. * Number of Simultaneous lights allowed on the material.
  53538. */
  53539. maxSimultaneousLights: number;
  53540. /**
  53541. * If sets to true, disables all the lights affecting the material.
  53542. */
  53543. disableLighting: boolean;
  53544. /**
  53545. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53546. */
  53547. environmentTexture: BaseTexture;
  53548. /**
  53549. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53550. */
  53551. invertNormalMapX: boolean;
  53552. /**
  53553. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53554. */
  53555. invertNormalMapY: boolean;
  53556. /**
  53557. * Normal map used in the model.
  53558. */
  53559. normalTexture: BaseTexture;
  53560. /**
  53561. * Emissivie color used to self-illuminate the model.
  53562. */
  53563. emissiveColor: Color3;
  53564. /**
  53565. * Emissivie texture used to self-illuminate the model.
  53566. */
  53567. emissiveTexture: BaseTexture;
  53568. /**
  53569. * Occlusion Channel Strenght.
  53570. */
  53571. occlusionStrength: number;
  53572. /**
  53573. * Occlusion Texture of the material (adding extra occlusion effects).
  53574. */
  53575. occlusionTexture: BaseTexture;
  53576. /**
  53577. * Defines the alpha limits in alpha test mode.
  53578. */
  53579. alphaCutOff: number;
  53580. /**
  53581. * Gets the current double sided mode.
  53582. */
  53583. /**
  53584. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53585. */
  53586. doubleSided: boolean;
  53587. /**
  53588. * Stores the pre-calculated light information of a mesh in a texture.
  53589. */
  53590. lightmapTexture: BaseTexture;
  53591. /**
  53592. * If true, the light map contains occlusion information instead of lighting info.
  53593. */
  53594. useLightmapAsShadowmap: boolean;
  53595. /**
  53596. * Instantiates a new PBRMaterial instance.
  53597. *
  53598. * @param name The material name
  53599. * @param scene The scene the material will be use in.
  53600. */
  53601. constructor(name: string, scene: Scene);
  53602. getClassName(): string;
  53603. }
  53604. }
  53605. declare module BABYLON {
  53606. /**
  53607. * The PBR material of BJS following the metal roughness convention.
  53608. *
  53609. * This fits to the PBR convention in the GLTF definition:
  53610. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53611. */
  53612. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53613. /**
  53614. * The base color has two different interpretations depending on the value of metalness.
  53615. * When the material is a metal, the base color is the specific measured reflectance value
  53616. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53617. * of the material.
  53618. */
  53619. baseColor: Color3;
  53620. /**
  53621. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53622. * well as opacity information in the alpha channel.
  53623. */
  53624. baseTexture: BaseTexture;
  53625. /**
  53626. * Specifies the metallic scalar value of the material.
  53627. * Can also be used to scale the metalness values of the metallic texture.
  53628. */
  53629. metallic: number;
  53630. /**
  53631. * Specifies the roughness scalar value of the material.
  53632. * Can also be used to scale the roughness values of the metallic texture.
  53633. */
  53634. roughness: number;
  53635. /**
  53636. * Texture containing both the metallic value in the B channel and the
  53637. * roughness value in the G channel to keep better precision.
  53638. */
  53639. metallicRoughnessTexture: BaseTexture;
  53640. /**
  53641. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53642. *
  53643. * @param name The material name
  53644. * @param scene The scene the material will be use in.
  53645. */
  53646. constructor(name: string, scene: Scene);
  53647. /**
  53648. * Return the currrent class name of the material.
  53649. */
  53650. getClassName(): string;
  53651. /**
  53652. * Makes a duplicate of the current material.
  53653. * @param name - name to use for the new material.
  53654. */
  53655. clone(name: string): PBRMetallicRoughnessMaterial;
  53656. /**
  53657. * Serialize the material to a parsable JSON object.
  53658. */
  53659. serialize(): any;
  53660. /**
  53661. * Parses a JSON object correponding to the serialize function.
  53662. */
  53663. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53664. }
  53665. }
  53666. declare module BABYLON {
  53667. /**
  53668. * The PBR material of BJS following the specular glossiness convention.
  53669. *
  53670. * This fits to the PBR convention in the GLTF definition:
  53671. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53672. */
  53673. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53674. /**
  53675. * Specifies the diffuse color of the material.
  53676. */
  53677. diffuseColor: Color3;
  53678. /**
  53679. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53680. * channel.
  53681. */
  53682. diffuseTexture: BaseTexture;
  53683. /**
  53684. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53685. */
  53686. specularColor: Color3;
  53687. /**
  53688. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53689. */
  53690. glossiness: number;
  53691. /**
  53692. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53693. */
  53694. specularGlossinessTexture: BaseTexture;
  53695. /**
  53696. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53697. *
  53698. * @param name The material name
  53699. * @param scene The scene the material will be use in.
  53700. */
  53701. constructor(name: string, scene: Scene);
  53702. /**
  53703. * Return the currrent class name of the material.
  53704. */
  53705. getClassName(): string;
  53706. /**
  53707. * Makes a duplicate of the current material.
  53708. * @param name - name to use for the new material.
  53709. */
  53710. clone(name: string): PBRSpecularGlossinessMaterial;
  53711. /**
  53712. * Serialize the material to a parsable JSON object.
  53713. */
  53714. serialize(): any;
  53715. /**
  53716. * Parses a JSON object correponding to the serialize function.
  53717. */
  53718. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53719. }
  53720. }
  53721. declare module BABYLON {
  53722. /**
  53723. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53724. * It can help converting any input color in a desired output one. This can then be used to create effects
  53725. * from sepia, black and white to sixties or futuristic rendering...
  53726. *
  53727. * The only supported format is currently 3dl.
  53728. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53729. */
  53730. export class ColorGradingTexture extends BaseTexture {
  53731. /**
  53732. * The current texture matrix. (will always be identity in color grading texture)
  53733. */
  53734. private _textureMatrix;
  53735. /**
  53736. * The texture URL.
  53737. */
  53738. url: string;
  53739. /**
  53740. * Empty line regex stored for GC.
  53741. */
  53742. private static _noneEmptyLineRegex;
  53743. private _engine;
  53744. /**
  53745. * Instantiates a ColorGradingTexture from the following parameters.
  53746. *
  53747. * @param url The location of the color gradind data (currently only supporting 3dl)
  53748. * @param scene The scene the texture will be used in
  53749. */
  53750. constructor(url: string, scene: Scene);
  53751. /**
  53752. * Returns the texture matrix used in most of the material.
  53753. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53754. */
  53755. getTextureMatrix(): Matrix;
  53756. /**
  53757. * Occurs when the file being loaded is a .3dl LUT file.
  53758. */
  53759. private load3dlTexture;
  53760. /**
  53761. * Starts the loading process of the texture.
  53762. */
  53763. private loadTexture;
  53764. /**
  53765. * Clones the color gradind texture.
  53766. */
  53767. clone(): ColorGradingTexture;
  53768. /**
  53769. * Called during delayed load for textures.
  53770. */
  53771. delayLoad(): void;
  53772. /**
  53773. * Parses a color grading texture serialized by Babylon.
  53774. * @param parsedTexture The texture information being parsedTexture
  53775. * @param scene The scene to load the texture in
  53776. * @param rootUrl The root url of the data assets to load
  53777. * @return A color gradind texture
  53778. */
  53779. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53780. /**
  53781. * Serializes the LUT texture to json format.
  53782. */
  53783. serialize(): any;
  53784. }
  53785. }
  53786. declare module BABYLON {
  53787. /**
  53788. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53789. */
  53790. export class EquiRectangularCubeTexture extends BaseTexture {
  53791. /** The six faces of the cube. */
  53792. private static _FacesMapping;
  53793. private _noMipmap;
  53794. private _onLoad;
  53795. private _onError;
  53796. /** The size of the cubemap. */
  53797. private _size;
  53798. /** The buffer of the image. */
  53799. private _buffer;
  53800. /** The width of the input image. */
  53801. private _width;
  53802. /** The height of the input image. */
  53803. private _height;
  53804. /** The URL to the image. */
  53805. url: string;
  53806. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53807. coordinatesMode: number;
  53808. /**
  53809. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53810. * @param url The location of the image
  53811. * @param scene The scene the texture will be used in
  53812. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53813. * @param noMipmap Forces to not generate the mipmap if true
  53814. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53815. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53816. * @param onLoad — defines a callback called when texture is loaded
  53817. * @param onError — defines a callback called if there is an error
  53818. */
  53819. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53820. /**
  53821. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53822. */
  53823. private loadImage;
  53824. /**
  53825. * Convert the image buffer into a cubemap and create a CubeTexture.
  53826. */
  53827. private loadTexture;
  53828. /**
  53829. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53830. * @param buffer The ArrayBuffer that should be converted.
  53831. * @returns The buffer as Float32Array.
  53832. */
  53833. private getFloat32ArrayFromArrayBuffer;
  53834. /**
  53835. * Get the current class name of the texture useful for serialization or dynamic coding.
  53836. * @returns "EquiRectangularCubeTexture"
  53837. */
  53838. getClassName(): string;
  53839. /**
  53840. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53841. * @returns A clone of the current EquiRectangularCubeTexture.
  53842. */
  53843. clone(): EquiRectangularCubeTexture;
  53844. }
  53845. }
  53846. declare module BABYLON {
  53847. /**
  53848. * Based on jsTGALoader - Javascript loader for TGA file
  53849. * By Vincent Thibault
  53850. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53851. */
  53852. export class TGATools {
  53853. private static _TYPE_INDEXED;
  53854. private static _TYPE_RGB;
  53855. private static _TYPE_GREY;
  53856. private static _TYPE_RLE_INDEXED;
  53857. private static _TYPE_RLE_RGB;
  53858. private static _TYPE_RLE_GREY;
  53859. private static _ORIGIN_MASK;
  53860. private static _ORIGIN_SHIFT;
  53861. private static _ORIGIN_BL;
  53862. private static _ORIGIN_BR;
  53863. private static _ORIGIN_UL;
  53864. private static _ORIGIN_UR;
  53865. /**
  53866. * Gets the header of a TGA file
  53867. * @param data defines the TGA data
  53868. * @returns the header
  53869. */
  53870. static GetTGAHeader(data: Uint8Array): any;
  53871. /**
  53872. * Uploads TGA content to a Babylon Texture
  53873. * @hidden
  53874. */
  53875. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53876. /** @hidden */
  53877. 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;
  53878. /** @hidden */
  53879. 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;
  53880. /** @hidden */
  53881. 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;
  53882. /** @hidden */
  53883. 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;
  53884. /** @hidden */
  53885. 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;
  53886. /** @hidden */
  53887. 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;
  53888. }
  53889. }
  53890. declare module BABYLON {
  53891. /**
  53892. * Implementation of the TGA Texture Loader.
  53893. * @hidden
  53894. */
  53895. export class _TGATextureLoader implements IInternalTextureLoader {
  53896. /**
  53897. * Defines wether the loader supports cascade loading the different faces.
  53898. */
  53899. readonly supportCascades: boolean;
  53900. /**
  53901. * This returns if the loader support the current file information.
  53902. * @param extension defines the file extension of the file being loaded
  53903. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53904. * @param fallback defines the fallback internal texture if any
  53905. * @param isBase64 defines whether the texture is encoded as a base64
  53906. * @param isBuffer defines whether the texture data are stored as a buffer
  53907. * @returns true if the loader can load the specified file
  53908. */
  53909. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53910. /**
  53911. * Transform the url before loading if required.
  53912. * @param rootUrl the url of the texture
  53913. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53914. * @returns the transformed texture
  53915. */
  53916. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53917. /**
  53918. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53919. * @param rootUrl the url of the texture
  53920. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53921. * @returns the fallback texture
  53922. */
  53923. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53924. /**
  53925. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53926. * @param data contains the texture data
  53927. * @param texture defines the BabylonJS internal texture
  53928. * @param createPolynomials will be true if polynomials have been requested
  53929. * @param onLoad defines the callback to trigger once the texture is ready
  53930. * @param onError defines the callback to trigger in case of error
  53931. */
  53932. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53933. /**
  53934. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53935. * @param data contains the texture data
  53936. * @param texture defines the BabylonJS internal texture
  53937. * @param callback defines the method to call once ready to upload
  53938. */
  53939. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53940. }
  53941. }
  53942. declare module BABYLON {
  53943. /**
  53944. * Info about the .basis files
  53945. */
  53946. class BasisFileInfo {
  53947. /**
  53948. * If the file has alpha
  53949. */
  53950. hasAlpha: boolean;
  53951. /**
  53952. * Info about each image of the basis file
  53953. */
  53954. images: Array<{
  53955. levels: Array<{
  53956. width: number;
  53957. height: number;
  53958. transcodedPixels: ArrayBufferView;
  53959. }>;
  53960. }>;
  53961. }
  53962. /**
  53963. * Result of transcoding a basis file
  53964. */
  53965. class TranscodeResult {
  53966. /**
  53967. * Info about the .basis file
  53968. */
  53969. fileInfo: BasisFileInfo;
  53970. /**
  53971. * Format to use when loading the file
  53972. */
  53973. format: number;
  53974. }
  53975. /**
  53976. * Configuration options for the Basis transcoder
  53977. */
  53978. export class BasisTranscodeConfiguration {
  53979. /**
  53980. * Supported compression formats used to determine the supported output format of the transcoder
  53981. */
  53982. supportedCompressionFormats?: {
  53983. /**
  53984. * etc1 compression format
  53985. */
  53986. etc1?: boolean;
  53987. /**
  53988. * s3tc compression format
  53989. */
  53990. s3tc?: boolean;
  53991. /**
  53992. * pvrtc compression format
  53993. */
  53994. pvrtc?: boolean;
  53995. /**
  53996. * etc2 compression format
  53997. */
  53998. etc2?: boolean;
  53999. };
  54000. /**
  54001. * If mipmap levels should be loaded for transcoded images (Default: true)
  54002. */
  54003. loadMipmapLevels?: boolean;
  54004. /**
  54005. * Index of a single image to load (Default: all images)
  54006. */
  54007. loadSingleImage?: number;
  54008. }
  54009. /**
  54010. * Used to load .Basis files
  54011. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54012. */
  54013. export class BasisTools {
  54014. private static _IgnoreSupportedFormats;
  54015. /**
  54016. * URL to use when loading the basis transcoder
  54017. */
  54018. static JSModuleURL: string;
  54019. /**
  54020. * URL to use when loading the wasm module for the transcoder
  54021. */
  54022. static WasmModuleURL: string;
  54023. /**
  54024. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54025. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54026. * @returns internal format corresponding to the Basis format
  54027. */
  54028. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54029. private static _WorkerPromise;
  54030. private static _Worker;
  54031. private static _actionId;
  54032. private static _CreateWorkerAsync;
  54033. /**
  54034. * Transcodes a loaded image file to compressed pixel data
  54035. * @param imageData image data to transcode
  54036. * @param config configuration options for the transcoding
  54037. * @returns a promise resulting in the transcoded image
  54038. */
  54039. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54040. /**
  54041. * Loads a texture from the transcode result
  54042. * @param texture texture load to
  54043. * @param transcodeResult the result of transcoding the basis file to load from
  54044. */
  54045. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54046. }
  54047. }
  54048. declare module BABYLON {
  54049. /**
  54050. * Loader for .basis file format
  54051. */
  54052. export class _BasisTextureLoader implements IInternalTextureLoader {
  54053. /**
  54054. * Defines whether the loader supports cascade loading the different faces.
  54055. */
  54056. readonly supportCascades: boolean;
  54057. /**
  54058. * This returns if the loader support the current file information.
  54059. * @param extension defines the file extension of the file being loaded
  54060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54061. * @param fallback defines the fallback internal texture if any
  54062. * @param isBase64 defines whether the texture is encoded as a base64
  54063. * @param isBuffer defines whether the texture data are stored as a buffer
  54064. * @returns true if the loader can load the specified file
  54065. */
  54066. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54067. /**
  54068. * Transform the url before loading if required.
  54069. * @param rootUrl the url of the texture
  54070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54071. * @returns the transformed texture
  54072. */
  54073. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54074. /**
  54075. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54076. * @param rootUrl the url of the texture
  54077. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54078. * @returns the fallback texture
  54079. */
  54080. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54081. /**
  54082. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54083. * @param data contains the texture data
  54084. * @param texture defines the BabylonJS internal texture
  54085. * @param createPolynomials will be true if polynomials have been requested
  54086. * @param onLoad defines the callback to trigger once the texture is ready
  54087. * @param onError defines the callback to trigger in case of error
  54088. */
  54089. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54090. /**
  54091. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54092. * @param data contains the texture data
  54093. * @param texture defines the BabylonJS internal texture
  54094. * @param callback defines the method to call once ready to upload
  54095. */
  54096. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54097. }
  54098. }
  54099. declare module BABYLON {
  54100. /**
  54101. * 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.
  54102. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54103. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54104. */
  54105. export class CustomProceduralTexture extends ProceduralTexture {
  54106. private _animate;
  54107. private _time;
  54108. private _config;
  54109. private _texturePath;
  54110. /**
  54111. * Instantiates a new Custom Procedural Texture.
  54112. * 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.
  54113. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54114. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54115. * @param name Define the name of the texture
  54116. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54117. * @param size Define the size of the texture to create
  54118. * @param scene Define the scene the texture belongs to
  54119. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54120. * @param generateMipMaps Define if the texture should creates mip maps or not
  54121. */
  54122. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54123. private _loadJson;
  54124. /**
  54125. * Is the texture ready to be used ? (rendered at least once)
  54126. * @returns true if ready, otherwise, false.
  54127. */
  54128. isReady(): boolean;
  54129. /**
  54130. * Render the texture to its associated render target.
  54131. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54132. */
  54133. render(useCameraPostProcess?: boolean): void;
  54134. /**
  54135. * Update the list of dependant textures samplers in the shader.
  54136. */
  54137. updateTextures(): void;
  54138. /**
  54139. * Update the uniform values of the procedural texture in the shader.
  54140. */
  54141. updateShaderUniforms(): void;
  54142. /**
  54143. * Define if the texture animates or not.
  54144. */
  54145. animate: boolean;
  54146. }
  54147. }
  54148. declare module BABYLON {
  54149. /** @hidden */
  54150. export var noisePixelShader: {
  54151. name: string;
  54152. shader: string;
  54153. };
  54154. }
  54155. declare module BABYLON {
  54156. /**
  54157. * Class used to generate noise procedural textures
  54158. */
  54159. export class NoiseProceduralTexture extends ProceduralTexture {
  54160. private _time;
  54161. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54162. brightness: number;
  54163. /** Defines the number of octaves to process */
  54164. octaves: number;
  54165. /** Defines the level of persistence (0.8 by default) */
  54166. persistence: number;
  54167. /** Gets or sets animation speed factor (default is 1) */
  54168. animationSpeedFactor: number;
  54169. /**
  54170. * Creates a new NoiseProceduralTexture
  54171. * @param name defines the name fo the texture
  54172. * @param size defines the size of the texture (default is 256)
  54173. * @param scene defines the hosting scene
  54174. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54175. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54176. */
  54177. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54178. private _updateShaderUniforms;
  54179. protected _getDefines(): string;
  54180. /** Generate the current state of the procedural texture */
  54181. render(useCameraPostProcess?: boolean): void;
  54182. /**
  54183. * Serializes this noise procedural texture
  54184. * @returns a serialized noise procedural texture object
  54185. */
  54186. serialize(): any;
  54187. /**
  54188. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54189. * @param parsedTexture defines parsed texture data
  54190. * @param scene defines the current scene
  54191. * @param rootUrl defines the root URL containing noise procedural texture information
  54192. * @returns a parsed NoiseProceduralTexture
  54193. */
  54194. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54195. }
  54196. }
  54197. declare module BABYLON {
  54198. /**
  54199. * Raw cube texture where the raw buffers are passed in
  54200. */
  54201. export class RawCubeTexture extends CubeTexture {
  54202. /**
  54203. * Creates a cube texture where the raw buffers are passed in.
  54204. * @param scene defines the scene the texture is attached to
  54205. * @param data defines the array of data to use to create each face
  54206. * @param size defines the size of the textures
  54207. * @param format defines the format of the data
  54208. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54209. * @param generateMipMaps defines if the engine should generate the mip levels
  54210. * @param invertY defines if data must be stored with Y axis inverted
  54211. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54212. * @param compression defines the compression used (null by default)
  54213. */
  54214. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54215. /**
  54216. * Updates the raw cube texture.
  54217. * @param data defines the data to store
  54218. * @param format defines the data format
  54219. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54220. * @param invertY defines if data must be stored with Y axis inverted
  54221. * @param compression defines the compression used (null by default)
  54222. * @param level defines which level of the texture to update
  54223. */
  54224. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54225. /**
  54226. * Updates a raw cube texture with RGBD encoded data.
  54227. * @param data defines the array of data [mipmap][face] to use to create each face
  54228. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54229. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54230. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54231. * @returns a promsie that resolves when the operation is complete
  54232. */
  54233. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54234. /**
  54235. * Clones the raw cube texture.
  54236. * @return a new cube texture
  54237. */
  54238. clone(): CubeTexture;
  54239. /** @hidden */
  54240. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54241. }
  54242. }
  54243. declare module BABYLON {
  54244. /**
  54245. * Class used to store 3D textures containing user data
  54246. */
  54247. export class RawTexture3D extends Texture {
  54248. /** Gets or sets the texture format to use */
  54249. format: number;
  54250. private _engine;
  54251. /**
  54252. * Create a new RawTexture3D
  54253. * @param data defines the data of the texture
  54254. * @param width defines the width of the texture
  54255. * @param height defines the height of the texture
  54256. * @param depth defines the depth of the texture
  54257. * @param format defines the texture format to use
  54258. * @param scene defines the hosting scene
  54259. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54260. * @param invertY defines if texture must be stored with Y axis inverted
  54261. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54262. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54263. */
  54264. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54265. /** Gets or sets the texture format to use */
  54266. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54267. /**
  54268. * Update the texture with new data
  54269. * @param data defines the data to store in the texture
  54270. */
  54271. update(data: ArrayBufferView): void;
  54272. }
  54273. }
  54274. declare module BABYLON {
  54275. /**
  54276. * Class used to store 2D array textures containing user data
  54277. */
  54278. export class RawTexture2DArray extends Texture {
  54279. /** Gets or sets the texture format to use */
  54280. format: number;
  54281. private _engine;
  54282. /**
  54283. * Create a new RawTexture2DArray
  54284. * @param data defines the data of the texture
  54285. * @param width defines the width of the texture
  54286. * @param height defines the height of the texture
  54287. * @param depth defines the number of layers of the texture
  54288. * @param format defines the texture format to use
  54289. * @param scene defines the hosting scene
  54290. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54291. * @param invertY defines if texture must be stored with Y axis inverted
  54292. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54293. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54294. */
  54295. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54296. /** Gets or sets the texture format to use */
  54297. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54298. /**
  54299. * Update the texture with new data
  54300. * @param data defines the data to store in the texture
  54301. */
  54302. update(data: ArrayBufferView): void;
  54303. }
  54304. }
  54305. declare module BABYLON {
  54306. /**
  54307. * Creates a refraction texture used by refraction channel of the standard material.
  54308. * It is like a mirror but to see through a material.
  54309. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54310. */
  54311. export class RefractionTexture extends RenderTargetTexture {
  54312. /**
  54313. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54314. * 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.
  54315. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54316. */
  54317. refractionPlane: Plane;
  54318. /**
  54319. * Define how deep under the surface we should see.
  54320. */
  54321. depth: number;
  54322. /**
  54323. * Creates a refraction texture used by refraction channel of the standard material.
  54324. * It is like a mirror but to see through a material.
  54325. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54326. * @param name Define the texture name
  54327. * @param size Define the size of the underlying texture
  54328. * @param scene Define the scene the refraction belongs to
  54329. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54330. */
  54331. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54332. /**
  54333. * Clone the refraction texture.
  54334. * @returns the cloned texture
  54335. */
  54336. clone(): RefractionTexture;
  54337. /**
  54338. * Serialize the texture to a JSON representation you could use in Parse later on
  54339. * @returns the serialized JSON representation
  54340. */
  54341. serialize(): any;
  54342. }
  54343. }
  54344. declare module BABYLON {
  54345. /**
  54346. * Defines the options related to the creation of an HtmlElementTexture
  54347. */
  54348. export interface IHtmlElementTextureOptions {
  54349. /**
  54350. * Defines wether mip maps should be created or not.
  54351. */
  54352. generateMipMaps?: boolean;
  54353. /**
  54354. * Defines the sampling mode of the texture.
  54355. */
  54356. samplingMode?: number;
  54357. /**
  54358. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54359. */
  54360. engine: Nullable<ThinEngine>;
  54361. /**
  54362. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54363. */
  54364. scene: Nullable<Scene>;
  54365. }
  54366. /**
  54367. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54368. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54369. * is automatically managed.
  54370. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54371. * in your application.
  54372. *
  54373. * As the update is not automatic, you need to call them manually.
  54374. */
  54375. export class HtmlElementTexture extends BaseTexture {
  54376. /**
  54377. * The texture URL.
  54378. */
  54379. element: HTMLVideoElement | HTMLCanvasElement;
  54380. private static readonly DefaultOptions;
  54381. private _textureMatrix;
  54382. private _engine;
  54383. private _isVideo;
  54384. private _generateMipMaps;
  54385. private _samplingMode;
  54386. /**
  54387. * Instantiates a HtmlElementTexture from the following parameters.
  54388. *
  54389. * @param name Defines the name of the texture
  54390. * @param element Defines the video or canvas the texture is filled with
  54391. * @param options Defines the other none mandatory texture creation options
  54392. */
  54393. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54394. private _createInternalTexture;
  54395. /**
  54396. * Returns the texture matrix used in most of the material.
  54397. */
  54398. getTextureMatrix(): Matrix;
  54399. /**
  54400. * Updates the content of the texture.
  54401. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54402. */
  54403. update(invertY?: Nullable<boolean>): void;
  54404. }
  54405. }
  54406. declare module BABYLON {
  54407. /**
  54408. * Enum used to define the target of a block
  54409. */
  54410. export enum NodeMaterialBlockTargets {
  54411. /** Vertex shader */
  54412. Vertex = 1,
  54413. /** Fragment shader */
  54414. Fragment = 2,
  54415. /** Neutral */
  54416. Neutral = 4,
  54417. /** Vertex and Fragment */
  54418. VertexAndFragment = 3
  54419. }
  54420. }
  54421. declare module BABYLON {
  54422. /**
  54423. * Defines the kind of connection point for node based material
  54424. */
  54425. export enum NodeMaterialBlockConnectionPointTypes {
  54426. /** Float */
  54427. Float = 1,
  54428. /** Int */
  54429. Int = 2,
  54430. /** Vector2 */
  54431. Vector2 = 4,
  54432. /** Vector3 */
  54433. Vector3 = 8,
  54434. /** Vector4 */
  54435. Vector4 = 16,
  54436. /** Color3 */
  54437. Color3 = 32,
  54438. /** Color4 */
  54439. Color4 = 64,
  54440. /** Matrix */
  54441. Matrix = 128,
  54442. /** Detect type based on connection */
  54443. AutoDetect = 1024,
  54444. /** Output type that will be defined by input type */
  54445. BasedOnInput = 2048
  54446. }
  54447. }
  54448. declare module BABYLON {
  54449. /**
  54450. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54451. */
  54452. export enum NodeMaterialBlockConnectionPointMode {
  54453. /** Value is an uniform */
  54454. Uniform = 0,
  54455. /** Value is a mesh attribute */
  54456. Attribute = 1,
  54457. /** Value is a varying between vertex and fragment shaders */
  54458. Varying = 2,
  54459. /** Mode is undefined */
  54460. Undefined = 3
  54461. }
  54462. }
  54463. declare module BABYLON {
  54464. /**
  54465. * Enum used to define system values e.g. values automatically provided by the system
  54466. */
  54467. export enum NodeMaterialSystemValues {
  54468. /** World */
  54469. World = 1,
  54470. /** View */
  54471. View = 2,
  54472. /** Projection */
  54473. Projection = 3,
  54474. /** ViewProjection */
  54475. ViewProjection = 4,
  54476. /** WorldView */
  54477. WorldView = 5,
  54478. /** WorldViewProjection */
  54479. WorldViewProjection = 6,
  54480. /** CameraPosition */
  54481. CameraPosition = 7,
  54482. /** Fog Color */
  54483. FogColor = 8,
  54484. /** Delta time */
  54485. DeltaTime = 9
  54486. }
  54487. }
  54488. declare module BABYLON {
  54489. /**
  54490. * Root class for all node material optimizers
  54491. */
  54492. export class NodeMaterialOptimizer {
  54493. /**
  54494. * Function used to optimize a NodeMaterial graph
  54495. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54496. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54497. */
  54498. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54499. }
  54500. }
  54501. declare module BABYLON {
  54502. /**
  54503. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54504. */
  54505. export class TransformBlock extends NodeMaterialBlock {
  54506. /**
  54507. * Defines the value to use to complement W value to transform it to a Vector4
  54508. */
  54509. complementW: number;
  54510. /**
  54511. * Defines the value to use to complement z value to transform it to a Vector4
  54512. */
  54513. complementZ: number;
  54514. /**
  54515. * Creates a new TransformBlock
  54516. * @param name defines the block name
  54517. */
  54518. constructor(name: string);
  54519. /**
  54520. * Gets the current class name
  54521. * @returns the class name
  54522. */
  54523. getClassName(): string;
  54524. /**
  54525. * Gets the vector input
  54526. */
  54527. readonly vector: NodeMaterialConnectionPoint;
  54528. /**
  54529. * Gets the output component
  54530. */
  54531. readonly output: NodeMaterialConnectionPoint;
  54532. /**
  54533. * Gets the matrix transform input
  54534. */
  54535. readonly transform: NodeMaterialConnectionPoint;
  54536. protected _buildBlock(state: NodeMaterialBuildState): this;
  54537. serialize(): any;
  54538. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54539. protected _dumpPropertiesCode(): string;
  54540. }
  54541. }
  54542. declare module BABYLON {
  54543. /**
  54544. * Block used to output the vertex position
  54545. */
  54546. export class VertexOutputBlock extends NodeMaterialBlock {
  54547. /**
  54548. * Creates a new VertexOutputBlock
  54549. * @param name defines the block name
  54550. */
  54551. constructor(name: string);
  54552. /**
  54553. * Gets the current class name
  54554. * @returns the class name
  54555. */
  54556. getClassName(): string;
  54557. /**
  54558. * Gets the vector input component
  54559. */
  54560. readonly vector: NodeMaterialConnectionPoint;
  54561. protected _buildBlock(state: NodeMaterialBuildState): this;
  54562. }
  54563. }
  54564. declare module BABYLON {
  54565. /**
  54566. * Block used to output the final color
  54567. */
  54568. export class FragmentOutputBlock extends NodeMaterialBlock {
  54569. /**
  54570. * Create a new FragmentOutputBlock
  54571. * @param name defines the block name
  54572. */
  54573. constructor(name: string);
  54574. /**
  54575. * Gets the current class name
  54576. * @returns the class name
  54577. */
  54578. getClassName(): string;
  54579. /**
  54580. * Gets the rgba input component
  54581. */
  54582. readonly rgba: NodeMaterialConnectionPoint;
  54583. /**
  54584. * Gets the rgb input component
  54585. */
  54586. readonly rgb: NodeMaterialConnectionPoint;
  54587. /**
  54588. * Gets the a input component
  54589. */
  54590. readonly a: NodeMaterialConnectionPoint;
  54591. protected _buildBlock(state: NodeMaterialBuildState): this;
  54592. }
  54593. }
  54594. declare module BABYLON {
  54595. /**
  54596. * Block used to read a reflection texture from a sampler
  54597. */
  54598. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54599. private _define3DName;
  54600. private _defineCubicName;
  54601. private _defineExplicitName;
  54602. private _defineProjectionName;
  54603. private _defineLocalCubicName;
  54604. private _defineSphericalName;
  54605. private _definePlanarName;
  54606. private _defineEquirectangularName;
  54607. private _defineMirroredEquirectangularFixedName;
  54608. private _defineEquirectangularFixedName;
  54609. private _defineSkyboxName;
  54610. private _cubeSamplerName;
  54611. private _2DSamplerName;
  54612. private _positionUVWName;
  54613. private _directionWName;
  54614. private _reflectionCoordsName;
  54615. private _reflection2DCoordsName;
  54616. private _reflectionColorName;
  54617. private _reflectionMatrixName;
  54618. /**
  54619. * Gets or sets the texture associated with the node
  54620. */
  54621. texture: Nullable<BaseTexture>;
  54622. /**
  54623. * Create a new TextureBlock
  54624. * @param name defines the block name
  54625. */
  54626. constructor(name: string);
  54627. /**
  54628. * Gets the current class name
  54629. * @returns the class name
  54630. */
  54631. getClassName(): string;
  54632. /**
  54633. * Gets the world position input component
  54634. */
  54635. readonly position: NodeMaterialConnectionPoint;
  54636. /**
  54637. * Gets the world position input component
  54638. */
  54639. readonly worldPosition: NodeMaterialConnectionPoint;
  54640. /**
  54641. * Gets the world normal input component
  54642. */
  54643. readonly worldNormal: NodeMaterialConnectionPoint;
  54644. /**
  54645. * Gets the world input component
  54646. */
  54647. readonly world: NodeMaterialConnectionPoint;
  54648. /**
  54649. * Gets the camera (or eye) position component
  54650. */
  54651. readonly cameraPosition: NodeMaterialConnectionPoint;
  54652. /**
  54653. * Gets the view input component
  54654. */
  54655. readonly view: NodeMaterialConnectionPoint;
  54656. /**
  54657. * Gets the rgb output component
  54658. */
  54659. readonly rgb: NodeMaterialConnectionPoint;
  54660. /**
  54661. * Gets the r output component
  54662. */
  54663. readonly r: NodeMaterialConnectionPoint;
  54664. /**
  54665. * Gets the g output component
  54666. */
  54667. readonly g: NodeMaterialConnectionPoint;
  54668. /**
  54669. * Gets the b output component
  54670. */
  54671. readonly b: NodeMaterialConnectionPoint;
  54672. autoConfigure(material: NodeMaterial): void;
  54673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54674. isReady(): boolean;
  54675. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54676. private _injectVertexCode;
  54677. private _writeOutput;
  54678. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54679. protected _dumpPropertiesCode(): string;
  54680. serialize(): any;
  54681. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54682. }
  54683. }
  54684. declare module BABYLON {
  54685. /**
  54686. * Interface used to configure the node material editor
  54687. */
  54688. export interface INodeMaterialEditorOptions {
  54689. /** Define the URl to load node editor script */
  54690. editorURL?: string;
  54691. }
  54692. /** @hidden */
  54693. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54694. /** BONES */
  54695. NUM_BONE_INFLUENCERS: number;
  54696. BonesPerMesh: number;
  54697. BONETEXTURE: boolean;
  54698. /** MORPH TARGETS */
  54699. MORPHTARGETS: boolean;
  54700. MORPHTARGETS_NORMAL: boolean;
  54701. MORPHTARGETS_TANGENT: boolean;
  54702. MORPHTARGETS_UV: boolean;
  54703. NUM_MORPH_INFLUENCERS: number;
  54704. /** IMAGE PROCESSING */
  54705. IMAGEPROCESSING: boolean;
  54706. VIGNETTE: boolean;
  54707. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54708. VIGNETTEBLENDMODEOPAQUE: boolean;
  54709. TONEMAPPING: boolean;
  54710. TONEMAPPING_ACES: boolean;
  54711. CONTRAST: boolean;
  54712. EXPOSURE: boolean;
  54713. COLORCURVES: boolean;
  54714. COLORGRADING: boolean;
  54715. COLORGRADING3D: boolean;
  54716. SAMPLER3DGREENDEPTH: boolean;
  54717. SAMPLER3DBGRMAP: boolean;
  54718. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54719. /** MISC. */
  54720. BUMPDIRECTUV: number;
  54721. constructor();
  54722. setValue(name: string, value: boolean): void;
  54723. }
  54724. /**
  54725. * Class used to configure NodeMaterial
  54726. */
  54727. export interface INodeMaterialOptions {
  54728. /**
  54729. * Defines if blocks should emit comments
  54730. */
  54731. emitComments: boolean;
  54732. }
  54733. /**
  54734. * Class used to create a node based material built by assembling shader blocks
  54735. */
  54736. export class NodeMaterial extends PushMaterial {
  54737. private static _BuildIdGenerator;
  54738. private _options;
  54739. private _vertexCompilationState;
  54740. private _fragmentCompilationState;
  54741. private _sharedData;
  54742. private _buildId;
  54743. private _buildWasSuccessful;
  54744. private _cachedWorldViewMatrix;
  54745. private _cachedWorldViewProjectionMatrix;
  54746. private _optimizers;
  54747. private _animationFrame;
  54748. /** Define the URl to load node editor script */
  54749. static EditorURL: string;
  54750. private BJSNODEMATERIALEDITOR;
  54751. /** Get the inspector from bundle or global */
  54752. private _getGlobalNodeMaterialEditor;
  54753. /**
  54754. * Gets or sets data used by visual editor
  54755. * @see https://nme.babylonjs.com
  54756. */
  54757. editorData: any;
  54758. /**
  54759. * 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)
  54760. */
  54761. ignoreAlpha: boolean;
  54762. /**
  54763. * Defines the maximum number of lights that can be used in the material
  54764. */
  54765. maxSimultaneousLights: number;
  54766. /**
  54767. * Observable raised when the material is built
  54768. */
  54769. onBuildObservable: Observable<NodeMaterial>;
  54770. /**
  54771. * Gets or sets the root nodes of the material vertex shader
  54772. */
  54773. _vertexOutputNodes: NodeMaterialBlock[];
  54774. /**
  54775. * Gets or sets the root nodes of the material fragment (pixel) shader
  54776. */
  54777. _fragmentOutputNodes: NodeMaterialBlock[];
  54778. /** Gets or sets options to control the node material overall behavior */
  54779. options: INodeMaterialOptions;
  54780. /**
  54781. * Default configuration related to image processing available in the standard Material.
  54782. */
  54783. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54784. /**
  54785. * Gets the image processing configuration used either in this material.
  54786. */
  54787. /**
  54788. * Sets the Default image processing configuration used either in the this material.
  54789. *
  54790. * If sets to null, the scene one is in use.
  54791. */
  54792. imageProcessingConfiguration: ImageProcessingConfiguration;
  54793. /**
  54794. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54795. */
  54796. attachedBlocks: NodeMaterialBlock[];
  54797. /**
  54798. * Create a new node based material
  54799. * @param name defines the material name
  54800. * @param scene defines the hosting scene
  54801. * @param options defines creation option
  54802. */
  54803. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54804. /**
  54805. * Gets the current class name of the material e.g. "NodeMaterial"
  54806. * @returns the class name
  54807. */
  54808. getClassName(): string;
  54809. /**
  54810. * Keep track of the image processing observer to allow dispose and replace.
  54811. */
  54812. private _imageProcessingObserver;
  54813. /**
  54814. * Attaches a new image processing configuration to the Standard Material.
  54815. * @param configuration
  54816. */
  54817. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54818. /**
  54819. * Get a block by its name
  54820. * @param name defines the name of the block to retrieve
  54821. * @returns the required block or null if not found
  54822. */
  54823. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54824. /**
  54825. * Get a block by its name
  54826. * @param predicate defines the predicate used to find the good candidate
  54827. * @returns the required block or null if not found
  54828. */
  54829. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54830. /**
  54831. * Get an input block by its name
  54832. * @param predicate defines the predicate used to find the good candidate
  54833. * @returns the required input block or null if not found
  54834. */
  54835. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54836. /**
  54837. * Gets the list of input blocks attached to this material
  54838. * @returns an array of InputBlocks
  54839. */
  54840. getInputBlocks(): InputBlock[];
  54841. /**
  54842. * Adds a new optimizer to the list of optimizers
  54843. * @param optimizer defines the optimizers to add
  54844. * @returns the current material
  54845. */
  54846. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54847. /**
  54848. * Remove an optimizer from the list of optimizers
  54849. * @param optimizer defines the optimizers to remove
  54850. * @returns the current material
  54851. */
  54852. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54853. /**
  54854. * Add a new block to the list of output nodes
  54855. * @param node defines the node to add
  54856. * @returns the current material
  54857. */
  54858. addOutputNode(node: NodeMaterialBlock): this;
  54859. /**
  54860. * Remove a block from the list of root nodes
  54861. * @param node defines the node to remove
  54862. * @returns the current material
  54863. */
  54864. removeOutputNode(node: NodeMaterialBlock): this;
  54865. private _addVertexOutputNode;
  54866. private _removeVertexOutputNode;
  54867. private _addFragmentOutputNode;
  54868. private _removeFragmentOutputNode;
  54869. /**
  54870. * Specifies if the material will require alpha blending
  54871. * @returns a boolean specifying if alpha blending is needed
  54872. */
  54873. needAlphaBlending(): boolean;
  54874. /**
  54875. * Specifies if this material should be rendered in alpha test mode
  54876. * @returns a boolean specifying if an alpha test is needed.
  54877. */
  54878. needAlphaTesting(): boolean;
  54879. private _initializeBlock;
  54880. private _resetDualBlocks;
  54881. /**
  54882. * Remove a block from the current node material
  54883. * @param block defines the block to remove
  54884. */
  54885. removeBlock(block: NodeMaterialBlock): void;
  54886. /**
  54887. * Build the material and generates the inner effect
  54888. * @param verbose defines if the build should log activity
  54889. */
  54890. build(verbose?: boolean): void;
  54891. /**
  54892. * Runs an otpimization phase to try to improve the shader code
  54893. */
  54894. optimize(): void;
  54895. private _prepareDefinesForAttributes;
  54896. /**
  54897. * Get if the submesh is ready to be used and all its information available.
  54898. * Child classes can use it to update shaders
  54899. * @param mesh defines the mesh to check
  54900. * @param subMesh defines which submesh to check
  54901. * @param useInstances specifies that instances should be used
  54902. * @returns a boolean indicating that the submesh is ready or not
  54903. */
  54904. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54905. /**
  54906. * Get a string representing the shaders built by the current node graph
  54907. */
  54908. readonly compiledShaders: string;
  54909. /**
  54910. * Binds the world matrix to the material
  54911. * @param world defines the world transformation matrix
  54912. */
  54913. bindOnlyWorldMatrix(world: Matrix): void;
  54914. /**
  54915. * Binds the submesh to this material by preparing the effect and shader to draw
  54916. * @param world defines the world transformation matrix
  54917. * @param mesh defines the mesh containing the submesh
  54918. * @param subMesh defines the submesh to bind the material to
  54919. */
  54920. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54921. /**
  54922. * Gets the active textures from the material
  54923. * @returns an array of textures
  54924. */
  54925. getActiveTextures(): BaseTexture[];
  54926. /**
  54927. * Gets the list of texture blocks
  54928. * @returns an array of texture blocks
  54929. */
  54930. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54931. /**
  54932. * Specifies if the material uses a texture
  54933. * @param texture defines the texture to check against the material
  54934. * @returns a boolean specifying if the material uses the texture
  54935. */
  54936. hasTexture(texture: BaseTexture): boolean;
  54937. /**
  54938. * Disposes the material
  54939. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54940. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54941. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54942. */
  54943. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54944. /** Creates the node editor window. */
  54945. private _createNodeEditor;
  54946. /**
  54947. * Launch the node material editor
  54948. * @param config Define the configuration of the editor
  54949. * @return a promise fulfilled when the node editor is visible
  54950. */
  54951. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54952. /**
  54953. * Clear the current material
  54954. */
  54955. clear(): void;
  54956. /**
  54957. * Clear the current material and set it to a default state
  54958. */
  54959. setToDefault(): void;
  54960. /**
  54961. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54962. * @param url defines the url to load from
  54963. * @returns a promise that will fullfil when the material is fully loaded
  54964. */
  54965. loadAsync(url: string): Promise<void>;
  54966. private _gatherBlocks;
  54967. /**
  54968. * Generate a string containing the code declaration required to create an equivalent of this material
  54969. * @returns a string
  54970. */
  54971. generateCode(): string;
  54972. /**
  54973. * Serializes this material in a JSON representation
  54974. * @returns the serialized material object
  54975. */
  54976. serialize(): any;
  54977. private _restoreConnections;
  54978. /**
  54979. * Clear the current graph and load a new one from a serialization object
  54980. * @param source defines the JSON representation of the material
  54981. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54982. */
  54983. loadFromSerialization(source: any, rootUrl?: string): void;
  54984. /**
  54985. * Creates a node material from parsed material data
  54986. * @param source defines the JSON representation of the material
  54987. * @param scene defines the hosting scene
  54988. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54989. * @returns a new node material
  54990. */
  54991. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54992. /**
  54993. * Creates a new node material set to default basic configuration
  54994. * @param name defines the name of the material
  54995. * @param scene defines the hosting scene
  54996. * @returns a new NodeMaterial
  54997. */
  54998. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54999. }
  55000. }
  55001. declare module BABYLON {
  55002. /**
  55003. * Block used to read a texture from a sampler
  55004. */
  55005. export class TextureBlock extends NodeMaterialBlock {
  55006. private _defineName;
  55007. private _linearDefineName;
  55008. private _tempTextureRead;
  55009. private _samplerName;
  55010. private _transformedUVName;
  55011. private _textureTransformName;
  55012. private _textureInfoName;
  55013. private _mainUVName;
  55014. private _mainUVDefineName;
  55015. /**
  55016. * Gets or sets the texture associated with the node
  55017. */
  55018. texture: Nullable<Texture>;
  55019. /**
  55020. * Create a new TextureBlock
  55021. * @param name defines the block name
  55022. */
  55023. constructor(name: string);
  55024. /**
  55025. * Gets the current class name
  55026. * @returns the class name
  55027. */
  55028. getClassName(): string;
  55029. /**
  55030. * Gets the uv input component
  55031. */
  55032. readonly uv: NodeMaterialConnectionPoint;
  55033. /**
  55034. * Gets the rgba output component
  55035. */
  55036. readonly rgba: NodeMaterialConnectionPoint;
  55037. /**
  55038. * Gets the rgb output component
  55039. */
  55040. readonly rgb: NodeMaterialConnectionPoint;
  55041. /**
  55042. * Gets the r output component
  55043. */
  55044. readonly r: NodeMaterialConnectionPoint;
  55045. /**
  55046. * Gets the g output component
  55047. */
  55048. readonly g: NodeMaterialConnectionPoint;
  55049. /**
  55050. * Gets the b output component
  55051. */
  55052. readonly b: NodeMaterialConnectionPoint;
  55053. /**
  55054. * Gets the a output component
  55055. */
  55056. readonly a: NodeMaterialConnectionPoint;
  55057. readonly target: NodeMaterialBlockTargets;
  55058. autoConfigure(material: NodeMaterial): void;
  55059. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55060. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55061. private _getTextureBase;
  55062. isReady(): boolean;
  55063. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55064. private readonly _isMixed;
  55065. private _injectVertexCode;
  55066. private _writeTextureRead;
  55067. private _writeOutput;
  55068. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55069. protected _dumpPropertiesCode(): string;
  55070. serialize(): any;
  55071. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55072. }
  55073. }
  55074. declare module BABYLON {
  55075. /**
  55076. * Class used to store shared data between 2 NodeMaterialBuildState
  55077. */
  55078. export class NodeMaterialBuildStateSharedData {
  55079. /**
  55080. * Gets the list of emitted varyings
  55081. */
  55082. temps: string[];
  55083. /**
  55084. * Gets the list of emitted varyings
  55085. */
  55086. varyings: string[];
  55087. /**
  55088. * Gets the varying declaration string
  55089. */
  55090. varyingDeclaration: string;
  55091. /**
  55092. * Input blocks
  55093. */
  55094. inputBlocks: InputBlock[];
  55095. /**
  55096. * Input blocks
  55097. */
  55098. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55099. /**
  55100. * Bindable blocks (Blocks that need to set data to the effect)
  55101. */
  55102. bindableBlocks: NodeMaterialBlock[];
  55103. /**
  55104. * List of blocks that can provide a compilation fallback
  55105. */
  55106. blocksWithFallbacks: NodeMaterialBlock[];
  55107. /**
  55108. * List of blocks that can provide a define update
  55109. */
  55110. blocksWithDefines: NodeMaterialBlock[];
  55111. /**
  55112. * List of blocks that can provide a repeatable content
  55113. */
  55114. repeatableContentBlocks: NodeMaterialBlock[];
  55115. /**
  55116. * List of blocks that can provide a dynamic list of uniforms
  55117. */
  55118. dynamicUniformBlocks: NodeMaterialBlock[];
  55119. /**
  55120. * List of blocks that can block the isReady function for the material
  55121. */
  55122. blockingBlocks: NodeMaterialBlock[];
  55123. /**
  55124. * Gets the list of animated inputs
  55125. */
  55126. animatedInputs: InputBlock[];
  55127. /**
  55128. * Build Id used to avoid multiple recompilations
  55129. */
  55130. buildId: number;
  55131. /** List of emitted variables */
  55132. variableNames: {
  55133. [key: string]: number;
  55134. };
  55135. /** List of emitted defines */
  55136. defineNames: {
  55137. [key: string]: number;
  55138. };
  55139. /** Should emit comments? */
  55140. emitComments: boolean;
  55141. /** Emit build activity */
  55142. verbose: boolean;
  55143. /** Gets or sets the hosting scene */
  55144. scene: Scene;
  55145. /**
  55146. * Gets the compilation hints emitted at compilation time
  55147. */
  55148. hints: {
  55149. needWorldViewMatrix: boolean;
  55150. needWorldViewProjectionMatrix: boolean;
  55151. needAlphaBlending: boolean;
  55152. needAlphaTesting: boolean;
  55153. };
  55154. /**
  55155. * List of compilation checks
  55156. */
  55157. checks: {
  55158. emitVertex: boolean;
  55159. emitFragment: boolean;
  55160. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55161. };
  55162. /** Creates a new shared data */
  55163. constructor();
  55164. /**
  55165. * Emits console errors and exceptions if there is a failing check
  55166. */
  55167. emitErrors(): void;
  55168. }
  55169. }
  55170. declare module BABYLON {
  55171. /**
  55172. * Class used to store node based material build state
  55173. */
  55174. export class NodeMaterialBuildState {
  55175. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55176. supportUniformBuffers: boolean;
  55177. /**
  55178. * Gets the list of emitted attributes
  55179. */
  55180. attributes: string[];
  55181. /**
  55182. * Gets the list of emitted uniforms
  55183. */
  55184. uniforms: string[];
  55185. /**
  55186. * Gets the list of emitted constants
  55187. */
  55188. constants: string[];
  55189. /**
  55190. * Gets the list of emitted samplers
  55191. */
  55192. samplers: string[];
  55193. /**
  55194. * Gets the list of emitted functions
  55195. */
  55196. functions: {
  55197. [key: string]: string;
  55198. };
  55199. /**
  55200. * Gets the list of emitted extensions
  55201. */
  55202. extensions: {
  55203. [key: string]: string;
  55204. };
  55205. /**
  55206. * Gets the target of the compilation state
  55207. */
  55208. target: NodeMaterialBlockTargets;
  55209. /**
  55210. * Gets the list of emitted counters
  55211. */
  55212. counters: {
  55213. [key: string]: number;
  55214. };
  55215. /**
  55216. * Shared data between multiple NodeMaterialBuildState instances
  55217. */
  55218. sharedData: NodeMaterialBuildStateSharedData;
  55219. /** @hidden */
  55220. _vertexState: NodeMaterialBuildState;
  55221. /** @hidden */
  55222. _attributeDeclaration: string;
  55223. /** @hidden */
  55224. _uniformDeclaration: string;
  55225. /** @hidden */
  55226. _constantDeclaration: string;
  55227. /** @hidden */
  55228. _samplerDeclaration: string;
  55229. /** @hidden */
  55230. _varyingTransfer: string;
  55231. private _repeatableContentAnchorIndex;
  55232. /** @hidden */
  55233. _builtCompilationString: string;
  55234. /**
  55235. * Gets the emitted compilation strings
  55236. */
  55237. compilationString: string;
  55238. /**
  55239. * Finalize the compilation strings
  55240. * @param state defines the current compilation state
  55241. */
  55242. finalize(state: NodeMaterialBuildState): void;
  55243. /** @hidden */
  55244. readonly _repeatableContentAnchor: string;
  55245. /** @hidden */
  55246. _getFreeVariableName(prefix: string): string;
  55247. /** @hidden */
  55248. _getFreeDefineName(prefix: string): string;
  55249. /** @hidden */
  55250. _excludeVariableName(name: string): void;
  55251. /** @hidden */
  55252. _emit2DSampler(name: string): void;
  55253. /** @hidden */
  55254. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55255. /** @hidden */
  55256. _emitExtension(name: string, extension: string): void;
  55257. /** @hidden */
  55258. _emitFunction(name: string, code: string, comments: string): void;
  55259. /** @hidden */
  55260. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55261. replaceStrings?: {
  55262. search: RegExp;
  55263. replace: string;
  55264. }[];
  55265. repeatKey?: string;
  55266. }): string;
  55267. /** @hidden */
  55268. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55269. repeatKey?: string;
  55270. removeAttributes?: boolean;
  55271. removeUniforms?: boolean;
  55272. removeVaryings?: boolean;
  55273. removeIfDef?: boolean;
  55274. replaceStrings?: {
  55275. search: RegExp;
  55276. replace: string;
  55277. }[];
  55278. }, storeKey?: string): void;
  55279. /** @hidden */
  55280. _registerTempVariable(name: string): boolean;
  55281. /** @hidden */
  55282. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55283. /** @hidden */
  55284. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55285. /** @hidden */
  55286. _emitFloat(value: number): string;
  55287. }
  55288. }
  55289. declare module BABYLON {
  55290. /**
  55291. * Defines a block that can be used inside a node based material
  55292. */
  55293. export class NodeMaterialBlock {
  55294. private _buildId;
  55295. private _buildTarget;
  55296. private _target;
  55297. private _isFinalMerger;
  55298. private _isInput;
  55299. protected _isUnique: boolean;
  55300. /** @hidden */
  55301. _codeVariableName: string;
  55302. /** @hidden */
  55303. _inputs: NodeMaterialConnectionPoint[];
  55304. /** @hidden */
  55305. _outputs: NodeMaterialConnectionPoint[];
  55306. /** @hidden */
  55307. _preparationId: number;
  55308. /**
  55309. * Gets or sets the name of the block
  55310. */
  55311. name: string;
  55312. /**
  55313. * Gets or sets the unique id of the node
  55314. */
  55315. uniqueId: number;
  55316. /**
  55317. * Gets or sets the comments associated with this block
  55318. */
  55319. comments: string;
  55320. /**
  55321. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  55322. */
  55323. readonly isUnique: boolean;
  55324. /**
  55325. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55326. */
  55327. readonly isFinalMerger: boolean;
  55328. /**
  55329. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55330. */
  55331. readonly isInput: boolean;
  55332. /**
  55333. * Gets or sets the build Id
  55334. */
  55335. buildId: number;
  55336. /**
  55337. * Gets or sets the target of the block
  55338. */
  55339. target: NodeMaterialBlockTargets;
  55340. /**
  55341. * Gets the list of input points
  55342. */
  55343. readonly inputs: NodeMaterialConnectionPoint[];
  55344. /** Gets the list of output points */
  55345. readonly outputs: NodeMaterialConnectionPoint[];
  55346. /**
  55347. * Find an input by its name
  55348. * @param name defines the name of the input to look for
  55349. * @returns the input or null if not found
  55350. */
  55351. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55352. /**
  55353. * Find an output by its name
  55354. * @param name defines the name of the outputto look for
  55355. * @returns the output or null if not found
  55356. */
  55357. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55358. /**
  55359. * Creates a new NodeMaterialBlock
  55360. * @param name defines the block name
  55361. * @param target defines the target of that block (Vertex by default)
  55362. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55363. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55364. */
  55365. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55366. /**
  55367. * Initialize the block and prepare the context for build
  55368. * @param state defines the state that will be used for the build
  55369. */
  55370. initialize(state: NodeMaterialBuildState): void;
  55371. /**
  55372. * Bind data to effect. Will only be called for blocks with isBindable === true
  55373. * @param effect defines the effect to bind data to
  55374. * @param nodeMaterial defines the hosting NodeMaterial
  55375. * @param mesh defines the mesh that will be rendered
  55376. */
  55377. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55378. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55379. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55380. protected _writeFloat(value: number): string;
  55381. /**
  55382. * Gets the current class name e.g. "NodeMaterialBlock"
  55383. * @returns the class name
  55384. */
  55385. getClassName(): string;
  55386. /**
  55387. * Register a new input. Must be called inside a block constructor
  55388. * @param name defines the connection point name
  55389. * @param type defines the connection point type
  55390. * @param isOptional defines a boolean indicating that this input can be omitted
  55391. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55392. * @returns the current block
  55393. */
  55394. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55395. /**
  55396. * Register a new output. Must be called inside a block constructor
  55397. * @param name defines the connection point name
  55398. * @param type defines the connection point type
  55399. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55400. * @returns the current block
  55401. */
  55402. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55403. /**
  55404. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55405. * @param forOutput defines an optional connection point to check compatibility with
  55406. * @returns the first available input or null
  55407. */
  55408. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55409. /**
  55410. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55411. * @param forBlock defines an optional block to check compatibility with
  55412. * @returns the first available input or null
  55413. */
  55414. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55415. /**
  55416. * Gets the sibling of the given output
  55417. * @param current defines the current output
  55418. * @returns the next output in the list or null
  55419. */
  55420. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55421. /**
  55422. * Connect current block with another block
  55423. * @param other defines the block to connect with
  55424. * @param options define the various options to help pick the right connections
  55425. * @returns the current block
  55426. */
  55427. connectTo(other: NodeMaterialBlock, options?: {
  55428. input?: string;
  55429. output?: string;
  55430. outputSwizzle?: string;
  55431. }): this | undefined;
  55432. protected _buildBlock(state: NodeMaterialBuildState): void;
  55433. /**
  55434. * Add uniforms, samplers and uniform buffers at compilation time
  55435. * @param state defines the state to update
  55436. * @param nodeMaterial defines the node material requesting the update
  55437. * @param defines defines the material defines to update
  55438. * @param uniformBuffers defines the list of uniform buffer names
  55439. */
  55440. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  55441. /**
  55442. * Add potential fallbacks if shader compilation fails
  55443. * @param mesh defines the mesh to be rendered
  55444. * @param fallbacks defines the current prioritized list of fallbacks
  55445. */
  55446. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55447. /**
  55448. * Initialize defines for shader compilation
  55449. * @param mesh defines the mesh to be rendered
  55450. * @param nodeMaterial defines the node material requesting the update
  55451. * @param defines defines the material defines to update
  55452. * @param useInstances specifies that instances should be used
  55453. */
  55454. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55455. /**
  55456. * Update defines for shader compilation
  55457. * @param mesh defines the mesh to be rendered
  55458. * @param nodeMaterial defines the node material requesting the update
  55459. * @param defines defines the material defines to update
  55460. * @param useInstances specifies that instances should be used
  55461. */
  55462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55463. /**
  55464. * Lets the block try to connect some inputs automatically
  55465. * @param material defines the hosting NodeMaterial
  55466. */
  55467. autoConfigure(material: NodeMaterial): void;
  55468. /**
  55469. * Function called when a block is declared as repeatable content generator
  55470. * @param vertexShaderState defines the current compilation state for the vertex shader
  55471. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55472. * @param mesh defines the mesh to be rendered
  55473. * @param defines defines the material defines to update
  55474. */
  55475. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55476. /**
  55477. * Checks if the block is ready
  55478. * @param mesh defines the mesh to be rendered
  55479. * @param nodeMaterial defines the node material requesting the update
  55480. * @param defines defines the material defines to update
  55481. * @param useInstances specifies that instances should be used
  55482. * @returns true if the block is ready
  55483. */
  55484. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55485. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55486. private _processBuild;
  55487. /**
  55488. * Compile the current node and generate the shader code
  55489. * @param state defines the current compilation state (uniforms, samplers, current string)
  55490. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55491. * @returns true if already built
  55492. */
  55493. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55494. protected _inputRename(name: string): string;
  55495. protected _outputRename(name: string): string;
  55496. protected _dumpPropertiesCode(): string;
  55497. /** @hidden */
  55498. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55499. /** @hidden */
  55500. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  55501. /**
  55502. * Clone the current block to a new identical block
  55503. * @param scene defines the hosting scene
  55504. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55505. * @returns a copy of the current block
  55506. */
  55507. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55508. /**
  55509. * Serializes this block in a JSON representation
  55510. * @returns the serialized block object
  55511. */
  55512. serialize(): any;
  55513. /** @hidden */
  55514. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55515. /**
  55516. * Release resources
  55517. */
  55518. dispose(): void;
  55519. }
  55520. }
  55521. declare module BABYLON {
  55522. /**
  55523. * Enum defining the type of animations supported by InputBlock
  55524. */
  55525. export enum AnimatedInputBlockTypes {
  55526. /** No animation */
  55527. None = 0,
  55528. /** Time based animation. Will only work for floats */
  55529. Time = 1
  55530. }
  55531. }
  55532. declare module BABYLON {
  55533. /**
  55534. * Block used to expose an input value
  55535. */
  55536. export class InputBlock extends NodeMaterialBlock {
  55537. private _mode;
  55538. private _associatedVariableName;
  55539. private _storedValue;
  55540. private _valueCallback;
  55541. private _type;
  55542. private _animationType;
  55543. /** Gets or set a value used to limit the range of float values */
  55544. min: number;
  55545. /** Gets or set a value used to limit the range of float values */
  55546. max: number;
  55547. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  55548. matrixMode: number;
  55549. /** @hidden */
  55550. _systemValue: Nullable<NodeMaterialSystemValues>;
  55551. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55552. visibleInInspector: boolean;
  55553. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  55554. isConstant: boolean;
  55555. /** Gets or sets the group to use to display this block in the Inspector */
  55556. groupInInspector: string;
  55557. /**
  55558. * Gets or sets the connection point type (default is float)
  55559. */
  55560. readonly type: NodeMaterialBlockConnectionPointTypes;
  55561. /**
  55562. * Creates a new InputBlock
  55563. * @param name defines the block name
  55564. * @param target defines the target of that block (Vertex by default)
  55565. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55566. */
  55567. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55568. /**
  55569. * Gets the output component
  55570. */
  55571. readonly output: NodeMaterialConnectionPoint;
  55572. /**
  55573. * Set the source of this connection point to a vertex attribute
  55574. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55575. * @returns the current connection point
  55576. */
  55577. setAsAttribute(attributeName?: string): InputBlock;
  55578. /**
  55579. * Set the source of this connection point to a system value
  55580. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55581. * @returns the current connection point
  55582. */
  55583. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55584. /**
  55585. * Gets or sets the value of that point.
  55586. * Please note that this value will be ignored if valueCallback is defined
  55587. */
  55588. value: any;
  55589. /**
  55590. * Gets or sets a callback used to get the value of that point.
  55591. * Please note that setting this value will force the connection point to ignore the value property
  55592. */
  55593. valueCallback: () => any;
  55594. /**
  55595. * Gets or sets the associated variable name in the shader
  55596. */
  55597. associatedVariableName: string;
  55598. /** Gets or sets the type of animation applied to the input */
  55599. animationType: AnimatedInputBlockTypes;
  55600. /**
  55601. * Gets a boolean indicating that this connection point not defined yet
  55602. */
  55603. readonly isUndefined: boolean;
  55604. /**
  55605. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55606. * In this case the connection point name must be the name of the uniform to use.
  55607. * Can only be set on inputs
  55608. */
  55609. isUniform: boolean;
  55610. /**
  55611. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55612. * In this case the connection point name must be the name of the attribute to use
  55613. * Can only be set on inputs
  55614. */
  55615. isAttribute: boolean;
  55616. /**
  55617. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55618. * Can only be set on exit points
  55619. */
  55620. isVarying: boolean;
  55621. /**
  55622. * Gets a boolean indicating that the current connection point is a system value
  55623. */
  55624. readonly isSystemValue: boolean;
  55625. /**
  55626. * Gets or sets the current well known value or null if not defined as a system value
  55627. */
  55628. systemValue: Nullable<NodeMaterialSystemValues>;
  55629. /**
  55630. * Gets the current class name
  55631. * @returns the class name
  55632. */
  55633. getClassName(): string;
  55634. /**
  55635. * Animate the input if animationType !== None
  55636. * @param scene defines the rendering scene
  55637. */
  55638. animate(scene: Scene): void;
  55639. private _emitDefine;
  55640. initialize(state: NodeMaterialBuildState): void;
  55641. /**
  55642. * Set the input block to its default value (based on its type)
  55643. */
  55644. setDefaultValue(): void;
  55645. private _emitConstant;
  55646. private _emit;
  55647. /** @hidden */
  55648. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55649. /** @hidden */
  55650. _transmit(effect: Effect, scene: Scene): void;
  55651. protected _buildBlock(state: NodeMaterialBuildState): void;
  55652. protected _dumpPropertiesCode(): string;
  55653. serialize(): any;
  55654. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55655. }
  55656. }
  55657. declare module BABYLON {
  55658. /**
  55659. * Enum used to define the compatibility state between two connection points
  55660. */
  55661. export enum NodeMaterialConnectionPointCompatibilityStates {
  55662. /** Points are compatibles */
  55663. Compatible = 0,
  55664. /** Points are incompatible because of their types */
  55665. TypeIncompatible = 1,
  55666. /** Points are incompatible because of their targets (vertex vs fragment) */
  55667. TargetIncompatible = 2
  55668. }
  55669. /**
  55670. * Defines the direction of a connection point
  55671. */
  55672. export enum NodeMaterialConnectionPointDirection {
  55673. /** Input */
  55674. Input = 0,
  55675. /** Output */
  55676. Output = 1
  55677. }
  55678. /**
  55679. * Defines a connection point for a block
  55680. */
  55681. export class NodeMaterialConnectionPoint {
  55682. /** @hidden */
  55683. _ownerBlock: NodeMaterialBlock;
  55684. /** @hidden */
  55685. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55686. private _endpoints;
  55687. private _associatedVariableName;
  55688. private _direction;
  55689. /** @hidden */
  55690. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55691. /** @hidden */
  55692. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55693. private _type;
  55694. /** @hidden */
  55695. _enforceAssociatedVariableName: boolean;
  55696. /** Gets the direction of the point */
  55697. readonly direction: NodeMaterialConnectionPointDirection;
  55698. /**
  55699. * Gets or sets the additional types supported by this connection point
  55700. */
  55701. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55702. /**
  55703. * Gets or sets the additional types excluded by this connection point
  55704. */
  55705. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55706. /**
  55707. * Observable triggered when this point is connected
  55708. */
  55709. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  55710. /**
  55711. * Gets or sets the associated variable name in the shader
  55712. */
  55713. associatedVariableName: string;
  55714. /**
  55715. * Gets or sets the connection point type (default is float)
  55716. */
  55717. type: NodeMaterialBlockConnectionPointTypes;
  55718. /**
  55719. * Gets or sets the connection point name
  55720. */
  55721. name: string;
  55722. /**
  55723. * Gets or sets a boolean indicating that this connection point can be omitted
  55724. */
  55725. isOptional: boolean;
  55726. /**
  55727. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55728. */
  55729. define: string;
  55730. /** @hidden */
  55731. _prioritizeVertex: boolean;
  55732. private _target;
  55733. /** Gets or sets the target of that connection point */
  55734. target: NodeMaterialBlockTargets;
  55735. /**
  55736. * Gets a boolean indicating that the current point is connected
  55737. */
  55738. readonly isConnected: boolean;
  55739. /**
  55740. * Gets a boolean indicating that the current point is connected to an input block
  55741. */
  55742. readonly isConnectedToInputBlock: boolean;
  55743. /**
  55744. * Gets a the connected input block (if any)
  55745. */
  55746. readonly connectInputBlock: Nullable<InputBlock>;
  55747. /** Get the other side of the connection (if any) */
  55748. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55749. /** Get the block that owns this connection point */
  55750. readonly ownerBlock: NodeMaterialBlock;
  55751. /** Get the block connected on the other side of this connection (if any) */
  55752. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55753. /** Get the block connected on the endpoints of this connection (if any) */
  55754. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55755. /** Gets the list of connected endpoints */
  55756. readonly endpoints: NodeMaterialConnectionPoint[];
  55757. /** Gets a boolean indicating if that output point is connected to at least one input */
  55758. readonly hasEndpoints: boolean;
  55759. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  55760. readonly isConnectedInVertexShader: boolean;
  55761. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  55762. readonly isConnectedInFragmentShader: boolean;
  55763. /**
  55764. * Creates a new connection point
  55765. * @param name defines the connection point name
  55766. * @param ownerBlock defines the block hosting this connection point
  55767. * @param direction defines the direction of the connection point
  55768. */
  55769. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  55770. /**
  55771. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55772. * @returns the class name
  55773. */
  55774. getClassName(): string;
  55775. /**
  55776. * Gets a boolean indicating if the current point can be connected to another point
  55777. * @param connectionPoint defines the other connection point
  55778. * @returns a boolean
  55779. */
  55780. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55781. /**
  55782. * Gets a number indicating if the current point can be connected to another point
  55783. * @param connectionPoint defines the other connection point
  55784. * @returns a number defining the compatibility state
  55785. */
  55786. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  55787. /**
  55788. * Connect this point to another connection point
  55789. * @param connectionPoint defines the other connection point
  55790. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55791. * @returns the current connection point
  55792. */
  55793. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55794. /**
  55795. * Disconnect this point from one of his endpoint
  55796. * @param endpoint defines the other connection point
  55797. * @returns the current connection point
  55798. */
  55799. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55800. /**
  55801. * Serializes this point in a JSON representation
  55802. * @returns the serialized point object
  55803. */
  55804. serialize(): any;
  55805. /**
  55806. * Release resources
  55807. */
  55808. dispose(): void;
  55809. }
  55810. }
  55811. declare module BABYLON {
  55812. /**
  55813. * Block used to add support for vertex skinning (bones)
  55814. */
  55815. export class BonesBlock extends NodeMaterialBlock {
  55816. /**
  55817. * Creates a new BonesBlock
  55818. * @param name defines the block name
  55819. */
  55820. constructor(name: string);
  55821. /**
  55822. * Initialize the block and prepare the context for build
  55823. * @param state defines the state that will be used for the build
  55824. */
  55825. initialize(state: NodeMaterialBuildState): void;
  55826. /**
  55827. * Gets the current class name
  55828. * @returns the class name
  55829. */
  55830. getClassName(): string;
  55831. /**
  55832. * Gets the matrix indices input component
  55833. */
  55834. readonly matricesIndices: NodeMaterialConnectionPoint;
  55835. /**
  55836. * Gets the matrix weights input component
  55837. */
  55838. readonly matricesWeights: NodeMaterialConnectionPoint;
  55839. /**
  55840. * Gets the extra matrix indices input component
  55841. */
  55842. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55843. /**
  55844. * Gets the extra matrix weights input component
  55845. */
  55846. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55847. /**
  55848. * Gets the world input component
  55849. */
  55850. readonly world: NodeMaterialConnectionPoint;
  55851. /**
  55852. * Gets the output component
  55853. */
  55854. readonly output: NodeMaterialConnectionPoint;
  55855. autoConfigure(material: NodeMaterial): void;
  55856. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55857. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55858. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55859. protected _buildBlock(state: NodeMaterialBuildState): this;
  55860. }
  55861. }
  55862. declare module BABYLON {
  55863. /**
  55864. * Block used to add support for instances
  55865. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55866. */
  55867. export class InstancesBlock extends NodeMaterialBlock {
  55868. /**
  55869. * Creates a new InstancesBlock
  55870. * @param name defines the block name
  55871. */
  55872. constructor(name: string);
  55873. /**
  55874. * Gets the current class name
  55875. * @returns the class name
  55876. */
  55877. getClassName(): string;
  55878. /**
  55879. * Gets the first world row input component
  55880. */
  55881. readonly world0: NodeMaterialConnectionPoint;
  55882. /**
  55883. * Gets the second world row input component
  55884. */
  55885. readonly world1: NodeMaterialConnectionPoint;
  55886. /**
  55887. * Gets the third world row input component
  55888. */
  55889. readonly world2: NodeMaterialConnectionPoint;
  55890. /**
  55891. * Gets the forth world row input component
  55892. */
  55893. readonly world3: NodeMaterialConnectionPoint;
  55894. /**
  55895. * Gets the world input component
  55896. */
  55897. readonly world: NodeMaterialConnectionPoint;
  55898. /**
  55899. * Gets the output component
  55900. */
  55901. readonly output: NodeMaterialConnectionPoint;
  55902. autoConfigure(material: NodeMaterial): void;
  55903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55904. protected _buildBlock(state: NodeMaterialBuildState): this;
  55905. }
  55906. }
  55907. declare module BABYLON {
  55908. /**
  55909. * Block used to add morph targets support to vertex shader
  55910. */
  55911. export class MorphTargetsBlock extends NodeMaterialBlock {
  55912. private _repeatableContentAnchor;
  55913. private _repeatebleContentGenerated;
  55914. /**
  55915. * Create a new MorphTargetsBlock
  55916. * @param name defines the block name
  55917. */
  55918. constructor(name: string);
  55919. /**
  55920. * Gets the current class name
  55921. * @returns the class name
  55922. */
  55923. getClassName(): string;
  55924. /**
  55925. * Gets the position input component
  55926. */
  55927. readonly position: NodeMaterialConnectionPoint;
  55928. /**
  55929. * Gets the normal input component
  55930. */
  55931. readonly normal: NodeMaterialConnectionPoint;
  55932. /**
  55933. * Gets the tangent input component
  55934. */
  55935. readonly tangent: NodeMaterialConnectionPoint;
  55936. /**
  55937. * Gets the tangent input component
  55938. */
  55939. readonly uv: NodeMaterialConnectionPoint;
  55940. /**
  55941. * Gets the position output component
  55942. */
  55943. readonly positionOutput: NodeMaterialConnectionPoint;
  55944. /**
  55945. * Gets the normal output component
  55946. */
  55947. readonly normalOutput: NodeMaterialConnectionPoint;
  55948. /**
  55949. * Gets the tangent output component
  55950. */
  55951. readonly tangentOutput: NodeMaterialConnectionPoint;
  55952. /**
  55953. * Gets the tangent output component
  55954. */
  55955. readonly uvOutput: NodeMaterialConnectionPoint;
  55956. initialize(state: NodeMaterialBuildState): void;
  55957. autoConfigure(material: NodeMaterial): void;
  55958. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55959. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55960. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55961. protected _buildBlock(state: NodeMaterialBuildState): this;
  55962. }
  55963. }
  55964. declare module BABYLON {
  55965. /**
  55966. * Block used to get data information from a light
  55967. */
  55968. export class LightInformationBlock extends NodeMaterialBlock {
  55969. private _lightDataUniformName;
  55970. private _lightColorUniformName;
  55971. private _lightTypeDefineName;
  55972. /**
  55973. * Gets or sets the light associated with this block
  55974. */
  55975. light: Nullable<Light>;
  55976. /**
  55977. * Creates a new LightInformationBlock
  55978. * @param name defines the block name
  55979. */
  55980. constructor(name: string);
  55981. /**
  55982. * Gets the current class name
  55983. * @returns the class name
  55984. */
  55985. getClassName(): string;
  55986. /**
  55987. * Gets the world position input component
  55988. */
  55989. readonly worldPosition: NodeMaterialConnectionPoint;
  55990. /**
  55991. * Gets the direction output component
  55992. */
  55993. readonly direction: NodeMaterialConnectionPoint;
  55994. /**
  55995. * Gets the direction output component
  55996. */
  55997. readonly color: NodeMaterialConnectionPoint;
  55998. /**
  55999. * Gets the direction output component
  56000. */
  56001. readonly intensity: NodeMaterialConnectionPoint;
  56002. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56003. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56004. protected _buildBlock(state: NodeMaterialBuildState): this;
  56005. serialize(): any;
  56006. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56007. }
  56008. }
  56009. declare module BABYLON {
  56010. /**
  56011. * Block used to add image processing support to fragment shader
  56012. */
  56013. export class ImageProcessingBlock extends NodeMaterialBlock {
  56014. /**
  56015. * Create a new ImageProcessingBlock
  56016. * @param name defines the block name
  56017. */
  56018. constructor(name: string);
  56019. /**
  56020. * Gets the current class name
  56021. * @returns the class name
  56022. */
  56023. getClassName(): string;
  56024. /**
  56025. * Gets the color input component
  56026. */
  56027. readonly color: NodeMaterialConnectionPoint;
  56028. /**
  56029. * Gets the output component
  56030. */
  56031. readonly output: NodeMaterialConnectionPoint;
  56032. /**
  56033. * Initialize the block and prepare the context for build
  56034. * @param state defines the state that will be used for the build
  56035. */
  56036. initialize(state: NodeMaterialBuildState): void;
  56037. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56038. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56039. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56040. protected _buildBlock(state: NodeMaterialBuildState): this;
  56041. }
  56042. }
  56043. declare module BABYLON {
  56044. /**
  56045. * Block used to pertub normals based on a normal map
  56046. */
  56047. export class PerturbNormalBlock extends NodeMaterialBlock {
  56048. private _tangentSpaceParameterName;
  56049. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56050. invertX: boolean;
  56051. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56052. invertY: boolean;
  56053. /**
  56054. * Create a new PerturbNormalBlock
  56055. * @param name defines the block name
  56056. */
  56057. constructor(name: string);
  56058. /**
  56059. * Gets the current class name
  56060. * @returns the class name
  56061. */
  56062. getClassName(): string;
  56063. /**
  56064. * Gets the world position input component
  56065. */
  56066. readonly worldPosition: NodeMaterialConnectionPoint;
  56067. /**
  56068. * Gets the world normal input component
  56069. */
  56070. readonly worldNormal: NodeMaterialConnectionPoint;
  56071. /**
  56072. * Gets the uv input component
  56073. */
  56074. readonly uv: NodeMaterialConnectionPoint;
  56075. /**
  56076. * Gets the normal map color input component
  56077. */
  56078. readonly normalMapColor: NodeMaterialConnectionPoint;
  56079. /**
  56080. * Gets the strength input component
  56081. */
  56082. readonly strength: NodeMaterialConnectionPoint;
  56083. /**
  56084. * Gets the output component
  56085. */
  56086. readonly output: NodeMaterialConnectionPoint;
  56087. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56088. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56089. autoConfigure(material: NodeMaterial): void;
  56090. protected _buildBlock(state: NodeMaterialBuildState): this;
  56091. protected _dumpPropertiesCode(): string;
  56092. serialize(): any;
  56093. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56094. }
  56095. }
  56096. declare module BABYLON {
  56097. /**
  56098. * Block used to discard a pixel if a value is smaller than a cutoff
  56099. */
  56100. export class DiscardBlock extends NodeMaterialBlock {
  56101. /**
  56102. * Create a new DiscardBlock
  56103. * @param name defines the block name
  56104. */
  56105. constructor(name: string);
  56106. /**
  56107. * Gets the current class name
  56108. * @returns the class name
  56109. */
  56110. getClassName(): string;
  56111. /**
  56112. * Gets the color input component
  56113. */
  56114. readonly value: NodeMaterialConnectionPoint;
  56115. /**
  56116. * Gets the cutoff input component
  56117. */
  56118. readonly cutoff: NodeMaterialConnectionPoint;
  56119. protected _buildBlock(state: NodeMaterialBuildState): this;
  56120. }
  56121. }
  56122. declare module BABYLON {
  56123. /**
  56124. * Block used to test if the fragment shader is front facing
  56125. */
  56126. export class FrontFacingBlock extends NodeMaterialBlock {
  56127. /**
  56128. * Creates a new FrontFacingBlock
  56129. * @param name defines the block name
  56130. */
  56131. constructor(name: string);
  56132. /**
  56133. * Gets the current class name
  56134. * @returns the class name
  56135. */
  56136. getClassName(): string;
  56137. /**
  56138. * Gets the output component
  56139. */
  56140. readonly output: NodeMaterialConnectionPoint;
  56141. protected _buildBlock(state: NodeMaterialBuildState): this;
  56142. }
  56143. }
  56144. declare module BABYLON {
  56145. /**
  56146. * Block used to get the derivative value on x and y of a given input
  56147. */
  56148. export class DerivativeBlock extends NodeMaterialBlock {
  56149. /**
  56150. * Create a new DerivativeBlock
  56151. * @param name defines the block name
  56152. */
  56153. constructor(name: string);
  56154. /**
  56155. * Gets the current class name
  56156. * @returns the class name
  56157. */
  56158. getClassName(): string;
  56159. /**
  56160. * Gets the input component
  56161. */
  56162. readonly input: NodeMaterialConnectionPoint;
  56163. /**
  56164. * Gets the derivative output on x
  56165. */
  56166. readonly dx: NodeMaterialConnectionPoint;
  56167. /**
  56168. * Gets the derivative output on y
  56169. */
  56170. readonly dy: NodeMaterialConnectionPoint;
  56171. protected _buildBlock(state: NodeMaterialBuildState): this;
  56172. }
  56173. }
  56174. declare module BABYLON {
  56175. /**
  56176. * Block used to add support for scene fog
  56177. */
  56178. export class FogBlock extends NodeMaterialBlock {
  56179. private _fogDistanceName;
  56180. private _fogParameters;
  56181. /**
  56182. * Create a new FogBlock
  56183. * @param name defines the block name
  56184. */
  56185. constructor(name: string);
  56186. /**
  56187. * Gets the current class name
  56188. * @returns the class name
  56189. */
  56190. getClassName(): string;
  56191. /**
  56192. * Gets the world position input component
  56193. */
  56194. readonly worldPosition: NodeMaterialConnectionPoint;
  56195. /**
  56196. * Gets the view input component
  56197. */
  56198. readonly view: NodeMaterialConnectionPoint;
  56199. /**
  56200. * Gets the color input component
  56201. */
  56202. readonly input: NodeMaterialConnectionPoint;
  56203. /**
  56204. * Gets the fog color input component
  56205. */
  56206. readonly fogColor: NodeMaterialConnectionPoint;
  56207. /**
  56208. * Gets the output component
  56209. */
  56210. readonly output: NodeMaterialConnectionPoint;
  56211. autoConfigure(material: NodeMaterial): void;
  56212. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56213. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56214. protected _buildBlock(state: NodeMaterialBuildState): this;
  56215. }
  56216. }
  56217. declare module BABYLON {
  56218. /**
  56219. * Block used to add light in the fragment shader
  56220. */
  56221. export class LightBlock extends NodeMaterialBlock {
  56222. private _lightId;
  56223. /**
  56224. * Gets or sets the light associated with this block
  56225. */
  56226. light: Nullable<Light>;
  56227. /**
  56228. * Create a new LightBlock
  56229. * @param name defines the block name
  56230. */
  56231. constructor(name: string);
  56232. /**
  56233. * Gets the current class name
  56234. * @returns the class name
  56235. */
  56236. getClassName(): string;
  56237. /**
  56238. * Gets the world position input component
  56239. */
  56240. readonly worldPosition: NodeMaterialConnectionPoint;
  56241. /**
  56242. * Gets the world normal input component
  56243. */
  56244. readonly worldNormal: NodeMaterialConnectionPoint;
  56245. /**
  56246. * Gets the camera (or eye) position component
  56247. */
  56248. readonly cameraPosition: NodeMaterialConnectionPoint;
  56249. /**
  56250. * Gets the glossiness component
  56251. */
  56252. readonly glossiness: NodeMaterialConnectionPoint;
  56253. /**
  56254. * Gets the glossinness power component
  56255. */
  56256. readonly glossPower: NodeMaterialConnectionPoint;
  56257. /**
  56258. * Gets the diffuse color component
  56259. */
  56260. readonly diffuseColor: NodeMaterialConnectionPoint;
  56261. /**
  56262. * Gets the specular color component
  56263. */
  56264. readonly specularColor: NodeMaterialConnectionPoint;
  56265. /**
  56266. * Gets the diffuse output component
  56267. */
  56268. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56269. /**
  56270. * Gets the specular output component
  56271. */
  56272. readonly specularOutput: NodeMaterialConnectionPoint;
  56273. autoConfigure(material: NodeMaterial): void;
  56274. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56275. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56276. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56277. private _injectVertexCode;
  56278. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56279. serialize(): any;
  56280. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56281. }
  56282. }
  56283. declare module BABYLON {
  56284. /**
  56285. * Block used to multiply 2 values
  56286. */
  56287. export class MultiplyBlock extends NodeMaterialBlock {
  56288. /**
  56289. * Creates a new MultiplyBlock
  56290. * @param name defines the block name
  56291. */
  56292. constructor(name: string);
  56293. /**
  56294. * Gets the current class name
  56295. * @returns the class name
  56296. */
  56297. getClassName(): string;
  56298. /**
  56299. * Gets the left operand input component
  56300. */
  56301. readonly left: NodeMaterialConnectionPoint;
  56302. /**
  56303. * Gets the right operand input component
  56304. */
  56305. readonly right: NodeMaterialConnectionPoint;
  56306. /**
  56307. * Gets the output component
  56308. */
  56309. readonly output: NodeMaterialConnectionPoint;
  56310. protected _buildBlock(state: NodeMaterialBuildState): this;
  56311. }
  56312. }
  56313. declare module BABYLON {
  56314. /**
  56315. * Block used to add 2 vectors
  56316. */
  56317. export class AddBlock extends NodeMaterialBlock {
  56318. /**
  56319. * Creates a new AddBlock
  56320. * @param name defines the block name
  56321. */
  56322. constructor(name: string);
  56323. /**
  56324. * Gets the current class name
  56325. * @returns the class name
  56326. */
  56327. getClassName(): string;
  56328. /**
  56329. * Gets the left operand input component
  56330. */
  56331. readonly left: NodeMaterialConnectionPoint;
  56332. /**
  56333. * Gets the right operand input component
  56334. */
  56335. readonly right: NodeMaterialConnectionPoint;
  56336. /**
  56337. * Gets the output component
  56338. */
  56339. readonly output: NodeMaterialConnectionPoint;
  56340. protected _buildBlock(state: NodeMaterialBuildState): this;
  56341. }
  56342. }
  56343. declare module BABYLON {
  56344. /**
  56345. * Block used to scale a vector by a float
  56346. */
  56347. export class ScaleBlock extends NodeMaterialBlock {
  56348. /**
  56349. * Creates a new ScaleBlock
  56350. * @param name defines the block name
  56351. */
  56352. constructor(name: string);
  56353. /**
  56354. * Gets the current class name
  56355. * @returns the class name
  56356. */
  56357. getClassName(): string;
  56358. /**
  56359. * Gets the input component
  56360. */
  56361. readonly input: NodeMaterialConnectionPoint;
  56362. /**
  56363. * Gets the factor input component
  56364. */
  56365. readonly factor: NodeMaterialConnectionPoint;
  56366. /**
  56367. * Gets the output component
  56368. */
  56369. readonly output: NodeMaterialConnectionPoint;
  56370. protected _buildBlock(state: NodeMaterialBuildState): this;
  56371. }
  56372. }
  56373. declare module BABYLON {
  56374. /**
  56375. * Block used to clamp a float
  56376. */
  56377. export class ClampBlock extends NodeMaterialBlock {
  56378. /** Gets or sets the minimum range */
  56379. minimum: number;
  56380. /** Gets or sets the maximum range */
  56381. maximum: number;
  56382. /**
  56383. * Creates a new ClampBlock
  56384. * @param name defines the block name
  56385. */
  56386. constructor(name: string);
  56387. /**
  56388. * Gets the current class name
  56389. * @returns the class name
  56390. */
  56391. getClassName(): string;
  56392. /**
  56393. * Gets the value input component
  56394. */
  56395. readonly value: NodeMaterialConnectionPoint;
  56396. /**
  56397. * Gets the output component
  56398. */
  56399. readonly output: NodeMaterialConnectionPoint;
  56400. protected _buildBlock(state: NodeMaterialBuildState): this;
  56401. protected _dumpPropertiesCode(): string;
  56402. serialize(): any;
  56403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56404. }
  56405. }
  56406. declare module BABYLON {
  56407. /**
  56408. * Block used to apply a cross product between 2 vectors
  56409. */
  56410. export class CrossBlock extends NodeMaterialBlock {
  56411. /**
  56412. * Creates a new CrossBlock
  56413. * @param name defines the block name
  56414. */
  56415. constructor(name: string);
  56416. /**
  56417. * Gets the current class name
  56418. * @returns the class name
  56419. */
  56420. getClassName(): string;
  56421. /**
  56422. * Gets the left operand input component
  56423. */
  56424. readonly left: NodeMaterialConnectionPoint;
  56425. /**
  56426. * Gets the right operand input component
  56427. */
  56428. readonly right: NodeMaterialConnectionPoint;
  56429. /**
  56430. * Gets the output component
  56431. */
  56432. readonly output: NodeMaterialConnectionPoint;
  56433. protected _buildBlock(state: NodeMaterialBuildState): this;
  56434. }
  56435. }
  56436. declare module BABYLON {
  56437. /**
  56438. * Block used to apply a dot product between 2 vectors
  56439. */
  56440. export class DotBlock extends NodeMaterialBlock {
  56441. /**
  56442. * Creates a new DotBlock
  56443. * @param name defines the block name
  56444. */
  56445. constructor(name: string);
  56446. /**
  56447. * Gets the current class name
  56448. * @returns the class name
  56449. */
  56450. getClassName(): string;
  56451. /**
  56452. * Gets the left operand input component
  56453. */
  56454. readonly left: NodeMaterialConnectionPoint;
  56455. /**
  56456. * Gets the right operand input component
  56457. */
  56458. readonly right: NodeMaterialConnectionPoint;
  56459. /**
  56460. * Gets the output component
  56461. */
  56462. readonly output: NodeMaterialConnectionPoint;
  56463. protected _buildBlock(state: NodeMaterialBuildState): this;
  56464. }
  56465. }
  56466. declare module BABYLON {
  56467. /**
  56468. * Block used to remap a float from a range to a new one
  56469. */
  56470. export class RemapBlock extends NodeMaterialBlock {
  56471. /**
  56472. * Gets or sets the source range
  56473. */
  56474. sourceRange: Vector2;
  56475. /**
  56476. * Gets or sets the target range
  56477. */
  56478. targetRange: Vector2;
  56479. /**
  56480. * Creates a new RemapBlock
  56481. * @param name defines the block name
  56482. */
  56483. constructor(name: string);
  56484. /**
  56485. * Gets the current class name
  56486. * @returns the class name
  56487. */
  56488. getClassName(): string;
  56489. /**
  56490. * Gets the input component
  56491. */
  56492. readonly input: NodeMaterialConnectionPoint;
  56493. /**
  56494. * Gets the source min input component
  56495. */
  56496. readonly sourceMin: NodeMaterialConnectionPoint;
  56497. /**
  56498. * Gets the source max input component
  56499. */
  56500. readonly sourceMax: NodeMaterialConnectionPoint;
  56501. /**
  56502. * Gets the target min input component
  56503. */
  56504. readonly targetMin: NodeMaterialConnectionPoint;
  56505. /**
  56506. * Gets the target max input component
  56507. */
  56508. readonly targetMax: NodeMaterialConnectionPoint;
  56509. /**
  56510. * Gets the output component
  56511. */
  56512. readonly output: NodeMaterialConnectionPoint;
  56513. protected _buildBlock(state: NodeMaterialBuildState): this;
  56514. protected _dumpPropertiesCode(): string;
  56515. serialize(): any;
  56516. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56517. }
  56518. }
  56519. declare module BABYLON {
  56520. /**
  56521. * Block used to normalize a vector
  56522. */
  56523. export class NormalizeBlock extends NodeMaterialBlock {
  56524. /**
  56525. * Creates a new NormalizeBlock
  56526. * @param name defines the block name
  56527. */
  56528. constructor(name: string);
  56529. /**
  56530. * Gets the current class name
  56531. * @returns the class name
  56532. */
  56533. getClassName(): string;
  56534. /**
  56535. * Gets the input component
  56536. */
  56537. readonly input: NodeMaterialConnectionPoint;
  56538. /**
  56539. * Gets the output component
  56540. */
  56541. readonly output: NodeMaterialConnectionPoint;
  56542. protected _buildBlock(state: NodeMaterialBuildState): this;
  56543. }
  56544. }
  56545. declare module BABYLON {
  56546. /**
  56547. * Operations supported by the Trigonometry block
  56548. */
  56549. export enum TrigonometryBlockOperations {
  56550. /** Cos */
  56551. Cos = 0,
  56552. /** Sin */
  56553. Sin = 1,
  56554. /** Abs */
  56555. Abs = 2,
  56556. /** Exp */
  56557. Exp = 3,
  56558. /** Exp2 */
  56559. Exp2 = 4,
  56560. /** Round */
  56561. Round = 5,
  56562. /** Floor */
  56563. Floor = 6,
  56564. /** Ceiling */
  56565. Ceiling = 7,
  56566. /** Square root */
  56567. Sqrt = 8,
  56568. /** Log */
  56569. Log = 9,
  56570. /** Tangent */
  56571. Tan = 10,
  56572. /** Arc tangent */
  56573. ArcTan = 11,
  56574. /** Arc cosinus */
  56575. ArcCos = 12,
  56576. /** Arc sinus */
  56577. ArcSin = 13,
  56578. /** Fraction */
  56579. Fract = 14,
  56580. /** Sign */
  56581. Sign = 15,
  56582. /** To radians (from degrees) */
  56583. Radians = 16,
  56584. /** To degrees (from radians) */
  56585. Degrees = 17
  56586. }
  56587. /**
  56588. * Block used to apply trigonometry operation to floats
  56589. */
  56590. export class TrigonometryBlock extends NodeMaterialBlock {
  56591. /**
  56592. * Gets or sets the operation applied by the block
  56593. */
  56594. operation: TrigonometryBlockOperations;
  56595. /**
  56596. * Creates a new TrigonometryBlock
  56597. * @param name defines the block name
  56598. */
  56599. constructor(name: string);
  56600. /**
  56601. * Gets the current class name
  56602. * @returns the class name
  56603. */
  56604. getClassName(): string;
  56605. /**
  56606. * Gets the input component
  56607. */
  56608. readonly input: NodeMaterialConnectionPoint;
  56609. /**
  56610. * Gets the output component
  56611. */
  56612. readonly output: NodeMaterialConnectionPoint;
  56613. protected _buildBlock(state: NodeMaterialBuildState): this;
  56614. serialize(): any;
  56615. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56616. protected _dumpPropertiesCode(): string;
  56617. }
  56618. }
  56619. declare module BABYLON {
  56620. /**
  56621. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56622. */
  56623. export class ColorMergerBlock extends NodeMaterialBlock {
  56624. /**
  56625. * Create a new ColorMergerBlock
  56626. * @param name defines the block name
  56627. */
  56628. constructor(name: string);
  56629. /**
  56630. * Gets the current class name
  56631. * @returns the class name
  56632. */
  56633. getClassName(): string;
  56634. /**
  56635. * Gets the rgb component (input)
  56636. */
  56637. readonly rgbIn: NodeMaterialConnectionPoint;
  56638. /**
  56639. * Gets the r component (input)
  56640. */
  56641. readonly r: NodeMaterialConnectionPoint;
  56642. /**
  56643. * Gets the g component (input)
  56644. */
  56645. readonly g: NodeMaterialConnectionPoint;
  56646. /**
  56647. * Gets the b component (input)
  56648. */
  56649. readonly b: NodeMaterialConnectionPoint;
  56650. /**
  56651. * Gets the a component (input)
  56652. */
  56653. readonly a: NodeMaterialConnectionPoint;
  56654. /**
  56655. * Gets the rgba component (output)
  56656. */
  56657. readonly rgba: NodeMaterialConnectionPoint;
  56658. /**
  56659. * Gets the rgb component (output)
  56660. */
  56661. readonly rgbOut: NodeMaterialConnectionPoint;
  56662. /**
  56663. * Gets the rgb component (output)
  56664. * @deprecated Please use rgbOut instead.
  56665. */
  56666. readonly rgb: NodeMaterialConnectionPoint;
  56667. protected _buildBlock(state: NodeMaterialBuildState): this;
  56668. }
  56669. }
  56670. declare module BABYLON {
  56671. /**
  56672. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56673. */
  56674. export class VectorMergerBlock extends NodeMaterialBlock {
  56675. /**
  56676. * Create a new VectorMergerBlock
  56677. * @param name defines the block name
  56678. */
  56679. constructor(name: string);
  56680. /**
  56681. * Gets the current class name
  56682. * @returns the class name
  56683. */
  56684. getClassName(): string;
  56685. /**
  56686. * Gets the xyz component (input)
  56687. */
  56688. readonly xyzIn: NodeMaterialConnectionPoint;
  56689. /**
  56690. * Gets the xy component (input)
  56691. */
  56692. readonly xyIn: NodeMaterialConnectionPoint;
  56693. /**
  56694. * Gets the x component (input)
  56695. */
  56696. readonly x: NodeMaterialConnectionPoint;
  56697. /**
  56698. * Gets the y component (input)
  56699. */
  56700. readonly y: NodeMaterialConnectionPoint;
  56701. /**
  56702. * Gets the z component (input)
  56703. */
  56704. readonly z: NodeMaterialConnectionPoint;
  56705. /**
  56706. * Gets the w component (input)
  56707. */
  56708. readonly w: NodeMaterialConnectionPoint;
  56709. /**
  56710. * Gets the xyzw component (output)
  56711. */
  56712. readonly xyzw: NodeMaterialConnectionPoint;
  56713. /**
  56714. * Gets the xyz component (output)
  56715. */
  56716. readonly xyzOut: NodeMaterialConnectionPoint;
  56717. /**
  56718. * Gets the xy component (output)
  56719. */
  56720. readonly xyOut: NodeMaterialConnectionPoint;
  56721. /**
  56722. * Gets the xy component (output)
  56723. * @deprecated Please use xyOut instead.
  56724. */
  56725. readonly xy: NodeMaterialConnectionPoint;
  56726. /**
  56727. * Gets the xyz component (output)
  56728. * @deprecated Please use xyzOut instead.
  56729. */
  56730. readonly xyz: NodeMaterialConnectionPoint;
  56731. protected _buildBlock(state: NodeMaterialBuildState): this;
  56732. }
  56733. }
  56734. declare module BABYLON {
  56735. /**
  56736. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56737. */
  56738. export class ColorSplitterBlock extends NodeMaterialBlock {
  56739. /**
  56740. * Create a new ColorSplitterBlock
  56741. * @param name defines the block name
  56742. */
  56743. constructor(name: string);
  56744. /**
  56745. * Gets the current class name
  56746. * @returns the class name
  56747. */
  56748. getClassName(): string;
  56749. /**
  56750. * Gets the rgba component (input)
  56751. */
  56752. readonly rgba: NodeMaterialConnectionPoint;
  56753. /**
  56754. * Gets the rgb component (input)
  56755. */
  56756. readonly rgbIn: NodeMaterialConnectionPoint;
  56757. /**
  56758. * Gets the rgb component (output)
  56759. */
  56760. readonly rgbOut: NodeMaterialConnectionPoint;
  56761. /**
  56762. * Gets the r component (output)
  56763. */
  56764. readonly r: NodeMaterialConnectionPoint;
  56765. /**
  56766. * Gets the g component (output)
  56767. */
  56768. readonly g: NodeMaterialConnectionPoint;
  56769. /**
  56770. * Gets the b component (output)
  56771. */
  56772. readonly b: NodeMaterialConnectionPoint;
  56773. /**
  56774. * Gets the a component (output)
  56775. */
  56776. readonly a: NodeMaterialConnectionPoint;
  56777. protected _inputRename(name: string): string;
  56778. protected _outputRename(name: string): string;
  56779. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56780. }
  56781. }
  56782. declare module BABYLON {
  56783. /**
  56784. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56785. */
  56786. export class VectorSplitterBlock extends NodeMaterialBlock {
  56787. /**
  56788. * Create a new VectorSplitterBlock
  56789. * @param name defines the block name
  56790. */
  56791. constructor(name: string);
  56792. /**
  56793. * Gets the current class name
  56794. * @returns the class name
  56795. */
  56796. getClassName(): string;
  56797. /**
  56798. * Gets the xyzw component (input)
  56799. */
  56800. readonly xyzw: NodeMaterialConnectionPoint;
  56801. /**
  56802. * Gets the xyz component (input)
  56803. */
  56804. readonly xyzIn: NodeMaterialConnectionPoint;
  56805. /**
  56806. * Gets the xy component (input)
  56807. */
  56808. readonly xyIn: NodeMaterialConnectionPoint;
  56809. /**
  56810. * Gets the xyz component (output)
  56811. */
  56812. readonly xyzOut: NodeMaterialConnectionPoint;
  56813. /**
  56814. * Gets the xy component (output)
  56815. */
  56816. readonly xyOut: NodeMaterialConnectionPoint;
  56817. /**
  56818. * Gets the x component (output)
  56819. */
  56820. readonly x: NodeMaterialConnectionPoint;
  56821. /**
  56822. * Gets the y component (output)
  56823. */
  56824. readonly y: NodeMaterialConnectionPoint;
  56825. /**
  56826. * Gets the z component (output)
  56827. */
  56828. readonly z: NodeMaterialConnectionPoint;
  56829. /**
  56830. * Gets the w component (output)
  56831. */
  56832. readonly w: NodeMaterialConnectionPoint;
  56833. protected _inputRename(name: string): string;
  56834. protected _outputRename(name: string): string;
  56835. protected _buildBlock(state: NodeMaterialBuildState): this;
  56836. }
  56837. }
  56838. declare module BABYLON {
  56839. /**
  56840. * Block used to lerp between 2 values
  56841. */
  56842. export class LerpBlock extends NodeMaterialBlock {
  56843. /**
  56844. * Creates a new LerpBlock
  56845. * @param name defines the block name
  56846. */
  56847. constructor(name: string);
  56848. /**
  56849. * Gets the current class name
  56850. * @returns the class name
  56851. */
  56852. getClassName(): string;
  56853. /**
  56854. * Gets the left operand input component
  56855. */
  56856. readonly left: NodeMaterialConnectionPoint;
  56857. /**
  56858. * Gets the right operand input component
  56859. */
  56860. readonly right: NodeMaterialConnectionPoint;
  56861. /**
  56862. * Gets the gradient operand input component
  56863. */
  56864. readonly gradient: NodeMaterialConnectionPoint;
  56865. /**
  56866. * Gets the output component
  56867. */
  56868. readonly output: NodeMaterialConnectionPoint;
  56869. protected _buildBlock(state: NodeMaterialBuildState): this;
  56870. }
  56871. }
  56872. declare module BABYLON {
  56873. /**
  56874. * Block used to divide 2 vectors
  56875. */
  56876. export class DivideBlock extends NodeMaterialBlock {
  56877. /**
  56878. * Creates a new DivideBlock
  56879. * @param name defines the block name
  56880. */
  56881. constructor(name: string);
  56882. /**
  56883. * Gets the current class name
  56884. * @returns the class name
  56885. */
  56886. getClassName(): string;
  56887. /**
  56888. * Gets the left operand input component
  56889. */
  56890. readonly left: NodeMaterialConnectionPoint;
  56891. /**
  56892. * Gets the right operand input component
  56893. */
  56894. readonly right: NodeMaterialConnectionPoint;
  56895. /**
  56896. * Gets the output component
  56897. */
  56898. readonly output: NodeMaterialConnectionPoint;
  56899. protected _buildBlock(state: NodeMaterialBuildState): this;
  56900. }
  56901. }
  56902. declare module BABYLON {
  56903. /**
  56904. * Block used to subtract 2 vectors
  56905. */
  56906. export class SubtractBlock extends NodeMaterialBlock {
  56907. /**
  56908. * Creates a new SubtractBlock
  56909. * @param name defines the block name
  56910. */
  56911. constructor(name: string);
  56912. /**
  56913. * Gets the current class name
  56914. * @returns the class name
  56915. */
  56916. getClassName(): string;
  56917. /**
  56918. * Gets the left operand input component
  56919. */
  56920. readonly left: NodeMaterialConnectionPoint;
  56921. /**
  56922. * Gets the right operand input component
  56923. */
  56924. readonly right: NodeMaterialConnectionPoint;
  56925. /**
  56926. * Gets the output component
  56927. */
  56928. readonly output: NodeMaterialConnectionPoint;
  56929. protected _buildBlock(state: NodeMaterialBuildState): this;
  56930. }
  56931. }
  56932. declare module BABYLON {
  56933. /**
  56934. * Block used to step a value
  56935. */
  56936. export class StepBlock extends NodeMaterialBlock {
  56937. /**
  56938. * Creates a new StepBlock
  56939. * @param name defines the block name
  56940. */
  56941. constructor(name: string);
  56942. /**
  56943. * Gets the current class name
  56944. * @returns the class name
  56945. */
  56946. getClassName(): string;
  56947. /**
  56948. * Gets the value operand input component
  56949. */
  56950. readonly value: NodeMaterialConnectionPoint;
  56951. /**
  56952. * Gets the edge operand input component
  56953. */
  56954. readonly edge: NodeMaterialConnectionPoint;
  56955. /**
  56956. * Gets the output component
  56957. */
  56958. readonly output: NodeMaterialConnectionPoint;
  56959. protected _buildBlock(state: NodeMaterialBuildState): this;
  56960. }
  56961. }
  56962. declare module BABYLON {
  56963. /**
  56964. * Block used to get the opposite (1 - x) of a value
  56965. */
  56966. export class OneMinusBlock extends NodeMaterialBlock {
  56967. /**
  56968. * Creates a new OneMinusBlock
  56969. * @param name defines the block name
  56970. */
  56971. constructor(name: string);
  56972. /**
  56973. * Gets the current class name
  56974. * @returns the class name
  56975. */
  56976. getClassName(): string;
  56977. /**
  56978. * Gets the input component
  56979. */
  56980. readonly input: NodeMaterialConnectionPoint;
  56981. /**
  56982. * Gets the output component
  56983. */
  56984. readonly output: NodeMaterialConnectionPoint;
  56985. protected _buildBlock(state: NodeMaterialBuildState): this;
  56986. }
  56987. }
  56988. declare module BABYLON {
  56989. /**
  56990. * Block used to get the view direction
  56991. */
  56992. export class ViewDirectionBlock extends NodeMaterialBlock {
  56993. /**
  56994. * Creates a new ViewDirectionBlock
  56995. * @param name defines the block name
  56996. */
  56997. constructor(name: string);
  56998. /**
  56999. * Gets the current class name
  57000. * @returns the class name
  57001. */
  57002. getClassName(): string;
  57003. /**
  57004. * Gets the world position component
  57005. */
  57006. readonly worldPosition: NodeMaterialConnectionPoint;
  57007. /**
  57008. * Gets the camera position component
  57009. */
  57010. readonly cameraPosition: NodeMaterialConnectionPoint;
  57011. /**
  57012. * Gets the output component
  57013. */
  57014. readonly output: NodeMaterialConnectionPoint;
  57015. autoConfigure(material: NodeMaterial): void;
  57016. protected _buildBlock(state: NodeMaterialBuildState): this;
  57017. }
  57018. }
  57019. declare module BABYLON {
  57020. /**
  57021. * Block used to compute fresnel value
  57022. */
  57023. export class FresnelBlock extends NodeMaterialBlock {
  57024. /**
  57025. * Create a new FresnelBlock
  57026. * @param name defines the block name
  57027. */
  57028. constructor(name: string);
  57029. /**
  57030. * Gets the current class name
  57031. * @returns the class name
  57032. */
  57033. getClassName(): string;
  57034. /**
  57035. * Gets the world normal input component
  57036. */
  57037. readonly worldNormal: NodeMaterialConnectionPoint;
  57038. /**
  57039. * Gets the view direction input component
  57040. */
  57041. readonly viewDirection: NodeMaterialConnectionPoint;
  57042. /**
  57043. * Gets the bias input component
  57044. */
  57045. readonly bias: NodeMaterialConnectionPoint;
  57046. /**
  57047. * Gets the camera (or eye) position component
  57048. */
  57049. readonly power: NodeMaterialConnectionPoint;
  57050. /**
  57051. * Gets the fresnel output component
  57052. */
  57053. readonly fresnel: NodeMaterialConnectionPoint;
  57054. autoConfigure(material: NodeMaterial): void;
  57055. protected _buildBlock(state: NodeMaterialBuildState): this;
  57056. }
  57057. }
  57058. declare module BABYLON {
  57059. /**
  57060. * Block used to get the max of 2 values
  57061. */
  57062. export class MaxBlock extends NodeMaterialBlock {
  57063. /**
  57064. * Creates a new MaxBlock
  57065. * @param name defines the block name
  57066. */
  57067. constructor(name: string);
  57068. /**
  57069. * Gets the current class name
  57070. * @returns the class name
  57071. */
  57072. getClassName(): string;
  57073. /**
  57074. * Gets the left operand input component
  57075. */
  57076. readonly left: NodeMaterialConnectionPoint;
  57077. /**
  57078. * Gets the right operand input component
  57079. */
  57080. readonly right: NodeMaterialConnectionPoint;
  57081. /**
  57082. * Gets the output component
  57083. */
  57084. readonly output: NodeMaterialConnectionPoint;
  57085. protected _buildBlock(state: NodeMaterialBuildState): this;
  57086. }
  57087. }
  57088. declare module BABYLON {
  57089. /**
  57090. * Block used to get the min of 2 values
  57091. */
  57092. export class MinBlock extends NodeMaterialBlock {
  57093. /**
  57094. * Creates a new MinBlock
  57095. * @param name defines the block name
  57096. */
  57097. constructor(name: string);
  57098. /**
  57099. * Gets the current class name
  57100. * @returns the class name
  57101. */
  57102. getClassName(): string;
  57103. /**
  57104. * Gets the left operand input component
  57105. */
  57106. readonly left: NodeMaterialConnectionPoint;
  57107. /**
  57108. * Gets the right operand input component
  57109. */
  57110. readonly right: NodeMaterialConnectionPoint;
  57111. /**
  57112. * Gets the output component
  57113. */
  57114. readonly output: NodeMaterialConnectionPoint;
  57115. protected _buildBlock(state: NodeMaterialBuildState): this;
  57116. }
  57117. }
  57118. declare module BABYLON {
  57119. /**
  57120. * Block used to get the distance between 2 values
  57121. */
  57122. export class DistanceBlock extends NodeMaterialBlock {
  57123. /**
  57124. * Creates a new DistanceBlock
  57125. * @param name defines the block name
  57126. */
  57127. constructor(name: string);
  57128. /**
  57129. * Gets the current class name
  57130. * @returns the class name
  57131. */
  57132. getClassName(): string;
  57133. /**
  57134. * Gets the left operand input component
  57135. */
  57136. readonly left: NodeMaterialConnectionPoint;
  57137. /**
  57138. * Gets the right operand input component
  57139. */
  57140. readonly right: NodeMaterialConnectionPoint;
  57141. /**
  57142. * Gets the output component
  57143. */
  57144. readonly output: NodeMaterialConnectionPoint;
  57145. protected _buildBlock(state: NodeMaterialBuildState): this;
  57146. }
  57147. }
  57148. declare module BABYLON {
  57149. /**
  57150. * Block used to get the length of a vector
  57151. */
  57152. export class LengthBlock extends NodeMaterialBlock {
  57153. /**
  57154. * Creates a new LengthBlock
  57155. * @param name defines the block name
  57156. */
  57157. constructor(name: string);
  57158. /**
  57159. * Gets the current class name
  57160. * @returns the class name
  57161. */
  57162. getClassName(): string;
  57163. /**
  57164. * Gets the value input component
  57165. */
  57166. readonly value: NodeMaterialConnectionPoint;
  57167. /**
  57168. * Gets the output component
  57169. */
  57170. readonly output: NodeMaterialConnectionPoint;
  57171. protected _buildBlock(state: NodeMaterialBuildState): this;
  57172. }
  57173. }
  57174. declare module BABYLON {
  57175. /**
  57176. * Block used to get negative version of a value (i.e. x * -1)
  57177. */
  57178. export class NegateBlock extends NodeMaterialBlock {
  57179. /**
  57180. * Creates a new NegateBlock
  57181. * @param name defines the block name
  57182. */
  57183. constructor(name: string);
  57184. /**
  57185. * Gets the current class name
  57186. * @returns the class name
  57187. */
  57188. getClassName(): string;
  57189. /**
  57190. * Gets the value input component
  57191. */
  57192. readonly value: NodeMaterialConnectionPoint;
  57193. /**
  57194. * Gets the output component
  57195. */
  57196. readonly output: NodeMaterialConnectionPoint;
  57197. protected _buildBlock(state: NodeMaterialBuildState): this;
  57198. }
  57199. }
  57200. declare module BABYLON {
  57201. /**
  57202. * Block used to get the value of the first parameter raised to the power of the second
  57203. */
  57204. export class PowBlock extends NodeMaterialBlock {
  57205. /**
  57206. * Creates a new PowBlock
  57207. * @param name defines the block name
  57208. */
  57209. constructor(name: string);
  57210. /**
  57211. * Gets the current class name
  57212. * @returns the class name
  57213. */
  57214. getClassName(): string;
  57215. /**
  57216. * Gets the value operand input component
  57217. */
  57218. readonly value: NodeMaterialConnectionPoint;
  57219. /**
  57220. * Gets the power operand input component
  57221. */
  57222. readonly power: NodeMaterialConnectionPoint;
  57223. /**
  57224. * Gets the output component
  57225. */
  57226. readonly output: NodeMaterialConnectionPoint;
  57227. protected _buildBlock(state: NodeMaterialBuildState): this;
  57228. }
  57229. }
  57230. declare module BABYLON {
  57231. /**
  57232. * Block used to get a random number
  57233. */
  57234. export class RandomNumberBlock extends NodeMaterialBlock {
  57235. /**
  57236. * Creates a new RandomNumberBlock
  57237. * @param name defines the block name
  57238. */
  57239. constructor(name: string);
  57240. /**
  57241. * Gets the current class name
  57242. * @returns the class name
  57243. */
  57244. getClassName(): string;
  57245. /**
  57246. * Gets the seed input component
  57247. */
  57248. readonly seed: NodeMaterialConnectionPoint;
  57249. /**
  57250. * Gets the output component
  57251. */
  57252. readonly output: NodeMaterialConnectionPoint;
  57253. protected _buildBlock(state: NodeMaterialBuildState): this;
  57254. }
  57255. }
  57256. declare module BABYLON {
  57257. /**
  57258. * Block used to compute arc tangent of 2 values
  57259. */
  57260. export class ArcTan2Block extends NodeMaterialBlock {
  57261. /**
  57262. * Creates a new ArcTan2Block
  57263. * @param name defines the block name
  57264. */
  57265. constructor(name: string);
  57266. /**
  57267. * Gets the current class name
  57268. * @returns the class name
  57269. */
  57270. getClassName(): string;
  57271. /**
  57272. * Gets the x operand input component
  57273. */
  57274. readonly x: NodeMaterialConnectionPoint;
  57275. /**
  57276. * Gets the y operand input component
  57277. */
  57278. readonly y: NodeMaterialConnectionPoint;
  57279. /**
  57280. * Gets the output component
  57281. */
  57282. readonly output: NodeMaterialConnectionPoint;
  57283. protected _buildBlock(state: NodeMaterialBuildState): this;
  57284. }
  57285. }
  57286. declare module BABYLON {
  57287. /**
  57288. * Block used to smooth step a value
  57289. */
  57290. export class SmoothStepBlock extends NodeMaterialBlock {
  57291. /**
  57292. * Creates a new SmoothStepBlock
  57293. * @param name defines the block name
  57294. */
  57295. constructor(name: string);
  57296. /**
  57297. * Gets the current class name
  57298. * @returns the class name
  57299. */
  57300. getClassName(): string;
  57301. /**
  57302. * Gets the value operand input component
  57303. */
  57304. readonly value: NodeMaterialConnectionPoint;
  57305. /**
  57306. * Gets the first edge operand input component
  57307. */
  57308. readonly edge0: NodeMaterialConnectionPoint;
  57309. /**
  57310. * Gets the second edge operand input component
  57311. */
  57312. readonly edge1: NodeMaterialConnectionPoint;
  57313. /**
  57314. * Gets the output component
  57315. */
  57316. readonly output: NodeMaterialConnectionPoint;
  57317. protected _buildBlock(state: NodeMaterialBuildState): this;
  57318. }
  57319. }
  57320. declare module BABYLON {
  57321. /**
  57322. * Block used to get the reciprocal (1 / x) of a value
  57323. */
  57324. export class ReciprocalBlock extends NodeMaterialBlock {
  57325. /**
  57326. * Creates a new ReciprocalBlock
  57327. * @param name defines the block name
  57328. */
  57329. constructor(name: string);
  57330. /**
  57331. * Gets the current class name
  57332. * @returns the class name
  57333. */
  57334. getClassName(): string;
  57335. /**
  57336. * Gets the input component
  57337. */
  57338. readonly input: NodeMaterialConnectionPoint;
  57339. /**
  57340. * Gets the output component
  57341. */
  57342. readonly output: NodeMaterialConnectionPoint;
  57343. protected _buildBlock(state: NodeMaterialBuildState): this;
  57344. }
  57345. }
  57346. declare module BABYLON {
  57347. /**
  57348. * Block used to replace a color by another one
  57349. */
  57350. export class ReplaceColorBlock extends NodeMaterialBlock {
  57351. /**
  57352. * Creates a new ReplaceColorBlock
  57353. * @param name defines the block name
  57354. */
  57355. constructor(name: string);
  57356. /**
  57357. * Gets the current class name
  57358. * @returns the class name
  57359. */
  57360. getClassName(): string;
  57361. /**
  57362. * Gets the value input component
  57363. */
  57364. readonly value: NodeMaterialConnectionPoint;
  57365. /**
  57366. * Gets the reference input component
  57367. */
  57368. readonly reference: NodeMaterialConnectionPoint;
  57369. /**
  57370. * Gets the distance input component
  57371. */
  57372. readonly distance: NodeMaterialConnectionPoint;
  57373. /**
  57374. * Gets the replacement input component
  57375. */
  57376. readonly replacement: NodeMaterialConnectionPoint;
  57377. /**
  57378. * Gets the output component
  57379. */
  57380. readonly output: NodeMaterialConnectionPoint;
  57381. protected _buildBlock(state: NodeMaterialBuildState): this;
  57382. }
  57383. }
  57384. declare module BABYLON {
  57385. /**
  57386. * Block used to posterize a value
  57387. * @see https://en.wikipedia.org/wiki/Posterization
  57388. */
  57389. export class PosterizeBlock extends NodeMaterialBlock {
  57390. /**
  57391. * Creates a new PosterizeBlock
  57392. * @param name defines the block name
  57393. */
  57394. constructor(name: string);
  57395. /**
  57396. * Gets the current class name
  57397. * @returns the class name
  57398. */
  57399. getClassName(): string;
  57400. /**
  57401. * Gets the value input component
  57402. */
  57403. readonly value: NodeMaterialConnectionPoint;
  57404. /**
  57405. * Gets the steps input component
  57406. */
  57407. readonly steps: NodeMaterialConnectionPoint;
  57408. /**
  57409. * Gets the output component
  57410. */
  57411. readonly output: NodeMaterialConnectionPoint;
  57412. protected _buildBlock(state: NodeMaterialBuildState): this;
  57413. }
  57414. }
  57415. declare module BABYLON {
  57416. /**
  57417. * Operations supported by the Wave block
  57418. */
  57419. export enum WaveBlockKind {
  57420. /** SawTooth */
  57421. SawTooth = 0,
  57422. /** Square */
  57423. Square = 1,
  57424. /** Triangle */
  57425. Triangle = 2
  57426. }
  57427. /**
  57428. * Block used to apply wave operation to floats
  57429. */
  57430. export class WaveBlock extends NodeMaterialBlock {
  57431. /**
  57432. * Gets or sets the kibnd of wave to be applied by the block
  57433. */
  57434. kind: WaveBlockKind;
  57435. /**
  57436. * Creates a new WaveBlock
  57437. * @param name defines the block name
  57438. */
  57439. constructor(name: string);
  57440. /**
  57441. * Gets the current class name
  57442. * @returns the class name
  57443. */
  57444. getClassName(): string;
  57445. /**
  57446. * Gets the input component
  57447. */
  57448. readonly input: NodeMaterialConnectionPoint;
  57449. /**
  57450. * Gets the output component
  57451. */
  57452. readonly output: NodeMaterialConnectionPoint;
  57453. protected _buildBlock(state: NodeMaterialBuildState): this;
  57454. serialize(): any;
  57455. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57456. }
  57457. }
  57458. declare module BABYLON {
  57459. /**
  57460. * Class used to store a color step for the GradientBlock
  57461. */
  57462. export class GradientBlockColorStep {
  57463. /**
  57464. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  57465. */
  57466. step: number;
  57467. /**
  57468. * Gets or sets the color associated with this step
  57469. */
  57470. color: Color3;
  57471. /**
  57472. * Creates a new GradientBlockColorStep
  57473. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  57474. * @param color defines the color associated with this step
  57475. */
  57476. constructor(
  57477. /**
  57478. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  57479. */
  57480. step: number,
  57481. /**
  57482. * Gets or sets the color associated with this step
  57483. */
  57484. color: Color3);
  57485. }
  57486. /**
  57487. * Block used to return a color from a gradient based on an input value between 0 and 1
  57488. */
  57489. export class GradientBlock extends NodeMaterialBlock {
  57490. /**
  57491. * Gets or sets the list of color steps
  57492. */
  57493. colorSteps: GradientBlockColorStep[];
  57494. /**
  57495. * Creates a new GradientBlock
  57496. * @param name defines the block name
  57497. */
  57498. constructor(name: string);
  57499. /**
  57500. * Gets the current class name
  57501. * @returns the class name
  57502. */
  57503. getClassName(): string;
  57504. /**
  57505. * Gets the gradient input component
  57506. */
  57507. readonly gradient: NodeMaterialConnectionPoint;
  57508. /**
  57509. * Gets the output component
  57510. */
  57511. readonly output: NodeMaterialConnectionPoint;
  57512. private _writeColorConstant;
  57513. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57514. serialize(): any;
  57515. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57516. protected _dumpPropertiesCode(): string;
  57517. }
  57518. }
  57519. declare module BABYLON {
  57520. /**
  57521. * Block used to normalize lerp between 2 values
  57522. */
  57523. export class NLerpBlock extends NodeMaterialBlock {
  57524. /**
  57525. * Creates a new NLerpBlock
  57526. * @param name defines the block name
  57527. */
  57528. constructor(name: string);
  57529. /**
  57530. * Gets the current class name
  57531. * @returns the class name
  57532. */
  57533. getClassName(): string;
  57534. /**
  57535. * Gets the left operand input component
  57536. */
  57537. readonly left: NodeMaterialConnectionPoint;
  57538. /**
  57539. * Gets the right operand input component
  57540. */
  57541. readonly right: NodeMaterialConnectionPoint;
  57542. /**
  57543. * Gets the gradient operand input component
  57544. */
  57545. readonly gradient: NodeMaterialConnectionPoint;
  57546. /**
  57547. * Gets the output component
  57548. */
  57549. readonly output: NodeMaterialConnectionPoint;
  57550. protected _buildBlock(state: NodeMaterialBuildState): this;
  57551. }
  57552. }
  57553. declare module BABYLON {
  57554. /**
  57555. * block used to Generate a Worley Noise 3D Noise Pattern
  57556. */
  57557. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  57558. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57559. manhattanDistance: boolean;
  57560. /**
  57561. * Creates a new WorleyNoise3DBlock
  57562. * @param name defines the block name
  57563. */
  57564. constructor(name: string);
  57565. /**
  57566. * Gets the current class name
  57567. * @returns the class name
  57568. */
  57569. getClassName(): string;
  57570. /**
  57571. * Gets the seed input component
  57572. */
  57573. readonly seed: NodeMaterialConnectionPoint;
  57574. /**
  57575. * Gets the jitter input component
  57576. */
  57577. readonly jitter: NodeMaterialConnectionPoint;
  57578. /**
  57579. * Gets the output component
  57580. */
  57581. readonly output: NodeMaterialConnectionPoint;
  57582. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57583. /**
  57584. * Exposes the properties to the UI?
  57585. */
  57586. protected _dumpPropertiesCode(): string;
  57587. /**
  57588. * Exposes the properties to the Seralize?
  57589. */
  57590. serialize(): any;
  57591. /**
  57592. * Exposes the properties to the deseralize?
  57593. */
  57594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57595. }
  57596. }
  57597. declare module BABYLON {
  57598. /**
  57599. * block used to Generate a Simplex Perlin 3d Noise Pattern
  57600. */
  57601. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  57602. /**
  57603. * Creates a new SimplexPerlin3DBlock
  57604. * @param name defines the block name
  57605. */
  57606. constructor(name: string);
  57607. /**
  57608. * Gets the current class name
  57609. * @returns the class name
  57610. */
  57611. getClassName(): string;
  57612. /**
  57613. * Gets the seed operand input component
  57614. */
  57615. readonly seed: NodeMaterialConnectionPoint;
  57616. /**
  57617. * Gets the output component
  57618. */
  57619. readonly output: NodeMaterialConnectionPoint;
  57620. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57621. }
  57622. }
  57623. declare module BABYLON {
  57624. /**
  57625. * Block used to blend normals
  57626. */
  57627. export class NormalBlendBlock extends NodeMaterialBlock {
  57628. /**
  57629. * Creates a new NormalBlendBlock
  57630. * @param name defines the block name
  57631. */
  57632. constructor(name: string);
  57633. /**
  57634. * Gets the current class name
  57635. * @returns the class name
  57636. */
  57637. getClassName(): string;
  57638. /**
  57639. * Gets the first input component
  57640. */
  57641. readonly normalMap0: NodeMaterialConnectionPoint;
  57642. /**
  57643. * Gets the second input component
  57644. */
  57645. readonly normalMap1: NodeMaterialConnectionPoint;
  57646. /**
  57647. * Gets the output component
  57648. */
  57649. readonly output: NodeMaterialConnectionPoint;
  57650. protected _buildBlock(state: NodeMaterialBuildState): this;
  57651. }
  57652. }
  57653. declare module BABYLON {
  57654. /**
  57655. * Block used to rotate a 2d vector by a given angle
  57656. */
  57657. export class Rotate2dBlock extends NodeMaterialBlock {
  57658. /**
  57659. * Creates a new Rotate2dBlock
  57660. * @param name defines the block name
  57661. */
  57662. constructor(name: string);
  57663. /**
  57664. * Gets the current class name
  57665. * @returns the class name
  57666. */
  57667. getClassName(): string;
  57668. /**
  57669. * Gets the input vector
  57670. */
  57671. readonly input: NodeMaterialConnectionPoint;
  57672. /**
  57673. * Gets the input angle
  57674. */
  57675. readonly angle: NodeMaterialConnectionPoint;
  57676. /**
  57677. * Gets the output component
  57678. */
  57679. readonly output: NodeMaterialConnectionPoint;
  57680. autoConfigure(material: NodeMaterial): void;
  57681. protected _buildBlock(state: NodeMaterialBuildState): this;
  57682. }
  57683. }
  57684. declare module BABYLON {
  57685. /**
  57686. * Block used to get the reflected vector from a direction and a normal
  57687. */
  57688. export class ReflectBlock extends NodeMaterialBlock {
  57689. /**
  57690. * Creates a new ReflectBlock
  57691. * @param name defines the block name
  57692. */
  57693. constructor(name: string);
  57694. /**
  57695. * Gets the current class name
  57696. * @returns the class name
  57697. */
  57698. getClassName(): string;
  57699. /**
  57700. * Gets the incident component
  57701. */
  57702. readonly incident: NodeMaterialConnectionPoint;
  57703. /**
  57704. * Gets the normal component
  57705. */
  57706. readonly normal: NodeMaterialConnectionPoint;
  57707. /**
  57708. * Gets the output component
  57709. */
  57710. readonly output: NodeMaterialConnectionPoint;
  57711. protected _buildBlock(state: NodeMaterialBuildState): this;
  57712. }
  57713. }
  57714. declare module BABYLON {
  57715. /**
  57716. * Block used to get the refracted vector from a direction and a normal
  57717. */
  57718. export class RefractBlock extends NodeMaterialBlock {
  57719. /**
  57720. * Creates a new RefractBlock
  57721. * @param name defines the block name
  57722. */
  57723. constructor(name: string);
  57724. /**
  57725. * Gets the current class name
  57726. * @returns the class name
  57727. */
  57728. getClassName(): string;
  57729. /**
  57730. * Gets the incident component
  57731. */
  57732. readonly incident: NodeMaterialConnectionPoint;
  57733. /**
  57734. * Gets the normal component
  57735. */
  57736. readonly normal: NodeMaterialConnectionPoint;
  57737. /**
  57738. * Gets the index of refraction component
  57739. */
  57740. readonly ior: NodeMaterialConnectionPoint;
  57741. /**
  57742. * Gets the output component
  57743. */
  57744. readonly output: NodeMaterialConnectionPoint;
  57745. protected _buildBlock(state: NodeMaterialBuildState): this;
  57746. }
  57747. }
  57748. declare module BABYLON {
  57749. /**
  57750. * Block used to desaturate a color
  57751. */
  57752. export class DesaturateBlock extends NodeMaterialBlock {
  57753. /**
  57754. * Creates a new DesaturateBlock
  57755. * @param name defines the block name
  57756. */
  57757. constructor(name: string);
  57758. /**
  57759. * Gets the current class name
  57760. * @returns the class name
  57761. */
  57762. getClassName(): string;
  57763. /**
  57764. * Gets the color operand input component
  57765. */
  57766. readonly color: NodeMaterialConnectionPoint;
  57767. /**
  57768. * Gets the level operand input component
  57769. */
  57770. readonly level: NodeMaterialConnectionPoint;
  57771. /**
  57772. * Gets the output component
  57773. */
  57774. readonly output: NodeMaterialConnectionPoint;
  57775. protected _buildBlock(state: NodeMaterialBuildState): this;
  57776. }
  57777. }
  57778. declare module BABYLON {
  57779. /**
  57780. * Effect Render Options
  57781. */
  57782. export interface IEffectRendererOptions {
  57783. /**
  57784. * Defines the vertices positions.
  57785. */
  57786. positions?: number[];
  57787. /**
  57788. * Defines the indices.
  57789. */
  57790. indices?: number[];
  57791. }
  57792. /**
  57793. * Helper class to render one or more effects
  57794. */
  57795. export class EffectRenderer {
  57796. private engine;
  57797. private static _DefaultOptions;
  57798. private _vertexBuffers;
  57799. private _indexBuffer;
  57800. private _ringBufferIndex;
  57801. private _ringScreenBuffer;
  57802. private _fullscreenViewport;
  57803. private _getNextFrameBuffer;
  57804. /**
  57805. * Creates an effect renderer
  57806. * @param engine the engine to use for rendering
  57807. * @param options defines the options of the effect renderer
  57808. */
  57809. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  57810. /**
  57811. * Sets the current viewport in normalized coordinates 0-1
  57812. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57813. */
  57814. setViewport(viewport?: Viewport): void;
  57815. /**
  57816. * Binds the embedded attributes buffer to the effect.
  57817. * @param effect Defines the effect to bind the attributes for
  57818. */
  57819. bindBuffers(effect: Effect): void;
  57820. /**
  57821. * Sets the current effect wrapper to use during draw.
  57822. * The effect needs to be ready before calling this api.
  57823. * This also sets the default full screen position attribute.
  57824. * @param effectWrapper Defines the effect to draw with
  57825. */
  57826. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57827. /**
  57828. * Draws a full screen quad.
  57829. */
  57830. draw(): void;
  57831. /**
  57832. * renders one or more effects to a specified texture
  57833. * @param effectWrappers list of effects to renderer
  57834. * @param outputTexture texture to draw to, if null it will render to the screen
  57835. */
  57836. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57837. /**
  57838. * Disposes of the effect renderer
  57839. */
  57840. dispose(): void;
  57841. }
  57842. /**
  57843. * Options to create an EffectWrapper
  57844. */
  57845. interface EffectWrapperCreationOptions {
  57846. /**
  57847. * Engine to use to create the effect
  57848. */
  57849. engine: ThinEngine;
  57850. /**
  57851. * Fragment shader for the effect
  57852. */
  57853. fragmentShader: string;
  57854. /**
  57855. * Vertex shader for the effect
  57856. */
  57857. vertexShader?: string;
  57858. /**
  57859. * Attributes to use in the shader
  57860. */
  57861. attributeNames?: Array<string>;
  57862. /**
  57863. * Uniforms to use in the shader
  57864. */
  57865. uniformNames?: Array<string>;
  57866. /**
  57867. * Texture sampler names to use in the shader
  57868. */
  57869. samplerNames?: Array<string>;
  57870. /**
  57871. * The friendly name of the effect displayed in Spector.
  57872. */
  57873. name?: string;
  57874. }
  57875. /**
  57876. * Wraps an effect to be used for rendering
  57877. */
  57878. export class EffectWrapper {
  57879. /**
  57880. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57881. */
  57882. onApplyObservable: Observable<{}>;
  57883. /**
  57884. * The underlying effect
  57885. */
  57886. effect: Effect;
  57887. /**
  57888. * Creates an effect to be renderer
  57889. * @param creationOptions options to create the effect
  57890. */
  57891. constructor(creationOptions: EffectWrapperCreationOptions);
  57892. /**
  57893. * Disposes of the effect wrapper
  57894. */
  57895. dispose(): void;
  57896. }
  57897. }
  57898. declare module BABYLON {
  57899. /**
  57900. * Helper class to push actions to a pool of workers.
  57901. */
  57902. export class WorkerPool implements IDisposable {
  57903. private _workerInfos;
  57904. private _pendingActions;
  57905. /**
  57906. * Constructor
  57907. * @param workers Array of workers to use for actions
  57908. */
  57909. constructor(workers: Array<Worker>);
  57910. /**
  57911. * Terminates all workers and clears any pending actions.
  57912. */
  57913. dispose(): void;
  57914. /**
  57915. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57916. * pended until a worker has completed its action.
  57917. * @param action The action to perform. Call onComplete when the action is complete.
  57918. */
  57919. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57920. private _execute;
  57921. }
  57922. }
  57923. declare module BABYLON {
  57924. /**
  57925. * Configuration for Draco compression
  57926. */
  57927. export interface IDracoCompressionConfiguration {
  57928. /**
  57929. * Configuration for the decoder.
  57930. */
  57931. decoder: {
  57932. /**
  57933. * The url to the WebAssembly module.
  57934. */
  57935. wasmUrl?: string;
  57936. /**
  57937. * The url to the WebAssembly binary.
  57938. */
  57939. wasmBinaryUrl?: string;
  57940. /**
  57941. * The url to the fallback JavaScript module.
  57942. */
  57943. fallbackUrl?: string;
  57944. };
  57945. }
  57946. /**
  57947. * Draco compression (https://google.github.io/draco/)
  57948. *
  57949. * This class wraps the Draco module.
  57950. *
  57951. * **Encoder**
  57952. *
  57953. * The encoder is not currently implemented.
  57954. *
  57955. * **Decoder**
  57956. *
  57957. * 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.
  57958. *
  57959. * To update the configuration, use the following code:
  57960. * ```javascript
  57961. * DracoCompression.Configuration = {
  57962. * decoder: {
  57963. * wasmUrl: "<url to the WebAssembly library>",
  57964. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57965. * fallbackUrl: "<url to the fallback JavaScript library>",
  57966. * }
  57967. * };
  57968. * ```
  57969. *
  57970. * 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.
  57971. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57972. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57973. *
  57974. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57975. * ```javascript
  57976. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57977. * ```
  57978. *
  57979. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57980. */
  57981. export class DracoCompression implements IDisposable {
  57982. private _workerPoolPromise?;
  57983. private _decoderModulePromise?;
  57984. /**
  57985. * The configuration. Defaults to the following urls:
  57986. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57987. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57988. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57989. */
  57990. static Configuration: IDracoCompressionConfiguration;
  57991. /**
  57992. * Returns true if the decoder configuration is available.
  57993. */
  57994. static readonly DecoderAvailable: boolean;
  57995. /**
  57996. * Default number of workers to create when creating the draco compression object.
  57997. */
  57998. static DefaultNumWorkers: number;
  57999. private static GetDefaultNumWorkers;
  58000. private static _Default;
  58001. /**
  58002. * Default instance for the draco compression object.
  58003. */
  58004. static readonly Default: DracoCompression;
  58005. /**
  58006. * Constructor
  58007. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58008. */
  58009. constructor(numWorkers?: number);
  58010. /**
  58011. * Stop all async operations and release resources.
  58012. */
  58013. dispose(): void;
  58014. /**
  58015. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58016. * @returns a promise that resolves when ready
  58017. */
  58018. whenReadyAsync(): Promise<void>;
  58019. /**
  58020. * Decode Draco compressed mesh data to vertex data.
  58021. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58022. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58023. * @returns A promise that resolves with the decoded vertex data
  58024. */
  58025. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58026. [kind: string]: number;
  58027. }): Promise<VertexData>;
  58028. }
  58029. }
  58030. declare module BABYLON {
  58031. /**
  58032. * Class for building Constructive Solid Geometry
  58033. */
  58034. export class CSG {
  58035. private polygons;
  58036. /**
  58037. * The world matrix
  58038. */
  58039. matrix: Matrix;
  58040. /**
  58041. * Stores the position
  58042. */
  58043. position: Vector3;
  58044. /**
  58045. * Stores the rotation
  58046. */
  58047. rotation: Vector3;
  58048. /**
  58049. * Stores the rotation quaternion
  58050. */
  58051. rotationQuaternion: Nullable<Quaternion>;
  58052. /**
  58053. * Stores the scaling vector
  58054. */
  58055. scaling: Vector3;
  58056. /**
  58057. * Convert the Mesh to CSG
  58058. * @param mesh The Mesh to convert to CSG
  58059. * @returns A new CSG from the Mesh
  58060. */
  58061. static FromMesh(mesh: Mesh): CSG;
  58062. /**
  58063. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58064. * @param polygons Polygons used to construct a CSG solid
  58065. */
  58066. private static FromPolygons;
  58067. /**
  58068. * Clones, or makes a deep copy, of the CSG
  58069. * @returns A new CSG
  58070. */
  58071. clone(): CSG;
  58072. /**
  58073. * Unions this CSG with another CSG
  58074. * @param csg The CSG to union against this CSG
  58075. * @returns The unioned CSG
  58076. */
  58077. union(csg: CSG): CSG;
  58078. /**
  58079. * Unions this CSG with another CSG in place
  58080. * @param csg The CSG to union against this CSG
  58081. */
  58082. unionInPlace(csg: CSG): void;
  58083. /**
  58084. * Subtracts this CSG with another CSG
  58085. * @param csg The CSG to subtract against this CSG
  58086. * @returns A new CSG
  58087. */
  58088. subtract(csg: CSG): CSG;
  58089. /**
  58090. * Subtracts this CSG with another CSG in place
  58091. * @param csg The CSG to subtact against this CSG
  58092. */
  58093. subtractInPlace(csg: CSG): void;
  58094. /**
  58095. * Intersect this CSG with another CSG
  58096. * @param csg The CSG to intersect against this CSG
  58097. * @returns A new CSG
  58098. */
  58099. intersect(csg: CSG): CSG;
  58100. /**
  58101. * Intersects this CSG with another CSG in place
  58102. * @param csg The CSG to intersect against this CSG
  58103. */
  58104. intersectInPlace(csg: CSG): void;
  58105. /**
  58106. * Return a new CSG solid with solid and empty space switched. This solid is
  58107. * not modified.
  58108. * @returns A new CSG solid with solid and empty space switched
  58109. */
  58110. inverse(): CSG;
  58111. /**
  58112. * Inverses the CSG in place
  58113. */
  58114. inverseInPlace(): void;
  58115. /**
  58116. * This is used to keep meshes transformations so they can be restored
  58117. * when we build back a Babylon Mesh
  58118. * NB : All CSG operations are performed in world coordinates
  58119. * @param csg The CSG to copy the transform attributes from
  58120. * @returns This CSG
  58121. */
  58122. copyTransformAttributes(csg: CSG): CSG;
  58123. /**
  58124. * Build Raw mesh from CSG
  58125. * Coordinates here are in world space
  58126. * @param name The name of the mesh geometry
  58127. * @param scene The Scene
  58128. * @param keepSubMeshes Specifies if the submeshes should be kept
  58129. * @returns A new Mesh
  58130. */
  58131. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58132. /**
  58133. * Build Mesh from CSG taking material and transforms into account
  58134. * @param name The name of the Mesh
  58135. * @param material The material of the Mesh
  58136. * @param scene The Scene
  58137. * @param keepSubMeshes Specifies if submeshes should be kept
  58138. * @returns The new Mesh
  58139. */
  58140. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58141. }
  58142. }
  58143. declare module BABYLON {
  58144. /**
  58145. * Class used to create a trail following a mesh
  58146. */
  58147. export class TrailMesh extends Mesh {
  58148. private _generator;
  58149. private _autoStart;
  58150. private _running;
  58151. private _diameter;
  58152. private _length;
  58153. private _sectionPolygonPointsCount;
  58154. private _sectionVectors;
  58155. private _sectionNormalVectors;
  58156. private _beforeRenderObserver;
  58157. /**
  58158. * @constructor
  58159. * @param name The value used by scene.getMeshByName() to do a lookup.
  58160. * @param generator The mesh to generate a trail.
  58161. * @param scene The scene to add this mesh to.
  58162. * @param diameter Diameter of trailing mesh. Default is 1.
  58163. * @param length Length of trailing mesh. Default is 60.
  58164. * @param autoStart Automatically start trailing mesh. Default true.
  58165. */
  58166. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58167. /**
  58168. * "TrailMesh"
  58169. * @returns "TrailMesh"
  58170. */
  58171. getClassName(): string;
  58172. private _createMesh;
  58173. /**
  58174. * Start trailing mesh.
  58175. */
  58176. start(): void;
  58177. /**
  58178. * Stop trailing mesh.
  58179. */
  58180. stop(): void;
  58181. /**
  58182. * Update trailing mesh geometry.
  58183. */
  58184. update(): void;
  58185. /**
  58186. * Returns a new TrailMesh object.
  58187. * @param name is a string, the name given to the new mesh
  58188. * @param newGenerator use new generator object for cloned trail mesh
  58189. * @returns a new mesh
  58190. */
  58191. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58192. /**
  58193. * Serializes this trail mesh
  58194. * @param serializationObject object to write serialization to
  58195. */
  58196. serialize(serializationObject: any): void;
  58197. /**
  58198. * Parses a serialized trail mesh
  58199. * @param parsedMesh the serialized mesh
  58200. * @param scene the scene to create the trail mesh in
  58201. * @returns the created trail mesh
  58202. */
  58203. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58204. }
  58205. }
  58206. declare module BABYLON {
  58207. /**
  58208. * Class containing static functions to help procedurally build meshes
  58209. */
  58210. export class TiledBoxBuilder {
  58211. /**
  58212. * Creates a box mesh
  58213. * 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)
  58214. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58216. * * 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
  58217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58218. * @param name defines the name of the mesh
  58219. * @param options defines the options used to create the mesh
  58220. * @param scene defines the hosting scene
  58221. * @returns the box mesh
  58222. */
  58223. static CreateTiledBox(name: string, options: {
  58224. pattern?: number;
  58225. width?: number;
  58226. height?: number;
  58227. depth?: number;
  58228. tileSize?: number;
  58229. tileWidth?: number;
  58230. tileHeight?: number;
  58231. alignHorizontal?: number;
  58232. alignVertical?: number;
  58233. faceUV?: Vector4[];
  58234. faceColors?: Color4[];
  58235. sideOrientation?: number;
  58236. updatable?: boolean;
  58237. }, scene?: Nullable<Scene>): Mesh;
  58238. }
  58239. }
  58240. declare module BABYLON {
  58241. /**
  58242. * Class containing static functions to help procedurally build meshes
  58243. */
  58244. export class TorusKnotBuilder {
  58245. /**
  58246. * Creates a torus knot mesh
  58247. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58248. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58249. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58250. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58252. * * 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
  58253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58254. * @param name defines the name of the mesh
  58255. * @param options defines the options used to create the mesh
  58256. * @param scene defines the hosting scene
  58257. * @returns the torus knot mesh
  58258. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58259. */
  58260. static CreateTorusKnot(name: string, options: {
  58261. radius?: number;
  58262. tube?: number;
  58263. radialSegments?: number;
  58264. tubularSegments?: number;
  58265. p?: number;
  58266. q?: number;
  58267. updatable?: boolean;
  58268. sideOrientation?: number;
  58269. frontUVs?: Vector4;
  58270. backUVs?: Vector4;
  58271. }, scene: any): Mesh;
  58272. }
  58273. }
  58274. declare module BABYLON {
  58275. /**
  58276. * Polygon
  58277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58278. */
  58279. export class Polygon {
  58280. /**
  58281. * Creates a rectangle
  58282. * @param xmin bottom X coord
  58283. * @param ymin bottom Y coord
  58284. * @param xmax top X coord
  58285. * @param ymax top Y coord
  58286. * @returns points that make the resulting rectation
  58287. */
  58288. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58289. /**
  58290. * Creates a circle
  58291. * @param radius radius of circle
  58292. * @param cx scale in x
  58293. * @param cy scale in y
  58294. * @param numberOfSides number of sides that make up the circle
  58295. * @returns points that make the resulting circle
  58296. */
  58297. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58298. /**
  58299. * Creates a polygon from input string
  58300. * @param input Input polygon data
  58301. * @returns the parsed points
  58302. */
  58303. static Parse(input: string): Vector2[];
  58304. /**
  58305. * Starts building a polygon from x and y coordinates
  58306. * @param x x coordinate
  58307. * @param y y coordinate
  58308. * @returns the started path2
  58309. */
  58310. static StartingAt(x: number, y: number): Path2;
  58311. }
  58312. /**
  58313. * Builds a polygon
  58314. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58315. */
  58316. export class PolygonMeshBuilder {
  58317. private _points;
  58318. private _outlinepoints;
  58319. private _holes;
  58320. private _name;
  58321. private _scene;
  58322. private _epoints;
  58323. private _eholes;
  58324. private _addToepoint;
  58325. /**
  58326. * Babylon reference to the earcut plugin.
  58327. */
  58328. bjsEarcut: any;
  58329. /**
  58330. * Creates a PolygonMeshBuilder
  58331. * @param name name of the builder
  58332. * @param contours Path of the polygon
  58333. * @param scene scene to add to when creating the mesh
  58334. * @param earcutInjection can be used to inject your own earcut reference
  58335. */
  58336. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58337. /**
  58338. * Adds a whole within the polygon
  58339. * @param hole Array of points defining the hole
  58340. * @returns this
  58341. */
  58342. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58343. /**
  58344. * Creates the polygon
  58345. * @param updatable If the mesh should be updatable
  58346. * @param depth The depth of the mesh created
  58347. * @returns the created mesh
  58348. */
  58349. build(updatable?: boolean, depth?: number): Mesh;
  58350. /**
  58351. * Creates the polygon
  58352. * @param depth The depth of the mesh created
  58353. * @returns the created VertexData
  58354. */
  58355. buildVertexData(depth?: number): VertexData;
  58356. /**
  58357. * Adds a side to the polygon
  58358. * @param positions points that make the polygon
  58359. * @param normals normals of the polygon
  58360. * @param uvs uvs of the polygon
  58361. * @param indices indices of the polygon
  58362. * @param bounds bounds of the polygon
  58363. * @param points points of the polygon
  58364. * @param depth depth of the polygon
  58365. * @param flip flip of the polygon
  58366. */
  58367. private addSide;
  58368. }
  58369. }
  58370. declare module BABYLON {
  58371. /**
  58372. * Class containing static functions to help procedurally build meshes
  58373. */
  58374. export class PolygonBuilder {
  58375. /**
  58376. * Creates a polygon mesh
  58377. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58378. * * 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
  58379. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58381. * * 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)
  58382. * * Remember you can only change the shape positions, not their number when updating a polygon
  58383. * @param name defines the name of the mesh
  58384. * @param options defines the options used to create the mesh
  58385. * @param scene defines the hosting scene
  58386. * @param earcutInjection can be used to inject your own earcut reference
  58387. * @returns the polygon mesh
  58388. */
  58389. static CreatePolygon(name: string, options: {
  58390. shape: Vector3[];
  58391. holes?: Vector3[][];
  58392. depth?: number;
  58393. faceUV?: Vector4[];
  58394. faceColors?: Color4[];
  58395. updatable?: boolean;
  58396. sideOrientation?: number;
  58397. frontUVs?: Vector4;
  58398. backUVs?: Vector4;
  58399. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58400. /**
  58401. * Creates an extruded polygon mesh, with depth in the Y direction.
  58402. * * 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)
  58403. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58404. * @param name defines the name of the mesh
  58405. * @param options defines the options used to create the mesh
  58406. * @param scene defines the hosting scene
  58407. * @param earcutInjection can be used to inject your own earcut reference
  58408. * @returns the polygon mesh
  58409. */
  58410. static ExtrudePolygon(name: string, options: {
  58411. shape: Vector3[];
  58412. holes?: Vector3[][];
  58413. depth?: number;
  58414. faceUV?: Vector4[];
  58415. faceColors?: Color4[];
  58416. updatable?: boolean;
  58417. sideOrientation?: number;
  58418. frontUVs?: Vector4;
  58419. backUVs?: Vector4;
  58420. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58421. }
  58422. }
  58423. declare module BABYLON {
  58424. /**
  58425. * Class containing static functions to help procedurally build meshes
  58426. */
  58427. export class LatheBuilder {
  58428. /**
  58429. * Creates lathe mesh.
  58430. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58431. * * 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
  58432. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58433. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58434. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58435. * * 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
  58436. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58437. * * 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
  58438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58439. * * 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
  58440. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58442. * @param name defines the name of the mesh
  58443. * @param options defines the options used to create the mesh
  58444. * @param scene defines the hosting scene
  58445. * @returns the lathe mesh
  58446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58447. */
  58448. static CreateLathe(name: string, options: {
  58449. shape: Vector3[];
  58450. radius?: number;
  58451. tessellation?: number;
  58452. clip?: number;
  58453. arc?: number;
  58454. closed?: boolean;
  58455. updatable?: boolean;
  58456. sideOrientation?: number;
  58457. frontUVs?: Vector4;
  58458. backUVs?: Vector4;
  58459. cap?: number;
  58460. invertUV?: boolean;
  58461. }, scene?: Nullable<Scene>): Mesh;
  58462. }
  58463. }
  58464. declare module BABYLON {
  58465. /**
  58466. * Class containing static functions to help procedurally build meshes
  58467. */
  58468. export class TiledPlaneBuilder {
  58469. /**
  58470. * Creates a tiled plane mesh
  58471. * * The parameter `pattern` will, depending on value, do nothing or
  58472. * * * flip (reflect about central vertical) alternate tiles across and up
  58473. * * * flip every tile on alternate rows
  58474. * * * rotate (180 degs) alternate tiles across and up
  58475. * * * rotate every tile on alternate rows
  58476. * * * flip and rotate alternate tiles across and up
  58477. * * * flip and rotate every tile on alternate rows
  58478. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58479. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58480. * * 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
  58481. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58482. * * 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)
  58483. * * 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)
  58484. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58485. * @param name defines the name of the mesh
  58486. * @param options defines the options used to create the mesh
  58487. * @param scene defines the hosting scene
  58488. * @returns the box mesh
  58489. */
  58490. static CreateTiledPlane(name: string, options: {
  58491. pattern?: number;
  58492. tileSize?: number;
  58493. tileWidth?: number;
  58494. tileHeight?: number;
  58495. size?: number;
  58496. width?: number;
  58497. height?: number;
  58498. alignHorizontal?: number;
  58499. alignVertical?: number;
  58500. sideOrientation?: number;
  58501. frontUVs?: Vector4;
  58502. backUVs?: Vector4;
  58503. updatable?: boolean;
  58504. }, scene?: Nullable<Scene>): Mesh;
  58505. }
  58506. }
  58507. declare module BABYLON {
  58508. /**
  58509. * Class containing static functions to help procedurally build meshes
  58510. */
  58511. export class TubeBuilder {
  58512. /**
  58513. * Creates a tube mesh.
  58514. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58515. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58516. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58517. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58518. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58519. * * 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)
  58520. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58521. * * 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
  58522. * * 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
  58523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58524. * * 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
  58525. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58527. * @param name defines the name of the mesh
  58528. * @param options defines the options used to create the mesh
  58529. * @param scene defines the hosting scene
  58530. * @returns the tube mesh
  58531. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58532. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58533. */
  58534. static CreateTube(name: string, options: {
  58535. path: Vector3[];
  58536. radius?: number;
  58537. tessellation?: number;
  58538. radiusFunction?: {
  58539. (i: number, distance: number): number;
  58540. };
  58541. cap?: number;
  58542. arc?: number;
  58543. updatable?: boolean;
  58544. sideOrientation?: number;
  58545. frontUVs?: Vector4;
  58546. backUVs?: Vector4;
  58547. instance?: Mesh;
  58548. invertUV?: boolean;
  58549. }, scene?: Nullable<Scene>): Mesh;
  58550. }
  58551. }
  58552. declare module BABYLON {
  58553. /**
  58554. * Class containing static functions to help procedurally build meshes
  58555. */
  58556. export class IcoSphereBuilder {
  58557. /**
  58558. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58559. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58560. * * 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`)
  58561. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58562. * * 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
  58563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58564. * * 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
  58565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58566. * @param name defines the name of the mesh
  58567. * @param options defines the options used to create the mesh
  58568. * @param scene defines the hosting scene
  58569. * @returns the icosahedron mesh
  58570. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58571. */
  58572. static CreateIcoSphere(name: string, options: {
  58573. radius?: number;
  58574. radiusX?: number;
  58575. radiusY?: number;
  58576. radiusZ?: number;
  58577. flat?: boolean;
  58578. subdivisions?: number;
  58579. sideOrientation?: number;
  58580. frontUVs?: Vector4;
  58581. backUVs?: Vector4;
  58582. updatable?: boolean;
  58583. }, scene?: Nullable<Scene>): Mesh;
  58584. }
  58585. }
  58586. declare module BABYLON {
  58587. /**
  58588. * Class containing static functions to help procedurally build meshes
  58589. */
  58590. export class DecalBuilder {
  58591. /**
  58592. * Creates a decal mesh.
  58593. * 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
  58594. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58595. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58596. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58597. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58598. * @param name defines the name of the mesh
  58599. * @param sourceMesh defines the mesh where the decal must be applied
  58600. * @param options defines the options used to create the mesh
  58601. * @param scene defines the hosting scene
  58602. * @returns the decal mesh
  58603. * @see https://doc.babylonjs.com/how_to/decals
  58604. */
  58605. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58606. position?: Vector3;
  58607. normal?: Vector3;
  58608. size?: Vector3;
  58609. angle?: number;
  58610. }): Mesh;
  58611. }
  58612. }
  58613. declare module BABYLON {
  58614. /**
  58615. * Class containing static functions to help procedurally build meshes
  58616. */
  58617. export class MeshBuilder {
  58618. /**
  58619. * Creates a box mesh
  58620. * * The parameter `size` sets the size (float) of each box side (default 1)
  58621. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58622. * * 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)
  58623. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58625. * * 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
  58626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58627. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58628. * @param name defines the name of the mesh
  58629. * @param options defines the options used to create the mesh
  58630. * @param scene defines the hosting scene
  58631. * @returns the box mesh
  58632. */
  58633. static CreateBox(name: string, options: {
  58634. size?: number;
  58635. width?: number;
  58636. height?: number;
  58637. depth?: number;
  58638. faceUV?: Vector4[];
  58639. faceColors?: Color4[];
  58640. sideOrientation?: number;
  58641. frontUVs?: Vector4;
  58642. backUVs?: Vector4;
  58643. updatable?: boolean;
  58644. }, scene?: Nullable<Scene>): Mesh;
  58645. /**
  58646. * Creates a tiled box mesh
  58647. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58649. * @param name defines the name of the mesh
  58650. * @param options defines the options used to create the mesh
  58651. * @param scene defines the hosting scene
  58652. * @returns the tiled box mesh
  58653. */
  58654. static CreateTiledBox(name: string, options: {
  58655. pattern?: number;
  58656. size?: number;
  58657. width?: number;
  58658. height?: number;
  58659. depth: number;
  58660. tileSize?: number;
  58661. tileWidth?: number;
  58662. tileHeight?: number;
  58663. faceUV?: Vector4[];
  58664. faceColors?: Color4[];
  58665. alignHorizontal?: number;
  58666. alignVertical?: number;
  58667. sideOrientation?: number;
  58668. updatable?: boolean;
  58669. }, scene?: Nullable<Scene>): Mesh;
  58670. /**
  58671. * Creates a sphere mesh
  58672. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58673. * * 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`)
  58674. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58675. * * 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
  58676. * * 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)
  58677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58678. * * 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
  58679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58680. * @param name defines the name of the mesh
  58681. * @param options defines the options used to create the mesh
  58682. * @param scene defines the hosting scene
  58683. * @returns the sphere mesh
  58684. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58685. */
  58686. static CreateSphere(name: string, options: {
  58687. segments?: number;
  58688. diameter?: number;
  58689. diameterX?: number;
  58690. diameterY?: number;
  58691. diameterZ?: number;
  58692. arc?: number;
  58693. slice?: number;
  58694. sideOrientation?: number;
  58695. frontUVs?: Vector4;
  58696. backUVs?: Vector4;
  58697. updatable?: boolean;
  58698. }, scene?: Nullable<Scene>): Mesh;
  58699. /**
  58700. * Creates a plane polygonal mesh. By default, this is a disc
  58701. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58702. * * 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
  58703. * * 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
  58704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58705. * * 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
  58706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58707. * @param name defines the name of the mesh
  58708. * @param options defines the options used to create the mesh
  58709. * @param scene defines the hosting scene
  58710. * @returns the plane polygonal mesh
  58711. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58712. */
  58713. static CreateDisc(name: string, options: {
  58714. radius?: number;
  58715. tessellation?: number;
  58716. arc?: number;
  58717. updatable?: boolean;
  58718. sideOrientation?: number;
  58719. frontUVs?: Vector4;
  58720. backUVs?: Vector4;
  58721. }, scene?: Nullable<Scene>): Mesh;
  58722. /**
  58723. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58724. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58725. * * 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`)
  58726. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58727. * * 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
  58728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58729. * * 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
  58730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58731. * @param name defines the name of the mesh
  58732. * @param options defines the options used to create the mesh
  58733. * @param scene defines the hosting scene
  58734. * @returns the icosahedron mesh
  58735. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58736. */
  58737. static CreateIcoSphere(name: string, options: {
  58738. radius?: number;
  58739. radiusX?: number;
  58740. radiusY?: number;
  58741. radiusZ?: number;
  58742. flat?: boolean;
  58743. subdivisions?: number;
  58744. sideOrientation?: number;
  58745. frontUVs?: Vector4;
  58746. backUVs?: Vector4;
  58747. updatable?: boolean;
  58748. }, scene?: Nullable<Scene>): Mesh;
  58749. /**
  58750. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58751. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58752. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58753. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58754. * * 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
  58755. * * 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
  58756. * * 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
  58757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58758. * * 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
  58759. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58760. * * 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
  58761. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58762. * * 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
  58763. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58765. * @param name defines the name of the mesh
  58766. * @param options defines the options used to create the mesh
  58767. * @param scene defines the hosting scene
  58768. * @returns the ribbon mesh
  58769. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58770. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58771. */
  58772. static CreateRibbon(name: string, options: {
  58773. pathArray: Vector3[][];
  58774. closeArray?: boolean;
  58775. closePath?: boolean;
  58776. offset?: number;
  58777. updatable?: boolean;
  58778. sideOrientation?: number;
  58779. frontUVs?: Vector4;
  58780. backUVs?: Vector4;
  58781. instance?: Mesh;
  58782. invertUV?: boolean;
  58783. uvs?: Vector2[];
  58784. colors?: Color4[];
  58785. }, scene?: Nullable<Scene>): Mesh;
  58786. /**
  58787. * Creates a cylinder or a cone mesh
  58788. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58789. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58790. * * 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.
  58791. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58792. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58793. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58794. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58795. * * 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).
  58796. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58797. * * 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).
  58798. * * 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
  58799. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58800. * * 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
  58801. * * 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.
  58802. * * If `enclose` is false, a ring surface is one element.
  58803. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58804. * * 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
  58805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58806. * * 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
  58807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58808. * @param name defines the name of the mesh
  58809. * @param options defines the options used to create the mesh
  58810. * @param scene defines the hosting scene
  58811. * @returns the cylinder mesh
  58812. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58813. */
  58814. static CreateCylinder(name: string, options: {
  58815. height?: number;
  58816. diameterTop?: number;
  58817. diameterBottom?: number;
  58818. diameter?: number;
  58819. tessellation?: number;
  58820. subdivisions?: number;
  58821. arc?: number;
  58822. faceColors?: Color4[];
  58823. faceUV?: Vector4[];
  58824. updatable?: boolean;
  58825. hasRings?: boolean;
  58826. enclose?: boolean;
  58827. cap?: number;
  58828. sideOrientation?: number;
  58829. frontUVs?: Vector4;
  58830. backUVs?: Vector4;
  58831. }, scene?: Nullable<Scene>): Mesh;
  58832. /**
  58833. * Creates a torus mesh
  58834. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58835. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58836. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58838. * * 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
  58839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58840. * @param name defines the name of the mesh
  58841. * @param options defines the options used to create the mesh
  58842. * @param scene defines the hosting scene
  58843. * @returns the torus mesh
  58844. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58845. */
  58846. static CreateTorus(name: string, options: {
  58847. diameter?: number;
  58848. thickness?: number;
  58849. tessellation?: number;
  58850. updatable?: boolean;
  58851. sideOrientation?: number;
  58852. frontUVs?: Vector4;
  58853. backUVs?: Vector4;
  58854. }, scene?: Nullable<Scene>): Mesh;
  58855. /**
  58856. * Creates a torus knot mesh
  58857. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58858. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58859. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58860. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58862. * * 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
  58863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58864. * @param name defines the name of the mesh
  58865. * @param options defines the options used to create the mesh
  58866. * @param scene defines the hosting scene
  58867. * @returns the torus knot mesh
  58868. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58869. */
  58870. static CreateTorusKnot(name: string, options: {
  58871. radius?: number;
  58872. tube?: number;
  58873. radialSegments?: number;
  58874. tubularSegments?: number;
  58875. p?: number;
  58876. q?: number;
  58877. updatable?: boolean;
  58878. sideOrientation?: number;
  58879. frontUVs?: Vector4;
  58880. backUVs?: Vector4;
  58881. }, scene?: Nullable<Scene>): Mesh;
  58882. /**
  58883. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58884. * * 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
  58885. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58886. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58887. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58888. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58889. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58890. * * 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
  58891. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58894. * @param name defines the name of the new line system
  58895. * @param options defines the options used to create the line system
  58896. * @param scene defines the hosting scene
  58897. * @returns a new line system mesh
  58898. */
  58899. static CreateLineSystem(name: string, options: {
  58900. lines: Vector3[][];
  58901. updatable?: boolean;
  58902. instance?: Nullable<LinesMesh>;
  58903. colors?: Nullable<Color4[][]>;
  58904. useVertexAlpha?: boolean;
  58905. }, scene: Nullable<Scene>): LinesMesh;
  58906. /**
  58907. * Creates a line mesh
  58908. * 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
  58909. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58910. * * The parameter `points` is an array successive Vector3
  58911. * * 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
  58912. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58913. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58914. * * When updating an instance, remember that only point positions can change, not the number of points
  58915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58917. * @param name defines the name of the new line system
  58918. * @param options defines the options used to create the line system
  58919. * @param scene defines the hosting scene
  58920. * @returns a new line mesh
  58921. */
  58922. static CreateLines(name: string, options: {
  58923. points: Vector3[];
  58924. updatable?: boolean;
  58925. instance?: Nullable<LinesMesh>;
  58926. colors?: Color4[];
  58927. useVertexAlpha?: boolean;
  58928. }, scene?: Nullable<Scene>): LinesMesh;
  58929. /**
  58930. * Creates a dashed line mesh
  58931. * * 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
  58932. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58933. * * The parameter `points` is an array successive Vector3
  58934. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58935. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58936. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58937. * * 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
  58938. * * When updating an instance, remember that only point positions can change, not the number of points
  58939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58940. * @param name defines the name of the mesh
  58941. * @param options defines the options used to create the mesh
  58942. * @param scene defines the hosting scene
  58943. * @returns the dashed line mesh
  58944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58945. */
  58946. static CreateDashedLines(name: string, options: {
  58947. points: Vector3[];
  58948. dashSize?: number;
  58949. gapSize?: number;
  58950. dashNb?: number;
  58951. updatable?: boolean;
  58952. instance?: LinesMesh;
  58953. }, scene?: Nullable<Scene>): LinesMesh;
  58954. /**
  58955. * 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.
  58956. * * 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.
  58957. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58958. * * 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.
  58959. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58960. * * 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
  58961. * * 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
  58962. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58964. * * 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
  58965. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58967. * @param name defines the name of the mesh
  58968. * @param options defines the options used to create the mesh
  58969. * @param scene defines the hosting scene
  58970. * @returns the extruded shape mesh
  58971. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58972. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58973. */
  58974. static ExtrudeShape(name: string, options: {
  58975. shape: Vector3[];
  58976. path: Vector3[];
  58977. scale?: number;
  58978. rotation?: number;
  58979. cap?: number;
  58980. updatable?: boolean;
  58981. sideOrientation?: number;
  58982. frontUVs?: Vector4;
  58983. backUVs?: Vector4;
  58984. instance?: Mesh;
  58985. invertUV?: boolean;
  58986. }, scene?: Nullable<Scene>): Mesh;
  58987. /**
  58988. * Creates an custom extruded shape mesh.
  58989. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58990. * * 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.
  58991. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58992. * * 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
  58993. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58994. * * 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
  58995. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58996. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58997. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58998. * * 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
  58999. * * 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
  59000. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59002. * * 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
  59003. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59005. * @param name defines the name of the mesh
  59006. * @param options defines the options used to create the mesh
  59007. * @param scene defines the hosting scene
  59008. * @returns the custom extruded shape mesh
  59009. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59010. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59011. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59012. */
  59013. static ExtrudeShapeCustom(name: string, options: {
  59014. shape: Vector3[];
  59015. path: Vector3[];
  59016. scaleFunction?: any;
  59017. rotationFunction?: any;
  59018. ribbonCloseArray?: boolean;
  59019. ribbonClosePath?: boolean;
  59020. cap?: number;
  59021. updatable?: boolean;
  59022. sideOrientation?: number;
  59023. frontUVs?: Vector4;
  59024. backUVs?: Vector4;
  59025. instance?: Mesh;
  59026. invertUV?: boolean;
  59027. }, scene?: Nullable<Scene>): Mesh;
  59028. /**
  59029. * Creates lathe mesh.
  59030. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59031. * * 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
  59032. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59033. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59034. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59035. * * 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
  59036. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59037. * * 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
  59038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59039. * * 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
  59040. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59042. * @param name defines the name of the mesh
  59043. * @param options defines the options used to create the mesh
  59044. * @param scene defines the hosting scene
  59045. * @returns the lathe mesh
  59046. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59047. */
  59048. static CreateLathe(name: string, options: {
  59049. shape: Vector3[];
  59050. radius?: number;
  59051. tessellation?: number;
  59052. clip?: number;
  59053. arc?: number;
  59054. closed?: boolean;
  59055. updatable?: boolean;
  59056. sideOrientation?: number;
  59057. frontUVs?: Vector4;
  59058. backUVs?: Vector4;
  59059. cap?: number;
  59060. invertUV?: boolean;
  59061. }, scene?: Nullable<Scene>): Mesh;
  59062. /**
  59063. * Creates a tiled plane mesh
  59064. * * You can set a limited pattern arrangement with the tiles
  59065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59066. * * 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
  59067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59068. * @param name defines the name of the mesh
  59069. * @param options defines the options used to create the mesh
  59070. * @param scene defines the hosting scene
  59071. * @returns the plane mesh
  59072. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59073. */
  59074. static CreateTiledPlane(name: string, options: {
  59075. pattern?: number;
  59076. tileSize?: number;
  59077. tileWidth?: number;
  59078. tileHeight?: number;
  59079. size?: number;
  59080. width?: number;
  59081. height?: number;
  59082. alignHorizontal?: number;
  59083. alignVertical?: number;
  59084. sideOrientation?: number;
  59085. frontUVs?: Vector4;
  59086. backUVs?: Vector4;
  59087. updatable?: boolean;
  59088. }, scene?: Nullable<Scene>): Mesh;
  59089. /**
  59090. * Creates a plane mesh
  59091. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59092. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59093. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59095. * * 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
  59096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59097. * @param name defines the name of the mesh
  59098. * @param options defines the options used to create the mesh
  59099. * @param scene defines the hosting scene
  59100. * @returns the plane mesh
  59101. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59102. */
  59103. static CreatePlane(name: string, options: {
  59104. size?: number;
  59105. width?: number;
  59106. height?: number;
  59107. sideOrientation?: number;
  59108. frontUVs?: Vector4;
  59109. backUVs?: Vector4;
  59110. updatable?: boolean;
  59111. sourcePlane?: Plane;
  59112. }, scene?: Nullable<Scene>): Mesh;
  59113. /**
  59114. * Creates a ground mesh
  59115. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59116. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59118. * @param name defines the name of the mesh
  59119. * @param options defines the options used to create the mesh
  59120. * @param scene defines the hosting scene
  59121. * @returns the ground mesh
  59122. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59123. */
  59124. static CreateGround(name: string, options: {
  59125. width?: number;
  59126. height?: number;
  59127. subdivisions?: number;
  59128. subdivisionsX?: number;
  59129. subdivisionsY?: number;
  59130. updatable?: boolean;
  59131. }, scene?: Nullable<Scene>): Mesh;
  59132. /**
  59133. * Creates a tiled ground mesh
  59134. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59135. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59136. * * 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
  59137. * * 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
  59138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59139. * @param name defines the name of the mesh
  59140. * @param options defines the options used to create the mesh
  59141. * @param scene defines the hosting scene
  59142. * @returns the tiled ground mesh
  59143. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59144. */
  59145. static CreateTiledGround(name: string, options: {
  59146. xmin: number;
  59147. zmin: number;
  59148. xmax: number;
  59149. zmax: number;
  59150. subdivisions?: {
  59151. w: number;
  59152. h: number;
  59153. };
  59154. precision?: {
  59155. w: number;
  59156. h: number;
  59157. };
  59158. updatable?: boolean;
  59159. }, scene?: Nullable<Scene>): Mesh;
  59160. /**
  59161. * Creates a ground mesh from a height map
  59162. * * The parameter `url` sets the URL of the height map image resource.
  59163. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59164. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59165. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59166. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59167. * * 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.
  59168. * * 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).
  59169. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59171. * @param name defines the name of the mesh
  59172. * @param url defines the url to the height map
  59173. * @param options defines the options used to create the mesh
  59174. * @param scene defines the hosting scene
  59175. * @returns the ground mesh
  59176. * @see https://doc.babylonjs.com/babylon101/height_map
  59177. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59178. */
  59179. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59180. width?: number;
  59181. height?: number;
  59182. subdivisions?: number;
  59183. minHeight?: number;
  59184. maxHeight?: number;
  59185. colorFilter?: Color3;
  59186. alphaFilter?: number;
  59187. updatable?: boolean;
  59188. onReady?: (mesh: GroundMesh) => void;
  59189. }, scene?: Nullable<Scene>): GroundMesh;
  59190. /**
  59191. * Creates a polygon mesh
  59192. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59193. * * 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
  59194. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59196. * * 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)
  59197. * * Remember you can only change the shape positions, not their number when updating a polygon
  59198. * @param name defines the name of the mesh
  59199. * @param options defines the options used to create the mesh
  59200. * @param scene defines the hosting scene
  59201. * @param earcutInjection can be used to inject your own earcut reference
  59202. * @returns the polygon mesh
  59203. */
  59204. static CreatePolygon(name: string, options: {
  59205. shape: Vector3[];
  59206. holes?: Vector3[][];
  59207. depth?: number;
  59208. faceUV?: Vector4[];
  59209. faceColors?: Color4[];
  59210. updatable?: boolean;
  59211. sideOrientation?: number;
  59212. frontUVs?: Vector4;
  59213. backUVs?: Vector4;
  59214. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59215. /**
  59216. * Creates an extruded polygon mesh, with depth in the Y direction.
  59217. * * 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)
  59218. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59219. * @param name defines the name of the mesh
  59220. * @param options defines the options used to create the mesh
  59221. * @param scene defines the hosting scene
  59222. * @param earcutInjection can be used to inject your own earcut reference
  59223. * @returns the polygon mesh
  59224. */
  59225. static ExtrudePolygon(name: string, options: {
  59226. shape: Vector3[];
  59227. holes?: Vector3[][];
  59228. depth?: number;
  59229. faceUV?: Vector4[];
  59230. faceColors?: Color4[];
  59231. updatable?: boolean;
  59232. sideOrientation?: number;
  59233. frontUVs?: Vector4;
  59234. backUVs?: Vector4;
  59235. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59236. /**
  59237. * Creates a tube mesh.
  59238. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59239. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59240. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59241. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59242. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59243. * * 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)
  59244. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59245. * * 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
  59246. * * 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
  59247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59248. * * 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
  59249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59251. * @param name defines the name of the mesh
  59252. * @param options defines the options used to create the mesh
  59253. * @param scene defines the hosting scene
  59254. * @returns the tube mesh
  59255. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59256. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59257. */
  59258. static CreateTube(name: string, options: {
  59259. path: Vector3[];
  59260. radius?: number;
  59261. tessellation?: number;
  59262. radiusFunction?: {
  59263. (i: number, distance: number): number;
  59264. };
  59265. cap?: number;
  59266. arc?: number;
  59267. updatable?: boolean;
  59268. sideOrientation?: number;
  59269. frontUVs?: Vector4;
  59270. backUVs?: Vector4;
  59271. instance?: Mesh;
  59272. invertUV?: boolean;
  59273. }, scene?: Nullable<Scene>): Mesh;
  59274. /**
  59275. * Creates a polyhedron mesh
  59276. * * 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
  59277. * * The parameter `size` (positive float, default 1) sets the polygon size
  59278. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59279. * * 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`
  59280. * * 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
  59281. * * 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)`)
  59282. * * 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
  59283. * * 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
  59284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59285. * * 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
  59286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59287. * @param name defines the name of the mesh
  59288. * @param options defines the options used to create the mesh
  59289. * @param scene defines the hosting scene
  59290. * @returns the polyhedron mesh
  59291. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59292. */
  59293. static CreatePolyhedron(name: string, options: {
  59294. type?: number;
  59295. size?: number;
  59296. sizeX?: number;
  59297. sizeY?: number;
  59298. sizeZ?: number;
  59299. custom?: any;
  59300. faceUV?: Vector4[];
  59301. faceColors?: Color4[];
  59302. flat?: boolean;
  59303. updatable?: boolean;
  59304. sideOrientation?: number;
  59305. frontUVs?: Vector4;
  59306. backUVs?: Vector4;
  59307. }, scene?: Nullable<Scene>): Mesh;
  59308. /**
  59309. * Creates a decal mesh.
  59310. * 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
  59311. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59312. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59313. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59314. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59315. * @param name defines the name of the mesh
  59316. * @param sourceMesh defines the mesh where the decal must be applied
  59317. * @param options defines the options used to create the mesh
  59318. * @param scene defines the hosting scene
  59319. * @returns the decal mesh
  59320. * @see https://doc.babylonjs.com/how_to/decals
  59321. */
  59322. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59323. position?: Vector3;
  59324. normal?: Vector3;
  59325. size?: Vector3;
  59326. angle?: number;
  59327. }): Mesh;
  59328. }
  59329. }
  59330. declare module BABYLON {
  59331. /**
  59332. * A simplifier interface for future simplification implementations
  59333. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59334. */
  59335. export interface ISimplifier {
  59336. /**
  59337. * Simplification of a given mesh according to the given settings.
  59338. * Since this requires computation, it is assumed that the function runs async.
  59339. * @param settings The settings of the simplification, including quality and distance
  59340. * @param successCallback A callback that will be called after the mesh was simplified.
  59341. * @param errorCallback in case of an error, this callback will be called. optional.
  59342. */
  59343. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59344. }
  59345. /**
  59346. * Expected simplification settings.
  59347. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59348. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59349. */
  59350. export interface ISimplificationSettings {
  59351. /**
  59352. * Gets or sets the expected quality
  59353. */
  59354. quality: number;
  59355. /**
  59356. * Gets or sets the distance when this optimized version should be used
  59357. */
  59358. distance: number;
  59359. /**
  59360. * Gets an already optimized mesh
  59361. */
  59362. optimizeMesh?: boolean;
  59363. }
  59364. /**
  59365. * Class used to specify simplification options
  59366. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59367. */
  59368. export class SimplificationSettings implements ISimplificationSettings {
  59369. /** expected quality */
  59370. quality: number;
  59371. /** distance when this optimized version should be used */
  59372. distance: number;
  59373. /** already optimized mesh */
  59374. optimizeMesh?: boolean | undefined;
  59375. /**
  59376. * Creates a SimplificationSettings
  59377. * @param quality expected quality
  59378. * @param distance distance when this optimized version should be used
  59379. * @param optimizeMesh already optimized mesh
  59380. */
  59381. constructor(
  59382. /** expected quality */
  59383. quality: number,
  59384. /** distance when this optimized version should be used */
  59385. distance: number,
  59386. /** already optimized mesh */
  59387. optimizeMesh?: boolean | undefined);
  59388. }
  59389. /**
  59390. * Interface used to define a simplification task
  59391. */
  59392. export interface ISimplificationTask {
  59393. /**
  59394. * Array of settings
  59395. */
  59396. settings: Array<ISimplificationSettings>;
  59397. /**
  59398. * Simplification type
  59399. */
  59400. simplificationType: SimplificationType;
  59401. /**
  59402. * Mesh to simplify
  59403. */
  59404. mesh: Mesh;
  59405. /**
  59406. * Callback called on success
  59407. */
  59408. successCallback?: () => void;
  59409. /**
  59410. * Defines if parallel processing can be used
  59411. */
  59412. parallelProcessing: boolean;
  59413. }
  59414. /**
  59415. * Queue used to order the simplification tasks
  59416. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59417. */
  59418. export class SimplificationQueue {
  59419. private _simplificationArray;
  59420. /**
  59421. * Gets a boolean indicating that the process is still running
  59422. */
  59423. running: boolean;
  59424. /**
  59425. * Creates a new queue
  59426. */
  59427. constructor();
  59428. /**
  59429. * Adds a new simplification task
  59430. * @param task defines a task to add
  59431. */
  59432. addTask(task: ISimplificationTask): void;
  59433. /**
  59434. * Execute next task
  59435. */
  59436. executeNext(): void;
  59437. /**
  59438. * Execute a simplification task
  59439. * @param task defines the task to run
  59440. */
  59441. runSimplification(task: ISimplificationTask): void;
  59442. private getSimplifier;
  59443. }
  59444. /**
  59445. * The implemented types of simplification
  59446. * At the moment only Quadratic Error Decimation is implemented
  59447. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59448. */
  59449. export enum SimplificationType {
  59450. /** Quadratic error decimation */
  59451. QUADRATIC = 0
  59452. }
  59453. }
  59454. declare module BABYLON {
  59455. interface Scene {
  59456. /** @hidden (Backing field) */
  59457. _simplificationQueue: SimplificationQueue;
  59458. /**
  59459. * Gets or sets the simplification queue attached to the scene
  59460. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59461. */
  59462. simplificationQueue: SimplificationQueue;
  59463. }
  59464. interface Mesh {
  59465. /**
  59466. * Simplify the mesh according to the given array of settings.
  59467. * Function will return immediately and will simplify async
  59468. * @param settings a collection of simplification settings
  59469. * @param parallelProcessing should all levels calculate parallel or one after the other
  59470. * @param simplificationType the type of simplification to run
  59471. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59472. * @returns the current mesh
  59473. */
  59474. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59475. }
  59476. /**
  59477. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59478. * created in a scene
  59479. */
  59480. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59481. /**
  59482. * The component name helpfull to identify the component in the list of scene components.
  59483. */
  59484. readonly name: string;
  59485. /**
  59486. * The scene the component belongs to.
  59487. */
  59488. scene: Scene;
  59489. /**
  59490. * Creates a new instance of the component for the given scene
  59491. * @param scene Defines the scene to register the component in
  59492. */
  59493. constructor(scene: Scene);
  59494. /**
  59495. * Registers the component in a given scene
  59496. */
  59497. register(): void;
  59498. /**
  59499. * Rebuilds the elements related to this component in case of
  59500. * context lost for instance.
  59501. */
  59502. rebuild(): void;
  59503. /**
  59504. * Disposes the component and the associated ressources
  59505. */
  59506. dispose(): void;
  59507. private _beforeCameraUpdate;
  59508. }
  59509. }
  59510. declare module BABYLON {
  59511. /**
  59512. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59513. */
  59514. export interface INavigationEnginePlugin {
  59515. /**
  59516. * plugin name
  59517. */
  59518. name: string;
  59519. /**
  59520. * Creates a navigation mesh
  59521. * @param meshes array of all the geometry used to compute the navigatio mesh
  59522. * @param parameters bunch of parameters used to filter geometry
  59523. */
  59524. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59525. /**
  59526. * Create a navigation mesh debug mesh
  59527. * @param scene is where the mesh will be added
  59528. * @returns debug display mesh
  59529. */
  59530. createDebugNavMesh(scene: Scene): Mesh;
  59531. /**
  59532. * Get a navigation mesh constrained position, closest to the parameter position
  59533. * @param position world position
  59534. * @returns the closest point to position constrained by the navigation mesh
  59535. */
  59536. getClosestPoint(position: Vector3): Vector3;
  59537. /**
  59538. * Get a navigation mesh constrained position, within a particular radius
  59539. * @param position world position
  59540. * @param maxRadius the maximum distance to the constrained world position
  59541. * @returns the closest point to position constrained by the navigation mesh
  59542. */
  59543. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59544. /**
  59545. * Compute the final position from a segment made of destination-position
  59546. * @param position world position
  59547. * @param destination world position
  59548. * @returns the resulting point along the navmesh
  59549. */
  59550. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59551. /**
  59552. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59553. * @param start world position
  59554. * @param end world position
  59555. * @returns array containing world position composing the path
  59556. */
  59557. computePath(start: Vector3, end: Vector3): Vector3[];
  59558. /**
  59559. * If this plugin is supported
  59560. * @returns true if plugin is supported
  59561. */
  59562. isSupported(): boolean;
  59563. /**
  59564. * Create a new Crowd so you can add agents
  59565. * @param maxAgents the maximum agent count in the crowd
  59566. * @param maxAgentRadius the maximum radius an agent can have
  59567. * @param scene to attach the crowd to
  59568. * @returns the crowd you can add agents to
  59569. */
  59570. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59571. /**
  59572. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59573. * The queries will try to find a solution within those bounds
  59574. * default is (1,1,1)
  59575. * @param extent x,y,z value that define the extent around the queries point of reference
  59576. */
  59577. setDefaultQueryExtent(extent: Vector3): void;
  59578. /**
  59579. * Get the Bounding box extent specified by setDefaultQueryExtent
  59580. * @returns the box extent values
  59581. */
  59582. getDefaultQueryExtent(): Vector3;
  59583. /**
  59584. * Release all resources
  59585. */
  59586. dispose(): void;
  59587. }
  59588. /**
  59589. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59590. */
  59591. export interface ICrowd {
  59592. /**
  59593. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59594. * You can attach anything to that node. The node position is updated in the scene update tick.
  59595. * @param pos world position that will be constrained by the navigation mesh
  59596. * @param parameters agent parameters
  59597. * @param transform hooked to the agent that will be update by the scene
  59598. * @returns agent index
  59599. */
  59600. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59601. /**
  59602. * Returns the agent position in world space
  59603. * @param index agent index returned by addAgent
  59604. * @returns world space position
  59605. */
  59606. getAgentPosition(index: number): Vector3;
  59607. /**
  59608. * Gets the agent velocity in world space
  59609. * @param index agent index returned by addAgent
  59610. * @returns world space velocity
  59611. */
  59612. getAgentVelocity(index: number): Vector3;
  59613. /**
  59614. * remove a particular agent previously created
  59615. * @param index agent index returned by addAgent
  59616. */
  59617. removeAgent(index: number): void;
  59618. /**
  59619. * get the list of all agents attached to this crowd
  59620. * @returns list of agent indices
  59621. */
  59622. getAgents(): number[];
  59623. /**
  59624. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59625. * @param deltaTime in seconds
  59626. */
  59627. update(deltaTime: number): void;
  59628. /**
  59629. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59630. * @param index agent index returned by addAgent
  59631. * @param destination targeted world position
  59632. */
  59633. agentGoto(index: number, destination: Vector3): void;
  59634. /**
  59635. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59636. * The queries will try to find a solution within those bounds
  59637. * default is (1,1,1)
  59638. * @param extent x,y,z value that define the extent around the queries point of reference
  59639. */
  59640. setDefaultQueryExtent(extent: Vector3): void;
  59641. /**
  59642. * Get the Bounding box extent specified by setDefaultQueryExtent
  59643. * @returns the box extent values
  59644. */
  59645. getDefaultQueryExtent(): Vector3;
  59646. /**
  59647. * Release all resources
  59648. */
  59649. dispose(): void;
  59650. }
  59651. /**
  59652. * Configures an agent
  59653. */
  59654. export interface IAgentParameters {
  59655. /**
  59656. * Agent radius. [Limit: >= 0]
  59657. */
  59658. radius: number;
  59659. /**
  59660. * Agent height. [Limit: > 0]
  59661. */
  59662. height: number;
  59663. /**
  59664. * Maximum allowed acceleration. [Limit: >= 0]
  59665. */
  59666. maxAcceleration: number;
  59667. /**
  59668. * Maximum allowed speed. [Limit: >= 0]
  59669. */
  59670. maxSpeed: number;
  59671. /**
  59672. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59673. */
  59674. collisionQueryRange: number;
  59675. /**
  59676. * The path visibility optimization range. [Limit: > 0]
  59677. */
  59678. pathOptimizationRange: number;
  59679. /**
  59680. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59681. */
  59682. separationWeight: number;
  59683. }
  59684. /**
  59685. * Configures the navigation mesh creation
  59686. */
  59687. export interface INavMeshParameters {
  59688. /**
  59689. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59690. */
  59691. cs: number;
  59692. /**
  59693. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59694. */
  59695. ch: number;
  59696. /**
  59697. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59698. */
  59699. walkableSlopeAngle: number;
  59700. /**
  59701. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59702. * be considered walkable. [Limit: >= 3] [Units: vx]
  59703. */
  59704. walkableHeight: number;
  59705. /**
  59706. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59707. */
  59708. walkableClimb: number;
  59709. /**
  59710. * The distance to erode/shrink the walkable area of the heightfield away from
  59711. * obstructions. [Limit: >=0] [Units: vx]
  59712. */
  59713. walkableRadius: number;
  59714. /**
  59715. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59716. */
  59717. maxEdgeLen: number;
  59718. /**
  59719. * The maximum distance a simplfied contour's border edges should deviate
  59720. * the original raw contour. [Limit: >=0] [Units: vx]
  59721. */
  59722. maxSimplificationError: number;
  59723. /**
  59724. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59725. */
  59726. minRegionArea: number;
  59727. /**
  59728. * Any regions with a span count smaller than this value will, if possible,
  59729. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59730. */
  59731. mergeRegionArea: number;
  59732. /**
  59733. * The maximum number of vertices allowed for polygons generated during the
  59734. * contour to polygon conversion process. [Limit: >= 3]
  59735. */
  59736. maxVertsPerPoly: number;
  59737. /**
  59738. * Sets the sampling distance to use when generating the detail mesh.
  59739. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59740. */
  59741. detailSampleDist: number;
  59742. /**
  59743. * The maximum distance the detail mesh surface should deviate from heightfield
  59744. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59745. */
  59746. detailSampleMaxError: number;
  59747. }
  59748. }
  59749. declare module BABYLON {
  59750. /**
  59751. * RecastJS navigation plugin
  59752. */
  59753. export class RecastJSPlugin implements INavigationEnginePlugin {
  59754. /**
  59755. * Reference to the Recast library
  59756. */
  59757. bjsRECAST: any;
  59758. /**
  59759. * plugin name
  59760. */
  59761. name: string;
  59762. /**
  59763. * the first navmesh created. We might extend this to support multiple navmeshes
  59764. */
  59765. navMesh: any;
  59766. /**
  59767. * Initializes the recastJS plugin
  59768. * @param recastInjection can be used to inject your own recast reference
  59769. */
  59770. constructor(recastInjection?: any);
  59771. /**
  59772. * Creates a navigation mesh
  59773. * @param meshes array of all the geometry used to compute the navigatio mesh
  59774. * @param parameters bunch of parameters used to filter geometry
  59775. */
  59776. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59777. /**
  59778. * Create a navigation mesh debug mesh
  59779. * @param scene is where the mesh will be added
  59780. * @returns debug display mesh
  59781. */
  59782. createDebugNavMesh(scene: Scene): Mesh;
  59783. /**
  59784. * Get a navigation mesh constrained position, closest to the parameter position
  59785. * @param position world position
  59786. * @returns the closest point to position constrained by the navigation mesh
  59787. */
  59788. getClosestPoint(position: Vector3): Vector3;
  59789. /**
  59790. * Get a navigation mesh constrained position, within a particular radius
  59791. * @param position world position
  59792. * @param maxRadius the maximum distance to the constrained world position
  59793. * @returns the closest point to position constrained by the navigation mesh
  59794. */
  59795. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59796. /**
  59797. * Compute the final position from a segment made of destination-position
  59798. * @param position world position
  59799. * @param destination world position
  59800. * @returns the resulting point along the navmesh
  59801. */
  59802. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59803. /**
  59804. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59805. * @param start world position
  59806. * @param end world position
  59807. * @returns array containing world position composing the path
  59808. */
  59809. computePath(start: Vector3, end: Vector3): Vector3[];
  59810. /**
  59811. * Create a new Crowd so you can add agents
  59812. * @param maxAgents the maximum agent count in the crowd
  59813. * @param maxAgentRadius the maximum radius an agent can have
  59814. * @param scene to attach the crowd to
  59815. * @returns the crowd you can add agents to
  59816. */
  59817. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59818. /**
  59819. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59820. * The queries will try to find a solution within those bounds
  59821. * default is (1,1,1)
  59822. * @param extent x,y,z value that define the extent around the queries point of reference
  59823. */
  59824. setDefaultQueryExtent(extent: Vector3): void;
  59825. /**
  59826. * Get the Bounding box extent specified by setDefaultQueryExtent
  59827. * @returns the box extent values
  59828. */
  59829. getDefaultQueryExtent(): Vector3;
  59830. /**
  59831. * Disposes
  59832. */
  59833. dispose(): void;
  59834. /**
  59835. * If this plugin is supported
  59836. * @returns true if plugin is supported
  59837. */
  59838. isSupported(): boolean;
  59839. }
  59840. /**
  59841. * Recast detour crowd implementation
  59842. */
  59843. export class RecastJSCrowd implements ICrowd {
  59844. /**
  59845. * Recast/detour plugin
  59846. */
  59847. bjsRECASTPlugin: RecastJSPlugin;
  59848. /**
  59849. * Link to the detour crowd
  59850. */
  59851. recastCrowd: any;
  59852. /**
  59853. * One transform per agent
  59854. */
  59855. transforms: TransformNode[];
  59856. /**
  59857. * All agents created
  59858. */
  59859. agents: number[];
  59860. /**
  59861. * Link to the scene is kept to unregister the crowd from the scene
  59862. */
  59863. private _scene;
  59864. /**
  59865. * Observer for crowd updates
  59866. */
  59867. private _onBeforeAnimationsObserver;
  59868. /**
  59869. * Constructor
  59870. * @param plugin recastJS plugin
  59871. * @param maxAgents the maximum agent count in the crowd
  59872. * @param maxAgentRadius the maximum radius an agent can have
  59873. * @param scene to attach the crowd to
  59874. * @returns the crowd you can add agents to
  59875. */
  59876. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59877. /**
  59878. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59879. * You can attach anything to that node. The node position is updated in the scene update tick.
  59880. * @param pos world position that will be constrained by the navigation mesh
  59881. * @param parameters agent parameters
  59882. * @param transform hooked to the agent that will be update by the scene
  59883. * @returns agent index
  59884. */
  59885. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59886. /**
  59887. * Returns the agent position in world space
  59888. * @param index agent index returned by addAgent
  59889. * @returns world space position
  59890. */
  59891. getAgentPosition(index: number): Vector3;
  59892. /**
  59893. * Returns the agent velocity in world space
  59894. * @param index agent index returned by addAgent
  59895. * @returns world space velocity
  59896. */
  59897. getAgentVelocity(index: number): Vector3;
  59898. /**
  59899. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59900. * @param index agent index returned by addAgent
  59901. * @param destination targeted world position
  59902. */
  59903. agentGoto(index: number, destination: Vector3): void;
  59904. /**
  59905. * remove a particular agent previously created
  59906. * @param index agent index returned by addAgent
  59907. */
  59908. removeAgent(index: number): void;
  59909. /**
  59910. * get the list of all agents attached to this crowd
  59911. * @returns list of agent indices
  59912. */
  59913. getAgents(): number[];
  59914. /**
  59915. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59916. * @param deltaTime in seconds
  59917. */
  59918. update(deltaTime: number): void;
  59919. /**
  59920. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59921. * The queries will try to find a solution within those bounds
  59922. * default is (1,1,1)
  59923. * @param extent x,y,z value that define the extent around the queries point of reference
  59924. */
  59925. setDefaultQueryExtent(extent: Vector3): void;
  59926. /**
  59927. * Get the Bounding box extent specified by setDefaultQueryExtent
  59928. * @returns the box extent values
  59929. */
  59930. getDefaultQueryExtent(): Vector3;
  59931. /**
  59932. * Release all resources
  59933. */
  59934. dispose(): void;
  59935. }
  59936. }
  59937. declare module BABYLON {
  59938. /**
  59939. * Class used to enable access to IndexedDB
  59940. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59941. */
  59942. export class Database implements IOfflineProvider {
  59943. private _callbackManifestChecked;
  59944. private _currentSceneUrl;
  59945. private _db;
  59946. private _enableSceneOffline;
  59947. private _enableTexturesOffline;
  59948. private _manifestVersionFound;
  59949. private _mustUpdateRessources;
  59950. private _hasReachedQuota;
  59951. private _isSupported;
  59952. private _idbFactory;
  59953. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59954. private static IsUASupportingBlobStorage;
  59955. /**
  59956. * Gets a boolean indicating if Database storate is enabled (off by default)
  59957. */
  59958. static IDBStorageEnabled: boolean;
  59959. /**
  59960. * Gets a boolean indicating if scene must be saved in the database
  59961. */
  59962. readonly enableSceneOffline: boolean;
  59963. /**
  59964. * Gets a boolean indicating if textures must be saved in the database
  59965. */
  59966. readonly enableTexturesOffline: boolean;
  59967. /**
  59968. * Creates a new Database
  59969. * @param urlToScene defines the url to load the scene
  59970. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59971. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59972. */
  59973. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59974. private static _ParseURL;
  59975. private static _ReturnFullUrlLocation;
  59976. private _checkManifestFile;
  59977. /**
  59978. * Open the database and make it available
  59979. * @param successCallback defines the callback to call on success
  59980. * @param errorCallback defines the callback to call on error
  59981. */
  59982. open(successCallback: () => void, errorCallback: () => void): void;
  59983. /**
  59984. * Loads an image from the database
  59985. * @param url defines the url to load from
  59986. * @param image defines the target DOM image
  59987. */
  59988. loadImage(url: string, image: HTMLImageElement): void;
  59989. private _loadImageFromDBAsync;
  59990. private _saveImageIntoDBAsync;
  59991. private _checkVersionFromDB;
  59992. private _loadVersionFromDBAsync;
  59993. private _saveVersionIntoDBAsync;
  59994. /**
  59995. * Loads a file from database
  59996. * @param url defines the URL to load from
  59997. * @param sceneLoaded defines a callback to call on success
  59998. * @param progressCallBack defines a callback to call when progress changed
  59999. * @param errorCallback defines a callback to call on error
  60000. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60001. */
  60002. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60003. private _loadFileAsync;
  60004. private _saveFileAsync;
  60005. /**
  60006. * Validates if xhr data is correct
  60007. * @param xhr defines the request to validate
  60008. * @param dataType defines the expected data type
  60009. * @returns true if data is correct
  60010. */
  60011. private static _ValidateXHRData;
  60012. }
  60013. }
  60014. declare module BABYLON {
  60015. /** @hidden */
  60016. export var gpuUpdateParticlesPixelShader: {
  60017. name: string;
  60018. shader: string;
  60019. };
  60020. }
  60021. declare module BABYLON {
  60022. /** @hidden */
  60023. export var gpuUpdateParticlesVertexShader: {
  60024. name: string;
  60025. shader: string;
  60026. };
  60027. }
  60028. declare module BABYLON {
  60029. /** @hidden */
  60030. export var clipPlaneFragmentDeclaration2: {
  60031. name: string;
  60032. shader: string;
  60033. };
  60034. }
  60035. declare module BABYLON {
  60036. /** @hidden */
  60037. export var gpuRenderParticlesPixelShader: {
  60038. name: string;
  60039. shader: string;
  60040. };
  60041. }
  60042. declare module BABYLON {
  60043. /** @hidden */
  60044. export var clipPlaneVertexDeclaration2: {
  60045. name: string;
  60046. shader: string;
  60047. };
  60048. }
  60049. declare module BABYLON {
  60050. /** @hidden */
  60051. export var gpuRenderParticlesVertexShader: {
  60052. name: string;
  60053. shader: string;
  60054. };
  60055. }
  60056. declare module BABYLON {
  60057. /**
  60058. * This represents a GPU particle system in Babylon
  60059. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60060. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60061. */
  60062. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60063. /**
  60064. * The layer mask we are rendering the particles through.
  60065. */
  60066. layerMask: number;
  60067. private _capacity;
  60068. private _activeCount;
  60069. private _currentActiveCount;
  60070. private _accumulatedCount;
  60071. private _renderEffect;
  60072. private _updateEffect;
  60073. private _buffer0;
  60074. private _buffer1;
  60075. private _spriteBuffer;
  60076. private _updateVAO;
  60077. private _renderVAO;
  60078. private _targetIndex;
  60079. private _sourceBuffer;
  60080. private _targetBuffer;
  60081. private _engine;
  60082. private _currentRenderId;
  60083. private _started;
  60084. private _stopped;
  60085. private _timeDelta;
  60086. private _randomTexture;
  60087. private _randomTexture2;
  60088. private _attributesStrideSize;
  60089. private _updateEffectOptions;
  60090. private _randomTextureSize;
  60091. private _actualFrame;
  60092. private readonly _rawTextureWidth;
  60093. /**
  60094. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60095. */
  60096. static readonly IsSupported: boolean;
  60097. /**
  60098. * An event triggered when the system is disposed.
  60099. */
  60100. onDisposeObservable: Observable<GPUParticleSystem>;
  60101. /**
  60102. * Gets the maximum number of particles active at the same time.
  60103. * @returns The max number of active particles.
  60104. */
  60105. getCapacity(): number;
  60106. /**
  60107. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60108. * to override the particles.
  60109. */
  60110. forceDepthWrite: boolean;
  60111. /**
  60112. * Gets or set the number of active particles
  60113. */
  60114. activeParticleCount: number;
  60115. private _preWarmDone;
  60116. /**
  60117. * Is this system ready to be used/rendered
  60118. * @return true if the system is ready
  60119. */
  60120. isReady(): boolean;
  60121. /**
  60122. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60123. * @returns True if it has been started, otherwise false.
  60124. */
  60125. isStarted(): boolean;
  60126. /**
  60127. * Starts the particle system and begins to emit
  60128. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60129. */
  60130. start(delay?: number): void;
  60131. /**
  60132. * Stops the particle system.
  60133. */
  60134. stop(): void;
  60135. /**
  60136. * Remove all active particles
  60137. */
  60138. reset(): void;
  60139. /**
  60140. * Returns the string "GPUParticleSystem"
  60141. * @returns a string containing the class name
  60142. */
  60143. getClassName(): string;
  60144. private _colorGradientsTexture;
  60145. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60146. /**
  60147. * Adds a new color gradient
  60148. * @param gradient defines the gradient to use (between 0 and 1)
  60149. * @param color1 defines the color to affect to the specified gradient
  60150. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60151. * @returns the current particle system
  60152. */
  60153. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60154. /**
  60155. * Remove a specific color gradient
  60156. * @param gradient defines the gradient to remove
  60157. * @returns the current particle system
  60158. */
  60159. removeColorGradient(gradient: number): GPUParticleSystem;
  60160. private _angularSpeedGradientsTexture;
  60161. private _sizeGradientsTexture;
  60162. private _velocityGradientsTexture;
  60163. private _limitVelocityGradientsTexture;
  60164. private _dragGradientsTexture;
  60165. private _addFactorGradient;
  60166. /**
  60167. * Adds a new size gradient
  60168. * @param gradient defines the gradient to use (between 0 and 1)
  60169. * @param factor defines the size factor to affect to the specified gradient
  60170. * @returns the current particle system
  60171. */
  60172. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60173. /**
  60174. * Remove a specific size gradient
  60175. * @param gradient defines the gradient to remove
  60176. * @returns the current particle system
  60177. */
  60178. removeSizeGradient(gradient: number): GPUParticleSystem;
  60179. /**
  60180. * Adds a new angular speed gradient
  60181. * @param gradient defines the gradient to use (between 0 and 1)
  60182. * @param factor defines the angular speed to affect to the specified gradient
  60183. * @returns the current particle system
  60184. */
  60185. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60186. /**
  60187. * Remove a specific angular speed gradient
  60188. * @param gradient defines the gradient to remove
  60189. * @returns the current particle system
  60190. */
  60191. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60192. /**
  60193. * Adds a new velocity gradient
  60194. * @param gradient defines the gradient to use (between 0 and 1)
  60195. * @param factor defines the velocity to affect to the specified gradient
  60196. * @returns the current particle system
  60197. */
  60198. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60199. /**
  60200. * Remove a specific velocity gradient
  60201. * @param gradient defines the gradient to remove
  60202. * @returns the current particle system
  60203. */
  60204. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60205. /**
  60206. * Adds a new limit velocity gradient
  60207. * @param gradient defines the gradient to use (between 0 and 1)
  60208. * @param factor defines the limit velocity value to affect to the specified gradient
  60209. * @returns the current particle system
  60210. */
  60211. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60212. /**
  60213. * Remove a specific limit velocity gradient
  60214. * @param gradient defines the gradient to remove
  60215. * @returns the current particle system
  60216. */
  60217. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60218. /**
  60219. * Adds a new drag gradient
  60220. * @param gradient defines the gradient to use (between 0 and 1)
  60221. * @param factor defines the drag value to affect to the specified gradient
  60222. * @returns the current particle system
  60223. */
  60224. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60225. /**
  60226. * Remove a specific drag gradient
  60227. * @param gradient defines the gradient to remove
  60228. * @returns the current particle system
  60229. */
  60230. removeDragGradient(gradient: number): GPUParticleSystem;
  60231. /**
  60232. * Not supported by GPUParticleSystem
  60233. * @param gradient defines the gradient to use (between 0 and 1)
  60234. * @param factor defines the emit rate value to affect to the specified gradient
  60235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60236. * @returns the current particle system
  60237. */
  60238. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60239. /**
  60240. * Not supported by GPUParticleSystem
  60241. * @param gradient defines the gradient to remove
  60242. * @returns the current particle system
  60243. */
  60244. removeEmitRateGradient(gradient: number): IParticleSystem;
  60245. /**
  60246. * Not supported by GPUParticleSystem
  60247. * @param gradient defines the gradient to use (between 0 and 1)
  60248. * @param factor defines the start size value to affect to the specified gradient
  60249. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60250. * @returns the current particle system
  60251. */
  60252. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60253. /**
  60254. * Not supported by GPUParticleSystem
  60255. * @param gradient defines the gradient to remove
  60256. * @returns the current particle system
  60257. */
  60258. removeStartSizeGradient(gradient: number): IParticleSystem;
  60259. /**
  60260. * Not supported by GPUParticleSystem
  60261. * @param gradient defines the gradient to use (between 0 and 1)
  60262. * @param min defines the color remap minimal range
  60263. * @param max defines the color remap maximal range
  60264. * @returns the current particle system
  60265. */
  60266. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60267. /**
  60268. * Not supported by GPUParticleSystem
  60269. * @param gradient defines the gradient to remove
  60270. * @returns the current particle system
  60271. */
  60272. removeColorRemapGradient(): IParticleSystem;
  60273. /**
  60274. * Not supported by GPUParticleSystem
  60275. * @param gradient defines the gradient to use (between 0 and 1)
  60276. * @param min defines the alpha remap minimal range
  60277. * @param max defines the alpha remap maximal range
  60278. * @returns the current particle system
  60279. */
  60280. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60281. /**
  60282. * Not supported by GPUParticleSystem
  60283. * @param gradient defines the gradient to remove
  60284. * @returns the current particle system
  60285. */
  60286. removeAlphaRemapGradient(): IParticleSystem;
  60287. /**
  60288. * Not supported by GPUParticleSystem
  60289. * @param gradient defines the gradient to use (between 0 and 1)
  60290. * @param color defines the color to affect to the specified gradient
  60291. * @returns the current particle system
  60292. */
  60293. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60294. /**
  60295. * Not supported by GPUParticleSystem
  60296. * @param gradient defines the gradient to remove
  60297. * @returns the current particle system
  60298. */
  60299. removeRampGradient(): IParticleSystem;
  60300. /**
  60301. * Not supported by GPUParticleSystem
  60302. * @returns the list of ramp gradients
  60303. */
  60304. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60305. /**
  60306. * Not supported by GPUParticleSystem
  60307. * Gets or sets a boolean indicating that ramp gradients must be used
  60308. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60309. */
  60310. useRampGradients: boolean;
  60311. /**
  60312. * Not supported by GPUParticleSystem
  60313. * @param gradient defines the gradient to use (between 0 and 1)
  60314. * @param factor defines the life time factor to affect to the specified gradient
  60315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60316. * @returns the current particle system
  60317. */
  60318. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60319. /**
  60320. * Not supported by GPUParticleSystem
  60321. * @param gradient defines the gradient to remove
  60322. * @returns the current particle system
  60323. */
  60324. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60325. /**
  60326. * Instantiates a GPU particle system.
  60327. * 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.
  60328. * @param name The name of the particle system
  60329. * @param options The options used to create the system
  60330. * @param scene The scene the particle system belongs to
  60331. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60332. */
  60333. constructor(name: string, options: Partial<{
  60334. capacity: number;
  60335. randomTextureSize: number;
  60336. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60337. protected _reset(): void;
  60338. private _createUpdateVAO;
  60339. private _createRenderVAO;
  60340. private _initialize;
  60341. /** @hidden */
  60342. _recreateUpdateEffect(): void;
  60343. /** @hidden */
  60344. _recreateRenderEffect(): void;
  60345. /**
  60346. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60347. * @param preWarm defines if we are in the pre-warmimg phase
  60348. */
  60349. animate(preWarm?: boolean): void;
  60350. private _createFactorGradientTexture;
  60351. private _createSizeGradientTexture;
  60352. private _createAngularSpeedGradientTexture;
  60353. private _createVelocityGradientTexture;
  60354. private _createLimitVelocityGradientTexture;
  60355. private _createDragGradientTexture;
  60356. private _createColorGradientTexture;
  60357. /**
  60358. * Renders the particle system in its current state
  60359. * @param preWarm defines if the system should only update the particles but not render them
  60360. * @returns the current number of particles
  60361. */
  60362. render(preWarm?: boolean): number;
  60363. /**
  60364. * Rebuilds the particle system
  60365. */
  60366. rebuild(): void;
  60367. private _releaseBuffers;
  60368. private _releaseVAOs;
  60369. /**
  60370. * Disposes the particle system and free the associated resources
  60371. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60372. */
  60373. dispose(disposeTexture?: boolean): void;
  60374. /**
  60375. * Clones the particle system.
  60376. * @param name The name of the cloned object
  60377. * @param newEmitter The new emitter to use
  60378. * @returns the cloned particle system
  60379. */
  60380. clone(name: string, newEmitter: any): GPUParticleSystem;
  60381. /**
  60382. * Serializes the particle system to a JSON object.
  60383. * @returns the JSON object
  60384. */
  60385. serialize(): any;
  60386. /**
  60387. * Parses a JSON object to create a GPU particle system.
  60388. * @param parsedParticleSystem The JSON object to parse
  60389. * @param scene The scene to create the particle system in
  60390. * @param rootUrl The root url to use to load external dependencies like texture
  60391. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60392. * @returns the parsed GPU particle system
  60393. */
  60394. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60395. }
  60396. }
  60397. declare module BABYLON {
  60398. /**
  60399. * Represents a set of particle systems working together to create a specific effect
  60400. */
  60401. export class ParticleSystemSet implements IDisposable {
  60402. /**
  60403. * Gets or sets base Assets URL
  60404. */
  60405. static BaseAssetsUrl: string;
  60406. private _emitterCreationOptions;
  60407. private _emitterNode;
  60408. /**
  60409. * Gets the particle system list
  60410. */
  60411. systems: IParticleSystem[];
  60412. /**
  60413. * Gets the emitter node used with this set
  60414. */
  60415. readonly emitterNode: Nullable<TransformNode>;
  60416. /**
  60417. * Creates a new emitter mesh as a sphere
  60418. * @param options defines the options used to create the sphere
  60419. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60420. * @param scene defines the hosting scene
  60421. */
  60422. setEmitterAsSphere(options: {
  60423. diameter: number;
  60424. segments: number;
  60425. color: Color3;
  60426. }, renderingGroupId: number, scene: Scene): void;
  60427. /**
  60428. * Starts all particle systems of the set
  60429. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60430. */
  60431. start(emitter?: AbstractMesh): void;
  60432. /**
  60433. * Release all associated resources
  60434. */
  60435. dispose(): void;
  60436. /**
  60437. * Serialize the set into a JSON compatible object
  60438. * @returns a JSON compatible representation of the set
  60439. */
  60440. serialize(): any;
  60441. /**
  60442. * Parse a new ParticleSystemSet from a serialized source
  60443. * @param data defines a JSON compatible representation of the set
  60444. * @param scene defines the hosting scene
  60445. * @param gpu defines if we want GPU particles or CPU particles
  60446. * @returns a new ParticleSystemSet
  60447. */
  60448. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60449. }
  60450. }
  60451. declare module BABYLON {
  60452. /**
  60453. * This class is made for on one-liner static method to help creating particle system set.
  60454. */
  60455. export class ParticleHelper {
  60456. /**
  60457. * Gets or sets base Assets URL
  60458. */
  60459. static BaseAssetsUrl: string;
  60460. /**
  60461. * Create a default particle system that you can tweak
  60462. * @param emitter defines the emitter to use
  60463. * @param capacity defines the system capacity (default is 500 particles)
  60464. * @param scene defines the hosting scene
  60465. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60466. * @returns the new Particle system
  60467. */
  60468. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60469. /**
  60470. * This is the main static method (one-liner) of this helper to create different particle systems
  60471. * @param type This string represents the type to the particle system to create
  60472. * @param scene The scene where the particle system should live
  60473. * @param gpu If the system will use gpu
  60474. * @returns the ParticleSystemSet created
  60475. */
  60476. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60477. /**
  60478. * Static function used to export a particle system to a ParticleSystemSet variable.
  60479. * Please note that the emitter shape is not exported
  60480. * @param systems defines the particle systems to export
  60481. * @returns the created particle system set
  60482. */
  60483. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60484. }
  60485. }
  60486. declare module BABYLON {
  60487. interface Engine {
  60488. /**
  60489. * Create an effect to use with particle systems.
  60490. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60491. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60492. * @param uniformsNames defines a list of attribute names
  60493. * @param samplers defines an array of string used to represent textures
  60494. * @param defines defines the string containing the defines to use to compile the shaders
  60495. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60496. * @param onCompiled defines a function to call when the effect creation is successful
  60497. * @param onError defines a function to call when the effect creation has failed
  60498. * @returns the new Effect
  60499. */
  60500. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60501. }
  60502. interface Mesh {
  60503. /**
  60504. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60505. * @returns an array of IParticleSystem
  60506. */
  60507. getEmittedParticleSystems(): IParticleSystem[];
  60508. /**
  60509. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60510. * @returns an array of IParticleSystem
  60511. */
  60512. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60513. }
  60514. /**
  60515. * @hidden
  60516. */
  60517. export var _IDoNeedToBeInTheBuild: number;
  60518. }
  60519. declare module BABYLON {
  60520. /** Defines the 4 color options */
  60521. export enum PointColor {
  60522. /** color value */
  60523. Color = 2,
  60524. /** uv value */
  60525. UV = 1,
  60526. /** random value */
  60527. Random = 0,
  60528. /** stated value */
  60529. Stated = 3
  60530. }
  60531. /**
  60532. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  60533. * 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.
  60534. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  60535. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  60536. *
  60537. * Full documentation here : TO BE ENTERED
  60538. */
  60539. export class PointsCloudSystem implements IDisposable {
  60540. /**
  60541. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  60542. * Example : var p = SPS.particles[i];
  60543. */
  60544. particles: CloudPoint[];
  60545. /**
  60546. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  60547. */
  60548. nbParticles: number;
  60549. /**
  60550. * This a counter for your own usage. It's not set by any SPS functions.
  60551. */
  60552. counter: number;
  60553. /**
  60554. * The PCS name. This name is also given to the underlying mesh.
  60555. */
  60556. name: string;
  60557. /**
  60558. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  60559. */
  60560. mesh: Mesh;
  60561. /**
  60562. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  60563. * Please read :
  60564. */
  60565. vars: any;
  60566. /**
  60567. * @hidden
  60568. */
  60569. _size: number;
  60570. private _scene;
  60571. private _promises;
  60572. private _positions;
  60573. private _indices;
  60574. private _normals;
  60575. private _colors;
  60576. private _uvs;
  60577. private _indices32;
  60578. private _positions32;
  60579. private _colors32;
  60580. private _uvs32;
  60581. private _updatable;
  60582. private _isVisibilityBoxLocked;
  60583. private _alwaysVisible;
  60584. private _groups;
  60585. private _groupCounter;
  60586. private _computeParticleColor;
  60587. private _computeParticleTexture;
  60588. private _computeParticleRotation;
  60589. private _computeBoundingBox;
  60590. private _isReady;
  60591. /**
  60592. * Creates a PCS (Points Cloud System) object
  60593. * @param name (String) is the PCS name, this will be the underlying mesh name
  60594. * @param pointSize (number) is the size for each point
  60595. * @param scene (Scene) is the scene in which the PCS is added
  60596. * @param options defines the options of the PCS e.g.
  60597. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  60598. */
  60599. constructor(name: string, pointSize: number, scene: Scene, options?: {
  60600. updatable?: boolean;
  60601. });
  60602. /**
  60603. * Builds the PCS underlying mesh. Returns a standard Mesh.
  60604. * If no points were added to the PCS, the returned mesh is just a single point.
  60605. * @returns a promise for the created mesh
  60606. */
  60607. buildMeshAsync(): Promise<Mesh>;
  60608. /**
  60609. * @hidden
  60610. */
  60611. private _buildMesh;
  60612. private _addParticle;
  60613. private _randomUnitVector;
  60614. private _getColorIndicesForCoord;
  60615. private _setPointsColorOrUV;
  60616. private _colorFromTexture;
  60617. private _calculateDensity;
  60618. /**
  60619. * Adds points to the PCS in random positions within a unit sphere
  60620. * @param nb (positive integer) the number of particles to be created from this model
  60621. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  60622. * @returns the number of groups in the system
  60623. */
  60624. addPoints(nb: number, pointFunction?: any): number;
  60625. /**
  60626. * Adds points to the PCS from the surface of the model shape
  60627. * @param mesh is any Mesh object that will be used as a surface model for the points
  60628. * @param nb (positive integer) the number of particles to be created from this model
  60629. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  60630. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  60631. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  60632. * @returns the number of groups in the system
  60633. */
  60634. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  60635. /**
  60636. * Adds points to the PCS inside the model shape
  60637. * @param mesh is any Mesh object that will be used as a surface model for the points
  60638. * @param nb (positive integer) the number of particles to be created from this model
  60639. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  60640. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  60641. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  60642. * @returns the number of groups in the system
  60643. */
  60644. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  60645. /**
  60646. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  60647. * This method calls `updateParticle()` for each particle of the SPS.
  60648. * For an animated SPS, it is usually called within the render loop.
  60649. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  60650. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  60651. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  60652. * @returns the PCS.
  60653. */
  60654. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  60655. /**
  60656. * Disposes the PCS.
  60657. */
  60658. dispose(): void;
  60659. /**
  60660. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  60661. * doc :
  60662. * @returns the PCS.
  60663. */
  60664. refreshVisibleSize(): PointsCloudSystem;
  60665. /**
  60666. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  60667. * @param size the size (float) of the visibility box
  60668. * note : this doesn't lock the PCS mesh bounding box.
  60669. * doc :
  60670. */
  60671. setVisibilityBox(size: number): void;
  60672. /**
  60673. * Gets whether the PCS is always visible or not
  60674. * doc :
  60675. */
  60676. /**
  60677. * Sets the PCS as always visible or not
  60678. * doc :
  60679. */
  60680. isAlwaysVisible: boolean;
  60681. /**
  60682. * Tells to `setParticles()` to compute the particle rotations or not
  60683. * Default value : false. The PCS is faster when it's set to false
  60684. * Note : particle rotations are only applied to parent particles
  60685. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  60686. */
  60687. computeParticleRotation: boolean;
  60688. /**
  60689. * Tells to `setParticles()` to compute the particle colors or not.
  60690. * Default value : true. The PCS is faster when it's set to false.
  60691. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  60692. */
  60693. /**
  60694. * Gets if `setParticles()` computes the particle colors or not.
  60695. * Default value : false. The PCS is faster when it's set to false.
  60696. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  60697. */
  60698. computeParticleColor: boolean;
  60699. /**
  60700. * Gets if `setParticles()` computes the particle textures or not.
  60701. * Default value : false. The PCS is faster when it's set to false.
  60702. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  60703. */
  60704. computeParticleTexture: boolean;
  60705. /**
  60706. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  60707. */
  60708. /**
  60709. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  60710. */
  60711. computeBoundingBox: boolean;
  60712. /**
  60713. * This function does nothing. It may be overwritten to set all the particle first values.
  60714. * The PCS doesn't call this function, you may have to call it by your own.
  60715. * doc :
  60716. */
  60717. initParticles(): void;
  60718. /**
  60719. * This function does nothing. It may be overwritten to recycle a particle
  60720. * The PCS doesn't call this function, you can to call it
  60721. * doc :
  60722. * @param particle The particle to recycle
  60723. * @returns the recycled particle
  60724. */
  60725. recycleParticle(particle: CloudPoint): CloudPoint;
  60726. /**
  60727. * Updates a particle : this function should be overwritten by the user.
  60728. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  60729. * doc :
  60730. * @example : just set a particle position or velocity and recycle conditions
  60731. * @param particle The particle to update
  60732. * @returns the updated particle
  60733. */
  60734. updateParticle(particle: CloudPoint): CloudPoint;
  60735. /**
  60736. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  60737. * This does nothing and may be overwritten by the user.
  60738. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  60739. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  60740. * @param update the boolean update value actually passed to setParticles()
  60741. */
  60742. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  60743. /**
  60744. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  60745. * This will be passed three parameters.
  60746. * This does nothing and may be overwritten by the user.
  60747. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  60748. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  60749. * @param update the boolean update value actually passed to setParticles()
  60750. */
  60751. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  60752. }
  60753. }
  60754. declare module BABYLON {
  60755. /**
  60756. * Represents one particle of a points cloud system.
  60757. */
  60758. export class CloudPoint {
  60759. /**
  60760. * particle global index
  60761. */
  60762. idx: number;
  60763. /**
  60764. * The color of the particle
  60765. */
  60766. color: Nullable<Color4>;
  60767. /**
  60768. * The world space position of the particle.
  60769. */
  60770. position: Vector3;
  60771. /**
  60772. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  60773. */
  60774. rotation: Vector3;
  60775. /**
  60776. * The world space rotation quaternion of the particle.
  60777. */
  60778. rotationQuaternion: Nullable<Quaternion>;
  60779. /**
  60780. * The uv of the particle.
  60781. */
  60782. uv: Nullable<Vector2>;
  60783. /**
  60784. * The current speed of the particle.
  60785. */
  60786. velocity: Vector3;
  60787. /**
  60788. * The pivot point in the particle local space.
  60789. */
  60790. pivot: Vector3;
  60791. /**
  60792. * Must the particle be translated from its pivot point in its local space ?
  60793. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  60794. * Default : false
  60795. */
  60796. translateFromPivot: boolean;
  60797. /**
  60798. * Index of this particle in the global "positions" array (Internal use)
  60799. * @hidden
  60800. */
  60801. _pos: number;
  60802. /**
  60803. * @hidden Index of this particle in the global "indices" array (Internal use)
  60804. */
  60805. _ind: number;
  60806. /**
  60807. * Group this particle belongs to
  60808. */
  60809. _group: PointsGroup;
  60810. /**
  60811. * Group id of this particle
  60812. */
  60813. groupId: number;
  60814. /**
  60815. * Index of the particle in its group id (Internal use)
  60816. */
  60817. idxInGroup: number;
  60818. /**
  60819. * @hidden Particle BoundingInfo object (Internal use)
  60820. */
  60821. _boundingInfo: BoundingInfo;
  60822. /**
  60823. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  60824. */
  60825. _pcs: PointsCloudSystem;
  60826. /**
  60827. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  60828. */
  60829. _stillInvisible: boolean;
  60830. /**
  60831. * @hidden Last computed particle rotation matrix
  60832. */
  60833. _rotationMatrix: number[];
  60834. /**
  60835. * Parent particle Id, if any.
  60836. * Default null.
  60837. */
  60838. parentId: Nullable<number>;
  60839. /**
  60840. * @hidden Internal global position in the PCS.
  60841. */
  60842. _globalPosition: Vector3;
  60843. /**
  60844. * Creates a Point Cloud object.
  60845. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  60846. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  60847. * @param group (PointsGroup) is the group the particle belongs to
  60848. * @param groupId (integer) is the group identifier in the PCS.
  60849. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  60850. * @param pcs defines the PCS it is associated to
  60851. */
  60852. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  60853. /**
  60854. * get point size
  60855. */
  60856. /**
  60857. * Set point size
  60858. */
  60859. size: Vector3;
  60860. /**
  60861. * Legacy support, changed quaternion to rotationQuaternion
  60862. */
  60863. /**
  60864. * Legacy support, changed quaternion to rotationQuaternion
  60865. */
  60866. quaternion: Nullable<Quaternion>;
  60867. /**
  60868. * Returns a boolean. True if the particle intersects a mesh, else false
  60869. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  60870. * @param target is the object (point or mesh) what the intersection is computed against
  60871. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  60872. * @returns true if it intersects
  60873. */
  60874. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  60875. /**
  60876. * get the rotation matrix of the particle
  60877. * @hidden
  60878. */
  60879. getRotationMatrix(m: Matrix): void;
  60880. }
  60881. /**
  60882. * Represents a group of points in a points cloud system
  60883. * * PCS internal tool, don't use it manually.
  60884. */
  60885. export class PointsGroup {
  60886. /**
  60887. * The group id
  60888. * @hidden
  60889. */
  60890. groupID: number;
  60891. /**
  60892. * image data for group (internal use)
  60893. * @hidden
  60894. */
  60895. _groupImageData: Nullable<ArrayBufferView>;
  60896. /**
  60897. * Image Width (internal use)
  60898. * @hidden
  60899. */
  60900. _groupImgWidth: number;
  60901. /**
  60902. * Image Height (internal use)
  60903. * @hidden
  60904. */
  60905. _groupImgHeight: number;
  60906. /**
  60907. * Custom position function (internal use)
  60908. * @hidden
  60909. */
  60910. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  60911. /**
  60912. * density per facet for surface points
  60913. * @hidden
  60914. */
  60915. _groupDensity: number[];
  60916. /**
  60917. * Only when points are colored by texture carries pointer to texture list array
  60918. * @hidden
  60919. */
  60920. _textureNb: number;
  60921. /**
  60922. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  60923. * PCS internal tool, don't use it manually.
  60924. * @hidden
  60925. */
  60926. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  60927. }
  60928. }
  60929. declare module BABYLON {
  60930. interface Scene {
  60931. /** @hidden (Backing field) */
  60932. _physicsEngine: Nullable<IPhysicsEngine>;
  60933. /** @hidden */
  60934. _physicsTimeAccumulator: number;
  60935. /**
  60936. * Gets the current physics engine
  60937. * @returns a IPhysicsEngine or null if none attached
  60938. */
  60939. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60940. /**
  60941. * Enables physics to the current scene
  60942. * @param gravity defines the scene's gravity for the physics engine
  60943. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60944. * @return a boolean indicating if the physics engine was initialized
  60945. */
  60946. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60947. /**
  60948. * Disables and disposes the physics engine associated with the scene
  60949. */
  60950. disablePhysicsEngine(): void;
  60951. /**
  60952. * Gets a boolean indicating if there is an active physics engine
  60953. * @returns a boolean indicating if there is an active physics engine
  60954. */
  60955. isPhysicsEnabled(): boolean;
  60956. /**
  60957. * Deletes a physics compound impostor
  60958. * @param compound defines the compound to delete
  60959. */
  60960. deleteCompoundImpostor(compound: any): void;
  60961. /**
  60962. * An event triggered when physic simulation is about to be run
  60963. */
  60964. onBeforePhysicsObservable: Observable<Scene>;
  60965. /**
  60966. * An event triggered when physic simulation has been done
  60967. */
  60968. onAfterPhysicsObservable: Observable<Scene>;
  60969. }
  60970. interface AbstractMesh {
  60971. /** @hidden */
  60972. _physicsImpostor: Nullable<PhysicsImpostor>;
  60973. /**
  60974. * Gets or sets impostor used for physic simulation
  60975. * @see http://doc.babylonjs.com/features/physics_engine
  60976. */
  60977. physicsImpostor: Nullable<PhysicsImpostor>;
  60978. /**
  60979. * Gets the current physics impostor
  60980. * @see http://doc.babylonjs.com/features/physics_engine
  60981. * @returns a physics impostor or null
  60982. */
  60983. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60984. /** Apply a physic impulse to the mesh
  60985. * @param force defines the force to apply
  60986. * @param contactPoint defines where to apply the force
  60987. * @returns the current mesh
  60988. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60989. */
  60990. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60991. /**
  60992. * Creates a physic joint between two meshes
  60993. * @param otherMesh defines the other mesh to use
  60994. * @param pivot1 defines the pivot to use on this mesh
  60995. * @param pivot2 defines the pivot to use on the other mesh
  60996. * @param options defines additional options (can be plugin dependent)
  60997. * @returns the current mesh
  60998. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60999. */
  61000. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61001. /** @hidden */
  61002. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61003. }
  61004. /**
  61005. * Defines the physics engine scene component responsible to manage a physics engine
  61006. */
  61007. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61008. /**
  61009. * The component name helpful to identify the component in the list of scene components.
  61010. */
  61011. readonly name: string;
  61012. /**
  61013. * The scene the component belongs to.
  61014. */
  61015. scene: Scene;
  61016. /**
  61017. * Creates a new instance of the component for the given scene
  61018. * @param scene Defines the scene to register the component in
  61019. */
  61020. constructor(scene: Scene);
  61021. /**
  61022. * Registers the component in a given scene
  61023. */
  61024. register(): void;
  61025. /**
  61026. * Rebuilds the elements related to this component in case of
  61027. * context lost for instance.
  61028. */
  61029. rebuild(): void;
  61030. /**
  61031. * Disposes the component and the associated ressources
  61032. */
  61033. dispose(): void;
  61034. }
  61035. }
  61036. declare module BABYLON {
  61037. /**
  61038. * A helper for physics simulations
  61039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61040. */
  61041. export class PhysicsHelper {
  61042. private _scene;
  61043. private _physicsEngine;
  61044. /**
  61045. * Initializes the Physics helper
  61046. * @param scene Babylon.js scene
  61047. */
  61048. constructor(scene: Scene);
  61049. /**
  61050. * Applies a radial explosion impulse
  61051. * @param origin the origin of the explosion
  61052. * @param radiusOrEventOptions the radius or the options of radial explosion
  61053. * @param strength the explosion strength
  61054. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61055. * @returns A physics radial explosion event, or null
  61056. */
  61057. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61058. /**
  61059. * Applies a radial explosion force
  61060. * @param origin the origin of the explosion
  61061. * @param radiusOrEventOptions the radius or the options of radial explosion
  61062. * @param strength the explosion strength
  61063. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61064. * @returns A physics radial explosion event, or null
  61065. */
  61066. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61067. /**
  61068. * Creates a gravitational field
  61069. * @param origin the origin of the explosion
  61070. * @param radiusOrEventOptions the radius or the options of radial explosion
  61071. * @param strength the explosion strength
  61072. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61073. * @returns A physics gravitational field event, or null
  61074. */
  61075. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61076. /**
  61077. * Creates a physics updraft event
  61078. * @param origin the origin of the updraft
  61079. * @param radiusOrEventOptions the radius or the options of the updraft
  61080. * @param strength the strength of the updraft
  61081. * @param height the height of the updraft
  61082. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61083. * @returns A physics updraft event, or null
  61084. */
  61085. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61086. /**
  61087. * Creates a physics vortex event
  61088. * @param origin the of the vortex
  61089. * @param radiusOrEventOptions the radius or the options of the vortex
  61090. * @param strength the strength of the vortex
  61091. * @param height the height of the vortex
  61092. * @returns a Physics vortex event, or null
  61093. * A physics vortex event or null
  61094. */
  61095. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61096. }
  61097. /**
  61098. * Represents a physics radial explosion event
  61099. */
  61100. class PhysicsRadialExplosionEvent {
  61101. private _scene;
  61102. private _options;
  61103. private _sphere;
  61104. private _dataFetched;
  61105. /**
  61106. * Initializes a radial explosioin event
  61107. * @param _scene BabylonJS scene
  61108. * @param _options The options for the vortex event
  61109. */
  61110. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61111. /**
  61112. * Returns the data related to the radial explosion event (sphere).
  61113. * @returns The radial explosion event data
  61114. */
  61115. getData(): PhysicsRadialExplosionEventData;
  61116. /**
  61117. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61118. * @param impostor A physics imposter
  61119. * @param origin the origin of the explosion
  61120. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61121. */
  61122. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61123. /**
  61124. * Triggers affecterd impostors callbacks
  61125. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61126. */
  61127. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61128. /**
  61129. * Disposes the sphere.
  61130. * @param force Specifies if the sphere should be disposed by force
  61131. */
  61132. dispose(force?: boolean): void;
  61133. /*** Helpers ***/
  61134. private _prepareSphere;
  61135. private _intersectsWithSphere;
  61136. }
  61137. /**
  61138. * Represents a gravitational field event
  61139. */
  61140. class PhysicsGravitationalFieldEvent {
  61141. private _physicsHelper;
  61142. private _scene;
  61143. private _origin;
  61144. private _options;
  61145. private _tickCallback;
  61146. private _sphere;
  61147. private _dataFetched;
  61148. /**
  61149. * Initializes the physics gravitational field event
  61150. * @param _physicsHelper A physics helper
  61151. * @param _scene BabylonJS scene
  61152. * @param _origin The origin position of the gravitational field event
  61153. * @param _options The options for the vortex event
  61154. */
  61155. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61156. /**
  61157. * Returns the data related to the gravitational field event (sphere).
  61158. * @returns A gravitational field event
  61159. */
  61160. getData(): PhysicsGravitationalFieldEventData;
  61161. /**
  61162. * Enables the gravitational field.
  61163. */
  61164. enable(): void;
  61165. /**
  61166. * Disables the gravitational field.
  61167. */
  61168. disable(): void;
  61169. /**
  61170. * Disposes the sphere.
  61171. * @param force The force to dispose from the gravitational field event
  61172. */
  61173. dispose(force?: boolean): void;
  61174. private _tick;
  61175. }
  61176. /**
  61177. * Represents a physics updraft event
  61178. */
  61179. class PhysicsUpdraftEvent {
  61180. private _scene;
  61181. private _origin;
  61182. private _options;
  61183. private _physicsEngine;
  61184. private _originTop;
  61185. private _originDirection;
  61186. private _tickCallback;
  61187. private _cylinder;
  61188. private _cylinderPosition;
  61189. private _dataFetched;
  61190. /**
  61191. * Initializes the physics updraft event
  61192. * @param _scene BabylonJS scene
  61193. * @param _origin The origin position of the updraft
  61194. * @param _options The options for the updraft event
  61195. */
  61196. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61197. /**
  61198. * Returns the data related to the updraft event (cylinder).
  61199. * @returns A physics updraft event
  61200. */
  61201. getData(): PhysicsUpdraftEventData;
  61202. /**
  61203. * Enables the updraft.
  61204. */
  61205. enable(): void;
  61206. /**
  61207. * Disables the updraft.
  61208. */
  61209. disable(): void;
  61210. /**
  61211. * Disposes the cylinder.
  61212. * @param force Specifies if the updraft should be disposed by force
  61213. */
  61214. dispose(force?: boolean): void;
  61215. private getImpostorHitData;
  61216. private _tick;
  61217. /*** Helpers ***/
  61218. private _prepareCylinder;
  61219. private _intersectsWithCylinder;
  61220. }
  61221. /**
  61222. * Represents a physics vortex event
  61223. */
  61224. class PhysicsVortexEvent {
  61225. private _scene;
  61226. private _origin;
  61227. private _options;
  61228. private _physicsEngine;
  61229. private _originTop;
  61230. private _tickCallback;
  61231. private _cylinder;
  61232. private _cylinderPosition;
  61233. private _dataFetched;
  61234. /**
  61235. * Initializes the physics vortex event
  61236. * @param _scene The BabylonJS scene
  61237. * @param _origin The origin position of the vortex
  61238. * @param _options The options for the vortex event
  61239. */
  61240. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61241. /**
  61242. * Returns the data related to the vortex event (cylinder).
  61243. * @returns The physics vortex event data
  61244. */
  61245. getData(): PhysicsVortexEventData;
  61246. /**
  61247. * Enables the vortex.
  61248. */
  61249. enable(): void;
  61250. /**
  61251. * Disables the cortex.
  61252. */
  61253. disable(): void;
  61254. /**
  61255. * Disposes the sphere.
  61256. * @param force
  61257. */
  61258. dispose(force?: boolean): void;
  61259. private getImpostorHitData;
  61260. private _tick;
  61261. /*** Helpers ***/
  61262. private _prepareCylinder;
  61263. private _intersectsWithCylinder;
  61264. }
  61265. /**
  61266. * Options fot the radial explosion event
  61267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61268. */
  61269. export class PhysicsRadialExplosionEventOptions {
  61270. /**
  61271. * The radius of the sphere for the radial explosion.
  61272. */
  61273. radius: number;
  61274. /**
  61275. * The strenth of the explosion.
  61276. */
  61277. strength: number;
  61278. /**
  61279. * The strenght of the force in correspondence to the distance of the affected object
  61280. */
  61281. falloff: PhysicsRadialImpulseFalloff;
  61282. /**
  61283. * Sphere options for the radial explosion.
  61284. */
  61285. sphere: {
  61286. segments: number;
  61287. diameter: number;
  61288. };
  61289. /**
  61290. * Sphere options for the radial explosion.
  61291. */
  61292. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61293. }
  61294. /**
  61295. * Options fot the updraft event
  61296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61297. */
  61298. export class PhysicsUpdraftEventOptions {
  61299. /**
  61300. * The radius of the cylinder for the vortex
  61301. */
  61302. radius: number;
  61303. /**
  61304. * The strenth of the updraft.
  61305. */
  61306. strength: number;
  61307. /**
  61308. * The height of the cylinder for the updraft.
  61309. */
  61310. height: number;
  61311. /**
  61312. * The mode for the the updraft.
  61313. */
  61314. updraftMode: PhysicsUpdraftMode;
  61315. }
  61316. /**
  61317. * Options fot the vortex event
  61318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61319. */
  61320. export class PhysicsVortexEventOptions {
  61321. /**
  61322. * The radius of the cylinder for the vortex
  61323. */
  61324. radius: number;
  61325. /**
  61326. * The strenth of the vortex.
  61327. */
  61328. strength: number;
  61329. /**
  61330. * The height of the cylinder for the vortex.
  61331. */
  61332. height: number;
  61333. /**
  61334. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61335. */
  61336. centripetalForceThreshold: number;
  61337. /**
  61338. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61339. */
  61340. centripetalForceMultiplier: number;
  61341. /**
  61342. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61343. */
  61344. centrifugalForceMultiplier: number;
  61345. /**
  61346. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61347. */
  61348. updraftForceMultiplier: number;
  61349. }
  61350. /**
  61351. * The strenght of the force in correspondence to the distance of the affected object
  61352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61353. */
  61354. export enum PhysicsRadialImpulseFalloff {
  61355. /** Defines that impulse is constant in strength across it's whole radius */
  61356. Constant = 0,
  61357. /** Defines that impulse gets weaker if it's further from the origin */
  61358. Linear = 1
  61359. }
  61360. /**
  61361. * The strength of the force in correspondence to the distance of the affected object
  61362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61363. */
  61364. export enum PhysicsUpdraftMode {
  61365. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61366. Center = 0,
  61367. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61368. Perpendicular = 1
  61369. }
  61370. /**
  61371. * Interface for a physics hit data
  61372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61373. */
  61374. export interface PhysicsHitData {
  61375. /**
  61376. * The force applied at the contact point
  61377. */
  61378. force: Vector3;
  61379. /**
  61380. * The contact point
  61381. */
  61382. contactPoint: Vector3;
  61383. /**
  61384. * The distance from the origin to the contact point
  61385. */
  61386. distanceFromOrigin: number;
  61387. }
  61388. /**
  61389. * Interface for radial explosion event data
  61390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61391. */
  61392. export interface PhysicsRadialExplosionEventData {
  61393. /**
  61394. * A sphere used for the radial explosion event
  61395. */
  61396. sphere: Mesh;
  61397. }
  61398. /**
  61399. * Interface for gravitational field event data
  61400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61401. */
  61402. export interface PhysicsGravitationalFieldEventData {
  61403. /**
  61404. * A sphere mesh used for the gravitational field event
  61405. */
  61406. sphere: Mesh;
  61407. }
  61408. /**
  61409. * Interface for updraft event data
  61410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61411. */
  61412. export interface PhysicsUpdraftEventData {
  61413. /**
  61414. * A cylinder used for the updraft event
  61415. */
  61416. cylinder: Mesh;
  61417. }
  61418. /**
  61419. * Interface for vortex event data
  61420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61421. */
  61422. export interface PhysicsVortexEventData {
  61423. /**
  61424. * A cylinder used for the vortex event
  61425. */
  61426. cylinder: Mesh;
  61427. }
  61428. /**
  61429. * Interface for an affected physics impostor
  61430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61431. */
  61432. export interface PhysicsAffectedImpostorWithData {
  61433. /**
  61434. * The impostor affected by the effect
  61435. */
  61436. impostor: PhysicsImpostor;
  61437. /**
  61438. * The data about the hit/horce from the explosion
  61439. */
  61440. hitData: PhysicsHitData;
  61441. }
  61442. }
  61443. declare module BABYLON {
  61444. /** @hidden */
  61445. export var blackAndWhitePixelShader: {
  61446. name: string;
  61447. shader: string;
  61448. };
  61449. }
  61450. declare module BABYLON {
  61451. /**
  61452. * Post process used to render in black and white
  61453. */
  61454. export class BlackAndWhitePostProcess extends PostProcess {
  61455. /**
  61456. * Linear about to convert he result to black and white (default: 1)
  61457. */
  61458. degree: number;
  61459. /**
  61460. * Creates a black and white post process
  61461. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61462. * @param name The name of the effect.
  61463. * @param options The required width/height ratio to downsize to before computing the render pass.
  61464. * @param camera The camera to apply the render pass to.
  61465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61466. * @param engine The engine which the post process will be applied. (default: current engine)
  61467. * @param reusable If the post process can be reused on the same frame. (default: false)
  61468. */
  61469. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61470. }
  61471. }
  61472. declare module BABYLON {
  61473. /**
  61474. * This represents a set of one or more post processes in Babylon.
  61475. * A post process can be used to apply a shader to a texture after it is rendered.
  61476. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61477. */
  61478. export class PostProcessRenderEffect {
  61479. private _postProcesses;
  61480. private _getPostProcesses;
  61481. private _singleInstance;
  61482. private _cameras;
  61483. private _indicesForCamera;
  61484. /**
  61485. * Name of the effect
  61486. * @hidden
  61487. */
  61488. _name: string;
  61489. /**
  61490. * Instantiates a post process render effect.
  61491. * A post process can be used to apply a shader to a texture after it is rendered.
  61492. * @param engine The engine the effect is tied to
  61493. * @param name The name of the effect
  61494. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61495. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61496. */
  61497. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61498. /**
  61499. * Checks if all the post processes in the effect are supported.
  61500. */
  61501. readonly isSupported: boolean;
  61502. /**
  61503. * Updates the current state of the effect
  61504. * @hidden
  61505. */
  61506. _update(): void;
  61507. /**
  61508. * Attaches the effect on cameras
  61509. * @param cameras The camera to attach to.
  61510. * @hidden
  61511. */
  61512. _attachCameras(cameras: Camera): void;
  61513. /**
  61514. * Attaches the effect on cameras
  61515. * @param cameras The camera to attach to.
  61516. * @hidden
  61517. */
  61518. _attachCameras(cameras: Camera[]): void;
  61519. /**
  61520. * Detaches the effect on cameras
  61521. * @param cameras The camera to detatch from.
  61522. * @hidden
  61523. */
  61524. _detachCameras(cameras: Camera): void;
  61525. /**
  61526. * Detatches the effect on cameras
  61527. * @param cameras The camera to detatch from.
  61528. * @hidden
  61529. */
  61530. _detachCameras(cameras: Camera[]): void;
  61531. /**
  61532. * Enables the effect on given cameras
  61533. * @param cameras The camera to enable.
  61534. * @hidden
  61535. */
  61536. _enable(cameras: Camera): void;
  61537. /**
  61538. * Enables the effect on given cameras
  61539. * @param cameras The camera to enable.
  61540. * @hidden
  61541. */
  61542. _enable(cameras: Nullable<Camera[]>): void;
  61543. /**
  61544. * Disables the effect on the given cameras
  61545. * @param cameras The camera to disable.
  61546. * @hidden
  61547. */
  61548. _disable(cameras: Camera): void;
  61549. /**
  61550. * Disables the effect on the given cameras
  61551. * @param cameras The camera to disable.
  61552. * @hidden
  61553. */
  61554. _disable(cameras: Nullable<Camera[]>): void;
  61555. /**
  61556. * Gets a list of the post processes contained in the effect.
  61557. * @param camera The camera to get the post processes on.
  61558. * @returns The list of the post processes in the effect.
  61559. */
  61560. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61561. }
  61562. }
  61563. declare module BABYLON {
  61564. /** @hidden */
  61565. export var extractHighlightsPixelShader: {
  61566. name: string;
  61567. shader: string;
  61568. };
  61569. }
  61570. declare module BABYLON {
  61571. /**
  61572. * 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.
  61573. */
  61574. export class ExtractHighlightsPostProcess extends PostProcess {
  61575. /**
  61576. * The luminance threshold, pixels below this value will be set to black.
  61577. */
  61578. threshold: number;
  61579. /** @hidden */
  61580. _exposure: number;
  61581. /**
  61582. * Post process which has the input texture to be used when performing highlight extraction
  61583. * @hidden
  61584. */
  61585. _inputPostProcess: Nullable<PostProcess>;
  61586. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61587. }
  61588. }
  61589. declare module BABYLON {
  61590. /** @hidden */
  61591. export var bloomMergePixelShader: {
  61592. name: string;
  61593. shader: string;
  61594. };
  61595. }
  61596. declare module BABYLON {
  61597. /**
  61598. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61599. */
  61600. export class BloomMergePostProcess extends PostProcess {
  61601. /** Weight of the bloom to be added to the original input. */
  61602. weight: number;
  61603. /**
  61604. * Creates a new instance of @see BloomMergePostProcess
  61605. * @param name The name of the effect.
  61606. * @param originalFromInput Post process which's input will be used for the merge.
  61607. * @param blurred Blurred highlights post process which's output will be used.
  61608. * @param weight Weight of the bloom to be added to the original input.
  61609. * @param options The required width/height ratio to downsize to before computing the render pass.
  61610. * @param camera The camera to apply the render pass to.
  61611. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61612. * @param engine The engine which the post process will be applied. (default: current engine)
  61613. * @param reusable If the post process can be reused on the same frame. (default: false)
  61614. * @param textureType Type of textures used when performing the post process. (default: 0)
  61615. * @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)
  61616. */
  61617. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61618. /** Weight of the bloom to be added to the original input. */
  61619. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61620. }
  61621. }
  61622. declare module BABYLON {
  61623. /**
  61624. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61625. */
  61626. export class BloomEffect extends PostProcessRenderEffect {
  61627. private bloomScale;
  61628. /**
  61629. * @hidden Internal
  61630. */
  61631. _effects: Array<PostProcess>;
  61632. /**
  61633. * @hidden Internal
  61634. */
  61635. _downscale: ExtractHighlightsPostProcess;
  61636. private _blurX;
  61637. private _blurY;
  61638. private _merge;
  61639. /**
  61640. * The luminance threshold to find bright areas of the image to bloom.
  61641. */
  61642. threshold: number;
  61643. /**
  61644. * The strength of the bloom.
  61645. */
  61646. weight: number;
  61647. /**
  61648. * Specifies the size of the bloom blur kernel, relative to the final output size
  61649. */
  61650. kernel: number;
  61651. /**
  61652. * Creates a new instance of @see BloomEffect
  61653. * @param scene The scene the effect belongs to.
  61654. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61655. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61656. * @param bloomWeight The the strength of bloom.
  61657. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61658. * @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)
  61659. */
  61660. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61661. /**
  61662. * Disposes each of the internal effects for a given camera.
  61663. * @param camera The camera to dispose the effect on.
  61664. */
  61665. disposeEffects(camera: Camera): void;
  61666. /**
  61667. * @hidden Internal
  61668. */
  61669. _updateEffects(): void;
  61670. /**
  61671. * Internal
  61672. * @returns if all the contained post processes are ready.
  61673. * @hidden
  61674. */
  61675. _isReady(): boolean;
  61676. }
  61677. }
  61678. declare module BABYLON {
  61679. /** @hidden */
  61680. export var chromaticAberrationPixelShader: {
  61681. name: string;
  61682. shader: string;
  61683. };
  61684. }
  61685. declare module BABYLON {
  61686. /**
  61687. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61688. */
  61689. export class ChromaticAberrationPostProcess extends PostProcess {
  61690. /**
  61691. * The amount of seperation of rgb channels (default: 30)
  61692. */
  61693. aberrationAmount: number;
  61694. /**
  61695. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61696. */
  61697. radialIntensity: number;
  61698. /**
  61699. * 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))
  61700. */
  61701. direction: Vector2;
  61702. /**
  61703. * 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))
  61704. */
  61705. centerPosition: Vector2;
  61706. /**
  61707. * Creates a new instance ChromaticAberrationPostProcess
  61708. * @param name The name of the effect.
  61709. * @param screenWidth The width of the screen to apply the effect on.
  61710. * @param screenHeight The height of the screen to apply the effect on.
  61711. * @param options The required width/height ratio to downsize to before computing the render pass.
  61712. * @param camera The camera to apply the render pass to.
  61713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61714. * @param engine The engine which the post process will be applied. (default: current engine)
  61715. * @param reusable If the post process can be reused on the same frame. (default: false)
  61716. * @param textureType Type of textures used when performing the post process. (default: 0)
  61717. * @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)
  61718. */
  61719. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61720. }
  61721. }
  61722. declare module BABYLON {
  61723. /** @hidden */
  61724. export var circleOfConfusionPixelShader: {
  61725. name: string;
  61726. shader: string;
  61727. };
  61728. }
  61729. declare module BABYLON {
  61730. /**
  61731. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61732. */
  61733. export class CircleOfConfusionPostProcess extends PostProcess {
  61734. /**
  61735. * 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.
  61736. */
  61737. lensSize: number;
  61738. /**
  61739. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61740. */
  61741. fStop: number;
  61742. /**
  61743. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61744. */
  61745. focusDistance: number;
  61746. /**
  61747. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61748. */
  61749. focalLength: number;
  61750. private _depthTexture;
  61751. /**
  61752. * Creates a new instance CircleOfConfusionPostProcess
  61753. * @param name The name of the effect.
  61754. * @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.
  61755. * @param options The required width/height ratio to downsize to before computing the render pass.
  61756. * @param camera The camera to apply the render pass to.
  61757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61758. * @param engine The engine which the post process will be applied. (default: current engine)
  61759. * @param reusable If the post process can be reused on the same frame. (default: false)
  61760. * @param textureType Type of textures used when performing the post process. (default: 0)
  61761. * @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)
  61762. */
  61763. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61764. /**
  61765. * 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.
  61766. */
  61767. depthTexture: RenderTargetTexture;
  61768. }
  61769. }
  61770. declare module BABYLON {
  61771. /** @hidden */
  61772. export var colorCorrectionPixelShader: {
  61773. name: string;
  61774. shader: string;
  61775. };
  61776. }
  61777. declare module BABYLON {
  61778. /**
  61779. *
  61780. * This post-process allows the modification of rendered colors by using
  61781. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61782. *
  61783. * The object needs to be provided an url to a texture containing the color
  61784. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61785. * Use an image editing software to tweak the LUT to match your needs.
  61786. *
  61787. * For an example of a color LUT, see here:
  61788. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61789. * For explanations on color grading, see here:
  61790. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61791. *
  61792. */
  61793. export class ColorCorrectionPostProcess extends PostProcess {
  61794. private _colorTableTexture;
  61795. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61796. }
  61797. }
  61798. declare module BABYLON {
  61799. /** @hidden */
  61800. export var convolutionPixelShader: {
  61801. name: string;
  61802. shader: string;
  61803. };
  61804. }
  61805. declare module BABYLON {
  61806. /**
  61807. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61808. * input texture to perform effects such as edge detection or sharpening
  61809. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61810. */
  61811. export class ConvolutionPostProcess extends PostProcess {
  61812. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61813. kernel: number[];
  61814. /**
  61815. * Creates a new instance ConvolutionPostProcess
  61816. * @param name The name of the effect.
  61817. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61818. * @param options The required width/height ratio to downsize to before computing the render pass.
  61819. * @param camera The camera to apply the render pass to.
  61820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61821. * @param engine The engine which the post process will be applied. (default: current engine)
  61822. * @param reusable If the post process can be reused on the same frame. (default: false)
  61823. * @param textureType Type of textures used when performing the post process. (default: 0)
  61824. */
  61825. constructor(name: string,
  61826. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61827. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61828. /**
  61829. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61830. */
  61831. static EdgeDetect0Kernel: number[];
  61832. /**
  61833. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61834. */
  61835. static EdgeDetect1Kernel: number[];
  61836. /**
  61837. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61838. */
  61839. static EdgeDetect2Kernel: number[];
  61840. /**
  61841. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61842. */
  61843. static SharpenKernel: number[];
  61844. /**
  61845. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61846. */
  61847. static EmbossKernel: number[];
  61848. /**
  61849. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61850. */
  61851. static GaussianKernel: number[];
  61852. }
  61853. }
  61854. declare module BABYLON {
  61855. /**
  61856. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61857. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61858. * based on samples that have a large difference in distance than the center pixel.
  61859. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61860. */
  61861. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61862. direction: Vector2;
  61863. /**
  61864. * Creates a new instance CircleOfConfusionPostProcess
  61865. * @param name The name of the effect.
  61866. * @param scene The scene the effect belongs to.
  61867. * @param direction The direction the blur should be applied.
  61868. * @param kernel The size of the kernel used to blur.
  61869. * @param options The required width/height ratio to downsize to before computing the render pass.
  61870. * @param camera The camera to apply the render pass to.
  61871. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61872. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61874. * @param engine The engine which the post process will be applied. (default: current engine)
  61875. * @param reusable If the post process can be reused on the same frame. (default: false)
  61876. * @param textureType Type of textures used when performing the post process. (default: 0)
  61877. * @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)
  61878. */
  61879. 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);
  61880. }
  61881. }
  61882. declare module BABYLON {
  61883. /** @hidden */
  61884. export var depthOfFieldMergePixelShader: {
  61885. name: string;
  61886. shader: string;
  61887. };
  61888. }
  61889. declare module BABYLON {
  61890. /**
  61891. * Options to be set when merging outputs from the default pipeline.
  61892. */
  61893. export class DepthOfFieldMergePostProcessOptions {
  61894. /**
  61895. * The original image to merge on top of
  61896. */
  61897. originalFromInput: PostProcess;
  61898. /**
  61899. * Parameters to perform the merge of the depth of field effect
  61900. */
  61901. depthOfField?: {
  61902. circleOfConfusion: PostProcess;
  61903. blurSteps: Array<PostProcess>;
  61904. };
  61905. /**
  61906. * Parameters to perform the merge of bloom effect
  61907. */
  61908. bloom?: {
  61909. blurred: PostProcess;
  61910. weight: number;
  61911. };
  61912. }
  61913. /**
  61914. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61915. */
  61916. export class DepthOfFieldMergePostProcess extends PostProcess {
  61917. private blurSteps;
  61918. /**
  61919. * Creates a new instance of DepthOfFieldMergePostProcess
  61920. * @param name The name of the effect.
  61921. * @param originalFromInput Post process which's input will be used for the merge.
  61922. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61923. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61924. * @param options The required width/height ratio to downsize to before computing the render pass.
  61925. * @param camera The camera to apply the render pass to.
  61926. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61927. * @param engine The engine which the post process will be applied. (default: current engine)
  61928. * @param reusable If the post process can be reused on the same frame. (default: false)
  61929. * @param textureType Type of textures used when performing the post process. (default: 0)
  61930. * @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)
  61931. */
  61932. 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);
  61933. /**
  61934. * Updates the effect with the current post process compile time values and recompiles the shader.
  61935. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61936. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61937. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61938. * @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
  61939. * @param onCompiled Called when the shader has been compiled.
  61940. * @param onError Called if there is an error when compiling a shader.
  61941. */
  61942. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61943. }
  61944. }
  61945. declare module BABYLON {
  61946. /**
  61947. * Specifies the level of max blur that should be applied when using the depth of field effect
  61948. */
  61949. export enum DepthOfFieldEffectBlurLevel {
  61950. /**
  61951. * Subtle blur
  61952. */
  61953. Low = 0,
  61954. /**
  61955. * Medium blur
  61956. */
  61957. Medium = 1,
  61958. /**
  61959. * Large blur
  61960. */
  61961. High = 2
  61962. }
  61963. /**
  61964. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61965. */
  61966. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61967. private _circleOfConfusion;
  61968. /**
  61969. * @hidden Internal, blurs from high to low
  61970. */
  61971. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61972. private _depthOfFieldBlurY;
  61973. private _dofMerge;
  61974. /**
  61975. * @hidden Internal post processes in depth of field effect
  61976. */
  61977. _effects: Array<PostProcess>;
  61978. /**
  61979. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61980. */
  61981. focalLength: number;
  61982. /**
  61983. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61984. */
  61985. fStop: number;
  61986. /**
  61987. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61988. */
  61989. focusDistance: number;
  61990. /**
  61991. * 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.
  61992. */
  61993. lensSize: number;
  61994. /**
  61995. * Creates a new instance DepthOfFieldEffect
  61996. * @param scene The scene the effect belongs to.
  61997. * @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.
  61998. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61999. * @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)
  62000. */
  62001. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62002. /**
  62003. * Get the current class name of the current effet
  62004. * @returns "DepthOfFieldEffect"
  62005. */
  62006. getClassName(): string;
  62007. /**
  62008. * 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.
  62009. */
  62010. depthTexture: RenderTargetTexture;
  62011. /**
  62012. * Disposes each of the internal effects for a given camera.
  62013. * @param camera The camera to dispose the effect on.
  62014. */
  62015. disposeEffects(camera: Camera): void;
  62016. /**
  62017. * @hidden Internal
  62018. */
  62019. _updateEffects(): void;
  62020. /**
  62021. * Internal
  62022. * @returns if all the contained post processes are ready.
  62023. * @hidden
  62024. */
  62025. _isReady(): boolean;
  62026. }
  62027. }
  62028. declare module BABYLON {
  62029. /** @hidden */
  62030. export var displayPassPixelShader: {
  62031. name: string;
  62032. shader: string;
  62033. };
  62034. }
  62035. declare module BABYLON {
  62036. /**
  62037. * DisplayPassPostProcess which produces an output the same as it's input
  62038. */
  62039. export class DisplayPassPostProcess extends PostProcess {
  62040. /**
  62041. * Creates the DisplayPassPostProcess
  62042. * @param name The name of the effect.
  62043. * @param options The required width/height ratio to downsize to before computing the render pass.
  62044. * @param camera The camera to apply the render pass to.
  62045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62046. * @param engine The engine which the post process will be applied. (default: current engine)
  62047. * @param reusable If the post process can be reused on the same frame. (default: false)
  62048. */
  62049. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62050. }
  62051. }
  62052. declare module BABYLON {
  62053. /** @hidden */
  62054. export var filterPixelShader: {
  62055. name: string;
  62056. shader: string;
  62057. };
  62058. }
  62059. declare module BABYLON {
  62060. /**
  62061. * Applies a kernel filter to the image
  62062. */
  62063. export class FilterPostProcess extends PostProcess {
  62064. /** The matrix to be applied to the image */
  62065. kernelMatrix: Matrix;
  62066. /**
  62067. *
  62068. * @param name The name of the effect.
  62069. * @param kernelMatrix The matrix to be applied to the image
  62070. * @param options The required width/height ratio to downsize to before computing the render pass.
  62071. * @param camera The camera to apply the render pass to.
  62072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62073. * @param engine The engine which the post process will be applied. (default: current engine)
  62074. * @param reusable If the post process can be reused on the same frame. (default: false)
  62075. */
  62076. constructor(name: string,
  62077. /** The matrix to be applied to the image */
  62078. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62079. }
  62080. }
  62081. declare module BABYLON {
  62082. /** @hidden */
  62083. export var fxaaPixelShader: {
  62084. name: string;
  62085. shader: string;
  62086. };
  62087. }
  62088. declare module BABYLON {
  62089. /** @hidden */
  62090. export var fxaaVertexShader: {
  62091. name: string;
  62092. shader: string;
  62093. };
  62094. }
  62095. declare module BABYLON {
  62096. /**
  62097. * Fxaa post process
  62098. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62099. */
  62100. export class FxaaPostProcess extends PostProcess {
  62101. /** @hidden */
  62102. texelWidth: number;
  62103. /** @hidden */
  62104. texelHeight: number;
  62105. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62106. private _getDefines;
  62107. }
  62108. }
  62109. declare module BABYLON {
  62110. /** @hidden */
  62111. export var grainPixelShader: {
  62112. name: string;
  62113. shader: string;
  62114. };
  62115. }
  62116. declare module BABYLON {
  62117. /**
  62118. * The GrainPostProcess adds noise to the image at mid luminance levels
  62119. */
  62120. export class GrainPostProcess extends PostProcess {
  62121. /**
  62122. * The intensity of the grain added (default: 30)
  62123. */
  62124. intensity: number;
  62125. /**
  62126. * If the grain should be randomized on every frame
  62127. */
  62128. animated: boolean;
  62129. /**
  62130. * Creates a new instance of @see GrainPostProcess
  62131. * @param name The name of the effect.
  62132. * @param options The required width/height ratio to downsize to before computing the render pass.
  62133. * @param camera The camera to apply the render pass to.
  62134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62135. * @param engine The engine which the post process will be applied. (default: current engine)
  62136. * @param reusable If the post process can be reused on the same frame. (default: false)
  62137. * @param textureType Type of textures used when performing the post process. (default: 0)
  62138. * @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)
  62139. */
  62140. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62141. }
  62142. }
  62143. declare module BABYLON {
  62144. /** @hidden */
  62145. export var highlightsPixelShader: {
  62146. name: string;
  62147. shader: string;
  62148. };
  62149. }
  62150. declare module BABYLON {
  62151. /**
  62152. * Extracts highlights from the image
  62153. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62154. */
  62155. export class HighlightsPostProcess extends PostProcess {
  62156. /**
  62157. * Extracts highlights from the image
  62158. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62159. * @param name The name of the effect.
  62160. * @param options The required width/height ratio to downsize to before computing the render pass.
  62161. * @param camera The camera to apply the render pass to.
  62162. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62163. * @param engine The engine which the post process will be applied. (default: current engine)
  62164. * @param reusable If the post process can be reused on the same frame. (default: false)
  62165. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62166. */
  62167. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62168. }
  62169. }
  62170. declare module BABYLON {
  62171. /** @hidden */
  62172. export var mrtFragmentDeclaration: {
  62173. name: string;
  62174. shader: string;
  62175. };
  62176. }
  62177. declare module BABYLON {
  62178. /** @hidden */
  62179. export var geometryPixelShader: {
  62180. name: string;
  62181. shader: string;
  62182. };
  62183. }
  62184. declare module BABYLON {
  62185. /** @hidden */
  62186. export var geometryVertexShader: {
  62187. name: string;
  62188. shader: string;
  62189. };
  62190. }
  62191. declare module BABYLON {
  62192. /** @hidden */
  62193. interface ISavedTransformationMatrix {
  62194. world: Matrix;
  62195. viewProjection: Matrix;
  62196. }
  62197. /**
  62198. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62199. */
  62200. export class GeometryBufferRenderer {
  62201. /**
  62202. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62203. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62204. */
  62205. static readonly POSITION_TEXTURE_TYPE: number;
  62206. /**
  62207. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62208. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62209. */
  62210. static readonly VELOCITY_TEXTURE_TYPE: number;
  62211. /**
  62212. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62213. * in order to compute objects velocities when enableVelocity is set to "true"
  62214. * @hidden
  62215. */
  62216. _previousTransformationMatrices: {
  62217. [index: number]: ISavedTransformationMatrix;
  62218. };
  62219. /**
  62220. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62221. * in order to compute objects velocities when enableVelocity is set to "true"
  62222. * @hidden
  62223. */
  62224. _previousBonesTransformationMatrices: {
  62225. [index: number]: Float32Array;
  62226. };
  62227. /**
  62228. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62229. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62230. */
  62231. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62232. private _scene;
  62233. private _multiRenderTarget;
  62234. private _ratio;
  62235. private _enablePosition;
  62236. private _enableVelocity;
  62237. private _positionIndex;
  62238. private _velocityIndex;
  62239. protected _effect: Effect;
  62240. protected _cachedDefines: string;
  62241. /**
  62242. * Set the render list (meshes to be rendered) used in the G buffer.
  62243. */
  62244. renderList: Mesh[];
  62245. /**
  62246. * Gets wether or not G buffer are supported by the running hardware.
  62247. * This requires draw buffer supports
  62248. */
  62249. readonly isSupported: boolean;
  62250. /**
  62251. * Returns the index of the given texture type in the G-Buffer textures array
  62252. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62253. * @returns the index of the given texture type in the G-Buffer textures array
  62254. */
  62255. getTextureIndex(textureType: number): number;
  62256. /**
  62257. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62258. */
  62259. /**
  62260. * Sets whether or not objects positions are enabled for the G buffer.
  62261. */
  62262. enablePosition: boolean;
  62263. /**
  62264. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62265. */
  62266. /**
  62267. * Sets wether or not objects velocities are enabled for the G buffer.
  62268. */
  62269. enableVelocity: boolean;
  62270. /**
  62271. * Gets the scene associated with the buffer.
  62272. */
  62273. readonly scene: Scene;
  62274. /**
  62275. * Gets the ratio used by the buffer during its creation.
  62276. * How big is the buffer related to the main canvas.
  62277. */
  62278. readonly ratio: number;
  62279. /** @hidden */
  62280. static _SceneComponentInitialization: (scene: Scene) => void;
  62281. /**
  62282. * Creates a new G Buffer for the scene
  62283. * @param scene The scene the buffer belongs to
  62284. * @param ratio How big is the buffer related to the main canvas.
  62285. */
  62286. constructor(scene: Scene, ratio?: number);
  62287. /**
  62288. * Checks wether everything is ready to render a submesh to the G buffer.
  62289. * @param subMesh the submesh to check readiness for
  62290. * @param useInstances is the mesh drawn using instance or not
  62291. * @returns true if ready otherwise false
  62292. */
  62293. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62294. /**
  62295. * Gets the current underlying G Buffer.
  62296. * @returns the buffer
  62297. */
  62298. getGBuffer(): MultiRenderTarget;
  62299. /**
  62300. * Gets the number of samples used to render the buffer (anti aliasing).
  62301. */
  62302. /**
  62303. * Sets the number of samples used to render the buffer (anti aliasing).
  62304. */
  62305. samples: number;
  62306. /**
  62307. * Disposes the renderer and frees up associated resources.
  62308. */
  62309. dispose(): void;
  62310. protected _createRenderTargets(): void;
  62311. private _copyBonesTransformationMatrices;
  62312. }
  62313. }
  62314. declare module BABYLON {
  62315. interface Scene {
  62316. /** @hidden (Backing field) */
  62317. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62318. /**
  62319. * Gets or Sets the current geometry buffer associated to the scene.
  62320. */
  62321. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62322. /**
  62323. * Enables a GeometryBufferRender and associates it with the scene
  62324. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62325. * @returns the GeometryBufferRenderer
  62326. */
  62327. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62328. /**
  62329. * Disables the GeometryBufferRender associated with the scene
  62330. */
  62331. disableGeometryBufferRenderer(): void;
  62332. }
  62333. /**
  62334. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62335. * in several rendering techniques.
  62336. */
  62337. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62338. /**
  62339. * The component name helpful to identify the component in the list of scene components.
  62340. */
  62341. readonly name: string;
  62342. /**
  62343. * The scene the component belongs to.
  62344. */
  62345. scene: Scene;
  62346. /**
  62347. * Creates a new instance of the component for the given scene
  62348. * @param scene Defines the scene to register the component in
  62349. */
  62350. constructor(scene: Scene);
  62351. /**
  62352. * Registers the component in a given scene
  62353. */
  62354. register(): void;
  62355. /**
  62356. * Rebuilds the elements related to this component in case of
  62357. * context lost for instance.
  62358. */
  62359. rebuild(): void;
  62360. /**
  62361. * Disposes the component and the associated ressources
  62362. */
  62363. dispose(): void;
  62364. private _gatherRenderTargets;
  62365. }
  62366. }
  62367. declare module BABYLON {
  62368. /** @hidden */
  62369. export var motionBlurPixelShader: {
  62370. name: string;
  62371. shader: string;
  62372. };
  62373. }
  62374. declare module BABYLON {
  62375. /**
  62376. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62377. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62378. * As an example, all you have to do is to create the post-process:
  62379. * var mb = new BABYLON.MotionBlurPostProcess(
  62380. * 'mb', // The name of the effect.
  62381. * scene, // The scene containing the objects to blur according to their velocity.
  62382. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62383. * camera // The camera to apply the render pass to.
  62384. * );
  62385. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62386. */
  62387. export class MotionBlurPostProcess extends PostProcess {
  62388. /**
  62389. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62390. */
  62391. motionStrength: number;
  62392. /**
  62393. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62394. */
  62395. /**
  62396. * Sets the number of iterations to be used for motion blur quality
  62397. */
  62398. motionBlurSamples: number;
  62399. private _motionBlurSamples;
  62400. private _geometryBufferRenderer;
  62401. /**
  62402. * Creates a new instance MotionBlurPostProcess
  62403. * @param name The name of the effect.
  62404. * @param scene The scene containing the objects to blur according to their velocity.
  62405. * @param options The required width/height ratio to downsize to before computing the render pass.
  62406. * @param camera The camera to apply the render pass to.
  62407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62408. * @param engine The engine which the post process will be applied. (default: current engine)
  62409. * @param reusable If the post process can be reused on the same frame. (default: false)
  62410. * @param textureType Type of textures used when performing the post process. (default: 0)
  62411. * @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)
  62412. */
  62413. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62414. /**
  62415. * Excludes the given skinned mesh from computing bones velocities.
  62416. * 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.
  62417. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62418. */
  62419. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62420. /**
  62421. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62422. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62423. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62424. */
  62425. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62426. /**
  62427. * Disposes the post process.
  62428. * @param camera The camera to dispose the post process on.
  62429. */
  62430. dispose(camera?: Camera): void;
  62431. }
  62432. }
  62433. declare module BABYLON {
  62434. /** @hidden */
  62435. export var refractionPixelShader: {
  62436. name: string;
  62437. shader: string;
  62438. };
  62439. }
  62440. declare module BABYLON {
  62441. /**
  62442. * Post process which applies a refractin texture
  62443. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62444. */
  62445. export class RefractionPostProcess extends PostProcess {
  62446. /** the base color of the refraction (used to taint the rendering) */
  62447. color: Color3;
  62448. /** simulated refraction depth */
  62449. depth: number;
  62450. /** the coefficient of the base color (0 to remove base color tainting) */
  62451. colorLevel: number;
  62452. private _refTexture;
  62453. private _ownRefractionTexture;
  62454. /**
  62455. * Gets or sets the refraction texture
  62456. * Please note that you are responsible for disposing the texture if you set it manually
  62457. */
  62458. refractionTexture: Texture;
  62459. /**
  62460. * Initializes the RefractionPostProcess
  62461. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62462. * @param name The name of the effect.
  62463. * @param refractionTextureUrl Url of the refraction texture to use
  62464. * @param color the base color of the refraction (used to taint the rendering)
  62465. * @param depth simulated refraction depth
  62466. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62467. * @param camera The camera to apply the render pass to.
  62468. * @param options The required width/height ratio to downsize to before computing the render pass.
  62469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62470. * @param engine The engine which the post process will be applied. (default: current engine)
  62471. * @param reusable If the post process can be reused on the same frame. (default: false)
  62472. */
  62473. constructor(name: string, refractionTextureUrl: string,
  62474. /** the base color of the refraction (used to taint the rendering) */
  62475. color: Color3,
  62476. /** simulated refraction depth */
  62477. depth: number,
  62478. /** the coefficient of the base color (0 to remove base color tainting) */
  62479. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62480. /**
  62481. * Disposes of the post process
  62482. * @param camera Camera to dispose post process on
  62483. */
  62484. dispose(camera: Camera): void;
  62485. }
  62486. }
  62487. declare module BABYLON {
  62488. /** @hidden */
  62489. export var sharpenPixelShader: {
  62490. name: string;
  62491. shader: string;
  62492. };
  62493. }
  62494. declare module BABYLON {
  62495. /**
  62496. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62497. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62498. */
  62499. export class SharpenPostProcess extends PostProcess {
  62500. /**
  62501. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62502. */
  62503. colorAmount: number;
  62504. /**
  62505. * How much sharpness should be applied (default: 0.3)
  62506. */
  62507. edgeAmount: number;
  62508. /**
  62509. * Creates a new instance ConvolutionPostProcess
  62510. * @param name The name of the effect.
  62511. * @param options The required width/height ratio to downsize to before computing the render pass.
  62512. * @param camera The camera to apply the render pass to.
  62513. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62514. * @param engine The engine which the post process will be applied. (default: current engine)
  62515. * @param reusable If the post process can be reused on the same frame. (default: false)
  62516. * @param textureType Type of textures used when performing the post process. (default: 0)
  62517. * @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)
  62518. */
  62519. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62520. }
  62521. }
  62522. declare module BABYLON {
  62523. /**
  62524. * PostProcessRenderPipeline
  62525. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62526. */
  62527. export class PostProcessRenderPipeline {
  62528. private engine;
  62529. private _renderEffects;
  62530. private _renderEffectsForIsolatedPass;
  62531. /**
  62532. * List of inspectable custom properties (used by the Inspector)
  62533. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62534. */
  62535. inspectableCustomProperties: IInspectable[];
  62536. /**
  62537. * @hidden
  62538. */
  62539. protected _cameras: Camera[];
  62540. /** @hidden */
  62541. _name: string;
  62542. /**
  62543. * Gets pipeline name
  62544. */
  62545. readonly name: string;
  62546. /** Gets the list of attached cameras */
  62547. readonly cameras: Camera[];
  62548. /**
  62549. * Initializes a PostProcessRenderPipeline
  62550. * @param engine engine to add the pipeline to
  62551. * @param name name of the pipeline
  62552. */
  62553. constructor(engine: Engine, name: string);
  62554. /**
  62555. * Gets the class name
  62556. * @returns "PostProcessRenderPipeline"
  62557. */
  62558. getClassName(): string;
  62559. /**
  62560. * If all the render effects in the pipeline are supported
  62561. */
  62562. readonly isSupported: boolean;
  62563. /**
  62564. * Adds an effect to the pipeline
  62565. * @param renderEffect the effect to add
  62566. */
  62567. addEffect(renderEffect: PostProcessRenderEffect): void;
  62568. /** @hidden */
  62569. _rebuild(): void;
  62570. /** @hidden */
  62571. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62572. /** @hidden */
  62573. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62574. /** @hidden */
  62575. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62576. /** @hidden */
  62577. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62578. /** @hidden */
  62579. _attachCameras(cameras: Camera, unique: boolean): void;
  62580. /** @hidden */
  62581. _attachCameras(cameras: Camera[], unique: boolean): void;
  62582. /** @hidden */
  62583. _detachCameras(cameras: Camera): void;
  62584. /** @hidden */
  62585. _detachCameras(cameras: Nullable<Camera[]>): void;
  62586. /** @hidden */
  62587. _update(): void;
  62588. /** @hidden */
  62589. _reset(): void;
  62590. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62591. /**
  62592. * Disposes of the pipeline
  62593. */
  62594. dispose(): void;
  62595. }
  62596. }
  62597. declare module BABYLON {
  62598. /**
  62599. * PostProcessRenderPipelineManager class
  62600. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62601. */
  62602. export class PostProcessRenderPipelineManager {
  62603. private _renderPipelines;
  62604. /**
  62605. * Initializes a PostProcessRenderPipelineManager
  62606. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62607. */
  62608. constructor();
  62609. /**
  62610. * Gets the list of supported render pipelines
  62611. */
  62612. readonly supportedPipelines: PostProcessRenderPipeline[];
  62613. /**
  62614. * Adds a pipeline to the manager
  62615. * @param renderPipeline The pipeline to add
  62616. */
  62617. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62618. /**
  62619. * Attaches a camera to the pipeline
  62620. * @param renderPipelineName The name of the pipeline to attach to
  62621. * @param cameras the camera to attach
  62622. * @param unique if the camera can be attached multiple times to the pipeline
  62623. */
  62624. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62625. /**
  62626. * Detaches a camera from the pipeline
  62627. * @param renderPipelineName The name of the pipeline to detach from
  62628. * @param cameras the camera to detach
  62629. */
  62630. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62631. /**
  62632. * Enables an effect by name on a pipeline
  62633. * @param renderPipelineName the name of the pipeline to enable the effect in
  62634. * @param renderEffectName the name of the effect to enable
  62635. * @param cameras the cameras that the effect should be enabled on
  62636. */
  62637. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62638. /**
  62639. * Disables an effect by name on a pipeline
  62640. * @param renderPipelineName the name of the pipeline to disable the effect in
  62641. * @param renderEffectName the name of the effect to disable
  62642. * @param cameras the cameras that the effect should be disabled on
  62643. */
  62644. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62645. /**
  62646. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62647. */
  62648. update(): void;
  62649. /** @hidden */
  62650. _rebuild(): void;
  62651. /**
  62652. * Disposes of the manager and pipelines
  62653. */
  62654. dispose(): void;
  62655. }
  62656. }
  62657. declare module BABYLON {
  62658. interface Scene {
  62659. /** @hidden (Backing field) */
  62660. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62661. /**
  62662. * Gets the postprocess render pipeline manager
  62663. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62664. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62665. */
  62666. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62667. }
  62668. /**
  62669. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62670. */
  62671. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62672. /**
  62673. * The component name helpfull to identify the component in the list of scene components.
  62674. */
  62675. readonly name: string;
  62676. /**
  62677. * The scene the component belongs to.
  62678. */
  62679. scene: Scene;
  62680. /**
  62681. * Creates a new instance of the component for the given scene
  62682. * @param scene Defines the scene to register the component in
  62683. */
  62684. constructor(scene: Scene);
  62685. /**
  62686. * Registers the component in a given scene
  62687. */
  62688. register(): void;
  62689. /**
  62690. * Rebuilds the elements related to this component in case of
  62691. * context lost for instance.
  62692. */
  62693. rebuild(): void;
  62694. /**
  62695. * Disposes the component and the associated ressources
  62696. */
  62697. dispose(): void;
  62698. private _gatherRenderTargets;
  62699. }
  62700. }
  62701. declare module BABYLON {
  62702. /**
  62703. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62704. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62705. */
  62706. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62707. private _scene;
  62708. private _camerasToBeAttached;
  62709. /**
  62710. * ID of the sharpen post process,
  62711. */
  62712. private readonly SharpenPostProcessId;
  62713. /**
  62714. * @ignore
  62715. * ID of the image processing post process;
  62716. */
  62717. readonly ImageProcessingPostProcessId: string;
  62718. /**
  62719. * @ignore
  62720. * ID of the Fast Approximate Anti-Aliasing post process;
  62721. */
  62722. readonly FxaaPostProcessId: string;
  62723. /**
  62724. * ID of the chromatic aberration post process,
  62725. */
  62726. private readonly ChromaticAberrationPostProcessId;
  62727. /**
  62728. * ID of the grain post process
  62729. */
  62730. private readonly GrainPostProcessId;
  62731. /**
  62732. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62733. */
  62734. sharpen: SharpenPostProcess;
  62735. private _sharpenEffect;
  62736. private bloom;
  62737. /**
  62738. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62739. */
  62740. depthOfField: DepthOfFieldEffect;
  62741. /**
  62742. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62743. */
  62744. fxaa: FxaaPostProcess;
  62745. /**
  62746. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62747. */
  62748. imageProcessing: ImageProcessingPostProcess;
  62749. /**
  62750. * Chromatic aberration post process which will shift rgb colors in the image
  62751. */
  62752. chromaticAberration: ChromaticAberrationPostProcess;
  62753. private _chromaticAberrationEffect;
  62754. /**
  62755. * Grain post process which add noise to the image
  62756. */
  62757. grain: GrainPostProcess;
  62758. private _grainEffect;
  62759. /**
  62760. * Glow post process which adds a glow to emissive areas of the image
  62761. */
  62762. private _glowLayer;
  62763. /**
  62764. * Animations which can be used to tweak settings over a period of time
  62765. */
  62766. animations: Animation[];
  62767. private _imageProcessingConfigurationObserver;
  62768. private _sharpenEnabled;
  62769. private _bloomEnabled;
  62770. private _depthOfFieldEnabled;
  62771. private _depthOfFieldBlurLevel;
  62772. private _fxaaEnabled;
  62773. private _imageProcessingEnabled;
  62774. private _defaultPipelineTextureType;
  62775. private _bloomScale;
  62776. private _chromaticAberrationEnabled;
  62777. private _grainEnabled;
  62778. private _buildAllowed;
  62779. /**
  62780. * Gets active scene
  62781. */
  62782. readonly scene: Scene;
  62783. /**
  62784. * Enable or disable the sharpen process from the pipeline
  62785. */
  62786. sharpenEnabled: boolean;
  62787. private _resizeObserver;
  62788. private _hardwareScaleLevel;
  62789. private _bloomKernel;
  62790. /**
  62791. * Specifies the size of the bloom blur kernel, relative to the final output size
  62792. */
  62793. bloomKernel: number;
  62794. /**
  62795. * Specifies the weight of the bloom in the final rendering
  62796. */
  62797. private _bloomWeight;
  62798. /**
  62799. * Specifies the luma threshold for the area that will be blurred by the bloom
  62800. */
  62801. private _bloomThreshold;
  62802. private _hdr;
  62803. /**
  62804. * The strength of the bloom.
  62805. */
  62806. bloomWeight: number;
  62807. /**
  62808. * The strength of the bloom.
  62809. */
  62810. bloomThreshold: number;
  62811. /**
  62812. * The scale of the bloom, lower value will provide better performance.
  62813. */
  62814. bloomScale: number;
  62815. /**
  62816. * Enable or disable the bloom from the pipeline
  62817. */
  62818. bloomEnabled: boolean;
  62819. private _rebuildBloom;
  62820. /**
  62821. * If the depth of field is enabled.
  62822. */
  62823. depthOfFieldEnabled: boolean;
  62824. /**
  62825. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62826. */
  62827. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62828. /**
  62829. * If the anti aliasing is enabled.
  62830. */
  62831. fxaaEnabled: boolean;
  62832. private _samples;
  62833. /**
  62834. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62835. */
  62836. samples: number;
  62837. /**
  62838. * If image processing is enabled.
  62839. */
  62840. imageProcessingEnabled: boolean;
  62841. /**
  62842. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62843. */
  62844. glowLayerEnabled: boolean;
  62845. /**
  62846. * Gets the glow layer (or null if not defined)
  62847. */
  62848. readonly glowLayer: Nullable<GlowLayer>;
  62849. /**
  62850. * Enable or disable the chromaticAberration process from the pipeline
  62851. */
  62852. chromaticAberrationEnabled: boolean;
  62853. /**
  62854. * Enable or disable the grain process from the pipeline
  62855. */
  62856. grainEnabled: boolean;
  62857. /**
  62858. * @constructor
  62859. * @param name - The rendering pipeline name (default: "")
  62860. * @param hdr - If high dynamic range textures should be used (default: true)
  62861. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62862. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62863. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62864. */
  62865. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62866. /**
  62867. * Get the class name
  62868. * @returns "DefaultRenderingPipeline"
  62869. */
  62870. getClassName(): string;
  62871. /**
  62872. * Force the compilation of the entire pipeline.
  62873. */
  62874. prepare(): void;
  62875. private _hasCleared;
  62876. private _prevPostProcess;
  62877. private _prevPrevPostProcess;
  62878. private _setAutoClearAndTextureSharing;
  62879. private _depthOfFieldSceneObserver;
  62880. private _buildPipeline;
  62881. private _disposePostProcesses;
  62882. /**
  62883. * Adds a camera to the pipeline
  62884. * @param camera the camera to be added
  62885. */
  62886. addCamera(camera: Camera): void;
  62887. /**
  62888. * Removes a camera from the pipeline
  62889. * @param camera the camera to remove
  62890. */
  62891. removeCamera(camera: Camera): void;
  62892. /**
  62893. * Dispose of the pipeline and stop all post processes
  62894. */
  62895. dispose(): void;
  62896. /**
  62897. * Serialize the rendering pipeline (Used when exporting)
  62898. * @returns the serialized object
  62899. */
  62900. serialize(): any;
  62901. /**
  62902. * Parse the serialized pipeline
  62903. * @param source Source pipeline.
  62904. * @param scene The scene to load the pipeline to.
  62905. * @param rootUrl The URL of the serialized pipeline.
  62906. * @returns An instantiated pipeline from the serialized object.
  62907. */
  62908. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62909. }
  62910. }
  62911. declare module BABYLON {
  62912. /** @hidden */
  62913. export var lensHighlightsPixelShader: {
  62914. name: string;
  62915. shader: string;
  62916. };
  62917. }
  62918. declare module BABYLON {
  62919. /** @hidden */
  62920. export var depthOfFieldPixelShader: {
  62921. name: string;
  62922. shader: string;
  62923. };
  62924. }
  62925. declare module BABYLON {
  62926. /**
  62927. * BABYLON.JS Chromatic Aberration GLSL Shader
  62928. * Author: Olivier Guyot
  62929. * Separates very slightly R, G and B colors on the edges of the screen
  62930. * Inspired by Francois Tarlier & Martins Upitis
  62931. */
  62932. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62933. /**
  62934. * @ignore
  62935. * The chromatic aberration PostProcess id in the pipeline
  62936. */
  62937. LensChromaticAberrationEffect: string;
  62938. /**
  62939. * @ignore
  62940. * The highlights enhancing PostProcess id in the pipeline
  62941. */
  62942. HighlightsEnhancingEffect: string;
  62943. /**
  62944. * @ignore
  62945. * The depth-of-field PostProcess id in the pipeline
  62946. */
  62947. LensDepthOfFieldEffect: string;
  62948. private _scene;
  62949. private _depthTexture;
  62950. private _grainTexture;
  62951. private _chromaticAberrationPostProcess;
  62952. private _highlightsPostProcess;
  62953. private _depthOfFieldPostProcess;
  62954. private _edgeBlur;
  62955. private _grainAmount;
  62956. private _chromaticAberration;
  62957. private _distortion;
  62958. private _highlightsGain;
  62959. private _highlightsThreshold;
  62960. private _dofDistance;
  62961. private _dofAperture;
  62962. private _dofDarken;
  62963. private _dofPentagon;
  62964. private _blurNoise;
  62965. /**
  62966. * @constructor
  62967. *
  62968. * Effect parameters are as follow:
  62969. * {
  62970. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62971. * edge_blur: number; // from 0 to x (1 for realism)
  62972. * distortion: number; // from 0 to x (1 for realism)
  62973. * grain_amount: number; // from 0 to 1
  62974. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62975. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62976. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62977. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62978. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62979. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62980. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62981. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62982. * }
  62983. * Note: if an effect parameter is unset, effect is disabled
  62984. *
  62985. * @param name The rendering pipeline name
  62986. * @param parameters - An object containing all parameters (see above)
  62987. * @param scene The scene linked to this pipeline
  62988. * @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)
  62989. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62990. */
  62991. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62992. /**
  62993. * Get the class name
  62994. * @returns "LensRenderingPipeline"
  62995. */
  62996. getClassName(): string;
  62997. /**
  62998. * Gets associated scene
  62999. */
  63000. readonly scene: Scene;
  63001. /**
  63002. * Gets or sets the edge blur
  63003. */
  63004. edgeBlur: number;
  63005. /**
  63006. * Gets or sets the grain amount
  63007. */
  63008. grainAmount: number;
  63009. /**
  63010. * Gets or sets the chromatic aberration amount
  63011. */
  63012. chromaticAberration: number;
  63013. /**
  63014. * Gets or sets the depth of field aperture
  63015. */
  63016. dofAperture: number;
  63017. /**
  63018. * Gets or sets the edge distortion
  63019. */
  63020. edgeDistortion: number;
  63021. /**
  63022. * Gets or sets the depth of field distortion
  63023. */
  63024. dofDistortion: number;
  63025. /**
  63026. * Gets or sets the darken out of focus amount
  63027. */
  63028. darkenOutOfFocus: number;
  63029. /**
  63030. * Gets or sets a boolean indicating if blur noise is enabled
  63031. */
  63032. blurNoise: boolean;
  63033. /**
  63034. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63035. */
  63036. pentagonBokeh: boolean;
  63037. /**
  63038. * Gets or sets the highlight grain amount
  63039. */
  63040. highlightsGain: number;
  63041. /**
  63042. * Gets or sets the highlight threshold
  63043. */
  63044. highlightsThreshold: number;
  63045. /**
  63046. * Sets the amount of blur at the edges
  63047. * @param amount blur amount
  63048. */
  63049. setEdgeBlur(amount: number): void;
  63050. /**
  63051. * Sets edge blur to 0
  63052. */
  63053. disableEdgeBlur(): void;
  63054. /**
  63055. * Sets the amout of grain
  63056. * @param amount Amount of grain
  63057. */
  63058. setGrainAmount(amount: number): void;
  63059. /**
  63060. * Set grain amount to 0
  63061. */
  63062. disableGrain(): void;
  63063. /**
  63064. * Sets the chromatic aberration amount
  63065. * @param amount amount of chromatic aberration
  63066. */
  63067. setChromaticAberration(amount: number): void;
  63068. /**
  63069. * Sets chromatic aberration amount to 0
  63070. */
  63071. disableChromaticAberration(): void;
  63072. /**
  63073. * Sets the EdgeDistortion amount
  63074. * @param amount amount of EdgeDistortion
  63075. */
  63076. setEdgeDistortion(amount: number): void;
  63077. /**
  63078. * Sets edge distortion to 0
  63079. */
  63080. disableEdgeDistortion(): void;
  63081. /**
  63082. * Sets the FocusDistance amount
  63083. * @param amount amount of FocusDistance
  63084. */
  63085. setFocusDistance(amount: number): void;
  63086. /**
  63087. * Disables depth of field
  63088. */
  63089. disableDepthOfField(): void;
  63090. /**
  63091. * Sets the Aperture amount
  63092. * @param amount amount of Aperture
  63093. */
  63094. setAperture(amount: number): void;
  63095. /**
  63096. * Sets the DarkenOutOfFocus amount
  63097. * @param amount amount of DarkenOutOfFocus
  63098. */
  63099. setDarkenOutOfFocus(amount: number): void;
  63100. private _pentagonBokehIsEnabled;
  63101. /**
  63102. * Creates a pentagon bokeh effect
  63103. */
  63104. enablePentagonBokeh(): void;
  63105. /**
  63106. * Disables the pentagon bokeh effect
  63107. */
  63108. disablePentagonBokeh(): void;
  63109. /**
  63110. * Enables noise blur
  63111. */
  63112. enableNoiseBlur(): void;
  63113. /**
  63114. * Disables noise blur
  63115. */
  63116. disableNoiseBlur(): void;
  63117. /**
  63118. * Sets the HighlightsGain amount
  63119. * @param amount amount of HighlightsGain
  63120. */
  63121. setHighlightsGain(amount: number): void;
  63122. /**
  63123. * Sets the HighlightsThreshold amount
  63124. * @param amount amount of HighlightsThreshold
  63125. */
  63126. setHighlightsThreshold(amount: number): void;
  63127. /**
  63128. * Disables highlights
  63129. */
  63130. disableHighlights(): void;
  63131. /**
  63132. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63133. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63134. */
  63135. dispose(disableDepthRender?: boolean): void;
  63136. private _createChromaticAberrationPostProcess;
  63137. private _createHighlightsPostProcess;
  63138. private _createDepthOfFieldPostProcess;
  63139. private _createGrainTexture;
  63140. }
  63141. }
  63142. declare module BABYLON {
  63143. /** @hidden */
  63144. export var ssao2PixelShader: {
  63145. name: string;
  63146. shader: string;
  63147. };
  63148. }
  63149. declare module BABYLON {
  63150. /** @hidden */
  63151. export var ssaoCombinePixelShader: {
  63152. name: string;
  63153. shader: string;
  63154. };
  63155. }
  63156. declare module BABYLON {
  63157. /**
  63158. * Render pipeline to produce ssao effect
  63159. */
  63160. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63161. /**
  63162. * @ignore
  63163. * The PassPostProcess id in the pipeline that contains the original scene color
  63164. */
  63165. SSAOOriginalSceneColorEffect: string;
  63166. /**
  63167. * @ignore
  63168. * The SSAO PostProcess id in the pipeline
  63169. */
  63170. SSAORenderEffect: string;
  63171. /**
  63172. * @ignore
  63173. * The horizontal blur PostProcess id in the pipeline
  63174. */
  63175. SSAOBlurHRenderEffect: string;
  63176. /**
  63177. * @ignore
  63178. * The vertical blur PostProcess id in the pipeline
  63179. */
  63180. SSAOBlurVRenderEffect: string;
  63181. /**
  63182. * @ignore
  63183. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63184. */
  63185. SSAOCombineRenderEffect: string;
  63186. /**
  63187. * The output strength of the SSAO post-process. Default value is 1.0.
  63188. */
  63189. totalStrength: number;
  63190. /**
  63191. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63192. */
  63193. maxZ: number;
  63194. /**
  63195. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63196. */
  63197. minZAspect: number;
  63198. private _samples;
  63199. /**
  63200. * Number of samples used for the SSAO calculations. Default value is 8
  63201. */
  63202. samples: number;
  63203. private _textureSamples;
  63204. /**
  63205. * Number of samples to use for antialiasing
  63206. */
  63207. textureSamples: number;
  63208. /**
  63209. * Ratio object used for SSAO ratio and blur ratio
  63210. */
  63211. private _ratio;
  63212. /**
  63213. * Dynamically generated sphere sampler.
  63214. */
  63215. private _sampleSphere;
  63216. /**
  63217. * Blur filter offsets
  63218. */
  63219. private _samplerOffsets;
  63220. private _expensiveBlur;
  63221. /**
  63222. * If bilateral blur should be used
  63223. */
  63224. expensiveBlur: boolean;
  63225. /**
  63226. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63227. */
  63228. radius: number;
  63229. /**
  63230. * The base color of the SSAO post-process
  63231. * The final result is "base + ssao" between [0, 1]
  63232. */
  63233. base: number;
  63234. /**
  63235. * Support test.
  63236. */
  63237. static readonly IsSupported: boolean;
  63238. private _scene;
  63239. private _depthTexture;
  63240. private _normalTexture;
  63241. private _randomTexture;
  63242. private _originalColorPostProcess;
  63243. private _ssaoPostProcess;
  63244. private _blurHPostProcess;
  63245. private _blurVPostProcess;
  63246. private _ssaoCombinePostProcess;
  63247. /**
  63248. * Gets active scene
  63249. */
  63250. readonly scene: Scene;
  63251. /**
  63252. * @constructor
  63253. * @param name The rendering pipeline name
  63254. * @param scene The scene linked to this pipeline
  63255. * @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 }
  63256. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63257. */
  63258. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63259. /**
  63260. * Get the class name
  63261. * @returns "SSAO2RenderingPipeline"
  63262. */
  63263. getClassName(): string;
  63264. /**
  63265. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63266. */
  63267. dispose(disableGeometryBufferRenderer?: boolean): void;
  63268. private _createBlurPostProcess;
  63269. /** @hidden */
  63270. _rebuild(): void;
  63271. private _bits;
  63272. private _radicalInverse_VdC;
  63273. private _hammersley;
  63274. private _hemisphereSample_uniform;
  63275. private _generateHemisphere;
  63276. private _createSSAOPostProcess;
  63277. private _createSSAOCombinePostProcess;
  63278. private _createRandomTexture;
  63279. /**
  63280. * Serialize the rendering pipeline (Used when exporting)
  63281. * @returns the serialized object
  63282. */
  63283. serialize(): any;
  63284. /**
  63285. * Parse the serialized pipeline
  63286. * @param source Source pipeline.
  63287. * @param scene The scene to load the pipeline to.
  63288. * @param rootUrl The URL of the serialized pipeline.
  63289. * @returns An instantiated pipeline from the serialized object.
  63290. */
  63291. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63292. }
  63293. }
  63294. declare module BABYLON {
  63295. /** @hidden */
  63296. export var ssaoPixelShader: {
  63297. name: string;
  63298. shader: string;
  63299. };
  63300. }
  63301. declare module BABYLON {
  63302. /**
  63303. * Render pipeline to produce ssao effect
  63304. */
  63305. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63306. /**
  63307. * @ignore
  63308. * The PassPostProcess id in the pipeline that contains the original scene color
  63309. */
  63310. SSAOOriginalSceneColorEffect: string;
  63311. /**
  63312. * @ignore
  63313. * The SSAO PostProcess id in the pipeline
  63314. */
  63315. SSAORenderEffect: string;
  63316. /**
  63317. * @ignore
  63318. * The horizontal blur PostProcess id in the pipeline
  63319. */
  63320. SSAOBlurHRenderEffect: string;
  63321. /**
  63322. * @ignore
  63323. * The vertical blur PostProcess id in the pipeline
  63324. */
  63325. SSAOBlurVRenderEffect: string;
  63326. /**
  63327. * @ignore
  63328. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63329. */
  63330. SSAOCombineRenderEffect: string;
  63331. /**
  63332. * The output strength of the SSAO post-process. Default value is 1.0.
  63333. */
  63334. totalStrength: number;
  63335. /**
  63336. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63337. */
  63338. radius: number;
  63339. /**
  63340. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63341. * Must not be equal to fallOff and superior to fallOff.
  63342. * Default value is 0.0075
  63343. */
  63344. area: number;
  63345. /**
  63346. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63347. * Must not be equal to area and inferior to area.
  63348. * Default value is 0.000001
  63349. */
  63350. fallOff: number;
  63351. /**
  63352. * The base color of the SSAO post-process
  63353. * The final result is "base + ssao" between [0, 1]
  63354. */
  63355. base: number;
  63356. private _scene;
  63357. private _depthTexture;
  63358. private _randomTexture;
  63359. private _originalColorPostProcess;
  63360. private _ssaoPostProcess;
  63361. private _blurHPostProcess;
  63362. private _blurVPostProcess;
  63363. private _ssaoCombinePostProcess;
  63364. private _firstUpdate;
  63365. /**
  63366. * Gets active scene
  63367. */
  63368. readonly scene: Scene;
  63369. /**
  63370. * @constructor
  63371. * @param name - The rendering pipeline name
  63372. * @param scene - The scene linked to this pipeline
  63373. * @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 }
  63374. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63375. */
  63376. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63377. /**
  63378. * Get the class name
  63379. * @returns "SSAORenderingPipeline"
  63380. */
  63381. getClassName(): string;
  63382. /**
  63383. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63384. */
  63385. dispose(disableDepthRender?: boolean): void;
  63386. private _createBlurPostProcess;
  63387. /** @hidden */
  63388. _rebuild(): void;
  63389. private _createSSAOPostProcess;
  63390. private _createSSAOCombinePostProcess;
  63391. private _createRandomTexture;
  63392. }
  63393. }
  63394. declare module BABYLON {
  63395. /** @hidden */
  63396. export var standardPixelShader: {
  63397. name: string;
  63398. shader: string;
  63399. };
  63400. }
  63401. declare module BABYLON {
  63402. /**
  63403. * Standard rendering pipeline
  63404. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63405. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63406. */
  63407. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63408. /**
  63409. * Public members
  63410. */
  63411. /**
  63412. * Post-process which contains the original scene color before the pipeline applies all the effects
  63413. */
  63414. originalPostProcess: Nullable<PostProcess>;
  63415. /**
  63416. * Post-process used to down scale an image x4
  63417. */
  63418. downSampleX4PostProcess: Nullable<PostProcess>;
  63419. /**
  63420. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63421. */
  63422. brightPassPostProcess: Nullable<PostProcess>;
  63423. /**
  63424. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63425. */
  63426. blurHPostProcesses: PostProcess[];
  63427. /**
  63428. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63429. */
  63430. blurVPostProcesses: PostProcess[];
  63431. /**
  63432. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63433. */
  63434. textureAdderPostProcess: Nullable<PostProcess>;
  63435. /**
  63436. * Post-process used to create volumetric lighting effect
  63437. */
  63438. volumetricLightPostProcess: Nullable<PostProcess>;
  63439. /**
  63440. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63441. */
  63442. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63443. /**
  63444. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63445. */
  63446. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63447. /**
  63448. * Post-process used to merge the volumetric light effect and the real scene color
  63449. */
  63450. volumetricLightMergePostProces: Nullable<PostProcess>;
  63451. /**
  63452. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63453. */
  63454. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63455. /**
  63456. * Base post-process used to calculate the average luminance of the final image for HDR
  63457. */
  63458. luminancePostProcess: Nullable<PostProcess>;
  63459. /**
  63460. * Post-processes used to create down sample post-processes in order to get
  63461. * the average luminance of the final image for HDR
  63462. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63463. */
  63464. luminanceDownSamplePostProcesses: PostProcess[];
  63465. /**
  63466. * Post-process used to create a HDR effect (light adaptation)
  63467. */
  63468. hdrPostProcess: Nullable<PostProcess>;
  63469. /**
  63470. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63471. */
  63472. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63473. /**
  63474. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63475. */
  63476. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63477. /**
  63478. * Post-process used to merge the final HDR post-process and the real scene color
  63479. */
  63480. hdrFinalPostProcess: Nullable<PostProcess>;
  63481. /**
  63482. * Post-process used to create a lens flare effect
  63483. */
  63484. lensFlarePostProcess: Nullable<PostProcess>;
  63485. /**
  63486. * Post-process that merges the result of the lens flare post-process and the real scene color
  63487. */
  63488. lensFlareComposePostProcess: Nullable<PostProcess>;
  63489. /**
  63490. * Post-process used to create a motion blur effect
  63491. */
  63492. motionBlurPostProcess: Nullable<PostProcess>;
  63493. /**
  63494. * Post-process used to create a depth of field effect
  63495. */
  63496. depthOfFieldPostProcess: Nullable<PostProcess>;
  63497. /**
  63498. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63499. */
  63500. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63501. /**
  63502. * Represents the brightness threshold in order to configure the illuminated surfaces
  63503. */
  63504. brightThreshold: number;
  63505. /**
  63506. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63507. */
  63508. blurWidth: number;
  63509. /**
  63510. * Sets if the blur for highlighted surfaces must be only horizontal
  63511. */
  63512. horizontalBlur: boolean;
  63513. /**
  63514. * Gets the overall exposure used by the pipeline
  63515. */
  63516. /**
  63517. * Sets the overall exposure used by the pipeline
  63518. */
  63519. exposure: number;
  63520. /**
  63521. * Texture used typically to simulate "dirty" on camera lens
  63522. */
  63523. lensTexture: Nullable<Texture>;
  63524. /**
  63525. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63526. */
  63527. volumetricLightCoefficient: number;
  63528. /**
  63529. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63530. */
  63531. volumetricLightPower: number;
  63532. /**
  63533. * Used the set the blur intensity to smooth the volumetric lights
  63534. */
  63535. volumetricLightBlurScale: number;
  63536. /**
  63537. * Light (spot or directional) used to generate the volumetric lights rays
  63538. * The source light must have a shadow generate so the pipeline can get its
  63539. * depth map
  63540. */
  63541. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63542. /**
  63543. * For eye adaptation, represents the minimum luminance the eye can see
  63544. */
  63545. hdrMinimumLuminance: number;
  63546. /**
  63547. * For eye adaptation, represents the decrease luminance speed
  63548. */
  63549. hdrDecreaseRate: number;
  63550. /**
  63551. * For eye adaptation, represents the increase luminance speed
  63552. */
  63553. hdrIncreaseRate: number;
  63554. /**
  63555. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63556. */
  63557. /**
  63558. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63559. */
  63560. hdrAutoExposure: boolean;
  63561. /**
  63562. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63563. */
  63564. lensColorTexture: Nullable<Texture>;
  63565. /**
  63566. * The overall strengh for the lens flare effect
  63567. */
  63568. lensFlareStrength: number;
  63569. /**
  63570. * Dispersion coefficient for lens flare ghosts
  63571. */
  63572. lensFlareGhostDispersal: number;
  63573. /**
  63574. * Main lens flare halo width
  63575. */
  63576. lensFlareHaloWidth: number;
  63577. /**
  63578. * Based on the lens distortion effect, defines how much the lens flare result
  63579. * is distorted
  63580. */
  63581. lensFlareDistortionStrength: number;
  63582. /**
  63583. * Configures the blur intensity used for for lens flare (halo)
  63584. */
  63585. lensFlareBlurWidth: number;
  63586. /**
  63587. * Lens star texture must be used to simulate rays on the flares and is available
  63588. * in the documentation
  63589. */
  63590. lensStarTexture: Nullable<Texture>;
  63591. /**
  63592. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63593. * flare effect by taking account of the dirt texture
  63594. */
  63595. lensFlareDirtTexture: Nullable<Texture>;
  63596. /**
  63597. * Represents the focal length for the depth of field effect
  63598. */
  63599. depthOfFieldDistance: number;
  63600. /**
  63601. * Represents the blur intensity for the blurred part of the depth of field effect
  63602. */
  63603. depthOfFieldBlurWidth: number;
  63604. /**
  63605. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63606. */
  63607. /**
  63608. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63609. */
  63610. motionStrength: number;
  63611. /**
  63612. * Gets wether or not the motion blur post-process is object based or screen based.
  63613. */
  63614. /**
  63615. * Sets wether or not the motion blur post-process should be object based or screen based
  63616. */
  63617. objectBasedMotionBlur: boolean;
  63618. /**
  63619. * List of animations for the pipeline (IAnimatable implementation)
  63620. */
  63621. animations: Animation[];
  63622. /**
  63623. * Private members
  63624. */
  63625. private _scene;
  63626. private _currentDepthOfFieldSource;
  63627. private _basePostProcess;
  63628. private _fixedExposure;
  63629. private _currentExposure;
  63630. private _hdrAutoExposure;
  63631. private _hdrCurrentLuminance;
  63632. private _motionStrength;
  63633. private _isObjectBasedMotionBlur;
  63634. private _floatTextureType;
  63635. private _camerasToBeAttached;
  63636. private _ratio;
  63637. private _bloomEnabled;
  63638. private _depthOfFieldEnabled;
  63639. private _vlsEnabled;
  63640. private _lensFlareEnabled;
  63641. private _hdrEnabled;
  63642. private _motionBlurEnabled;
  63643. private _fxaaEnabled;
  63644. private _motionBlurSamples;
  63645. private _volumetricLightStepsCount;
  63646. private _samples;
  63647. /**
  63648. * @ignore
  63649. * Specifies if the bloom pipeline is enabled
  63650. */
  63651. BloomEnabled: boolean;
  63652. /**
  63653. * @ignore
  63654. * Specifies if the depth of field pipeline is enabed
  63655. */
  63656. DepthOfFieldEnabled: boolean;
  63657. /**
  63658. * @ignore
  63659. * Specifies if the lens flare pipeline is enabed
  63660. */
  63661. LensFlareEnabled: boolean;
  63662. /**
  63663. * @ignore
  63664. * Specifies if the HDR pipeline is enabled
  63665. */
  63666. HDREnabled: boolean;
  63667. /**
  63668. * @ignore
  63669. * Specifies if the volumetric lights scattering effect is enabled
  63670. */
  63671. VLSEnabled: boolean;
  63672. /**
  63673. * @ignore
  63674. * Specifies if the motion blur effect is enabled
  63675. */
  63676. MotionBlurEnabled: boolean;
  63677. /**
  63678. * Specifies if anti-aliasing is enabled
  63679. */
  63680. fxaaEnabled: boolean;
  63681. /**
  63682. * Specifies the number of steps used to calculate the volumetric lights
  63683. * Typically in interval [50, 200]
  63684. */
  63685. volumetricLightStepsCount: number;
  63686. /**
  63687. * Specifies the number of samples used for the motion blur effect
  63688. * Typically in interval [16, 64]
  63689. */
  63690. motionBlurSamples: number;
  63691. /**
  63692. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63693. */
  63694. samples: number;
  63695. /**
  63696. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63697. * @constructor
  63698. * @param name The rendering pipeline name
  63699. * @param scene The scene linked to this pipeline
  63700. * @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)
  63701. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63702. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63703. */
  63704. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63705. private _buildPipeline;
  63706. private _createDownSampleX4PostProcess;
  63707. private _createBrightPassPostProcess;
  63708. private _createBlurPostProcesses;
  63709. private _createTextureAdderPostProcess;
  63710. private _createVolumetricLightPostProcess;
  63711. private _createLuminancePostProcesses;
  63712. private _createHdrPostProcess;
  63713. private _createLensFlarePostProcess;
  63714. private _createDepthOfFieldPostProcess;
  63715. private _createMotionBlurPostProcess;
  63716. private _getDepthTexture;
  63717. private _disposePostProcesses;
  63718. /**
  63719. * Dispose of the pipeline and stop all post processes
  63720. */
  63721. dispose(): void;
  63722. /**
  63723. * Serialize the rendering pipeline (Used when exporting)
  63724. * @returns the serialized object
  63725. */
  63726. serialize(): any;
  63727. /**
  63728. * Parse the serialized pipeline
  63729. * @param source Source pipeline.
  63730. * @param scene The scene to load the pipeline to.
  63731. * @param rootUrl The URL of the serialized pipeline.
  63732. * @returns An instantiated pipeline from the serialized object.
  63733. */
  63734. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63735. /**
  63736. * Luminance steps
  63737. */
  63738. static LuminanceSteps: number;
  63739. }
  63740. }
  63741. declare module BABYLON {
  63742. /** @hidden */
  63743. export var tonemapPixelShader: {
  63744. name: string;
  63745. shader: string;
  63746. };
  63747. }
  63748. declare module BABYLON {
  63749. /** Defines operator used for tonemapping */
  63750. export enum TonemappingOperator {
  63751. /** Hable */
  63752. Hable = 0,
  63753. /** Reinhard */
  63754. Reinhard = 1,
  63755. /** HejiDawson */
  63756. HejiDawson = 2,
  63757. /** Photographic */
  63758. Photographic = 3
  63759. }
  63760. /**
  63761. * Defines a post process to apply tone mapping
  63762. */
  63763. export class TonemapPostProcess extends PostProcess {
  63764. private _operator;
  63765. /** Defines the required exposure adjustement */
  63766. exposureAdjustment: number;
  63767. /**
  63768. * Creates a new TonemapPostProcess
  63769. * @param name defines the name of the postprocess
  63770. * @param _operator defines the operator to use
  63771. * @param exposureAdjustment defines the required exposure adjustement
  63772. * @param camera defines the camera to use (can be null)
  63773. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63774. * @param engine defines the hosting engine (can be ignore if camera is set)
  63775. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63776. */
  63777. constructor(name: string, _operator: TonemappingOperator,
  63778. /** Defines the required exposure adjustement */
  63779. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63780. }
  63781. }
  63782. declare module BABYLON {
  63783. /** @hidden */
  63784. export var depthVertexShader: {
  63785. name: string;
  63786. shader: string;
  63787. };
  63788. }
  63789. declare module BABYLON {
  63790. /** @hidden */
  63791. export var volumetricLightScatteringPixelShader: {
  63792. name: string;
  63793. shader: string;
  63794. };
  63795. }
  63796. declare module BABYLON {
  63797. /** @hidden */
  63798. export var volumetricLightScatteringPassVertexShader: {
  63799. name: string;
  63800. shader: string;
  63801. };
  63802. }
  63803. declare module BABYLON {
  63804. /** @hidden */
  63805. export var volumetricLightScatteringPassPixelShader: {
  63806. name: string;
  63807. shader: string;
  63808. };
  63809. }
  63810. declare module BABYLON {
  63811. /**
  63812. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63813. */
  63814. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63815. private _volumetricLightScatteringPass;
  63816. private _volumetricLightScatteringRTT;
  63817. private _viewPort;
  63818. private _screenCoordinates;
  63819. private _cachedDefines;
  63820. /**
  63821. * If not undefined, the mesh position is computed from the attached node position
  63822. */
  63823. attachedNode: {
  63824. position: Vector3;
  63825. };
  63826. /**
  63827. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63828. */
  63829. customMeshPosition: Vector3;
  63830. /**
  63831. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63832. */
  63833. useCustomMeshPosition: boolean;
  63834. /**
  63835. * If the post-process should inverse the light scattering direction
  63836. */
  63837. invert: boolean;
  63838. /**
  63839. * The internal mesh used by the post-process
  63840. */
  63841. mesh: Mesh;
  63842. /**
  63843. * @hidden
  63844. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63845. */
  63846. useDiffuseColor: boolean;
  63847. /**
  63848. * Array containing the excluded meshes not rendered in the internal pass
  63849. */
  63850. excludedMeshes: AbstractMesh[];
  63851. /**
  63852. * Controls the overall intensity of the post-process
  63853. */
  63854. exposure: number;
  63855. /**
  63856. * Dissipates each sample's contribution in range [0, 1]
  63857. */
  63858. decay: number;
  63859. /**
  63860. * Controls the overall intensity of each sample
  63861. */
  63862. weight: number;
  63863. /**
  63864. * Controls the density of each sample
  63865. */
  63866. density: number;
  63867. /**
  63868. * @constructor
  63869. * @param name The post-process name
  63870. * @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)
  63871. * @param camera The camera that the post-process will be attached to
  63872. * @param mesh The mesh used to create the light scattering
  63873. * @param samples The post-process quality, default 100
  63874. * @param samplingModeThe post-process filtering mode
  63875. * @param engine The babylon engine
  63876. * @param reusable If the post-process is reusable
  63877. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63878. */
  63879. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63880. /**
  63881. * Returns the string "VolumetricLightScatteringPostProcess"
  63882. * @returns "VolumetricLightScatteringPostProcess"
  63883. */
  63884. getClassName(): string;
  63885. private _isReady;
  63886. /**
  63887. * Sets the new light position for light scattering effect
  63888. * @param position The new custom light position
  63889. */
  63890. setCustomMeshPosition(position: Vector3): void;
  63891. /**
  63892. * Returns the light position for light scattering effect
  63893. * @return Vector3 The custom light position
  63894. */
  63895. getCustomMeshPosition(): Vector3;
  63896. /**
  63897. * Disposes the internal assets and detaches the post-process from the camera
  63898. */
  63899. dispose(camera: Camera): void;
  63900. /**
  63901. * Returns the render target texture used by the post-process
  63902. * @return the render target texture used by the post-process
  63903. */
  63904. getPass(): RenderTargetTexture;
  63905. private _meshExcluded;
  63906. private _createPass;
  63907. private _updateMeshScreenCoordinates;
  63908. /**
  63909. * Creates a default mesh for the Volumeric Light Scattering post-process
  63910. * @param name The mesh name
  63911. * @param scene The scene where to create the mesh
  63912. * @return the default mesh
  63913. */
  63914. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63915. }
  63916. }
  63917. declare module BABYLON {
  63918. interface Scene {
  63919. /** @hidden (Backing field) */
  63920. _boundingBoxRenderer: BoundingBoxRenderer;
  63921. /** @hidden (Backing field) */
  63922. _forceShowBoundingBoxes: boolean;
  63923. /**
  63924. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63925. */
  63926. forceShowBoundingBoxes: boolean;
  63927. /**
  63928. * Gets the bounding box renderer associated with the scene
  63929. * @returns a BoundingBoxRenderer
  63930. */
  63931. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63932. }
  63933. interface AbstractMesh {
  63934. /** @hidden (Backing field) */
  63935. _showBoundingBox: boolean;
  63936. /**
  63937. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63938. */
  63939. showBoundingBox: boolean;
  63940. }
  63941. /**
  63942. * Component responsible of rendering the bounding box of the meshes in a scene.
  63943. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63944. */
  63945. export class BoundingBoxRenderer implements ISceneComponent {
  63946. /**
  63947. * The component name helpfull to identify the component in the list of scene components.
  63948. */
  63949. readonly name: string;
  63950. /**
  63951. * The scene the component belongs to.
  63952. */
  63953. scene: Scene;
  63954. /**
  63955. * Color of the bounding box lines placed in front of an object
  63956. */
  63957. frontColor: Color3;
  63958. /**
  63959. * Color of the bounding box lines placed behind an object
  63960. */
  63961. backColor: Color3;
  63962. /**
  63963. * Defines if the renderer should show the back lines or not
  63964. */
  63965. showBackLines: boolean;
  63966. /**
  63967. * @hidden
  63968. */
  63969. renderList: SmartArray<BoundingBox>;
  63970. private _colorShader;
  63971. private _vertexBuffers;
  63972. private _indexBuffer;
  63973. private _fillIndexBuffer;
  63974. private _fillIndexData;
  63975. /**
  63976. * Instantiates a new bounding box renderer in a scene.
  63977. * @param scene the scene the renderer renders in
  63978. */
  63979. constructor(scene: Scene);
  63980. /**
  63981. * Registers the component in a given scene
  63982. */
  63983. register(): void;
  63984. private _evaluateSubMesh;
  63985. private _activeMesh;
  63986. private _prepareRessources;
  63987. private _createIndexBuffer;
  63988. /**
  63989. * Rebuilds the elements related to this component in case of
  63990. * context lost for instance.
  63991. */
  63992. rebuild(): void;
  63993. /**
  63994. * @hidden
  63995. */
  63996. reset(): void;
  63997. /**
  63998. * Render the bounding boxes of a specific rendering group
  63999. * @param renderingGroupId defines the rendering group to render
  64000. */
  64001. render(renderingGroupId: number): void;
  64002. /**
  64003. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64004. * @param mesh Define the mesh to render the occlusion bounding box for
  64005. */
  64006. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64007. /**
  64008. * Dispose and release the resources attached to this renderer.
  64009. */
  64010. dispose(): void;
  64011. }
  64012. }
  64013. declare module BABYLON {
  64014. /** @hidden */
  64015. export var depthPixelShader: {
  64016. name: string;
  64017. shader: string;
  64018. };
  64019. }
  64020. declare module BABYLON {
  64021. /**
  64022. * This represents a depth renderer in Babylon.
  64023. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64024. */
  64025. export class DepthRenderer {
  64026. private _scene;
  64027. private _depthMap;
  64028. private _effect;
  64029. private readonly _storeNonLinearDepth;
  64030. private readonly _clearColor;
  64031. /** Get if the depth renderer is using packed depth or not */
  64032. readonly isPacked: boolean;
  64033. private _cachedDefines;
  64034. private _camera;
  64035. /**
  64036. * Specifiess that the depth renderer will only be used within
  64037. * the camera it is created for.
  64038. * This can help forcing its rendering during the camera processing.
  64039. */
  64040. useOnlyInActiveCamera: boolean;
  64041. /** @hidden */
  64042. static _SceneComponentInitialization: (scene: Scene) => void;
  64043. /**
  64044. * Instantiates a depth renderer
  64045. * @param scene The scene the renderer belongs to
  64046. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64047. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64048. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64049. */
  64050. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64051. /**
  64052. * Creates the depth rendering effect and checks if the effect is ready.
  64053. * @param subMesh The submesh to be used to render the depth map of
  64054. * @param useInstances If multiple world instances should be used
  64055. * @returns if the depth renderer is ready to render the depth map
  64056. */
  64057. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64058. /**
  64059. * Gets the texture which the depth map will be written to.
  64060. * @returns The depth map texture
  64061. */
  64062. getDepthMap(): RenderTargetTexture;
  64063. /**
  64064. * Disposes of the depth renderer.
  64065. */
  64066. dispose(): void;
  64067. }
  64068. }
  64069. declare module BABYLON {
  64070. interface Scene {
  64071. /** @hidden (Backing field) */
  64072. _depthRenderer: {
  64073. [id: string]: DepthRenderer;
  64074. };
  64075. /**
  64076. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64077. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64078. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64079. * @returns the created depth renderer
  64080. */
  64081. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64082. /**
  64083. * Disables a depth renderer for a given camera
  64084. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64085. */
  64086. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64087. }
  64088. /**
  64089. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64090. * in several rendering techniques.
  64091. */
  64092. export class DepthRendererSceneComponent implements ISceneComponent {
  64093. /**
  64094. * The component name helpfull to identify the component in the list of scene components.
  64095. */
  64096. readonly name: string;
  64097. /**
  64098. * The scene the component belongs to.
  64099. */
  64100. scene: Scene;
  64101. /**
  64102. * Creates a new instance of the component for the given scene
  64103. * @param scene Defines the scene to register the component in
  64104. */
  64105. constructor(scene: Scene);
  64106. /**
  64107. * Registers the component in a given scene
  64108. */
  64109. register(): void;
  64110. /**
  64111. * Rebuilds the elements related to this component in case of
  64112. * context lost for instance.
  64113. */
  64114. rebuild(): void;
  64115. /**
  64116. * Disposes the component and the associated ressources
  64117. */
  64118. dispose(): void;
  64119. private _gatherRenderTargets;
  64120. private _gatherActiveCameraRenderTargets;
  64121. }
  64122. }
  64123. declare module BABYLON {
  64124. /** @hidden */
  64125. export var outlinePixelShader: {
  64126. name: string;
  64127. shader: string;
  64128. };
  64129. }
  64130. declare module BABYLON {
  64131. /** @hidden */
  64132. export var outlineVertexShader: {
  64133. name: string;
  64134. shader: string;
  64135. };
  64136. }
  64137. declare module BABYLON {
  64138. interface Scene {
  64139. /** @hidden */
  64140. _outlineRenderer: OutlineRenderer;
  64141. /**
  64142. * Gets the outline renderer associated with the scene
  64143. * @returns a OutlineRenderer
  64144. */
  64145. getOutlineRenderer(): OutlineRenderer;
  64146. }
  64147. interface AbstractMesh {
  64148. /** @hidden (Backing field) */
  64149. _renderOutline: boolean;
  64150. /**
  64151. * Gets or sets a boolean indicating if the outline must be rendered as well
  64152. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64153. */
  64154. renderOutline: boolean;
  64155. /** @hidden (Backing field) */
  64156. _renderOverlay: boolean;
  64157. /**
  64158. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64159. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64160. */
  64161. renderOverlay: boolean;
  64162. }
  64163. /**
  64164. * This class is responsible to draw bothe outline/overlay of meshes.
  64165. * It should not be used directly but through the available method on mesh.
  64166. */
  64167. export class OutlineRenderer implements ISceneComponent {
  64168. /**
  64169. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64170. */
  64171. private static _StencilReference;
  64172. /**
  64173. * The name of the component. Each component must have a unique name.
  64174. */
  64175. name: string;
  64176. /**
  64177. * The scene the component belongs to.
  64178. */
  64179. scene: Scene;
  64180. /**
  64181. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64182. */
  64183. zOffset: number;
  64184. private _engine;
  64185. private _effect;
  64186. private _cachedDefines;
  64187. private _savedDepthWrite;
  64188. /**
  64189. * Instantiates a new outline renderer. (There could be only one per scene).
  64190. * @param scene Defines the scene it belongs to
  64191. */
  64192. constructor(scene: Scene);
  64193. /**
  64194. * Register the component to one instance of a scene.
  64195. */
  64196. register(): void;
  64197. /**
  64198. * Rebuilds the elements related to this component in case of
  64199. * context lost for instance.
  64200. */
  64201. rebuild(): void;
  64202. /**
  64203. * Disposes the component and the associated ressources.
  64204. */
  64205. dispose(): void;
  64206. /**
  64207. * Renders the outline in the canvas.
  64208. * @param subMesh Defines the sumesh to render
  64209. * @param batch Defines the batch of meshes in case of instances
  64210. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64211. */
  64212. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64213. /**
  64214. * Returns whether or not the outline renderer is ready for a given submesh.
  64215. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64216. * @param subMesh Defines the submesh to check readyness for
  64217. * @param useInstances Defines wheter wee are trying to render instances or not
  64218. * @returns true if ready otherwise false
  64219. */
  64220. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64221. private _beforeRenderingMesh;
  64222. private _afterRenderingMesh;
  64223. }
  64224. }
  64225. declare module BABYLON {
  64226. /**
  64227. * Defines the basic options interface of a Sprite Frame Source Size.
  64228. */
  64229. export interface ISpriteJSONSpriteSourceSize {
  64230. /**
  64231. * number of the original width of the Frame
  64232. */
  64233. w: number;
  64234. /**
  64235. * number of the original height of the Frame
  64236. */
  64237. h: number;
  64238. }
  64239. /**
  64240. * Defines the basic options interface of a Sprite Frame Data.
  64241. */
  64242. export interface ISpriteJSONSpriteFrameData {
  64243. /**
  64244. * number of the x offset of the Frame
  64245. */
  64246. x: number;
  64247. /**
  64248. * number of the y offset of the Frame
  64249. */
  64250. y: number;
  64251. /**
  64252. * number of the width of the Frame
  64253. */
  64254. w: number;
  64255. /**
  64256. * number of the height of the Frame
  64257. */
  64258. h: number;
  64259. }
  64260. /**
  64261. * Defines the basic options interface of a JSON Sprite.
  64262. */
  64263. export interface ISpriteJSONSprite {
  64264. /**
  64265. * string name of the Frame
  64266. */
  64267. filename: string;
  64268. /**
  64269. * ISpriteJSONSpriteFrame basic object of the frame data
  64270. */
  64271. frame: ISpriteJSONSpriteFrameData;
  64272. /**
  64273. * boolean to flag is the frame was rotated.
  64274. */
  64275. rotated: boolean;
  64276. /**
  64277. * boolean to flag is the frame was trimmed.
  64278. */
  64279. trimmed: boolean;
  64280. /**
  64281. * ISpriteJSONSpriteFrame basic object of the source data
  64282. */
  64283. spriteSourceSize: ISpriteJSONSpriteFrameData;
  64284. /**
  64285. * ISpriteJSONSpriteFrame basic object of the source data
  64286. */
  64287. sourceSize: ISpriteJSONSpriteSourceSize;
  64288. }
  64289. /**
  64290. * Defines the basic options interface of a JSON atlas.
  64291. */
  64292. export interface ISpriteJSONAtlas {
  64293. /**
  64294. * Array of objects that contain the frame data.
  64295. */
  64296. frames: Array<ISpriteJSONSprite>;
  64297. /**
  64298. * object basic object containing the sprite meta data.
  64299. */
  64300. meta?: object;
  64301. }
  64302. }
  64303. declare module BABYLON {
  64304. /** @hidden */
  64305. export var spriteMapPixelShader: {
  64306. name: string;
  64307. shader: string;
  64308. };
  64309. }
  64310. declare module BABYLON {
  64311. /** @hidden */
  64312. export var spriteMapVertexShader: {
  64313. name: string;
  64314. shader: string;
  64315. };
  64316. }
  64317. declare module BABYLON {
  64318. /**
  64319. * Defines the basic options interface of a SpriteMap
  64320. */
  64321. export interface ISpriteMapOptions {
  64322. /**
  64323. * Vector2 of the number of cells in the grid.
  64324. */
  64325. stageSize?: Vector2;
  64326. /**
  64327. * Vector2 of the size of the output plane in World Units.
  64328. */
  64329. outputSize?: Vector2;
  64330. /**
  64331. * Vector3 of the position of the output plane in World Units.
  64332. */
  64333. outputPosition?: Vector3;
  64334. /**
  64335. * Vector3 of the rotation of the output plane.
  64336. */
  64337. outputRotation?: Vector3;
  64338. /**
  64339. * number of layers that the system will reserve in resources.
  64340. */
  64341. layerCount?: number;
  64342. /**
  64343. * number of max animation frames a single cell will reserve in resources.
  64344. */
  64345. maxAnimationFrames?: number;
  64346. /**
  64347. * number cell index of the base tile when the system compiles.
  64348. */
  64349. baseTile?: number;
  64350. /**
  64351. * boolean flip the sprite after its been repositioned by the framing data.
  64352. */
  64353. flipU?: boolean;
  64354. /**
  64355. * Vector3 scalar of the global RGB values of the SpriteMap.
  64356. */
  64357. colorMultiply?: Vector3;
  64358. }
  64359. /**
  64360. * Defines the IDisposable interface in order to be cleanable from resources.
  64361. */
  64362. export interface ISpriteMap extends IDisposable {
  64363. /**
  64364. * String name of the SpriteMap.
  64365. */
  64366. name: string;
  64367. /**
  64368. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  64369. */
  64370. atlasJSON: ISpriteJSONAtlas;
  64371. /**
  64372. * Texture of the SpriteMap.
  64373. */
  64374. spriteSheet: Texture;
  64375. /**
  64376. * The parameters to initialize the SpriteMap with.
  64377. */
  64378. options: ISpriteMapOptions;
  64379. }
  64380. /**
  64381. * Class used to manage a grid restricted sprite deployment on an Output plane.
  64382. */
  64383. export class SpriteMap implements ISpriteMap {
  64384. /** The Name of the spriteMap */
  64385. name: string;
  64386. /** The JSON file with the frame and meta data */
  64387. atlasJSON: ISpriteJSONAtlas;
  64388. /** The systems Sprite Sheet Texture */
  64389. spriteSheet: Texture;
  64390. /** Arguments passed with the Constructor */
  64391. options: ISpriteMapOptions;
  64392. /** Public Sprite Storage array, parsed from atlasJSON */
  64393. sprites: Array<ISpriteJSONSprite>;
  64394. /** Returns the Number of Sprites in the System */
  64395. readonly spriteCount: number;
  64396. /** Returns the Position of Output Plane*/
  64397. /** Returns the Position of Output Plane*/
  64398. position: Vector3;
  64399. /** Returns the Rotation of Output Plane*/
  64400. /** Returns the Rotation of Output Plane*/
  64401. rotation: Vector3;
  64402. /** Sets the AnimationMap*/
  64403. /** Sets the AnimationMap*/
  64404. animationMap: RawTexture;
  64405. /** Scene that the SpriteMap was created in */
  64406. private _scene;
  64407. /** Texture Buffer of Float32 that holds tile frame data*/
  64408. private _frameMap;
  64409. /** Texture Buffers of Float32 that holds tileMap data*/
  64410. private _tileMaps;
  64411. /** Texture Buffer of Float32 that holds Animation Data*/
  64412. private _animationMap;
  64413. /** Custom ShaderMaterial Central to the System*/
  64414. private _material;
  64415. /** Custom ShaderMaterial Central to the System*/
  64416. private _output;
  64417. /** Systems Time Ticker*/
  64418. private _time;
  64419. /**
  64420. * Creates a new SpriteMap
  64421. * @param name defines the SpriteMaps Name
  64422. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  64423. * @param spriteSheet is the Texture that the Sprites are on.
  64424. * @param options a basic deployment configuration
  64425. * @param scene The Scene that the map is deployed on
  64426. */
  64427. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  64428. /**
  64429. * Returns tileID location
  64430. * @returns Vector2 the cell position ID
  64431. */
  64432. getTileID(): Vector2;
  64433. /**
  64434. * Gets the UV location of the mouse over the SpriteMap.
  64435. * @returns Vector2 the UV position of the mouse interaction
  64436. */
  64437. getMousePosition(): Vector2;
  64438. /**
  64439. * Creates the "frame" texture Buffer
  64440. * -------------------------------------
  64441. * Structure of frames
  64442. * "filename": "Falling-Water-2.png",
  64443. * "frame": {"x":69,"y":103,"w":24,"h":32},
  64444. * "rotated": true,
  64445. * "trimmed": true,
  64446. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  64447. * "sourceSize": {"w":32,"h":32}
  64448. * @returns RawTexture of the frameMap
  64449. */
  64450. private _createFrameBuffer;
  64451. /**
  64452. * Creates the tileMap texture Buffer
  64453. * @param buffer normally and array of numbers, or a false to generate from scratch
  64454. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  64455. * @returns RawTexture of the tileMap
  64456. */
  64457. private _createTileBuffer;
  64458. /**
  64459. * Modifies the data of the tileMaps
  64460. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  64461. * @param pos is the iVector2 Coordinates of the Tile
  64462. * @param tile The SpriteIndex of the new Tile
  64463. */
  64464. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  64465. /**
  64466. * Creates the animationMap texture Buffer
  64467. * @param buffer normally and array of numbers, or a false to generate from scratch
  64468. * @returns RawTexture of the animationMap
  64469. */
  64470. private _createTileAnimationBuffer;
  64471. /**
  64472. * Modifies the data of the animationMap
  64473. * @param cellID is the Index of the Sprite
  64474. * @param _frame is the target Animation frame
  64475. * @param toCell is the Target Index of the next frame of the animation
  64476. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  64477. * @param speed is a global scalar of the time variable on the map.
  64478. */
  64479. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  64480. /**
  64481. * Exports the .tilemaps file
  64482. */
  64483. saveTileMaps(): void;
  64484. /**
  64485. * Imports the .tilemaps file
  64486. * @param url of the .tilemaps file
  64487. */
  64488. loadTileMaps(url: string): void;
  64489. /**
  64490. * Release associated resources
  64491. */
  64492. dispose(): void;
  64493. }
  64494. }
  64495. declare module BABYLON {
  64496. /**
  64497. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64498. * @see http://doc.babylonjs.com/babylon101/sprites
  64499. */
  64500. export class SpritePackedManager extends SpriteManager {
  64501. /** defines the packed manager's name */
  64502. name: string;
  64503. /**
  64504. * Creates a new sprite manager from a packed sprite sheet
  64505. * @param name defines the manager's name
  64506. * @param imgUrl defines the sprite sheet url
  64507. * @param capacity defines the maximum allowed number of sprites
  64508. * @param scene defines the hosting scene
  64509. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64510. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64511. * @param samplingMode defines the smapling mode to use with spritesheet
  64512. * @param fromPacked set to true; do not alter
  64513. */
  64514. constructor(
  64515. /** defines the packed manager's name */
  64516. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64517. }
  64518. }
  64519. declare module BABYLON {
  64520. /**
  64521. * Defines the list of states available for a task inside a AssetsManager
  64522. */
  64523. export enum AssetTaskState {
  64524. /**
  64525. * Initialization
  64526. */
  64527. INIT = 0,
  64528. /**
  64529. * Running
  64530. */
  64531. RUNNING = 1,
  64532. /**
  64533. * Done
  64534. */
  64535. DONE = 2,
  64536. /**
  64537. * Error
  64538. */
  64539. ERROR = 3
  64540. }
  64541. /**
  64542. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64543. */
  64544. export abstract class AbstractAssetTask {
  64545. /**
  64546. * Task name
  64547. */ name: string;
  64548. /**
  64549. * Callback called when the task is successful
  64550. */
  64551. onSuccess: (task: any) => void;
  64552. /**
  64553. * Callback called when the task is not successful
  64554. */
  64555. onError: (task: any, message?: string, exception?: any) => void;
  64556. /**
  64557. * Creates a new AssetsManager
  64558. * @param name defines the name of the task
  64559. */
  64560. constructor(
  64561. /**
  64562. * Task name
  64563. */ name: string);
  64564. private _isCompleted;
  64565. private _taskState;
  64566. private _errorObject;
  64567. /**
  64568. * Get if the task is completed
  64569. */
  64570. readonly isCompleted: boolean;
  64571. /**
  64572. * Gets the current state of the task
  64573. */
  64574. readonly taskState: AssetTaskState;
  64575. /**
  64576. * Gets the current error object (if task is in error)
  64577. */
  64578. readonly errorObject: {
  64579. message?: string;
  64580. exception?: any;
  64581. };
  64582. /**
  64583. * Internal only
  64584. * @hidden
  64585. */
  64586. _setErrorObject(message?: string, exception?: any): void;
  64587. /**
  64588. * Execute the current task
  64589. * @param scene defines the scene where you want your assets to be loaded
  64590. * @param onSuccess is a callback called when the task is successfully executed
  64591. * @param onError is a callback called if an error occurs
  64592. */
  64593. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64594. /**
  64595. * Execute the current task
  64596. * @param scene defines the scene where you want your assets to be loaded
  64597. * @param onSuccess is a callback called when the task is successfully executed
  64598. * @param onError is a callback called if an error occurs
  64599. */
  64600. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64601. /**
  64602. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64603. * This can be used with failed tasks that have the reason for failure fixed.
  64604. */
  64605. reset(): void;
  64606. private onErrorCallback;
  64607. private onDoneCallback;
  64608. }
  64609. /**
  64610. * Define the interface used by progress events raised during assets loading
  64611. */
  64612. export interface IAssetsProgressEvent {
  64613. /**
  64614. * Defines the number of remaining tasks to process
  64615. */
  64616. remainingCount: number;
  64617. /**
  64618. * Defines the total number of tasks
  64619. */
  64620. totalCount: number;
  64621. /**
  64622. * Defines the task that was just processed
  64623. */
  64624. task: AbstractAssetTask;
  64625. }
  64626. /**
  64627. * Class used to share progress information about assets loading
  64628. */
  64629. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64630. /**
  64631. * Defines the number of remaining tasks to process
  64632. */
  64633. remainingCount: number;
  64634. /**
  64635. * Defines the total number of tasks
  64636. */
  64637. totalCount: number;
  64638. /**
  64639. * Defines the task that was just processed
  64640. */
  64641. task: AbstractAssetTask;
  64642. /**
  64643. * Creates a AssetsProgressEvent
  64644. * @param remainingCount defines the number of remaining tasks to process
  64645. * @param totalCount defines the total number of tasks
  64646. * @param task defines the task that was just processed
  64647. */
  64648. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64649. }
  64650. /**
  64651. * Define a task used by AssetsManager to load meshes
  64652. */
  64653. export class MeshAssetTask extends AbstractAssetTask {
  64654. /**
  64655. * Defines the name of the task
  64656. */
  64657. name: string;
  64658. /**
  64659. * Defines the list of mesh's names you want to load
  64660. */
  64661. meshesNames: any;
  64662. /**
  64663. * Defines the root url to use as a base to load your meshes and associated resources
  64664. */
  64665. rootUrl: string;
  64666. /**
  64667. * Defines the filename of the scene to load from
  64668. */
  64669. sceneFilename: string;
  64670. /**
  64671. * Gets the list of loaded meshes
  64672. */
  64673. loadedMeshes: Array<AbstractMesh>;
  64674. /**
  64675. * Gets the list of loaded particle systems
  64676. */
  64677. loadedParticleSystems: Array<IParticleSystem>;
  64678. /**
  64679. * Gets the list of loaded skeletons
  64680. */
  64681. loadedSkeletons: Array<Skeleton>;
  64682. /**
  64683. * Gets the list of loaded animation groups
  64684. */
  64685. loadedAnimationGroups: Array<AnimationGroup>;
  64686. /**
  64687. * Callback called when the task is successful
  64688. */
  64689. onSuccess: (task: MeshAssetTask) => void;
  64690. /**
  64691. * Callback called when the task is successful
  64692. */
  64693. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64694. /**
  64695. * Creates a new MeshAssetTask
  64696. * @param name defines the name of the task
  64697. * @param meshesNames defines the list of mesh's names you want to load
  64698. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64699. * @param sceneFilename defines the filename of the scene to load from
  64700. */
  64701. constructor(
  64702. /**
  64703. * Defines the name of the task
  64704. */
  64705. name: string,
  64706. /**
  64707. * Defines the list of mesh's names you want to load
  64708. */
  64709. meshesNames: any,
  64710. /**
  64711. * Defines the root url to use as a base to load your meshes and associated resources
  64712. */
  64713. rootUrl: string,
  64714. /**
  64715. * Defines the filename of the scene to load from
  64716. */
  64717. sceneFilename: string);
  64718. /**
  64719. * Execute the current task
  64720. * @param scene defines the scene where you want your assets to be loaded
  64721. * @param onSuccess is a callback called when the task is successfully executed
  64722. * @param onError is a callback called if an error occurs
  64723. */
  64724. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64725. }
  64726. /**
  64727. * Define a task used by AssetsManager to load text content
  64728. */
  64729. export class TextFileAssetTask extends AbstractAssetTask {
  64730. /**
  64731. * Defines the name of the task
  64732. */
  64733. name: string;
  64734. /**
  64735. * Defines the location of the file to load
  64736. */
  64737. url: string;
  64738. /**
  64739. * Gets the loaded text string
  64740. */
  64741. text: string;
  64742. /**
  64743. * Callback called when the task is successful
  64744. */
  64745. onSuccess: (task: TextFileAssetTask) => void;
  64746. /**
  64747. * Callback called when the task is successful
  64748. */
  64749. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64750. /**
  64751. * Creates a new TextFileAssetTask object
  64752. * @param name defines the name of the task
  64753. * @param url defines the location of the file to load
  64754. */
  64755. constructor(
  64756. /**
  64757. * Defines the name of the task
  64758. */
  64759. name: string,
  64760. /**
  64761. * Defines the location of the file to load
  64762. */
  64763. url: string);
  64764. /**
  64765. * Execute the current task
  64766. * @param scene defines the scene where you want your assets to be loaded
  64767. * @param onSuccess is a callback called when the task is successfully executed
  64768. * @param onError is a callback called if an error occurs
  64769. */
  64770. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64771. }
  64772. /**
  64773. * Define a task used by AssetsManager to load binary data
  64774. */
  64775. export class BinaryFileAssetTask extends AbstractAssetTask {
  64776. /**
  64777. * Defines the name of the task
  64778. */
  64779. name: string;
  64780. /**
  64781. * Defines the location of the file to load
  64782. */
  64783. url: string;
  64784. /**
  64785. * Gets the lodaded data (as an array buffer)
  64786. */
  64787. data: ArrayBuffer;
  64788. /**
  64789. * Callback called when the task is successful
  64790. */
  64791. onSuccess: (task: BinaryFileAssetTask) => void;
  64792. /**
  64793. * Callback called when the task is successful
  64794. */
  64795. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64796. /**
  64797. * Creates a new BinaryFileAssetTask object
  64798. * @param name defines the name of the new task
  64799. * @param url defines the location of the file to load
  64800. */
  64801. constructor(
  64802. /**
  64803. * Defines the name of the task
  64804. */
  64805. name: string,
  64806. /**
  64807. * Defines the location of the file to load
  64808. */
  64809. url: string);
  64810. /**
  64811. * Execute the current task
  64812. * @param scene defines the scene where you want your assets to be loaded
  64813. * @param onSuccess is a callback called when the task is successfully executed
  64814. * @param onError is a callback called if an error occurs
  64815. */
  64816. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64817. }
  64818. /**
  64819. * Define a task used by AssetsManager to load images
  64820. */
  64821. export class ImageAssetTask extends AbstractAssetTask {
  64822. /**
  64823. * Defines the name of the task
  64824. */
  64825. name: string;
  64826. /**
  64827. * Defines the location of the image to load
  64828. */
  64829. url: string;
  64830. /**
  64831. * Gets the loaded images
  64832. */
  64833. image: HTMLImageElement;
  64834. /**
  64835. * Callback called when the task is successful
  64836. */
  64837. onSuccess: (task: ImageAssetTask) => void;
  64838. /**
  64839. * Callback called when the task is successful
  64840. */
  64841. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64842. /**
  64843. * Creates a new ImageAssetTask
  64844. * @param name defines the name of the task
  64845. * @param url defines the location of the image to load
  64846. */
  64847. constructor(
  64848. /**
  64849. * Defines the name of the task
  64850. */
  64851. name: string,
  64852. /**
  64853. * Defines the location of the image to load
  64854. */
  64855. url: string);
  64856. /**
  64857. * Execute the current task
  64858. * @param scene defines the scene where you want your assets to be loaded
  64859. * @param onSuccess is a callback called when the task is successfully executed
  64860. * @param onError is a callback called if an error occurs
  64861. */
  64862. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64863. }
  64864. /**
  64865. * Defines the interface used by texture loading tasks
  64866. */
  64867. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64868. /**
  64869. * Gets the loaded texture
  64870. */
  64871. texture: TEX;
  64872. }
  64873. /**
  64874. * Define a task used by AssetsManager to load 2D textures
  64875. */
  64876. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64877. /**
  64878. * Defines the name of the task
  64879. */
  64880. name: string;
  64881. /**
  64882. * Defines the location of the file to load
  64883. */
  64884. url: string;
  64885. /**
  64886. * Defines if mipmap should not be generated (default is false)
  64887. */
  64888. noMipmap?: boolean | undefined;
  64889. /**
  64890. * Defines if texture must be inverted on Y axis (default is false)
  64891. */
  64892. invertY?: boolean | undefined;
  64893. /**
  64894. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64895. */
  64896. samplingMode: number;
  64897. /**
  64898. * Gets the loaded texture
  64899. */
  64900. texture: Texture;
  64901. /**
  64902. * Callback called when the task is successful
  64903. */
  64904. onSuccess: (task: TextureAssetTask) => void;
  64905. /**
  64906. * Callback called when the task is successful
  64907. */
  64908. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64909. /**
  64910. * Creates a new TextureAssetTask object
  64911. * @param name defines the name of the task
  64912. * @param url defines the location of the file to load
  64913. * @param noMipmap defines if mipmap should not be generated (default is false)
  64914. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64915. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64916. */
  64917. constructor(
  64918. /**
  64919. * Defines the name of the task
  64920. */
  64921. name: string,
  64922. /**
  64923. * Defines the location of the file to load
  64924. */
  64925. url: string,
  64926. /**
  64927. * Defines if mipmap should not be generated (default is false)
  64928. */
  64929. noMipmap?: boolean | undefined,
  64930. /**
  64931. * Defines if texture must be inverted on Y axis (default is false)
  64932. */
  64933. invertY?: boolean | undefined,
  64934. /**
  64935. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64936. */
  64937. samplingMode?: number);
  64938. /**
  64939. * Execute the current task
  64940. * @param scene defines the scene where you want your assets to be loaded
  64941. * @param onSuccess is a callback called when the task is successfully executed
  64942. * @param onError is a callback called if an error occurs
  64943. */
  64944. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64945. }
  64946. /**
  64947. * Define a task used by AssetsManager to load cube textures
  64948. */
  64949. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64950. /**
  64951. * Defines the name of the task
  64952. */
  64953. name: string;
  64954. /**
  64955. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64956. */
  64957. url: string;
  64958. /**
  64959. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64960. */
  64961. extensions?: string[] | undefined;
  64962. /**
  64963. * Defines if mipmaps should not be generated (default is false)
  64964. */
  64965. noMipmap?: boolean | undefined;
  64966. /**
  64967. * Defines the explicit list of files (undefined by default)
  64968. */
  64969. files?: string[] | undefined;
  64970. /**
  64971. * Gets the loaded texture
  64972. */
  64973. texture: CubeTexture;
  64974. /**
  64975. * Callback called when the task is successful
  64976. */
  64977. onSuccess: (task: CubeTextureAssetTask) => void;
  64978. /**
  64979. * Callback called when the task is successful
  64980. */
  64981. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64982. /**
  64983. * Creates a new CubeTextureAssetTask
  64984. * @param name defines the name of the task
  64985. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64986. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64987. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64988. * @param files defines the explicit list of files (undefined by default)
  64989. */
  64990. constructor(
  64991. /**
  64992. * Defines the name of the task
  64993. */
  64994. name: string,
  64995. /**
  64996. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64997. */
  64998. url: string,
  64999. /**
  65000. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65001. */
  65002. extensions?: string[] | undefined,
  65003. /**
  65004. * Defines if mipmaps should not be generated (default is false)
  65005. */
  65006. noMipmap?: boolean | undefined,
  65007. /**
  65008. * Defines the explicit list of files (undefined by default)
  65009. */
  65010. files?: string[] | undefined);
  65011. /**
  65012. * Execute the current task
  65013. * @param scene defines the scene where you want your assets to be loaded
  65014. * @param onSuccess is a callback called when the task is successfully executed
  65015. * @param onError is a callback called if an error occurs
  65016. */
  65017. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65018. }
  65019. /**
  65020. * Define a task used by AssetsManager to load HDR cube textures
  65021. */
  65022. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65023. /**
  65024. * Defines the name of the task
  65025. */
  65026. name: string;
  65027. /**
  65028. * Defines the location of the file to load
  65029. */
  65030. url: string;
  65031. /**
  65032. * Defines the desired size (the more it increases the longer the generation will be)
  65033. */
  65034. size: number;
  65035. /**
  65036. * Defines if mipmaps should not be generated (default is false)
  65037. */
  65038. noMipmap: boolean;
  65039. /**
  65040. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65041. */
  65042. generateHarmonics: boolean;
  65043. /**
  65044. * 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)
  65045. */
  65046. gammaSpace: boolean;
  65047. /**
  65048. * Internal Use Only
  65049. */
  65050. reserved: boolean;
  65051. /**
  65052. * Gets the loaded texture
  65053. */
  65054. texture: HDRCubeTexture;
  65055. /**
  65056. * Callback called when the task is successful
  65057. */
  65058. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65059. /**
  65060. * Callback called when the task is successful
  65061. */
  65062. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65063. /**
  65064. * Creates a new HDRCubeTextureAssetTask object
  65065. * @param name defines the name of the task
  65066. * @param url defines the location of the file to load
  65067. * @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.
  65068. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65069. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65070. * @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)
  65071. * @param reserved Internal use only
  65072. */
  65073. constructor(
  65074. /**
  65075. * Defines the name of the task
  65076. */
  65077. name: string,
  65078. /**
  65079. * Defines the location of the file to load
  65080. */
  65081. url: string,
  65082. /**
  65083. * Defines the desired size (the more it increases the longer the generation will be)
  65084. */
  65085. size: number,
  65086. /**
  65087. * Defines if mipmaps should not be generated (default is false)
  65088. */
  65089. noMipmap?: boolean,
  65090. /**
  65091. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65092. */
  65093. generateHarmonics?: boolean,
  65094. /**
  65095. * 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)
  65096. */
  65097. gammaSpace?: boolean,
  65098. /**
  65099. * Internal Use Only
  65100. */
  65101. reserved?: boolean);
  65102. /**
  65103. * Execute the current task
  65104. * @param scene defines the scene where you want your assets to be loaded
  65105. * @param onSuccess is a callback called when the task is successfully executed
  65106. * @param onError is a callback called if an error occurs
  65107. */
  65108. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65109. }
  65110. /**
  65111. * Define a task used by AssetsManager to load Equirectangular cube textures
  65112. */
  65113. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65114. /**
  65115. * Defines the name of the task
  65116. */
  65117. name: string;
  65118. /**
  65119. * Defines the location of the file to load
  65120. */
  65121. url: string;
  65122. /**
  65123. * Defines the desired size (the more it increases the longer the generation will be)
  65124. */
  65125. size: number;
  65126. /**
  65127. * Defines if mipmaps should not be generated (default is false)
  65128. */
  65129. noMipmap: boolean;
  65130. /**
  65131. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65132. * but the standard material would require them in Gamma space) (default is true)
  65133. */
  65134. gammaSpace: boolean;
  65135. /**
  65136. * Gets the loaded texture
  65137. */
  65138. texture: EquiRectangularCubeTexture;
  65139. /**
  65140. * Callback called when the task is successful
  65141. */
  65142. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65143. /**
  65144. * Callback called when the task is successful
  65145. */
  65146. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65147. /**
  65148. * Creates a new EquiRectangularCubeTextureAssetTask object
  65149. * @param name defines the name of the task
  65150. * @param url defines the location of the file to load
  65151. * @param size defines the desired size (the more it increases the longer the generation will be)
  65152. * If the size is omitted this implies you are using a preprocessed cubemap.
  65153. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65154. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65155. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65156. * (default is true)
  65157. */
  65158. constructor(
  65159. /**
  65160. * Defines the name of the task
  65161. */
  65162. name: string,
  65163. /**
  65164. * Defines the location of the file to load
  65165. */
  65166. url: string,
  65167. /**
  65168. * Defines the desired size (the more it increases the longer the generation will be)
  65169. */
  65170. size: number,
  65171. /**
  65172. * Defines if mipmaps should not be generated (default is false)
  65173. */
  65174. noMipmap?: boolean,
  65175. /**
  65176. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65177. * but the standard material would require them in Gamma space) (default is true)
  65178. */
  65179. gammaSpace?: boolean);
  65180. /**
  65181. * Execute the current task
  65182. * @param scene defines the scene where you want your assets to be loaded
  65183. * @param onSuccess is a callback called when the task is successfully executed
  65184. * @param onError is a callback called if an error occurs
  65185. */
  65186. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65187. }
  65188. /**
  65189. * This class can be used to easily import assets into a scene
  65190. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65191. */
  65192. export class AssetsManager {
  65193. private _scene;
  65194. private _isLoading;
  65195. protected _tasks: AbstractAssetTask[];
  65196. protected _waitingTasksCount: number;
  65197. protected _totalTasksCount: number;
  65198. /**
  65199. * Callback called when all tasks are processed
  65200. */
  65201. onFinish: (tasks: AbstractAssetTask[]) => void;
  65202. /**
  65203. * Callback called when a task is successful
  65204. */
  65205. onTaskSuccess: (task: AbstractAssetTask) => void;
  65206. /**
  65207. * Callback called when a task had an error
  65208. */
  65209. onTaskError: (task: AbstractAssetTask) => void;
  65210. /**
  65211. * Callback called when a task is done (whatever the result is)
  65212. */
  65213. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65214. /**
  65215. * Observable called when all tasks are processed
  65216. */
  65217. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65218. /**
  65219. * Observable called when a task had an error
  65220. */
  65221. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65222. /**
  65223. * Observable called when all tasks were executed
  65224. */
  65225. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65226. /**
  65227. * Observable called when a task is done (whatever the result is)
  65228. */
  65229. onProgressObservable: Observable<IAssetsProgressEvent>;
  65230. /**
  65231. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65232. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65233. */
  65234. useDefaultLoadingScreen: boolean;
  65235. /**
  65236. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65237. * when all assets have been downloaded.
  65238. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65239. */
  65240. autoHideLoadingUI: boolean;
  65241. /**
  65242. * Creates a new AssetsManager
  65243. * @param scene defines the scene to work on
  65244. */
  65245. constructor(scene: Scene);
  65246. /**
  65247. * Add a MeshAssetTask to the list of active tasks
  65248. * @param taskName defines the name of the new task
  65249. * @param meshesNames defines the name of meshes to load
  65250. * @param rootUrl defines the root url to use to locate files
  65251. * @param sceneFilename defines the filename of the scene file
  65252. * @returns a new MeshAssetTask object
  65253. */
  65254. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65255. /**
  65256. * Add a TextFileAssetTask to the list of active tasks
  65257. * @param taskName defines the name of the new task
  65258. * @param url defines the url of the file to load
  65259. * @returns a new TextFileAssetTask object
  65260. */
  65261. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65262. /**
  65263. * Add a BinaryFileAssetTask to the list of active tasks
  65264. * @param taskName defines the name of the new task
  65265. * @param url defines the url of the file to load
  65266. * @returns a new BinaryFileAssetTask object
  65267. */
  65268. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65269. /**
  65270. * Add a ImageAssetTask to the list of active tasks
  65271. * @param taskName defines the name of the new task
  65272. * @param url defines the url of the file to load
  65273. * @returns a new ImageAssetTask object
  65274. */
  65275. addImageTask(taskName: string, url: string): ImageAssetTask;
  65276. /**
  65277. * Add a TextureAssetTask to the list of active tasks
  65278. * @param taskName defines the name of the new task
  65279. * @param url defines the url of the file to load
  65280. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65281. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65282. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65283. * @returns a new TextureAssetTask object
  65284. */
  65285. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65286. /**
  65287. * Add a CubeTextureAssetTask to the list of active tasks
  65288. * @param taskName defines the name of the new task
  65289. * @param url defines the url of the file to load
  65290. * @param extensions defines the extension to use to load the cube map (can be null)
  65291. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65292. * @param files defines the list of files to load (can be null)
  65293. * @returns a new CubeTextureAssetTask object
  65294. */
  65295. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65296. /**
  65297. *
  65298. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65299. * @param taskName defines the name of the new task
  65300. * @param url defines the url of the file to load
  65301. * @param size defines the size you want for the cubemap (can be null)
  65302. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65303. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65304. * @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)
  65305. * @param reserved Internal use only
  65306. * @returns a new HDRCubeTextureAssetTask object
  65307. */
  65308. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65309. /**
  65310. *
  65311. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65312. * @param taskName defines the name of the new task
  65313. * @param url defines the url of the file to load
  65314. * @param size defines the size you want for the cubemap (can be null)
  65315. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65316. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65317. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65318. * @returns a new EquiRectangularCubeTextureAssetTask object
  65319. */
  65320. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65321. /**
  65322. * Remove a task from the assets manager.
  65323. * @param task the task to remove
  65324. */
  65325. removeTask(task: AbstractAssetTask): void;
  65326. private _decreaseWaitingTasksCount;
  65327. private _runTask;
  65328. /**
  65329. * Reset the AssetsManager and remove all tasks
  65330. * @return the current instance of the AssetsManager
  65331. */
  65332. reset(): AssetsManager;
  65333. /**
  65334. * Start the loading process
  65335. * @return the current instance of the AssetsManager
  65336. */
  65337. load(): AssetsManager;
  65338. /**
  65339. * Start the loading process as an async operation
  65340. * @return a promise returning the list of failed tasks
  65341. */
  65342. loadAsync(): Promise<void>;
  65343. }
  65344. }
  65345. declare module BABYLON {
  65346. /**
  65347. * Wrapper class for promise with external resolve and reject.
  65348. */
  65349. export class Deferred<T> {
  65350. /**
  65351. * The promise associated with this deferred object.
  65352. */
  65353. readonly promise: Promise<T>;
  65354. private _resolve;
  65355. private _reject;
  65356. /**
  65357. * The resolve method of the promise associated with this deferred object.
  65358. */
  65359. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65360. /**
  65361. * The reject method of the promise associated with this deferred object.
  65362. */
  65363. readonly reject: (reason?: any) => void;
  65364. /**
  65365. * Constructor for this deferred object.
  65366. */
  65367. constructor();
  65368. }
  65369. }
  65370. declare module BABYLON {
  65371. /**
  65372. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65373. */
  65374. export class MeshExploder {
  65375. private _centerMesh;
  65376. private _meshes;
  65377. private _meshesOrigins;
  65378. private _toCenterVectors;
  65379. private _scaledDirection;
  65380. private _newPosition;
  65381. private _centerPosition;
  65382. /**
  65383. * Explodes meshes from a center mesh.
  65384. * @param meshes The meshes to explode.
  65385. * @param centerMesh The mesh to be center of explosion.
  65386. */
  65387. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65388. private _setCenterMesh;
  65389. /**
  65390. * Get class name
  65391. * @returns "MeshExploder"
  65392. */
  65393. getClassName(): string;
  65394. /**
  65395. * "Exploded meshes"
  65396. * @returns Array of meshes with the centerMesh at index 0.
  65397. */
  65398. getMeshes(): Array<Mesh>;
  65399. /**
  65400. * Explodes meshes giving a specific direction
  65401. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65402. */
  65403. explode(direction?: number): void;
  65404. }
  65405. }
  65406. declare module BABYLON {
  65407. /**
  65408. * Class used to help managing file picking and drag'n'drop
  65409. */
  65410. export class FilesInput {
  65411. /**
  65412. * List of files ready to be loaded
  65413. */
  65414. static readonly FilesToLoad: {
  65415. [key: string]: File;
  65416. };
  65417. /**
  65418. * Callback called when a file is processed
  65419. */
  65420. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65421. private _engine;
  65422. private _currentScene;
  65423. private _sceneLoadedCallback;
  65424. private _progressCallback;
  65425. private _additionalRenderLoopLogicCallback;
  65426. private _textureLoadingCallback;
  65427. private _startingProcessingFilesCallback;
  65428. private _onReloadCallback;
  65429. private _errorCallback;
  65430. private _elementToMonitor;
  65431. private _sceneFileToLoad;
  65432. private _filesToLoad;
  65433. /**
  65434. * Creates a new FilesInput
  65435. * @param engine defines the rendering engine
  65436. * @param scene defines the hosting scene
  65437. * @param sceneLoadedCallback callback called when scene is loaded
  65438. * @param progressCallback callback called to track progress
  65439. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65440. * @param textureLoadingCallback callback called when a texture is loading
  65441. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65442. * @param onReloadCallback callback called when a reload is requested
  65443. * @param errorCallback callback call if an error occurs
  65444. */
  65445. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  65446. private _dragEnterHandler;
  65447. private _dragOverHandler;
  65448. private _dropHandler;
  65449. /**
  65450. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65451. * @param elementToMonitor defines the DOM element to track
  65452. */
  65453. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65454. /**
  65455. * Release all associated resources
  65456. */
  65457. dispose(): void;
  65458. private renderFunction;
  65459. private drag;
  65460. private drop;
  65461. private _traverseFolder;
  65462. private _processFiles;
  65463. /**
  65464. * Load files from a drop event
  65465. * @param event defines the drop event to use as source
  65466. */
  65467. loadFiles(event: any): void;
  65468. private _processReload;
  65469. /**
  65470. * Reload the current scene from the loaded files
  65471. */
  65472. reload(): void;
  65473. }
  65474. }
  65475. declare module BABYLON {
  65476. /**
  65477. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65478. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65479. */
  65480. export class SceneOptimization {
  65481. /**
  65482. * Defines the priority of this optimization (0 by default which means first in the list)
  65483. */
  65484. priority: number;
  65485. /**
  65486. * Gets a string describing the action executed by the current optimization
  65487. * @returns description string
  65488. */
  65489. getDescription(): string;
  65490. /**
  65491. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65492. * @param scene defines the current scene where to apply this optimization
  65493. * @param optimizer defines the current optimizer
  65494. * @returns true if everything that can be done was applied
  65495. */
  65496. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65497. /**
  65498. * Creates the SceneOptimization object
  65499. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65500. * @param desc defines the description associated with the optimization
  65501. */
  65502. constructor(
  65503. /**
  65504. * Defines the priority of this optimization (0 by default which means first in the list)
  65505. */
  65506. priority?: number);
  65507. }
  65508. /**
  65509. * Defines an optimization used to reduce the size of render target textures
  65510. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65511. */
  65512. export class TextureOptimization extends SceneOptimization {
  65513. /**
  65514. * Defines the priority of this optimization (0 by default which means first in the list)
  65515. */
  65516. priority: number;
  65517. /**
  65518. * 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
  65519. */
  65520. maximumSize: number;
  65521. /**
  65522. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65523. */
  65524. step: number;
  65525. /**
  65526. * Gets a string describing the action executed by the current optimization
  65527. * @returns description string
  65528. */
  65529. getDescription(): string;
  65530. /**
  65531. * Creates the TextureOptimization object
  65532. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65533. * @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
  65534. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65535. */
  65536. constructor(
  65537. /**
  65538. * Defines the priority of this optimization (0 by default which means first in the list)
  65539. */
  65540. priority?: number,
  65541. /**
  65542. * 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
  65543. */
  65544. maximumSize?: number,
  65545. /**
  65546. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65547. */
  65548. step?: number);
  65549. /**
  65550. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65551. * @param scene defines the current scene where to apply this optimization
  65552. * @param optimizer defines the current optimizer
  65553. * @returns true if everything that can be done was applied
  65554. */
  65555. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65556. }
  65557. /**
  65558. * Defines an optimization used to increase or decrease the rendering resolution
  65559. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65560. */
  65561. export class HardwareScalingOptimization extends SceneOptimization {
  65562. /**
  65563. * Defines the priority of this optimization (0 by default which means first in the list)
  65564. */
  65565. priority: number;
  65566. /**
  65567. * Defines the maximum scale to use (2 by default)
  65568. */
  65569. maximumScale: number;
  65570. /**
  65571. * Defines the step to use between two passes (0.5 by default)
  65572. */
  65573. step: number;
  65574. private _currentScale;
  65575. private _directionOffset;
  65576. /**
  65577. * Gets a string describing the action executed by the current optimization
  65578. * @return description string
  65579. */
  65580. getDescription(): string;
  65581. /**
  65582. * Creates the HardwareScalingOptimization object
  65583. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65584. * @param maximumScale defines the maximum scale to use (2 by default)
  65585. * @param step defines the step to use between two passes (0.5 by default)
  65586. */
  65587. constructor(
  65588. /**
  65589. * Defines the priority of this optimization (0 by default which means first in the list)
  65590. */
  65591. priority?: number,
  65592. /**
  65593. * Defines the maximum scale to use (2 by default)
  65594. */
  65595. maximumScale?: number,
  65596. /**
  65597. * Defines the step to use between two passes (0.5 by default)
  65598. */
  65599. step?: number);
  65600. /**
  65601. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65602. * @param scene defines the current scene where to apply this optimization
  65603. * @param optimizer defines the current optimizer
  65604. * @returns true if everything that can be done was applied
  65605. */
  65606. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65607. }
  65608. /**
  65609. * Defines an optimization used to remove shadows
  65610. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65611. */
  65612. export class ShadowsOptimization extends SceneOptimization {
  65613. /**
  65614. * Gets a string describing the action executed by the current optimization
  65615. * @return description string
  65616. */
  65617. getDescription(): string;
  65618. /**
  65619. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65620. * @param scene defines the current scene where to apply this optimization
  65621. * @param optimizer defines the current optimizer
  65622. * @returns true if everything that can be done was applied
  65623. */
  65624. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65625. }
  65626. /**
  65627. * Defines an optimization used to turn post-processes off
  65628. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65629. */
  65630. export class PostProcessesOptimization extends SceneOptimization {
  65631. /**
  65632. * Gets a string describing the action executed by the current optimization
  65633. * @return description string
  65634. */
  65635. getDescription(): string;
  65636. /**
  65637. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65638. * @param scene defines the current scene where to apply this optimization
  65639. * @param optimizer defines the current optimizer
  65640. * @returns true if everything that can be done was applied
  65641. */
  65642. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65643. }
  65644. /**
  65645. * Defines an optimization used to turn lens flares off
  65646. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65647. */
  65648. export class LensFlaresOptimization extends SceneOptimization {
  65649. /**
  65650. * Gets a string describing the action executed by the current optimization
  65651. * @return description string
  65652. */
  65653. getDescription(): string;
  65654. /**
  65655. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65656. * @param scene defines the current scene where to apply this optimization
  65657. * @param optimizer defines the current optimizer
  65658. * @returns true if everything that can be done was applied
  65659. */
  65660. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65661. }
  65662. /**
  65663. * Defines an optimization based on user defined callback.
  65664. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65665. */
  65666. export class CustomOptimization extends SceneOptimization {
  65667. /**
  65668. * Callback called to apply the custom optimization.
  65669. */
  65670. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65671. /**
  65672. * Callback called to get custom description
  65673. */
  65674. onGetDescription: () => string;
  65675. /**
  65676. * Gets a string describing the action executed by the current optimization
  65677. * @returns description string
  65678. */
  65679. getDescription(): string;
  65680. /**
  65681. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65682. * @param scene defines the current scene where to apply this optimization
  65683. * @param optimizer defines the current optimizer
  65684. * @returns true if everything that can be done was applied
  65685. */
  65686. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65687. }
  65688. /**
  65689. * Defines an optimization used to turn particles off
  65690. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65691. */
  65692. export class ParticlesOptimization extends SceneOptimization {
  65693. /**
  65694. * Gets a string describing the action executed by the current optimization
  65695. * @return description string
  65696. */
  65697. getDescription(): string;
  65698. /**
  65699. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65700. * @param scene defines the current scene where to apply this optimization
  65701. * @param optimizer defines the current optimizer
  65702. * @returns true if everything that can be done was applied
  65703. */
  65704. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65705. }
  65706. /**
  65707. * Defines an optimization used to turn render targets off
  65708. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65709. */
  65710. export class RenderTargetsOptimization extends SceneOptimization {
  65711. /**
  65712. * Gets a string describing the action executed by the current optimization
  65713. * @return description string
  65714. */
  65715. getDescription(): string;
  65716. /**
  65717. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65718. * @param scene defines the current scene where to apply this optimization
  65719. * @param optimizer defines the current optimizer
  65720. * @returns true if everything that can be done was applied
  65721. */
  65722. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65723. }
  65724. /**
  65725. * Defines an optimization used to merge meshes with compatible materials
  65726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65727. */
  65728. export class MergeMeshesOptimization extends SceneOptimization {
  65729. private static _UpdateSelectionTree;
  65730. /**
  65731. * Gets or sets a boolean which defines if optimization octree has to be updated
  65732. */
  65733. /**
  65734. * Gets or sets a boolean which defines if optimization octree has to be updated
  65735. */
  65736. static UpdateSelectionTree: boolean;
  65737. /**
  65738. * Gets a string describing the action executed by the current optimization
  65739. * @return description string
  65740. */
  65741. getDescription(): string;
  65742. private _canBeMerged;
  65743. /**
  65744. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65745. * @param scene defines the current scene where to apply this optimization
  65746. * @param optimizer defines the current optimizer
  65747. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65748. * @returns true if everything that can be done was applied
  65749. */
  65750. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65751. }
  65752. /**
  65753. * Defines a list of options used by SceneOptimizer
  65754. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65755. */
  65756. export class SceneOptimizerOptions {
  65757. /**
  65758. * Defines the target frame rate to reach (60 by default)
  65759. */
  65760. targetFrameRate: number;
  65761. /**
  65762. * Defines the interval between two checkes (2000ms by default)
  65763. */
  65764. trackerDuration: number;
  65765. /**
  65766. * Gets the list of optimizations to apply
  65767. */
  65768. optimizations: SceneOptimization[];
  65769. /**
  65770. * Creates a new list of options used by SceneOptimizer
  65771. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65772. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65773. */
  65774. constructor(
  65775. /**
  65776. * Defines the target frame rate to reach (60 by default)
  65777. */
  65778. targetFrameRate?: number,
  65779. /**
  65780. * Defines the interval between two checkes (2000ms by default)
  65781. */
  65782. trackerDuration?: number);
  65783. /**
  65784. * Add a new optimization
  65785. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65786. * @returns the current SceneOptimizerOptions
  65787. */
  65788. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65789. /**
  65790. * Add a new custom optimization
  65791. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65792. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65793. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65794. * @returns the current SceneOptimizerOptions
  65795. */
  65796. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65797. /**
  65798. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65799. * @param targetFrameRate defines the target frame rate (60 by default)
  65800. * @returns a SceneOptimizerOptions object
  65801. */
  65802. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65803. /**
  65804. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65805. * @param targetFrameRate defines the target frame rate (60 by default)
  65806. * @returns a SceneOptimizerOptions object
  65807. */
  65808. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65809. /**
  65810. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65811. * @param targetFrameRate defines the target frame rate (60 by default)
  65812. * @returns a SceneOptimizerOptions object
  65813. */
  65814. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65815. }
  65816. /**
  65817. * Class used to run optimizations in order to reach a target frame rate
  65818. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65819. */
  65820. export class SceneOptimizer implements IDisposable {
  65821. private _isRunning;
  65822. private _options;
  65823. private _scene;
  65824. private _currentPriorityLevel;
  65825. private _targetFrameRate;
  65826. private _trackerDuration;
  65827. private _currentFrameRate;
  65828. private _sceneDisposeObserver;
  65829. private _improvementMode;
  65830. /**
  65831. * Defines an observable called when the optimizer reaches the target frame rate
  65832. */
  65833. onSuccessObservable: Observable<SceneOptimizer>;
  65834. /**
  65835. * Defines an observable called when the optimizer enables an optimization
  65836. */
  65837. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65838. /**
  65839. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65840. */
  65841. onFailureObservable: Observable<SceneOptimizer>;
  65842. /**
  65843. * Gets a boolean indicating if the optimizer is in improvement mode
  65844. */
  65845. readonly isInImprovementMode: boolean;
  65846. /**
  65847. * Gets the current priority level (0 at start)
  65848. */
  65849. readonly currentPriorityLevel: number;
  65850. /**
  65851. * Gets the current frame rate checked by the SceneOptimizer
  65852. */
  65853. readonly currentFrameRate: number;
  65854. /**
  65855. * Gets or sets the current target frame rate (60 by default)
  65856. */
  65857. /**
  65858. * Gets or sets the current target frame rate (60 by default)
  65859. */
  65860. targetFrameRate: number;
  65861. /**
  65862. * Gets or sets the current interval between two checks (every 2000ms by default)
  65863. */
  65864. /**
  65865. * Gets or sets the current interval between two checks (every 2000ms by default)
  65866. */
  65867. trackerDuration: number;
  65868. /**
  65869. * Gets the list of active optimizations
  65870. */
  65871. readonly optimizations: SceneOptimization[];
  65872. /**
  65873. * Creates a new SceneOptimizer
  65874. * @param scene defines the scene to work on
  65875. * @param options defines the options to use with the SceneOptimizer
  65876. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65877. * @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)
  65878. */
  65879. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65880. /**
  65881. * Stops the current optimizer
  65882. */
  65883. stop(): void;
  65884. /**
  65885. * Reset the optimizer to initial step (current priority level = 0)
  65886. */
  65887. reset(): void;
  65888. /**
  65889. * Start the optimizer. By default it will try to reach a specific framerate
  65890. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65891. */
  65892. start(): void;
  65893. private _checkCurrentState;
  65894. /**
  65895. * Release all resources
  65896. */
  65897. dispose(): void;
  65898. /**
  65899. * Helper function to create a SceneOptimizer with one single line of code
  65900. * @param scene defines the scene to work on
  65901. * @param options defines the options to use with the SceneOptimizer
  65902. * @param onSuccess defines a callback to call on success
  65903. * @param onFailure defines a callback to call on failure
  65904. * @returns the new SceneOptimizer object
  65905. */
  65906. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65907. }
  65908. }
  65909. declare module BABYLON {
  65910. /**
  65911. * Class used to serialize a scene into a string
  65912. */
  65913. export class SceneSerializer {
  65914. /**
  65915. * Clear cache used by a previous serialization
  65916. */
  65917. static ClearCache(): void;
  65918. /**
  65919. * Serialize a scene into a JSON compatible object
  65920. * @param scene defines the scene to serialize
  65921. * @returns a JSON compatible object
  65922. */
  65923. static Serialize(scene: Scene): any;
  65924. /**
  65925. * Serialize a mesh into a JSON compatible object
  65926. * @param toSerialize defines the mesh to serialize
  65927. * @param withParents defines if parents must be serialized as well
  65928. * @param withChildren defines if children must be serialized as well
  65929. * @returns a JSON compatible object
  65930. */
  65931. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65932. }
  65933. }
  65934. declare module BABYLON {
  65935. /**
  65936. * Class used to host texture specific utilities
  65937. */
  65938. export class TextureTools {
  65939. /**
  65940. * Uses the GPU to create a copy texture rescaled at a given size
  65941. * @param texture Texture to copy from
  65942. * @param width defines the desired width
  65943. * @param height defines the desired height
  65944. * @param useBilinearMode defines if bilinear mode has to be used
  65945. * @return the generated texture
  65946. */
  65947. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65948. }
  65949. }
  65950. declare module BABYLON {
  65951. /**
  65952. * This represents the different options available for the video capture.
  65953. */
  65954. export interface VideoRecorderOptions {
  65955. /** Defines the mime type of the video. */
  65956. mimeType: string;
  65957. /** Defines the FPS the video should be recorded at. */
  65958. fps: number;
  65959. /** Defines the chunk size for the recording data. */
  65960. recordChunckSize: number;
  65961. /** The audio tracks to attach to the recording. */
  65962. audioTracks?: MediaStreamTrack[];
  65963. }
  65964. /**
  65965. * This can help with recording videos from BabylonJS.
  65966. * This is based on the available WebRTC functionalities of the browser.
  65967. *
  65968. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65969. */
  65970. export class VideoRecorder {
  65971. private static readonly _defaultOptions;
  65972. /**
  65973. * Returns whether or not the VideoRecorder is available in your browser.
  65974. * @param engine Defines the Babylon Engine.
  65975. * @returns true if supported otherwise false.
  65976. */
  65977. static IsSupported(engine: Engine): boolean;
  65978. private readonly _options;
  65979. private _canvas;
  65980. private _mediaRecorder;
  65981. private _recordedChunks;
  65982. private _fileName;
  65983. private _resolve;
  65984. private _reject;
  65985. /**
  65986. * True when a recording is already in progress.
  65987. */
  65988. readonly isRecording: boolean;
  65989. /**
  65990. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65991. * @param engine Defines the BabylonJS Engine you wish to record.
  65992. * @param options Defines options that can be used to customize the capture.
  65993. */
  65994. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65995. /**
  65996. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65997. */
  65998. stopRecording(): void;
  65999. /**
  66000. * Starts recording the canvas for a max duration specified in parameters.
  66001. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66002. * If null no automatic download will start and you can rely on the promise to get the data back.
  66003. * @param maxDuration Defines the maximum recording time in seconds.
  66004. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66005. * @return A promise callback at the end of the recording with the video data in Blob.
  66006. */
  66007. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66008. /**
  66009. * Releases internal resources used during the recording.
  66010. */
  66011. dispose(): void;
  66012. private _handleDataAvailable;
  66013. private _handleError;
  66014. private _handleStop;
  66015. }
  66016. }
  66017. declare module BABYLON {
  66018. /**
  66019. * Class containing a set of static utilities functions for screenshots
  66020. */
  66021. export class ScreenshotTools {
  66022. /**
  66023. * Captures a screenshot of the current rendering
  66024. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66025. * @param engine defines the rendering engine
  66026. * @param camera defines the source camera
  66027. * @param size This parameter can be set to a single number or to an object with the
  66028. * following (optional) properties: precision, width, height. If a single number is passed,
  66029. * it will be used for both width and height. If an object is passed, the screenshot size
  66030. * will be derived from the parameters. The precision property is a multiplier allowing
  66031. * rendering at a higher or lower resolution
  66032. * @param successCallback defines the callback receives a single parameter which contains the
  66033. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66034. * src parameter of an <img> to display it
  66035. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66036. * Check your browser for supported MIME types
  66037. */
  66038. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66039. /**
  66040. * Captures a screenshot of the current rendering
  66041. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66042. * @param engine defines the rendering engine
  66043. * @param camera defines the source camera
  66044. * @param size This parameter can be set to a single number or to an object with the
  66045. * following (optional) properties: precision, width, height. If a single number is passed,
  66046. * it will be used for both width and height. If an object is passed, the screenshot size
  66047. * will be derived from the parameters. The precision property is a multiplier allowing
  66048. * rendering at a higher or lower resolution
  66049. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66050. * Check your browser for supported MIME types
  66051. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66052. * to the src parameter of an <img> to display it
  66053. */
  66054. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66055. /**
  66056. * Generates an image screenshot from the specified camera.
  66057. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66058. * @param engine The engine to use for rendering
  66059. * @param camera The camera to use for rendering
  66060. * @param size This parameter can be set to a single number or to an object with the
  66061. * following (optional) properties: precision, width, height. If a single number is passed,
  66062. * it will be used for both width and height. If an object is passed, the screenshot size
  66063. * will be derived from the parameters. The precision property is a multiplier allowing
  66064. * rendering at a higher or lower resolution
  66065. * @param successCallback The callback receives a single parameter which contains the
  66066. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66067. * src parameter of an <img> to display it
  66068. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66069. * Check your browser for supported MIME types
  66070. * @param samples Texture samples (default: 1)
  66071. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66072. * @param fileName A name for for the downloaded file.
  66073. */
  66074. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66075. /**
  66076. * Generates an image screenshot from the specified camera.
  66077. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66078. * @param engine The engine to use for rendering
  66079. * @param camera The camera to use for rendering
  66080. * @param size This parameter can be set to a single number or to an object with the
  66081. * following (optional) properties: precision, width, height. If a single number is passed,
  66082. * it will be used for both width and height. If an object is passed, the screenshot size
  66083. * will be derived from the parameters. The precision property is a multiplier allowing
  66084. * rendering at a higher or lower resolution
  66085. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66086. * Check your browser for supported MIME types
  66087. * @param samples Texture samples (default: 1)
  66088. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66089. * @param fileName A name for for the downloaded file.
  66090. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66091. * to the src parameter of an <img> to display it
  66092. */
  66093. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66094. /**
  66095. * Gets height and width for screenshot size
  66096. * @private
  66097. */
  66098. private static _getScreenshotSize;
  66099. }
  66100. }
  66101. declare module BABYLON {
  66102. /**
  66103. * Interface for a data buffer
  66104. */
  66105. export interface IDataBuffer {
  66106. /**
  66107. * Reads bytes from the data buffer.
  66108. * @param byteOffset The byte offset to read
  66109. * @param byteLength The byte length to read
  66110. * @returns A promise that resolves when the bytes are read
  66111. */
  66112. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  66113. /**
  66114. * The byte length of the buffer.
  66115. */
  66116. readonly byteLength: number;
  66117. }
  66118. /**
  66119. * Utility class for reading from a data buffer
  66120. */
  66121. export class DataReader {
  66122. /**
  66123. * The data buffer associated with this data reader.
  66124. */
  66125. readonly buffer: IDataBuffer;
  66126. /**
  66127. * The current byte offset from the beginning of the data buffer.
  66128. */
  66129. byteOffset: number;
  66130. private _dataView;
  66131. private _dataByteOffset;
  66132. /**
  66133. * Constructor
  66134. * @param buffer The buffer to read
  66135. */
  66136. constructor(buffer: IDataBuffer);
  66137. /**
  66138. * Loads the given byte length.
  66139. * @param byteLength The byte length to load
  66140. * @returns A promise that resolves when the load is complete
  66141. */
  66142. loadAsync(byteLength: number): Promise<void>;
  66143. /**
  66144. * Read a unsigned 32-bit integer from the currently loaded data range.
  66145. * @returns The 32-bit integer read
  66146. */
  66147. readUint32(): number;
  66148. /**
  66149. * Read a byte array from the currently loaded data range.
  66150. * @param byteLength The byte length to read
  66151. * @returns The byte array read
  66152. */
  66153. readUint8Array(byteLength: number): Uint8Array;
  66154. /**
  66155. * Read a string from the currently loaded data range.
  66156. * @param byteLength The byte length to read
  66157. * @returns The string read
  66158. */
  66159. readString(byteLength: number): string;
  66160. /**
  66161. * Skips the given byte length the currently loaded data range.
  66162. * @param byteLength The byte length to skip
  66163. */
  66164. skipBytes(byteLength: number): void;
  66165. }
  66166. }
  66167. declare module BABYLON {
  66168. /**
  66169. * A cursor which tracks a point on a path
  66170. */
  66171. export class PathCursor {
  66172. private path;
  66173. /**
  66174. * Stores path cursor callbacks for when an onchange event is triggered
  66175. */
  66176. private _onchange;
  66177. /**
  66178. * The value of the path cursor
  66179. */
  66180. value: number;
  66181. /**
  66182. * The animation array of the path cursor
  66183. */
  66184. animations: Animation[];
  66185. /**
  66186. * Initializes the path cursor
  66187. * @param path The path to track
  66188. */
  66189. constructor(path: Path2);
  66190. /**
  66191. * Gets the cursor point on the path
  66192. * @returns A point on the path cursor at the cursor location
  66193. */
  66194. getPoint(): Vector3;
  66195. /**
  66196. * Moves the cursor ahead by the step amount
  66197. * @param step The amount to move the cursor forward
  66198. * @returns This path cursor
  66199. */
  66200. moveAhead(step?: number): PathCursor;
  66201. /**
  66202. * Moves the cursor behind by the step amount
  66203. * @param step The amount to move the cursor back
  66204. * @returns This path cursor
  66205. */
  66206. moveBack(step?: number): PathCursor;
  66207. /**
  66208. * Moves the cursor by the step amount
  66209. * If the step amount is greater than one, an exception is thrown
  66210. * @param step The amount to move the cursor
  66211. * @returns This path cursor
  66212. */
  66213. move(step: number): PathCursor;
  66214. /**
  66215. * Ensures that the value is limited between zero and one
  66216. * @returns This path cursor
  66217. */
  66218. private ensureLimits;
  66219. /**
  66220. * Runs onchange callbacks on change (used by the animation engine)
  66221. * @returns This path cursor
  66222. */
  66223. private raiseOnChange;
  66224. /**
  66225. * Executes a function on change
  66226. * @param f A path cursor onchange callback
  66227. * @returns This path cursor
  66228. */
  66229. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66230. }
  66231. }
  66232. declare module BABYLON {
  66233. /** @hidden */
  66234. export var blurPixelShader: {
  66235. name: string;
  66236. shader: string;
  66237. };
  66238. }
  66239. declare module BABYLON {
  66240. /** @hidden */
  66241. export var pointCloudVertexDeclaration: {
  66242. name: string;
  66243. shader: string;
  66244. };
  66245. }
  66246. // Mixins
  66247. interface Window {
  66248. mozIndexedDB: IDBFactory;
  66249. webkitIndexedDB: IDBFactory;
  66250. msIndexedDB: IDBFactory;
  66251. webkitURL: typeof URL;
  66252. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  66253. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  66254. WebGLRenderingContext: WebGLRenderingContext;
  66255. MSGesture: MSGesture;
  66256. CANNON: any;
  66257. AudioContext: AudioContext;
  66258. webkitAudioContext: AudioContext;
  66259. PointerEvent: any;
  66260. Math: Math;
  66261. Uint8Array: Uint8ArrayConstructor;
  66262. Float32Array: Float32ArrayConstructor;
  66263. mozURL: typeof URL;
  66264. msURL: typeof URL;
  66265. VRFrameData: any; // WebVR, from specs 1.1
  66266. DracoDecoderModule: any;
  66267. setImmediate(handler: (...args: any[]) => void): number;
  66268. }
  66269. interface HTMLCanvasElement {
  66270. requestPointerLock(): void;
  66271. msRequestPointerLock?(): void;
  66272. mozRequestPointerLock?(): void;
  66273. webkitRequestPointerLock?(): void;
  66274. /** Track wether a record is in progress */
  66275. isRecording: boolean;
  66276. /** Capture Stream method defined by some browsers */
  66277. captureStream(fps?: number): MediaStream;
  66278. }
  66279. interface CanvasRenderingContext2D {
  66280. msImageSmoothingEnabled: boolean;
  66281. }
  66282. interface MouseEvent {
  66283. mozMovementX: number;
  66284. mozMovementY: number;
  66285. webkitMovementX: number;
  66286. webkitMovementY: number;
  66287. msMovementX: number;
  66288. msMovementY: number;
  66289. }
  66290. interface Navigator {
  66291. mozGetVRDevices: (any: any) => any;
  66292. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66293. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66294. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66295. webkitGetGamepads(): Gamepad[];
  66296. msGetGamepads(): Gamepad[];
  66297. webkitGamepads(): Gamepad[];
  66298. }
  66299. interface HTMLVideoElement {
  66300. mozSrcObject: any;
  66301. }
  66302. interface Math {
  66303. fround(x: number): number;
  66304. imul(a: number, b: number): number;
  66305. }
  66306. interface WebGLRenderingContext {
  66307. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  66308. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  66309. vertexAttribDivisor(index: number, divisor: number): void;
  66310. createVertexArray(): any;
  66311. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  66312. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  66313. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  66314. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  66315. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  66316. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  66317. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  66318. // Queries
  66319. createQuery(): WebGLQuery;
  66320. deleteQuery(query: WebGLQuery): void;
  66321. beginQuery(target: number, query: WebGLQuery): void;
  66322. endQuery(target: number): void;
  66323. getQueryParameter(query: WebGLQuery, pname: number): any;
  66324. getQuery(target: number, pname: number): any;
  66325. MAX_SAMPLES: number;
  66326. RGBA8: number;
  66327. READ_FRAMEBUFFER: number;
  66328. DRAW_FRAMEBUFFER: number;
  66329. UNIFORM_BUFFER: number;
  66330. HALF_FLOAT_OES: number;
  66331. RGBA16F: number;
  66332. RGBA32F: number;
  66333. R32F: number;
  66334. RG32F: number;
  66335. RGB32F: number;
  66336. R16F: number;
  66337. RG16F: number;
  66338. RGB16F: number;
  66339. RED: number;
  66340. RG: number;
  66341. R8: number;
  66342. RG8: number;
  66343. UNSIGNED_INT_24_8: number;
  66344. DEPTH24_STENCIL8: number;
  66345. MIN: number;
  66346. MAX: number;
  66347. /* Multiple Render Targets */
  66348. drawBuffers(buffers: number[]): void;
  66349. readBuffer(src: number): void;
  66350. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  66351. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  66352. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  66353. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  66354. // Occlusion Query
  66355. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  66356. ANY_SAMPLES_PASSED: number;
  66357. QUERY_RESULT_AVAILABLE: number;
  66358. QUERY_RESULT: number;
  66359. }
  66360. interface WebGLProgram {
  66361. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  66362. }
  66363. interface EXT_disjoint_timer_query {
  66364. QUERY_COUNTER_BITS_EXT: number;
  66365. TIME_ELAPSED_EXT: number;
  66366. TIMESTAMP_EXT: number;
  66367. GPU_DISJOINT_EXT: number;
  66368. QUERY_RESULT_EXT: number;
  66369. QUERY_RESULT_AVAILABLE_EXT: number;
  66370. queryCounterEXT(query: WebGLQuery, target: number): void;
  66371. createQueryEXT(): WebGLQuery;
  66372. beginQueryEXT(target: number, query: WebGLQuery): void;
  66373. endQueryEXT(target: number): void;
  66374. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  66375. deleteQueryEXT(query: WebGLQuery): void;
  66376. }
  66377. interface WebGLUniformLocation {
  66378. _currentState: any;
  66379. }
  66380. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  66381. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  66382. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  66383. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  66384. interface WebGLRenderingContext {
  66385. readonly RASTERIZER_DISCARD: number;
  66386. readonly DEPTH_COMPONENT24: number;
  66387. readonly TEXTURE_3D: number;
  66388. readonly TEXTURE_2D_ARRAY: number;
  66389. readonly TEXTURE_COMPARE_FUNC: number;
  66390. readonly TEXTURE_COMPARE_MODE: number;
  66391. readonly COMPARE_REF_TO_TEXTURE: number;
  66392. readonly TEXTURE_WRAP_R: number;
  66393. readonly HALF_FLOAT: number;
  66394. readonly RGB8: number;
  66395. readonly RED_INTEGER: number;
  66396. readonly RG_INTEGER: number;
  66397. readonly RGB_INTEGER: number;
  66398. readonly RGBA_INTEGER: number;
  66399. readonly R8_SNORM: number;
  66400. readonly RG8_SNORM: number;
  66401. readonly RGB8_SNORM: number;
  66402. readonly RGBA8_SNORM: number;
  66403. readonly R8I: number;
  66404. readonly RG8I: number;
  66405. readonly RGB8I: number;
  66406. readonly RGBA8I: number;
  66407. readonly R8UI: number;
  66408. readonly RG8UI: number;
  66409. readonly RGB8UI: number;
  66410. readonly RGBA8UI: number;
  66411. readonly R16I: number;
  66412. readonly RG16I: number;
  66413. readonly RGB16I: number;
  66414. readonly RGBA16I: number;
  66415. readonly R16UI: number;
  66416. readonly RG16UI: number;
  66417. readonly RGB16UI: number;
  66418. readonly RGBA16UI: number;
  66419. readonly R32I: number;
  66420. readonly RG32I: number;
  66421. readonly RGB32I: number;
  66422. readonly RGBA32I: number;
  66423. readonly R32UI: number;
  66424. readonly RG32UI: number;
  66425. readonly RGB32UI: number;
  66426. readonly RGBA32UI: number;
  66427. readonly RGB10_A2UI: number;
  66428. readonly R11F_G11F_B10F: number;
  66429. readonly RGB9_E5: number;
  66430. readonly RGB10_A2: number;
  66431. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  66432. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  66433. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  66434. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  66435. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  66436. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  66437. 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;
  66438. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  66439. readonly TRANSFORM_FEEDBACK: number;
  66440. readonly INTERLEAVED_ATTRIBS: number;
  66441. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  66442. createTransformFeedback(): WebGLTransformFeedback;
  66443. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  66444. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  66445. beginTransformFeedback(primitiveMode: number): void;
  66446. endTransformFeedback(): void;
  66447. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  66448. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  66449. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  66450. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  66451. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  66452. }
  66453. interface ImageBitmap {
  66454. readonly width: number;
  66455. readonly height: number;
  66456. close(): void;
  66457. }
  66458. interface WebGLQuery extends WebGLObject {
  66459. }
  66460. declare var WebGLQuery: {
  66461. prototype: WebGLQuery;
  66462. new(): WebGLQuery;
  66463. };
  66464. interface WebGLSampler extends WebGLObject {
  66465. }
  66466. declare var WebGLSampler: {
  66467. prototype: WebGLSampler;
  66468. new(): WebGLSampler;
  66469. };
  66470. interface WebGLSync extends WebGLObject {
  66471. }
  66472. declare var WebGLSync: {
  66473. prototype: WebGLSync;
  66474. new(): WebGLSync;
  66475. };
  66476. interface WebGLTransformFeedback extends WebGLObject {
  66477. }
  66478. declare var WebGLTransformFeedback: {
  66479. prototype: WebGLTransformFeedback;
  66480. new(): WebGLTransformFeedback;
  66481. };
  66482. interface WebGLVertexArrayObject extends WebGLObject {
  66483. }
  66484. declare var WebGLVertexArrayObject: {
  66485. prototype: WebGLVertexArrayObject;
  66486. new(): WebGLVertexArrayObject;
  66487. };
  66488. // Type definitions for WebVR API
  66489. // Project: https://w3c.github.io/webvr/
  66490. // Definitions by: six a <https://github.com/lostfictions>
  66491. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  66492. interface VRDisplay extends EventTarget {
  66493. /**
  66494. * Dictionary of capabilities describing the VRDisplay.
  66495. */
  66496. readonly capabilities: VRDisplayCapabilities;
  66497. /**
  66498. * z-depth defining the far plane of the eye view frustum
  66499. * enables mapping of values in the render target depth
  66500. * attachment to scene coordinates. Initially set to 10000.0.
  66501. */
  66502. depthFar: number;
  66503. /**
  66504. * z-depth defining the near plane of the eye view frustum
  66505. * enables mapping of values in the render target depth
  66506. * attachment to scene coordinates. Initially set to 0.01.
  66507. */
  66508. depthNear: number;
  66509. /**
  66510. * An identifier for this distinct VRDisplay. Used as an
  66511. * association point in the Gamepad API.
  66512. */
  66513. readonly displayId: number;
  66514. /**
  66515. * A display name, a user-readable name identifying it.
  66516. */
  66517. readonly displayName: string;
  66518. readonly isConnected: boolean;
  66519. readonly isPresenting: boolean;
  66520. /**
  66521. * If this VRDisplay supports room-scale experiences, the optional
  66522. * stage attribute contains details on the room-scale parameters.
  66523. */
  66524. readonly stageParameters: VRStageParameters | null;
  66525. /**
  66526. * Passing the value returned by `requestAnimationFrame` to
  66527. * `cancelAnimationFrame` will unregister the callback.
  66528. * @param handle Define the hanle of the request to cancel
  66529. */
  66530. cancelAnimationFrame(handle: number): void;
  66531. /**
  66532. * Stops presenting to the VRDisplay.
  66533. * @returns a promise to know when it stopped
  66534. */
  66535. exitPresent(): Promise<void>;
  66536. /**
  66537. * Return the current VREyeParameters for the given eye.
  66538. * @param whichEye Define the eye we want the parameter for
  66539. * @returns the eye parameters
  66540. */
  66541. getEyeParameters(whichEye: string): VREyeParameters;
  66542. /**
  66543. * Populates the passed VRFrameData with the information required to render
  66544. * the current frame.
  66545. * @param frameData Define the data structure to populate
  66546. * @returns true if ok otherwise false
  66547. */
  66548. getFrameData(frameData: VRFrameData): boolean;
  66549. /**
  66550. * Get the layers currently being presented.
  66551. * @returns the list of VR layers
  66552. */
  66553. getLayers(): VRLayer[];
  66554. /**
  66555. * Return a VRPose containing the future predicted pose of the VRDisplay
  66556. * when the current frame will be presented. The value returned will not
  66557. * change until JavaScript has returned control to the browser.
  66558. *
  66559. * The VRPose will contain the position, orientation, velocity,
  66560. * and acceleration of each of these properties.
  66561. * @returns the pose object
  66562. */
  66563. getPose(): VRPose;
  66564. /**
  66565. * Return the current instantaneous pose of the VRDisplay, with no
  66566. * prediction applied.
  66567. * @returns the current instantaneous pose
  66568. */
  66569. getImmediatePose(): VRPose;
  66570. /**
  66571. * The callback passed to `requestAnimationFrame` will be called
  66572. * any time a new frame should be rendered. When the VRDisplay is
  66573. * presenting the callback will be called at the native refresh
  66574. * rate of the HMD. When not presenting this function acts
  66575. * identically to how window.requestAnimationFrame acts. Content should
  66576. * make no assumptions of frame rate or vsync behavior as the HMD runs
  66577. * asynchronously from other displays and at differing refresh rates.
  66578. * @param callback Define the eaction to run next frame
  66579. * @returns the request handle it
  66580. */
  66581. requestAnimationFrame(callback: FrameRequestCallback): number;
  66582. /**
  66583. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  66584. * Repeat calls while already presenting will update the VRLayers being displayed.
  66585. * @param layers Define the list of layer to present
  66586. * @returns a promise to know when the request has been fulfilled
  66587. */
  66588. requestPresent(layers: VRLayer[]): Promise<void>;
  66589. /**
  66590. * Reset the pose for this display, treating its current position and
  66591. * orientation as the "origin/zero" values. VRPose.position,
  66592. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  66593. * updated when calling resetPose(). This should be called in only
  66594. * sitting-space experiences.
  66595. */
  66596. resetPose(): void;
  66597. /**
  66598. * The VRLayer provided to the VRDisplay will be captured and presented
  66599. * in the HMD. Calling this function has the same effect on the source
  66600. * canvas as any other operation that uses its source image, and canvases
  66601. * created without preserveDrawingBuffer set to true will be cleared.
  66602. * @param pose Define the pose to submit
  66603. */
  66604. submitFrame(pose?: VRPose): void;
  66605. }
  66606. declare var VRDisplay: {
  66607. prototype: VRDisplay;
  66608. new(): VRDisplay;
  66609. };
  66610. interface VRLayer {
  66611. leftBounds?: number[] | Float32Array | null;
  66612. rightBounds?: number[] | Float32Array | null;
  66613. source?: HTMLCanvasElement | null;
  66614. }
  66615. interface VRDisplayCapabilities {
  66616. readonly canPresent: boolean;
  66617. readonly hasExternalDisplay: boolean;
  66618. readonly hasOrientation: boolean;
  66619. readonly hasPosition: boolean;
  66620. readonly maxLayers: number;
  66621. }
  66622. interface VREyeParameters {
  66623. /** @deprecated */
  66624. readonly fieldOfView: VRFieldOfView;
  66625. readonly offset: Float32Array;
  66626. readonly renderHeight: number;
  66627. readonly renderWidth: number;
  66628. }
  66629. interface VRFieldOfView {
  66630. readonly downDegrees: number;
  66631. readonly leftDegrees: number;
  66632. readonly rightDegrees: number;
  66633. readonly upDegrees: number;
  66634. }
  66635. interface VRFrameData {
  66636. readonly leftProjectionMatrix: Float32Array;
  66637. readonly leftViewMatrix: Float32Array;
  66638. readonly pose: VRPose;
  66639. readonly rightProjectionMatrix: Float32Array;
  66640. readonly rightViewMatrix: Float32Array;
  66641. readonly timestamp: number;
  66642. }
  66643. interface VRPose {
  66644. readonly angularAcceleration: Float32Array | null;
  66645. readonly angularVelocity: Float32Array | null;
  66646. readonly linearAcceleration: Float32Array | null;
  66647. readonly linearVelocity: Float32Array | null;
  66648. readonly orientation: Float32Array | null;
  66649. readonly position: Float32Array | null;
  66650. readonly timestamp: number;
  66651. }
  66652. interface VRStageParameters {
  66653. sittingToStandingTransform?: Float32Array;
  66654. sizeX?: number;
  66655. sizeY?: number;
  66656. }
  66657. interface Navigator {
  66658. getVRDisplays(): Promise<VRDisplay[]>;
  66659. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  66660. }
  66661. interface Window {
  66662. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  66663. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  66664. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  66665. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  66666. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  66667. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  66668. }
  66669. interface Gamepad {
  66670. readonly displayId: number;
  66671. }
  66672. type XRSessionMode =
  66673. | "inline"
  66674. | "immersive-vr"
  66675. | "immersive-ar";
  66676. type XRReferenceSpaceType =
  66677. | "viewer"
  66678. | "local"
  66679. | "local-floor"
  66680. | "bounded-floor"
  66681. | "unbounded";
  66682. type XREnvironmentBlendMode =
  66683. | "opaque"
  66684. | "additive"
  66685. | "alpha-blend";
  66686. type XRVisibilityState =
  66687. | "visible"
  66688. | "visible-blurred"
  66689. | "hidden";
  66690. type XRHandedness =
  66691. | "none"
  66692. | "left"
  66693. | "right";
  66694. type XRTargetRayMode =
  66695. | "gaze"
  66696. | "tracked-pointer"
  66697. | "screen";
  66698. type XREye =
  66699. | "none"
  66700. | "left"
  66701. | "right";
  66702. interface XRSpace extends EventTarget {
  66703. }
  66704. interface XRRenderState {
  66705. depthNear?: number;
  66706. depthFar?: number;
  66707. inlineVerticalFieldOfView?: number;
  66708. baseLayer?: XRWebGLLayer;
  66709. }
  66710. interface XRInputSource {
  66711. handedness: XRHandedness;
  66712. targetRayMode: XRTargetRayMode;
  66713. targetRaySpace: XRSpace;
  66714. gripSpace: XRSpace | undefined;
  66715. gamepad: Gamepad | undefined;
  66716. profiles: Array<string>;
  66717. }
  66718. interface XRSession extends XRAnchorCreator {
  66719. addEventListener: Function;
  66720. removeEventListener: Function;
  66721. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  66722. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  66723. requestAnimationFrame: Function;
  66724. end(): Promise<void>;
  66725. renderState: XRRenderState;
  66726. inputSources: Array<XRInputSource>;
  66727. // AR hit test
  66728. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  66729. updateWorldTrackingState(options: {
  66730. planeDetectionState?: { enabled: boolean; }
  66731. }): void;
  66732. }
  66733. interface XRReferenceSpace extends XRSpace {
  66734. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  66735. onreset: any;
  66736. }
  66737. type XRPlaneSet = Set<XRPlane>;
  66738. type XRAnchorSet = Set<XRAnchor>;
  66739. interface XRFrame {
  66740. session: XRSession;
  66741. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  66742. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  66743. // Anchors
  66744. trackedAnchors?: XRAnchorSet;
  66745. // Planes
  66746. worldInformation: {
  66747. detectedPlanes?: XRPlaneSet;
  66748. };
  66749. }
  66750. interface XRViewerPose extends XRPose {
  66751. views: Array<XRView>;
  66752. }
  66753. interface XRPose {
  66754. transform: XRRigidTransform;
  66755. emulatedPosition: boolean;
  66756. }
  66757. interface XRWebGLLayerOptions {
  66758. antialias?: boolean;
  66759. depth?: boolean;
  66760. stencil?: boolean;
  66761. alpha?: boolean;
  66762. multiview?: boolean;
  66763. framebufferScaleFactor?: number;
  66764. }
  66765. declare var XRWebGLLayer: {
  66766. prototype: XRWebGLLayer;
  66767. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  66768. };
  66769. interface XRWebGLLayer {
  66770. framebuffer: WebGLFramebuffer;
  66771. framebufferWidth: number;
  66772. framebufferHeight: number;
  66773. getViewport: Function;
  66774. }
  66775. declare class XRRigidTransform {
  66776. constructor(matrix: Float32Array);
  66777. position: DOMPointReadOnly;
  66778. orientation: DOMPointReadOnly;
  66779. matrix: Float32Array;
  66780. inverse: XRRigidTransform;
  66781. }
  66782. interface XRView {
  66783. eye: XREye;
  66784. projectionMatrix: Float32Array;
  66785. transform: XRRigidTransform;
  66786. }
  66787. interface XRInputSourceChangeEvent {
  66788. session: XRSession;
  66789. removed: Array<XRInputSource>;
  66790. added: Array<XRInputSource>;
  66791. }
  66792. interface XRInputSourceEvent extends Event {
  66793. readonly frame: XRFrame;
  66794. readonly inputSource: XRInputSource;
  66795. }
  66796. // Experimental(er) features
  66797. declare class XRRay {
  66798. constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
  66799. origin: DOMPointReadOnly;
  66800. direction: DOMPointReadOnly;
  66801. matrix: Float32Array;
  66802. }
  66803. interface XRHitResult {
  66804. hitMatrix: Float32Array;
  66805. }
  66806. interface XRAnchor {
  66807. // remove?
  66808. id?: string;
  66809. anchorSpace: XRSpace;
  66810. lastChangedTime: number;
  66811. detach(): void;
  66812. }
  66813. interface XRPlane extends XRAnchorCreator {
  66814. orientation: "Horizontal" | "Vertical";
  66815. planeSpace: XRSpace;
  66816. polygon: Array<DOMPointReadOnly>;
  66817. lastChangedTime: number;
  66818. }
  66819. interface XRAnchorCreator {
  66820. // AR Anchors
  66821. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  66822. }
  66823. /**
  66824. * @ignore
  66825. */
  66826. declare module BABYLON.GLTF2.Exporter {
  66827. }
  66828. /**
  66829. * @ignore
  66830. */
  66831. declare module BABYLON.GLTF1 {
  66832. }
  66833. declare module BABYLON.GUI {
  66834. /**
  66835. * Class used to specific a value and its associated unit
  66836. */
  66837. export class ValueAndUnit {
  66838. /** defines the unit to store */
  66839. unit: number;
  66840. /** defines a boolean indicating if the value can be negative */
  66841. negativeValueAllowed: boolean;
  66842. private _value;
  66843. private _originalUnit;
  66844. /**
  66845. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  66846. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66847. */
  66848. ignoreAdaptiveScaling: boolean;
  66849. /**
  66850. * Creates a new ValueAndUnit
  66851. * @param value defines the value to store
  66852. * @param unit defines the unit to store
  66853. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  66854. */
  66855. constructor(value: number,
  66856. /** defines the unit to store */
  66857. unit?: number,
  66858. /** defines a boolean indicating if the value can be negative */
  66859. negativeValueAllowed?: boolean);
  66860. /** Gets a boolean indicating if the value is a percentage */
  66861. readonly isPercentage: boolean;
  66862. /** Gets a boolean indicating if the value is store as pixel */
  66863. readonly isPixel: boolean;
  66864. /** Gets direct internal value */
  66865. readonly internalValue: number;
  66866. /**
  66867. * Gets value as pixel
  66868. * @param host defines the root host
  66869. * @param refValue defines the reference value for percentages
  66870. * @returns the value as pixel
  66871. */
  66872. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  66873. /**
  66874. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  66875. * @param value defines the value to store
  66876. * @param unit defines the unit to store
  66877. * @returns the current ValueAndUnit
  66878. */
  66879. updateInPlace(value: number, unit?: number): ValueAndUnit;
  66880. /**
  66881. * Gets the value accordingly to its unit
  66882. * @param host defines the root host
  66883. * @returns the value
  66884. */
  66885. getValue(host: AdvancedDynamicTexture): number;
  66886. /**
  66887. * Gets a string representation of the value
  66888. * @param host defines the root host
  66889. * @param decimals defines an optional number of decimals to display
  66890. * @returns a string
  66891. */
  66892. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  66893. /**
  66894. * Store a value parsed from a string
  66895. * @param source defines the source string
  66896. * @returns true if the value was successfully parsed
  66897. */
  66898. fromString(source: string | number): boolean;
  66899. private static _Regex;
  66900. private static _UNITMODE_PERCENTAGE;
  66901. private static _UNITMODE_PIXEL;
  66902. /** UNITMODE_PERCENTAGE */
  66903. static readonly UNITMODE_PERCENTAGE: number;
  66904. /** UNITMODE_PIXEL */
  66905. static readonly UNITMODE_PIXEL: number;
  66906. }
  66907. }
  66908. declare module BABYLON.GUI {
  66909. /**
  66910. * Define a style used by control to automatically setup properties based on a template.
  66911. * Only support font related properties so far
  66912. */
  66913. export class Style implements BABYLON.IDisposable {
  66914. private _fontFamily;
  66915. private _fontStyle;
  66916. private _fontWeight;
  66917. /** @hidden */
  66918. _host: AdvancedDynamicTexture;
  66919. /** @hidden */
  66920. _fontSize: ValueAndUnit;
  66921. /**
  66922. * BABYLON.Observable raised when the style values are changed
  66923. */
  66924. onChangedObservable: BABYLON.Observable<Style>;
  66925. /**
  66926. * Creates a new style object
  66927. * @param host defines the AdvancedDynamicTexture which hosts this style
  66928. */
  66929. constructor(host: AdvancedDynamicTexture);
  66930. /**
  66931. * Gets or sets the font size
  66932. */
  66933. fontSize: string | number;
  66934. /**
  66935. * Gets or sets the font family
  66936. */
  66937. fontFamily: string;
  66938. /**
  66939. * Gets or sets the font style
  66940. */
  66941. fontStyle: string;
  66942. /** Gets or sets font weight */
  66943. fontWeight: string;
  66944. /** Dispose all associated resources */
  66945. dispose(): void;
  66946. }
  66947. }
  66948. declare module BABYLON.GUI {
  66949. /**
  66950. * Class used to transport BABYLON.Vector2 information for pointer events
  66951. */
  66952. export class Vector2WithInfo extends BABYLON.Vector2 {
  66953. /** defines the current mouse button index */
  66954. buttonIndex: number;
  66955. /**
  66956. * Creates a new Vector2WithInfo
  66957. * @param source defines the vector2 data to transport
  66958. * @param buttonIndex defines the current mouse button index
  66959. */
  66960. constructor(source: BABYLON.Vector2,
  66961. /** defines the current mouse button index */
  66962. buttonIndex?: number);
  66963. }
  66964. /** Class used to provide 2D matrix features */
  66965. export class Matrix2D {
  66966. /** Gets the internal array of 6 floats used to store matrix data */
  66967. m: Float32Array;
  66968. /**
  66969. * Creates a new matrix
  66970. * @param m00 defines value for (0, 0)
  66971. * @param m01 defines value for (0, 1)
  66972. * @param m10 defines value for (1, 0)
  66973. * @param m11 defines value for (1, 1)
  66974. * @param m20 defines value for (2, 0)
  66975. * @param m21 defines value for (2, 1)
  66976. */
  66977. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  66978. /**
  66979. * Fills the matrix from direct values
  66980. * @param m00 defines value for (0, 0)
  66981. * @param m01 defines value for (0, 1)
  66982. * @param m10 defines value for (1, 0)
  66983. * @param m11 defines value for (1, 1)
  66984. * @param m20 defines value for (2, 0)
  66985. * @param m21 defines value for (2, 1)
  66986. * @returns the current modified matrix
  66987. */
  66988. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  66989. /**
  66990. * Gets matrix determinant
  66991. * @returns the determinant
  66992. */
  66993. determinant(): number;
  66994. /**
  66995. * Inverses the matrix and stores it in a target matrix
  66996. * @param result defines the target matrix
  66997. * @returns the current matrix
  66998. */
  66999. invertToRef(result: Matrix2D): Matrix2D;
  67000. /**
  67001. * Multiplies the current matrix with another one
  67002. * @param other defines the second operand
  67003. * @param result defines the target matrix
  67004. * @returns the current matrix
  67005. */
  67006. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  67007. /**
  67008. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  67009. * @param x defines the x coordinate to transform
  67010. * @param y defines the x coordinate to transform
  67011. * @param result defines the target vector2
  67012. * @returns the current matrix
  67013. */
  67014. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  67015. /**
  67016. * Creates an identity matrix
  67017. * @returns a new matrix
  67018. */
  67019. static Identity(): Matrix2D;
  67020. /**
  67021. * Creates a translation matrix and stores it in a target matrix
  67022. * @param x defines the x coordinate of the translation
  67023. * @param y defines the y coordinate of the translation
  67024. * @param result defines the target matrix
  67025. */
  67026. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  67027. /**
  67028. * Creates a scaling matrix and stores it in a target matrix
  67029. * @param x defines the x coordinate of the scaling
  67030. * @param y defines the y coordinate of the scaling
  67031. * @param result defines the target matrix
  67032. */
  67033. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  67034. /**
  67035. * Creates a rotation matrix and stores it in a target matrix
  67036. * @param angle defines the rotation angle
  67037. * @param result defines the target matrix
  67038. */
  67039. static RotationToRef(angle: number, result: Matrix2D): void;
  67040. private static _TempPreTranslationMatrix;
  67041. private static _TempPostTranslationMatrix;
  67042. private static _TempRotationMatrix;
  67043. private static _TempScalingMatrix;
  67044. private static _TempCompose0;
  67045. private static _TempCompose1;
  67046. private static _TempCompose2;
  67047. /**
  67048. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  67049. * @param tx defines the x coordinate of the translation
  67050. * @param ty defines the y coordinate of the translation
  67051. * @param angle defines the rotation angle
  67052. * @param scaleX defines the x coordinate of the scaling
  67053. * @param scaleY defines the y coordinate of the scaling
  67054. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  67055. * @param result defines the target matrix
  67056. */
  67057. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  67058. }
  67059. }
  67060. declare module BABYLON.GUI {
  67061. /**
  67062. * Class used to store 2D control sizes
  67063. */
  67064. export class Measure {
  67065. /** defines left coordinate */
  67066. left: number;
  67067. /** defines top coordinate */
  67068. top: number;
  67069. /** defines width dimension */
  67070. width: number;
  67071. /** defines height dimension */
  67072. height: number;
  67073. /**
  67074. * Creates a new measure
  67075. * @param left defines left coordinate
  67076. * @param top defines top coordinate
  67077. * @param width defines width dimension
  67078. * @param height defines height dimension
  67079. */
  67080. constructor(
  67081. /** defines left coordinate */
  67082. left: number,
  67083. /** defines top coordinate */
  67084. top: number,
  67085. /** defines width dimension */
  67086. width: number,
  67087. /** defines height dimension */
  67088. height: number);
  67089. /**
  67090. * Copy from another measure
  67091. * @param other defines the other measure to copy from
  67092. */
  67093. copyFrom(other: Measure): void;
  67094. /**
  67095. * Copy from a group of 4 floats
  67096. * @param left defines left coordinate
  67097. * @param top defines top coordinate
  67098. * @param width defines width dimension
  67099. * @param height defines height dimension
  67100. */
  67101. copyFromFloats(left: number, top: number, width: number, height: number): void;
  67102. /**
  67103. * Computes the axis aligned bounding box measure for two given measures
  67104. * @param a Input measure
  67105. * @param b Input measure
  67106. * @param result the resulting bounding measure
  67107. */
  67108. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  67109. /**
  67110. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  67111. * @param transform the matrix to transform the measure before computing the AABB
  67112. * @param result the resulting AABB
  67113. */
  67114. transformToRef(transform: Matrix2D, result: Measure): void;
  67115. /**
  67116. * Check equality between this measure and another one
  67117. * @param other defines the other measures
  67118. * @returns true if both measures are equals
  67119. */
  67120. isEqualsTo(other: Measure): boolean;
  67121. /**
  67122. * Creates an empty measure
  67123. * @returns a new measure
  67124. */
  67125. static Empty(): Measure;
  67126. }
  67127. }
  67128. declare module BABYLON.GUI {
  67129. /**
  67130. * Interface used to define a control that can receive focus
  67131. */
  67132. export interface IFocusableControl {
  67133. /**
  67134. * Function called when the control receives the focus
  67135. */
  67136. onFocus(): void;
  67137. /**
  67138. * Function called when the control loses the focus
  67139. */
  67140. onBlur(): void;
  67141. /**
  67142. * Function called to let the control handle keyboard events
  67143. * @param evt defines the current keyboard event
  67144. */
  67145. processKeyboard(evt: KeyboardEvent): void;
  67146. /**
  67147. * Function called to get the list of controls that should not steal the focus from this control
  67148. * @returns an array of controls
  67149. */
  67150. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  67151. }
  67152. /**
  67153. * Class used to create texture to support 2D GUI elements
  67154. * @see http://doc.babylonjs.com/how_to/gui
  67155. */
  67156. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  67157. private _isDirty;
  67158. private _renderObserver;
  67159. private _resizeObserver;
  67160. private _preKeyboardObserver;
  67161. private _pointerMoveObserver;
  67162. private _pointerObserver;
  67163. private _canvasPointerOutObserver;
  67164. private _background;
  67165. /** @hidden */
  67166. _rootContainer: Container;
  67167. /** @hidden */
  67168. _lastPickedControl: Control;
  67169. /** @hidden */
  67170. _lastControlOver: {
  67171. [pointerId: number]: Control;
  67172. };
  67173. /** @hidden */
  67174. _lastControlDown: {
  67175. [pointerId: number]: Control;
  67176. };
  67177. /** @hidden */
  67178. _capturingControl: {
  67179. [pointerId: number]: Control;
  67180. };
  67181. /** @hidden */
  67182. _shouldBlockPointer: boolean;
  67183. /** @hidden */
  67184. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  67185. /** @hidden */
  67186. _linkedControls: Control[];
  67187. private _isFullscreen;
  67188. private _fullscreenViewport;
  67189. private _idealWidth;
  67190. private _idealHeight;
  67191. private _useSmallestIdeal;
  67192. private _renderAtIdealSize;
  67193. private _focusedControl;
  67194. private _blockNextFocusCheck;
  67195. private _renderScale;
  67196. private _rootElement;
  67197. private _cursorChanged;
  67198. /**
  67199. * Define type to string to ensure compatibility across browsers
  67200. * Safari doesn't support DataTransfer constructor
  67201. */
  67202. private _clipboardData;
  67203. /**
  67204. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  67205. */
  67206. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  67207. /**
  67208. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  67209. */
  67210. onControlPickedObservable: BABYLON.Observable<Control>;
  67211. /**
  67212. * BABYLON.Observable event triggered before layout is evaluated
  67213. */
  67214. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67215. /**
  67216. * BABYLON.Observable event triggered after the layout was evaluated
  67217. */
  67218. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67219. /**
  67220. * BABYLON.Observable event triggered before the texture is rendered
  67221. */
  67222. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67223. /**
  67224. * BABYLON.Observable event triggered after the texture was rendered
  67225. */
  67226. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67227. /**
  67228. * Gets or sets a boolean defining if alpha is stored as premultiplied
  67229. */
  67230. premulAlpha: boolean;
  67231. /**
  67232. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  67233. * Useful when you want more antialiasing
  67234. */
  67235. renderScale: number;
  67236. /** Gets or sets the background color */
  67237. background: string;
  67238. /**
  67239. * Gets or sets the ideal width used to design controls.
  67240. * The GUI will then rescale everything accordingly
  67241. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67242. */
  67243. idealWidth: number;
  67244. /**
  67245. * Gets or sets the ideal height used to design controls.
  67246. * The GUI will then rescale everything accordingly
  67247. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67248. */
  67249. idealHeight: number;
  67250. /**
  67251. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  67252. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67253. */
  67254. useSmallestIdeal: boolean;
  67255. /**
  67256. * Gets or sets a boolean indicating if adaptive scaling must be used
  67257. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67258. */
  67259. renderAtIdealSize: boolean;
  67260. /**
  67261. * Gets the underlying layer used to render the texture when in fullscreen mode
  67262. */
  67263. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  67264. /**
  67265. * Gets the root container control
  67266. */
  67267. readonly rootContainer: Container;
  67268. /**
  67269. * Returns an array containing the root container.
  67270. * This is mostly used to let the Inspector introspects the ADT
  67271. * @returns an array containing the rootContainer
  67272. */
  67273. getChildren(): Array<Container>;
  67274. /**
  67275. * Will return all controls that are inside this texture
  67276. * @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
  67277. * @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
  67278. * @return all child controls
  67279. */
  67280. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  67281. /**
  67282. * Gets or sets the current focused control
  67283. */
  67284. focusedControl: BABYLON.Nullable<IFocusableControl>;
  67285. /**
  67286. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  67287. */
  67288. isForeground: boolean;
  67289. /**
  67290. * Gets or set information about clipboardData
  67291. */
  67292. clipboardData: string;
  67293. /**
  67294. * Creates a new AdvancedDynamicTexture
  67295. * @param name defines the name of the texture
  67296. * @param width defines the width of the texture
  67297. * @param height defines the height of the texture
  67298. * @param scene defines the hosting scene
  67299. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  67300. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  67301. */
  67302. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  67303. /**
  67304. * Get the current class name of the texture useful for serialization or dynamic coding.
  67305. * @returns "AdvancedDynamicTexture"
  67306. */
  67307. getClassName(): string;
  67308. /**
  67309. * Function used to execute a function on all controls
  67310. * @param func defines the function to execute
  67311. * @param container defines the container where controls belong. If null the root container will be used
  67312. */
  67313. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  67314. private _useInvalidateRectOptimization;
  67315. /**
  67316. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  67317. */
  67318. useInvalidateRectOptimization: boolean;
  67319. private _invalidatedRectangle;
  67320. /**
  67321. * Invalidates a rectangle area on the gui texture
  67322. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  67323. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  67324. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  67325. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  67326. */
  67327. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  67328. /**
  67329. * Marks the texture as dirty forcing a complete update
  67330. */
  67331. markAsDirty(): void;
  67332. /**
  67333. * Helper function used to create a new style
  67334. * @returns a new style
  67335. * @see http://doc.babylonjs.com/how_to/gui#styles
  67336. */
  67337. createStyle(): Style;
  67338. /**
  67339. * Adds a new control to the root container
  67340. * @param control defines the control to add
  67341. * @returns the current texture
  67342. */
  67343. addControl(control: Control): AdvancedDynamicTexture;
  67344. /**
  67345. * Removes a control from the root container
  67346. * @param control defines the control to remove
  67347. * @returns the current texture
  67348. */
  67349. removeControl(control: Control): AdvancedDynamicTexture;
  67350. /**
  67351. * Release all resources
  67352. */
  67353. dispose(): void;
  67354. private _onResize;
  67355. /** @hidden */
  67356. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  67357. /**
  67358. * Get screen coordinates for a vector3
  67359. * @param position defines the position to project
  67360. * @param worldMatrix defines the world matrix to use
  67361. * @returns the projected position
  67362. */
  67363. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  67364. private _checkUpdate;
  67365. private _clearMeasure;
  67366. private _render;
  67367. /** @hidden */
  67368. _changeCursor(cursor: string): void;
  67369. /** @hidden */
  67370. _registerLastControlDown(control: Control, pointerId: number): void;
  67371. private _doPicking;
  67372. /** @hidden */
  67373. _cleanControlAfterRemovalFromList(list: {
  67374. [pointerId: number]: Control;
  67375. }, control: Control): void;
  67376. /** @hidden */
  67377. _cleanControlAfterRemoval(control: Control): void;
  67378. /** Attach to all scene events required to support pointer events */
  67379. attach(): void;
  67380. /** @hidden */
  67381. private onClipboardCopy;
  67382. /** @hidden */
  67383. private onClipboardCut;
  67384. /** @hidden */
  67385. private onClipboardPaste;
  67386. /**
  67387. * Register the clipboard Events onto the canvas
  67388. */
  67389. registerClipboardEvents(): void;
  67390. /**
  67391. * Unregister the clipboard Events from the canvas
  67392. */
  67393. unRegisterClipboardEvents(): void;
  67394. /**
  67395. * Connect the texture to a hosting mesh to enable interactions
  67396. * @param mesh defines the mesh to attach to
  67397. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  67398. */
  67399. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  67400. /**
  67401. * Move the focus to a specific control
  67402. * @param control defines the control which will receive the focus
  67403. */
  67404. moveFocusToControl(control: IFocusableControl): void;
  67405. private _manageFocus;
  67406. private _attachToOnPointerOut;
  67407. /**
  67408. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  67409. * @param mesh defines the mesh which will receive the texture
  67410. * @param width defines the texture width (1024 by default)
  67411. * @param height defines the texture height (1024 by default)
  67412. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  67413. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  67414. * @returns a new AdvancedDynamicTexture
  67415. */
  67416. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  67417. /**
  67418. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  67419. * In this mode the texture will rely on a layer for its rendering.
  67420. * This allows it to be treated like any other layer.
  67421. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  67422. * LayerMask is set through advancedTexture.layer.layerMask
  67423. * @param name defines name for the texture
  67424. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  67425. * @param scene defines the hsoting scene
  67426. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  67427. * @returns a new AdvancedDynamicTexture
  67428. */
  67429. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  67430. }
  67431. }
  67432. declare module BABYLON.GUI {
  67433. /**
  67434. * Root class used for all 2D controls
  67435. * @see http://doc.babylonjs.com/how_to/gui#controls
  67436. */
  67437. export class Control {
  67438. /** defines the name of the control */
  67439. name?: string | undefined;
  67440. /**
  67441. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  67442. */
  67443. static AllowAlphaInheritance: boolean;
  67444. private _alpha;
  67445. private _alphaSet;
  67446. private _zIndex;
  67447. /** @hidden */
  67448. _host: AdvancedDynamicTexture;
  67449. /** Gets or sets the control parent */
  67450. parent: BABYLON.Nullable<Container>;
  67451. /** @hidden */
  67452. _currentMeasure: Measure;
  67453. private _fontFamily;
  67454. private _fontStyle;
  67455. private _fontWeight;
  67456. private _fontSize;
  67457. private _font;
  67458. /** @hidden */
  67459. _width: ValueAndUnit;
  67460. /** @hidden */
  67461. _height: ValueAndUnit;
  67462. /** @hidden */
  67463. protected _fontOffset: {
  67464. ascent: number;
  67465. height: number;
  67466. descent: number;
  67467. };
  67468. private _color;
  67469. private _style;
  67470. private _styleObserver;
  67471. /** @hidden */
  67472. protected _horizontalAlignment: number;
  67473. /** @hidden */
  67474. protected _verticalAlignment: number;
  67475. /** @hidden */
  67476. protected _isDirty: boolean;
  67477. /** @hidden */
  67478. protected _wasDirty: boolean;
  67479. /** @hidden */
  67480. _tempParentMeasure: Measure;
  67481. /** @hidden */
  67482. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  67483. /** @hidden */
  67484. protected _cachedParentMeasure: Measure;
  67485. private _paddingLeft;
  67486. private _paddingRight;
  67487. private _paddingTop;
  67488. private _paddingBottom;
  67489. /** @hidden */
  67490. _left: ValueAndUnit;
  67491. /** @hidden */
  67492. _top: ValueAndUnit;
  67493. private _scaleX;
  67494. private _scaleY;
  67495. private _rotation;
  67496. private _transformCenterX;
  67497. private _transformCenterY;
  67498. /** @hidden */
  67499. _transformMatrix: Matrix2D;
  67500. /** @hidden */
  67501. protected _invertTransformMatrix: Matrix2D;
  67502. /** @hidden */
  67503. protected _transformedPosition: BABYLON.Vector2;
  67504. private _isMatrixDirty;
  67505. private _cachedOffsetX;
  67506. private _cachedOffsetY;
  67507. private _isVisible;
  67508. private _isHighlighted;
  67509. /** @hidden */
  67510. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67511. private _fontSet;
  67512. private _dummyVector2;
  67513. private _downCount;
  67514. private _enterCount;
  67515. private _doNotRender;
  67516. private _downPointerIds;
  67517. protected _isEnabled: boolean;
  67518. protected _disabledColor: string;
  67519. /** @hidden */
  67520. protected _rebuildLayout: boolean;
  67521. /** @hidden */
  67522. _isClipped: boolean;
  67523. /** @hidden */
  67524. _automaticSize: boolean;
  67525. /** @hidden */
  67526. _tag: any;
  67527. /**
  67528. * 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
  67529. */
  67530. uniqueId: number;
  67531. /**
  67532. * Gets or sets an object used to store user defined information for the node
  67533. */
  67534. metadata: any;
  67535. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  67536. isHitTestVisible: boolean;
  67537. /** Gets or sets a boolean indicating if the control can block pointer events */
  67538. isPointerBlocker: boolean;
  67539. /** Gets or sets a boolean indicating if the control can be focusable */
  67540. isFocusInvisible: boolean;
  67541. /**
  67542. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  67543. * 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
  67544. */
  67545. clipChildren: boolean;
  67546. /**
  67547. * Gets or sets a boolean indicating that control content must be clipped
  67548. * 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
  67549. */
  67550. clipContent: boolean;
  67551. /**
  67552. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  67553. */
  67554. useBitmapCache: boolean;
  67555. private _cacheData;
  67556. private _shadowOffsetX;
  67557. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  67558. shadowOffsetX: number;
  67559. private _shadowOffsetY;
  67560. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  67561. shadowOffsetY: number;
  67562. private _shadowBlur;
  67563. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  67564. shadowBlur: number;
  67565. private _shadowColor;
  67566. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  67567. shadowColor: string;
  67568. /** Gets or sets the cursor to use when the control is hovered */
  67569. hoverCursor: string;
  67570. /** @hidden */
  67571. protected _linkOffsetX: ValueAndUnit;
  67572. /** @hidden */
  67573. protected _linkOffsetY: ValueAndUnit;
  67574. /** Gets the control type name */
  67575. readonly typeName: string;
  67576. /**
  67577. * Get the current class name of the control.
  67578. * @returns current class name
  67579. */
  67580. getClassName(): string;
  67581. /**
  67582. * An event triggered when the pointer move over the control.
  67583. */
  67584. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  67585. /**
  67586. * An event triggered when the pointer move out of the control.
  67587. */
  67588. onPointerOutObservable: BABYLON.Observable<Control>;
  67589. /**
  67590. * An event triggered when the pointer taps the control
  67591. */
  67592. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  67593. /**
  67594. * An event triggered when pointer up
  67595. */
  67596. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  67597. /**
  67598. * An event triggered when a control is clicked on
  67599. */
  67600. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  67601. /**
  67602. * An event triggered when pointer enters the control
  67603. */
  67604. onPointerEnterObservable: BABYLON.Observable<Control>;
  67605. /**
  67606. * An event triggered when the control is marked as dirty
  67607. */
  67608. onDirtyObservable: BABYLON.Observable<Control>;
  67609. /**
  67610. * An event triggered before drawing the control
  67611. */
  67612. onBeforeDrawObservable: BABYLON.Observable<Control>;
  67613. /**
  67614. * An event triggered after the control was drawn
  67615. */
  67616. onAfterDrawObservable: BABYLON.Observable<Control>;
  67617. /**
  67618. * Get the hosting AdvancedDynamicTexture
  67619. */
  67620. readonly host: AdvancedDynamicTexture;
  67621. /** Gets or set information about font offsets (used to render and align text) */
  67622. fontOffset: {
  67623. ascent: number;
  67624. height: number;
  67625. descent: number;
  67626. };
  67627. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  67628. alpha: number;
  67629. /**
  67630. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  67631. */
  67632. isHighlighted: boolean;
  67633. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  67634. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67635. */
  67636. scaleX: number;
  67637. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  67638. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67639. */
  67640. scaleY: number;
  67641. /** Gets or sets the rotation angle (0 by default)
  67642. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67643. */
  67644. rotation: number;
  67645. /** Gets or sets the transformation center on Y axis (0 by default)
  67646. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67647. */
  67648. transformCenterY: number;
  67649. /** Gets or sets the transformation center on X axis (0 by default)
  67650. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67651. */
  67652. transformCenterX: number;
  67653. /**
  67654. * Gets or sets the horizontal alignment
  67655. * @see http://doc.babylonjs.com/how_to/gui#alignments
  67656. */
  67657. horizontalAlignment: number;
  67658. /**
  67659. * Gets or sets the vertical alignment
  67660. * @see http://doc.babylonjs.com/how_to/gui#alignments
  67661. */
  67662. verticalAlignment: number;
  67663. /**
  67664. * Gets or sets control width
  67665. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67666. */
  67667. width: string | number;
  67668. /**
  67669. * Gets or sets the control width in pixel
  67670. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67671. */
  67672. widthInPixels: number;
  67673. /**
  67674. * Gets or sets control height
  67675. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67676. */
  67677. height: string | number;
  67678. /**
  67679. * Gets or sets control height in pixel
  67680. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67681. */
  67682. heightInPixels: number;
  67683. /** Gets or set font family */
  67684. fontFamily: string;
  67685. /** Gets or sets font style */
  67686. fontStyle: string;
  67687. /** Gets or sets font weight */
  67688. fontWeight: string;
  67689. /**
  67690. * Gets or sets style
  67691. * @see http://doc.babylonjs.com/how_to/gui#styles
  67692. */
  67693. style: BABYLON.Nullable<Style>;
  67694. /** @hidden */
  67695. readonly _isFontSizeInPercentage: boolean;
  67696. /** Gets or sets font size in pixels */
  67697. fontSizeInPixels: number;
  67698. /** Gets or sets font size */
  67699. fontSize: string | number;
  67700. /** Gets or sets foreground color */
  67701. color: string;
  67702. /** Gets or sets z index which is used to reorder controls on the z axis */
  67703. zIndex: number;
  67704. /** Gets or sets a boolean indicating if the control can be rendered */
  67705. notRenderable: boolean;
  67706. /** Gets or sets a boolean indicating if the control is visible */
  67707. isVisible: boolean;
  67708. /** Gets a boolean indicating that the control needs to update its rendering */
  67709. readonly isDirty: boolean;
  67710. /**
  67711. * Gets the current linked mesh (or null if none)
  67712. */
  67713. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67714. /**
  67715. * Gets or sets a value indicating the padding to use on the left of the control
  67716. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67717. */
  67718. paddingLeft: string | number;
  67719. /**
  67720. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  67721. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67722. */
  67723. paddingLeftInPixels: number;
  67724. /**
  67725. * Gets or sets a value indicating the padding to use on the right of the control
  67726. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67727. */
  67728. paddingRight: string | number;
  67729. /**
  67730. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  67731. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67732. */
  67733. paddingRightInPixels: number;
  67734. /**
  67735. * Gets or sets a value indicating the padding to use on the top of the control
  67736. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67737. */
  67738. paddingTop: string | number;
  67739. /**
  67740. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  67741. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67742. */
  67743. paddingTopInPixels: number;
  67744. /**
  67745. * Gets or sets a value indicating the padding to use on the bottom of the control
  67746. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67747. */
  67748. paddingBottom: string | number;
  67749. /**
  67750. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  67751. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67752. */
  67753. paddingBottomInPixels: number;
  67754. /**
  67755. * Gets or sets a value indicating the left coordinate of the control
  67756. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67757. */
  67758. left: string | number;
  67759. /**
  67760. * Gets or sets a value indicating the left coordinate in pixels of the control
  67761. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67762. */
  67763. leftInPixels: number;
  67764. /**
  67765. * Gets or sets a value indicating the top coordinate of the control
  67766. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67767. */
  67768. top: string | number;
  67769. /**
  67770. * Gets or sets a value indicating the top coordinate in pixels of the control
  67771. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67772. */
  67773. topInPixels: number;
  67774. /**
  67775. * Gets or sets a value indicating the offset on X axis to the linked mesh
  67776. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67777. */
  67778. linkOffsetX: string | number;
  67779. /**
  67780. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  67781. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67782. */
  67783. linkOffsetXInPixels: number;
  67784. /**
  67785. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  67786. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67787. */
  67788. linkOffsetY: string | number;
  67789. /**
  67790. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  67791. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67792. */
  67793. linkOffsetYInPixels: number;
  67794. /** Gets the center coordinate on X axis */
  67795. readonly centerX: number;
  67796. /** Gets the center coordinate on Y axis */
  67797. readonly centerY: number;
  67798. /** Gets or sets if control is Enabled*/
  67799. isEnabled: boolean;
  67800. /** Gets or sets background color of control if it's disabled*/
  67801. disabledColor: string;
  67802. /**
  67803. * Creates a new control
  67804. * @param name defines the name of the control
  67805. */
  67806. constructor(
  67807. /** defines the name of the control */
  67808. name?: string | undefined);
  67809. /** @hidden */
  67810. protected _getTypeName(): string;
  67811. /**
  67812. * Gets the first ascendant in the hierarchy of the given type
  67813. * @param className defines the required type
  67814. * @returns the ascendant or null if not found
  67815. */
  67816. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  67817. /** @hidden */
  67818. _resetFontCache(): void;
  67819. /**
  67820. * Determines if a container is an ascendant of the current control
  67821. * @param container defines the container to look for
  67822. * @returns true if the container is one of the ascendant of the control
  67823. */
  67824. isAscendant(container: Control): boolean;
  67825. /**
  67826. * Gets coordinates in local control space
  67827. * @param globalCoordinates defines the coordinates to transform
  67828. * @returns the new coordinates in local space
  67829. */
  67830. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  67831. /**
  67832. * Gets coordinates in local control space
  67833. * @param globalCoordinates defines the coordinates to transform
  67834. * @param result defines the target vector2 where to store the result
  67835. * @returns the current control
  67836. */
  67837. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  67838. /**
  67839. * Gets coordinates in parent local control space
  67840. * @param globalCoordinates defines the coordinates to transform
  67841. * @returns the new coordinates in parent local space
  67842. */
  67843. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  67844. /**
  67845. * Move the current control to a vector3 position projected onto the screen.
  67846. * @param position defines the target position
  67847. * @param scene defines the hosting scene
  67848. */
  67849. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  67850. /**
  67851. * Will store all controls that have this control as ascendant in a given array
  67852. * @param results defines the array where to store the descendants
  67853. * @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
  67854. * @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
  67855. */
  67856. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  67857. /**
  67858. * Will return all controls that have this control as ascendant
  67859. * @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
  67860. * @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
  67861. * @return all child controls
  67862. */
  67863. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  67864. /**
  67865. * Link current control with a target mesh
  67866. * @param mesh defines the mesh to link with
  67867. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67868. */
  67869. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  67870. /** @hidden */
  67871. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  67872. /** @hidden */
  67873. _offsetLeft(offset: number): void;
  67874. /** @hidden */
  67875. _offsetTop(offset: number): void;
  67876. /** @hidden */
  67877. _markMatrixAsDirty(): void;
  67878. /** @hidden */
  67879. _flagDescendantsAsMatrixDirty(): void;
  67880. /** @hidden */
  67881. _intersectsRect(rect: Measure): boolean;
  67882. /** @hidden */
  67883. protected invalidateRect(): void;
  67884. /** @hidden */
  67885. _markAsDirty(force?: boolean): void;
  67886. /** @hidden */
  67887. _markAllAsDirty(): void;
  67888. /** @hidden */
  67889. _link(host: AdvancedDynamicTexture): void;
  67890. /** @hidden */
  67891. protected _transform(context?: CanvasRenderingContext2D): void;
  67892. /** @hidden */
  67893. _renderHighlight(context: CanvasRenderingContext2D): void;
  67894. /** @hidden */
  67895. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67896. /** @hidden */
  67897. protected _applyStates(context: CanvasRenderingContext2D): void;
  67898. /** @hidden */
  67899. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  67900. /** @hidden */
  67901. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67902. protected _evaluateClippingState(parentMeasure: Measure): void;
  67903. /** @hidden */
  67904. _measure(): void;
  67905. /** @hidden */
  67906. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67907. /** @hidden */
  67908. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67909. /** @hidden */
  67910. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67911. /** @hidden */
  67912. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  67913. private static _ClipMeasure;
  67914. private _tmpMeasureA;
  67915. private _clip;
  67916. /** @hidden */
  67917. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  67918. /** @hidden */
  67919. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67920. /**
  67921. * Tests if a given coordinates belong to the current control
  67922. * @param x defines x coordinate to test
  67923. * @param y defines y coordinate to test
  67924. * @returns true if the coordinates are inside the control
  67925. */
  67926. contains(x: number, y: number): boolean;
  67927. /** @hidden */
  67928. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  67929. /** @hidden */
  67930. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67931. /** @hidden */
  67932. _onPointerEnter(target: Control): boolean;
  67933. /** @hidden */
  67934. _onPointerOut(target: Control, force?: boolean): void;
  67935. /** @hidden */
  67936. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67937. /** @hidden */
  67938. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67939. /** @hidden */
  67940. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67941. /** @hidden */
  67942. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  67943. private _prepareFont;
  67944. /** Releases associated resources */
  67945. dispose(): void;
  67946. private static _HORIZONTAL_ALIGNMENT_LEFT;
  67947. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  67948. private static _HORIZONTAL_ALIGNMENT_CENTER;
  67949. private static _VERTICAL_ALIGNMENT_TOP;
  67950. private static _VERTICAL_ALIGNMENT_BOTTOM;
  67951. private static _VERTICAL_ALIGNMENT_CENTER;
  67952. /** HORIZONTAL_ALIGNMENT_LEFT */
  67953. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  67954. /** HORIZONTAL_ALIGNMENT_RIGHT */
  67955. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  67956. /** HORIZONTAL_ALIGNMENT_CENTER */
  67957. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  67958. /** VERTICAL_ALIGNMENT_TOP */
  67959. static readonly VERTICAL_ALIGNMENT_TOP: number;
  67960. /** VERTICAL_ALIGNMENT_BOTTOM */
  67961. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  67962. /** VERTICAL_ALIGNMENT_CENTER */
  67963. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  67964. private static _FontHeightSizes;
  67965. /** @hidden */
  67966. static _GetFontOffset(font: string): {
  67967. ascent: number;
  67968. height: number;
  67969. descent: number;
  67970. };
  67971. /**
  67972. * Creates a stack panel that can be used to render headers
  67973. * @param control defines the control to associate with the header
  67974. * @param text defines the text of the header
  67975. * @param size defines the size of the header
  67976. * @param options defines options used to configure the header
  67977. * @returns a new StackPanel
  67978. * @ignore
  67979. * @hidden
  67980. */
  67981. static AddHeader: (control: Control, text: string, size: string | number, options: {
  67982. isHorizontal: boolean;
  67983. controlFirst: boolean;
  67984. }) => any;
  67985. /** @hidden */
  67986. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  67987. }
  67988. }
  67989. declare module BABYLON.GUI {
  67990. /**
  67991. * Root class for 2D containers
  67992. * @see http://doc.babylonjs.com/how_to/gui#containers
  67993. */
  67994. export class Container extends Control {
  67995. name?: string | undefined;
  67996. /** @hidden */
  67997. protected _children: Control[];
  67998. /** @hidden */
  67999. protected _measureForChildren: Measure;
  68000. /** @hidden */
  68001. protected _background: string;
  68002. /** @hidden */
  68003. protected _adaptWidthToChildren: boolean;
  68004. /** @hidden */
  68005. protected _adaptHeightToChildren: boolean;
  68006. /**
  68007. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  68008. */
  68009. logLayoutCycleErrors: boolean;
  68010. /**
  68011. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  68012. */
  68013. maxLayoutCycle: number;
  68014. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  68015. adaptHeightToChildren: boolean;
  68016. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  68017. adaptWidthToChildren: boolean;
  68018. /** Gets or sets background color */
  68019. background: string;
  68020. /** Gets the list of children */
  68021. readonly children: Control[];
  68022. /**
  68023. * Creates a new Container
  68024. * @param name defines the name of the container
  68025. */
  68026. constructor(name?: string | undefined);
  68027. protected _getTypeName(): string;
  68028. _flagDescendantsAsMatrixDirty(): void;
  68029. /**
  68030. * Gets a child using its name
  68031. * @param name defines the child name to look for
  68032. * @returns the child control if found
  68033. */
  68034. getChildByName(name: string): BABYLON.Nullable<Control>;
  68035. /**
  68036. * Gets a child using its type and its name
  68037. * @param name defines the child name to look for
  68038. * @param type defines the child type to look for
  68039. * @returns the child control if found
  68040. */
  68041. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  68042. /**
  68043. * Search for a specific control in children
  68044. * @param control defines the control to look for
  68045. * @returns true if the control is in child list
  68046. */
  68047. containsControl(control: Control): boolean;
  68048. /**
  68049. * Adds a new control to the current container
  68050. * @param control defines the control to add
  68051. * @returns the current container
  68052. */
  68053. addControl(control: BABYLON.Nullable<Control>): Container;
  68054. /**
  68055. * Removes all controls from the current container
  68056. * @returns the current container
  68057. */
  68058. clearControls(): Container;
  68059. /**
  68060. * Removes a control from the current container
  68061. * @param control defines the control to remove
  68062. * @returns the current container
  68063. */
  68064. removeControl(control: Control): Container;
  68065. /** @hidden */
  68066. _reOrderControl(control: Control): void;
  68067. /** @hidden */
  68068. _offsetLeft(offset: number): void;
  68069. /** @hidden */
  68070. _offsetTop(offset: number): void;
  68071. /** @hidden */
  68072. _markAllAsDirty(): void;
  68073. /** @hidden */
  68074. protected _localDraw(context: CanvasRenderingContext2D): void;
  68075. /** @hidden */
  68076. _link(host: AdvancedDynamicTexture): void;
  68077. /** @hidden */
  68078. protected _beforeLayout(): void;
  68079. /** @hidden */
  68080. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68081. /** @hidden */
  68082. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  68083. protected _postMeasure(): void;
  68084. /** @hidden */
  68085. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  68086. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  68087. /** @hidden */
  68088. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68089. /** @hidden */
  68090. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68091. /** Releases associated resources */
  68092. dispose(): void;
  68093. }
  68094. }
  68095. declare module BABYLON.GUI {
  68096. /** Class used to create rectangle container */
  68097. export class Rectangle extends Container {
  68098. name?: string | undefined;
  68099. private _thickness;
  68100. private _cornerRadius;
  68101. /** Gets or sets border thickness */
  68102. thickness: number;
  68103. /** Gets or sets the corner radius angle */
  68104. cornerRadius: number;
  68105. /**
  68106. * Creates a new Rectangle
  68107. * @param name defines the control name
  68108. */
  68109. constructor(name?: string | undefined);
  68110. protected _getTypeName(): string;
  68111. protected _localDraw(context: CanvasRenderingContext2D): void;
  68112. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68113. private _drawRoundedRect;
  68114. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68115. }
  68116. }
  68117. declare module BABYLON.GUI {
  68118. /**
  68119. * Enum that determines the text-wrapping mode to use.
  68120. */
  68121. export enum TextWrapping {
  68122. /**
  68123. * Clip the text when it's larger than Control.width; this is the default mode.
  68124. */
  68125. Clip = 0,
  68126. /**
  68127. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  68128. */
  68129. WordWrap = 1,
  68130. /**
  68131. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  68132. */
  68133. Ellipsis = 2
  68134. }
  68135. /**
  68136. * Class used to create text block control
  68137. */
  68138. export class TextBlock extends Control {
  68139. /**
  68140. * Defines the name of the control
  68141. */
  68142. name?: string | undefined;
  68143. private _text;
  68144. private _textWrapping;
  68145. private _textHorizontalAlignment;
  68146. private _textVerticalAlignment;
  68147. private _lines;
  68148. private _resizeToFit;
  68149. private _lineSpacing;
  68150. private _outlineWidth;
  68151. private _outlineColor;
  68152. /**
  68153. * An event triggered after the text is changed
  68154. */
  68155. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  68156. /**
  68157. * An event triggered after the text was broken up into lines
  68158. */
  68159. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  68160. /**
  68161. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  68162. */
  68163. readonly lines: any[];
  68164. /**
  68165. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68166. */
  68167. /**
  68168. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68169. */
  68170. resizeToFit: boolean;
  68171. /**
  68172. * Gets or sets a boolean indicating if text must be wrapped
  68173. */
  68174. /**
  68175. * Gets or sets a boolean indicating if text must be wrapped
  68176. */
  68177. textWrapping: TextWrapping | boolean;
  68178. /**
  68179. * Gets or sets text to display
  68180. */
  68181. /**
  68182. * Gets or sets text to display
  68183. */
  68184. text: string;
  68185. /**
  68186. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68187. */
  68188. /**
  68189. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68190. */
  68191. textHorizontalAlignment: number;
  68192. /**
  68193. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68194. */
  68195. /**
  68196. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68197. */
  68198. textVerticalAlignment: number;
  68199. /**
  68200. * Gets or sets line spacing value
  68201. */
  68202. /**
  68203. * Gets or sets line spacing value
  68204. */
  68205. lineSpacing: string | number;
  68206. /**
  68207. * Gets or sets outlineWidth of the text to display
  68208. */
  68209. /**
  68210. * Gets or sets outlineWidth of the text to display
  68211. */
  68212. outlineWidth: number;
  68213. /**
  68214. * Gets or sets outlineColor of the text to display
  68215. */
  68216. /**
  68217. * Gets or sets outlineColor of the text to display
  68218. */
  68219. outlineColor: string;
  68220. /**
  68221. * Creates a new TextBlock object
  68222. * @param name defines the name of the control
  68223. * @param text defines the text to display (emptry string by default)
  68224. */
  68225. constructor(
  68226. /**
  68227. * Defines the name of the control
  68228. */
  68229. name?: string | undefined, text?: string);
  68230. protected _getTypeName(): string;
  68231. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68232. private _drawText;
  68233. /** @hidden */
  68234. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68235. protected _applyStates(context: CanvasRenderingContext2D): void;
  68236. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  68237. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  68238. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  68239. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  68240. protected _renderLines(context: CanvasRenderingContext2D): void;
  68241. /**
  68242. * Given a width constraint applied on the text block, find the expected height
  68243. * @returns expected height
  68244. */
  68245. computeExpectedHeight(): number;
  68246. dispose(): void;
  68247. }
  68248. }
  68249. declare module BABYLON.GUI {
  68250. /**
  68251. * Class used to create 2D images
  68252. */
  68253. export class Image extends Control {
  68254. name?: string | undefined;
  68255. private _workingCanvas;
  68256. private _domImage;
  68257. private _imageWidth;
  68258. private _imageHeight;
  68259. private _loaded;
  68260. private _stretch;
  68261. private _source;
  68262. private _autoScale;
  68263. private _sourceLeft;
  68264. private _sourceTop;
  68265. private _sourceWidth;
  68266. private _sourceHeight;
  68267. private _cellWidth;
  68268. private _cellHeight;
  68269. private _cellId;
  68270. private _populateNinePatchSlicesFromImage;
  68271. private _sliceLeft;
  68272. private _sliceRight;
  68273. private _sliceTop;
  68274. private _sliceBottom;
  68275. private _detectPointerOnOpaqueOnly;
  68276. /**
  68277. * BABYLON.Observable notified when the content is loaded
  68278. */
  68279. onImageLoadedObservable: BABYLON.Observable<Image>;
  68280. /**
  68281. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  68282. */
  68283. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  68284. /**
  68285. * Gets a boolean indicating that the content is loaded
  68286. */
  68287. readonly isLoaded: boolean;
  68288. /**
  68289. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  68290. */
  68291. populateNinePatchSlicesFromImage: boolean;
  68292. /**
  68293. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  68294. * Beware using this as this will comsume more memory as the image has to be stored twice
  68295. */
  68296. detectPointerOnOpaqueOnly: boolean;
  68297. /**
  68298. * Gets or sets the left value for slicing (9-patch)
  68299. */
  68300. sliceLeft: number;
  68301. /**
  68302. * Gets or sets the right value for slicing (9-patch)
  68303. */
  68304. sliceRight: number;
  68305. /**
  68306. * Gets or sets the top value for slicing (9-patch)
  68307. */
  68308. sliceTop: number;
  68309. /**
  68310. * Gets or sets the bottom value for slicing (9-patch)
  68311. */
  68312. sliceBottom: number;
  68313. /**
  68314. * Gets or sets the left coordinate in the source image
  68315. */
  68316. sourceLeft: number;
  68317. /**
  68318. * Gets or sets the top coordinate in the source image
  68319. */
  68320. sourceTop: number;
  68321. /**
  68322. * Gets or sets the width to capture in the source image
  68323. */
  68324. sourceWidth: number;
  68325. /**
  68326. * Gets or sets the height to capture in the source image
  68327. */
  68328. sourceHeight: number;
  68329. /**
  68330. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  68331. * @see http://doc.babylonjs.com/how_to/gui#image
  68332. */
  68333. autoScale: boolean;
  68334. /** Gets or sets the streching mode used by the image */
  68335. stretch: number;
  68336. /** @hidden */
  68337. _rotate90(n: number): Image;
  68338. /**
  68339. * Gets or sets the internal DOM image used to render the control
  68340. */
  68341. domImage: HTMLImageElement;
  68342. private _onImageLoaded;
  68343. private _extractNinePatchSliceDataFromImage;
  68344. /**
  68345. * Gets or sets image source url
  68346. */
  68347. source: BABYLON.Nullable<string>;
  68348. /**
  68349. * Checks for svg document with icon id present
  68350. */
  68351. private _svgCheck;
  68352. /**
  68353. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  68354. * given external svg file and icon id
  68355. */
  68356. private _getSVGAttribs;
  68357. /**
  68358. * Gets or sets the cell width to use when animation sheet is enabled
  68359. * @see http://doc.babylonjs.com/how_to/gui#image
  68360. */
  68361. cellWidth: number;
  68362. /**
  68363. * Gets or sets the cell height to use when animation sheet is enabled
  68364. * @see http://doc.babylonjs.com/how_to/gui#image
  68365. */
  68366. cellHeight: number;
  68367. /**
  68368. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  68369. * @see http://doc.babylonjs.com/how_to/gui#image
  68370. */
  68371. cellId: number;
  68372. /**
  68373. * Creates a new Image
  68374. * @param name defines the control name
  68375. * @param url defines the image url
  68376. */
  68377. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  68378. /**
  68379. * Tests if a given coordinates belong to the current control
  68380. * @param x defines x coordinate to test
  68381. * @param y defines y coordinate to test
  68382. * @returns true if the coordinates are inside the control
  68383. */
  68384. contains(x: number, y: number): boolean;
  68385. protected _getTypeName(): string;
  68386. /** Force the control to synchronize with its content */
  68387. synchronizeSizeWithContent(): void;
  68388. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68389. private _prepareWorkingCanvasForOpaqueDetection;
  68390. private _drawImage;
  68391. _draw(context: CanvasRenderingContext2D): void;
  68392. private _renderCornerPatch;
  68393. private _renderNinePatch;
  68394. dispose(): void;
  68395. /** STRETCH_NONE */
  68396. static readonly STRETCH_NONE: number;
  68397. /** STRETCH_FILL */
  68398. static readonly STRETCH_FILL: number;
  68399. /** STRETCH_UNIFORM */
  68400. static readonly STRETCH_UNIFORM: number;
  68401. /** STRETCH_EXTEND */
  68402. static readonly STRETCH_EXTEND: number;
  68403. /** NINE_PATCH */
  68404. static readonly STRETCH_NINE_PATCH: number;
  68405. }
  68406. }
  68407. declare module BABYLON.GUI {
  68408. /**
  68409. * Class used to create 2D buttons
  68410. */
  68411. export class Button extends Rectangle {
  68412. name?: string | undefined;
  68413. /**
  68414. * Function called to generate a pointer enter animation
  68415. */
  68416. pointerEnterAnimation: () => void;
  68417. /**
  68418. * Function called to generate a pointer out animation
  68419. */
  68420. pointerOutAnimation: () => void;
  68421. /**
  68422. * Function called to generate a pointer down animation
  68423. */
  68424. pointerDownAnimation: () => void;
  68425. /**
  68426. * Function called to generate a pointer up animation
  68427. */
  68428. pointerUpAnimation: () => void;
  68429. /**
  68430. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  68431. */
  68432. delegatePickingToChildren: boolean;
  68433. private _image;
  68434. /**
  68435. * Returns the image part of the button (if any)
  68436. */
  68437. readonly image: BABYLON.Nullable<Image>;
  68438. private _textBlock;
  68439. /**
  68440. * Returns the image part of the button (if any)
  68441. */
  68442. readonly textBlock: BABYLON.Nullable<TextBlock>;
  68443. /**
  68444. * Creates a new Button
  68445. * @param name defines the name of the button
  68446. */
  68447. constructor(name?: string | undefined);
  68448. protected _getTypeName(): string;
  68449. /** @hidden */
  68450. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68451. /** @hidden */
  68452. _onPointerEnter(target: Control): boolean;
  68453. /** @hidden */
  68454. _onPointerOut(target: Control, force?: boolean): void;
  68455. /** @hidden */
  68456. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68457. /** @hidden */
  68458. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68459. /**
  68460. * Creates a new button made with an image and a text
  68461. * @param name defines the name of the button
  68462. * @param text defines the text of the button
  68463. * @param imageUrl defines the url of the image
  68464. * @returns a new Button
  68465. */
  68466. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  68467. /**
  68468. * Creates a new button made with an image
  68469. * @param name defines the name of the button
  68470. * @param imageUrl defines the url of the image
  68471. * @returns a new Button
  68472. */
  68473. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  68474. /**
  68475. * Creates a new button made with a text
  68476. * @param name defines the name of the button
  68477. * @param text defines the text of the button
  68478. * @returns a new Button
  68479. */
  68480. static CreateSimpleButton(name: string, text: string): Button;
  68481. /**
  68482. * Creates a new button made with an image and a centered text
  68483. * @param name defines the name of the button
  68484. * @param text defines the text of the button
  68485. * @param imageUrl defines the url of the image
  68486. * @returns a new Button
  68487. */
  68488. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  68489. }
  68490. }
  68491. declare module BABYLON.GUI {
  68492. /**
  68493. * Class used to create a 2D stack panel container
  68494. */
  68495. export class StackPanel extends Container {
  68496. name?: string | undefined;
  68497. private _isVertical;
  68498. private _manualWidth;
  68499. private _manualHeight;
  68500. private _doNotTrackManualChanges;
  68501. /**
  68502. * Gets or sets a boolean indicating that layou warnings should be ignored
  68503. */
  68504. ignoreLayoutWarnings: boolean;
  68505. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  68506. isVertical: boolean;
  68507. /**
  68508. * Gets or sets panel width.
  68509. * This value should not be set when in horizontal mode as it will be computed automatically
  68510. */
  68511. width: string | number;
  68512. /**
  68513. * Gets or sets panel height.
  68514. * This value should not be set when in vertical mode as it will be computed automatically
  68515. */
  68516. height: string | number;
  68517. /**
  68518. * Creates a new StackPanel
  68519. * @param name defines control name
  68520. */
  68521. constructor(name?: string | undefined);
  68522. protected _getTypeName(): string;
  68523. /** @hidden */
  68524. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68525. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68526. protected _postMeasure(): void;
  68527. }
  68528. }
  68529. declare module BABYLON.GUI {
  68530. /**
  68531. * Class used to represent a 2D checkbox
  68532. */
  68533. export class Checkbox extends Control {
  68534. name?: string | undefined;
  68535. private _isChecked;
  68536. private _background;
  68537. private _checkSizeRatio;
  68538. private _thickness;
  68539. /** Gets or sets border thickness */
  68540. thickness: number;
  68541. /**
  68542. * BABYLON.Observable raised when isChecked property changes
  68543. */
  68544. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  68545. /** Gets or sets a value indicating the ratio between overall size and check size */
  68546. checkSizeRatio: number;
  68547. /** Gets or sets background color */
  68548. background: string;
  68549. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  68550. isChecked: boolean;
  68551. /**
  68552. * Creates a new CheckBox
  68553. * @param name defines the control name
  68554. */
  68555. constructor(name?: string | undefined);
  68556. protected _getTypeName(): string;
  68557. /** @hidden */
  68558. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68559. /** @hidden */
  68560. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68561. /**
  68562. * Utility function to easily create a checkbox with a header
  68563. * @param title defines the label to use for the header
  68564. * @param onValueChanged defines the callback to call when value changes
  68565. * @returns a StackPanel containing the checkbox and a textBlock
  68566. */
  68567. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  68568. }
  68569. }
  68570. declare module BABYLON.GUI {
  68571. /**
  68572. * Class used to store key control properties
  68573. */
  68574. export class KeyPropertySet {
  68575. /** Width */
  68576. width?: string;
  68577. /** Height */
  68578. height?: string;
  68579. /** Left padding */
  68580. paddingLeft?: string;
  68581. /** Right padding */
  68582. paddingRight?: string;
  68583. /** Top padding */
  68584. paddingTop?: string;
  68585. /** Bottom padding */
  68586. paddingBottom?: string;
  68587. /** Foreground color */
  68588. color?: string;
  68589. /** Background color */
  68590. background?: string;
  68591. }
  68592. /**
  68593. * Class used to create virtual keyboard
  68594. */
  68595. export class VirtualKeyboard extends StackPanel {
  68596. /** BABYLON.Observable raised when a key is pressed */
  68597. onKeyPressObservable: BABYLON.Observable<string>;
  68598. /** Gets or sets default key button width */
  68599. defaultButtonWidth: string;
  68600. /** Gets or sets default key button height */
  68601. defaultButtonHeight: string;
  68602. /** Gets or sets default key button left padding */
  68603. defaultButtonPaddingLeft: string;
  68604. /** Gets or sets default key button right padding */
  68605. defaultButtonPaddingRight: string;
  68606. /** Gets or sets default key button top padding */
  68607. defaultButtonPaddingTop: string;
  68608. /** Gets or sets default key button bottom padding */
  68609. defaultButtonPaddingBottom: string;
  68610. /** Gets or sets default key button foreground color */
  68611. defaultButtonColor: string;
  68612. /** Gets or sets default key button background color */
  68613. defaultButtonBackground: string;
  68614. /** Gets or sets shift button foreground color */
  68615. shiftButtonColor: string;
  68616. /** Gets or sets shift button thickness*/
  68617. selectedShiftThickness: number;
  68618. /** Gets shift key state */
  68619. shiftState: number;
  68620. protected _getTypeName(): string;
  68621. private _createKey;
  68622. /**
  68623. * Adds a new row of keys
  68624. * @param keys defines the list of keys to add
  68625. * @param propertySets defines the associated property sets
  68626. */
  68627. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  68628. /**
  68629. * Set the shift key to a specific state
  68630. * @param shiftState defines the new shift state
  68631. */
  68632. applyShiftState(shiftState: number): void;
  68633. private _currentlyConnectedInputText;
  68634. private _connectedInputTexts;
  68635. private _onKeyPressObserver;
  68636. /** Gets the input text control currently attached to the keyboard */
  68637. readonly connectedInputText: BABYLON.Nullable<InputText>;
  68638. /**
  68639. * Connects the keyboard with an input text control
  68640. *
  68641. * @param input defines the target control
  68642. */
  68643. connect(input: InputText): void;
  68644. /**
  68645. * Disconnects the keyboard from connected InputText controls
  68646. *
  68647. * @param input optionally defines a target control, otherwise all are disconnected
  68648. */
  68649. disconnect(input?: InputText): void;
  68650. private _removeConnectedInputObservables;
  68651. /**
  68652. * Release all resources
  68653. */
  68654. dispose(): void;
  68655. /**
  68656. * Creates a new keyboard using a default layout
  68657. *
  68658. * @param name defines control name
  68659. * @returns a new VirtualKeyboard
  68660. */
  68661. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  68662. }
  68663. }
  68664. declare module BABYLON.GUI {
  68665. /**
  68666. * Class used to create input text control
  68667. */
  68668. export class InputText extends Control implements IFocusableControl {
  68669. name?: string | undefined;
  68670. private _text;
  68671. private _placeholderText;
  68672. private _background;
  68673. private _focusedBackground;
  68674. private _focusedColor;
  68675. private _placeholderColor;
  68676. private _thickness;
  68677. private _margin;
  68678. private _autoStretchWidth;
  68679. private _maxWidth;
  68680. private _isFocused;
  68681. private _blinkTimeout;
  68682. private _blinkIsEven;
  68683. private _cursorOffset;
  68684. private _scrollLeft;
  68685. private _textWidth;
  68686. private _clickedCoordinate;
  68687. private _deadKey;
  68688. private _addKey;
  68689. private _currentKey;
  68690. private _isTextHighlightOn;
  68691. private _textHighlightColor;
  68692. private _highligherOpacity;
  68693. private _highlightedText;
  68694. private _startHighlightIndex;
  68695. private _endHighlightIndex;
  68696. private _cursorIndex;
  68697. private _onFocusSelectAll;
  68698. private _isPointerDown;
  68699. private _onClipboardObserver;
  68700. private _onPointerDblTapObserver;
  68701. /** @hidden */
  68702. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  68703. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  68704. promptMessage: string;
  68705. /** Force disable prompt on mobile device */
  68706. disableMobilePrompt: boolean;
  68707. /** BABYLON.Observable raised when the text changes */
  68708. onTextChangedObservable: BABYLON.Observable<InputText>;
  68709. /** BABYLON.Observable raised just before an entered character is to be added */
  68710. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  68711. /** BABYLON.Observable raised when the control gets the focus */
  68712. onFocusObservable: BABYLON.Observable<InputText>;
  68713. /** BABYLON.Observable raised when the control loses the focus */
  68714. onBlurObservable: BABYLON.Observable<InputText>;
  68715. /**Observable raised when the text is highlighted */
  68716. onTextHighlightObservable: BABYLON.Observable<InputText>;
  68717. /**Observable raised when copy event is triggered */
  68718. onTextCopyObservable: BABYLON.Observable<InputText>;
  68719. /** BABYLON.Observable raised when cut event is triggered */
  68720. onTextCutObservable: BABYLON.Observable<InputText>;
  68721. /** BABYLON.Observable raised when paste event is triggered */
  68722. onTextPasteObservable: BABYLON.Observable<InputText>;
  68723. /** BABYLON.Observable raised when a key event was processed */
  68724. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  68725. /** Gets or sets the maximum width allowed by the control */
  68726. maxWidth: string | number;
  68727. /** Gets the maximum width allowed by the control in pixels */
  68728. readonly maxWidthInPixels: number;
  68729. /** Gets or sets the text highlighter transparency; default: 0.4 */
  68730. highligherOpacity: number;
  68731. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  68732. onFocusSelectAll: boolean;
  68733. /** Gets or sets the text hightlight color */
  68734. textHighlightColor: string;
  68735. /** Gets or sets control margin */
  68736. margin: string;
  68737. /** Gets control margin in pixels */
  68738. readonly marginInPixels: number;
  68739. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  68740. autoStretchWidth: boolean;
  68741. /** Gets or sets border thickness */
  68742. thickness: number;
  68743. /** Gets or sets the background color when focused */
  68744. focusedBackground: string;
  68745. /** Gets or sets the background color when focused */
  68746. focusedColor: string;
  68747. /** Gets or sets the background color */
  68748. background: string;
  68749. /** Gets or sets the placeholder color */
  68750. placeholderColor: string;
  68751. /** Gets or sets the text displayed when the control is empty */
  68752. placeholderText: string;
  68753. /** Gets or sets the dead key flag */
  68754. deadKey: boolean;
  68755. /** Gets or sets the highlight text */
  68756. highlightedText: string;
  68757. /** Gets or sets if the current key should be added */
  68758. addKey: boolean;
  68759. /** Gets or sets the value of the current key being entered */
  68760. currentKey: string;
  68761. /** Gets or sets the text displayed in the control */
  68762. text: string;
  68763. /** Gets or sets control width */
  68764. width: string | number;
  68765. /**
  68766. * Creates a new InputText
  68767. * @param name defines the control name
  68768. * @param text defines the text of the control
  68769. */
  68770. constructor(name?: string | undefined, text?: string);
  68771. /** @hidden */
  68772. onBlur(): void;
  68773. /** @hidden */
  68774. onFocus(): void;
  68775. protected _getTypeName(): string;
  68776. /**
  68777. * Function called to get the list of controls that should not steal the focus from this control
  68778. * @returns an array of controls
  68779. */
  68780. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  68781. /** @hidden */
  68782. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  68783. /** @hidden */
  68784. private _updateValueFromCursorIndex;
  68785. /** @hidden */
  68786. private _processDblClick;
  68787. /** @hidden */
  68788. private _selectAllText;
  68789. /**
  68790. * Handles the keyboard event
  68791. * @param evt Defines the KeyboardEvent
  68792. */
  68793. processKeyboard(evt: KeyboardEvent): void;
  68794. /** @hidden */
  68795. private _onCopyText;
  68796. /** @hidden */
  68797. private _onCutText;
  68798. /** @hidden */
  68799. private _onPasteText;
  68800. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68801. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68802. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68803. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68804. protected _beforeRenderText(text: string): string;
  68805. dispose(): void;
  68806. }
  68807. }
  68808. declare module BABYLON.GUI {
  68809. /**
  68810. * Class used to create a 2D grid container
  68811. */
  68812. export class Grid extends Container {
  68813. name?: string | undefined;
  68814. private _rowDefinitions;
  68815. private _columnDefinitions;
  68816. private _cells;
  68817. private _childControls;
  68818. /**
  68819. * Gets the number of columns
  68820. */
  68821. readonly columnCount: number;
  68822. /**
  68823. * Gets the number of rows
  68824. */
  68825. readonly rowCount: number;
  68826. /** Gets the list of children */
  68827. readonly children: Control[];
  68828. /** Gets the list of cells (e.g. the containers) */
  68829. readonly cells: {
  68830. [key: string]: Container;
  68831. };
  68832. /**
  68833. * Gets the definition of a specific row
  68834. * @param index defines the index of the row
  68835. * @returns the row definition
  68836. */
  68837. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  68838. /**
  68839. * Gets the definition of a specific column
  68840. * @param index defines the index of the column
  68841. * @returns the column definition
  68842. */
  68843. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  68844. /**
  68845. * Adds a new row to the grid
  68846. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  68847. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  68848. * @returns the current grid
  68849. */
  68850. addRowDefinition(height: number, isPixel?: boolean): Grid;
  68851. /**
  68852. * Adds a new column to the grid
  68853. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  68854. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  68855. * @returns the current grid
  68856. */
  68857. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  68858. /**
  68859. * Update a row definition
  68860. * @param index defines the index of the row to update
  68861. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  68862. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  68863. * @returns the current grid
  68864. */
  68865. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  68866. /**
  68867. * Update a column definition
  68868. * @param index defines the index of the column to update
  68869. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  68870. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  68871. * @returns the current grid
  68872. */
  68873. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  68874. /**
  68875. * Gets the list of children stored in a specific cell
  68876. * @param row defines the row to check
  68877. * @param column defines the column to check
  68878. * @returns the list of controls
  68879. */
  68880. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  68881. /**
  68882. * Gets a string representing the child cell info (row x column)
  68883. * @param child defines the control to get info from
  68884. * @returns a string containing the child cell info (row x column)
  68885. */
  68886. getChildCellInfo(child: Control): string;
  68887. private _removeCell;
  68888. private _offsetCell;
  68889. /**
  68890. * Remove a column definition at specified index
  68891. * @param index defines the index of the column to remove
  68892. * @returns the current grid
  68893. */
  68894. removeColumnDefinition(index: number): Grid;
  68895. /**
  68896. * Remove a row definition at specified index
  68897. * @param index defines the index of the row to remove
  68898. * @returns the current grid
  68899. */
  68900. removeRowDefinition(index: number): Grid;
  68901. /**
  68902. * Adds a new control to the current grid
  68903. * @param control defines the control to add
  68904. * @param row defines the row where to add the control (0 by default)
  68905. * @param column defines the column where to add the control (0 by default)
  68906. * @returns the current grid
  68907. */
  68908. addControl(control: Control, row?: number, column?: number): Grid;
  68909. /**
  68910. * Removes a control from the current container
  68911. * @param control defines the control to remove
  68912. * @returns the current container
  68913. */
  68914. removeControl(control: Control): Container;
  68915. /**
  68916. * Creates a new Grid
  68917. * @param name defines control name
  68918. */
  68919. constructor(name?: string | undefined);
  68920. protected _getTypeName(): string;
  68921. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  68922. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68923. _flagDescendantsAsMatrixDirty(): void;
  68924. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  68925. /** Releases associated resources */
  68926. dispose(): void;
  68927. }
  68928. }
  68929. declare module BABYLON.GUI {
  68930. /** Class used to create color pickers */
  68931. export class ColorPicker extends Control {
  68932. name?: string | undefined;
  68933. private static _Epsilon;
  68934. private _colorWheelCanvas;
  68935. private _value;
  68936. private _tmpColor;
  68937. private _pointerStartedOnSquare;
  68938. private _pointerStartedOnWheel;
  68939. private _squareLeft;
  68940. private _squareTop;
  68941. private _squareSize;
  68942. private _h;
  68943. private _s;
  68944. private _v;
  68945. private _lastPointerDownID;
  68946. /**
  68947. * BABYLON.Observable raised when the value changes
  68948. */
  68949. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  68950. /** Gets or sets the color of the color picker */
  68951. value: BABYLON.Color3;
  68952. /**
  68953. * Gets or sets control width
  68954. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68955. */
  68956. width: string | number;
  68957. /**
  68958. * Gets or sets control height
  68959. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68960. */
  68961. /** Gets or sets control height */
  68962. height: string | number;
  68963. /** Gets or sets control size */
  68964. size: string | number;
  68965. /**
  68966. * Creates a new ColorPicker
  68967. * @param name defines the control name
  68968. */
  68969. constructor(name?: string | undefined);
  68970. protected _getTypeName(): string;
  68971. /** @hidden */
  68972. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68973. private _updateSquareProps;
  68974. private _drawGradientSquare;
  68975. private _drawCircle;
  68976. private _createColorWheelCanvas;
  68977. /** @hidden */
  68978. _draw(context: CanvasRenderingContext2D): void;
  68979. private _pointerIsDown;
  68980. private _updateValueFromPointer;
  68981. private _isPointOnSquare;
  68982. private _isPointOnWheel;
  68983. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68984. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68985. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68986. /**
  68987. * This function expands the color picker by creating a color picker dialog with manual
  68988. * color value input and the ability to save colors into an array to be used later in
  68989. * subsequent launches of the dialogue.
  68990. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  68991. * @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.
  68992. * @returns picked color as a hex string and the saved colors array as hex strings.
  68993. */
  68994. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  68995. pickerWidth?: string;
  68996. pickerHeight?: string;
  68997. headerHeight?: string;
  68998. lastColor?: string;
  68999. swatchLimit?: number;
  69000. numSwatchesPerLine?: number;
  69001. savedColors?: Array<string>;
  69002. }): Promise<{
  69003. savedColors?: string[];
  69004. pickedColor: string;
  69005. }>;
  69006. }
  69007. }
  69008. declare module BABYLON.GUI {
  69009. /** Class used to create 2D ellipse containers */
  69010. export class Ellipse extends Container {
  69011. name?: string | undefined;
  69012. private _thickness;
  69013. /** Gets or sets border thickness */
  69014. thickness: number;
  69015. /**
  69016. * Creates a new Ellipse
  69017. * @param name defines the control name
  69018. */
  69019. constructor(name?: string | undefined);
  69020. protected _getTypeName(): string;
  69021. protected _localDraw(context: CanvasRenderingContext2D): void;
  69022. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69023. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  69024. }
  69025. }
  69026. declare module BABYLON.GUI {
  69027. /**
  69028. * Class used to create a password control
  69029. */
  69030. export class InputPassword extends InputText {
  69031. protected _beforeRenderText(text: string): string;
  69032. }
  69033. }
  69034. declare module BABYLON.GUI {
  69035. /** Class used to render 2D lines */
  69036. export class Line extends Control {
  69037. name?: string | undefined;
  69038. private _lineWidth;
  69039. private _x1;
  69040. private _y1;
  69041. private _x2;
  69042. private _y2;
  69043. private _dash;
  69044. private _connectedControl;
  69045. private _connectedControlDirtyObserver;
  69046. /** Gets or sets the dash pattern */
  69047. dash: Array<number>;
  69048. /** Gets or sets the control connected with the line end */
  69049. connectedControl: Control;
  69050. /** Gets or sets start coordinates on X axis */
  69051. x1: string | number;
  69052. /** Gets or sets start coordinates on Y axis */
  69053. y1: string | number;
  69054. /** Gets or sets end coordinates on X axis */
  69055. x2: string | number;
  69056. /** Gets or sets end coordinates on Y axis */
  69057. y2: string | number;
  69058. /** Gets or sets line width */
  69059. lineWidth: number;
  69060. /** Gets or sets horizontal alignment */
  69061. horizontalAlignment: number;
  69062. /** Gets or sets vertical alignment */
  69063. verticalAlignment: number;
  69064. private readonly _effectiveX2;
  69065. private readonly _effectiveY2;
  69066. /**
  69067. * Creates a new Line
  69068. * @param name defines the control name
  69069. */
  69070. constructor(name?: string | undefined);
  69071. protected _getTypeName(): string;
  69072. _draw(context: CanvasRenderingContext2D): void;
  69073. _measure(): void;
  69074. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69075. /**
  69076. * Move one end of the line given 3D cartesian coordinates.
  69077. * @param position Targeted world position
  69078. * @param scene BABYLON.Scene
  69079. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69080. */
  69081. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  69082. /**
  69083. * Move one end of the line to a position in screen absolute space.
  69084. * @param projectedPosition Position in screen absolute space (X, Y)
  69085. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69086. */
  69087. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  69088. }
  69089. }
  69090. declare module BABYLON.GUI {
  69091. /**
  69092. * Class used to store a point for a MultiLine object.
  69093. * The point can be pure 2D coordinates, a mesh or a control
  69094. */
  69095. export class MultiLinePoint {
  69096. private _multiLine;
  69097. private _x;
  69098. private _y;
  69099. private _control;
  69100. private _mesh;
  69101. private _controlObserver;
  69102. private _meshObserver;
  69103. /** @hidden */
  69104. _point: BABYLON.Vector2;
  69105. /**
  69106. * Creates a new MultiLinePoint
  69107. * @param multiLine defines the source MultiLine object
  69108. */
  69109. constructor(multiLine: MultiLine);
  69110. /** Gets or sets x coordinate */
  69111. x: string | number;
  69112. /** Gets or sets y coordinate */
  69113. y: string | number;
  69114. /** Gets or sets the control associated with this point */
  69115. control: BABYLON.Nullable<Control>;
  69116. /** Gets or sets the mesh associated with this point */
  69117. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  69118. /** Resets links */
  69119. resetLinks(): void;
  69120. /**
  69121. * Gets a translation vector
  69122. * @returns the translation vector
  69123. */
  69124. translate(): BABYLON.Vector2;
  69125. private _translatePoint;
  69126. /** Release associated resources */
  69127. dispose(): void;
  69128. }
  69129. }
  69130. declare module BABYLON.GUI {
  69131. /**
  69132. * Class used to create multi line control
  69133. */
  69134. export class MultiLine extends Control {
  69135. name?: string | undefined;
  69136. private _lineWidth;
  69137. private _dash;
  69138. private _points;
  69139. private _minX;
  69140. private _minY;
  69141. private _maxX;
  69142. private _maxY;
  69143. /**
  69144. * Creates a new MultiLine
  69145. * @param name defines the control name
  69146. */
  69147. constructor(name?: string | undefined);
  69148. /** Gets or sets dash pattern */
  69149. dash: Array<number>;
  69150. /**
  69151. * Gets point stored at specified index
  69152. * @param index defines the index to look for
  69153. * @returns the requested point if found
  69154. */
  69155. getAt(index: number): MultiLinePoint;
  69156. /** Function called when a point is updated */
  69157. onPointUpdate: () => void;
  69158. /**
  69159. * Adds new points to the point collection
  69160. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  69161. * @returns the list of created MultiLinePoint
  69162. */
  69163. add(...items: (AbstractMesh | Control | {
  69164. x: string | number;
  69165. y: string | number;
  69166. })[]): MultiLinePoint[];
  69167. /**
  69168. * Adds a new point to the point collection
  69169. * @param item defines the item (mesh, control or 2d coordiantes) to add
  69170. * @returns the created MultiLinePoint
  69171. */
  69172. push(item?: (AbstractMesh | Control | {
  69173. x: string | number;
  69174. y: string | number;
  69175. })): MultiLinePoint;
  69176. /**
  69177. * Remove a specific value or point from the active point collection
  69178. * @param value defines the value or point to remove
  69179. */
  69180. remove(value: number | MultiLinePoint): void;
  69181. /**
  69182. * Resets this object to initial state (no point)
  69183. */
  69184. reset(): void;
  69185. /**
  69186. * Resets all links
  69187. */
  69188. resetLinks(): void;
  69189. /** Gets or sets line width */
  69190. lineWidth: number;
  69191. horizontalAlignment: number;
  69192. verticalAlignment: number;
  69193. protected _getTypeName(): string;
  69194. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69195. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69196. _measure(): void;
  69197. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69198. dispose(): void;
  69199. }
  69200. }
  69201. declare module BABYLON.GUI {
  69202. /**
  69203. * Class used to create radio button controls
  69204. */
  69205. export class RadioButton extends Control {
  69206. name?: string | undefined;
  69207. private _isChecked;
  69208. private _background;
  69209. private _checkSizeRatio;
  69210. private _thickness;
  69211. /** Gets or sets border thickness */
  69212. thickness: number;
  69213. /** Gets or sets group name */
  69214. group: string;
  69215. /** BABYLON.Observable raised when isChecked is changed */
  69216. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  69217. /** Gets or sets a value indicating the ratio between overall size and check size */
  69218. checkSizeRatio: number;
  69219. /** Gets or sets background color */
  69220. background: string;
  69221. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  69222. isChecked: boolean;
  69223. /**
  69224. * Creates a new RadioButton
  69225. * @param name defines the control name
  69226. */
  69227. constructor(name?: string | undefined);
  69228. protected _getTypeName(): string;
  69229. _draw(context: CanvasRenderingContext2D): void;
  69230. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69231. /**
  69232. * Utility function to easily create a radio button with a header
  69233. * @param title defines the label to use for the header
  69234. * @param group defines the group to use for the radio button
  69235. * @param isChecked defines the initial state of the radio button
  69236. * @param onValueChanged defines the callback to call when value changes
  69237. * @returns a StackPanel containing the radio button and a textBlock
  69238. */
  69239. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  69240. }
  69241. }
  69242. declare module BABYLON.GUI {
  69243. /**
  69244. * Class used to create slider controls
  69245. */
  69246. export class BaseSlider extends Control {
  69247. name?: string | undefined;
  69248. protected _thumbWidth: ValueAndUnit;
  69249. private _minimum;
  69250. private _maximum;
  69251. private _value;
  69252. private _isVertical;
  69253. protected _barOffset: ValueAndUnit;
  69254. private _isThumbClamped;
  69255. protected _displayThumb: boolean;
  69256. private _step;
  69257. private _lastPointerDownID;
  69258. protected _effectiveBarOffset: number;
  69259. protected _renderLeft: number;
  69260. protected _renderTop: number;
  69261. protected _renderWidth: number;
  69262. protected _renderHeight: number;
  69263. protected _backgroundBoxLength: number;
  69264. protected _backgroundBoxThickness: number;
  69265. protected _effectiveThumbThickness: number;
  69266. /** BABYLON.Observable raised when the sldier value changes */
  69267. onValueChangedObservable: BABYLON.Observable<number>;
  69268. /** Gets or sets a boolean indicating if the thumb must be rendered */
  69269. displayThumb: boolean;
  69270. /** Gets or sets a step to apply to values (0 by default) */
  69271. step: number;
  69272. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  69273. barOffset: string | number;
  69274. /** Gets main bar offset in pixels*/
  69275. readonly barOffsetInPixels: number;
  69276. /** Gets or sets thumb width */
  69277. thumbWidth: string | number;
  69278. /** Gets thumb width in pixels */
  69279. readonly thumbWidthInPixels: number;
  69280. /** Gets or sets minimum value */
  69281. minimum: number;
  69282. /** Gets or sets maximum value */
  69283. maximum: number;
  69284. /** Gets or sets current value */
  69285. value: number;
  69286. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  69287. isVertical: boolean;
  69288. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  69289. isThumbClamped: boolean;
  69290. /**
  69291. * Creates a new BaseSlider
  69292. * @param name defines the control name
  69293. */
  69294. constructor(name?: string | undefined);
  69295. protected _getTypeName(): string;
  69296. protected _getThumbPosition(): number;
  69297. protected _getThumbThickness(type: string): number;
  69298. protected _prepareRenderingData(type: string): void;
  69299. private _pointerIsDown;
  69300. /** @hidden */
  69301. protected _updateValueFromPointer(x: number, y: number): void;
  69302. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69303. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  69304. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69305. }
  69306. }
  69307. declare module BABYLON.GUI {
  69308. /**
  69309. * Class used to create slider controls
  69310. */
  69311. export class Slider extends BaseSlider {
  69312. name?: string | undefined;
  69313. private _background;
  69314. private _borderColor;
  69315. private _isThumbCircle;
  69316. protected _displayValueBar: boolean;
  69317. /** Gets or sets a boolean indicating if the value bar must be rendered */
  69318. displayValueBar: boolean;
  69319. /** Gets or sets border color */
  69320. borderColor: string;
  69321. /** Gets or sets background color */
  69322. background: string;
  69323. /** Gets or sets a boolean indicating if the thumb should be round or square */
  69324. isThumbCircle: boolean;
  69325. /**
  69326. * Creates a new Slider
  69327. * @param name defines the control name
  69328. */
  69329. constructor(name?: string | undefined);
  69330. protected _getTypeName(): string;
  69331. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69332. }
  69333. }
  69334. declare module BABYLON.GUI {
  69335. /** Class used to create a RadioGroup
  69336. * which contains groups of radio buttons
  69337. */
  69338. export class SelectorGroup {
  69339. /** name of SelectorGroup */
  69340. name: string;
  69341. private _groupPanel;
  69342. private _selectors;
  69343. private _groupHeader;
  69344. /**
  69345. * Creates a new SelectorGroup
  69346. * @param name of group, used as a group heading
  69347. */
  69348. constructor(
  69349. /** name of SelectorGroup */
  69350. name: string);
  69351. /** Gets the groupPanel of the SelectorGroup */
  69352. readonly groupPanel: StackPanel;
  69353. /** Gets the selectors array */
  69354. readonly selectors: StackPanel[];
  69355. /** Gets and sets the group header */
  69356. header: string;
  69357. /** @hidden */
  69358. private _addGroupHeader;
  69359. /** @hidden*/
  69360. _getSelector(selectorNb: number): StackPanel | undefined;
  69361. /** Removes the selector at the given position
  69362. * @param selectorNb the position of the selector within the group
  69363. */
  69364. removeSelector(selectorNb: number): void;
  69365. }
  69366. /** Class used to create a CheckboxGroup
  69367. * which contains groups of checkbox buttons
  69368. */
  69369. export class CheckboxGroup extends SelectorGroup {
  69370. /** Adds a checkbox as a control
  69371. * @param text is the label for the selector
  69372. * @param func is the function called when the Selector is checked
  69373. * @param checked is true when Selector is checked
  69374. */
  69375. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  69376. /** @hidden */
  69377. _setSelectorLabel(selectorNb: number, label: string): void;
  69378. /** @hidden */
  69379. _setSelectorLabelColor(selectorNb: number, color: string): void;
  69380. /** @hidden */
  69381. _setSelectorButtonColor(selectorNb: number, color: string): void;
  69382. /** @hidden */
  69383. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  69384. }
  69385. /** Class used to create a RadioGroup
  69386. * which contains groups of radio buttons
  69387. */
  69388. export class RadioGroup extends SelectorGroup {
  69389. private _selectNb;
  69390. /** Adds a radio button as a control
  69391. * @param label is the label for the selector
  69392. * @param func is the function called when the Selector is checked
  69393. * @param checked is true when Selector is checked
  69394. */
  69395. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  69396. /** @hidden */
  69397. _setSelectorLabel(selectorNb: number, label: string): void;
  69398. /** @hidden */
  69399. _setSelectorLabelColor(selectorNb: number, color: string): void;
  69400. /** @hidden */
  69401. _setSelectorButtonColor(selectorNb: number, color: string): void;
  69402. /** @hidden */
  69403. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  69404. }
  69405. /** Class used to create a SliderGroup
  69406. * which contains groups of slider buttons
  69407. */
  69408. export class SliderGroup extends SelectorGroup {
  69409. /**
  69410. * Adds a slider to the SelectorGroup
  69411. * @param label is the label for the SliderBar
  69412. * @param func is the function called when the Slider moves
  69413. * @param unit is a string describing the units used, eg degrees or metres
  69414. * @param min is the minimum value for the Slider
  69415. * @param max is the maximum value for the Slider
  69416. * @param value is the start value for the Slider between min and max
  69417. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  69418. */
  69419. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  69420. /** @hidden */
  69421. _setSelectorLabel(selectorNb: number, label: string): void;
  69422. /** @hidden */
  69423. _setSelectorLabelColor(selectorNb: number, color: string): void;
  69424. /** @hidden */
  69425. _setSelectorButtonColor(selectorNb: number, color: string): void;
  69426. /** @hidden */
  69427. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  69428. }
  69429. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  69430. * @see http://doc.babylonjs.com/how_to/selector
  69431. */
  69432. export class SelectionPanel extends Rectangle {
  69433. /** name of SelectionPanel */
  69434. name: string;
  69435. /** an array of SelectionGroups */
  69436. groups: SelectorGroup[];
  69437. private _panel;
  69438. private _buttonColor;
  69439. private _buttonBackground;
  69440. private _headerColor;
  69441. private _barColor;
  69442. private _barHeight;
  69443. private _spacerHeight;
  69444. private _labelColor;
  69445. private _groups;
  69446. private _bars;
  69447. /**
  69448. * Creates a new SelectionPanel
  69449. * @param name of SelectionPanel
  69450. * @param groups is an array of SelectionGroups
  69451. */
  69452. constructor(
  69453. /** name of SelectionPanel */
  69454. name: string,
  69455. /** an array of SelectionGroups */
  69456. groups?: SelectorGroup[]);
  69457. protected _getTypeName(): string;
  69458. /** Gets or sets the headerColor */
  69459. headerColor: string;
  69460. private _setHeaderColor;
  69461. /** Gets or sets the button color */
  69462. buttonColor: string;
  69463. private _setbuttonColor;
  69464. /** Gets or sets the label color */
  69465. labelColor: string;
  69466. private _setLabelColor;
  69467. /** Gets or sets the button background */
  69468. buttonBackground: string;
  69469. private _setButtonBackground;
  69470. /** Gets or sets the color of separator bar */
  69471. barColor: string;
  69472. private _setBarColor;
  69473. /** Gets or sets the height of separator bar */
  69474. barHeight: string;
  69475. private _setBarHeight;
  69476. /** Gets or sets the height of spacers*/
  69477. spacerHeight: string;
  69478. private _setSpacerHeight;
  69479. /** Adds a bar between groups */
  69480. private _addSpacer;
  69481. /** Add a group to the selection panel
  69482. * @param group is the selector group to add
  69483. */
  69484. addGroup(group: SelectorGroup): void;
  69485. /** Remove the group from the given position
  69486. * @param groupNb is the position of the group in the list
  69487. */
  69488. removeGroup(groupNb: number): void;
  69489. /** Change a group header label
  69490. * @param label is the new group header label
  69491. * @param groupNb is the number of the group to relabel
  69492. * */
  69493. setHeaderName(label: string, groupNb: number): void;
  69494. /** Change selector label to the one given
  69495. * @param label is the new selector label
  69496. * @param groupNb is the number of the groupcontaining the selector
  69497. * @param selectorNb is the number of the selector within a group to relabel
  69498. * */
  69499. relabel(label: string, groupNb: number, selectorNb: number): void;
  69500. /** For a given group position remove the selector at the given position
  69501. * @param groupNb is the number of the group to remove the selector from
  69502. * @param selectorNb is the number of the selector within the group
  69503. */
  69504. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  69505. /** For a given group position of correct type add a checkbox button
  69506. * @param groupNb is the number of the group to remove the selector from
  69507. * @param label is the label for the selector
  69508. * @param func is the function called when the Selector is checked
  69509. * @param checked is true when Selector is checked
  69510. */
  69511. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  69512. /** For a given group position of correct type add a radio button
  69513. * @param groupNb is the number of the group to remove the selector from
  69514. * @param label is the label for the selector
  69515. * @param func is the function called when the Selector is checked
  69516. * @param checked is true when Selector is checked
  69517. */
  69518. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  69519. /**
  69520. * For a given slider group add a slider
  69521. * @param groupNb is the number of the group to add the slider to
  69522. * @param label is the label for the Slider
  69523. * @param func is the function called when the Slider moves
  69524. * @param unit is a string describing the units used, eg degrees or metres
  69525. * @param min is the minimum value for the Slider
  69526. * @param max is the maximum value for the Slider
  69527. * @param value is the start value for the Slider between min and max
  69528. * @param onVal is the function used to format the value displayed, eg radians to degrees
  69529. */
  69530. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  69531. }
  69532. }
  69533. declare module BABYLON.GUI {
  69534. /**
  69535. * Class used to hold a the container for ScrollViewer
  69536. * @hidden
  69537. */
  69538. export class _ScrollViewerWindow extends Container {
  69539. parentClientWidth: number;
  69540. parentClientHeight: number;
  69541. /**
  69542. * Creates a new ScrollViewerWindow
  69543. * @param name of ScrollViewerWindow
  69544. */
  69545. constructor(name?: string);
  69546. protected _getTypeName(): string;
  69547. /** @hidden */
  69548. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69549. protected _postMeasure(): void;
  69550. }
  69551. }
  69552. declare module BABYLON.GUI {
  69553. /**
  69554. * Class used to create slider controls
  69555. */
  69556. export class ScrollBar extends BaseSlider {
  69557. name?: string | undefined;
  69558. private _background;
  69559. private _borderColor;
  69560. private _tempMeasure;
  69561. /** Gets or sets border color */
  69562. borderColor: string;
  69563. /** Gets or sets background color */
  69564. background: string;
  69565. /**
  69566. * Creates a new Slider
  69567. * @param name defines the control name
  69568. */
  69569. constructor(name?: string | undefined);
  69570. protected _getTypeName(): string;
  69571. protected _getThumbThickness(): number;
  69572. _draw(context: CanvasRenderingContext2D): void;
  69573. private _first;
  69574. private _originX;
  69575. private _originY;
  69576. /** @hidden */
  69577. protected _updateValueFromPointer(x: number, y: number): void;
  69578. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69579. }
  69580. }
  69581. declare module BABYLON.GUI {
  69582. /**
  69583. * Class used to create slider controls
  69584. */
  69585. export class ImageScrollBar extends BaseSlider {
  69586. name?: string | undefined;
  69587. private _backgroundBaseImage;
  69588. private _backgroundImage;
  69589. private _thumbImage;
  69590. private _thumbBaseImage;
  69591. private _thumbLength;
  69592. private _thumbHeight;
  69593. private _barImageHeight;
  69594. private _tempMeasure;
  69595. /**
  69596. * Gets or sets the image used to render the background for horizontal bar
  69597. */
  69598. backgroundImage: Image;
  69599. /**
  69600. * Gets or sets the image used to render the thumb
  69601. */
  69602. thumbImage: Image;
  69603. /**
  69604. * Gets or sets the length of the thumb
  69605. */
  69606. thumbLength: number;
  69607. /**
  69608. * Gets or sets the height of the thumb
  69609. */
  69610. thumbHeight: number;
  69611. /**
  69612. * Gets or sets the height of the bar image
  69613. */
  69614. barImageHeight: number;
  69615. /**
  69616. * Creates a new ImageScrollBar
  69617. * @param name defines the control name
  69618. */
  69619. constructor(name?: string | undefined);
  69620. protected _getTypeName(): string;
  69621. protected _getThumbThickness(): number;
  69622. _draw(context: CanvasRenderingContext2D): void;
  69623. private _first;
  69624. private _originX;
  69625. private _originY;
  69626. /** @hidden */
  69627. protected _updateValueFromPointer(x: number, y: number): void;
  69628. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69629. }
  69630. }
  69631. declare module BABYLON.GUI {
  69632. /**
  69633. * Class used to hold a viewer window and sliders in a grid
  69634. */
  69635. export class ScrollViewer extends Rectangle {
  69636. private _grid;
  69637. private _horizontalBarSpace;
  69638. private _verticalBarSpace;
  69639. private _dragSpace;
  69640. private _horizontalBar;
  69641. private _verticalBar;
  69642. private _barColor;
  69643. private _barBackground;
  69644. private _barImage;
  69645. private _barBackgroundImage;
  69646. private _barSize;
  69647. private _endLeft;
  69648. private _endTop;
  69649. private _window;
  69650. private _pointerIsOver;
  69651. private _wheelPrecision;
  69652. private _onPointerObserver;
  69653. private _clientWidth;
  69654. private _clientHeight;
  69655. private _useImageBar;
  69656. private _thumbLength;
  69657. private _thumbHeight;
  69658. private _barImageHeight;
  69659. /**
  69660. * Gets the horizontal scrollbar
  69661. */
  69662. readonly horizontalBar: ScrollBar | ImageScrollBar;
  69663. /**
  69664. * Gets the vertical scrollbar
  69665. */
  69666. readonly verticalBar: ScrollBar | ImageScrollBar;
  69667. /**
  69668. * Adds a new control to the current container
  69669. * @param control defines the control to add
  69670. * @returns the current container
  69671. */
  69672. addControl(control: BABYLON.Nullable<Control>): Container;
  69673. /**
  69674. * Removes a control from the current container
  69675. * @param control defines the control to remove
  69676. * @returns the current container
  69677. */
  69678. removeControl(control: Control): Container;
  69679. /** Gets the list of children */
  69680. readonly children: Control[];
  69681. _flagDescendantsAsMatrixDirty(): void;
  69682. /**
  69683. * Creates a new ScrollViewer
  69684. * @param name of ScrollViewer
  69685. */
  69686. constructor(name?: string, isImageBased?: boolean);
  69687. /** Reset the scroll viewer window to initial size */
  69688. resetWindow(): void;
  69689. protected _getTypeName(): string;
  69690. private _buildClientSizes;
  69691. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69692. protected _postMeasure(): void;
  69693. /**
  69694. * Gets or sets the mouse wheel precision
  69695. * from 0 to 1 with a default value of 0.05
  69696. * */
  69697. wheelPrecision: number;
  69698. /** Gets or sets the scroll bar container background color */
  69699. scrollBackground: string;
  69700. /** Gets or sets the bar color */
  69701. barColor: string;
  69702. /** Gets or sets the bar image */
  69703. thumbImage: Image;
  69704. /** Gets or sets the size of the bar */
  69705. barSize: number;
  69706. /** Gets or sets the length of the thumb */
  69707. thumbLength: number;
  69708. /** Gets or sets the height of the thumb */
  69709. thumbHeight: number;
  69710. /** Gets or sets the height of the bar image */
  69711. barImageHeight: number;
  69712. /** Gets or sets the bar background */
  69713. barBackground: string;
  69714. /** Gets or sets the bar background image */
  69715. barImage: Image;
  69716. /** @hidden */
  69717. private _updateScroller;
  69718. _link(host: AdvancedDynamicTexture): void;
  69719. /** @hidden */
  69720. private _addBar;
  69721. /** @hidden */
  69722. private _attachWheel;
  69723. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  69724. /** Releases associated resources */
  69725. dispose(): void;
  69726. }
  69727. }
  69728. declare module BABYLON.GUI {
  69729. /** Class used to render a grid */
  69730. export class DisplayGrid extends Control {
  69731. name?: string | undefined;
  69732. private _cellWidth;
  69733. private _cellHeight;
  69734. private _minorLineTickness;
  69735. private _minorLineColor;
  69736. private _majorLineTickness;
  69737. private _majorLineColor;
  69738. private _majorLineFrequency;
  69739. private _background;
  69740. private _displayMajorLines;
  69741. private _displayMinorLines;
  69742. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  69743. displayMinorLines: boolean;
  69744. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  69745. displayMajorLines: boolean;
  69746. /** Gets or sets background color (Black by default) */
  69747. background: string;
  69748. /** Gets or sets the width of each cell (20 by default) */
  69749. cellWidth: number;
  69750. /** Gets or sets the height of each cell (20 by default) */
  69751. cellHeight: number;
  69752. /** Gets or sets the tickness of minor lines (1 by default) */
  69753. minorLineTickness: number;
  69754. /** Gets or sets the color of minor lines (DarkGray by default) */
  69755. minorLineColor: string;
  69756. /** Gets or sets the tickness of major lines (2 by default) */
  69757. majorLineTickness: number;
  69758. /** Gets or sets the color of major lines (White by default) */
  69759. majorLineColor: string;
  69760. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  69761. majorLineFrequency: number;
  69762. /**
  69763. * Creates a new GridDisplayRectangle
  69764. * @param name defines the control name
  69765. */
  69766. constructor(name?: string | undefined);
  69767. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69768. protected _getTypeName(): string;
  69769. }
  69770. }
  69771. declare module BABYLON.GUI {
  69772. /**
  69773. * Class used to create slider controls based on images
  69774. */
  69775. export class ImageBasedSlider extends BaseSlider {
  69776. name?: string | undefined;
  69777. private _backgroundImage;
  69778. private _thumbImage;
  69779. private _valueBarImage;
  69780. private _tempMeasure;
  69781. displayThumb: boolean;
  69782. /**
  69783. * Gets or sets the image used to render the background
  69784. */
  69785. backgroundImage: Image;
  69786. /**
  69787. * Gets or sets the image used to render the value bar
  69788. */
  69789. valueBarImage: Image;
  69790. /**
  69791. * Gets or sets the image used to render the thumb
  69792. */
  69793. thumbImage: Image;
  69794. /**
  69795. * Creates a new ImageBasedSlider
  69796. * @param name defines the control name
  69797. */
  69798. constructor(name?: string | undefined);
  69799. protected _getTypeName(): string;
  69800. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69801. }
  69802. }
  69803. declare module BABYLON.GUI {
  69804. /**
  69805. * Forcing an export so that this code will execute
  69806. * @hidden
  69807. */
  69808. const name = "Statics";
  69809. }
  69810. declare module BABYLON.GUI {
  69811. /**
  69812. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  69813. */
  69814. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  69815. /**
  69816. * Define the instrumented AdvancedDynamicTexture.
  69817. */
  69818. texture: AdvancedDynamicTexture;
  69819. private _captureRenderTime;
  69820. private _renderTime;
  69821. private _captureLayoutTime;
  69822. private _layoutTime;
  69823. private _onBeginRenderObserver;
  69824. private _onEndRenderObserver;
  69825. private _onBeginLayoutObserver;
  69826. private _onEndLayoutObserver;
  69827. /**
  69828. * Gets the perf counter used to capture render time
  69829. */
  69830. readonly renderTimeCounter: BABYLON.PerfCounter;
  69831. /**
  69832. * Gets the perf counter used to capture layout time
  69833. */
  69834. readonly layoutTimeCounter: BABYLON.PerfCounter;
  69835. /**
  69836. * Enable or disable the render time capture
  69837. */
  69838. captureRenderTime: boolean;
  69839. /**
  69840. * Enable or disable the layout time capture
  69841. */
  69842. captureLayoutTime: boolean;
  69843. /**
  69844. * Instantiates a new advanced dynamic texture instrumentation.
  69845. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  69846. * @param texture Defines the AdvancedDynamicTexture to instrument
  69847. */
  69848. constructor(
  69849. /**
  69850. * Define the instrumented AdvancedDynamicTexture.
  69851. */
  69852. texture: AdvancedDynamicTexture);
  69853. /**
  69854. * Dispose and release associated resources.
  69855. */
  69856. dispose(): void;
  69857. }
  69858. }
  69859. declare module BABYLON.GUI {
  69860. /**
  69861. * Class used to load GUI via XML.
  69862. */
  69863. export class XmlLoader {
  69864. private _nodes;
  69865. private _nodeTypes;
  69866. private _isLoaded;
  69867. private _objectAttributes;
  69868. private _parentClass;
  69869. /**
  69870. * Create a new xml loader
  69871. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  69872. */
  69873. constructor(parentClass?: null);
  69874. private _getChainElement;
  69875. private _getClassAttribute;
  69876. private _createGuiElement;
  69877. private _parseGrid;
  69878. private _parseElement;
  69879. private _prepareSourceElement;
  69880. private _parseElementsFromSource;
  69881. private _parseXml;
  69882. /**
  69883. * Gets if the loading has finished.
  69884. * @returns whether the loading has finished or not
  69885. */
  69886. isLoaded(): boolean;
  69887. /**
  69888. * Gets a loaded node / control by id.
  69889. * @param id the Controls id set in the xml
  69890. * @returns element of type Control
  69891. */
  69892. getNodeById(id: string): any;
  69893. /**
  69894. * Gets all loaded nodes / controls
  69895. * @returns Array of controls
  69896. */
  69897. getNodes(): any;
  69898. /**
  69899. * Initiates the xml layout loading
  69900. * @param xmlFile defines the xml layout to load
  69901. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  69902. * @param callback defines the callback called on layout load.
  69903. */
  69904. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  69905. }
  69906. }
  69907. declare module BABYLON.GUI {
  69908. /**
  69909. * Class used to create containers for controls
  69910. */
  69911. export class Container3D extends Control3D {
  69912. private _blockLayout;
  69913. /**
  69914. * Gets the list of child controls
  69915. */
  69916. protected _children: Control3D[];
  69917. /**
  69918. * Gets the list of child controls
  69919. */
  69920. readonly children: Array<Control3D>;
  69921. /**
  69922. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  69923. * This is helpful to optimize layout operation when adding multiple children in a row
  69924. */
  69925. blockLayout: boolean;
  69926. /**
  69927. * Creates a new container
  69928. * @param name defines the container name
  69929. */
  69930. constructor(name?: string);
  69931. /**
  69932. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  69933. * @returns the current container
  69934. */
  69935. updateLayout(): Container3D;
  69936. /**
  69937. * Gets a boolean indicating if the given control is in the children of this control
  69938. * @param control defines the control to check
  69939. * @returns true if the control is in the child list
  69940. */
  69941. containsControl(control: Control3D): boolean;
  69942. /**
  69943. * Adds a control to the children of this control
  69944. * @param control defines the control to add
  69945. * @returns the current container
  69946. */
  69947. addControl(control: Control3D): Container3D;
  69948. /**
  69949. * This function will be called everytime a new control is added
  69950. */
  69951. protected _arrangeChildren(): void;
  69952. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  69953. /**
  69954. * Removes a control from the children of this control
  69955. * @param control defines the control to remove
  69956. * @returns the current container
  69957. */
  69958. removeControl(control: Control3D): Container3D;
  69959. protected _getTypeName(): string;
  69960. /**
  69961. * Releases all associated resources
  69962. */
  69963. dispose(): void;
  69964. /** Control rotation will remain unchanged */
  69965. static readonly UNSET_ORIENTATION: number;
  69966. /** Control will rotate to make it look at sphere central axis */
  69967. static readonly FACEORIGIN_ORIENTATION: number;
  69968. /** Control will rotate to make it look back at sphere central axis */
  69969. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  69970. /** Control will rotate to look at z axis (0, 0, 1) */
  69971. static readonly FACEFORWARD_ORIENTATION: number;
  69972. /** Control will rotate to look at negative z axis (0, 0, -1) */
  69973. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  69974. }
  69975. }
  69976. declare module BABYLON.GUI {
  69977. /**
  69978. * Class used to manage 3D user interface
  69979. * @see http://doc.babylonjs.com/how_to/gui3d
  69980. */
  69981. export class GUI3DManager implements BABYLON.IDisposable {
  69982. private _scene;
  69983. private _sceneDisposeObserver;
  69984. private _utilityLayer;
  69985. private _rootContainer;
  69986. private _pointerObserver;
  69987. private _pointerOutObserver;
  69988. /** @hidden */
  69989. _lastPickedControl: Control3D;
  69990. /** @hidden */
  69991. _lastControlOver: {
  69992. [pointerId: number]: Control3D;
  69993. };
  69994. /** @hidden */
  69995. _lastControlDown: {
  69996. [pointerId: number]: Control3D;
  69997. };
  69998. /**
  69999. * BABYLON.Observable raised when the point picked by the pointer events changed
  70000. */
  70001. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  70002. /** @hidden */
  70003. _sharedMaterials: {
  70004. [key: string]: BABYLON.Material;
  70005. };
  70006. /** Gets the hosting scene */
  70007. readonly scene: BABYLON.Scene;
  70008. /** Gets associated utility layer */
  70009. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  70010. /**
  70011. * Creates a new GUI3DManager
  70012. * @param scene
  70013. */
  70014. constructor(scene?: BABYLON.Scene);
  70015. private _handlePointerOut;
  70016. private _doPicking;
  70017. /**
  70018. * Gets the root container
  70019. */
  70020. readonly rootContainer: Container3D;
  70021. /**
  70022. * Gets a boolean indicating if the given control is in the root child list
  70023. * @param control defines the control to check
  70024. * @returns true if the control is in the root child list
  70025. */
  70026. containsControl(control: Control3D): boolean;
  70027. /**
  70028. * Adds a control to the root child list
  70029. * @param control defines the control to add
  70030. * @returns the current manager
  70031. */
  70032. addControl(control: Control3D): GUI3DManager;
  70033. /**
  70034. * Removes a control from the root child list
  70035. * @param control defines the control to remove
  70036. * @returns the current container
  70037. */
  70038. removeControl(control: Control3D): GUI3DManager;
  70039. /**
  70040. * Releases all associated resources
  70041. */
  70042. dispose(): void;
  70043. }
  70044. }
  70045. declare module BABYLON.GUI {
  70046. /**
  70047. * Class used to transport BABYLON.Vector3 information for pointer events
  70048. */
  70049. export class Vector3WithInfo extends BABYLON.Vector3 {
  70050. /** defines the current mouse button index */
  70051. buttonIndex: number;
  70052. /**
  70053. * Creates a new Vector3WithInfo
  70054. * @param source defines the vector3 data to transport
  70055. * @param buttonIndex defines the current mouse button index
  70056. */
  70057. constructor(source: BABYLON.Vector3,
  70058. /** defines the current mouse button index */
  70059. buttonIndex?: number);
  70060. }
  70061. }
  70062. declare module BABYLON.GUI {
  70063. /**
  70064. * Class used as base class for controls
  70065. */
  70066. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  70067. /** Defines the control name */
  70068. name?: string | undefined;
  70069. /** @hidden */
  70070. _host: GUI3DManager;
  70071. private _node;
  70072. private _downCount;
  70073. private _enterCount;
  70074. private _downPointerIds;
  70075. private _isVisible;
  70076. /** Gets or sets the control position in world space */
  70077. position: BABYLON.Vector3;
  70078. /** Gets or sets the control scaling in world space */
  70079. scaling: BABYLON.Vector3;
  70080. /** Callback used to start pointer enter animation */
  70081. pointerEnterAnimation: () => void;
  70082. /** Callback used to start pointer out animation */
  70083. pointerOutAnimation: () => void;
  70084. /** Callback used to start pointer down animation */
  70085. pointerDownAnimation: () => void;
  70086. /** Callback used to start pointer up animation */
  70087. pointerUpAnimation: () => void;
  70088. /**
  70089. * An event triggered when the pointer move over the control
  70090. */
  70091. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  70092. /**
  70093. * An event triggered when the pointer move out of the control
  70094. */
  70095. onPointerOutObservable: BABYLON.Observable<Control3D>;
  70096. /**
  70097. * An event triggered when the pointer taps the control
  70098. */
  70099. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  70100. /**
  70101. * An event triggered when pointer is up
  70102. */
  70103. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  70104. /**
  70105. * An event triggered when a control is clicked on (with a mouse)
  70106. */
  70107. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  70108. /**
  70109. * An event triggered when pointer enters the control
  70110. */
  70111. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  70112. /**
  70113. * Gets or sets the parent container
  70114. */
  70115. parent: BABYLON.Nullable<Container3D>;
  70116. private _behaviors;
  70117. /**
  70118. * Gets the list of attached behaviors
  70119. * @see http://doc.babylonjs.com/features/behaviour
  70120. */
  70121. readonly behaviors: BABYLON.Behavior<Control3D>[];
  70122. /**
  70123. * Attach a behavior to the control
  70124. * @see http://doc.babylonjs.com/features/behaviour
  70125. * @param behavior defines the behavior to attach
  70126. * @returns the current control
  70127. */
  70128. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  70129. /**
  70130. * Remove an attached behavior
  70131. * @see http://doc.babylonjs.com/features/behaviour
  70132. * @param behavior defines the behavior to attach
  70133. * @returns the current control
  70134. */
  70135. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  70136. /**
  70137. * Gets an attached behavior by name
  70138. * @param name defines the name of the behavior to look for
  70139. * @see http://doc.babylonjs.com/features/behaviour
  70140. * @returns null if behavior was not found else the requested behavior
  70141. */
  70142. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  70143. /** Gets or sets a boolean indicating if the control is visible */
  70144. isVisible: boolean;
  70145. /**
  70146. * Creates a new control
  70147. * @param name defines the control name
  70148. */
  70149. constructor(
  70150. /** Defines the control name */
  70151. name?: string | undefined);
  70152. /**
  70153. * Gets a string representing the class name
  70154. */
  70155. readonly typeName: string;
  70156. /**
  70157. * Get the current class name of the control.
  70158. * @returns current class name
  70159. */
  70160. getClassName(): string;
  70161. protected _getTypeName(): string;
  70162. /**
  70163. * Gets the transform node used by this control
  70164. */
  70165. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  70166. /**
  70167. * Gets the mesh used to render this control
  70168. */
  70169. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70170. /**
  70171. * Link the control as child of the given node
  70172. * @param node defines the node to link to. Use null to unlink the control
  70173. * @returns the current control
  70174. */
  70175. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  70176. /** @hidden **/
  70177. _prepareNode(scene: BABYLON.Scene): void;
  70178. /**
  70179. * Node creation.
  70180. * Can be overriden by children
  70181. * @param scene defines the scene where the node must be attached
  70182. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  70183. */
  70184. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  70185. /**
  70186. * Affect a material to the given mesh
  70187. * @param mesh defines the mesh which will represent the control
  70188. */
  70189. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  70190. /** @hidden */
  70191. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  70192. /** @hidden */
  70193. _onPointerEnter(target: Control3D): boolean;
  70194. /** @hidden */
  70195. _onPointerOut(target: Control3D): void;
  70196. /** @hidden */
  70197. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  70198. /** @hidden */
  70199. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70200. /** @hidden */
  70201. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  70202. /** @hidden */
  70203. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  70204. /** @hidden */
  70205. _disposeNode(): void;
  70206. /**
  70207. * Releases all associated resources
  70208. */
  70209. dispose(): void;
  70210. }
  70211. }
  70212. declare module BABYLON.GUI {
  70213. /**
  70214. * Class used as a root to all buttons
  70215. */
  70216. export class AbstractButton3D extends Control3D {
  70217. /**
  70218. * Creates a new button
  70219. * @param name defines the control name
  70220. */
  70221. constructor(name?: string);
  70222. protected _getTypeName(): string;
  70223. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  70224. }
  70225. }
  70226. declare module BABYLON.GUI {
  70227. /**
  70228. * Class used to create a button in 3D
  70229. */
  70230. export class Button3D extends AbstractButton3D {
  70231. /** @hidden */
  70232. protected _currentMaterial: BABYLON.Material;
  70233. private _facadeTexture;
  70234. private _content;
  70235. private _contentResolution;
  70236. private _contentScaleRatio;
  70237. /**
  70238. * Gets or sets the texture resolution used to render content (512 by default)
  70239. */
  70240. contentResolution: BABYLON.int;
  70241. /**
  70242. * Gets or sets the texture scale ratio used to render content (2 by default)
  70243. */
  70244. contentScaleRatio: number;
  70245. protected _disposeFacadeTexture(): void;
  70246. protected _resetContent(): void;
  70247. /**
  70248. * Creates a new button
  70249. * @param name defines the control name
  70250. */
  70251. constructor(name?: string);
  70252. /**
  70253. * Gets or sets the GUI 2D content used to display the button's facade
  70254. */
  70255. content: Control;
  70256. /**
  70257. * Apply the facade texture (created from the content property).
  70258. * This function can be overloaded by child classes
  70259. * @param facadeTexture defines the AdvancedDynamicTexture to use
  70260. */
  70261. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  70262. protected _getTypeName(): string;
  70263. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  70264. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  70265. /**
  70266. * Releases all associated resources
  70267. */
  70268. dispose(): void;
  70269. }
  70270. }
  70271. declare module BABYLON.GUI {
  70272. /**
  70273. * Abstract class used to create a container panel deployed on the surface of a volume
  70274. */
  70275. export abstract class VolumeBasedPanel extends Container3D {
  70276. private _columns;
  70277. private _rows;
  70278. private _rowThenColum;
  70279. private _orientation;
  70280. protected _cellWidth: number;
  70281. protected _cellHeight: number;
  70282. /**
  70283. * Gets or sets the distance between elements
  70284. */
  70285. margin: number;
  70286. /**
  70287. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  70288. * | Value | Type | Description |
  70289. * | ----- | ----------------------------------- | ----------- |
  70290. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  70291. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  70292. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  70293. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  70294. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  70295. */
  70296. orientation: number;
  70297. /**
  70298. * Gets or sets the number of columns requested (10 by default).
  70299. * The panel will automatically compute the number of rows based on number of child controls.
  70300. */
  70301. columns: BABYLON.int;
  70302. /**
  70303. * Gets or sets a the number of rows requested.
  70304. * The panel will automatically compute the number of columns based on number of child controls.
  70305. */
  70306. rows: BABYLON.int;
  70307. /**
  70308. * Creates new VolumeBasedPanel
  70309. */
  70310. constructor();
  70311. protected _arrangeChildren(): void;
  70312. /** Child classes must implement this function to provide correct control positioning */
  70313. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70314. /** Child classes can implement this function to provide additional processing */
  70315. protected _finalProcessing(): void;
  70316. }
  70317. }
  70318. declare module BABYLON.GUI {
  70319. /**
  70320. * Class used to create a container panel deployed on the surface of a cylinder
  70321. */
  70322. export class CylinderPanel extends VolumeBasedPanel {
  70323. private _radius;
  70324. /**
  70325. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  70326. */
  70327. radius: BABYLON.float;
  70328. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70329. private _cylindricalMapping;
  70330. }
  70331. }
  70332. declare module BABYLON.GUI {
  70333. /** @hidden */
  70334. export var fluentVertexShader: {
  70335. name: string;
  70336. shader: string;
  70337. };
  70338. }
  70339. declare module BABYLON.GUI {
  70340. /** @hidden */
  70341. export var fluentPixelShader: {
  70342. name: string;
  70343. shader: string;
  70344. };
  70345. }
  70346. declare module BABYLON.GUI {
  70347. /** @hidden */
  70348. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  70349. INNERGLOW: boolean;
  70350. BORDER: boolean;
  70351. HOVERLIGHT: boolean;
  70352. TEXTURE: boolean;
  70353. constructor();
  70354. }
  70355. /**
  70356. * Class used to render controls with fluent desgin
  70357. */
  70358. export class FluentMaterial extends BABYLON.PushMaterial {
  70359. /**
  70360. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  70361. */
  70362. innerGlowColorIntensity: number;
  70363. /**
  70364. * Gets or sets the inner glow color (white by default)
  70365. */
  70366. innerGlowColor: BABYLON.Color3;
  70367. /**
  70368. * Gets or sets alpha value (default is 1.0)
  70369. */
  70370. alpha: number;
  70371. /**
  70372. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  70373. */
  70374. albedoColor: BABYLON.Color3;
  70375. /**
  70376. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  70377. */
  70378. renderBorders: boolean;
  70379. /**
  70380. * Gets or sets border width (default is 0.5)
  70381. */
  70382. borderWidth: number;
  70383. /**
  70384. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  70385. */
  70386. edgeSmoothingValue: number;
  70387. /**
  70388. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  70389. */
  70390. borderMinValue: number;
  70391. /**
  70392. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  70393. */
  70394. renderHoverLight: boolean;
  70395. /**
  70396. * Gets or sets the radius used to render the hover light (default is 1.0)
  70397. */
  70398. hoverRadius: number;
  70399. /**
  70400. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  70401. */
  70402. hoverColor: BABYLON.Color4;
  70403. /**
  70404. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  70405. */
  70406. hoverPosition: BABYLON.Vector3;
  70407. private _albedoTexture;
  70408. /** Gets or sets the texture to use for albedo color */
  70409. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70410. /**
  70411. * Creates a new Fluent material
  70412. * @param name defines the name of the material
  70413. * @param scene defines the hosting scene
  70414. */
  70415. constructor(name: string, scene: BABYLON.Scene);
  70416. needAlphaBlending(): boolean;
  70417. needAlphaTesting(): boolean;
  70418. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70419. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70420. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70421. getActiveTextures(): BABYLON.BaseTexture[];
  70422. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70423. dispose(forceDisposeEffect?: boolean): void;
  70424. clone(name: string): FluentMaterial;
  70425. serialize(): any;
  70426. getClassName(): string;
  70427. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  70428. }
  70429. }
  70430. declare module BABYLON.GUI {
  70431. /**
  70432. * Class used to create a holographic button in 3D
  70433. */
  70434. export class HolographicButton extends Button3D {
  70435. private _backPlate;
  70436. private _textPlate;
  70437. private _frontPlate;
  70438. private _text;
  70439. private _imageUrl;
  70440. private _shareMaterials;
  70441. private _frontMaterial;
  70442. private _backMaterial;
  70443. private _plateMaterial;
  70444. private _pickedPointObserver;
  70445. private _tooltipFade;
  70446. private _tooltipTextBlock;
  70447. private _tooltipTexture;
  70448. private _tooltipMesh;
  70449. private _tooltipHoverObserver;
  70450. private _tooltipOutObserver;
  70451. private _disposeTooltip;
  70452. /**
  70453. * Rendering ground id of all the mesh in the button
  70454. */
  70455. renderingGroupId: number;
  70456. /**
  70457. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  70458. */
  70459. tooltipText: BABYLON.Nullable<string>;
  70460. /**
  70461. * Gets or sets text for the button
  70462. */
  70463. text: string;
  70464. /**
  70465. * Gets or sets the image url for the button
  70466. */
  70467. imageUrl: string;
  70468. /**
  70469. * Gets the back material used by this button
  70470. */
  70471. readonly backMaterial: FluentMaterial;
  70472. /**
  70473. * Gets the front material used by this button
  70474. */
  70475. readonly frontMaterial: FluentMaterial;
  70476. /**
  70477. * Gets the plate material used by this button
  70478. */
  70479. readonly plateMaterial: BABYLON.StandardMaterial;
  70480. /**
  70481. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  70482. */
  70483. readonly shareMaterials: boolean;
  70484. /**
  70485. * Creates a new button
  70486. * @param name defines the control name
  70487. */
  70488. constructor(name?: string, shareMaterials?: boolean);
  70489. protected _getTypeName(): string;
  70490. private _rebuildContent;
  70491. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  70492. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  70493. private _createBackMaterial;
  70494. private _createFrontMaterial;
  70495. private _createPlateMaterial;
  70496. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  70497. /**
  70498. * Releases all associated resources
  70499. */
  70500. dispose(): void;
  70501. }
  70502. }
  70503. declare module BABYLON.GUI {
  70504. /**
  70505. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  70506. */
  70507. export class MeshButton3D extends Button3D {
  70508. /** @hidden */
  70509. protected _currentMesh: BABYLON.Mesh;
  70510. /**
  70511. * Creates a new 3D button based on a mesh
  70512. * @param mesh mesh to become a 3D button
  70513. * @param name defines the control name
  70514. */
  70515. constructor(mesh: BABYLON.Mesh, name?: string);
  70516. protected _getTypeName(): string;
  70517. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  70518. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  70519. }
  70520. }
  70521. declare module BABYLON.GUI {
  70522. /**
  70523. * Class used to create a container panel deployed on the surface of a plane
  70524. */
  70525. export class PlanePanel extends VolumeBasedPanel {
  70526. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70527. }
  70528. }
  70529. declare module BABYLON.GUI {
  70530. /**
  70531. * Class used to create a container panel where items get randomized planar mapping
  70532. */
  70533. export class ScatterPanel extends VolumeBasedPanel {
  70534. private _iteration;
  70535. /**
  70536. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  70537. */
  70538. iteration: BABYLON.float;
  70539. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70540. private _scatterMapping;
  70541. protected _finalProcessing(): void;
  70542. }
  70543. }
  70544. declare module BABYLON.GUI {
  70545. /**
  70546. * Class used to create a container panel deployed on the surface of a sphere
  70547. */
  70548. export class SpherePanel extends VolumeBasedPanel {
  70549. private _radius;
  70550. /**
  70551. * Gets or sets the radius of the sphere where to project controls (5 by default)
  70552. */
  70553. radius: BABYLON.float;
  70554. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70555. private _sphericalMapping;
  70556. }
  70557. }
  70558. declare module BABYLON.GUI {
  70559. /**
  70560. * Class used to create a stack panel in 3D on XY plane
  70561. */
  70562. export class StackPanel3D extends Container3D {
  70563. private _isVertical;
  70564. /**
  70565. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  70566. */
  70567. isVertical: boolean;
  70568. /**
  70569. * Gets or sets the distance between elements
  70570. */
  70571. margin: number;
  70572. /**
  70573. * Creates new StackPanel
  70574. * @param isVertical
  70575. */
  70576. constructor(isVertical?: boolean);
  70577. protected _arrangeChildren(): void;
  70578. }
  70579. }
  70580. declare module BABYLON {
  70581. /**
  70582. * Mode that determines the coordinate system to use.
  70583. */
  70584. export enum GLTFLoaderCoordinateSystemMode {
  70585. /**
  70586. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  70587. */
  70588. AUTO = 0,
  70589. /**
  70590. * Sets the useRightHandedSystem flag on the scene.
  70591. */
  70592. FORCE_RIGHT_HANDED = 1
  70593. }
  70594. /**
  70595. * Mode that determines what animations will start.
  70596. */
  70597. export enum GLTFLoaderAnimationStartMode {
  70598. /**
  70599. * No animation will start.
  70600. */
  70601. NONE = 0,
  70602. /**
  70603. * The first animation will start.
  70604. */
  70605. FIRST = 1,
  70606. /**
  70607. * All animations will start.
  70608. */
  70609. ALL = 2
  70610. }
  70611. /**
  70612. * Interface that contains the data for the glTF asset.
  70613. */
  70614. export interface IGLTFLoaderData {
  70615. /**
  70616. * The object that represents the glTF JSON.
  70617. */
  70618. json: Object;
  70619. /**
  70620. * The BIN chunk of a binary glTF.
  70621. */
  70622. bin: Nullable<IDataBuffer>;
  70623. }
  70624. /**
  70625. * Interface for extending the loader.
  70626. */
  70627. export interface IGLTFLoaderExtension {
  70628. /**
  70629. * The name of this extension.
  70630. */
  70631. readonly name: string;
  70632. /**
  70633. * Defines whether this extension is enabled.
  70634. */
  70635. enabled: boolean;
  70636. /**
  70637. * Defines the order of this extension.
  70638. * The loader sorts the extensions using these values when loading.
  70639. */
  70640. order?: number;
  70641. }
  70642. /**
  70643. * Loader state.
  70644. */
  70645. export enum GLTFLoaderState {
  70646. /**
  70647. * The asset is loading.
  70648. */
  70649. LOADING = 0,
  70650. /**
  70651. * The asset is ready for rendering.
  70652. */
  70653. READY = 1,
  70654. /**
  70655. * The asset is completely loaded.
  70656. */
  70657. COMPLETE = 2
  70658. }
  70659. /** @hidden */
  70660. export interface IGLTFLoader extends IDisposable {
  70661. readonly state: Nullable<GLTFLoaderState>;
  70662. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  70663. meshes: AbstractMesh[];
  70664. particleSystems: IParticleSystem[];
  70665. skeletons: Skeleton[];
  70666. animationGroups: AnimationGroup[];
  70667. }>;
  70668. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  70669. }
  70670. /**
  70671. * File loader for loading glTF files into a scene.
  70672. */
  70673. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  70674. /** @hidden */
  70675. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  70676. /** @hidden */
  70677. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  70678. /**
  70679. * Raised when the asset has been parsed
  70680. */
  70681. onParsedObservable: Observable<IGLTFLoaderData>;
  70682. private _onParsedObserver;
  70683. /**
  70684. * Raised when the asset has been parsed
  70685. */
  70686. onParsed: (loaderData: IGLTFLoaderData) => void;
  70687. /**
  70688. * 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.
  70689. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  70690. * Defaults to true.
  70691. * @hidden
  70692. */
  70693. static IncrementalLoading: boolean;
  70694. /**
  70695. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  70696. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  70697. * @hidden
  70698. */
  70699. static HomogeneousCoordinates: boolean;
  70700. /**
  70701. * The coordinate system mode. Defaults to AUTO.
  70702. */
  70703. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  70704. /**
  70705. * The animation start mode. Defaults to FIRST.
  70706. */
  70707. animationStartMode: GLTFLoaderAnimationStartMode;
  70708. /**
  70709. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  70710. */
  70711. compileMaterials: boolean;
  70712. /**
  70713. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  70714. */
  70715. useClipPlane: boolean;
  70716. /**
  70717. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  70718. */
  70719. compileShadowGenerators: boolean;
  70720. /**
  70721. * Defines if the Alpha blended materials are only applied as coverage.
  70722. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  70723. * If true, no extra effects are applied to transparent pixels.
  70724. */
  70725. transparencyAsCoverage: boolean;
  70726. /**
  70727. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  70728. * Enabling will disable offline support and glTF validator.
  70729. * Defaults to false.
  70730. */
  70731. useRangeRequests: boolean;
  70732. /**
  70733. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  70734. */
  70735. createInstances: boolean;
  70736. /**
  70737. * Function called before loading a url referenced by the asset.
  70738. */
  70739. preprocessUrlAsync: (url: string) => Promise<string>;
  70740. /**
  70741. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  70742. */
  70743. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  70744. private _onMeshLoadedObserver;
  70745. /**
  70746. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  70747. */
  70748. onMeshLoaded: (mesh: AbstractMesh) => void;
  70749. /**
  70750. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  70751. */
  70752. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  70753. private _onTextureLoadedObserver;
  70754. /**
  70755. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  70756. */
  70757. onTextureLoaded: (texture: BaseTexture) => void;
  70758. /**
  70759. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  70760. */
  70761. readonly onMaterialLoadedObservable: Observable<Material>;
  70762. private _onMaterialLoadedObserver;
  70763. /**
  70764. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  70765. */
  70766. onMaterialLoaded: (material: Material) => void;
  70767. /**
  70768. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  70769. */
  70770. readonly onCameraLoadedObservable: Observable<Camera>;
  70771. private _onCameraLoadedObserver;
  70772. /**
  70773. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  70774. */
  70775. onCameraLoaded: (camera: Camera) => void;
  70776. /**
  70777. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  70778. * For assets with LODs, raised when all of the LODs are complete.
  70779. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  70780. */
  70781. readonly onCompleteObservable: Observable<void>;
  70782. private _onCompleteObserver;
  70783. /**
  70784. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  70785. * For assets with LODs, raised when all of the LODs are complete.
  70786. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  70787. */
  70788. onComplete: () => void;
  70789. /**
  70790. * Observable raised when an error occurs.
  70791. */
  70792. readonly onErrorObservable: Observable<any>;
  70793. private _onErrorObserver;
  70794. /**
  70795. * Callback raised when an error occurs.
  70796. */
  70797. onError: (reason: any) => void;
  70798. /**
  70799. * Observable raised after the loader is disposed.
  70800. */
  70801. readonly onDisposeObservable: Observable<void>;
  70802. private _onDisposeObserver;
  70803. /**
  70804. * Callback raised after the loader is disposed.
  70805. */
  70806. onDispose: () => void;
  70807. /**
  70808. * Observable raised after a loader extension is created.
  70809. * Set additional options for a loader extension in this event.
  70810. */
  70811. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  70812. private _onExtensionLoadedObserver;
  70813. /**
  70814. * Callback raised after a loader extension is created.
  70815. */
  70816. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  70817. /**
  70818. * Defines if the loader logging is enabled.
  70819. */
  70820. loggingEnabled: boolean;
  70821. /**
  70822. * Defines if the loader should capture performance counters.
  70823. */
  70824. capturePerformanceCounters: boolean;
  70825. /**
  70826. * Defines if the loader should validate the asset.
  70827. */
  70828. validate: boolean;
  70829. /**
  70830. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  70831. */
  70832. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  70833. private _onValidatedObserver;
  70834. /**
  70835. * Callback raised after a loader extension is created.
  70836. */
  70837. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  70838. private _loader;
  70839. /**
  70840. * Name of the loader ("gltf")
  70841. */
  70842. name: string;
  70843. /** @hidden */
  70844. extensions: ISceneLoaderPluginExtensions;
  70845. /**
  70846. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  70847. */
  70848. dispose(): void;
  70849. /** @hidden */
  70850. _clear(): void;
  70851. /** @hidden */
  70852. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  70853. /** @hidden */
  70854. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  70855. /** @hidden */
  70856. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70857. meshes: AbstractMesh[];
  70858. particleSystems: IParticleSystem[];
  70859. skeletons: Skeleton[];
  70860. animationGroups: AnimationGroup[];
  70861. }>;
  70862. /** @hidden */
  70863. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70864. /** @hidden */
  70865. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  70866. /** @hidden */
  70867. canDirectLoad(data: string): boolean;
  70868. /** @hidden */
  70869. directLoad(scene: Scene, data: string): any;
  70870. /**
  70871. * The callback that allows custom handling of the root url based on the response url.
  70872. * @param rootUrl the original root url
  70873. * @param responseURL the response url if available
  70874. * @returns the new root url
  70875. */
  70876. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  70877. /** @hidden */
  70878. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  70879. /**
  70880. * The loader state or null if the loader is not active.
  70881. */
  70882. readonly loaderState: Nullable<GLTFLoaderState>;
  70883. /**
  70884. * Returns a promise that resolves when the asset is completely loaded.
  70885. * @returns a promise that resolves when the asset is completely loaded.
  70886. */
  70887. whenCompleteAsync(): Promise<void>;
  70888. private _validateAsync;
  70889. private _getLoader;
  70890. private _parseJson;
  70891. private _unpackBinaryAsync;
  70892. private _unpackBinaryV1Async;
  70893. private _unpackBinaryV2Async;
  70894. private static _parseVersion;
  70895. private static _compareVersion;
  70896. private static readonly _logSpaces;
  70897. private _logIndentLevel;
  70898. private _loggingEnabled;
  70899. /** @hidden */
  70900. _log: (message: string) => void;
  70901. /** @hidden */
  70902. _logOpen(message: string): void;
  70903. /** @hidden */
  70904. _logClose(): void;
  70905. private _logEnabled;
  70906. private _logDisabled;
  70907. private _capturePerformanceCounters;
  70908. /** @hidden */
  70909. _startPerformanceCounter: (counterName: string) => void;
  70910. /** @hidden */
  70911. _endPerformanceCounter: (counterName: string) => void;
  70912. private _startPerformanceCounterEnabled;
  70913. private _startPerformanceCounterDisabled;
  70914. private _endPerformanceCounterEnabled;
  70915. private _endPerformanceCounterDisabled;
  70916. }
  70917. }
  70918. declare module BABYLON.GLTF1 {
  70919. /**
  70920. * Enums
  70921. * @hidden
  70922. */
  70923. export enum EComponentType {
  70924. BYTE = 5120,
  70925. UNSIGNED_BYTE = 5121,
  70926. SHORT = 5122,
  70927. UNSIGNED_SHORT = 5123,
  70928. FLOAT = 5126
  70929. }
  70930. /** @hidden */
  70931. export enum EShaderType {
  70932. FRAGMENT = 35632,
  70933. VERTEX = 35633
  70934. }
  70935. /** @hidden */
  70936. export enum EParameterType {
  70937. BYTE = 5120,
  70938. UNSIGNED_BYTE = 5121,
  70939. SHORT = 5122,
  70940. UNSIGNED_SHORT = 5123,
  70941. INT = 5124,
  70942. UNSIGNED_INT = 5125,
  70943. FLOAT = 5126,
  70944. FLOAT_VEC2 = 35664,
  70945. FLOAT_VEC3 = 35665,
  70946. FLOAT_VEC4 = 35666,
  70947. INT_VEC2 = 35667,
  70948. INT_VEC3 = 35668,
  70949. INT_VEC4 = 35669,
  70950. BOOL = 35670,
  70951. BOOL_VEC2 = 35671,
  70952. BOOL_VEC3 = 35672,
  70953. BOOL_VEC4 = 35673,
  70954. FLOAT_MAT2 = 35674,
  70955. FLOAT_MAT3 = 35675,
  70956. FLOAT_MAT4 = 35676,
  70957. SAMPLER_2D = 35678
  70958. }
  70959. /** @hidden */
  70960. export enum ETextureWrapMode {
  70961. CLAMP_TO_EDGE = 33071,
  70962. MIRRORED_REPEAT = 33648,
  70963. REPEAT = 10497
  70964. }
  70965. /** @hidden */
  70966. export enum ETextureFilterType {
  70967. NEAREST = 9728,
  70968. LINEAR = 9728,
  70969. NEAREST_MIPMAP_NEAREST = 9984,
  70970. LINEAR_MIPMAP_NEAREST = 9985,
  70971. NEAREST_MIPMAP_LINEAR = 9986,
  70972. LINEAR_MIPMAP_LINEAR = 9987
  70973. }
  70974. /** @hidden */
  70975. export enum ETextureFormat {
  70976. ALPHA = 6406,
  70977. RGB = 6407,
  70978. RGBA = 6408,
  70979. LUMINANCE = 6409,
  70980. LUMINANCE_ALPHA = 6410
  70981. }
  70982. /** @hidden */
  70983. export enum ECullingType {
  70984. FRONT = 1028,
  70985. BACK = 1029,
  70986. FRONT_AND_BACK = 1032
  70987. }
  70988. /** @hidden */
  70989. export enum EBlendingFunction {
  70990. ZERO = 0,
  70991. ONE = 1,
  70992. SRC_COLOR = 768,
  70993. ONE_MINUS_SRC_COLOR = 769,
  70994. DST_COLOR = 774,
  70995. ONE_MINUS_DST_COLOR = 775,
  70996. SRC_ALPHA = 770,
  70997. ONE_MINUS_SRC_ALPHA = 771,
  70998. DST_ALPHA = 772,
  70999. ONE_MINUS_DST_ALPHA = 773,
  71000. CONSTANT_COLOR = 32769,
  71001. ONE_MINUS_CONSTANT_COLOR = 32770,
  71002. CONSTANT_ALPHA = 32771,
  71003. ONE_MINUS_CONSTANT_ALPHA = 32772,
  71004. SRC_ALPHA_SATURATE = 776
  71005. }
  71006. /** @hidden */
  71007. export interface IGLTFProperty {
  71008. extensions?: {
  71009. [key: string]: any;
  71010. };
  71011. extras?: Object;
  71012. }
  71013. /** @hidden */
  71014. export interface IGLTFChildRootProperty extends IGLTFProperty {
  71015. name?: string;
  71016. }
  71017. /** @hidden */
  71018. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  71019. bufferView: string;
  71020. byteOffset: number;
  71021. byteStride: number;
  71022. count: number;
  71023. type: string;
  71024. componentType: EComponentType;
  71025. max?: number[];
  71026. min?: number[];
  71027. name?: string;
  71028. }
  71029. /** @hidden */
  71030. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  71031. buffer: string;
  71032. byteOffset: number;
  71033. byteLength: number;
  71034. byteStride: number;
  71035. target?: number;
  71036. }
  71037. /** @hidden */
  71038. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  71039. uri: string;
  71040. byteLength?: number;
  71041. type?: string;
  71042. }
  71043. /** @hidden */
  71044. export interface IGLTFShader extends IGLTFChildRootProperty {
  71045. uri: string;
  71046. type: EShaderType;
  71047. }
  71048. /** @hidden */
  71049. export interface IGLTFProgram extends IGLTFChildRootProperty {
  71050. attributes: string[];
  71051. fragmentShader: string;
  71052. vertexShader: string;
  71053. }
  71054. /** @hidden */
  71055. export interface IGLTFTechniqueParameter {
  71056. type: number;
  71057. count?: number;
  71058. semantic?: string;
  71059. node?: string;
  71060. value?: number | boolean | string | Array<any>;
  71061. source?: string;
  71062. babylonValue?: any;
  71063. }
  71064. /** @hidden */
  71065. export interface IGLTFTechniqueCommonProfile {
  71066. lightingModel: string;
  71067. texcoordBindings: Object;
  71068. parameters?: Array<any>;
  71069. }
  71070. /** @hidden */
  71071. export interface IGLTFTechniqueStatesFunctions {
  71072. blendColor?: number[];
  71073. blendEquationSeparate?: number[];
  71074. blendFuncSeparate?: number[];
  71075. colorMask: boolean[];
  71076. cullFace: number[];
  71077. }
  71078. /** @hidden */
  71079. export interface IGLTFTechniqueStates {
  71080. enable: number[];
  71081. functions: IGLTFTechniqueStatesFunctions;
  71082. }
  71083. /** @hidden */
  71084. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  71085. parameters: {
  71086. [key: string]: IGLTFTechniqueParameter;
  71087. };
  71088. program: string;
  71089. attributes: {
  71090. [key: string]: string;
  71091. };
  71092. uniforms: {
  71093. [key: string]: string;
  71094. };
  71095. states: IGLTFTechniqueStates;
  71096. }
  71097. /** @hidden */
  71098. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  71099. technique?: string;
  71100. values: string[];
  71101. }
  71102. /** @hidden */
  71103. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  71104. attributes: {
  71105. [key: string]: string;
  71106. };
  71107. indices: string;
  71108. material: string;
  71109. mode?: number;
  71110. }
  71111. /** @hidden */
  71112. export interface IGLTFMesh extends IGLTFChildRootProperty {
  71113. primitives: IGLTFMeshPrimitive[];
  71114. }
  71115. /** @hidden */
  71116. export interface IGLTFImage extends IGLTFChildRootProperty {
  71117. uri: string;
  71118. }
  71119. /** @hidden */
  71120. export interface IGLTFSampler extends IGLTFChildRootProperty {
  71121. magFilter?: number;
  71122. minFilter?: number;
  71123. wrapS?: number;
  71124. wrapT?: number;
  71125. }
  71126. /** @hidden */
  71127. export interface IGLTFTexture extends IGLTFChildRootProperty {
  71128. sampler: string;
  71129. source: string;
  71130. format?: ETextureFormat;
  71131. internalFormat?: ETextureFormat;
  71132. target?: number;
  71133. type?: number;
  71134. babylonTexture?: Texture;
  71135. }
  71136. /** @hidden */
  71137. export interface IGLTFAmbienLight {
  71138. color?: number[];
  71139. }
  71140. /** @hidden */
  71141. export interface IGLTFDirectionalLight {
  71142. color?: number[];
  71143. }
  71144. /** @hidden */
  71145. export interface IGLTFPointLight {
  71146. color?: number[];
  71147. constantAttenuation?: number;
  71148. linearAttenuation?: number;
  71149. quadraticAttenuation?: number;
  71150. }
  71151. /** @hidden */
  71152. export interface IGLTFSpotLight {
  71153. color?: number[];
  71154. constantAttenuation?: number;
  71155. fallOfAngle?: number;
  71156. fallOffExponent?: number;
  71157. linearAttenuation?: number;
  71158. quadraticAttenuation?: number;
  71159. }
  71160. /** @hidden */
  71161. export interface IGLTFLight extends IGLTFChildRootProperty {
  71162. type: string;
  71163. }
  71164. /** @hidden */
  71165. export interface IGLTFCameraOrthographic {
  71166. xmag: number;
  71167. ymag: number;
  71168. zfar: number;
  71169. znear: number;
  71170. }
  71171. /** @hidden */
  71172. export interface IGLTFCameraPerspective {
  71173. aspectRatio: number;
  71174. yfov: number;
  71175. zfar: number;
  71176. znear: number;
  71177. }
  71178. /** @hidden */
  71179. export interface IGLTFCamera extends IGLTFChildRootProperty {
  71180. type: string;
  71181. }
  71182. /** @hidden */
  71183. export interface IGLTFAnimationChannelTarget {
  71184. id: string;
  71185. path: string;
  71186. }
  71187. /** @hidden */
  71188. export interface IGLTFAnimationChannel {
  71189. sampler: string;
  71190. target: IGLTFAnimationChannelTarget;
  71191. }
  71192. /** @hidden */
  71193. export interface IGLTFAnimationSampler {
  71194. input: string;
  71195. output: string;
  71196. interpolation?: string;
  71197. }
  71198. /** @hidden */
  71199. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  71200. channels?: IGLTFAnimationChannel[];
  71201. parameters?: {
  71202. [key: string]: string;
  71203. };
  71204. samplers?: {
  71205. [key: string]: IGLTFAnimationSampler;
  71206. };
  71207. }
  71208. /** @hidden */
  71209. export interface IGLTFNodeInstanceSkin {
  71210. skeletons: string[];
  71211. skin: string;
  71212. meshes: string[];
  71213. }
  71214. /** @hidden */
  71215. export interface IGLTFSkins extends IGLTFChildRootProperty {
  71216. bindShapeMatrix: number[];
  71217. inverseBindMatrices: string;
  71218. jointNames: string[];
  71219. babylonSkeleton?: Skeleton;
  71220. }
  71221. /** @hidden */
  71222. export interface IGLTFNode extends IGLTFChildRootProperty {
  71223. camera?: string;
  71224. children: string[];
  71225. skin?: string;
  71226. jointName?: string;
  71227. light?: string;
  71228. matrix: number[];
  71229. mesh?: string;
  71230. meshes?: string[];
  71231. rotation?: number[];
  71232. scale?: number[];
  71233. translation?: number[];
  71234. babylonNode?: Node;
  71235. }
  71236. /** @hidden */
  71237. export interface IGLTFScene extends IGLTFChildRootProperty {
  71238. nodes: string[];
  71239. }
  71240. /** @hidden */
  71241. export interface IGLTFRuntime {
  71242. extensions: {
  71243. [key: string]: any;
  71244. };
  71245. accessors: {
  71246. [key: string]: IGLTFAccessor;
  71247. };
  71248. buffers: {
  71249. [key: string]: IGLTFBuffer;
  71250. };
  71251. bufferViews: {
  71252. [key: string]: IGLTFBufferView;
  71253. };
  71254. meshes: {
  71255. [key: string]: IGLTFMesh;
  71256. };
  71257. lights: {
  71258. [key: string]: IGLTFLight;
  71259. };
  71260. cameras: {
  71261. [key: string]: IGLTFCamera;
  71262. };
  71263. nodes: {
  71264. [key: string]: IGLTFNode;
  71265. };
  71266. images: {
  71267. [key: string]: IGLTFImage;
  71268. };
  71269. textures: {
  71270. [key: string]: IGLTFTexture;
  71271. };
  71272. shaders: {
  71273. [key: string]: IGLTFShader;
  71274. };
  71275. programs: {
  71276. [key: string]: IGLTFProgram;
  71277. };
  71278. samplers: {
  71279. [key: string]: IGLTFSampler;
  71280. };
  71281. techniques: {
  71282. [key: string]: IGLTFTechnique;
  71283. };
  71284. materials: {
  71285. [key: string]: IGLTFMaterial;
  71286. };
  71287. animations: {
  71288. [key: string]: IGLTFAnimation;
  71289. };
  71290. skins: {
  71291. [key: string]: IGLTFSkins;
  71292. };
  71293. currentScene?: Object;
  71294. scenes: {
  71295. [key: string]: IGLTFScene;
  71296. };
  71297. extensionsUsed: string[];
  71298. extensionsRequired?: string[];
  71299. buffersCount: number;
  71300. shaderscount: number;
  71301. scene: Scene;
  71302. rootUrl: string;
  71303. loadedBufferCount: number;
  71304. loadedBufferViews: {
  71305. [name: string]: ArrayBufferView;
  71306. };
  71307. loadedShaderCount: number;
  71308. importOnlyMeshes: boolean;
  71309. importMeshesNames?: string[];
  71310. dummyNodes: Node[];
  71311. }
  71312. /** @hidden */
  71313. export interface INodeToRoot {
  71314. bone: Bone;
  71315. node: IGLTFNode;
  71316. id: string;
  71317. }
  71318. /** @hidden */
  71319. export interface IJointNode {
  71320. node: IGLTFNode;
  71321. id: string;
  71322. }
  71323. }
  71324. declare module BABYLON.GLTF1 {
  71325. /**
  71326. * Utils functions for GLTF
  71327. * @hidden
  71328. */
  71329. export class GLTFUtils {
  71330. /**
  71331. * Sets the given "parameter" matrix
  71332. * @param scene: the Scene object
  71333. * @param source: the source node where to pick the matrix
  71334. * @param parameter: the GLTF technique parameter
  71335. * @param uniformName: the name of the shader's uniform
  71336. * @param shaderMaterial: the shader material
  71337. */
  71338. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  71339. /**
  71340. * Sets the given "parameter" matrix
  71341. * @param shaderMaterial: the shader material
  71342. * @param uniform: the name of the shader's uniform
  71343. * @param value: the value of the uniform
  71344. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  71345. */
  71346. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  71347. /**
  71348. * Returns the wrap mode of the texture
  71349. * @param mode: the mode value
  71350. */
  71351. static GetWrapMode(mode: number): number;
  71352. /**
  71353. * Returns the byte stride giving an accessor
  71354. * @param accessor: the GLTF accessor objet
  71355. */
  71356. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  71357. /**
  71358. * Returns the texture filter mode giving a mode value
  71359. * @param mode: the filter mode value
  71360. */
  71361. static GetTextureFilterMode(mode: number): ETextureFilterType;
  71362. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  71363. /**
  71364. * Returns a buffer from its accessor
  71365. * @param gltfRuntime: the GLTF runtime
  71366. * @param accessor: the GLTF accessor
  71367. */
  71368. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  71369. /**
  71370. * Decodes a buffer view into a string
  71371. * @param view: the buffer view
  71372. */
  71373. static DecodeBufferToText(view: ArrayBufferView): string;
  71374. /**
  71375. * Returns the default material of gltf. Related to
  71376. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  71377. * @param scene: the Babylon.js scene
  71378. */
  71379. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  71380. private static _DefaultMaterial;
  71381. }
  71382. }
  71383. declare module BABYLON.GLTF1 {
  71384. /**
  71385. * Implementation of the base glTF spec
  71386. * @hidden
  71387. */
  71388. export class GLTFLoaderBase {
  71389. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  71390. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  71391. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  71392. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  71393. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  71394. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  71395. }
  71396. /**
  71397. * glTF V1 Loader
  71398. * @hidden
  71399. */
  71400. export class GLTFLoader implements IGLTFLoader {
  71401. static Extensions: {
  71402. [name: string]: GLTFLoaderExtension;
  71403. };
  71404. static RegisterExtension(extension: GLTFLoaderExtension): void;
  71405. state: Nullable<GLTFLoaderState>;
  71406. dispose(): void;
  71407. private _importMeshAsync;
  71408. /**
  71409. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  71410. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  71411. * @param scene the scene the meshes should be added to
  71412. * @param data gltf data containing information of the meshes in a loaded file
  71413. * @param rootUrl root url to load from
  71414. * @param onProgress event that fires when loading progress has occured
  71415. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  71416. */
  71417. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  71418. meshes: AbstractMesh[];
  71419. particleSystems: IParticleSystem[];
  71420. skeletons: Skeleton[];
  71421. animationGroups: AnimationGroup[];
  71422. }>;
  71423. private _loadAsync;
  71424. /**
  71425. * Imports all objects from a loaded gltf file and adds them to the scene
  71426. * @param scene the scene the objects should be added to
  71427. * @param data gltf data containing information of the meshes in a loaded file
  71428. * @param rootUrl root url to load from
  71429. * @param onProgress event that fires when loading progress has occured
  71430. * @returns a promise which completes when objects have been loaded to the scene
  71431. */
  71432. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  71433. private _loadShadersAsync;
  71434. private _loadBuffersAsync;
  71435. private _createNodes;
  71436. }
  71437. /** @hidden */
  71438. export abstract class GLTFLoaderExtension {
  71439. private _name;
  71440. constructor(name: string);
  71441. readonly name: string;
  71442. /**
  71443. * Defines an override for loading the runtime
  71444. * Return true to stop further extensions from loading the runtime
  71445. */
  71446. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  71447. /**
  71448. * Defines an onverride for creating gltf runtime
  71449. * Return true to stop further extensions from creating the runtime
  71450. */
  71451. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  71452. /**
  71453. * Defines an override for loading buffers
  71454. * Return true to stop further extensions from loading this buffer
  71455. */
  71456. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  71457. /**
  71458. * Defines an override for loading texture buffers
  71459. * Return true to stop further extensions from loading this texture data
  71460. */
  71461. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  71462. /**
  71463. * Defines an override for creating textures
  71464. * Return true to stop further extensions from loading this texture
  71465. */
  71466. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  71467. /**
  71468. * Defines an override for loading shader strings
  71469. * Return true to stop further extensions from loading this shader data
  71470. */
  71471. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  71472. /**
  71473. * Defines an override for loading materials
  71474. * Return true to stop further extensions from loading this material
  71475. */
  71476. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  71477. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  71478. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  71479. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  71480. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  71481. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  71482. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  71483. private static LoadTextureBufferAsync;
  71484. private static CreateTextureAsync;
  71485. private static ApplyExtensions;
  71486. }
  71487. }
  71488. declare module BABYLON.GLTF1 {
  71489. /** @hidden */
  71490. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  71491. private _bin;
  71492. constructor();
  71493. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  71494. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  71495. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  71496. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  71497. }
  71498. }
  71499. declare module BABYLON.GLTF1 {
  71500. /** @hidden */
  71501. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  71502. constructor();
  71503. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  71504. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  71505. private _loadTexture;
  71506. }
  71507. }
  71508. declare module BABYLON.GLTF2.Loader {
  71509. /**
  71510. * Loader interface with an index field.
  71511. */
  71512. export interface IArrayItem {
  71513. /**
  71514. * The index of this item in the array.
  71515. */
  71516. index: number;
  71517. }
  71518. /**
  71519. * Loader interface with additional members.
  71520. */
  71521. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  71522. /** @hidden */
  71523. _data?: Promise<ArrayBufferView>;
  71524. /** @hidden */
  71525. _babylonVertexBuffer?: Promise<VertexBuffer>;
  71526. }
  71527. /**
  71528. * Loader interface with additional members.
  71529. */
  71530. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  71531. }
  71532. /** @hidden */
  71533. export interface _IAnimationSamplerData {
  71534. input: Float32Array;
  71535. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  71536. output: Float32Array;
  71537. }
  71538. /**
  71539. * Loader interface with additional members.
  71540. */
  71541. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  71542. /** @hidden */
  71543. _data?: Promise<_IAnimationSamplerData>;
  71544. }
  71545. /**
  71546. * Loader interface with additional members.
  71547. */
  71548. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  71549. channels: IAnimationChannel[];
  71550. samplers: IAnimationSampler[];
  71551. /** @hidden */
  71552. _babylonAnimationGroup?: AnimationGroup;
  71553. }
  71554. /**
  71555. * Loader interface with additional members.
  71556. */
  71557. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  71558. /** @hidden */
  71559. _data?: Promise<ArrayBufferView>;
  71560. }
  71561. /**
  71562. * Loader interface with additional members.
  71563. */
  71564. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  71565. /** @hidden */
  71566. _data?: Promise<ArrayBufferView>;
  71567. /** @hidden */
  71568. _babylonBuffer?: Promise<Buffer>;
  71569. }
  71570. /**
  71571. * Loader interface with additional members.
  71572. */
  71573. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  71574. }
  71575. /**
  71576. * Loader interface with additional members.
  71577. */
  71578. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  71579. /** @hidden */
  71580. _data?: Promise<ArrayBufferView>;
  71581. }
  71582. /**
  71583. * Loader interface with additional members.
  71584. */
  71585. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  71586. }
  71587. /**
  71588. * Loader interface with additional members.
  71589. */
  71590. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  71591. }
  71592. /**
  71593. * Loader interface with additional members.
  71594. */
  71595. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  71596. baseColorTexture?: ITextureInfo;
  71597. metallicRoughnessTexture?: ITextureInfo;
  71598. }
  71599. /**
  71600. * Loader interface with additional members.
  71601. */
  71602. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  71603. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  71604. normalTexture?: IMaterialNormalTextureInfo;
  71605. occlusionTexture?: IMaterialOcclusionTextureInfo;
  71606. emissiveTexture?: ITextureInfo;
  71607. /** @hidden */
  71608. _data?: {
  71609. [babylonDrawMode: number]: {
  71610. babylonMaterial: Material;
  71611. babylonMeshes: AbstractMesh[];
  71612. promise: Promise<void>;
  71613. };
  71614. };
  71615. }
  71616. /**
  71617. * Loader interface with additional members.
  71618. */
  71619. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  71620. primitives: IMeshPrimitive[];
  71621. }
  71622. /**
  71623. * Loader interface with additional members.
  71624. */
  71625. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  71626. /** @hidden */
  71627. _instanceData?: {
  71628. babylonSourceMesh: Mesh;
  71629. promise: Promise<any>;
  71630. };
  71631. }
  71632. /**
  71633. * Loader interface with additional members.
  71634. */
  71635. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  71636. /**
  71637. * The parent glTF node.
  71638. */
  71639. parent?: INode;
  71640. /** @hidden */
  71641. _babylonTransformNode?: TransformNode;
  71642. /** @hidden */
  71643. _primitiveBabylonMeshes?: AbstractMesh[];
  71644. /** @hidden */
  71645. _babylonBones?: Bone[];
  71646. /** @hidden */
  71647. _numMorphTargets?: number;
  71648. }
  71649. /** @hidden */
  71650. export interface _ISamplerData {
  71651. noMipMaps: boolean;
  71652. samplingMode: number;
  71653. wrapU: number;
  71654. wrapV: number;
  71655. }
  71656. /**
  71657. * Loader interface with additional members.
  71658. */
  71659. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  71660. /** @hidden */
  71661. _data?: _ISamplerData;
  71662. }
  71663. /**
  71664. * Loader interface with additional members.
  71665. */
  71666. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  71667. }
  71668. /**
  71669. * Loader interface with additional members.
  71670. */
  71671. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  71672. /** @hidden */
  71673. _data?: {
  71674. babylonSkeleton: Skeleton;
  71675. promise: Promise<void>;
  71676. };
  71677. }
  71678. /**
  71679. * Loader interface with additional members.
  71680. */
  71681. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  71682. }
  71683. /**
  71684. * Loader interface with additional members.
  71685. */
  71686. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  71687. }
  71688. /**
  71689. * Loader interface with additional members.
  71690. */
  71691. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  71692. accessors?: IAccessor[];
  71693. animations?: IAnimation[];
  71694. buffers?: IBuffer[];
  71695. bufferViews?: IBufferView[];
  71696. cameras?: ICamera[];
  71697. images?: IImage[];
  71698. materials?: IMaterial[];
  71699. meshes?: IMesh[];
  71700. nodes?: INode[];
  71701. samplers?: ISampler[];
  71702. scenes?: IScene[];
  71703. skins?: ISkin[];
  71704. textures?: ITexture[];
  71705. }
  71706. }
  71707. declare module BABYLON.GLTF2 {
  71708. /**
  71709. * Interface for a glTF loader extension.
  71710. */
  71711. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  71712. /**
  71713. * Called after the loader state changes to LOADING.
  71714. */
  71715. onLoading?(): void;
  71716. /**
  71717. * Called after the loader state changes to READY.
  71718. */
  71719. onReady?(): void;
  71720. /**
  71721. * Define this method to modify the default behavior when loading scenes.
  71722. * @param context The context when loading the asset
  71723. * @param scene The glTF scene property
  71724. * @returns A promise that resolves when the load is complete or null if not handled
  71725. */
  71726. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  71727. /**
  71728. * Define this method to modify the default behavior when loading nodes.
  71729. * @param context The context when loading the asset
  71730. * @param node The glTF node property
  71731. * @param assign A function called synchronously after parsing the glTF properties
  71732. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  71733. */
  71734. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71735. /**
  71736. * Define this method to modify the default behavior when loading cameras.
  71737. * @param context The context when loading the asset
  71738. * @param camera The glTF camera property
  71739. * @param assign A function called synchronously after parsing the glTF properties
  71740. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  71741. */
  71742. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  71743. /**
  71744. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  71745. * @param context The context when loading the asset
  71746. * @param primitive The glTF mesh primitive property
  71747. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  71748. */
  71749. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  71750. /**
  71751. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  71752. * @param context The context when loading the asset
  71753. * @param name The mesh name when loading the asset
  71754. * @param node The glTF node when loading the asset
  71755. * @param mesh The glTF mesh when loading the asset
  71756. * @param primitive The glTF mesh primitive property
  71757. * @param assign A function called synchronously after parsing the glTF properties
  71758. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  71759. */
  71760. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  71761. /**
  71762. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  71763. * @param context The context when loading the asset
  71764. * @param material The glTF material property
  71765. * @param assign A function called synchronously after parsing the glTF properties
  71766. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  71767. */
  71768. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  71769. /**
  71770. * Define this method to modify the default behavior when creating materials.
  71771. * @param context The context when loading the asset
  71772. * @param material The glTF material property
  71773. * @param babylonDrawMode The draw mode for the Babylon material
  71774. * @returns The Babylon material or null if not handled
  71775. */
  71776. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  71777. /**
  71778. * Define this method to modify the default behavior when loading material properties.
  71779. * @param context The context when loading the asset
  71780. * @param material The glTF material property
  71781. * @param babylonMaterial The Babylon material
  71782. * @returns A promise that resolves when the load is complete or null if not handled
  71783. */
  71784. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71785. /**
  71786. * Define this method to modify the default behavior when loading texture infos.
  71787. * @param context The context when loading the asset
  71788. * @param textureInfo The glTF texture info property
  71789. * @param assign A function called synchronously after parsing the glTF properties
  71790. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  71791. */
  71792. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  71793. /**
  71794. * Define this method to modify the default behavior when loading animations.
  71795. * @param context The context when loading the asset
  71796. * @param animation The glTF animation property
  71797. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  71798. */
  71799. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  71800. /**
  71801. * @hidden Define this method to modify the default behavior when loading skins.
  71802. * @param context The context when loading the asset
  71803. * @param node The glTF node property
  71804. * @param skin The glTF skin property
  71805. * @returns A promise that resolves when the load is complete or null if not handled
  71806. */
  71807. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  71808. /**
  71809. * @hidden Define this method to modify the default behavior when loading uris.
  71810. * @param context The context when loading the asset
  71811. * @param property The glTF property associated with the uri
  71812. * @param uri The uri to load
  71813. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71814. */
  71815. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  71816. /**
  71817. * Define this method to modify the default behavior when loading buffer views.
  71818. * @param context The context when loading the asset
  71819. * @param bufferView The glTF buffer view property
  71820. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71821. */
  71822. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  71823. /**
  71824. * Define this method to modify the default behavior when loading buffers.
  71825. * @param context The context when loading the asset
  71826. * @param buffer The glTF buffer property
  71827. * @param byteOffset The byte offset to load
  71828. * @param byteLength The byte length to load
  71829. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71830. */
  71831. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  71832. }
  71833. }
  71834. declare module BABYLON.GLTF2 {
  71835. /**
  71836. * Helper class for working with arrays when loading the glTF asset
  71837. */
  71838. export class ArrayItem {
  71839. /**
  71840. * Gets an item from the given array.
  71841. * @param context The context when loading the asset
  71842. * @param array The array to get the item from
  71843. * @param index The index to the array
  71844. * @returns The array item
  71845. */
  71846. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  71847. /**
  71848. * Assign an `index` field to each item of the given array.
  71849. * @param array The array of items
  71850. */
  71851. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  71852. }
  71853. /**
  71854. * The glTF 2.0 loader
  71855. */
  71856. export class GLTFLoader implements IGLTFLoader {
  71857. /** @hidden */
  71858. _completePromises: Promise<any>[];
  71859. private _disposed;
  71860. private _parent;
  71861. private _state;
  71862. private _extensions;
  71863. private _rootUrl;
  71864. private _fileName;
  71865. private _uniqueRootUrl;
  71866. private _gltf;
  71867. private _bin;
  71868. private _babylonScene;
  71869. private _rootBabylonMesh;
  71870. private _defaultBabylonMaterialData;
  71871. private _progressCallback?;
  71872. private _requests;
  71873. private static readonly _DefaultSampler;
  71874. private static _RegisteredExtensions;
  71875. /**
  71876. * Registers a loader extension.
  71877. * @param name The name of the loader extension.
  71878. * @param factory The factory function that creates the loader extension.
  71879. */
  71880. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  71881. /**
  71882. * Unregisters a loader extension.
  71883. * @param name The name of the loader extension.
  71884. * @returns A boolean indicating whether the extension has been unregistered
  71885. */
  71886. static UnregisterExtension(name: string): boolean;
  71887. /**
  71888. * Gets the loader state.
  71889. */
  71890. readonly state: Nullable<GLTFLoaderState>;
  71891. /**
  71892. * The object that represents the glTF JSON.
  71893. */
  71894. readonly gltf: IGLTF;
  71895. /**
  71896. * The BIN chunk of a binary glTF.
  71897. */
  71898. readonly bin: Nullable<IDataBuffer>;
  71899. /**
  71900. * The parent file loader.
  71901. */
  71902. readonly parent: GLTFFileLoader;
  71903. /**
  71904. * The Babylon scene when loading the asset.
  71905. */
  71906. readonly babylonScene: Scene;
  71907. /**
  71908. * The root Babylon mesh when loading the asset.
  71909. */
  71910. readonly rootBabylonMesh: Mesh;
  71911. /** @hidden */
  71912. constructor(parent: GLTFFileLoader);
  71913. /** @hidden */
  71914. dispose(): void;
  71915. /** @hidden */
  71916. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  71917. meshes: AbstractMesh[];
  71918. particleSystems: IParticleSystem[];
  71919. skeletons: Skeleton[];
  71920. animationGroups: AnimationGroup[];
  71921. }>;
  71922. /** @hidden */
  71923. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  71924. private _loadAsync;
  71925. private _loadData;
  71926. private _setupData;
  71927. private _loadExtensions;
  71928. private _checkExtensions;
  71929. private _setState;
  71930. private _createRootNode;
  71931. /**
  71932. * Loads a glTF scene.
  71933. * @param context The context when loading the asset
  71934. * @param scene The glTF scene property
  71935. * @returns A promise that resolves when the load is complete
  71936. */
  71937. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  71938. private _forEachPrimitive;
  71939. private _getMeshes;
  71940. private _getSkeletons;
  71941. private _getAnimationGroups;
  71942. private _startAnimations;
  71943. /**
  71944. * Loads a glTF node.
  71945. * @param context The context when loading the asset
  71946. * @param node The glTF node property
  71947. * @param assign A function called synchronously after parsing the glTF properties
  71948. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  71949. */
  71950. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  71951. private _loadMeshAsync;
  71952. /**
  71953. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  71954. * @param context The context when loading the asset
  71955. * @param name The mesh name when loading the asset
  71956. * @param node The glTF node when loading the asset
  71957. * @param mesh The glTF mesh when loading the asset
  71958. * @param primitive The glTF mesh primitive property
  71959. * @param assign A function called synchronously after parsing the glTF properties
  71960. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  71961. */
  71962. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  71963. private _loadVertexDataAsync;
  71964. private _createMorphTargets;
  71965. private _loadMorphTargetsAsync;
  71966. private _loadMorphTargetVertexDataAsync;
  71967. private static _LoadTransform;
  71968. private _loadSkinAsync;
  71969. private _loadBones;
  71970. private _loadBone;
  71971. private _loadSkinInverseBindMatricesDataAsync;
  71972. private _updateBoneMatrices;
  71973. private _getNodeMatrix;
  71974. /**
  71975. * Loads a glTF camera.
  71976. * @param context The context when loading the asset
  71977. * @param camera The glTF camera property
  71978. * @param assign A function called synchronously after parsing the glTF properties
  71979. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  71980. */
  71981. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  71982. private _loadAnimationsAsync;
  71983. /**
  71984. * Loads a glTF animation.
  71985. * @param context The context when loading the asset
  71986. * @param animation The glTF animation property
  71987. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  71988. */
  71989. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  71990. /**
  71991. * @hidden Loads a glTF animation channel.
  71992. * @param context The context when loading the asset
  71993. * @param animationContext The context of the animation when loading the asset
  71994. * @param animation The glTF animation property
  71995. * @param channel The glTF animation channel property
  71996. * @param babylonAnimationGroup The babylon animation group property
  71997. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  71998. * @returns A void promise when the channel load is complete
  71999. */
  72000. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  72001. private _loadAnimationSamplerAsync;
  72002. private _loadBufferAsync;
  72003. /**
  72004. * Loads a glTF buffer view.
  72005. * @param context The context when loading the asset
  72006. * @param bufferView The glTF buffer view property
  72007. * @returns A promise that resolves with the loaded data when the load is complete
  72008. */
  72009. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  72010. private _loadAccessorAsync;
  72011. private _loadFloatAccessorAsync;
  72012. private _loadIndicesAccessorAsync;
  72013. private _loadVertexBufferViewAsync;
  72014. private _loadVertexAccessorAsync;
  72015. private _loadMaterialMetallicRoughnessPropertiesAsync;
  72016. /** @hidden */
  72017. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  72018. private _createDefaultMaterial;
  72019. /**
  72020. * Creates a Babylon material from a glTF material.
  72021. * @param context The context when loading the asset
  72022. * @param material The glTF material property
  72023. * @param babylonDrawMode The draw mode for the Babylon material
  72024. * @returns The Babylon material
  72025. */
  72026. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  72027. /**
  72028. * Loads properties from a glTF material into a Babylon material.
  72029. * @param context The context when loading the asset
  72030. * @param material The glTF material property
  72031. * @param babylonMaterial The Babylon material
  72032. * @returns A promise that resolves when the load is complete
  72033. */
  72034. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72035. /**
  72036. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  72037. * @param context The context when loading the asset
  72038. * @param material The glTF material property
  72039. * @param babylonMaterial The Babylon material
  72040. * @returns A promise that resolves when the load is complete
  72041. */
  72042. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72043. /**
  72044. * Loads the alpha properties from a glTF material into a Babylon material.
  72045. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  72046. * @param context The context when loading the asset
  72047. * @param material The glTF material property
  72048. * @param babylonMaterial The Babylon material
  72049. */
  72050. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  72051. /**
  72052. * Loads a glTF texture info.
  72053. * @param context The context when loading the asset
  72054. * @param textureInfo The glTF texture info property
  72055. * @param assign A function called synchronously after parsing the glTF properties
  72056. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  72057. */
  72058. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  72059. private _loadTextureAsync;
  72060. private _loadSampler;
  72061. /**
  72062. * Loads a glTF image.
  72063. * @param context The context when loading the asset
  72064. * @param image The glTF image property
  72065. * @returns A promise that resolves with the loaded data when the load is complete
  72066. */
  72067. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  72068. /**
  72069. * Loads a glTF uri.
  72070. * @param context The context when loading the asset
  72071. * @param property The glTF property associated with the uri
  72072. * @param uri The base64 or relative uri
  72073. * @returns A promise that resolves with the loaded data when the load is complete
  72074. */
  72075. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  72076. private _onProgress;
  72077. /**
  72078. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  72079. * @param babylonObject the Babylon object with metadata
  72080. * @param pointer the JSON pointer
  72081. */
  72082. static AddPointerMetadata(babylonObject: {
  72083. metadata: any;
  72084. }, pointer: string): void;
  72085. private static _GetTextureWrapMode;
  72086. private static _GetTextureSamplingMode;
  72087. private static _GetTypedArrayConstructor;
  72088. private static _GetTypedArray;
  72089. private static _GetNumComponents;
  72090. private static _ValidateUri;
  72091. private static _GetDrawMode;
  72092. private _compileMaterialsAsync;
  72093. private _compileShadowGeneratorsAsync;
  72094. private _forEachExtensions;
  72095. private _applyExtensions;
  72096. private _extensionsOnLoading;
  72097. private _extensionsOnReady;
  72098. private _extensionsLoadSceneAsync;
  72099. private _extensionsLoadNodeAsync;
  72100. private _extensionsLoadCameraAsync;
  72101. private _extensionsLoadVertexDataAsync;
  72102. private _extensionsLoadMeshPrimitiveAsync;
  72103. private _extensionsLoadMaterialAsync;
  72104. private _extensionsCreateMaterial;
  72105. private _extensionsLoadMaterialPropertiesAsync;
  72106. private _extensionsLoadTextureInfoAsync;
  72107. private _extensionsLoadAnimationAsync;
  72108. private _extensionsLoadSkinAsync;
  72109. private _extensionsLoadUriAsync;
  72110. private _extensionsLoadBufferViewAsync;
  72111. private _extensionsLoadBufferAsync;
  72112. /**
  72113. * Helper method called by a loader extension to load an glTF extension.
  72114. * @param context The context when loading the asset
  72115. * @param property The glTF property to load the extension from
  72116. * @param extensionName The name of the extension to load
  72117. * @param actionAsync The action to run
  72118. * @returns The promise returned by actionAsync or null if the extension does not exist
  72119. */
  72120. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  72121. /**
  72122. * Helper method called by a loader extension to load a glTF extra.
  72123. * @param context The context when loading the asset
  72124. * @param property The glTF property to load the extra from
  72125. * @param extensionName The name of the extension to load
  72126. * @param actionAsync The action to run
  72127. * @returns The promise returned by actionAsync or null if the extra does not exist
  72128. */
  72129. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  72130. /**
  72131. * Checks for presence of an extension.
  72132. * @param name The name of the extension to check
  72133. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  72134. */
  72135. isExtensionUsed(name: string): boolean;
  72136. /**
  72137. * Increments the indentation level and logs a message.
  72138. * @param message The message to log
  72139. */
  72140. logOpen(message: string): void;
  72141. /**
  72142. * Decrements the indentation level.
  72143. */
  72144. logClose(): void;
  72145. /**
  72146. * Logs a message
  72147. * @param message The message to log
  72148. */
  72149. log(message: string): void;
  72150. /**
  72151. * Starts a performance counter.
  72152. * @param counterName The name of the performance counter
  72153. */
  72154. startPerformanceCounter(counterName: string): void;
  72155. /**
  72156. * Ends a performance counter.
  72157. * @param counterName The name of the performance counter
  72158. */
  72159. endPerformanceCounter(counterName: string): void;
  72160. }
  72161. }
  72162. declare module BABYLON.GLTF2.Loader.Extensions {
  72163. /**
  72164. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  72165. */
  72166. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  72167. /**
  72168. * The name of this extension.
  72169. */
  72170. readonly name: string;
  72171. /**
  72172. * Defines whether this extension is enabled.
  72173. */
  72174. enabled: boolean;
  72175. private _loader;
  72176. private _lights?;
  72177. /** @hidden */
  72178. constructor(loader: GLTFLoader);
  72179. /** @hidden */
  72180. dispose(): void;
  72181. /** @hidden */
  72182. onLoading(): void;
  72183. /** @hidden */
  72184. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  72185. private _loadLightAsync;
  72186. }
  72187. }
  72188. declare module BABYLON.GLTF2.Loader.Extensions {
  72189. /**
  72190. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  72191. */
  72192. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  72193. /**
  72194. * The name of this extension.
  72195. */
  72196. readonly name: string;
  72197. /**
  72198. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  72199. */
  72200. dracoCompression?: DracoCompression;
  72201. /**
  72202. * Defines whether this extension is enabled.
  72203. */
  72204. enabled: boolean;
  72205. private _loader;
  72206. /** @hidden */
  72207. constructor(loader: GLTFLoader);
  72208. /** @hidden */
  72209. dispose(): void;
  72210. /** @hidden */
  72211. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  72212. }
  72213. }
  72214. declare module BABYLON.GLTF2.Loader.Extensions {
  72215. /**
  72216. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  72217. */
  72218. export class KHR_lights implements IGLTFLoaderExtension {
  72219. /**
  72220. * The name of this extension.
  72221. */
  72222. readonly name: string;
  72223. /**
  72224. * Defines whether this extension is enabled.
  72225. */
  72226. enabled: boolean;
  72227. private _loader;
  72228. private _lights?;
  72229. /** @hidden */
  72230. constructor(loader: GLTFLoader);
  72231. /** @hidden */
  72232. dispose(): void;
  72233. /** @hidden */
  72234. onLoading(): void;
  72235. /** @hidden */
  72236. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72237. }
  72238. }
  72239. declare module BABYLON.GLTF2.Loader.Extensions {
  72240. /**
  72241. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  72242. */
  72243. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  72244. /**
  72245. * The name of this extension.
  72246. */
  72247. readonly name: string;
  72248. /**
  72249. * Defines whether this extension is enabled.
  72250. */
  72251. enabled: boolean;
  72252. /**
  72253. * Defines a number that determines the order the extensions are applied.
  72254. */
  72255. order: number;
  72256. private _loader;
  72257. /** @hidden */
  72258. constructor(loader: GLTFLoader);
  72259. /** @hidden */
  72260. dispose(): void;
  72261. /** @hidden */
  72262. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72263. private _loadSpecularGlossinessPropertiesAsync;
  72264. }
  72265. }
  72266. declare module BABYLON.GLTF2.Loader.Extensions {
  72267. /**
  72268. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  72269. */
  72270. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  72271. /**
  72272. * The name of this extension.
  72273. */
  72274. readonly name: string;
  72275. /**
  72276. * Defines whether this extension is enabled.
  72277. */
  72278. enabled: boolean;
  72279. /**
  72280. * Defines a number that determines the order the extensions are applied.
  72281. */
  72282. order: number;
  72283. private _loader;
  72284. /** @hidden */
  72285. constructor(loader: GLTFLoader);
  72286. /** @hidden */
  72287. dispose(): void;
  72288. /** @hidden */
  72289. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72290. private _loadUnlitPropertiesAsync;
  72291. }
  72292. }
  72293. declare module BABYLON.GLTF2.Loader.Extensions {
  72294. /**
  72295. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  72296. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  72297. * !!! Experimental Extension Subject to Changes !!!
  72298. */
  72299. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  72300. /**
  72301. * The name of this extension.
  72302. */
  72303. readonly name: string;
  72304. /**
  72305. * Defines whether this extension is enabled.
  72306. */
  72307. enabled: boolean;
  72308. /**
  72309. * Defines a number that determines the order the extensions are applied.
  72310. */
  72311. order: number;
  72312. private _loader;
  72313. /** @hidden */
  72314. constructor(loader: GLTFLoader);
  72315. /** @hidden */
  72316. dispose(): void;
  72317. /** @hidden */
  72318. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72319. private _loadClearCoatPropertiesAsync;
  72320. }
  72321. }
  72322. declare module BABYLON.GLTF2.Loader.Extensions {
  72323. /**
  72324. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  72325. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  72326. * !!! Experimental Extension Subject to Changes !!!
  72327. */
  72328. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  72329. /**
  72330. * The name of this extension.
  72331. */
  72332. readonly name: string;
  72333. /**
  72334. * Defines whether this extension is enabled.
  72335. */
  72336. enabled: boolean;
  72337. /**
  72338. * Defines a number that determines the order the extensions are applied.
  72339. */
  72340. order: number;
  72341. private _loader;
  72342. /** @hidden */
  72343. constructor(loader: GLTFLoader);
  72344. /** @hidden */
  72345. dispose(): void;
  72346. /** @hidden */
  72347. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72348. private _loadSheenPropertiesAsync;
  72349. }
  72350. }
  72351. declare module BABYLON.GLTF2.Loader.Extensions {
  72352. /**
  72353. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  72354. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  72355. * !!! Experimental Extension Subject to Changes !!!
  72356. */
  72357. export class KHR_materials_specular implements IGLTFLoaderExtension {
  72358. /**
  72359. * The name of this extension.
  72360. */
  72361. readonly name: string;
  72362. /**
  72363. * Defines whether this extension is enabled.
  72364. */
  72365. enabled: boolean;
  72366. /**
  72367. * Defines a number that determines the order the extensions are applied.
  72368. */
  72369. order: number;
  72370. private _loader;
  72371. /** @hidden */
  72372. constructor(loader: GLTFLoader);
  72373. /** @hidden */
  72374. dispose(): void;
  72375. /** @hidden */
  72376. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72377. private _loadSpecularPropertiesAsync;
  72378. }
  72379. }
  72380. declare module BABYLON.GLTF2.Loader.Extensions {
  72381. /**
  72382. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  72383. */
  72384. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  72385. /**
  72386. * The name of this extension.
  72387. */
  72388. readonly name: string;
  72389. /**
  72390. * Defines whether this extension is enabled.
  72391. */
  72392. enabled: boolean;
  72393. /** @hidden */
  72394. constructor(loader: GLTFLoader);
  72395. /** @hidden */
  72396. dispose(): void;
  72397. }
  72398. }
  72399. declare module BABYLON.GLTF2.Loader.Extensions {
  72400. /**
  72401. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  72402. */
  72403. export class KHR_texture_transform implements IGLTFLoaderExtension {
  72404. /**
  72405. * The name of this extension.
  72406. */
  72407. readonly name: string;
  72408. /**
  72409. * Defines whether this extension is enabled.
  72410. */
  72411. enabled: boolean;
  72412. private _loader;
  72413. /** @hidden */
  72414. constructor(loader: GLTFLoader);
  72415. /** @hidden */
  72416. dispose(): void;
  72417. /** @hidden */
  72418. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  72419. }
  72420. }
  72421. declare module BABYLON.GLTF2.Loader.Extensions {
  72422. /**
  72423. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  72424. */
  72425. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  72426. /**
  72427. * The name of this extension.
  72428. */
  72429. readonly name: string;
  72430. /**
  72431. * Defines whether this extension is enabled.
  72432. */
  72433. enabled: boolean;
  72434. private _loader;
  72435. private _clips;
  72436. private _emitters;
  72437. /** @hidden */
  72438. constructor(loader: GLTFLoader);
  72439. /** @hidden */
  72440. dispose(): void;
  72441. /** @hidden */
  72442. onLoading(): void;
  72443. /** @hidden */
  72444. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  72445. /** @hidden */
  72446. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72447. /** @hidden */
  72448. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  72449. private _loadClipAsync;
  72450. private _loadEmitterAsync;
  72451. private _getEventAction;
  72452. private _loadAnimationEventAsync;
  72453. }
  72454. }
  72455. declare module BABYLON.GLTF2.Loader.Extensions {
  72456. /**
  72457. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  72458. */
  72459. export class MSFT_lod implements IGLTFLoaderExtension {
  72460. /**
  72461. * The name of this extension.
  72462. */
  72463. readonly name: string;
  72464. /**
  72465. * Defines whether this extension is enabled.
  72466. */
  72467. enabled: boolean;
  72468. /**
  72469. * Defines a number that determines the order the extensions are applied.
  72470. */
  72471. order: number;
  72472. /**
  72473. * Maximum number of LODs to load, starting from the lowest LOD.
  72474. */
  72475. maxLODsToLoad: number;
  72476. /**
  72477. * Observable raised when all node LODs of one level are loaded.
  72478. * The event data is the index of the loaded LOD starting from zero.
  72479. * Dispose the loader to cancel the loading of the next level of LODs.
  72480. */
  72481. onNodeLODsLoadedObservable: Observable<number>;
  72482. /**
  72483. * Observable raised when all material LODs of one level are loaded.
  72484. * The event data is the index of the loaded LOD starting from zero.
  72485. * Dispose the loader to cancel the loading of the next level of LODs.
  72486. */
  72487. onMaterialLODsLoadedObservable: Observable<number>;
  72488. private _loader;
  72489. private _nodeIndexLOD;
  72490. private _nodeSignalLODs;
  72491. private _nodePromiseLODs;
  72492. private _materialIndexLOD;
  72493. private _materialSignalLODs;
  72494. private _materialPromiseLODs;
  72495. private _indexLOD;
  72496. private _bufferLODs;
  72497. /** @hidden */
  72498. constructor(loader: GLTFLoader);
  72499. /** @hidden */
  72500. dispose(): void;
  72501. /** @hidden */
  72502. onReady(): void;
  72503. /** @hidden */
  72504. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72505. /** @hidden */
  72506. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  72507. /** @hidden */
  72508. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  72509. /** @hidden */
  72510. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  72511. private _loadBufferLOD;
  72512. /**
  72513. * Gets an array of LOD properties from lowest to highest.
  72514. */
  72515. private _getLODs;
  72516. private _disposeUnusedMaterials;
  72517. }
  72518. }
  72519. declare module BABYLON.GLTF2.Loader.Extensions {
  72520. /** @hidden */
  72521. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  72522. readonly name: string;
  72523. enabled: boolean;
  72524. private _loader;
  72525. constructor(loader: GLTFLoader);
  72526. dispose(): void;
  72527. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72528. }
  72529. }
  72530. declare module BABYLON.GLTF2.Loader.Extensions {
  72531. /** @hidden */
  72532. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  72533. readonly name: string;
  72534. enabled: boolean;
  72535. private _loader;
  72536. constructor(loader: GLTFLoader);
  72537. dispose(): void;
  72538. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72539. }
  72540. }
  72541. declare module BABYLON.GLTF2.Loader.Extensions {
  72542. /**
  72543. * Store glTF extras (if present) in BJS objects' metadata
  72544. */
  72545. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  72546. /**
  72547. * The name of this extension.
  72548. */
  72549. readonly name: string;
  72550. /**
  72551. * Defines whether this extension is enabled.
  72552. */
  72553. enabled: boolean;
  72554. private _loader;
  72555. private _assignExtras;
  72556. /** @hidden */
  72557. constructor(loader: GLTFLoader);
  72558. /** @hidden */
  72559. dispose(): void;
  72560. /** @hidden */
  72561. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72562. /** @hidden */
  72563. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  72564. /** @hidden */
  72565. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  72566. }
  72567. }
  72568. declare module BABYLON {
  72569. /**
  72570. * Class reading and parsing the MTL file bundled with the obj file.
  72571. */
  72572. export class MTLFileLoader {
  72573. /**
  72574. * All material loaded from the mtl will be set here
  72575. */
  72576. materials: StandardMaterial[];
  72577. /**
  72578. * This function will read the mtl file and create each material described inside
  72579. * This function could be improve by adding :
  72580. * -some component missing (Ni, Tf...)
  72581. * -including the specific options available
  72582. *
  72583. * @param scene defines the scene the material will be created in
  72584. * @param data defines the mtl data to parse
  72585. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  72586. */
  72587. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  72588. /**
  72589. * Gets the texture for the material.
  72590. *
  72591. * If the material is imported from input file,
  72592. * We sanitize the url to ensure it takes the textre from aside the material.
  72593. *
  72594. * @param rootUrl The root url to load from
  72595. * @param value The value stored in the mtl
  72596. * @return The Texture
  72597. */
  72598. private static _getTexture;
  72599. }
  72600. /**
  72601. * Options for loading OBJ/MTL files
  72602. */
  72603. type MeshLoadOptions = {
  72604. /**
  72605. * Defines if UVs are optimized by default during load.
  72606. */
  72607. OptimizeWithUV: boolean;
  72608. /**
  72609. * Defines custom scaling of UV coordinates of loaded meshes.
  72610. */
  72611. UVScaling: Vector2;
  72612. /**
  72613. * Invert model on y-axis (does a model scaling inversion)
  72614. */
  72615. InvertY: boolean;
  72616. /**
  72617. * Invert Y-Axis of referenced textures on load
  72618. */
  72619. InvertTextureY: boolean;
  72620. /**
  72621. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  72622. */
  72623. ImportVertexColors: boolean;
  72624. /**
  72625. * Compute the normals for the model, even if normals are present in the file.
  72626. */
  72627. ComputeNormals: boolean;
  72628. /**
  72629. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  72630. */
  72631. SkipMaterials: boolean;
  72632. /**
  72633. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  72634. */
  72635. MaterialLoadingFailsSilently: boolean;
  72636. };
  72637. /**
  72638. * OBJ file type loader.
  72639. * This is a babylon scene loader plugin.
  72640. */
  72641. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  72642. /**
  72643. * Defines if UVs are optimized by default during load.
  72644. */
  72645. static OPTIMIZE_WITH_UV: boolean;
  72646. /**
  72647. * Invert model on y-axis (does a model scaling inversion)
  72648. */
  72649. static INVERT_Y: boolean;
  72650. /**
  72651. * Invert Y-Axis of referenced textures on load
  72652. */
  72653. static INVERT_TEXTURE_Y: boolean;
  72654. /**
  72655. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  72656. */
  72657. static IMPORT_VERTEX_COLORS: boolean;
  72658. /**
  72659. * Compute the normals for the model, even if normals are present in the file.
  72660. */
  72661. static COMPUTE_NORMALS: boolean;
  72662. /**
  72663. * Defines custom scaling of UV coordinates of loaded meshes.
  72664. */
  72665. static UV_SCALING: Vector2;
  72666. /**
  72667. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  72668. */
  72669. static SKIP_MATERIALS: boolean;
  72670. /**
  72671. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  72672. *
  72673. * Defaults to true for backwards compatibility.
  72674. */
  72675. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  72676. /**
  72677. * Defines the name of the plugin.
  72678. */
  72679. name: string;
  72680. /**
  72681. * Defines the extension the plugin is able to load.
  72682. */
  72683. extensions: string;
  72684. /** @hidden */
  72685. obj: RegExp;
  72686. /** @hidden */
  72687. group: RegExp;
  72688. /** @hidden */
  72689. mtllib: RegExp;
  72690. /** @hidden */
  72691. usemtl: RegExp;
  72692. /** @hidden */
  72693. smooth: RegExp;
  72694. /** @hidden */
  72695. vertexPattern: RegExp;
  72696. /** @hidden */
  72697. normalPattern: RegExp;
  72698. /** @hidden */
  72699. uvPattern: RegExp;
  72700. /** @hidden */
  72701. facePattern1: RegExp;
  72702. /** @hidden */
  72703. facePattern2: RegExp;
  72704. /** @hidden */
  72705. facePattern3: RegExp;
  72706. /** @hidden */
  72707. facePattern4: RegExp;
  72708. /** @hidden */
  72709. facePattern5: RegExp;
  72710. private _meshLoadOptions;
  72711. /**
  72712. * Creates loader for .OBJ files
  72713. *
  72714. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  72715. */
  72716. constructor(meshLoadOptions?: MeshLoadOptions);
  72717. private static readonly currentMeshLoadOptions;
  72718. /**
  72719. * Calls synchronously the MTL file attached to this obj.
  72720. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  72721. * Without this function materials are not displayed in the first frame (but displayed after).
  72722. * In consequence it is impossible to get material information in your HTML file
  72723. *
  72724. * @param url The URL of the MTL file
  72725. * @param rootUrl
  72726. * @param onSuccess Callback function to be called when the MTL file is loaded
  72727. * @private
  72728. */
  72729. private _loadMTL;
  72730. /**
  72731. * Instantiates a OBJ file loader plugin.
  72732. * @returns the created plugin
  72733. */
  72734. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  72735. /**
  72736. * If the data string can be loaded directly.
  72737. *
  72738. * @param data string containing the file data
  72739. * @returns if the data can be loaded directly
  72740. */
  72741. canDirectLoad(data: string): boolean;
  72742. /**
  72743. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  72744. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  72745. * @param scene the scene the meshes should be added to
  72746. * @param data the OBJ data to load
  72747. * @param rootUrl root url to load from
  72748. * @param onProgress event that fires when loading progress has occured
  72749. * @param fileName Defines the name of the file to load
  72750. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  72751. */
  72752. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  72753. meshes: AbstractMesh[];
  72754. particleSystems: IParticleSystem[];
  72755. skeletons: Skeleton[];
  72756. animationGroups: AnimationGroup[];
  72757. }>;
  72758. /**
  72759. * Imports all objects from the loaded OBJ data and adds them to the scene
  72760. * @param scene the scene the objects should be added to
  72761. * @param data the OBJ data to load
  72762. * @param rootUrl root url to load from
  72763. * @param onProgress event that fires when loading progress has occured
  72764. * @param fileName Defines the name of the file to load
  72765. * @returns a promise which completes when objects have been loaded to the scene
  72766. */
  72767. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  72768. /**
  72769. * Load into an asset container.
  72770. * @param scene The scene to load into
  72771. * @param data The data to import
  72772. * @param rootUrl The root url for scene and resources
  72773. * @param onProgress The callback when the load progresses
  72774. * @param fileName Defines the name of the file to load
  72775. * @returns The loaded asset container
  72776. */
  72777. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  72778. /**
  72779. * Read the OBJ file and create an Array of meshes.
  72780. * Each mesh contains all information given by the OBJ and the MTL file.
  72781. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  72782. *
  72783. * @param meshesNames
  72784. * @param scene Scene The scene where are displayed the data
  72785. * @param data String The content of the obj file
  72786. * @param rootUrl String The path to the folder
  72787. * @returns Array<AbstractMesh>
  72788. * @private
  72789. */
  72790. private _parseSolid;
  72791. }
  72792. }
  72793. declare module BABYLON {
  72794. /**
  72795. * STL file type loader.
  72796. * This is a babylon scene loader plugin.
  72797. */
  72798. export class STLFileLoader implements ISceneLoaderPlugin {
  72799. /** @hidden */
  72800. solidPattern: RegExp;
  72801. /** @hidden */
  72802. facetsPattern: RegExp;
  72803. /** @hidden */
  72804. normalPattern: RegExp;
  72805. /** @hidden */
  72806. vertexPattern: RegExp;
  72807. /**
  72808. * Defines the name of the plugin.
  72809. */
  72810. name: string;
  72811. /**
  72812. * Defines the extensions the stl loader is able to load.
  72813. * force data to come in as an ArrayBuffer
  72814. * we'll convert to string if it looks like it's an ASCII .stl
  72815. */
  72816. extensions: ISceneLoaderPluginExtensions;
  72817. /**
  72818. * Import meshes into a scene.
  72819. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  72820. * @param scene The scene to import into
  72821. * @param data The data to import
  72822. * @param rootUrl The root url for scene and resources
  72823. * @param meshes The meshes array to import into
  72824. * @param particleSystems The particle systems array to import into
  72825. * @param skeletons The skeletons array to import into
  72826. * @param onError The callback when import fails
  72827. * @returns True if successful or false otherwise
  72828. */
  72829. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  72830. /**
  72831. * Load into a scene.
  72832. * @param scene The scene to load into
  72833. * @param data The data to import
  72834. * @param rootUrl The root url for scene and resources
  72835. * @param onError The callback when import fails
  72836. * @returns true if successful or false otherwise
  72837. */
  72838. load(scene: Scene, data: any, rootUrl: string): boolean;
  72839. /**
  72840. * Load into an asset container.
  72841. * @param scene The scene to load into
  72842. * @param data The data to import
  72843. * @param rootUrl The root url for scene and resources
  72844. * @param onError The callback when import fails
  72845. * @returns The loaded asset container
  72846. */
  72847. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  72848. private _isBinary;
  72849. private _parseBinary;
  72850. private _parseASCII;
  72851. }
  72852. }
  72853. declare module BABYLON {
  72854. /**
  72855. * Class for generating OBJ data from a Babylon scene.
  72856. */
  72857. export class OBJExport {
  72858. /**
  72859. * Exports the geometry of a Mesh array in .OBJ file format (text)
  72860. * @param mesh defines the list of meshes to serialize
  72861. * @param materials defines if materials should be exported
  72862. * @param matlibname defines the name of the associated mtl file
  72863. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  72864. * @returns the OBJ content
  72865. */
  72866. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  72867. /**
  72868. * Exports the material(s) of a mesh in .MTL file format (text)
  72869. * @param mesh defines the mesh to extract the material from
  72870. * @returns the mtl content
  72871. */
  72872. static MTL(mesh: Mesh): string;
  72873. }
  72874. }
  72875. declare module BABYLON {
  72876. /** @hidden */
  72877. export var __IGLTFExporterExtension: number;
  72878. /**
  72879. * Interface for extending the exporter
  72880. * @hidden
  72881. */
  72882. export interface IGLTFExporterExtension {
  72883. /**
  72884. * The name of this extension
  72885. */
  72886. readonly name: string;
  72887. /**
  72888. * Defines whether this extension is enabled
  72889. */
  72890. enabled: boolean;
  72891. /**
  72892. * Defines whether this extension is required
  72893. */
  72894. required: boolean;
  72895. }
  72896. }
  72897. declare module BABYLON.GLTF2.Exporter {
  72898. /** @hidden */
  72899. export var __IGLTFExporterExtensionV2: number;
  72900. /**
  72901. * Interface for a glTF exporter extension
  72902. * @hidden
  72903. */
  72904. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  72905. /**
  72906. * Define this method to modify the default behavior before exporting a texture
  72907. * @param context The context when loading the asset
  72908. * @param babylonTexture The Babylon.js texture
  72909. * @param mimeType The mime-type of the generated image
  72910. * @returns A promise that resolves with the exported texture
  72911. */
  72912. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  72913. /**
  72914. * Define this method to get notified when a texture info is created
  72915. * @param context The context when loading the asset
  72916. * @param textureInfo The glTF texture info
  72917. * @param babylonTexture The Babylon.js texture
  72918. */
  72919. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  72920. /**
  72921. * Define this method to modify the default behavior when exporting texture info
  72922. * @param context The context when loading the asset
  72923. * @param meshPrimitive glTF mesh primitive
  72924. * @param babylonSubMesh Babylon submesh
  72925. * @param binaryWriter glTF serializer binary writer instance
  72926. * @returns nullable IMeshPrimitive promise
  72927. */
  72928. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  72929. /**
  72930. * Define this method to modify the default behavior when exporting a node
  72931. * @param context The context when exporting the node
  72932. * @param node glTF node
  72933. * @param babylonNode BabylonJS node
  72934. * @returns nullable INode promise
  72935. */
  72936. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  72937. /**
  72938. * Define this method to modify the default behavior when exporting a material
  72939. * @param material glTF material
  72940. * @param babylonMaterial BabylonJS material
  72941. * @returns nullable IMaterial promise
  72942. */
  72943. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  72944. /**
  72945. * Define this method to return additional textures to export from a material
  72946. * @param material glTF material
  72947. * @param babylonMaterial BabylonJS material
  72948. * @returns List of textures
  72949. */
  72950. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  72951. /** Gets a boolean indicating that this extension was used */
  72952. wasUsed: boolean;
  72953. /** Gets a boolean indicating that this extension is required for the file to work */
  72954. required: boolean;
  72955. /**
  72956. * Called after the exporter state changes to EXPORTING
  72957. */
  72958. onExporting?(): void;
  72959. }
  72960. }
  72961. declare module BABYLON.GLTF2.Exporter {
  72962. /**
  72963. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  72964. * @hidden
  72965. */
  72966. export class _GLTFMaterialExporter {
  72967. /**
  72968. * Represents the dielectric specular values for R, G and B
  72969. */
  72970. private static readonly _DielectricSpecular;
  72971. /**
  72972. * Allows the maximum specular power to be defined for material calculations
  72973. */
  72974. private static readonly _MaxSpecularPower;
  72975. /**
  72976. * Mapping to store textures
  72977. */
  72978. private _textureMap;
  72979. /**
  72980. * Numeric tolerance value
  72981. */
  72982. private static readonly _Epsilon;
  72983. /**
  72984. * Reference to the glTF Exporter
  72985. */
  72986. private _exporter;
  72987. constructor(exporter: _Exporter);
  72988. /**
  72989. * Specifies if two colors are approximately equal in value
  72990. * @param color1 first color to compare to
  72991. * @param color2 second color to compare to
  72992. * @param epsilon threshold value
  72993. */
  72994. private static FuzzyEquals;
  72995. /**
  72996. * Gets the materials from a Babylon scene and converts them to glTF materials
  72997. * @param scene babylonjs scene
  72998. * @param mimeType texture mime type
  72999. * @param images array of images
  73000. * @param textures array of textures
  73001. * @param materials array of materials
  73002. * @param imageData mapping of texture names to base64 textures
  73003. * @param hasTextureCoords specifies if texture coordinates are present on the material
  73004. */
  73005. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  73006. /**
  73007. * Makes a copy of the glTF material without the texture parameters
  73008. * @param originalMaterial original glTF material
  73009. * @returns glTF material without texture parameters
  73010. */
  73011. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  73012. /**
  73013. * Specifies if the material has any texture parameters present
  73014. * @param material glTF Material
  73015. * @returns boolean specifying if texture parameters are present
  73016. */
  73017. _hasTexturesPresent(material: IMaterial): boolean;
  73018. /**
  73019. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  73020. * @param babylonStandardMaterial
  73021. * @returns glTF Metallic Roughness Material representation
  73022. */
  73023. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  73024. /**
  73025. * Computes the metallic factor
  73026. * @param diffuse diffused value
  73027. * @param specular specular value
  73028. * @param oneMinusSpecularStrength one minus the specular strength
  73029. * @returns metallic value
  73030. */
  73031. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  73032. /**
  73033. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  73034. * @param glTFMaterial glTF material
  73035. * @param babylonMaterial Babylon material
  73036. */
  73037. private static _SetAlphaMode;
  73038. /**
  73039. * Converts a Babylon Standard Material to a glTF Material
  73040. * @param babylonStandardMaterial BJS Standard Material
  73041. * @param mimeType mime type to use for the textures
  73042. * @param images array of glTF image interfaces
  73043. * @param textures array of glTF texture interfaces
  73044. * @param materials array of glTF material interfaces
  73045. * @param imageData map of image file name to data
  73046. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73047. */
  73048. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73049. private _finishMaterial;
  73050. /**
  73051. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  73052. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  73053. * @param mimeType mime type to use for the textures
  73054. * @param images array of glTF image interfaces
  73055. * @param textures array of glTF texture interfaces
  73056. * @param materials array of glTF material interfaces
  73057. * @param imageData map of image file name to data
  73058. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73059. */
  73060. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73061. /**
  73062. * Converts an image typed array buffer to a base64 image
  73063. * @param buffer typed array buffer
  73064. * @param width width of the image
  73065. * @param height height of the image
  73066. * @param mimeType mimetype of the image
  73067. * @returns base64 image string
  73068. */
  73069. private _createBase64FromCanvasAsync;
  73070. /**
  73071. * Generates a white texture based on the specified width and height
  73072. * @param width width of the texture in pixels
  73073. * @param height height of the texture in pixels
  73074. * @param scene babylonjs scene
  73075. * @returns white texture
  73076. */
  73077. private _createWhiteTexture;
  73078. /**
  73079. * 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
  73080. * @param texture1 first texture to resize
  73081. * @param texture2 second texture to resize
  73082. * @param scene babylonjs scene
  73083. * @returns resized textures or null
  73084. */
  73085. private _resizeTexturesToSameDimensions;
  73086. /**
  73087. * Converts an array of pixels to a Float32Array
  73088. * Throws an error if the pixel format is not supported
  73089. * @param pixels - array buffer containing pixel values
  73090. * @returns Float32 of pixels
  73091. */
  73092. private _convertPixelArrayToFloat32;
  73093. /**
  73094. * Convert Specular Glossiness Textures to Metallic Roughness
  73095. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  73096. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  73097. * @param diffuseTexture texture used to store diffuse information
  73098. * @param specularGlossinessTexture texture used to store specular and glossiness information
  73099. * @param factors specular glossiness material factors
  73100. * @param mimeType the mime type to use for the texture
  73101. * @returns pbr metallic roughness interface or null
  73102. */
  73103. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  73104. /**
  73105. * Converts specular glossiness material properties to metallic roughness
  73106. * @param specularGlossiness interface with specular glossiness material properties
  73107. * @returns interface with metallic roughness material properties
  73108. */
  73109. private _convertSpecularGlossinessToMetallicRoughness;
  73110. /**
  73111. * Calculates the surface reflectance, independent of lighting conditions
  73112. * @param color Color source to calculate brightness from
  73113. * @returns number representing the perceived brightness, or zero if color is undefined
  73114. */
  73115. private _getPerceivedBrightness;
  73116. /**
  73117. * Returns the maximum color component value
  73118. * @param color
  73119. * @returns maximum color component value, or zero if color is null or undefined
  73120. */
  73121. private _getMaxComponent;
  73122. /**
  73123. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  73124. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  73125. * @param mimeType mime type to use for the textures
  73126. * @param images array of glTF image interfaces
  73127. * @param textures array of glTF texture interfaces
  73128. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  73129. * @param imageData map of image file name to data
  73130. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73131. * @returns glTF PBR Metallic Roughness factors
  73132. */
  73133. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  73134. private _getGLTFTextureSampler;
  73135. private _getGLTFTextureWrapMode;
  73136. private _getGLTFTextureWrapModesSampler;
  73137. /**
  73138. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  73139. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  73140. * @param mimeType mime type to use for the textures
  73141. * @param images array of glTF image interfaces
  73142. * @param textures array of glTF texture interfaces
  73143. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  73144. * @param imageData map of image file name to data
  73145. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73146. * @returns glTF PBR Metallic Roughness factors
  73147. */
  73148. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  73149. /**
  73150. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  73151. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  73152. * @param mimeType mime type to use for the textures
  73153. * @param images array of glTF image interfaces
  73154. * @param textures array of glTF texture interfaces
  73155. * @param materials array of glTF material interfaces
  73156. * @param imageData map of image file name to data
  73157. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73158. */
  73159. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73160. private setMetallicRoughnessPbrMaterial;
  73161. private getPixelsFromTexture;
  73162. /**
  73163. * Extracts a texture from a Babylon texture into file data and glTF data
  73164. * @param babylonTexture Babylon texture to extract
  73165. * @param mimeType Mime Type of the babylonTexture
  73166. * @return glTF texture info, or null if the texture format is not supported
  73167. */
  73168. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  73169. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  73170. /**
  73171. * Builds a texture from base64 string
  73172. * @param base64Texture base64 texture string
  73173. * @param baseTextureName Name to use for the texture
  73174. * @param mimeType image mime type for the texture
  73175. * @param images array of images
  73176. * @param textures array of textures
  73177. * @param imageData map of image data
  73178. * @returns glTF texture info, or null if the texture format is not supported
  73179. */
  73180. private _getTextureInfoFromBase64;
  73181. }
  73182. }
  73183. declare module BABYLON {
  73184. /**
  73185. * Class for holding and downloading glTF file data
  73186. */
  73187. export class GLTFData {
  73188. /**
  73189. * Object which contains the file name as the key and its data as the value
  73190. */
  73191. glTFFiles: {
  73192. [fileName: string]: string | Blob;
  73193. };
  73194. /**
  73195. * Initializes the glTF file object
  73196. */
  73197. constructor();
  73198. /**
  73199. * Downloads the glTF data as files based on their names and data
  73200. */
  73201. downloadFiles(): void;
  73202. }
  73203. }
  73204. declare module BABYLON {
  73205. /**
  73206. * Holds a collection of exporter options and parameters
  73207. */
  73208. export interface IExportOptions {
  73209. /**
  73210. * Function which indicates whether a babylon node should be exported or not
  73211. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  73212. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  73213. */
  73214. shouldExportNode?(node: Node): boolean;
  73215. /**
  73216. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  73217. * @param metadata source metadata to read from
  73218. * @returns the data to store to glTF node extras
  73219. */
  73220. metadataSelector?(metadata: any): any;
  73221. /**
  73222. * The sample rate to bake animation curves
  73223. */
  73224. animationSampleRate?: number;
  73225. /**
  73226. * Begin serialization without waiting for the scene to be ready
  73227. */
  73228. exportWithoutWaitingForScene?: boolean;
  73229. }
  73230. /**
  73231. * Class for generating glTF data from a Babylon scene.
  73232. */
  73233. export class GLTF2Export {
  73234. /**
  73235. * Exports the geometry of the scene to .gltf file format asynchronously
  73236. * @param scene Babylon scene with scene hierarchy information
  73237. * @param filePrefix File prefix to use when generating the glTF file
  73238. * @param options Exporter options
  73239. * @returns Returns an object with a .gltf file and associates texture names
  73240. * as keys and their data and paths as values
  73241. */
  73242. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  73243. private static _PreExportAsync;
  73244. private static _PostExportAsync;
  73245. /**
  73246. * Exports the geometry of the scene to .glb file format asychronously
  73247. * @param scene Babylon scene with scene hierarchy information
  73248. * @param filePrefix File prefix to use when generating glb file
  73249. * @param options Exporter options
  73250. * @returns Returns an object with a .glb filename as key and data as value
  73251. */
  73252. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  73253. }
  73254. }
  73255. declare module BABYLON.GLTF2.Exporter {
  73256. /**
  73257. * @hidden
  73258. */
  73259. export class _GLTFUtilities {
  73260. /**
  73261. * Creates a buffer view based on the supplied arguments
  73262. * @param bufferIndex index value of the specified buffer
  73263. * @param byteOffset byte offset value
  73264. * @param byteLength byte length of the bufferView
  73265. * @param byteStride byte distance between conequential elements
  73266. * @param name name of the buffer view
  73267. * @returns bufferView for glTF
  73268. */
  73269. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  73270. /**
  73271. * Creates an accessor based on the supplied arguments
  73272. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  73273. * @param name The name of the accessor
  73274. * @param type The type of the accessor
  73275. * @param componentType The datatype of components in the attribute
  73276. * @param count The number of attributes referenced by this accessor
  73277. * @param byteOffset The offset relative to the start of the bufferView in bytes
  73278. * @param min Minimum value of each component in this attribute
  73279. * @param max Maximum value of each component in this attribute
  73280. * @returns accessor for glTF
  73281. */
  73282. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  73283. /**
  73284. * Calculates the minimum and maximum values of an array of position floats
  73285. * @param positions Positions array of a mesh
  73286. * @param vertexStart Starting vertex offset to calculate min and max values
  73287. * @param vertexCount Number of vertices to check for min and max values
  73288. * @returns min number array and max number array
  73289. */
  73290. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  73291. min: number[];
  73292. max: number[];
  73293. };
  73294. /**
  73295. * Converts a new right-handed Vector3
  73296. * @param vector vector3 array
  73297. * @returns right-handed Vector3
  73298. */
  73299. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  73300. /**
  73301. * Converts a Vector3 to right-handed
  73302. * @param vector Vector3 to convert to right-handed
  73303. */
  73304. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  73305. /**
  73306. * Converts a three element number array to right-handed
  73307. * @param vector number array to convert to right-handed
  73308. */
  73309. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  73310. /**
  73311. * Converts a new right-handed Vector3
  73312. * @param vector vector3 array
  73313. * @returns right-handed Vector3
  73314. */
  73315. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  73316. /**
  73317. * Converts a Vector3 to right-handed
  73318. * @param vector Vector3 to convert to right-handed
  73319. */
  73320. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  73321. /**
  73322. * Converts a three element number array to right-handed
  73323. * @param vector number array to convert to right-handed
  73324. */
  73325. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  73326. /**
  73327. * Converts a Vector4 to right-handed
  73328. * @param vector Vector4 to convert to right-handed
  73329. */
  73330. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  73331. /**
  73332. * Converts a Vector4 to right-handed
  73333. * @param vector Vector4 to convert to right-handed
  73334. */
  73335. static _GetRightHandedArray4FromRef(vector: number[]): void;
  73336. /**
  73337. * Converts a Quaternion to right-handed
  73338. * @param quaternion Source quaternion to convert to right-handed
  73339. */
  73340. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  73341. /**
  73342. * Converts a Quaternion to right-handed
  73343. * @param quaternion Source quaternion to convert to right-handed
  73344. */
  73345. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  73346. static _NormalizeTangentFromRef(tangent: Vector4): void;
  73347. }
  73348. }
  73349. declare module BABYLON.GLTF2.Exporter {
  73350. /**
  73351. * Converts Babylon Scene into glTF 2.0.
  73352. * @hidden
  73353. */
  73354. export class _Exporter {
  73355. /**
  73356. * Stores the glTF to export
  73357. */
  73358. _glTF: IGLTF;
  73359. /**
  73360. * Stores all generated buffer views, which represents views into the main glTF buffer data
  73361. */
  73362. _bufferViews: IBufferView[];
  73363. /**
  73364. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  73365. */
  73366. _accessors: IAccessor[];
  73367. /**
  73368. * Stores all the generated nodes, which contains transform and/or mesh information per node
  73369. */
  73370. private _nodes;
  73371. /**
  73372. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  73373. */
  73374. private _scenes;
  73375. /**
  73376. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  73377. */
  73378. private _meshes;
  73379. /**
  73380. * Stores all the generated material information, which represents the appearance of each primitive
  73381. */
  73382. _materials: IMaterial[];
  73383. _materialMap: {
  73384. [materialID: number]: number;
  73385. };
  73386. /**
  73387. * Stores all the generated texture information, which is referenced by glTF materials
  73388. */
  73389. _textures: ITexture[];
  73390. /**
  73391. * Stores all the generated image information, which is referenced by glTF textures
  73392. */
  73393. _images: IImage[];
  73394. /**
  73395. * Stores all the texture samplers
  73396. */
  73397. _samplers: ISampler[];
  73398. /**
  73399. * Stores all the generated animation samplers, which is referenced by glTF animations
  73400. */
  73401. /**
  73402. * Stores the animations for glTF models
  73403. */
  73404. private _animations;
  73405. /**
  73406. * Stores the total amount of bytes stored in the glTF buffer
  73407. */
  73408. private _totalByteLength;
  73409. /**
  73410. * Stores a reference to the Babylon scene containing the source geometry and material information
  73411. */
  73412. _babylonScene: Scene;
  73413. /**
  73414. * Stores a map of the image data, where the key is the file name and the value
  73415. * is the image data
  73416. */
  73417. _imageData: {
  73418. [fileName: string]: {
  73419. data: Uint8Array;
  73420. mimeType: ImageMimeType;
  73421. };
  73422. };
  73423. /**
  73424. * Stores a map of the unique id of a node to its index in the node array
  73425. */
  73426. private _nodeMap;
  73427. /**
  73428. * Specifies if the Babylon scene should be converted to right-handed on export
  73429. */
  73430. _convertToRightHandedSystem: boolean;
  73431. /**
  73432. * Baked animation sample rate
  73433. */
  73434. private _animationSampleRate;
  73435. private _options;
  73436. private _localEngine;
  73437. _glTFMaterialExporter: _GLTFMaterialExporter;
  73438. private _extensions;
  73439. private static _ExtensionNames;
  73440. private static _ExtensionFactories;
  73441. private _applyExtension;
  73442. private _applyExtensions;
  73443. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  73444. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  73445. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  73446. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  73447. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  73448. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  73449. private _forEachExtensions;
  73450. private _extensionsOnExporting;
  73451. /**
  73452. * Load glTF serializer extensions
  73453. */
  73454. private _loadExtensions;
  73455. /**
  73456. * Creates a glTF Exporter instance, which can accept optional exporter options
  73457. * @param babylonScene Babylon scene object
  73458. * @param options Options to modify the behavior of the exporter
  73459. */
  73460. constructor(babylonScene: Scene, options?: IExportOptions);
  73461. dispose(): void;
  73462. /**
  73463. * Registers a glTF exporter extension
  73464. * @param name Name of the extension to export
  73465. * @param factory The factory function that creates the exporter extension
  73466. */
  73467. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  73468. /**
  73469. * Un-registers an exporter extension
  73470. * @param name The name fo the exporter extension
  73471. * @returns A boolean indicating whether the extension has been un-registered
  73472. */
  73473. static UnregisterExtension(name: string): boolean;
  73474. /**
  73475. * Lazy load a local engine with premultiplied alpha set to false
  73476. */
  73477. _getLocalEngine(): Engine;
  73478. private reorderIndicesBasedOnPrimitiveMode;
  73479. /**
  73480. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  73481. * clock-wise during export to glTF
  73482. * @param submesh BabylonJS submesh
  73483. * @param primitiveMode Primitive mode of the mesh
  73484. * @param sideOrientation the winding order of the submesh
  73485. * @param vertexBufferKind The type of vertex attribute
  73486. * @param meshAttributeArray The vertex attribute data
  73487. * @param byteOffset The offset to the binary data
  73488. * @param binaryWriter The binary data for the glTF file
  73489. */
  73490. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  73491. /**
  73492. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  73493. * clock-wise during export to glTF
  73494. * @param submesh BabylonJS submesh
  73495. * @param primitiveMode Primitive mode of the mesh
  73496. * @param sideOrientation the winding order of the submesh
  73497. * @param vertexBufferKind The type of vertex attribute
  73498. * @param meshAttributeArray The vertex attribute data
  73499. * @param byteOffset The offset to the binary data
  73500. * @param binaryWriter The binary data for the glTF file
  73501. */
  73502. private reorderTriangleFillMode;
  73503. /**
  73504. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  73505. * clock-wise during export to glTF
  73506. * @param submesh BabylonJS submesh
  73507. * @param primitiveMode Primitive mode of the mesh
  73508. * @param sideOrientation the winding order of the submesh
  73509. * @param vertexBufferKind The type of vertex attribute
  73510. * @param meshAttributeArray The vertex attribute data
  73511. * @param byteOffset The offset to the binary data
  73512. * @param binaryWriter The binary data for the glTF file
  73513. */
  73514. private reorderTriangleStripDrawMode;
  73515. /**
  73516. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  73517. * clock-wise during export to glTF
  73518. * @param submesh BabylonJS submesh
  73519. * @param primitiveMode Primitive mode of the mesh
  73520. * @param sideOrientation the winding order of the submesh
  73521. * @param vertexBufferKind The type of vertex attribute
  73522. * @param meshAttributeArray The vertex attribute data
  73523. * @param byteOffset The offset to the binary data
  73524. * @param binaryWriter The binary data for the glTF file
  73525. */
  73526. private reorderTriangleFanMode;
  73527. /**
  73528. * Writes the vertex attribute data to binary
  73529. * @param vertices The vertices to write to the binary writer
  73530. * @param byteOffset The offset into the binary writer to overwrite binary data
  73531. * @param vertexAttributeKind The vertex attribute type
  73532. * @param meshAttributeArray The vertex attribute data
  73533. * @param binaryWriter The writer containing the binary data
  73534. */
  73535. private writeVertexAttributeData;
  73536. /**
  73537. * Writes mesh attribute data to a data buffer
  73538. * Returns the bytelength of the data
  73539. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  73540. * @param meshAttributeArray Array containing the attribute data
  73541. * @param binaryWriter The buffer to write the binary data to
  73542. * @param indices Used to specify the order of the vertex data
  73543. */
  73544. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  73545. /**
  73546. * Generates glTF json data
  73547. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  73548. * @param glTFPrefix Text to use when prefixing a glTF file
  73549. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  73550. * @returns json data as string
  73551. */
  73552. private generateJSON;
  73553. /**
  73554. * Generates data for .gltf and .bin files based on the glTF prefix string
  73555. * @param glTFPrefix Text to use when prefixing a glTF file
  73556. * @param dispose Dispose the exporter
  73557. * @returns GLTFData with glTF file data
  73558. */
  73559. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  73560. /**
  73561. * Creates a binary buffer for glTF
  73562. * @returns array buffer for binary data
  73563. */
  73564. private _generateBinaryAsync;
  73565. /**
  73566. * Pads the number to a multiple of 4
  73567. * @param num number to pad
  73568. * @returns padded number
  73569. */
  73570. private _getPadding;
  73571. /**
  73572. * @hidden
  73573. */
  73574. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  73575. /**
  73576. * Sets the TRS for each node
  73577. * @param node glTF Node for storing the transformation data
  73578. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  73579. */
  73580. private setNodeTransformation;
  73581. private getVertexBufferFromMesh;
  73582. /**
  73583. * Creates a bufferview based on the vertices type for the Babylon mesh
  73584. * @param kind Indicates the type of vertices data
  73585. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  73586. * @param binaryWriter The buffer to write the bufferview data to
  73587. */
  73588. private createBufferViewKind;
  73589. /**
  73590. * The primitive mode of the Babylon mesh
  73591. * @param babylonMesh The BabylonJS mesh
  73592. */
  73593. private getMeshPrimitiveMode;
  73594. /**
  73595. * Sets the primitive mode of the glTF mesh primitive
  73596. * @param meshPrimitive glTF mesh primitive
  73597. * @param primitiveMode The primitive mode
  73598. */
  73599. private setPrimitiveMode;
  73600. /**
  73601. * Sets the vertex attribute accessor based of the glTF mesh primitive
  73602. * @param meshPrimitive glTF mesh primitive
  73603. * @param attributeKind vertex attribute
  73604. * @returns boolean specifying if uv coordinates are present
  73605. */
  73606. private setAttributeKind;
  73607. /**
  73608. * Sets data for the primitive attributes of each submesh
  73609. * @param mesh glTF Mesh object to store the primitive attribute information
  73610. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  73611. * @param binaryWriter Buffer to write the attribute data to
  73612. */
  73613. private setPrimitiveAttributesAsync;
  73614. /**
  73615. * Creates a glTF scene based on the array of meshes
  73616. * Returns the the total byte offset
  73617. * @param babylonScene Babylon scene to get the mesh data from
  73618. * @param binaryWriter Buffer to write binary data to
  73619. */
  73620. private createSceneAsync;
  73621. /**
  73622. * Creates a mapping of Node unique id to node index and handles animations
  73623. * @param babylonScene Babylon Scene
  73624. * @param nodes Babylon transform nodes
  73625. * @param binaryWriter Buffer to write binary data to
  73626. * @returns Node mapping of unique id to index
  73627. */
  73628. private createNodeMapAndAnimationsAsync;
  73629. /**
  73630. * Creates a glTF node from a Babylon mesh
  73631. * @param babylonMesh Source Babylon mesh
  73632. * @param binaryWriter Buffer for storing geometry data
  73633. * @returns glTF node
  73634. */
  73635. private createNodeAsync;
  73636. }
  73637. /**
  73638. * @hidden
  73639. *
  73640. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  73641. */
  73642. export class _BinaryWriter {
  73643. /**
  73644. * Array buffer which stores all binary data
  73645. */
  73646. private _arrayBuffer;
  73647. /**
  73648. * View of the array buffer
  73649. */
  73650. private _dataView;
  73651. /**
  73652. * byte offset of data in array buffer
  73653. */
  73654. private _byteOffset;
  73655. /**
  73656. * Initialize binary writer with an initial byte length
  73657. * @param byteLength Initial byte length of the array buffer
  73658. */
  73659. constructor(byteLength: number);
  73660. /**
  73661. * Resize the array buffer to the specified byte length
  73662. * @param byteLength
  73663. */
  73664. private resizeBuffer;
  73665. /**
  73666. * Get an array buffer with the length of the byte offset
  73667. * @returns ArrayBuffer resized to the byte offset
  73668. */
  73669. getArrayBuffer(): ArrayBuffer;
  73670. /**
  73671. * Get the byte offset of the array buffer
  73672. * @returns byte offset
  73673. */
  73674. getByteOffset(): number;
  73675. /**
  73676. * Stores an UInt8 in the array buffer
  73677. * @param entry
  73678. * @param byteOffset If defined, specifies where to set the value as an offset.
  73679. */
  73680. setUInt8(entry: number, byteOffset?: number): void;
  73681. /**
  73682. * Gets an UInt32 in the array buffer
  73683. * @param entry
  73684. * @param byteOffset If defined, specifies where to set the value as an offset.
  73685. */
  73686. getUInt32(byteOffset: number): number;
  73687. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  73688. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  73689. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  73690. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  73691. /**
  73692. * Stores a Float32 in the array buffer
  73693. * @param entry
  73694. */
  73695. setFloat32(entry: number, byteOffset?: number): void;
  73696. /**
  73697. * Stores an UInt32 in the array buffer
  73698. * @param entry
  73699. * @param byteOffset If defined, specifies where to set the value as an offset.
  73700. */
  73701. setUInt32(entry: number, byteOffset?: number): void;
  73702. }
  73703. }
  73704. declare module BABYLON.GLTF2.Exporter {
  73705. /**
  73706. * @hidden
  73707. * Interface to store animation data.
  73708. */
  73709. export interface _IAnimationData {
  73710. /**
  73711. * Keyframe data.
  73712. */
  73713. inputs: number[];
  73714. /**
  73715. * Value data.
  73716. */
  73717. outputs: number[][];
  73718. /**
  73719. * Animation interpolation data.
  73720. */
  73721. samplerInterpolation: AnimationSamplerInterpolation;
  73722. /**
  73723. * Minimum keyframe value.
  73724. */
  73725. inputsMin: number;
  73726. /**
  73727. * Maximum keyframe value.
  73728. */
  73729. inputsMax: number;
  73730. }
  73731. /**
  73732. * @hidden
  73733. */
  73734. export interface _IAnimationInfo {
  73735. /**
  73736. * The target channel for the animation
  73737. */
  73738. animationChannelTargetPath: AnimationChannelTargetPath;
  73739. /**
  73740. * The glTF accessor type for the data.
  73741. */
  73742. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  73743. /**
  73744. * Specifies if quaternions should be used.
  73745. */
  73746. useQuaternion: boolean;
  73747. }
  73748. /**
  73749. * @hidden
  73750. * Utility class for generating glTF animation data from BabylonJS.
  73751. */
  73752. export class _GLTFAnimation {
  73753. /**
  73754. * @ignore
  73755. *
  73756. * Creates glTF channel animation from BabylonJS animation.
  73757. * @param babylonTransformNode - BabylonJS mesh.
  73758. * @param animation - animation.
  73759. * @param animationChannelTargetPath - The target animation channel.
  73760. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  73761. * @param useQuaternion - Specifies if quaternions are used.
  73762. * @returns nullable IAnimationData
  73763. */
  73764. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  73765. private static _DeduceAnimationInfo;
  73766. /**
  73767. * @ignore
  73768. * Create node animations from the transform node animations
  73769. * @param babylonNode
  73770. * @param runtimeGLTFAnimation
  73771. * @param idleGLTFAnimations
  73772. * @param nodeMap
  73773. * @param nodes
  73774. * @param binaryWriter
  73775. * @param bufferViews
  73776. * @param accessors
  73777. * @param convertToRightHandedSystem
  73778. */
  73779. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  73780. [key: number]: number;
  73781. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  73782. /**
  73783. * @ignore
  73784. * Create node animations from the animation groups
  73785. * @param babylonScene
  73786. * @param glTFAnimations
  73787. * @param nodeMap
  73788. * @param nodes
  73789. * @param binaryWriter
  73790. * @param bufferViews
  73791. * @param accessors
  73792. * @param convertToRightHandedSystem
  73793. */
  73794. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  73795. [key: number]: number;
  73796. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  73797. private static AddAnimation;
  73798. /**
  73799. * Create a baked animation
  73800. * @param babylonTransformNode BabylonJS mesh
  73801. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  73802. * @param animationChannelTargetPath animation target channel
  73803. * @param minFrame minimum animation frame
  73804. * @param maxFrame maximum animation frame
  73805. * @param fps frames per second of the animation
  73806. * @param inputs input key frames of the animation
  73807. * @param outputs output key frame data of the animation
  73808. * @param convertToRightHandedSystem converts the values to right-handed
  73809. * @param useQuaternion specifies if quaternions should be used
  73810. */
  73811. private static _CreateBakedAnimation;
  73812. private static _ConvertFactorToVector3OrQuaternion;
  73813. private static _SetInterpolatedValue;
  73814. /**
  73815. * Creates linear animation from the animation key frames
  73816. * @param babylonTransformNode BabylonJS mesh
  73817. * @param animation BabylonJS animation
  73818. * @param animationChannelTargetPath The target animation channel
  73819. * @param frameDelta The difference between the last and first frame of the animation
  73820. * @param inputs Array to store the key frame times
  73821. * @param outputs Array to store the key frame data
  73822. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  73823. * @param useQuaternion Specifies if quaternions are used in the animation
  73824. */
  73825. private static _CreateLinearOrStepAnimation;
  73826. /**
  73827. * Creates cubic spline animation from the animation key frames
  73828. * @param babylonTransformNode BabylonJS mesh
  73829. * @param animation BabylonJS animation
  73830. * @param animationChannelTargetPath The target animation channel
  73831. * @param frameDelta The difference between the last and first frame of the animation
  73832. * @param inputs Array to store the key frame times
  73833. * @param outputs Array to store the key frame data
  73834. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  73835. * @param useQuaternion Specifies if quaternions are used in the animation
  73836. */
  73837. private static _CreateCubicSplineAnimation;
  73838. private static _GetBasePositionRotationOrScale;
  73839. /**
  73840. * Adds a key frame value
  73841. * @param keyFrame
  73842. * @param animation
  73843. * @param outputs
  73844. * @param animationChannelTargetPath
  73845. * @param basePositionRotationOrScale
  73846. * @param convertToRightHandedSystem
  73847. * @param useQuaternion
  73848. */
  73849. private static _AddKeyframeValue;
  73850. /**
  73851. * Determine the interpolation based on the key frames
  73852. * @param keyFrames
  73853. * @param animationChannelTargetPath
  73854. * @param useQuaternion
  73855. */
  73856. private static _DeduceInterpolation;
  73857. /**
  73858. * Adds an input tangent or output tangent to the output data
  73859. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  73860. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  73861. * @param outputs The animation data by keyframe
  73862. * @param animationChannelTargetPath The target animation channel
  73863. * @param interpolation The interpolation type
  73864. * @param keyFrame The key frame with the animation data
  73865. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  73866. * @param useQuaternion Specifies if quaternions are used
  73867. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  73868. */
  73869. private static AddSplineTangent;
  73870. /**
  73871. * Get the minimum and maximum key frames' frame values
  73872. * @param keyFrames animation key frames
  73873. * @returns the minimum and maximum key frame value
  73874. */
  73875. private static calculateMinMaxKeyFrames;
  73876. }
  73877. }
  73878. declare module BABYLON.GLTF2.Exporter {
  73879. /** @hidden */
  73880. export var textureTransformPixelShader: {
  73881. name: string;
  73882. shader: string;
  73883. };
  73884. }
  73885. declare module BABYLON.GLTF2.Exporter.Extensions {
  73886. /**
  73887. * @hidden
  73888. */
  73889. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  73890. private _recordedTextures;
  73891. /** Name of this extension */
  73892. readonly name: string;
  73893. /** Defines whether this extension is enabled */
  73894. enabled: boolean;
  73895. /** Defines whether this extension is required */
  73896. required: boolean;
  73897. /** Reference to the glTF exporter */
  73898. private _wasUsed;
  73899. constructor(exporter: _Exporter);
  73900. dispose(): void;
  73901. /** @hidden */
  73902. readonly wasUsed: boolean;
  73903. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  73904. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  73905. /**
  73906. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  73907. * @param babylonTexture
  73908. * @param offset
  73909. * @param rotation
  73910. * @param scale
  73911. * @param scene
  73912. */
  73913. private _textureTransformTextureAsync;
  73914. }
  73915. }
  73916. declare module BABYLON.GLTF2.Exporter.Extensions {
  73917. /**
  73918. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  73919. */
  73920. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  73921. /** The name of this extension. */
  73922. readonly name: string;
  73923. /** Defines whether this extension is enabled. */
  73924. enabled: boolean;
  73925. /** Defines whether this extension is required */
  73926. required: boolean;
  73927. /** Reference to the glTF exporter */
  73928. private _exporter;
  73929. private _lights;
  73930. /** @hidden */
  73931. constructor(exporter: _Exporter);
  73932. /** @hidden */
  73933. dispose(): void;
  73934. /** @hidden */
  73935. readonly wasUsed: boolean;
  73936. /** @hidden */
  73937. onExporting(): void;
  73938. /**
  73939. * Define this method to modify the default behavior when exporting a node
  73940. * @param context The context when exporting the node
  73941. * @param node glTF node
  73942. * @param babylonNode BabylonJS node
  73943. * @returns nullable INode promise
  73944. */
  73945. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  73946. }
  73947. }
  73948. declare module BABYLON.GLTF2.Exporter.Extensions {
  73949. /**
  73950. * @hidden
  73951. */
  73952. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  73953. /** Name of this extension */
  73954. readonly name: string;
  73955. /** Defines whether this extension is enabled */
  73956. enabled: boolean;
  73957. /** Defines whether this extension is required */
  73958. required: boolean;
  73959. /** Reference to the glTF exporter */
  73960. private _textureInfos;
  73961. private _exportedTextures;
  73962. private _wasUsed;
  73963. constructor(exporter: _Exporter);
  73964. dispose(): void;
  73965. /** @hidden */
  73966. readonly wasUsed: boolean;
  73967. private _getTextureIndex;
  73968. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  73969. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  73970. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  73971. }
  73972. }
  73973. declare module BABYLON {
  73974. /**
  73975. * Class for generating STL data from a Babylon scene.
  73976. */
  73977. export class STLExport {
  73978. /**
  73979. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  73980. * @param meshes list defines the mesh to serialize
  73981. * @param download triggers the automatic download of the file.
  73982. * @param fileName changes the downloads fileName.
  73983. * @param binary changes the STL to a binary type.
  73984. * @param isLittleEndian toggle for binary type exporter.
  73985. * @returns the STL as UTF8 string
  73986. */
  73987. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  73988. }
  73989. }
  73990. declare module "babylonjs-gltf2interface" {
  73991. export = BABYLON.GLTF2;
  73992. }
  73993. /**
  73994. * Module for glTF 2.0 Interface
  73995. */
  73996. declare module BABYLON.GLTF2 {
  73997. /**
  73998. * The datatype of the components in the attribute
  73999. */
  74000. const enum AccessorComponentType {
  74001. /**
  74002. * Byte
  74003. */
  74004. BYTE = 5120,
  74005. /**
  74006. * Unsigned Byte
  74007. */
  74008. UNSIGNED_BYTE = 5121,
  74009. /**
  74010. * Short
  74011. */
  74012. SHORT = 5122,
  74013. /**
  74014. * Unsigned Short
  74015. */
  74016. UNSIGNED_SHORT = 5123,
  74017. /**
  74018. * Unsigned Int
  74019. */
  74020. UNSIGNED_INT = 5125,
  74021. /**
  74022. * Float
  74023. */
  74024. FLOAT = 5126,
  74025. }
  74026. /**
  74027. * Specifies if the attirbute is a scalar, vector, or matrix
  74028. */
  74029. const enum AccessorType {
  74030. /**
  74031. * Scalar
  74032. */
  74033. SCALAR = "SCALAR",
  74034. /**
  74035. * Vector2
  74036. */
  74037. VEC2 = "VEC2",
  74038. /**
  74039. * Vector3
  74040. */
  74041. VEC3 = "VEC3",
  74042. /**
  74043. * Vector4
  74044. */
  74045. VEC4 = "VEC4",
  74046. /**
  74047. * Matrix2x2
  74048. */
  74049. MAT2 = "MAT2",
  74050. /**
  74051. * Matrix3x3
  74052. */
  74053. MAT3 = "MAT3",
  74054. /**
  74055. * Matrix4x4
  74056. */
  74057. MAT4 = "MAT4",
  74058. }
  74059. /**
  74060. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  74061. */
  74062. const enum AnimationChannelTargetPath {
  74063. /**
  74064. * Translation
  74065. */
  74066. TRANSLATION = "translation",
  74067. /**
  74068. * Rotation
  74069. */
  74070. ROTATION = "rotation",
  74071. /**
  74072. * Scale
  74073. */
  74074. SCALE = "scale",
  74075. /**
  74076. * Weights
  74077. */
  74078. WEIGHTS = "weights",
  74079. }
  74080. /**
  74081. * Interpolation algorithm
  74082. */
  74083. const enum AnimationSamplerInterpolation {
  74084. /**
  74085. * The animated values are linearly interpolated between keyframes
  74086. */
  74087. LINEAR = "LINEAR",
  74088. /**
  74089. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  74090. */
  74091. STEP = "STEP",
  74092. /**
  74093. * The animation's interpolation is computed using a cubic spline with specified tangents
  74094. */
  74095. CUBICSPLINE = "CUBICSPLINE",
  74096. }
  74097. /**
  74098. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  74099. */
  74100. const enum CameraType {
  74101. /**
  74102. * A perspective camera containing properties to create a perspective projection matrix
  74103. */
  74104. PERSPECTIVE = "perspective",
  74105. /**
  74106. * An orthographic camera containing properties to create an orthographic projection matrix
  74107. */
  74108. ORTHOGRAPHIC = "orthographic",
  74109. }
  74110. /**
  74111. * The mime-type of the image
  74112. */
  74113. const enum ImageMimeType {
  74114. /**
  74115. * JPEG Mime-type
  74116. */
  74117. JPEG = "image/jpeg",
  74118. /**
  74119. * PNG Mime-type
  74120. */
  74121. PNG = "image/png",
  74122. }
  74123. /**
  74124. * The alpha rendering mode of the material
  74125. */
  74126. const enum MaterialAlphaMode {
  74127. /**
  74128. * The alpha value is ignored and the rendered output is fully opaque
  74129. */
  74130. OPAQUE = "OPAQUE",
  74131. /**
  74132. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  74133. */
  74134. MASK = "MASK",
  74135. /**
  74136. * 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)
  74137. */
  74138. BLEND = "BLEND",
  74139. }
  74140. /**
  74141. * The type of the primitives to render
  74142. */
  74143. const enum MeshPrimitiveMode {
  74144. /**
  74145. * Points
  74146. */
  74147. POINTS = 0,
  74148. /**
  74149. * Lines
  74150. */
  74151. LINES = 1,
  74152. /**
  74153. * Line Loop
  74154. */
  74155. LINE_LOOP = 2,
  74156. /**
  74157. * Line Strip
  74158. */
  74159. LINE_STRIP = 3,
  74160. /**
  74161. * Triangles
  74162. */
  74163. TRIANGLES = 4,
  74164. /**
  74165. * Triangle Strip
  74166. */
  74167. TRIANGLE_STRIP = 5,
  74168. /**
  74169. * Triangle Fan
  74170. */
  74171. TRIANGLE_FAN = 6,
  74172. }
  74173. /**
  74174. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  74175. */
  74176. const enum TextureMagFilter {
  74177. /**
  74178. * Nearest
  74179. */
  74180. NEAREST = 9728,
  74181. /**
  74182. * Linear
  74183. */
  74184. LINEAR = 9729,
  74185. }
  74186. /**
  74187. * Minification filter. All valid values correspond to WebGL enums
  74188. */
  74189. const enum TextureMinFilter {
  74190. /**
  74191. * Nearest
  74192. */
  74193. NEAREST = 9728,
  74194. /**
  74195. * Linear
  74196. */
  74197. LINEAR = 9729,
  74198. /**
  74199. * Nearest Mip-Map Nearest
  74200. */
  74201. NEAREST_MIPMAP_NEAREST = 9984,
  74202. /**
  74203. * Linear Mipmap Nearest
  74204. */
  74205. LINEAR_MIPMAP_NEAREST = 9985,
  74206. /**
  74207. * Nearest Mipmap Linear
  74208. */
  74209. NEAREST_MIPMAP_LINEAR = 9986,
  74210. /**
  74211. * Linear Mipmap Linear
  74212. */
  74213. LINEAR_MIPMAP_LINEAR = 9987,
  74214. }
  74215. /**
  74216. * S (U) wrapping mode. All valid values correspond to WebGL enums
  74217. */
  74218. const enum TextureWrapMode {
  74219. /**
  74220. * Clamp to Edge
  74221. */
  74222. CLAMP_TO_EDGE = 33071,
  74223. /**
  74224. * Mirrored Repeat
  74225. */
  74226. MIRRORED_REPEAT = 33648,
  74227. /**
  74228. * Repeat
  74229. */
  74230. REPEAT = 10497,
  74231. }
  74232. /**
  74233. * glTF Property
  74234. */
  74235. interface IProperty {
  74236. /**
  74237. * Dictionary object with extension-specific objects
  74238. */
  74239. extensions?: {
  74240. [key: string]: any;
  74241. };
  74242. /**
  74243. * Application-Specific data
  74244. */
  74245. extras?: any;
  74246. }
  74247. /**
  74248. * glTF Child of Root Property
  74249. */
  74250. interface IChildRootProperty extends IProperty {
  74251. /**
  74252. * The user-defined name of this object
  74253. */
  74254. name?: string;
  74255. }
  74256. /**
  74257. * Indices of those attributes that deviate from their initialization value
  74258. */
  74259. interface IAccessorSparseIndices extends IProperty {
  74260. /**
  74261. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  74262. */
  74263. bufferView: number;
  74264. /**
  74265. * The offset relative to the start of the bufferView in bytes. Must be aligned
  74266. */
  74267. byteOffset?: number;
  74268. /**
  74269. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  74270. */
  74271. componentType: AccessorComponentType;
  74272. }
  74273. /**
  74274. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  74275. */
  74276. interface IAccessorSparseValues extends IProperty {
  74277. /**
  74278. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  74279. */
  74280. bufferView: number;
  74281. /**
  74282. * The offset relative to the start of the bufferView in bytes. Must be aligned
  74283. */
  74284. byteOffset?: number;
  74285. }
  74286. /**
  74287. * Sparse storage of attributes that deviate from their initialization value
  74288. */
  74289. interface IAccessorSparse extends IProperty {
  74290. /**
  74291. * The number of attributes encoded in this sparse accessor
  74292. */
  74293. count: number;
  74294. /**
  74295. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  74296. */
  74297. indices: IAccessorSparseIndices;
  74298. /**
  74299. * 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
  74300. */
  74301. values: IAccessorSparseValues;
  74302. }
  74303. /**
  74304. * 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
  74305. */
  74306. interface IAccessor extends IChildRootProperty {
  74307. /**
  74308. * The index of the bufferview
  74309. */
  74310. bufferView?: number;
  74311. /**
  74312. * The offset relative to the start of the bufferView in bytes
  74313. */
  74314. byteOffset?: number;
  74315. /**
  74316. * The datatype of components in the attribute
  74317. */
  74318. componentType: AccessorComponentType;
  74319. /**
  74320. * Specifies whether integer data values should be normalized
  74321. */
  74322. normalized?: boolean;
  74323. /**
  74324. * The number of attributes referenced by this accessor
  74325. */
  74326. count: number;
  74327. /**
  74328. * Specifies if the attribute is a scalar, vector, or matrix
  74329. */
  74330. type: AccessorType;
  74331. /**
  74332. * Maximum value of each component in this attribute
  74333. */
  74334. max?: number[];
  74335. /**
  74336. * Minimum value of each component in this attribute
  74337. */
  74338. min?: number[];
  74339. /**
  74340. * Sparse storage of attributes that deviate from their initialization value
  74341. */
  74342. sparse?: IAccessorSparse;
  74343. }
  74344. /**
  74345. * Targets an animation's sampler at a node's property
  74346. */
  74347. interface IAnimationChannel extends IProperty {
  74348. /**
  74349. * The index of a sampler in this animation used to compute the value for the target
  74350. */
  74351. sampler: number;
  74352. /**
  74353. * The index of the node and TRS property to target
  74354. */
  74355. target: IAnimationChannelTarget;
  74356. }
  74357. /**
  74358. * The index of the node and TRS property that an animation channel targets
  74359. */
  74360. interface IAnimationChannelTarget extends IProperty {
  74361. /**
  74362. * The index of the node to target
  74363. */
  74364. node: number;
  74365. /**
  74366. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  74367. */
  74368. path: AnimationChannelTargetPath;
  74369. }
  74370. /**
  74371. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  74372. */
  74373. interface IAnimationSampler extends IProperty {
  74374. /**
  74375. * The index of an accessor containing keyframe input values, e.g., time
  74376. */
  74377. input: number;
  74378. /**
  74379. * Interpolation algorithm
  74380. */
  74381. interpolation?: AnimationSamplerInterpolation;
  74382. /**
  74383. * The index of an accessor, containing keyframe output values
  74384. */
  74385. output: number;
  74386. }
  74387. /**
  74388. * A keyframe animation
  74389. */
  74390. interface IAnimation extends IChildRootProperty {
  74391. /**
  74392. * An array of channels, each of which targets an animation's sampler at a node's property
  74393. */
  74394. channels: IAnimationChannel[];
  74395. /**
  74396. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  74397. */
  74398. samplers: IAnimationSampler[];
  74399. }
  74400. /**
  74401. * Metadata about the glTF asset
  74402. */
  74403. interface IAsset extends IChildRootProperty {
  74404. /**
  74405. * A copyright message suitable for display to credit the content creator
  74406. */
  74407. copyright?: string;
  74408. /**
  74409. * Tool that generated this glTF model. Useful for debugging
  74410. */
  74411. generator?: string;
  74412. /**
  74413. * The glTF version that this asset targets
  74414. */
  74415. version: string;
  74416. /**
  74417. * The minimum glTF version that this asset targets
  74418. */
  74419. minVersion?: string;
  74420. }
  74421. /**
  74422. * A buffer points to binary geometry, animation, or skins
  74423. */
  74424. interface IBuffer extends IChildRootProperty {
  74425. /**
  74426. * 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
  74427. */
  74428. uri?: string;
  74429. /**
  74430. * The length of the buffer in bytes
  74431. */
  74432. byteLength: number;
  74433. }
  74434. /**
  74435. * A view into a buffer generally representing a subset of the buffer
  74436. */
  74437. interface IBufferView extends IChildRootProperty {
  74438. /**
  74439. * The index of the buffer
  74440. */
  74441. buffer: number;
  74442. /**
  74443. * The offset into the buffer in bytes
  74444. */
  74445. byteOffset?: number;
  74446. /**
  74447. * The lenth of the bufferView in bytes
  74448. */
  74449. byteLength: number;
  74450. /**
  74451. * The stride, in bytes
  74452. */
  74453. byteStride?: number;
  74454. }
  74455. /**
  74456. * An orthographic camera containing properties to create an orthographic projection matrix
  74457. */
  74458. interface ICameraOrthographic extends IProperty {
  74459. /**
  74460. * The floating-point horizontal magnification of the view. Must not be zero
  74461. */
  74462. xmag: number;
  74463. /**
  74464. * The floating-point vertical magnification of the view. Must not be zero
  74465. */
  74466. ymag: number;
  74467. /**
  74468. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  74469. */
  74470. zfar: number;
  74471. /**
  74472. * The floating-point distance to the near clipping plane
  74473. */
  74474. znear: number;
  74475. }
  74476. /**
  74477. * A perspective camera containing properties to create a perspective projection matrix
  74478. */
  74479. interface ICameraPerspective extends IProperty {
  74480. /**
  74481. * The floating-point aspect ratio of the field of view
  74482. */
  74483. aspectRatio?: number;
  74484. /**
  74485. * The floating-point vertical field of view in radians
  74486. */
  74487. yfov: number;
  74488. /**
  74489. * The floating-point distance to the far clipping plane
  74490. */
  74491. zfar?: number;
  74492. /**
  74493. * The floating-point distance to the near clipping plane
  74494. */
  74495. znear: number;
  74496. }
  74497. /**
  74498. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  74499. */
  74500. interface ICamera extends IChildRootProperty {
  74501. /**
  74502. * An orthographic camera containing properties to create an orthographic projection matrix
  74503. */
  74504. orthographic?: ICameraOrthographic;
  74505. /**
  74506. * A perspective camera containing properties to create a perspective projection matrix
  74507. */
  74508. perspective?: ICameraPerspective;
  74509. /**
  74510. * Specifies if the camera uses a perspective or orthographic projection
  74511. */
  74512. type: CameraType;
  74513. }
  74514. /**
  74515. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  74516. */
  74517. interface IImage extends IChildRootProperty {
  74518. /**
  74519. * 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
  74520. */
  74521. uri?: string;
  74522. /**
  74523. * The image's MIME type
  74524. */
  74525. mimeType?: ImageMimeType;
  74526. /**
  74527. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  74528. */
  74529. bufferView?: number;
  74530. }
  74531. /**
  74532. * Material Normal Texture Info
  74533. */
  74534. interface IMaterialNormalTextureInfo extends ITextureInfo {
  74535. /**
  74536. * The scalar multiplier applied to each normal vector of the normal texture
  74537. */
  74538. scale?: number;
  74539. }
  74540. /**
  74541. * Material Occlusion Texture Info
  74542. */
  74543. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  74544. /**
  74545. * A scalar multiplier controlling the amount of occlusion applied
  74546. */
  74547. strength?: number;
  74548. }
  74549. /**
  74550. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  74551. */
  74552. interface IMaterialPbrMetallicRoughness {
  74553. /**
  74554. * The material's base color factor
  74555. */
  74556. baseColorFactor?: number[];
  74557. /**
  74558. * The base color texture
  74559. */
  74560. baseColorTexture?: ITextureInfo;
  74561. /**
  74562. * The metalness of the material
  74563. */
  74564. metallicFactor?: number;
  74565. /**
  74566. * The roughness of the material
  74567. */
  74568. roughnessFactor?: number;
  74569. /**
  74570. * The metallic-roughness texture
  74571. */
  74572. metallicRoughnessTexture?: ITextureInfo;
  74573. }
  74574. /**
  74575. * The material appearance of a primitive
  74576. */
  74577. interface IMaterial extends IChildRootProperty {
  74578. /**
  74579. * 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
  74580. */
  74581. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  74582. /**
  74583. * The normal map texture
  74584. */
  74585. normalTexture?: IMaterialNormalTextureInfo;
  74586. /**
  74587. * The occlusion map texture
  74588. */
  74589. occlusionTexture?: IMaterialOcclusionTextureInfo;
  74590. /**
  74591. * The emissive map texture
  74592. */
  74593. emissiveTexture?: ITextureInfo;
  74594. /**
  74595. * 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
  74596. */
  74597. emissiveFactor?: number[];
  74598. /**
  74599. * The alpha rendering mode of the material
  74600. */
  74601. alphaMode?: MaterialAlphaMode;
  74602. /**
  74603. * The alpha cutoff value of the material
  74604. */
  74605. alphaCutoff?: number;
  74606. /**
  74607. * Specifies whether the material is double sided
  74608. */
  74609. doubleSided?: boolean;
  74610. }
  74611. /**
  74612. * Geometry to be rendered with the given material
  74613. */
  74614. interface IMeshPrimitive extends IProperty {
  74615. /**
  74616. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  74617. */
  74618. attributes: {
  74619. [name: string]: number;
  74620. };
  74621. /**
  74622. * The index of the accessor that contains the indices
  74623. */
  74624. indices?: number;
  74625. /**
  74626. * The index of the material to apply to this primitive when rendering
  74627. */
  74628. material?: number;
  74629. /**
  74630. * The type of primitives to render. All valid values correspond to WebGL enums
  74631. */
  74632. mode?: MeshPrimitiveMode;
  74633. /**
  74634. * 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
  74635. */
  74636. targets?: {
  74637. [name: string]: number;
  74638. }[];
  74639. }
  74640. /**
  74641. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  74642. */
  74643. interface IMesh extends IChildRootProperty {
  74644. /**
  74645. * An array of primitives, each defining geometry to be rendered with a material
  74646. */
  74647. primitives: IMeshPrimitive[];
  74648. /**
  74649. * Array of weights to be applied to the Morph Targets
  74650. */
  74651. weights?: number[];
  74652. }
  74653. /**
  74654. * A node in the node hierarchy
  74655. */
  74656. interface INode extends IChildRootProperty {
  74657. /**
  74658. * The index of the camera referenced by this node
  74659. */
  74660. camera?: number;
  74661. /**
  74662. * The indices of this node's children
  74663. */
  74664. children?: number[];
  74665. /**
  74666. * The index of the skin referenced by this node
  74667. */
  74668. skin?: number;
  74669. /**
  74670. * A floating-point 4x4 transformation matrix stored in column-major order
  74671. */
  74672. matrix?: number[];
  74673. /**
  74674. * The index of the mesh in this node
  74675. */
  74676. mesh?: number;
  74677. /**
  74678. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  74679. */
  74680. rotation?: number[];
  74681. /**
  74682. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  74683. */
  74684. scale?: number[];
  74685. /**
  74686. * The node's translation along the x, y, and z axes
  74687. */
  74688. translation?: number[];
  74689. /**
  74690. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  74691. */
  74692. weights?: number[];
  74693. }
  74694. /**
  74695. * Texture sampler properties for filtering and wrapping modes
  74696. */
  74697. interface ISampler extends IChildRootProperty {
  74698. /**
  74699. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  74700. */
  74701. magFilter?: TextureMagFilter;
  74702. /**
  74703. * Minification filter. All valid values correspond to WebGL enums
  74704. */
  74705. minFilter?: TextureMinFilter;
  74706. /**
  74707. * S (U) wrapping mode. All valid values correspond to WebGL enums
  74708. */
  74709. wrapS?: TextureWrapMode;
  74710. /**
  74711. * T (V) wrapping mode. All valid values correspond to WebGL enums
  74712. */
  74713. wrapT?: TextureWrapMode;
  74714. }
  74715. /**
  74716. * The root nodes of a scene
  74717. */
  74718. interface IScene extends IChildRootProperty {
  74719. /**
  74720. * The indices of each root node
  74721. */
  74722. nodes: number[];
  74723. }
  74724. /**
  74725. * Joints and matrices defining a skin
  74726. */
  74727. interface ISkin extends IChildRootProperty {
  74728. /**
  74729. * 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
  74730. */
  74731. inverseBindMatrices?: number;
  74732. /**
  74733. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  74734. */
  74735. skeleton?: number;
  74736. /**
  74737. * 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)
  74738. */
  74739. joints: number[];
  74740. }
  74741. /**
  74742. * A texture and its sampler
  74743. */
  74744. interface ITexture extends IChildRootProperty {
  74745. /**
  74746. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  74747. */
  74748. sampler?: number;
  74749. /**
  74750. * The index of the image used by this texture
  74751. */
  74752. source: number;
  74753. }
  74754. /**
  74755. * Reference to a texture
  74756. */
  74757. interface ITextureInfo extends IProperty {
  74758. /**
  74759. * The index of the texture
  74760. */
  74761. index: number;
  74762. /**
  74763. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  74764. */
  74765. texCoord?: number;
  74766. }
  74767. /**
  74768. * The root object for a glTF asset
  74769. */
  74770. interface IGLTF extends IProperty {
  74771. /**
  74772. * An array of accessors. An accessor is a typed view into a bufferView
  74773. */
  74774. accessors?: IAccessor[];
  74775. /**
  74776. * An array of keyframe animations
  74777. */
  74778. animations?: IAnimation[];
  74779. /**
  74780. * Metadata about the glTF asset
  74781. */
  74782. asset: IAsset;
  74783. /**
  74784. * An array of buffers. A buffer points to binary geometry, animation, or skins
  74785. */
  74786. buffers?: IBuffer[];
  74787. /**
  74788. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  74789. */
  74790. bufferViews?: IBufferView[];
  74791. /**
  74792. * An array of cameras
  74793. */
  74794. cameras?: ICamera[];
  74795. /**
  74796. * Names of glTF extensions used somewhere in this asset
  74797. */
  74798. extensionsUsed?: string[];
  74799. /**
  74800. * Names of glTF extensions required to properly load this asset
  74801. */
  74802. extensionsRequired?: string[];
  74803. /**
  74804. * An array of images. An image defines data used to create a texture
  74805. */
  74806. images?: IImage[];
  74807. /**
  74808. * An array of materials. A material defines the appearance of a primitive
  74809. */
  74810. materials?: IMaterial[];
  74811. /**
  74812. * An array of meshes. A mesh is a set of primitives to be rendered
  74813. */
  74814. meshes?: IMesh[];
  74815. /**
  74816. * An array of nodes
  74817. */
  74818. nodes?: INode[];
  74819. /**
  74820. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  74821. */
  74822. samplers?: ISampler[];
  74823. /**
  74824. * The index of the default scene
  74825. */
  74826. scene?: number;
  74827. /**
  74828. * An array of scenes
  74829. */
  74830. scenes?: IScene[];
  74831. /**
  74832. * An array of skins. A skin is defined by joints and matrices
  74833. */
  74834. skins?: ISkin[];
  74835. /**
  74836. * An array of textures
  74837. */
  74838. textures?: ITexture[];
  74839. }
  74840. /**
  74841. * The glTF validation results
  74842. * @ignore
  74843. */
  74844. interface IGLTFValidationResults {
  74845. info: {
  74846. generator: string;
  74847. hasAnimations: boolean;
  74848. hasDefaultScene: boolean;
  74849. hasMaterials: boolean;
  74850. hasMorphTargets: boolean;
  74851. hasSkins: boolean;
  74852. hasTextures: boolean;
  74853. maxAttributesUsed: number;
  74854. primitivesCount: number
  74855. };
  74856. issues: {
  74857. messages: Array<string>;
  74858. numErrors: number;
  74859. numHints: number;
  74860. numInfos: number;
  74861. numWarnings: number;
  74862. truncated: boolean
  74863. };
  74864. mimeType: string;
  74865. uri: string;
  74866. validatedAt: string;
  74867. validatorVersion: string;
  74868. }
  74869. /**
  74870. * The glTF validation options
  74871. */
  74872. interface IGLTFValidationOptions {
  74873. /** Uri to use */
  74874. uri?: string;
  74875. /** Function used to load external resources */
  74876. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  74877. /** Boolean indicating that we need to validate accessor data */
  74878. validateAccessorData?: boolean;
  74879. /** max number of issues allowed */
  74880. maxIssues?: number;
  74881. /** Ignored issues */
  74882. ignoredIssues?: Array<string>;
  74883. /** Value to override severy settings */
  74884. severityOverrides?: Object;
  74885. }
  74886. /**
  74887. * The glTF validator object
  74888. * @ignore
  74889. */
  74890. interface IGLTFValidator {
  74891. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  74892. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  74893. }
  74894. }
  74895. declare module BABYLON {
  74896. /** @hidden */
  74897. export var cellPixelShader: {
  74898. name: string;
  74899. shader: string;
  74900. };
  74901. }
  74902. declare module BABYLON {
  74903. /** @hidden */
  74904. export var cellVertexShader: {
  74905. name: string;
  74906. shader: string;
  74907. };
  74908. }
  74909. declare module BABYLON {
  74910. export class CellMaterial extends BABYLON.PushMaterial {
  74911. private _diffuseTexture;
  74912. diffuseTexture: BABYLON.BaseTexture;
  74913. diffuseColor: BABYLON.Color3;
  74914. _computeHighLevel: boolean;
  74915. computeHighLevel: boolean;
  74916. private _disableLighting;
  74917. disableLighting: boolean;
  74918. private _maxSimultaneousLights;
  74919. maxSimultaneousLights: number;
  74920. private _renderId;
  74921. constructor(name: string, scene: BABYLON.Scene);
  74922. needAlphaBlending(): boolean;
  74923. needAlphaTesting(): boolean;
  74924. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74925. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74926. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74927. getAnimatables(): BABYLON.IAnimatable[];
  74928. getActiveTextures(): BABYLON.BaseTexture[];
  74929. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74930. dispose(forceDisposeEffect?: boolean): void;
  74931. getClassName(): string;
  74932. clone(name: string): CellMaterial;
  74933. serialize(): any;
  74934. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  74935. }
  74936. }
  74937. declare module BABYLON {
  74938. export class CustomShaderStructure {
  74939. FragmentStore: string;
  74940. VertexStore: string;
  74941. constructor();
  74942. }
  74943. export class ShaderSpecialParts {
  74944. constructor();
  74945. Fragment_Begin: string;
  74946. Fragment_Definitions: string;
  74947. Fragment_MainBegin: string;
  74948. Fragment_Custom_Diffuse: string;
  74949. Fragment_Before_Lights: string;
  74950. Fragment_Before_Fog: string;
  74951. Fragment_Custom_Alpha: string;
  74952. Fragment_Before_FragColor: string;
  74953. Vertex_Begin: string;
  74954. Vertex_Definitions: string;
  74955. Vertex_MainBegin: string;
  74956. Vertex_Before_PositionUpdated: string;
  74957. Vertex_Before_NormalUpdated: string;
  74958. Vertex_MainEnd: string;
  74959. }
  74960. export class CustomMaterial extends BABYLON.StandardMaterial {
  74961. static ShaderIndexer: number;
  74962. CustomParts: ShaderSpecialParts;
  74963. _isCreatedShader: boolean;
  74964. _createdShaderName: string;
  74965. _customUniform: string[];
  74966. _newUniforms: string[];
  74967. _newUniformInstances: any[];
  74968. _newSamplerInstances: BABYLON.Texture[];
  74969. FragmentShader: string;
  74970. VertexShader: string;
  74971. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  74972. ReviewUniform(name: string, arr: string[]): string[];
  74973. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  74974. constructor(name: string, scene: BABYLON.Scene);
  74975. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  74976. Fragment_Begin(shaderPart: string): CustomMaterial;
  74977. Fragment_Definitions(shaderPart: string): CustomMaterial;
  74978. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  74979. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  74980. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  74981. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  74982. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  74983. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  74984. Vertex_Begin(shaderPart: string): CustomMaterial;
  74985. Vertex_Definitions(shaderPart: string): CustomMaterial;
  74986. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  74987. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  74988. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  74989. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  74990. }
  74991. }
  74992. declare module BABYLON {
  74993. export class ShaderAlebdoParts {
  74994. constructor();
  74995. Fragment_Begin: string;
  74996. Fragment_Definitions: string;
  74997. Fragment_MainBegin: string;
  74998. Fragment_Custom_Albedo: string;
  74999. Fragment_Before_Lights: string;
  75000. Fragment_Custom_MetallicRoughness: string;
  75001. Fragment_Custom_MicroSurface: string;
  75002. Fragment_Before_Fog: string;
  75003. Fragment_Custom_Alpha: string;
  75004. Fragment_Before_FragColor: string;
  75005. Vertex_Begin: string;
  75006. Vertex_Definitions: string;
  75007. Vertex_MainBegin: string;
  75008. Vertex_Before_PositionUpdated: string;
  75009. Vertex_Before_NormalUpdated: string;
  75010. Vertex_MainEnd: string;
  75011. }
  75012. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  75013. static ShaderIndexer: number;
  75014. CustomParts: ShaderAlebdoParts;
  75015. _isCreatedShader: boolean;
  75016. _createdShaderName: string;
  75017. _customUniform: string[];
  75018. _newUniforms: string[];
  75019. _newUniformInstances: any[];
  75020. _newSamplerInstances: BABYLON.Texture[];
  75021. FragmentShader: string;
  75022. VertexShader: string;
  75023. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  75024. ReviewUniform(name: string, arr: string[]): string[];
  75025. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  75026. constructor(name: string, scene: BABYLON.Scene);
  75027. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  75028. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  75029. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  75030. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  75031. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  75032. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  75033. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  75034. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  75035. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  75036. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  75037. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  75038. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  75039. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  75040. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  75041. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  75042. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  75043. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  75044. }
  75045. }
  75046. declare module BABYLON {
  75047. /** @hidden */
  75048. export var firePixelShader: {
  75049. name: string;
  75050. shader: string;
  75051. };
  75052. }
  75053. declare module BABYLON {
  75054. /** @hidden */
  75055. export var fireVertexShader: {
  75056. name: string;
  75057. shader: string;
  75058. };
  75059. }
  75060. declare module BABYLON {
  75061. export class FireMaterial extends BABYLON.PushMaterial {
  75062. private _diffuseTexture;
  75063. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75064. private _distortionTexture;
  75065. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75066. private _opacityTexture;
  75067. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75068. diffuseColor: BABYLON.Color3;
  75069. speed: number;
  75070. private _scaledDiffuse;
  75071. private _renderId;
  75072. private _lastTime;
  75073. constructor(name: string, scene: BABYLON.Scene);
  75074. needAlphaBlending(): boolean;
  75075. needAlphaTesting(): boolean;
  75076. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75077. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75078. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75079. getAnimatables(): BABYLON.IAnimatable[];
  75080. getActiveTextures(): BABYLON.BaseTexture[];
  75081. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75082. getClassName(): string;
  75083. dispose(forceDisposeEffect?: boolean): void;
  75084. clone(name: string): FireMaterial;
  75085. serialize(): any;
  75086. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  75087. }
  75088. }
  75089. declare module BABYLON {
  75090. /** @hidden */
  75091. export var furPixelShader: {
  75092. name: string;
  75093. shader: string;
  75094. };
  75095. }
  75096. declare module BABYLON {
  75097. /** @hidden */
  75098. export var furVertexShader: {
  75099. name: string;
  75100. shader: string;
  75101. };
  75102. }
  75103. declare module BABYLON {
  75104. export class FurMaterial extends BABYLON.PushMaterial {
  75105. private _diffuseTexture;
  75106. diffuseTexture: BABYLON.BaseTexture;
  75107. private _heightTexture;
  75108. heightTexture: BABYLON.BaseTexture;
  75109. diffuseColor: BABYLON.Color3;
  75110. furLength: number;
  75111. furAngle: number;
  75112. furColor: BABYLON.Color3;
  75113. furOffset: number;
  75114. furSpacing: number;
  75115. furGravity: BABYLON.Vector3;
  75116. furSpeed: number;
  75117. furDensity: number;
  75118. furOcclusion: number;
  75119. furTexture: BABYLON.DynamicTexture;
  75120. private _disableLighting;
  75121. disableLighting: boolean;
  75122. private _maxSimultaneousLights;
  75123. maxSimultaneousLights: number;
  75124. highLevelFur: boolean;
  75125. _meshes: BABYLON.AbstractMesh[];
  75126. private _renderId;
  75127. private _furTime;
  75128. constructor(name: string, scene: BABYLON.Scene);
  75129. furTime: number;
  75130. needAlphaBlending(): boolean;
  75131. needAlphaTesting(): boolean;
  75132. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75133. updateFur(): void;
  75134. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75135. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75136. getAnimatables(): BABYLON.IAnimatable[];
  75137. getActiveTextures(): BABYLON.BaseTexture[];
  75138. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75139. dispose(forceDisposeEffect?: boolean): void;
  75140. clone(name: string): FurMaterial;
  75141. serialize(): any;
  75142. getClassName(): string;
  75143. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  75144. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  75145. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  75146. }
  75147. }
  75148. declare module BABYLON {
  75149. /** @hidden */
  75150. export var gradientPixelShader: {
  75151. name: string;
  75152. shader: string;
  75153. };
  75154. }
  75155. declare module BABYLON {
  75156. /** @hidden */
  75157. export var gradientVertexShader: {
  75158. name: string;
  75159. shader: string;
  75160. };
  75161. }
  75162. declare module BABYLON {
  75163. export class GradientMaterial extends BABYLON.PushMaterial {
  75164. private _maxSimultaneousLights;
  75165. maxSimultaneousLights: number;
  75166. topColor: BABYLON.Color3;
  75167. topColorAlpha: number;
  75168. bottomColor: BABYLON.Color3;
  75169. bottomColorAlpha: number;
  75170. offset: number;
  75171. scale: number;
  75172. smoothness: number;
  75173. private _disableLighting;
  75174. disableLighting: boolean;
  75175. private _renderId;
  75176. constructor(name: string, scene: BABYLON.Scene);
  75177. needAlphaBlending(): boolean;
  75178. needAlphaTesting(): boolean;
  75179. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75180. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75181. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75182. getAnimatables(): BABYLON.IAnimatable[];
  75183. dispose(forceDisposeEffect?: boolean): void;
  75184. clone(name: string): GradientMaterial;
  75185. serialize(): any;
  75186. getClassName(): string;
  75187. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  75188. }
  75189. }
  75190. declare module BABYLON {
  75191. /** @hidden */
  75192. export var gridPixelShader: {
  75193. name: string;
  75194. shader: string;
  75195. };
  75196. }
  75197. declare module BABYLON {
  75198. /** @hidden */
  75199. export var gridVertexShader: {
  75200. name: string;
  75201. shader: string;
  75202. };
  75203. }
  75204. declare module BABYLON {
  75205. /**
  75206. * The grid materials allows you to wrap any shape with a grid.
  75207. * Colors are customizable.
  75208. */
  75209. export class GridMaterial extends BABYLON.PushMaterial {
  75210. /**
  75211. * Main color of the grid (e.g. between lines)
  75212. */
  75213. mainColor: BABYLON.Color3;
  75214. /**
  75215. * Color of the grid lines.
  75216. */
  75217. lineColor: BABYLON.Color3;
  75218. /**
  75219. * The scale of the grid compared to unit.
  75220. */
  75221. gridRatio: number;
  75222. /**
  75223. * Allows setting an offset for the grid lines.
  75224. */
  75225. gridOffset: BABYLON.Vector3;
  75226. /**
  75227. * The frequency of thicker lines.
  75228. */
  75229. majorUnitFrequency: number;
  75230. /**
  75231. * The visibility of minor units in the grid.
  75232. */
  75233. minorUnitVisibility: number;
  75234. /**
  75235. * The grid opacity outside of the lines.
  75236. */
  75237. opacity: number;
  75238. /**
  75239. * Determine RBG output is premultiplied by alpha value.
  75240. */
  75241. preMultiplyAlpha: boolean;
  75242. private _opacityTexture;
  75243. opacityTexture: BABYLON.BaseTexture;
  75244. private _gridControl;
  75245. private _renderId;
  75246. /**
  75247. * constructor
  75248. * @param name The name given to the material in order to identify it afterwards.
  75249. * @param scene The scene the material is used in.
  75250. */
  75251. constructor(name: string, scene: BABYLON.Scene);
  75252. /**
  75253. * Returns wehter or not the grid requires alpha blending.
  75254. */
  75255. needAlphaBlending(): boolean;
  75256. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  75257. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75258. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75259. /**
  75260. * Dispose the material and its associated resources.
  75261. * @param forceDisposeEffect will also dispose the used effect when true
  75262. */
  75263. dispose(forceDisposeEffect?: boolean): void;
  75264. clone(name: string): GridMaterial;
  75265. serialize(): any;
  75266. getClassName(): string;
  75267. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  75268. }
  75269. }
  75270. declare module BABYLON {
  75271. /** @hidden */
  75272. export var lavaPixelShader: {
  75273. name: string;
  75274. shader: string;
  75275. };
  75276. }
  75277. declare module BABYLON {
  75278. /** @hidden */
  75279. export var lavaVertexShader: {
  75280. name: string;
  75281. shader: string;
  75282. };
  75283. }
  75284. declare module BABYLON {
  75285. export class LavaMaterial extends BABYLON.PushMaterial {
  75286. private _diffuseTexture;
  75287. diffuseTexture: BABYLON.BaseTexture;
  75288. noiseTexture: BABYLON.BaseTexture;
  75289. fogColor: BABYLON.Color3;
  75290. speed: number;
  75291. movingSpeed: number;
  75292. lowFrequencySpeed: number;
  75293. fogDensity: number;
  75294. private _lastTime;
  75295. diffuseColor: BABYLON.Color3;
  75296. private _disableLighting;
  75297. disableLighting: boolean;
  75298. private _unlit;
  75299. unlit: boolean;
  75300. private _maxSimultaneousLights;
  75301. maxSimultaneousLights: number;
  75302. private _scaledDiffuse;
  75303. private _renderId;
  75304. constructor(name: string, scene: BABYLON.Scene);
  75305. needAlphaBlending(): boolean;
  75306. needAlphaTesting(): boolean;
  75307. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75308. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75309. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75310. getAnimatables(): BABYLON.IAnimatable[];
  75311. getActiveTextures(): BABYLON.BaseTexture[];
  75312. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75313. dispose(forceDisposeEffect?: boolean): void;
  75314. clone(name: string): LavaMaterial;
  75315. serialize(): any;
  75316. getClassName(): string;
  75317. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  75318. }
  75319. }
  75320. declare module BABYLON {
  75321. /** @hidden */
  75322. export var mixPixelShader: {
  75323. name: string;
  75324. shader: string;
  75325. };
  75326. }
  75327. declare module BABYLON {
  75328. /** @hidden */
  75329. export var mixVertexShader: {
  75330. name: string;
  75331. shader: string;
  75332. };
  75333. }
  75334. declare module BABYLON {
  75335. export class MixMaterial extends BABYLON.PushMaterial {
  75336. /**
  75337. * Mix textures
  75338. */
  75339. private _mixTexture1;
  75340. mixTexture1: BABYLON.BaseTexture;
  75341. private _mixTexture2;
  75342. mixTexture2: BABYLON.BaseTexture;
  75343. /**
  75344. * Diffuse textures
  75345. */
  75346. private _diffuseTexture1;
  75347. diffuseTexture1: BABYLON.Texture;
  75348. private _diffuseTexture2;
  75349. diffuseTexture2: BABYLON.Texture;
  75350. private _diffuseTexture3;
  75351. diffuseTexture3: BABYLON.Texture;
  75352. private _diffuseTexture4;
  75353. diffuseTexture4: BABYLON.Texture;
  75354. private _diffuseTexture5;
  75355. diffuseTexture5: BABYLON.Texture;
  75356. private _diffuseTexture6;
  75357. diffuseTexture6: BABYLON.Texture;
  75358. private _diffuseTexture7;
  75359. diffuseTexture7: BABYLON.Texture;
  75360. private _diffuseTexture8;
  75361. diffuseTexture8: BABYLON.Texture;
  75362. /**
  75363. * Uniforms
  75364. */
  75365. diffuseColor: BABYLON.Color3;
  75366. specularColor: BABYLON.Color3;
  75367. specularPower: number;
  75368. private _disableLighting;
  75369. disableLighting: boolean;
  75370. private _maxSimultaneousLights;
  75371. maxSimultaneousLights: number;
  75372. private _renderId;
  75373. constructor(name: string, scene: BABYLON.Scene);
  75374. needAlphaBlending(): boolean;
  75375. needAlphaTesting(): boolean;
  75376. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75377. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75378. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75379. getAnimatables(): BABYLON.IAnimatable[];
  75380. getActiveTextures(): BABYLON.BaseTexture[];
  75381. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75382. dispose(forceDisposeEffect?: boolean): void;
  75383. clone(name: string): MixMaterial;
  75384. serialize(): any;
  75385. getClassName(): string;
  75386. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  75387. }
  75388. }
  75389. declare module BABYLON {
  75390. /** @hidden */
  75391. export var normalPixelShader: {
  75392. name: string;
  75393. shader: string;
  75394. };
  75395. }
  75396. declare module BABYLON {
  75397. /** @hidden */
  75398. export var normalVertexShader: {
  75399. name: string;
  75400. shader: string;
  75401. };
  75402. }
  75403. declare module BABYLON {
  75404. export class NormalMaterial extends BABYLON.PushMaterial {
  75405. private _diffuseTexture;
  75406. diffuseTexture: BABYLON.BaseTexture;
  75407. diffuseColor: BABYLON.Color3;
  75408. private _disableLighting;
  75409. disableLighting: boolean;
  75410. private _maxSimultaneousLights;
  75411. maxSimultaneousLights: number;
  75412. private _renderId;
  75413. constructor(name: string, scene: BABYLON.Scene);
  75414. needAlphaBlending(): boolean;
  75415. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  75416. needAlphaTesting(): boolean;
  75417. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75418. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75419. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75420. getAnimatables(): BABYLON.IAnimatable[];
  75421. getActiveTextures(): BABYLON.BaseTexture[];
  75422. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75423. dispose(forceDisposeEffect?: boolean): void;
  75424. clone(name: string): NormalMaterial;
  75425. serialize(): any;
  75426. getClassName(): string;
  75427. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  75428. }
  75429. }
  75430. declare module BABYLON {
  75431. /** @hidden */
  75432. export var shadowOnlyPixelShader: {
  75433. name: string;
  75434. shader: string;
  75435. };
  75436. }
  75437. declare module BABYLON {
  75438. /** @hidden */
  75439. export var shadowOnlyVertexShader: {
  75440. name: string;
  75441. shader: string;
  75442. };
  75443. }
  75444. declare module BABYLON {
  75445. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  75446. private _renderId;
  75447. private _activeLight;
  75448. constructor(name: string, scene: BABYLON.Scene);
  75449. shadowColor: BABYLON.Color3;
  75450. needAlphaBlending(): boolean;
  75451. needAlphaTesting(): boolean;
  75452. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75453. activeLight: BABYLON.IShadowLight;
  75454. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75455. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75456. clone(name: string): ShadowOnlyMaterial;
  75457. serialize(): any;
  75458. getClassName(): string;
  75459. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  75460. }
  75461. }
  75462. declare module BABYLON {
  75463. /** @hidden */
  75464. export var simplePixelShader: {
  75465. name: string;
  75466. shader: string;
  75467. };
  75468. }
  75469. declare module BABYLON {
  75470. /** @hidden */
  75471. export var simpleVertexShader: {
  75472. name: string;
  75473. shader: string;
  75474. };
  75475. }
  75476. declare module BABYLON {
  75477. export class SimpleMaterial extends BABYLON.PushMaterial {
  75478. private _diffuseTexture;
  75479. diffuseTexture: BABYLON.BaseTexture;
  75480. diffuseColor: BABYLON.Color3;
  75481. private _disableLighting;
  75482. disableLighting: boolean;
  75483. private _maxSimultaneousLights;
  75484. maxSimultaneousLights: number;
  75485. private _renderId;
  75486. constructor(name: string, scene: BABYLON.Scene);
  75487. needAlphaBlending(): boolean;
  75488. needAlphaTesting(): boolean;
  75489. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75490. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75491. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75492. getAnimatables(): BABYLON.IAnimatable[];
  75493. getActiveTextures(): BABYLON.BaseTexture[];
  75494. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75495. dispose(forceDisposeEffect?: boolean): void;
  75496. clone(name: string): SimpleMaterial;
  75497. serialize(): any;
  75498. getClassName(): string;
  75499. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  75500. }
  75501. }
  75502. declare module BABYLON {
  75503. /** @hidden */
  75504. export var skyPixelShader: {
  75505. name: string;
  75506. shader: string;
  75507. };
  75508. }
  75509. declare module BABYLON {
  75510. /** @hidden */
  75511. export var skyVertexShader: {
  75512. name: string;
  75513. shader: string;
  75514. };
  75515. }
  75516. declare module BABYLON {
  75517. /**
  75518. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  75519. * @see https://doc.babylonjs.com/extensions/sky
  75520. */
  75521. export class SkyMaterial extends BABYLON.PushMaterial {
  75522. /**
  75523. * Defines the overall luminance of sky in interval ]0, 1[.
  75524. */
  75525. luminance: number;
  75526. /**
  75527. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  75528. */
  75529. turbidity: number;
  75530. /**
  75531. * Defines the sky appearance (light intensity).
  75532. */
  75533. rayleigh: number;
  75534. /**
  75535. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  75536. */
  75537. mieCoefficient: number;
  75538. /**
  75539. * Defines the amount of haze particles following the Mie scattering theory.
  75540. */
  75541. mieDirectionalG: number;
  75542. /**
  75543. * Defines the distance of the sun according to the active scene camera.
  75544. */
  75545. distance: number;
  75546. /**
  75547. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  75548. * "inclined".
  75549. */
  75550. inclination: number;
  75551. /**
  75552. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  75553. * an object direction and a reference direction.
  75554. */
  75555. azimuth: number;
  75556. /**
  75557. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  75558. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  75559. */
  75560. sunPosition: BABYLON.Vector3;
  75561. /**
  75562. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  75563. * .sunPosition property.
  75564. */
  75565. useSunPosition: boolean;
  75566. /**
  75567. * Defines an offset vector used to get a horizon offset.
  75568. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  75569. */
  75570. cameraOffset: BABYLON.Vector3;
  75571. private _cameraPosition;
  75572. private _renderId;
  75573. /**
  75574. * Instantiates a new sky material.
  75575. * This material allows to create dynamic and texture free
  75576. * effects for skyboxes by taking care of the atmosphere state.
  75577. * @see https://doc.babylonjs.com/extensions/sky
  75578. * @param name Define the name of the material in the scene
  75579. * @param scene Define the scene the material belong to
  75580. */
  75581. constructor(name: string, scene: BABYLON.Scene);
  75582. /**
  75583. * Specifies if the material will require alpha blending
  75584. * @returns a boolean specifying if alpha blending is needed
  75585. */
  75586. needAlphaBlending(): boolean;
  75587. /**
  75588. * Specifies if this material should be rendered in alpha test mode
  75589. * @returns false as the sky material doesn't need alpha testing.
  75590. */
  75591. needAlphaTesting(): boolean;
  75592. /**
  75593. * Get the texture used for alpha test purpose.
  75594. * @returns null as the sky material has no texture.
  75595. */
  75596. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75597. /**
  75598. * Get if the submesh is ready to be used and all its information available.
  75599. * Child classes can use it to update shaders
  75600. * @param mesh defines the mesh to check
  75601. * @param subMesh defines which submesh to check
  75602. * @param useInstances specifies that instances should be used
  75603. * @returns a boolean indicating that the submesh is ready or not
  75604. */
  75605. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75606. /**
  75607. * Binds the submesh to this material by preparing the effect and shader to draw
  75608. * @param world defines the world transformation matrix
  75609. * @param mesh defines the mesh containing the submesh
  75610. * @param subMesh defines the submesh to bind the material to
  75611. */
  75612. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75613. /**
  75614. * Get the list of animatables in the material.
  75615. * @returns the list of animatables object used in the material
  75616. */
  75617. getAnimatables(): BABYLON.IAnimatable[];
  75618. /**
  75619. * Disposes the material
  75620. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75621. */
  75622. dispose(forceDisposeEffect?: boolean): void;
  75623. /**
  75624. * Makes a duplicate of the material, and gives it a new name
  75625. * @param name defines the new name for the duplicated material
  75626. * @returns the cloned material
  75627. */
  75628. clone(name: string): SkyMaterial;
  75629. /**
  75630. * Serializes this material in a JSON representation
  75631. * @returns the serialized material object
  75632. */
  75633. serialize(): any;
  75634. /**
  75635. * Gets the current class name of the material e.g. "SkyMaterial"
  75636. * Mainly use in serialization.
  75637. * @returns the class name
  75638. */
  75639. getClassName(): string;
  75640. /**
  75641. * Creates a sky material from parsed material data
  75642. * @param source defines the JSON representation of the material
  75643. * @param scene defines the hosting scene
  75644. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75645. * @returns a new sky material
  75646. */
  75647. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  75648. }
  75649. }
  75650. declare module BABYLON {
  75651. /** @hidden */
  75652. export var terrainPixelShader: {
  75653. name: string;
  75654. shader: string;
  75655. };
  75656. }
  75657. declare module BABYLON {
  75658. /** @hidden */
  75659. export var terrainVertexShader: {
  75660. name: string;
  75661. shader: string;
  75662. };
  75663. }
  75664. declare module BABYLON {
  75665. export class TerrainMaterial extends BABYLON.PushMaterial {
  75666. private _mixTexture;
  75667. mixTexture: BABYLON.BaseTexture;
  75668. private _diffuseTexture1;
  75669. diffuseTexture1: BABYLON.Texture;
  75670. private _diffuseTexture2;
  75671. diffuseTexture2: BABYLON.Texture;
  75672. private _diffuseTexture3;
  75673. diffuseTexture3: BABYLON.Texture;
  75674. private _bumpTexture1;
  75675. bumpTexture1: BABYLON.Texture;
  75676. private _bumpTexture2;
  75677. bumpTexture2: BABYLON.Texture;
  75678. private _bumpTexture3;
  75679. bumpTexture3: BABYLON.Texture;
  75680. diffuseColor: BABYLON.Color3;
  75681. specularColor: BABYLON.Color3;
  75682. specularPower: number;
  75683. private _disableLighting;
  75684. disableLighting: boolean;
  75685. private _maxSimultaneousLights;
  75686. maxSimultaneousLights: number;
  75687. private _renderId;
  75688. constructor(name: string, scene: BABYLON.Scene);
  75689. needAlphaBlending(): boolean;
  75690. needAlphaTesting(): boolean;
  75691. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75692. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75693. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75694. getAnimatables(): BABYLON.IAnimatable[];
  75695. getActiveTextures(): BABYLON.BaseTexture[];
  75696. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75697. dispose(forceDisposeEffect?: boolean): void;
  75698. clone(name: string): TerrainMaterial;
  75699. serialize(): any;
  75700. getClassName(): string;
  75701. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  75702. }
  75703. }
  75704. declare module BABYLON {
  75705. /** @hidden */
  75706. export var triplanarPixelShader: {
  75707. name: string;
  75708. shader: string;
  75709. };
  75710. }
  75711. declare module BABYLON {
  75712. /** @hidden */
  75713. export var triplanarVertexShader: {
  75714. name: string;
  75715. shader: string;
  75716. };
  75717. }
  75718. declare module BABYLON {
  75719. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  75720. mixTexture: BABYLON.BaseTexture;
  75721. private _diffuseTextureX;
  75722. diffuseTextureX: BABYLON.BaseTexture;
  75723. private _diffuseTextureY;
  75724. diffuseTextureY: BABYLON.BaseTexture;
  75725. private _diffuseTextureZ;
  75726. diffuseTextureZ: BABYLON.BaseTexture;
  75727. private _normalTextureX;
  75728. normalTextureX: BABYLON.BaseTexture;
  75729. private _normalTextureY;
  75730. normalTextureY: BABYLON.BaseTexture;
  75731. private _normalTextureZ;
  75732. normalTextureZ: BABYLON.BaseTexture;
  75733. tileSize: number;
  75734. diffuseColor: BABYLON.Color3;
  75735. specularColor: BABYLON.Color3;
  75736. specularPower: number;
  75737. private _disableLighting;
  75738. disableLighting: boolean;
  75739. private _maxSimultaneousLights;
  75740. maxSimultaneousLights: number;
  75741. private _renderId;
  75742. constructor(name: string, scene: BABYLON.Scene);
  75743. needAlphaBlending(): boolean;
  75744. needAlphaTesting(): boolean;
  75745. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75746. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75747. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75748. getAnimatables(): BABYLON.IAnimatable[];
  75749. getActiveTextures(): BABYLON.BaseTexture[];
  75750. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75751. dispose(forceDisposeEffect?: boolean): void;
  75752. clone(name: string): TriPlanarMaterial;
  75753. serialize(): any;
  75754. getClassName(): string;
  75755. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  75756. }
  75757. }
  75758. declare module BABYLON {
  75759. /** @hidden */
  75760. export var waterPixelShader: {
  75761. name: string;
  75762. shader: string;
  75763. };
  75764. }
  75765. declare module BABYLON {
  75766. /** @hidden */
  75767. export var waterVertexShader: {
  75768. name: string;
  75769. shader: string;
  75770. };
  75771. }
  75772. declare module BABYLON {
  75773. export class WaterMaterial extends BABYLON.PushMaterial {
  75774. renderTargetSize: BABYLON.Vector2;
  75775. private _bumpTexture;
  75776. bumpTexture: BABYLON.BaseTexture;
  75777. diffuseColor: BABYLON.Color3;
  75778. specularColor: BABYLON.Color3;
  75779. specularPower: number;
  75780. private _disableLighting;
  75781. disableLighting: boolean;
  75782. private _maxSimultaneousLights;
  75783. maxSimultaneousLights: number;
  75784. /**
  75785. * @param {number}: Represents the wind force
  75786. */
  75787. windForce: number;
  75788. /**
  75789. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  75790. */
  75791. windDirection: BABYLON.Vector2;
  75792. /**
  75793. * @param {number}: Wave height, represents the height of the waves
  75794. */
  75795. waveHeight: number;
  75796. /**
  75797. * @param {number}: Bump height, represents the bump height related to the bump map
  75798. */
  75799. bumpHeight: number;
  75800. /**
  75801. * @param {boolean}: Add a smaller moving bump to less steady waves.
  75802. */
  75803. private _bumpSuperimpose;
  75804. bumpSuperimpose: boolean;
  75805. /**
  75806. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  75807. */
  75808. private _fresnelSeparate;
  75809. fresnelSeparate: boolean;
  75810. /**
  75811. * @param {boolean}: bump Waves modify the reflection.
  75812. */
  75813. private _bumpAffectsReflection;
  75814. bumpAffectsReflection: boolean;
  75815. /**
  75816. * @param {number}: The water color blended with the refraction (near)
  75817. */
  75818. waterColor: BABYLON.Color3;
  75819. /**
  75820. * @param {number}: The blend factor related to the water color
  75821. */
  75822. colorBlendFactor: number;
  75823. /**
  75824. * @param {number}: The water color blended with the reflection (far)
  75825. */
  75826. waterColor2: BABYLON.Color3;
  75827. /**
  75828. * @param {number}: The blend factor related to the water color (reflection, far)
  75829. */
  75830. colorBlendFactor2: number;
  75831. /**
  75832. * @param {number}: Represents the maximum length of a wave
  75833. */
  75834. waveLength: number;
  75835. /**
  75836. * @param {number}: Defines the waves speed
  75837. */
  75838. waveSpeed: number;
  75839. /**
  75840. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  75841. * will avoid calculating useless pixels in the pixel shader of the water material.
  75842. */
  75843. disableClipPlane: boolean;
  75844. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  75845. private _mesh;
  75846. private _refractionRTT;
  75847. private _reflectionRTT;
  75848. private _reflectionTransform;
  75849. private _lastTime;
  75850. private _lastDeltaTime;
  75851. private _renderId;
  75852. private _useLogarithmicDepth;
  75853. private _waitingRenderList;
  75854. private _imageProcessingConfiguration;
  75855. private _imageProcessingObserver;
  75856. /**
  75857. * Gets a boolean indicating that current material needs to register RTT
  75858. */
  75859. readonly hasRenderTargetTextures: boolean;
  75860. /**
  75861. * Constructor
  75862. */
  75863. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  75864. useLogarithmicDepth: boolean;
  75865. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  75866. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  75867. addToRenderList(node: any): void;
  75868. enableRenderTargets(enable: boolean): void;
  75869. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  75870. readonly renderTargetsEnabled: boolean;
  75871. needAlphaBlending(): boolean;
  75872. needAlphaTesting(): boolean;
  75873. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75874. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75875. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75876. private _createRenderTargets;
  75877. getAnimatables(): BABYLON.IAnimatable[];
  75878. getActiveTextures(): BABYLON.BaseTexture[];
  75879. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75880. dispose(forceDisposeEffect?: boolean): void;
  75881. clone(name: string): WaterMaterial;
  75882. serialize(): any;
  75883. getClassName(): string;
  75884. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  75885. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  75886. }
  75887. }
  75888. declare module BABYLON {
  75889. /** @hidden */
  75890. export var asciiartPixelShader: {
  75891. name: string;
  75892. shader: string;
  75893. };
  75894. }
  75895. declare module BABYLON {
  75896. /**
  75897. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  75898. *
  75899. * It basically takes care rendering the font front the given font size to a texture.
  75900. * This is used later on in the postprocess.
  75901. */
  75902. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  75903. private _font;
  75904. private _text;
  75905. private _charSize;
  75906. /**
  75907. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  75908. */
  75909. readonly charSize: number;
  75910. /**
  75911. * Create a new instance of the Ascii Art FontTexture class
  75912. * @param name the name of the texture
  75913. * @param font the font to use, use the W3C CSS notation
  75914. * @param text the caracter set to use in the rendering.
  75915. * @param scene the scene that owns the texture
  75916. */
  75917. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  75918. /**
  75919. * Gets the max char width of a font.
  75920. * @param font the font to use, use the W3C CSS notation
  75921. * @return the max char width
  75922. */
  75923. private getFontWidth;
  75924. /**
  75925. * Gets the max char height of a font.
  75926. * @param font the font to use, use the W3C CSS notation
  75927. * @return the max char height
  75928. */
  75929. private getFontHeight;
  75930. /**
  75931. * Clones the current AsciiArtTexture.
  75932. * @return the clone of the texture.
  75933. */
  75934. clone(): AsciiArtFontTexture;
  75935. /**
  75936. * Parses a json object representing the texture and returns an instance of it.
  75937. * @param source the source JSON representation
  75938. * @param scene the scene to create the texture for
  75939. * @return the parsed texture
  75940. */
  75941. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  75942. }
  75943. /**
  75944. * Option available in the Ascii Art Post Process.
  75945. */
  75946. export interface IAsciiArtPostProcessOptions {
  75947. /**
  75948. * The font to use following the w3c font definition.
  75949. */
  75950. font?: string;
  75951. /**
  75952. * The character set to use in the postprocess.
  75953. */
  75954. characterSet?: string;
  75955. /**
  75956. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  75957. * This number is defined between 0 and 1;
  75958. */
  75959. mixToTile?: number;
  75960. /**
  75961. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  75962. * This number is defined between 0 and 1;
  75963. */
  75964. mixToNormal?: number;
  75965. }
  75966. /**
  75967. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  75968. *
  75969. * Simmply add it to your scene and let the nerd that lives in you have fun.
  75970. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  75971. */
  75972. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  75973. /**
  75974. * The font texture used to render the char in the post process.
  75975. */
  75976. private _asciiArtFontTexture;
  75977. /**
  75978. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  75979. * This number is defined between 0 and 1;
  75980. */
  75981. mixToTile: number;
  75982. /**
  75983. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  75984. * This number is defined between 0 and 1;
  75985. */
  75986. mixToNormal: number;
  75987. /**
  75988. * Instantiates a new Ascii Art Post Process.
  75989. * @param name the name to give to the postprocess
  75990. * @camera the camera to apply the post process to.
  75991. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  75992. */
  75993. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  75994. }
  75995. }
  75996. declare module BABYLON {
  75997. /** @hidden */
  75998. export var digitalrainPixelShader: {
  75999. name: string;
  76000. shader: string;
  76001. };
  76002. }
  76003. declare module BABYLON {
  76004. /**
  76005. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  76006. *
  76007. * It basically takes care rendering the font front the given font size to a texture.
  76008. * This is used later on in the postprocess.
  76009. */
  76010. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  76011. private _font;
  76012. private _text;
  76013. private _charSize;
  76014. /**
  76015. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  76016. */
  76017. readonly charSize: number;
  76018. /**
  76019. * Create a new instance of the Digital Rain FontTexture class
  76020. * @param name the name of the texture
  76021. * @param font the font to use, use the W3C CSS notation
  76022. * @param text the caracter set to use in the rendering.
  76023. * @param scene the scene that owns the texture
  76024. */
  76025. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  76026. /**
  76027. * Gets the max char width of a font.
  76028. * @param font the font to use, use the W3C CSS notation
  76029. * @return the max char width
  76030. */
  76031. private getFontWidth;
  76032. /**
  76033. * Gets the max char height of a font.
  76034. * @param font the font to use, use the W3C CSS notation
  76035. * @return the max char height
  76036. */
  76037. private getFontHeight;
  76038. /**
  76039. * Clones the current DigitalRainFontTexture.
  76040. * @return the clone of the texture.
  76041. */
  76042. clone(): DigitalRainFontTexture;
  76043. /**
  76044. * Parses a json object representing the texture and returns an instance of it.
  76045. * @param source the source JSON representation
  76046. * @param scene the scene to create the texture for
  76047. * @return the parsed texture
  76048. */
  76049. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  76050. }
  76051. /**
  76052. * Option available in the Digital Rain Post Process.
  76053. */
  76054. export interface IDigitalRainPostProcessOptions {
  76055. /**
  76056. * The font to use following the w3c font definition.
  76057. */
  76058. font?: string;
  76059. /**
  76060. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  76061. * This number is defined between 0 and 1;
  76062. */
  76063. mixToTile?: number;
  76064. /**
  76065. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  76066. * This number is defined between 0 and 1;
  76067. */
  76068. mixToNormal?: number;
  76069. }
  76070. /**
  76071. * DigitalRainPostProcess helps rendering everithing in digital rain.
  76072. *
  76073. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76074. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  76075. */
  76076. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  76077. /**
  76078. * The font texture used to render the char in the post process.
  76079. */
  76080. private _digitalRainFontTexture;
  76081. /**
  76082. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  76083. * This number is defined between 0 and 1;
  76084. */
  76085. mixToTile: number;
  76086. /**
  76087. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  76088. * This number is defined between 0 and 1;
  76089. */
  76090. mixToNormal: number;
  76091. /**
  76092. * Instantiates a new Digital Rain Post Process.
  76093. * @param name the name to give to the postprocess
  76094. * @camera the camera to apply the post process to.
  76095. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  76096. */
  76097. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  76098. }
  76099. }
  76100. declare module BABYLON {
  76101. /** @hidden */
  76102. export var oceanPostProcessPixelShader: {
  76103. name: string;
  76104. shader: string;
  76105. };
  76106. }
  76107. declare module BABYLON {
  76108. /**
  76109. * Option available in the Ocean Post Process.
  76110. */
  76111. export interface IOceanPostProcessOptions {
  76112. /**
  76113. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  76114. */
  76115. reflectionSize?: number | {
  76116. width: number;
  76117. height: number;
  76118. } | {
  76119. ratio: number;
  76120. };
  76121. /**
  76122. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  76123. */
  76124. refractionSize?: number | {
  76125. width: number;
  76126. height: number;
  76127. } | {
  76128. ratio: number;
  76129. };
  76130. }
  76131. /**
  76132. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  76133. *
  76134. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76135. * Example usage:
  76136. * var pp = new OceanPostProcess("myOcean", camera);
  76137. * pp.reflectionEnabled = true;
  76138. * pp.refractionEnabled = true;
  76139. */
  76140. export class OceanPostProcess extends BABYLON.PostProcess {
  76141. /**
  76142. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  76143. */
  76144. /**
  76145. * Sets weither or not the real-time reflection is enabled on the ocean.
  76146. * Is set to true, the reflection mirror texture will be used as reflection texture.
  76147. */
  76148. reflectionEnabled: boolean;
  76149. /**
  76150. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  76151. */
  76152. /**
  76153. * Sets weither or not the real-time refraction is enabled on the ocean.
  76154. * Is set to true, the refraction render target texture will be used as refraction texture.
  76155. */
  76156. refractionEnabled: boolean;
  76157. /**
  76158. * Gets wether or not the post-processes is supported by the running hardware.
  76159. * This requires draw buffer supports.
  76160. */
  76161. readonly isSupported: boolean;
  76162. /**
  76163. * This is the reflection mirror texture used to display reflections on the ocean.
  76164. * By default, render list is empty.
  76165. */
  76166. reflectionTexture: BABYLON.MirrorTexture;
  76167. /**
  76168. * This is the refraction render target texture used to display refraction on the ocean.
  76169. * By default, render list is empty.
  76170. */
  76171. refractionTexture: BABYLON.RenderTargetTexture;
  76172. private _time;
  76173. private _cameraRotation;
  76174. private _cameraViewMatrix;
  76175. private _reflectionEnabled;
  76176. private _refractionEnabled;
  76177. private _geometryRenderer;
  76178. /**
  76179. * Instantiates a new Ocean Post Process.
  76180. * @param name the name to give to the postprocess.
  76181. * @camera the camera to apply the post process to.
  76182. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  76183. */
  76184. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  76185. /**
  76186. * Returns the appropriate defines according to the current configuration.
  76187. */
  76188. private _getDefines;
  76189. /**
  76190. * Computes the current camera rotation as the shader requires a camera rotation.
  76191. */
  76192. private _computeCameraRotation;
  76193. }
  76194. }
  76195. declare module BABYLON {
  76196. /** @hidden */
  76197. export var brickProceduralTexturePixelShader: {
  76198. name: string;
  76199. shader: string;
  76200. };
  76201. }
  76202. declare module BABYLON {
  76203. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  76204. private _numberOfBricksHeight;
  76205. private _numberOfBricksWidth;
  76206. private _jointColor;
  76207. private _brickColor;
  76208. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76209. updateShaderUniforms(): void;
  76210. numberOfBricksHeight: number;
  76211. numberOfBricksWidth: number;
  76212. jointColor: BABYLON.Color3;
  76213. brickColor: BABYLON.Color3;
  76214. /**
  76215. * Serializes this brick procedural texture
  76216. * @returns a serialized brick procedural texture object
  76217. */
  76218. serialize(): any;
  76219. /**
  76220. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  76221. * @param parsedTexture defines parsed texture data
  76222. * @param scene defines the current scene
  76223. * @param rootUrl defines the root URL containing brick procedural texture information
  76224. * @returns a parsed Brick Procedural BABYLON.Texture
  76225. */
  76226. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  76227. }
  76228. }
  76229. declare module BABYLON {
  76230. /** @hidden */
  76231. export var cloudProceduralTexturePixelShader: {
  76232. name: string;
  76233. shader: string;
  76234. };
  76235. }
  76236. declare module BABYLON {
  76237. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  76238. private _skyColor;
  76239. private _cloudColor;
  76240. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76241. updateShaderUniforms(): void;
  76242. skyColor: BABYLON.Color4;
  76243. cloudColor: BABYLON.Color4;
  76244. /**
  76245. * Serializes this cloud procedural texture
  76246. * @returns a serialized cloud procedural texture object
  76247. */
  76248. serialize(): any;
  76249. /**
  76250. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  76251. * @param parsedTexture defines parsed texture data
  76252. * @param scene defines the current scene
  76253. * @param rootUrl defines the root URL containing cloud procedural texture information
  76254. * @returns a parsed Cloud Procedural BABYLON.Texture
  76255. */
  76256. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  76257. }
  76258. }
  76259. declare module BABYLON {
  76260. /** @hidden */
  76261. export var fireProceduralTexturePixelShader: {
  76262. name: string;
  76263. shader: string;
  76264. };
  76265. }
  76266. declare module BABYLON {
  76267. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  76268. private _time;
  76269. private _speed;
  76270. private _autoGenerateTime;
  76271. private _fireColors;
  76272. private _alphaThreshold;
  76273. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76274. updateShaderUniforms(): void;
  76275. render(useCameraPostProcess?: boolean): void;
  76276. static readonly PurpleFireColors: BABYLON.Color3[];
  76277. static readonly GreenFireColors: BABYLON.Color3[];
  76278. static readonly RedFireColors: BABYLON.Color3[];
  76279. static readonly BlueFireColors: BABYLON.Color3[];
  76280. autoGenerateTime: boolean;
  76281. fireColors: BABYLON.Color3[];
  76282. time: number;
  76283. speed: BABYLON.Vector2;
  76284. alphaThreshold: number;
  76285. /**
  76286. * Serializes this fire procedural texture
  76287. * @returns a serialized fire procedural texture object
  76288. */
  76289. serialize(): any;
  76290. /**
  76291. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  76292. * @param parsedTexture defines parsed texture data
  76293. * @param scene defines the current scene
  76294. * @param rootUrl defines the root URL containing fire procedural texture information
  76295. * @returns a parsed Fire Procedural BABYLON.Texture
  76296. */
  76297. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  76298. }
  76299. }
  76300. declare module BABYLON {
  76301. /** @hidden */
  76302. export var grassProceduralTexturePixelShader: {
  76303. name: string;
  76304. shader: string;
  76305. };
  76306. }
  76307. declare module BABYLON {
  76308. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  76309. private _grassColors;
  76310. private _groundColor;
  76311. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76312. updateShaderUniforms(): void;
  76313. grassColors: BABYLON.Color3[];
  76314. groundColor: BABYLON.Color3;
  76315. /**
  76316. * Serializes this grass procedural texture
  76317. * @returns a serialized grass procedural texture object
  76318. */
  76319. serialize(): any;
  76320. /**
  76321. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  76322. * @param parsedTexture defines parsed texture data
  76323. * @param scene defines the current scene
  76324. * @param rootUrl defines the root URL containing grass procedural texture information
  76325. * @returns a parsed Grass Procedural BABYLON.Texture
  76326. */
  76327. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  76328. }
  76329. }
  76330. declare module BABYLON {
  76331. /** @hidden */
  76332. export var marbleProceduralTexturePixelShader: {
  76333. name: string;
  76334. shader: string;
  76335. };
  76336. }
  76337. declare module BABYLON {
  76338. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  76339. private _numberOfTilesHeight;
  76340. private _numberOfTilesWidth;
  76341. private _amplitude;
  76342. private _jointColor;
  76343. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76344. updateShaderUniforms(): void;
  76345. numberOfTilesHeight: number;
  76346. amplitude: number;
  76347. numberOfTilesWidth: number;
  76348. jointColor: BABYLON.Color3;
  76349. /**
  76350. * Serializes this marble procedural texture
  76351. * @returns a serialized marble procedural texture object
  76352. */
  76353. serialize(): any;
  76354. /**
  76355. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  76356. * @param parsedTexture defines parsed texture data
  76357. * @param scene defines the current scene
  76358. * @param rootUrl defines the root URL containing marble procedural texture information
  76359. * @returns a parsed Marble Procedural BABYLON.Texture
  76360. */
  76361. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  76362. }
  76363. }
  76364. declare module BABYLON {
  76365. /** @hidden */
  76366. export var normalMapProceduralTexturePixelShader: {
  76367. name: string;
  76368. shader: string;
  76369. };
  76370. }
  76371. declare module BABYLON {
  76372. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  76373. private _baseTexture;
  76374. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76375. updateShaderUniforms(): void;
  76376. render(useCameraPostProcess?: boolean): void;
  76377. resize(size: any, generateMipMaps: any): void;
  76378. baseTexture: BABYLON.Texture;
  76379. /**
  76380. * Serializes this normal map procedural texture
  76381. * @returns a serialized normal map procedural texture object
  76382. */
  76383. serialize(): any;
  76384. /**
  76385. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  76386. * @param parsedTexture defines parsed texture data
  76387. * @param scene defines the current scene
  76388. * @param rootUrl defines the root URL containing normal map procedural texture information
  76389. * @returns a parsed Normal Map Procedural BABYLON.Texture
  76390. */
  76391. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  76392. }
  76393. }
  76394. declare module BABYLON {
  76395. /** @hidden */
  76396. export var perlinNoiseProceduralTexturePixelShader: {
  76397. name: string;
  76398. shader: string;
  76399. };
  76400. }
  76401. declare module BABYLON {
  76402. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  76403. time: number;
  76404. timeScale: number;
  76405. translationSpeed: number;
  76406. private _currentTranslation;
  76407. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76408. updateShaderUniforms(): void;
  76409. render(useCameraPostProcess?: boolean): void;
  76410. resize(size: any, generateMipMaps: any): void;
  76411. /**
  76412. * Serializes this perlin noise procedural texture
  76413. * @returns a serialized perlin noise procedural texture object
  76414. */
  76415. serialize(): any;
  76416. /**
  76417. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  76418. * @param parsedTexture defines parsed texture data
  76419. * @param scene defines the current scene
  76420. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  76421. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  76422. */
  76423. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  76424. }
  76425. }
  76426. declare module BABYLON {
  76427. /** @hidden */
  76428. export var roadProceduralTexturePixelShader: {
  76429. name: string;
  76430. shader: string;
  76431. };
  76432. }
  76433. declare module BABYLON {
  76434. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  76435. private _roadColor;
  76436. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76437. updateShaderUniforms(): void;
  76438. roadColor: BABYLON.Color3;
  76439. /**
  76440. * Serializes this road procedural texture
  76441. * @returns a serialized road procedural texture object
  76442. */
  76443. serialize(): any;
  76444. /**
  76445. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  76446. * @param parsedTexture defines parsed texture data
  76447. * @param scene defines the current scene
  76448. * @param rootUrl defines the root URL containing road procedural texture information
  76449. * @returns a parsed Road Procedural BABYLON.Texture
  76450. */
  76451. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  76452. }
  76453. }
  76454. declare module BABYLON {
  76455. /** @hidden */
  76456. export var starfieldProceduralTexturePixelShader: {
  76457. name: string;
  76458. shader: string;
  76459. };
  76460. }
  76461. declare module BABYLON {
  76462. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  76463. private _time;
  76464. private _alpha;
  76465. private _beta;
  76466. private _zoom;
  76467. private _formuparam;
  76468. private _stepsize;
  76469. private _tile;
  76470. private _brightness;
  76471. private _darkmatter;
  76472. private _distfading;
  76473. private _saturation;
  76474. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76475. updateShaderUniforms(): void;
  76476. time: number;
  76477. alpha: number;
  76478. beta: number;
  76479. formuparam: number;
  76480. stepsize: number;
  76481. zoom: number;
  76482. tile: number;
  76483. brightness: number;
  76484. darkmatter: number;
  76485. distfading: number;
  76486. saturation: number;
  76487. /**
  76488. * Serializes this starfield procedural texture
  76489. * @returns a serialized starfield procedural texture object
  76490. */
  76491. serialize(): any;
  76492. /**
  76493. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  76494. * @param parsedTexture defines parsed texture data
  76495. * @param scene defines the current scene
  76496. * @param rootUrl defines the root URL containing startfield procedural texture information
  76497. * @returns a parsed Starfield Procedural BABYLON.Texture
  76498. */
  76499. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  76500. }
  76501. }
  76502. declare module BABYLON {
  76503. /** @hidden */
  76504. export var woodProceduralTexturePixelShader: {
  76505. name: string;
  76506. shader: string;
  76507. };
  76508. }
  76509. declare module BABYLON {
  76510. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  76511. private _ampScale;
  76512. private _woodColor;
  76513. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76514. updateShaderUniforms(): void;
  76515. ampScale: number;
  76516. woodColor: BABYLON.Color3;
  76517. /**
  76518. * Serializes this wood procedural texture
  76519. * @returns a serialized wood procedural texture object
  76520. */
  76521. serialize(): any;
  76522. /**
  76523. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  76524. * @param parsedTexture defines parsed texture data
  76525. * @param scene defines the current scene
  76526. * @param rootUrl defines the root URL containing wood procedural texture information
  76527. * @returns a parsed Wood Procedural BABYLON.Texture
  76528. */
  76529. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  76530. }
  76531. }