documentation.d.ts 2.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */
  110. _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * 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.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * 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).
  161. * 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.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @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.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Extracts text content from a DOM element hierarchy
  283. * @param element defines the root element
  284. * @returns a string
  285. */
  286. static GetDOMTextContent(element: HTMLElement): string;
  287. }
  288. }
  289. declare module BABYLON {
  290. /**
  291. * Logger used througouht the application to allow configuration of
  292. * the log level required for the messages.
  293. */
  294. export class Logger {
  295. /**
  296. * No log
  297. */
  298. static readonly NoneLogLevel: number;
  299. /**
  300. * Only message logs
  301. */
  302. static readonly MessageLogLevel: number;
  303. /**
  304. * Only warning logs
  305. */
  306. static readonly WarningLogLevel: number;
  307. /**
  308. * Only error logs
  309. */
  310. static readonly ErrorLogLevel: number;
  311. /**
  312. * All logs
  313. */
  314. static readonly AllLogLevel: number;
  315. private static _LogCache;
  316. /**
  317. * Gets a value indicating the number of loading errors
  318. * @ignorenaming
  319. */
  320. static errorsCount: number;
  321. /**
  322. * Callback called when a new log is added
  323. */
  324. static OnNewCacheEntry: (entry: string) => void;
  325. private static _AddLogEntry;
  326. private static _FormatMessage;
  327. private static _LogDisabled;
  328. private static _LogEnabled;
  329. private static _WarnDisabled;
  330. private static _WarnEnabled;
  331. private static _ErrorDisabled;
  332. private static _ErrorEnabled;
  333. /**
  334. * Log a message to the console
  335. */
  336. static Log: (message: string) => void;
  337. /**
  338. * Write a warning message to the console
  339. */
  340. static Warn: (message: string) => void;
  341. /**
  342. * Write an error message to the console
  343. */
  344. static Error: (message: string) => void;
  345. /**
  346. * Gets current log cache (list of logs)
  347. */
  348. static readonly LogCache: string;
  349. /**
  350. * Clears the log cache
  351. */
  352. static ClearLogCache(): void;
  353. /**
  354. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  355. */
  356. static LogLevels: number;
  357. }
  358. }
  359. declare module BABYLON {
  360. /** @hidden */
  361. export class _TypeStore {
  362. /** @hidden */
  363. static RegisteredTypes: {
  364. [key: string]: Object;
  365. };
  366. /** @hidden */
  367. static GetClass(fqdn: string): any;
  368. }
  369. }
  370. declare module BABYLON {
  371. /**
  372. * Class containing a set of static utilities functions for deep copy.
  373. */
  374. export class DeepCopier {
  375. /**
  376. * Tries to copy an object by duplicating every property
  377. * @param source defines the source object
  378. * @param destination defines the target object
  379. * @param doNotCopyList defines a list of properties to avoid
  380. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  381. */
  382. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  383. }
  384. }
  385. declare module BABYLON {
  386. /**
  387. * Class containing a set of static utilities functions for precision date
  388. */
  389. export class PrecisionDate {
  390. /**
  391. * Gets either window.performance.now() if supported or Date.now() else
  392. */
  393. static readonly Now: number;
  394. }
  395. }
  396. declare module BABYLON {
  397. /** @hidden */
  398. export class _DevTools {
  399. static WarnImport(name: string): string;
  400. }
  401. }
  402. declare module BABYLON {
  403. /**
  404. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  405. */
  406. export class WebRequest {
  407. private _xhr;
  408. /**
  409. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  410. * i.e. when loading files, where the server/service expects an Authorization header
  411. */
  412. static CustomRequestHeaders: {
  413. [key: string]: string;
  414. };
  415. /**
  416. * Add callback functions in this array to update all the requests before they get sent to the network
  417. */
  418. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  419. private _injectCustomRequestHeaders;
  420. /**
  421. * Gets or sets a function to be called when loading progress changes
  422. */
  423. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  424. /**
  425. * Returns client's state
  426. */
  427. readonly readyState: number;
  428. /**
  429. * Returns client's status
  430. */
  431. readonly status: number;
  432. /**
  433. * Returns client's status as a text
  434. */
  435. readonly statusText: string;
  436. /**
  437. * Returns client's response
  438. */
  439. readonly response: any;
  440. /**
  441. * Returns client's response url
  442. */
  443. readonly responseURL: string;
  444. /**
  445. * Returns client's response as text
  446. */
  447. readonly responseText: string;
  448. /**
  449. * Gets or sets the expected response type
  450. */
  451. responseType: XMLHttpRequestResponseType;
  452. /** @hidden */
  453. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  454. /** @hidden */
  455. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  456. /**
  457. * Cancels any network activity
  458. */
  459. abort(): void;
  460. /**
  461. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  462. * @param body defines an optional request body
  463. */
  464. send(body?: Document | BodyInit | null): void;
  465. /**
  466. * Sets the request method, request URL
  467. * @param method defines the method to use (GET, POST, etc..)
  468. * @param url defines the url to connect with
  469. */
  470. open(method: string, url: string): void;
  471. }
  472. }
  473. declare module BABYLON {
  474. /**
  475. * File request interface
  476. */
  477. export interface IFileRequest {
  478. /**
  479. * Raised when the request is complete (success or error).
  480. */
  481. onCompleteObservable: Observable<IFileRequest>;
  482. /**
  483. * Aborts the request for a file.
  484. */
  485. abort: () => void;
  486. }
  487. }
  488. declare module BABYLON {
  489. /**
  490. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  491. */
  492. export class PerformanceMonitor {
  493. private _enabled;
  494. private _rollingFrameTime;
  495. private _lastFrameTimeMs;
  496. /**
  497. * constructor
  498. * @param frameSampleSize The number of samples required to saturate the sliding window
  499. */
  500. constructor(frameSampleSize?: number);
  501. /**
  502. * Samples current frame
  503. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  504. */
  505. sampleFrame(timeMs?: number): void;
  506. /**
  507. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  508. */
  509. readonly averageFrameTime: number;
  510. /**
  511. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  512. */
  513. readonly averageFrameTimeVariance: number;
  514. /**
  515. * Returns the frame time of the most recent frame
  516. */
  517. readonly instantaneousFrameTime: number;
  518. /**
  519. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  520. */
  521. readonly averageFPS: number;
  522. /**
  523. * Returns the average framerate in frames per second using the most recent frame time
  524. */
  525. readonly instantaneousFPS: number;
  526. /**
  527. * Returns true if enough samples have been taken to completely fill the sliding window
  528. */
  529. readonly isSaturated: boolean;
  530. /**
  531. * Enables contributions to the sliding window sample set
  532. */
  533. enable(): void;
  534. /**
  535. * Disables contributions to the sliding window sample set
  536. * Samples will not be interpolated over the disabled period
  537. */
  538. disable(): void;
  539. /**
  540. * Returns true if sampling is enabled
  541. */
  542. readonly isEnabled: boolean;
  543. /**
  544. * Resets performance monitor
  545. */
  546. reset(): void;
  547. }
  548. /**
  549. * RollingAverage
  550. *
  551. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  552. */
  553. export class RollingAverage {
  554. /**
  555. * Current average
  556. */
  557. average: number;
  558. /**
  559. * Current variance
  560. */
  561. variance: number;
  562. protected _samples: Array<number>;
  563. protected _sampleCount: number;
  564. protected _pos: number;
  565. protected _m2: number;
  566. /**
  567. * constructor
  568. * @param length The number of samples required to saturate the sliding window
  569. */
  570. constructor(length: number);
  571. /**
  572. * Adds a sample to the sample set
  573. * @param v The sample value
  574. */
  575. add(v: number): void;
  576. /**
  577. * Returns previously added values or null if outside of history or outside the sliding window domain
  578. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  579. * @return Value previously recorded with add() or null if outside of range
  580. */
  581. history(i: number): number;
  582. /**
  583. * Returns true if enough samples have been taken to completely fill the sliding window
  584. * @return true if sample-set saturated
  585. */
  586. isSaturated(): boolean;
  587. /**
  588. * Resets the rolling average (equivalent to 0 samples taken so far)
  589. */
  590. reset(): void;
  591. /**
  592. * Wraps a value around the sample range boundaries
  593. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  594. * @return Wrapped position in sample range
  595. */
  596. protected _wrapPosition(i: number): number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /**
  601. * This class implement a typical dictionary using a string as key and the generic type T as value.
  602. * The underlying implementation relies on an associative array to ensure the best performances.
  603. * The value can be anything including 'null' but except 'undefined'
  604. */
  605. export class StringDictionary<T> {
  606. /**
  607. * This will clear this dictionary and copy the content from the 'source' one.
  608. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  609. * @param source the dictionary to take the content from and copy to this dictionary
  610. */
  611. copyFrom(source: StringDictionary<T>): void;
  612. /**
  613. * Get a value based from its key
  614. * @param key the given key to get the matching value from
  615. * @return the value if found, otherwise undefined is returned
  616. */
  617. get(key: string): T | undefined;
  618. /**
  619. * Get a value from its key or add it if it doesn't exist.
  620. * This method will ensure you that a given key/data will be present in the dictionary.
  621. * @param key the given key to get the matching value from
  622. * @param factory the factory that will create the value if the key is not present in the dictionary.
  623. * The factory will only be invoked if there's no data for the given key.
  624. * @return the value corresponding to the key.
  625. */
  626. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  627. /**
  628. * Get a value from its key if present in the dictionary otherwise add it
  629. * @param key the key to get the value from
  630. * @param val if there's no such key/value pair in the dictionary add it with this value
  631. * @return the value corresponding to the key
  632. */
  633. getOrAdd(key: string, val: T): T;
  634. /**
  635. * Check if there's a given key in the dictionary
  636. * @param key the key to check for
  637. * @return true if the key is present, false otherwise
  638. */
  639. contains(key: string): boolean;
  640. /**
  641. * Add a new key and its corresponding value
  642. * @param key the key to add
  643. * @param value the value corresponding to the key
  644. * @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
  645. */
  646. add(key: string, value: T): boolean;
  647. /**
  648. * Update a specific value associated to a key
  649. * @param key defines the key to use
  650. * @param value defines the value to store
  651. * @returns true if the value was updated (or false if the key was not found)
  652. */
  653. set(key: string, value: T): boolean;
  654. /**
  655. * Get the element of the given key and remove it from the dictionary
  656. * @param key defines the key to search
  657. * @returns the value associated with the key or null if not found
  658. */
  659. getAndRemove(key: string): Nullable<T>;
  660. /**
  661. * Remove a key/value from the dictionary.
  662. * @param key the key to remove
  663. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  664. */
  665. remove(key: string): boolean;
  666. /**
  667. * Clear the whole content of the dictionary
  668. */
  669. clear(): void;
  670. /**
  671. * Gets the current count
  672. */
  673. readonly count: number;
  674. /**
  675. * Execute a callback on each key/val of the dictionary.
  676. * Note that you can remove any element in this dictionary in the callback implementation
  677. * @param callback the callback to execute on a given key/value pair
  678. */
  679. forEach(callback: (key: string, val: T) => void): void;
  680. /**
  681. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  682. * If the callback returns null or undefined the method will iterate to the next key/value pair
  683. * Note that you can remove any element in this dictionary in the callback implementation
  684. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  685. * @returns the first item
  686. */
  687. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  688. private _count;
  689. private _data;
  690. }
  691. }
  692. declare module BABYLON {
  693. /**
  694. * Class used to store gfx data (like WebGLBuffer)
  695. */
  696. export class DataBuffer {
  697. /**
  698. * Gets or sets the number of objects referencing this buffer
  699. */
  700. references: number;
  701. /** Gets or sets the size of the underlying buffer */
  702. capacity: number;
  703. /**
  704. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  705. */
  706. is32Bits: boolean;
  707. /**
  708. * Gets the underlying buffer
  709. */
  710. readonly underlyingResource: any;
  711. }
  712. }
  713. declare module BABYLON {
  714. /**
  715. * Class used to store data that will be store in GPU memory
  716. */
  717. export class Buffer {
  718. private _engine;
  719. private _buffer;
  720. /** @hidden */
  721. _data: Nullable<DataArray>;
  722. private _updatable;
  723. private _instanced;
  724. /**
  725. * Gets the byte stride.
  726. */
  727. readonly byteStride: number;
  728. /**
  729. * Constructor
  730. * @param engine the engine
  731. * @param data the data to use for this buffer
  732. * @param updatable whether the data is updatable
  733. * @param stride the stride (optional)
  734. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  735. * @param instanced whether the buffer is instanced (optional)
  736. * @param useBytes set to true if the stride in in bytes (optional)
  737. */
  738. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  739. /**
  740. * Create a new VertexBuffer based on the current buffer
  741. * @param kind defines the vertex buffer kind (position, normal, etc.)
  742. * @param offset defines offset in the buffer (0 by default)
  743. * @param size defines the size in floats of attributes (position is 3 for instance)
  744. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  745. * @param instanced defines if the vertex buffer contains indexed data
  746. * @param useBytes defines if the offset and stride are in bytes
  747. * @returns the new vertex buffer
  748. */
  749. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  750. /**
  751. * Gets a boolean indicating if the Buffer is updatable?
  752. * @returns true if the buffer is updatable
  753. */
  754. isUpdatable(): boolean;
  755. /**
  756. * Gets current buffer's data
  757. * @returns a DataArray or null
  758. */
  759. getData(): Nullable<DataArray>;
  760. /**
  761. * Gets underlying native buffer
  762. * @returns underlying native buffer
  763. */
  764. getBuffer(): Nullable<DataBuffer>;
  765. /**
  766. * Gets the stride in float32 units (i.e. byte stride / 4).
  767. * May not be an integer if the byte stride is not divisible by 4.
  768. * DEPRECATED. Use byteStride instead.
  769. * @returns the stride in float32 units
  770. */
  771. getStrideSize(): number;
  772. /**
  773. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  774. * @param data defines the data to store
  775. */
  776. create(data?: Nullable<DataArray>): void;
  777. /** @hidden */
  778. _rebuild(): void;
  779. /**
  780. * Update current buffer data
  781. * @param data defines the data to store
  782. */
  783. update(data: DataArray): void;
  784. /**
  785. * Updates the data directly.
  786. * @param data the new data
  787. * @param offset the new offset
  788. * @param vertexCount the vertex count (optional)
  789. * @param useBytes set to true if the offset is in bytes
  790. */
  791. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  792. /**
  793. * Release all resources
  794. */
  795. dispose(): void;
  796. }
  797. /**
  798. * Specialized buffer used to store vertex data
  799. */
  800. export class VertexBuffer {
  801. /** @hidden */
  802. _buffer: Buffer;
  803. private _kind;
  804. private _size;
  805. private _ownsBuffer;
  806. private _instanced;
  807. private _instanceDivisor;
  808. /**
  809. * The byte type.
  810. */
  811. static readonly BYTE: number;
  812. /**
  813. * The unsigned byte type.
  814. */
  815. static readonly UNSIGNED_BYTE: number;
  816. /**
  817. * The short type.
  818. */
  819. static readonly SHORT: number;
  820. /**
  821. * The unsigned short type.
  822. */
  823. static readonly UNSIGNED_SHORT: number;
  824. /**
  825. * The integer type.
  826. */
  827. static readonly INT: number;
  828. /**
  829. * The unsigned integer type.
  830. */
  831. static readonly UNSIGNED_INT: number;
  832. /**
  833. * The float type.
  834. */
  835. static readonly FLOAT: number;
  836. /**
  837. * Gets or sets the instance divisor when in instanced mode
  838. */
  839. instanceDivisor: number;
  840. /**
  841. * Gets the byte stride.
  842. */
  843. readonly byteStride: number;
  844. /**
  845. * Gets the byte offset.
  846. */
  847. readonly byteOffset: number;
  848. /**
  849. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  850. */
  851. readonly normalized: boolean;
  852. /**
  853. * Gets the data type of each component in the array.
  854. */
  855. readonly type: number;
  856. /**
  857. * Constructor
  858. * @param engine the engine
  859. * @param data the data to use for this vertex buffer
  860. * @param kind the vertex buffer kind
  861. * @param updatable whether the data is updatable
  862. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  863. * @param stride the stride (optional)
  864. * @param instanced whether the buffer is instanced (optional)
  865. * @param offset the offset of the data (optional)
  866. * @param size the number of components (optional)
  867. * @param type the type of the component (optional)
  868. * @param normalized whether the data contains normalized data (optional)
  869. * @param useBytes set to true if stride and offset are in bytes (optional)
  870. */
  871. 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);
  872. /** @hidden */
  873. _rebuild(): void;
  874. /**
  875. * Returns the kind of the VertexBuffer (string)
  876. * @returns a string
  877. */
  878. getKind(): string;
  879. /**
  880. * Gets a boolean indicating if the VertexBuffer is updatable?
  881. * @returns true if the buffer is updatable
  882. */
  883. isUpdatable(): boolean;
  884. /**
  885. * Gets current buffer's data
  886. * @returns a DataArray or null
  887. */
  888. getData(): Nullable<DataArray>;
  889. /**
  890. * Gets underlying native buffer
  891. * @returns underlying native buffer
  892. */
  893. getBuffer(): Nullable<DataBuffer>;
  894. /**
  895. * Gets the stride in float32 units (i.e. byte stride / 4).
  896. * May not be an integer if the byte stride is not divisible by 4.
  897. * DEPRECATED. Use byteStride instead.
  898. * @returns the stride in float32 units
  899. */
  900. getStrideSize(): number;
  901. /**
  902. * Returns the offset as a multiple of the type byte length.
  903. * DEPRECATED. Use byteOffset instead.
  904. * @returns the offset in bytes
  905. */
  906. getOffset(): number;
  907. /**
  908. * Returns the number of components per vertex attribute (integer)
  909. * @returns the size in float
  910. */
  911. getSize(): number;
  912. /**
  913. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  914. * @returns true if this buffer is instanced
  915. */
  916. getIsInstanced(): boolean;
  917. /**
  918. * Returns the instancing divisor, zero for non-instanced (integer).
  919. * @returns a number
  920. */
  921. getInstanceDivisor(): number;
  922. /**
  923. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  924. * @param data defines the data to store
  925. */
  926. create(data?: DataArray): void;
  927. /**
  928. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  929. * This function will create a new buffer if the current one is not updatable
  930. * @param data defines the data to store
  931. */
  932. update(data: DataArray): void;
  933. /**
  934. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  935. * Returns the directly updated WebGLBuffer.
  936. * @param data the new data
  937. * @param offset the new offset
  938. * @param useBytes set to true if the offset is in bytes
  939. */
  940. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  941. /**
  942. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  943. */
  944. dispose(): void;
  945. /**
  946. * Enumerates each value of this vertex buffer as numbers.
  947. * @param count the number of values to enumerate
  948. * @param callback the callback function called for each value
  949. */
  950. forEach(count: number, callback: (value: number, index: number) => void): void;
  951. /**
  952. * Positions
  953. */
  954. static readonly PositionKind: string;
  955. /**
  956. * Normals
  957. */
  958. static readonly NormalKind: string;
  959. /**
  960. * Tangents
  961. */
  962. static readonly TangentKind: string;
  963. /**
  964. * Texture coordinates
  965. */
  966. static readonly UVKind: string;
  967. /**
  968. * Texture coordinates 2
  969. */
  970. static readonly UV2Kind: string;
  971. /**
  972. * Texture coordinates 3
  973. */
  974. static readonly UV3Kind: string;
  975. /**
  976. * Texture coordinates 4
  977. */
  978. static readonly UV4Kind: string;
  979. /**
  980. * Texture coordinates 5
  981. */
  982. static readonly UV5Kind: string;
  983. /**
  984. * Texture coordinates 6
  985. */
  986. static readonly UV6Kind: string;
  987. /**
  988. * Colors
  989. */
  990. static readonly ColorKind: string;
  991. /**
  992. * Matrix indices (for bones)
  993. */
  994. static readonly MatricesIndicesKind: string;
  995. /**
  996. * Matrix weights (for bones)
  997. */
  998. static readonly MatricesWeightsKind: string;
  999. /**
  1000. * Additional matrix indices (for bones)
  1001. */
  1002. static readonly MatricesIndicesExtraKind: string;
  1003. /**
  1004. * Additional matrix weights (for bones)
  1005. */
  1006. static readonly MatricesWeightsExtraKind: string;
  1007. /**
  1008. * Deduces the stride given a kind.
  1009. * @param kind The kind string to deduce
  1010. * @returns The deduced stride
  1011. */
  1012. static DeduceStride(kind: string): number;
  1013. /**
  1014. * Gets the byte length of the given type.
  1015. * @param type the type
  1016. * @returns the number of bytes
  1017. */
  1018. static GetTypeByteLength(type: number): number;
  1019. /**
  1020. * Enumerates each value of the given parameters as numbers.
  1021. * @param data the data to enumerate
  1022. * @param byteOffset the byte offset of the data
  1023. * @param byteStride the byte stride of the data
  1024. * @param componentCount the number of components per element
  1025. * @param componentType the type of the component
  1026. * @param count the number of values to enumerate
  1027. * @param normalized whether the data is normalized
  1028. * @param callback the callback function called for each value
  1029. */
  1030. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1031. private static _GetFloatValue;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * Scalar computation library
  1037. */
  1038. export class Scalar {
  1039. /**
  1040. * Two pi constants convenient for computation.
  1041. */
  1042. static TwoPi: number;
  1043. /**
  1044. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1045. * @param a number
  1046. * @param b number
  1047. * @param epsilon (default = 1.401298E-45)
  1048. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1049. */
  1050. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1051. /**
  1052. * Returns a string : the upper case translation of the number i to hexadecimal.
  1053. * @param i number
  1054. * @returns the upper case translation of the number i to hexadecimal.
  1055. */
  1056. static ToHex(i: number): string;
  1057. /**
  1058. * Returns -1 if value is negative and +1 is value is positive.
  1059. * @param value the value
  1060. * @returns the value itself if it's equal to zero.
  1061. */
  1062. static Sign(value: number): number;
  1063. /**
  1064. * Returns the value itself if it's between min and max.
  1065. * Returns min if the value is lower than min.
  1066. * Returns max if the value is greater than max.
  1067. * @param value the value to clmap
  1068. * @param min the min value to clamp to (default: 0)
  1069. * @param max the max value to clamp to (default: 1)
  1070. * @returns the clamped value
  1071. */
  1072. static Clamp(value: number, min?: number, max?: number): number;
  1073. /**
  1074. * the log2 of value.
  1075. * @param value the value to compute log2 of
  1076. * @returns the log2 of value.
  1077. */
  1078. static Log2(value: number): number;
  1079. /**
  1080. * Loops the value, so that it is never larger than length and never smaller than 0.
  1081. *
  1082. * This is similar to the modulo operator but it works with floating point numbers.
  1083. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1084. * With t = 5 and length = 2.5, the result would be 0.0.
  1085. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1086. * @param value the value
  1087. * @param length the length
  1088. * @returns the looped value
  1089. */
  1090. static Repeat(value: number, length: number): number;
  1091. /**
  1092. * Normalize the value between 0.0 and 1.0 using min and max values
  1093. * @param value value to normalize
  1094. * @param min max to normalize between
  1095. * @param max min to normalize between
  1096. * @returns the normalized value
  1097. */
  1098. static Normalize(value: number, min: number, max: number): number;
  1099. /**
  1100. * Denormalize the value from 0.0 and 1.0 using min and max values
  1101. * @param normalized value to denormalize
  1102. * @param min max to denormalize between
  1103. * @param max min to denormalize between
  1104. * @returns the denormalized value
  1105. */
  1106. static Denormalize(normalized: number, min: number, max: number): number;
  1107. /**
  1108. * Calculates the shortest difference between two given angles given in degrees.
  1109. * @param current current angle in degrees
  1110. * @param target target angle in degrees
  1111. * @returns the delta
  1112. */
  1113. static DeltaAngle(current: number, target: number): number;
  1114. /**
  1115. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1116. * @param tx value
  1117. * @param length length
  1118. * @returns The returned value will move back and forth between 0 and length
  1119. */
  1120. static PingPong(tx: number, length: number): number;
  1121. /**
  1122. * Interpolates between min and max with smoothing at the limits.
  1123. *
  1124. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1125. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1126. * @param from from
  1127. * @param to to
  1128. * @param tx value
  1129. * @returns the smooth stepped value
  1130. */
  1131. static SmoothStep(from: number, to: number, tx: number): number;
  1132. /**
  1133. * Moves a value current towards target.
  1134. *
  1135. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1136. * Negative values of maxDelta pushes the value away from target.
  1137. * @param current current value
  1138. * @param target target value
  1139. * @param maxDelta max distance to move
  1140. * @returns resulting value
  1141. */
  1142. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1143. /**
  1144. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1145. *
  1146. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1147. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1148. * @param current current value
  1149. * @param target target value
  1150. * @param maxDelta max distance to move
  1151. * @returns resulting angle
  1152. */
  1153. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1154. /**
  1155. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1156. * @param start start value
  1157. * @param end target value
  1158. * @param amount amount to lerp between
  1159. * @returns the lerped value
  1160. */
  1161. static Lerp(start: number, end: number, amount: number): number;
  1162. /**
  1163. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1164. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1165. * @param start start value
  1166. * @param end target value
  1167. * @param amount amount to lerp between
  1168. * @returns the lerped value
  1169. */
  1170. static LerpAngle(start: number, end: number, amount: number): number;
  1171. /**
  1172. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1173. * @param a start value
  1174. * @param b target value
  1175. * @param value value between a and b
  1176. * @returns the inverseLerp value
  1177. */
  1178. static InverseLerp(a: number, b: number, value: number): number;
  1179. /**
  1180. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1181. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1182. * @param value1 spline value
  1183. * @param tangent1 spline value
  1184. * @param value2 spline value
  1185. * @param tangent2 spline value
  1186. * @param amount input value
  1187. * @returns hermite result
  1188. */
  1189. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1190. /**
  1191. * Returns a random float number between and min and max values
  1192. * @param min min value of random
  1193. * @param max max value of random
  1194. * @returns random value
  1195. */
  1196. static RandomRange(min: number, max: number): number;
  1197. /**
  1198. * This function returns percentage of a number in a given range.
  1199. *
  1200. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1201. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1202. * @param number to convert to percentage
  1203. * @param min min range
  1204. * @param max max range
  1205. * @returns the percentage
  1206. */
  1207. static RangeToPercent(number: number, min: number, max: number): number;
  1208. /**
  1209. * This function returns number that corresponds to the percentage in a given range.
  1210. *
  1211. * PercentToRange(0.34,0,100) will return 34.
  1212. * @param percent to convert to number
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the number
  1216. */
  1217. static PercentToRange(percent: number, min: number, max: number): number;
  1218. /**
  1219. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1220. * @param angle The angle to normalize in radian.
  1221. * @return The converted angle.
  1222. */
  1223. static NormalizeRadians(angle: number): number;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /**
  1228. * Constant used to convert a value to gamma space
  1229. * @ignorenaming
  1230. */
  1231. export const ToGammaSpace: number;
  1232. /**
  1233. * Constant used to convert a value to linear space
  1234. * @ignorenaming
  1235. */
  1236. export const ToLinearSpace = 2.2;
  1237. /**
  1238. * Constant used to define the minimal number value in Babylon.js
  1239. * @ignorenaming
  1240. */
  1241. let Epsilon: number;
  1242. }
  1243. declare module BABYLON {
  1244. /**
  1245. * Class used to represent a viewport on screen
  1246. */
  1247. export class Viewport {
  1248. /** viewport left coordinate */
  1249. x: number;
  1250. /** viewport top coordinate */
  1251. y: number;
  1252. /**viewport width */
  1253. width: number;
  1254. /** viewport height */
  1255. height: number;
  1256. /**
  1257. * Creates a Viewport object located at (x, y) and sized (width, height)
  1258. * @param x defines viewport left coordinate
  1259. * @param y defines viewport top coordinate
  1260. * @param width defines the viewport width
  1261. * @param height defines the viewport height
  1262. */
  1263. constructor(
  1264. /** viewport left coordinate */
  1265. x: number,
  1266. /** viewport top coordinate */
  1267. y: number,
  1268. /**viewport width */
  1269. width: number,
  1270. /** viewport height */
  1271. height: number);
  1272. /**
  1273. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1274. * @param renderWidth defines the rendering width
  1275. * @param renderHeight defines the rendering height
  1276. * @returns a new Viewport
  1277. */
  1278. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1279. /**
  1280. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1281. * @param renderWidth defines the rendering width
  1282. * @param renderHeight defines the rendering height
  1283. * @param ref defines the target viewport
  1284. * @returns the current viewport
  1285. */
  1286. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1287. /**
  1288. * Returns a new Viewport copied from the current one
  1289. * @returns a new Viewport
  1290. */
  1291. clone(): Viewport;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class containing a set of static utilities functions for arrays.
  1297. */
  1298. export class ArrayTools {
  1299. /**
  1300. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1301. * @param size the number of element to construct and put in the array
  1302. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1303. * @returns a new array filled with new objects
  1304. */
  1305. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * @hidden
  1311. */
  1312. export interface IColor4Like {
  1313. r: float;
  1314. g: float;
  1315. b: float;
  1316. a: float;
  1317. }
  1318. /**
  1319. * @hidden
  1320. */
  1321. export interface IColor3Like {
  1322. r: float;
  1323. g: float;
  1324. b: float;
  1325. }
  1326. /**
  1327. * @hidden
  1328. */
  1329. export interface IVector4Like {
  1330. x: float;
  1331. y: float;
  1332. z: float;
  1333. w: float;
  1334. }
  1335. /**
  1336. * @hidden
  1337. */
  1338. export interface IVector3Like {
  1339. x: float;
  1340. y: float;
  1341. z: float;
  1342. }
  1343. /**
  1344. * @hidden
  1345. */
  1346. export interface IVector2Like {
  1347. x: float;
  1348. y: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IMatrixLike {
  1354. toArray(): DeepImmutable<Float32Array>;
  1355. updateFlag: int;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IViewportLike {
  1361. x: float;
  1362. y: float;
  1363. width: float;
  1364. height: float;
  1365. }
  1366. /**
  1367. * @hidden
  1368. */
  1369. export interface IPlaneLike {
  1370. normal: IVector3Like;
  1371. d: float;
  1372. normalize(): void;
  1373. }
  1374. }
  1375. declare module BABYLON {
  1376. /**
  1377. * Class representing a vector containing 2 coordinates
  1378. */
  1379. export class Vector2 {
  1380. /** defines the first coordinate */
  1381. x: number;
  1382. /** defines the second coordinate */
  1383. y: number;
  1384. /**
  1385. * Creates a new Vector2 from the given x and y coordinates
  1386. * @param x defines the first coordinate
  1387. * @param y defines the second coordinate
  1388. */
  1389. constructor(
  1390. /** defines the first coordinate */
  1391. x?: number,
  1392. /** defines the second coordinate */
  1393. y?: number);
  1394. /**
  1395. * Gets a string with the Vector2 coordinates
  1396. * @returns a string with the Vector2 coordinates
  1397. */
  1398. toString(): string;
  1399. /**
  1400. * Gets class name
  1401. * @returns the string "Vector2"
  1402. */
  1403. getClassName(): string;
  1404. /**
  1405. * Gets current vector hash code
  1406. * @returns the Vector2 hash code as a number
  1407. */
  1408. getHashCode(): number;
  1409. /**
  1410. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1411. * @param array defines the source array
  1412. * @param index defines the offset in source array
  1413. * @returns the current Vector2
  1414. */
  1415. toArray(array: FloatArray, index?: number): Vector2;
  1416. /**
  1417. * Copy the current vector to an array
  1418. * @returns a new array with 2 elements: the Vector2 coordinates.
  1419. */
  1420. asArray(): number[];
  1421. /**
  1422. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1423. * @param source defines the source Vector2
  1424. * @returns the current updated Vector2
  1425. */
  1426. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1427. /**
  1428. * Sets the Vector2 coordinates with the given floats
  1429. * @param x defines the first coordinate
  1430. * @param y defines the second coordinate
  1431. * @returns the current updated Vector2
  1432. */
  1433. copyFromFloats(x: number, y: number): Vector2;
  1434. /**
  1435. * Sets the Vector2 coordinates with the given floats
  1436. * @param x defines the first coordinate
  1437. * @param y defines the second coordinate
  1438. * @returns the current updated Vector2
  1439. */
  1440. set(x: number, y: number): Vector2;
  1441. /**
  1442. * Add another vector with the current one
  1443. * @param otherVector defines the other vector
  1444. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1445. */
  1446. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1447. /**
  1448. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1449. * @param otherVector defines the other vector
  1450. * @param result defines the target vector
  1451. * @returns the unmodified current Vector2
  1452. */
  1453. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1454. /**
  1455. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1456. * @param otherVector defines the other vector
  1457. * @returns the current updated Vector2
  1458. */
  1459. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1460. /**
  1461. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1462. * @param otherVector defines the other vector
  1463. * @returns a new Vector2
  1464. */
  1465. addVector3(otherVector: Vector3): Vector2;
  1466. /**
  1467. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1468. * @param otherVector defines the other vector
  1469. * @returns a new Vector2
  1470. */
  1471. subtract(otherVector: Vector2): Vector2;
  1472. /**
  1473. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1474. * @param otherVector defines the other vector
  1475. * @param result defines the target vector
  1476. * @returns the unmodified current Vector2
  1477. */
  1478. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1479. /**
  1480. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1481. * @param otherVector defines the other vector
  1482. * @returns the current updated Vector2
  1483. */
  1484. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1485. /**
  1486. * Multiplies in place the current Vector2 coordinates by the given ones
  1487. * @param otherVector defines the other vector
  1488. * @returns the current updated Vector2
  1489. */
  1490. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1491. /**
  1492. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1493. * @param otherVector defines the other vector
  1494. * @returns a new Vector2
  1495. */
  1496. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1497. /**
  1498. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1499. * @param otherVector defines the other vector
  1500. * @param result defines the target vector
  1501. * @returns the unmodified current Vector2
  1502. */
  1503. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1504. /**
  1505. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1506. * @param x defines the first coordinate
  1507. * @param y defines the second coordinate
  1508. * @returns a new Vector2
  1509. */
  1510. multiplyByFloats(x: number, y: number): Vector2;
  1511. /**
  1512. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1513. * @param otherVector defines the other vector
  1514. * @returns a new Vector2
  1515. */
  1516. divide(otherVector: Vector2): Vector2;
  1517. /**
  1518. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1519. * @param otherVector defines the other vector
  1520. * @param result defines the target vector
  1521. * @returns the unmodified current Vector2
  1522. */
  1523. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1524. /**
  1525. * Divides the current Vector2 coordinates by the given ones
  1526. * @param otherVector defines the other vector
  1527. * @returns the current updated Vector2
  1528. */
  1529. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1530. /**
  1531. * Gets a new Vector2 with current Vector2 negated coordinates
  1532. * @returns a new Vector2
  1533. */
  1534. negate(): Vector2;
  1535. /**
  1536. * Multiply the Vector2 coordinates by scale
  1537. * @param scale defines the scaling factor
  1538. * @returns the current updated Vector2
  1539. */
  1540. scaleInPlace(scale: number): Vector2;
  1541. /**
  1542. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1543. * @param scale defines the scaling factor
  1544. * @returns a new Vector2
  1545. */
  1546. scale(scale: number): Vector2;
  1547. /**
  1548. * Scale the current Vector2 values by a factor to a given Vector2
  1549. * @param scale defines the scale factor
  1550. * @param result defines the Vector2 object where to store the result
  1551. * @returns the unmodified current Vector2
  1552. */
  1553. scaleToRef(scale: number, result: Vector2): Vector2;
  1554. /**
  1555. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1556. * @param scale defines the scale factor
  1557. * @param result defines the Vector2 object where to store the result
  1558. * @returns the unmodified current Vector2
  1559. */
  1560. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1561. /**
  1562. * Gets a boolean if two vectors are equals
  1563. * @param otherVector defines the other vector
  1564. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1565. */
  1566. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1567. /**
  1568. * Gets a boolean if two vectors are equals (using an epsilon value)
  1569. * @param otherVector defines the other vector
  1570. * @param epsilon defines the minimal distance to consider equality
  1571. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1572. */
  1573. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1574. /**
  1575. * Gets a new Vector2 from current Vector2 floored values
  1576. * @returns a new Vector2
  1577. */
  1578. floor(): Vector2;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. fract(): Vector2;
  1584. /**
  1585. * Gets the length of the vector
  1586. * @returns the vector length (float)
  1587. */
  1588. length(): number;
  1589. /**
  1590. * Gets the vector squared length
  1591. * @returns the vector squared length (float)
  1592. */
  1593. lengthSquared(): number;
  1594. /**
  1595. * Normalize the vector
  1596. * @returns the current updated Vector2
  1597. */
  1598. normalize(): Vector2;
  1599. /**
  1600. * Gets a new Vector2 copied from the Vector2
  1601. * @returns a new Vector2
  1602. */
  1603. clone(): Vector2;
  1604. /**
  1605. * Gets a new Vector2(0, 0)
  1606. * @returns a new Vector2
  1607. */
  1608. static Zero(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(1, 1)
  1611. * @returns a new Vector2
  1612. */
  1613. static One(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 set from the given index element of the given array
  1616. * @param array defines the data source
  1617. * @param offset defines the offset in the data source
  1618. * @returns a new Vector2
  1619. */
  1620. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1621. /**
  1622. * Sets "result" from the given index element of the given array
  1623. * @param array defines the data source
  1624. * @param offset defines the offset in the data source
  1625. * @param result defines the target vector
  1626. */
  1627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1628. /**
  1629. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1630. * @param value1 defines 1st point of control
  1631. * @param value2 defines 2nd point of control
  1632. * @param value3 defines 3rd point of control
  1633. * @param value4 defines 4th point of control
  1634. * @param amount defines the interpolation factor
  1635. * @returns a new Vector2
  1636. */
  1637. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1638. /**
  1639. * 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".
  1640. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1641. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1642. * @param value defines the value to clamp
  1643. * @param min defines the lower limit
  1644. * @param max defines the upper limit
  1645. * @returns a new Vector2
  1646. */
  1647. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1648. /**
  1649. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1650. * @param value1 defines the 1st control point
  1651. * @param tangent1 defines the outgoing tangent
  1652. * @param value2 defines the 2nd control point
  1653. * @param tangent2 defines the incoming tangent
  1654. * @param amount defines the interpolation factor
  1655. * @returns a new Vector2
  1656. */
  1657. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1660. * @param start defines the start vector
  1661. * @param end defines the end vector
  1662. * @param amount defines the interpolation factor
  1663. * @returns a new Vector2
  1664. */
  1665. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1666. /**
  1667. * Gets the dot product of the vector "left" and the vector "right"
  1668. * @param left defines first vector
  1669. * @param right defines second vector
  1670. * @returns the dot product (float)
  1671. */
  1672. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1673. /**
  1674. * Returns a new Vector2 equal to the normalized given vector
  1675. * @param vector defines the vector to normalize
  1676. * @returns a new Vector2
  1677. */
  1678. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1679. /**
  1680. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1681. * @param left defines 1st vector
  1682. * @param right defines 2nd vector
  1683. * @returns a new Vector2
  1684. */
  1685. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1686. /**
  1687. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1688. * @param left defines 1st vector
  1689. * @param right defines 2nd vector
  1690. * @returns a new Vector2
  1691. */
  1692. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1693. /**
  1694. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1695. * @param vector defines the vector to transform
  1696. * @param transformation defines the matrix to apply
  1697. * @returns a new Vector2
  1698. */
  1699. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1700. /**
  1701. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1702. * @param vector defines the vector to transform
  1703. * @param transformation defines the matrix to apply
  1704. * @param result defines the target vector
  1705. */
  1706. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1707. /**
  1708. * Determines if a given vector is included in a triangle
  1709. * @param p defines the vector to test
  1710. * @param p0 defines 1st triangle point
  1711. * @param p1 defines 2nd triangle point
  1712. * @param p2 defines 3rd triangle point
  1713. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1714. */
  1715. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1716. /**
  1717. * Gets the distance between the vectors "value1" and "value2"
  1718. * @param value1 defines first vector
  1719. * @param value2 defines second vector
  1720. * @returns the distance between vectors
  1721. */
  1722. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1723. /**
  1724. * Returns the squared distance between the vectors "value1" and "value2"
  1725. * @param value1 defines first vector
  1726. * @param value2 defines second vector
  1727. * @returns the squared distance between vectors
  1728. */
  1729. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1730. /**
  1731. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1732. * @param value1 defines first vector
  1733. * @param value2 defines second vector
  1734. * @returns a new Vector2
  1735. */
  1736. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1737. /**
  1738. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1739. * @param p defines the middle point
  1740. * @param segA defines one point of the segment
  1741. * @param segB defines the other point of the segment
  1742. * @returns the shortest distance
  1743. */
  1744. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1745. }
  1746. /**
  1747. * Classed used to store (x,y,z) vector representation
  1748. * A Vector3 is the main object used in 3D geometry
  1749. * It can represent etiher the coordinates of a point the space, either a direction
  1750. * Reminder: js uses a left handed forward facing system
  1751. */
  1752. export class Vector3 {
  1753. /**
  1754. * Defines the first coordinates (on X axis)
  1755. */
  1756. x: number;
  1757. /**
  1758. * Defines the second coordinates (on Y axis)
  1759. */
  1760. y: number;
  1761. /**
  1762. * Defines the third coordinates (on Z axis)
  1763. */
  1764. z: number;
  1765. private static _UpReadOnly;
  1766. private static _ZeroReadOnly;
  1767. /**
  1768. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1769. * @param x defines the first coordinates (on X axis)
  1770. * @param y defines the second coordinates (on Y axis)
  1771. * @param z defines the third coordinates (on Z axis)
  1772. */
  1773. constructor(
  1774. /**
  1775. * Defines the first coordinates (on X axis)
  1776. */
  1777. x?: number,
  1778. /**
  1779. * Defines the second coordinates (on Y axis)
  1780. */
  1781. y?: number,
  1782. /**
  1783. * Defines the third coordinates (on Z axis)
  1784. */
  1785. z?: number);
  1786. /**
  1787. * Creates a string representation of the Vector3
  1788. * @returns a string with the Vector3 coordinates.
  1789. */
  1790. toString(): string;
  1791. /**
  1792. * Gets the class name
  1793. * @returns the string "Vector3"
  1794. */
  1795. getClassName(): string;
  1796. /**
  1797. * Creates the Vector3 hash code
  1798. * @returns a number which tends to be unique between Vector3 instances
  1799. */
  1800. getHashCode(): number;
  1801. /**
  1802. * Creates an array containing three elements : the coordinates of the Vector3
  1803. * @returns a new array of numbers
  1804. */
  1805. asArray(): number[];
  1806. /**
  1807. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1808. * @param array defines the destination array
  1809. * @param index defines the offset in the destination array
  1810. * @returns the current Vector3
  1811. */
  1812. toArray(array: FloatArray, index?: number): Vector3;
  1813. /**
  1814. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1815. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1816. */
  1817. toQuaternion(): Quaternion;
  1818. /**
  1819. * Adds the given vector to the current Vector3
  1820. * @param otherVector defines the second operand
  1821. * @returns the current updated Vector3
  1822. */
  1823. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1824. /**
  1825. * Adds the given coordinates to the current Vector3
  1826. * @param x defines the x coordinate of the operand
  1827. * @param y defines the y coordinate of the operand
  1828. * @param z defines the z coordinate of the operand
  1829. * @returns the current updated Vector3
  1830. */
  1831. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1832. /**
  1833. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1834. * @param otherVector defines the second operand
  1835. * @returns the resulting Vector3
  1836. */
  1837. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1838. /**
  1839. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1840. * @param otherVector defines the second operand
  1841. * @param result defines the Vector3 object where to store the result
  1842. * @returns the current Vector3
  1843. */
  1844. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1845. /**
  1846. * Subtract the given vector from the current Vector3
  1847. * @param otherVector defines the second operand
  1848. * @returns the current updated Vector3
  1849. */
  1850. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1851. /**
  1852. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1853. * @param otherVector defines the second operand
  1854. * @returns the resulting Vector3
  1855. */
  1856. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1857. /**
  1858. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1859. * @param otherVector defines the second operand
  1860. * @param result defines the Vector3 object where to store the result
  1861. * @returns the current Vector3
  1862. */
  1863. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1864. /**
  1865. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1866. * @param x defines the x coordinate of the operand
  1867. * @param y defines the y coordinate of the operand
  1868. * @param z defines the z coordinate of the operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1872. /**
  1873. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1874. * @param x defines the x coordinate of the operand
  1875. * @param y defines the y coordinate of the operand
  1876. * @param z defines the z coordinate of the operand
  1877. * @param result defines the Vector3 object where to store the result
  1878. * @returns the current Vector3
  1879. */
  1880. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1881. /**
  1882. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1883. * @returns a new Vector3
  1884. */
  1885. negate(): Vector3;
  1886. /**
  1887. * Multiplies the Vector3 coordinates by the float "scale"
  1888. * @param scale defines the multiplier factor
  1889. * @returns the current updated Vector3
  1890. */
  1891. scaleInPlace(scale: number): Vector3;
  1892. /**
  1893. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1894. * @param scale defines the multiplier factor
  1895. * @returns a new Vector3
  1896. */
  1897. scale(scale: number): Vector3;
  1898. /**
  1899. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1900. * @param scale defines the multiplier factor
  1901. * @param result defines the Vector3 object where to store the result
  1902. * @returns the current Vector3
  1903. */
  1904. scaleToRef(scale: number, result: Vector3): Vector3;
  1905. /**
  1906. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1907. * @param scale defines the scale factor
  1908. * @param result defines the Vector3 object where to store the result
  1909. * @returns the unmodified current Vector3
  1910. */
  1911. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1912. /**
  1913. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1914. * @param otherVector defines the second operand
  1915. * @returns true if both vectors are equals
  1916. */
  1917. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1918. /**
  1919. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1920. * @param otherVector defines the second operand
  1921. * @param epsilon defines the minimal distance to define values as equals
  1922. * @returns true if both vectors are distant less than epsilon
  1923. */
  1924. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1925. /**
  1926. * Returns true if the current Vector3 coordinates equals the given floats
  1927. * @param x defines the x coordinate of the operand
  1928. * @param y defines the y coordinate of the operand
  1929. * @param z defines the z coordinate of the operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equalsToFloats(x: number, y: number, z: number): boolean;
  1933. /**
  1934. * Multiplies the current Vector3 coordinates by the given ones
  1935. * @param otherVector defines the second operand
  1936. * @returns the current updated Vector3
  1937. */
  1938. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1939. /**
  1940. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1941. * @param otherVector defines the second operand
  1942. * @returns the new Vector3
  1943. */
  1944. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1947. * @param otherVector defines the second operand
  1948. * @param result defines the Vector3 object where to store the result
  1949. * @returns the current Vector3
  1950. */
  1951. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1952. /**
  1953. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1954. * @param x defines the x coordinate of the operand
  1955. * @param y defines the y coordinate of the operand
  1956. * @param z defines the z coordinate of the operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1960. /**
  1961. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1962. * @param otherVector defines the second operand
  1963. * @returns the new Vector3
  1964. */
  1965. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1966. /**
  1967. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1968. * @param otherVector defines the second operand
  1969. * @param result defines the Vector3 object where to store the result
  1970. * @returns the current Vector3
  1971. */
  1972. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1973. /**
  1974. * Divides the current Vector3 coordinates by the given ones.
  1975. * @param otherVector defines the second operand
  1976. * @returns the current updated Vector3
  1977. */
  1978. divideInPlace(otherVector: Vector3): Vector3;
  1979. /**
  1980. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1981. * @param other defines the second operand
  1982. * @returns the current updated Vector3
  1983. */
  1984. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1985. /**
  1986. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1987. * @param other defines the second operand
  1988. * @returns the current updated Vector3
  1989. */
  1990. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1991. /**
  1992. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1993. * @param x defines the x coordinate of the operand
  1994. * @param y defines the y coordinate of the operand
  1995. * @param z defines the z coordinate of the operand
  1996. * @returns the current updated Vector3
  1997. */
  1998. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1999. /**
  2000. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2001. * @param x defines the x coordinate of the operand
  2002. * @param y defines the y coordinate of the operand
  2003. * @param z defines the z coordinate of the operand
  2004. * @returns the current updated Vector3
  2005. */
  2006. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2007. /**
  2008. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2009. * Check if is non uniform within a certain amount of decimal places to account for this
  2010. * @param epsilon the amount the values can differ
  2011. * @returns if the the vector is non uniform to a certain number of decimal places
  2012. */
  2013. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2014. /**
  2015. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2016. */
  2017. readonly isNonUniform: boolean;
  2018. /**
  2019. * Gets a new Vector3 from current Vector3 floored values
  2020. * @returns a new Vector3
  2021. */
  2022. floor(): Vector3;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. fract(): Vector3;
  2028. /**
  2029. * Gets the length of the Vector3
  2030. * @returns the length of the Vector3
  2031. */
  2032. length(): number;
  2033. /**
  2034. * Gets the squared length of the Vector3
  2035. * @returns squared length of the Vector3
  2036. */
  2037. lengthSquared(): number;
  2038. /**
  2039. * Normalize the current Vector3.
  2040. * Please note that this is an in place operation.
  2041. * @returns the current updated Vector3
  2042. */
  2043. normalize(): Vector3;
  2044. /**
  2045. * Reorders the x y z properties of the vector in place
  2046. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2047. * @returns the current updated vector
  2048. */
  2049. reorderInPlace(order: string): this;
  2050. /**
  2051. * Rotates the vector around 0,0,0 by a quaternion
  2052. * @param quaternion the rotation quaternion
  2053. * @param result vector to store the result
  2054. * @returns the resulting vector
  2055. */
  2056. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2057. /**
  2058. * Rotates a vector around a given point
  2059. * @param quaternion the rotation quaternion
  2060. * @param point the point to rotate around
  2061. * @param result vector to store the result
  2062. * @returns the resulting vector
  2063. */
  2064. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2065. /**
  2066. * Normalize the current Vector3 with the given input length.
  2067. * Please note that this is an in place operation.
  2068. * @param len the length of the vector
  2069. * @returns the current updated Vector3
  2070. */
  2071. normalizeFromLength(len: number): Vector3;
  2072. /**
  2073. * Normalize the current Vector3 to a new vector
  2074. * @returns the new Vector3
  2075. */
  2076. normalizeToNew(): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 to the reference
  2079. * @param reference define the Vector3 to update
  2080. * @returns the updated Vector3
  2081. */
  2082. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2083. /**
  2084. * Creates a new Vector3 copied from the current Vector3
  2085. * @returns the new Vector3
  2086. */
  2087. clone(): Vector3;
  2088. /**
  2089. * Copies the given vector coordinates to the current Vector3 ones
  2090. * @param source defines the source Vector3
  2091. * @returns the current updated Vector3
  2092. */
  2093. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2094. /**
  2095. * Copies the given floats to the current Vector3 coordinates
  2096. * @param x defines the x coordinate of the operand
  2097. * @param y defines the y coordinate of the operand
  2098. * @param z defines the z coordinate of the operand
  2099. * @returns the current updated Vector3
  2100. */
  2101. copyFromFloats(x: number, y: number, z: number): Vector3;
  2102. /**
  2103. * Copies the given floats to the current Vector3 coordinates
  2104. * @param x defines the x coordinate of the operand
  2105. * @param y defines the y coordinate of the operand
  2106. * @param z defines the z coordinate of the operand
  2107. * @returns the current updated Vector3
  2108. */
  2109. set(x: number, y: number, z: number): Vector3;
  2110. /**
  2111. * Copies the given float to the current Vector3 coordinates
  2112. * @param v defines the x, y and z coordinates of the operand
  2113. * @returns the current updated Vector3
  2114. */
  2115. setAll(v: number): Vector3;
  2116. /**
  2117. * Get the clip factor between two vectors
  2118. * @param vector0 defines the first operand
  2119. * @param vector1 defines the second operand
  2120. * @param axis defines the axis to use
  2121. * @param size defines the size along the axis
  2122. * @returns the clip factor
  2123. */
  2124. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2125. /**
  2126. * Get angle between two vectors
  2127. * @param vector0 angle between vector0 and vector1
  2128. * @param vector1 angle between vector0 and vector1
  2129. * @param normal direction of the normal
  2130. * @return the angle between vector0 and vector1
  2131. */
  2132. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2133. /**
  2134. * Returns a new Vector3 set from the index "offset" of the given array
  2135. * @param array defines the source array
  2136. * @param offset defines the offset in the source array
  2137. * @returns the new Vector3
  2138. */
  2139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2140. /**
  2141. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2142. * This function is deprecated. Use FromArray instead
  2143. * @param array defines the source array
  2144. * @param offset defines the offset in the source array
  2145. * @returns the new Vector3
  2146. */
  2147. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2148. /**
  2149. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @param result defines the Vector3 where to store the result
  2153. */
  2154. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2155. /**
  2156. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2157. * This function is deprecated. Use FromArrayToRef instead.
  2158. * @param array defines the source array
  2159. * @param offset defines the offset in the source array
  2160. * @param result defines the Vector3 where to store the result
  2161. */
  2162. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2163. /**
  2164. * Sets the given vector "result" with the given floats.
  2165. * @param x defines the x coordinate of the source
  2166. * @param y defines the y coordinate of the source
  2167. * @param z defines the z coordinate of the source
  2168. * @param result defines the Vector3 where to store the result
  2169. */
  2170. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2171. /**
  2172. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2173. * @returns a new empty Vector3
  2174. */
  2175. static Zero(): Vector3;
  2176. /**
  2177. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2178. * @returns a new unit Vector3
  2179. */
  2180. static One(): Vector3;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2183. * @returns a new up Vector3
  2184. */
  2185. static Up(): Vector3;
  2186. /**
  2187. * Gets a up Vector3 that must not be updated
  2188. */
  2189. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2190. /**
  2191. * Gets a zero Vector3 that must not be updated
  2192. */
  2193. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2194. /**
  2195. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2196. * @returns a new down Vector3
  2197. */
  2198. static Down(): Vector3;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2201. * @returns a new forward Vector3
  2202. */
  2203. static Forward(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2206. * @returns a new forward Vector3
  2207. */
  2208. static Backward(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2211. * @returns a new right Vector3
  2212. */
  2213. static Right(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2216. * @returns a new left Vector3
  2217. */
  2218. static Left(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2221. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2222. * @param vector defines the Vector3 to transform
  2223. * @param transformation defines the transformation matrix
  2224. * @returns the transformed Vector3
  2225. */
  2226. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2227. /**
  2228. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2229. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2230. * @param vector defines the Vector3 to transform
  2231. * @param transformation defines the transformation matrix
  2232. * @param result defines the Vector3 where to store the result
  2233. */
  2234. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2235. /**
  2236. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2237. * This method computes tranformed coordinates only, not transformed direction vectors
  2238. * @param x define the x coordinate of the source vector
  2239. * @param y define the y coordinate of the source vector
  2240. * @param z define the z coordinate of the source vector
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2247. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2248. * @param vector defines the Vector3 to transform
  2249. * @param transformation defines the transformation matrix
  2250. * @returns the new Vector3
  2251. */
  2252. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2253. /**
  2254. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2255. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2256. * @param vector defines the Vector3 to transform
  2257. * @param transformation defines the transformation matrix
  2258. * @param result defines the Vector3 where to store the result
  2259. */
  2260. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2261. /**
  2262. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2263. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2264. * @param x define the x coordinate of the source vector
  2265. * @param y define the y coordinate of the source vector
  2266. * @param z define the z coordinate of the source vector
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2273. * @param value1 defines the first control point
  2274. * @param value2 defines the second control point
  2275. * @param value3 defines the third control point
  2276. * @param value4 defines the fourth control point
  2277. * @param amount defines the amount on the spline to use
  2278. * @returns the new Vector3
  2279. */
  2280. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2281. /**
  2282. * 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"
  2283. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2284. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2285. * @param value defines the current value
  2286. * @param min defines the lower range value
  2287. * @param max defines the upper range value
  2288. * @returns the new Vector3
  2289. */
  2290. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2291. /**
  2292. * 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"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @param result defines the Vector3 where to store the result
  2299. */
  2300. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2301. /**
  2302. * Checks if a given vector is inside a specific range
  2303. * @param v defines the vector to test
  2304. * @param min defines the minimum range
  2305. * @param max defines the maximum range
  2306. */
  2307. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2308. /**
  2309. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2310. * @param value1 defines the first control point
  2311. * @param tangent1 defines the first tangent vector
  2312. * @param value2 defines the second control point
  2313. * @param tangent2 defines the second tangent vector
  2314. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2315. * @returns the new Vector3
  2316. */
  2317. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2320. * @param start defines the start value
  2321. * @param end defines the end value
  2322. * @param amount max defines amount between both (between 0 and 1)
  2323. * @returns the new Vector3
  2324. */
  2325. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2326. /**
  2327. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2328. * @param start defines the start value
  2329. * @param end defines the end value
  2330. * @param amount max defines amount between both (between 0 and 1)
  2331. * @param result defines the Vector3 where to store the result
  2332. */
  2333. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2334. /**
  2335. * Returns the dot product (float) between the vectors "left" and "right"
  2336. * @param left defines the left operand
  2337. * @param right defines the right operand
  2338. * @returns the dot product
  2339. */
  2340. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2341. /**
  2342. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2343. * The cross product is then orthogonal to both "left" and "right"
  2344. * @param left defines the left operand
  2345. * @param right defines the right operand
  2346. * @returns the cross product
  2347. */
  2348. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2349. /**
  2350. * Sets the given vector "result" with the cross product of "left" and "right"
  2351. * The cross product is then orthogonal to both "left" and "right"
  2352. * @param left defines the left operand
  2353. * @param right defines the right operand
  2354. * @param result defines the Vector3 where to store the result
  2355. */
  2356. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2357. /**
  2358. * Returns a new Vector3 as the normalization of the given vector
  2359. * @param vector defines the Vector3 to normalize
  2360. * @returns the new Vector3
  2361. */
  2362. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2363. /**
  2364. * Sets the given vector "result" with the normalization of the given first vector
  2365. * @param vector defines the Vector3 to normalize
  2366. * @param result defines the Vector3 where to store the result
  2367. */
  2368. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2369. /**
  2370. * Project a Vector3 onto screen space
  2371. * @param vector defines the Vector3 to project
  2372. * @param world defines the world matrix to use
  2373. * @param transform defines the transform (view x projection) matrix to use
  2374. * @param viewport defines the screen viewport to use
  2375. * @returns the new Vector3
  2376. */
  2377. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2378. /** @hidden */
  2379. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2380. /**
  2381. * Unproject from screen space to object space
  2382. * @param source defines the screen space Vector3 to use
  2383. * @param viewportWidth defines the current width of the viewport
  2384. * @param viewportHeight defines the current height of the viewport
  2385. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2386. * @param transform defines the transform (view x projection) matrix to use
  2387. * @returns the new Vector3
  2388. */
  2389. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param view defines the view matrix to use
  2397. * @param projection defines the projection matrix to use
  2398. * @returns the new Vector3
  2399. */
  2400. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2401. /**
  2402. * Unproject from screen space to object space
  2403. * @param source defines the screen space Vector3 to use
  2404. * @param viewportWidth defines the current width of the viewport
  2405. * @param viewportHeight defines the current height of the viewport
  2406. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2407. * @param view defines the view matrix to use
  2408. * @param projection defines the projection matrix to use
  2409. * @param result defines the Vector3 where to store the result
  2410. */
  2411. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param sourceX defines the screen space x coordinate to use
  2415. * @param sourceY defines the screen space y coordinate to use
  2416. * @param sourceZ defines the screen space z coordinate to use
  2417. * @param viewportWidth defines the current width of the viewport
  2418. * @param viewportHeight defines the current height of the viewport
  2419. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2420. * @param view defines the view matrix to use
  2421. * @param projection defines the projection matrix to use
  2422. * @param result defines the Vector3 where to store the result
  2423. */
  2424. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2425. /**
  2426. * Gets the minimal coordinate values between two Vector3
  2427. * @param left defines the first operand
  2428. * @param right defines the second operand
  2429. * @returns the new Vector3
  2430. */
  2431. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2432. /**
  2433. * Gets the maximal coordinate values between two Vector3
  2434. * @param left defines the first operand
  2435. * @param right defines the second operand
  2436. * @returns the new Vector3
  2437. */
  2438. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2439. /**
  2440. * Returns the distance between the vectors "value1" and "value2"
  2441. * @param value1 defines the first operand
  2442. * @param value2 defines the second operand
  2443. * @returns the distance
  2444. */
  2445. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2446. /**
  2447. * Returns the squared distance between the vectors "value1" and "value2"
  2448. * @param value1 defines the first operand
  2449. * @param value2 defines the second operand
  2450. * @returns the squared distance
  2451. */
  2452. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2453. /**
  2454. * Returns a new Vector3 located at the center between "value1" and "value2"
  2455. * @param value1 defines the first operand
  2456. * @param value2 defines the second operand
  2457. * @returns the new Vector3
  2458. */
  2459. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2460. /**
  2461. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2462. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2463. * to something in order to rotate it from its local system to the given target system
  2464. * Note: axis1, axis2 and axis3 are normalized during this operation
  2465. * @param axis1 defines the first axis
  2466. * @param axis2 defines the second axis
  2467. * @param axis3 defines the third axis
  2468. * @returns a new Vector3
  2469. */
  2470. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2471. /**
  2472. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2473. * @param axis1 defines the first axis
  2474. * @param axis2 defines the second axis
  2475. * @param axis3 defines the third axis
  2476. * @param ref defines the Vector3 where to store the result
  2477. */
  2478. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2479. }
  2480. /**
  2481. * Vector4 class created for EulerAngle class conversion to Quaternion
  2482. */
  2483. export class Vector4 {
  2484. /** x value of the vector */
  2485. x: number;
  2486. /** y value of the vector */
  2487. y: number;
  2488. /** z value of the vector */
  2489. z: number;
  2490. /** w value of the vector */
  2491. w: number;
  2492. /**
  2493. * Creates a Vector4 object from the given floats.
  2494. * @param x x value of the vector
  2495. * @param y y value of the vector
  2496. * @param z z value of the vector
  2497. * @param w w value of the vector
  2498. */
  2499. constructor(
  2500. /** x value of the vector */
  2501. x: number,
  2502. /** y value of the vector */
  2503. y: number,
  2504. /** z value of the vector */
  2505. z: number,
  2506. /** w value of the vector */
  2507. w: number);
  2508. /**
  2509. * Returns the string with the Vector4 coordinates.
  2510. * @returns a string containing all the vector values
  2511. */
  2512. toString(): string;
  2513. /**
  2514. * Returns the string "Vector4".
  2515. * @returns "Vector4"
  2516. */
  2517. getClassName(): string;
  2518. /**
  2519. * Returns the Vector4 hash code.
  2520. * @returns a unique hash code
  2521. */
  2522. getHashCode(): number;
  2523. /**
  2524. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2525. * @returns the resulting array
  2526. */
  2527. asArray(): number[];
  2528. /**
  2529. * Populates the given array from the given index with the Vector4 coordinates.
  2530. * @param array array to populate
  2531. * @param index index of the array to start at (default: 0)
  2532. * @returns the Vector4.
  2533. */
  2534. toArray(array: FloatArray, index?: number): Vector4;
  2535. /**
  2536. * Adds the given vector to the current Vector4.
  2537. * @param otherVector the vector to add
  2538. * @returns the updated Vector4.
  2539. */
  2540. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2541. /**
  2542. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2543. * @param otherVector the vector to add
  2544. * @returns the resulting vector
  2545. */
  2546. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2547. /**
  2548. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2549. * @param otherVector the vector to add
  2550. * @param result the vector to store the result
  2551. * @returns the current Vector4.
  2552. */
  2553. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2554. /**
  2555. * Subtract in place the given vector from the current Vector4.
  2556. * @param otherVector the vector to subtract
  2557. * @returns the updated Vector4.
  2558. */
  2559. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2560. /**
  2561. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2562. * @param otherVector the vector to add
  2563. * @returns the new vector with the result
  2564. */
  2565. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2566. /**
  2567. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2568. * @param otherVector the vector to subtract
  2569. * @param result the vector to store the result
  2570. * @returns the current Vector4.
  2571. */
  2572. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2573. /**
  2574. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2575. */
  2576. /**
  2577. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2578. * @param x value to subtract
  2579. * @param y value to subtract
  2580. * @param z value to subtract
  2581. * @param w value to subtract
  2582. * @returns new vector containing the result
  2583. */
  2584. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2585. /**
  2586. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2587. * @param x value to subtract
  2588. * @param y value to subtract
  2589. * @param z value to subtract
  2590. * @param w value to subtract
  2591. * @param result the vector to store the result in
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2597. * @returns a new vector with the negated values
  2598. */
  2599. negate(): Vector4;
  2600. /**
  2601. * Multiplies the current Vector4 coordinates by scale (float).
  2602. * @param scale the number to scale with
  2603. * @returns the updated Vector4.
  2604. */
  2605. scaleInPlace(scale: number): Vector4;
  2606. /**
  2607. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2608. * @param scale the number to scale with
  2609. * @returns a new vector with the result
  2610. */
  2611. scale(scale: number): Vector4;
  2612. /**
  2613. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2614. * @param scale the number to scale with
  2615. * @param result a vector to store the result in
  2616. * @returns the current Vector4.
  2617. */
  2618. scaleToRef(scale: number, result: Vector4): Vector4;
  2619. /**
  2620. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2621. * @param scale defines the scale factor
  2622. * @param result defines the Vector4 object where to store the result
  2623. * @returns the unmodified current Vector4
  2624. */
  2625. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2626. /**
  2627. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2628. * @param otherVector the vector to compare against
  2629. * @returns true if they are equal
  2630. */
  2631. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2632. /**
  2633. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2634. * @param otherVector vector to compare against
  2635. * @param epsilon (Default: very small number)
  2636. * @returns true if they are equal
  2637. */
  2638. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2639. /**
  2640. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2641. * @param x x value to compare against
  2642. * @param y y value to compare against
  2643. * @param z z value to compare against
  2644. * @param w w value to compare against
  2645. * @returns true if equal
  2646. */
  2647. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2648. /**
  2649. * Multiplies in place the current Vector4 by the given one.
  2650. * @param otherVector vector to multiple with
  2651. * @returns the updated Vector4.
  2652. */
  2653. multiplyInPlace(otherVector: Vector4): Vector4;
  2654. /**
  2655. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2656. * @param otherVector vector to multiple with
  2657. * @returns resulting new vector
  2658. */
  2659. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2660. /**
  2661. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2662. * @param otherVector vector to multiple with
  2663. * @param result vector to store the result
  2664. * @returns the current Vector4.
  2665. */
  2666. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2667. /**
  2668. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2669. * @param x x value multiply with
  2670. * @param y y value multiply with
  2671. * @param z z value multiply with
  2672. * @param w w value multiply with
  2673. * @returns resulting new vector
  2674. */
  2675. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2678. * @param otherVector vector to devide with
  2679. * @returns resulting new vector
  2680. */
  2681. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2684. * @param otherVector vector to devide with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Divides the current Vector3 coordinates by the given ones.
  2691. * @param otherVector vector to devide with
  2692. * @returns the updated Vector3.
  2693. */
  2694. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2695. /**
  2696. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2697. * @param other defines the second operand
  2698. * @returns the current updated Vector4
  2699. */
  2700. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2701. /**
  2702. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector4
  2705. */
  2706. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2707. /**
  2708. * Gets a new Vector4 from current Vector4 floored values
  2709. * @returns a new Vector4
  2710. */
  2711. floor(): Vector4;
  2712. /**
  2713. * Gets a new Vector4 from current Vector3 floored values
  2714. * @returns a new Vector4
  2715. */
  2716. fract(): Vector4;
  2717. /**
  2718. * Returns the Vector4 length (float).
  2719. * @returns the length
  2720. */
  2721. length(): number;
  2722. /**
  2723. * Returns the Vector4 squared length (float).
  2724. * @returns the length squared
  2725. */
  2726. lengthSquared(): number;
  2727. /**
  2728. * Normalizes in place the Vector4.
  2729. * @returns the updated Vector4.
  2730. */
  2731. normalize(): Vector4;
  2732. /**
  2733. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2734. * @returns this converted to a new vector3
  2735. */
  2736. toVector3(): Vector3;
  2737. /**
  2738. * Returns a new Vector4 copied from the current one.
  2739. * @returns the new cloned vector
  2740. */
  2741. clone(): Vector4;
  2742. /**
  2743. * Updates the current Vector4 with the given one coordinates.
  2744. * @param source the source vector to copy from
  2745. * @returns the updated Vector4.
  2746. */
  2747. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2748. /**
  2749. * Updates the current Vector4 coordinates with the given floats.
  2750. * @param x float to copy from
  2751. * @param y float to copy from
  2752. * @param z float to copy from
  2753. * @param w float to copy from
  2754. * @returns the updated Vector4.
  2755. */
  2756. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2757. /**
  2758. * Updates the current Vector4 coordinates with the given floats.
  2759. * @param x float to set from
  2760. * @param y float to set from
  2761. * @param z float to set from
  2762. * @param w float to set from
  2763. * @returns the updated Vector4.
  2764. */
  2765. set(x: number, y: number, z: number, w: number): Vector4;
  2766. /**
  2767. * Copies the given float to the current Vector3 coordinates
  2768. * @param v defines the x, y, z and w coordinates of the operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. setAll(v: number): Vector4;
  2772. /**
  2773. * Returns a new Vector4 set from the starting index of the given array.
  2774. * @param array the array to pull values from
  2775. * @param offset the offset into the array to start at
  2776. * @returns the new vector
  2777. */
  2778. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2779. /**
  2780. * Updates the given vector "result" from the starting index of the given array.
  2781. * @param array the array to pull values from
  2782. * @param offset the offset into the array to start at
  2783. * @param result the vector to store the result in
  2784. */
  2785. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2786. /**
  2787. * Updates the given vector "result" from the starting index of the given Float32Array.
  2788. * @param array the array to pull values from
  2789. * @param offset the offset into the array to start at
  2790. * @param result the vector to store the result in
  2791. */
  2792. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2793. /**
  2794. * Updates the given vector "result" coordinates from the given floats.
  2795. * @param x float to set from
  2796. * @param y float to set from
  2797. * @param z float to set from
  2798. * @param w float to set from
  2799. * @param result the vector to the floats in
  2800. */
  2801. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2802. /**
  2803. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2804. * @returns the new vector
  2805. */
  2806. static Zero(): Vector4;
  2807. /**
  2808. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2809. * @returns the new vector
  2810. */
  2811. static One(): Vector4;
  2812. /**
  2813. * Returns a new normalized Vector4 from the given one.
  2814. * @param vector the vector to normalize
  2815. * @returns the vector
  2816. */
  2817. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2818. /**
  2819. * Updates the given vector "result" from the normalization of the given one.
  2820. * @param vector the vector to normalize
  2821. * @param result the vector to store the result in
  2822. */
  2823. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2824. /**
  2825. * Returns a vector with the minimum values from the left and right vectors
  2826. * @param left left vector to minimize
  2827. * @param right right vector to minimize
  2828. * @returns a new vector with the minimum of the left and right vector values
  2829. */
  2830. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2831. /**
  2832. * Returns a vector with the maximum values from the left and right vectors
  2833. * @param left left vector to maximize
  2834. * @param right right vector to maximize
  2835. * @returns a new vector with the maximum of the left and right vector values
  2836. */
  2837. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2838. /**
  2839. * Returns the distance (float) between the vectors "value1" and "value2".
  2840. * @param value1 value to calulate the distance between
  2841. * @param value2 value to calulate the distance between
  2842. * @return the distance between the two vectors
  2843. */
  2844. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2845. /**
  2846. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2847. * @param value1 value to calulate the distance between
  2848. * @param value2 value to calulate the distance between
  2849. * @return the distance between the two vectors squared
  2850. */
  2851. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2852. /**
  2853. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2854. * @param value1 value to calulate the center between
  2855. * @param value2 value to calulate the center between
  2856. * @return the center between the two vectors
  2857. */
  2858. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2859. /**
  2860. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2861. * This methods computes transformed normalized direction vectors only.
  2862. * @param vector the vector to transform
  2863. * @param transformation the transformation matrix to apply
  2864. * @returns the new vector
  2865. */
  2866. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2867. /**
  2868. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2869. * This methods computes transformed normalized direction vectors only.
  2870. * @param vector the vector to transform
  2871. * @param transformation the transformation matrix to apply
  2872. * @param result the vector to store the result in
  2873. */
  2874. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2875. /**
  2876. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2877. * This methods computes transformed normalized direction vectors only.
  2878. * @param x value to transform
  2879. * @param y value to transform
  2880. * @param z value to transform
  2881. * @param w value to transform
  2882. * @param transformation the transformation matrix to apply
  2883. * @param result the vector to store the results in
  2884. */
  2885. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2886. /**
  2887. * Creates a new Vector4 from a Vector3
  2888. * @param source defines the source data
  2889. * @param w defines the 4th component (default is 0)
  2890. * @returns a new Vector4
  2891. */
  2892. static FromVector3(source: Vector3, w?: number): Vector4;
  2893. }
  2894. /**
  2895. * Class used to store quaternion data
  2896. * @see https://en.wikipedia.org/wiki/Quaternion
  2897. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2898. */
  2899. export class Quaternion {
  2900. /** defines the first component (0 by default) */
  2901. x: number;
  2902. /** defines the second component (0 by default) */
  2903. y: number;
  2904. /** defines the third component (0 by default) */
  2905. z: number;
  2906. /** defines the fourth component (1.0 by default) */
  2907. w: number;
  2908. /**
  2909. * Creates a new Quaternion from the given floats
  2910. * @param x defines the first component (0 by default)
  2911. * @param y defines the second component (0 by default)
  2912. * @param z defines the third component (0 by default)
  2913. * @param w defines the fourth component (1.0 by default)
  2914. */
  2915. constructor(
  2916. /** defines the first component (0 by default) */
  2917. x?: number,
  2918. /** defines the second component (0 by default) */
  2919. y?: number,
  2920. /** defines the third component (0 by default) */
  2921. z?: number,
  2922. /** defines the fourth component (1.0 by default) */
  2923. w?: number);
  2924. /**
  2925. * Gets a string representation for the current quaternion
  2926. * @returns a string with the Quaternion coordinates
  2927. */
  2928. toString(): string;
  2929. /**
  2930. * Gets the class name of the quaternion
  2931. * @returns the string "Quaternion"
  2932. */
  2933. getClassName(): string;
  2934. /**
  2935. * Gets a hash code for this quaternion
  2936. * @returns the quaternion hash code
  2937. */
  2938. getHashCode(): number;
  2939. /**
  2940. * Copy the quaternion to an array
  2941. * @returns a new array populated with 4 elements from the quaternion coordinates
  2942. */
  2943. asArray(): number[];
  2944. /**
  2945. * Check if two quaternions are equals
  2946. * @param otherQuaternion defines the second operand
  2947. * @return true if the current quaternion and the given one coordinates are strictly equals
  2948. */
  2949. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2950. /**
  2951. * Clone the current quaternion
  2952. * @returns a new quaternion copied from the current one
  2953. */
  2954. clone(): Quaternion;
  2955. /**
  2956. * Copy a quaternion to the current one
  2957. * @param other defines the other quaternion
  2958. * @returns the updated current quaternion
  2959. */
  2960. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2961. /**
  2962. * Updates the current quaternion with the given float coordinates
  2963. * @param x defines the x coordinate
  2964. * @param y defines the y coordinate
  2965. * @param z defines the z coordinate
  2966. * @param w defines the w coordinate
  2967. * @returns the updated current quaternion
  2968. */
  2969. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2970. /**
  2971. * Updates the current quaternion from the given float coordinates
  2972. * @param x defines the x coordinate
  2973. * @param y defines the y coordinate
  2974. * @param z defines the z coordinate
  2975. * @param w defines the w coordinate
  2976. * @returns the updated current quaternion
  2977. */
  2978. set(x: number, y: number, z: number, w: number): Quaternion;
  2979. /**
  2980. * Adds two quaternions
  2981. * @param other defines the second operand
  2982. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2983. */
  2984. add(other: DeepImmutable<Quaternion>): Quaternion;
  2985. /**
  2986. * Add a quaternion to the current one
  2987. * @param other defines the quaternion to add
  2988. * @returns the current quaternion
  2989. */
  2990. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2991. /**
  2992. * Subtract two quaternions
  2993. * @param other defines the second operand
  2994. * @returns a new quaternion as the subtraction result of the given one from the current one
  2995. */
  2996. subtract(other: Quaternion): Quaternion;
  2997. /**
  2998. * Multiplies the current quaternion by a scale factor
  2999. * @param value defines the scale factor
  3000. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3001. */
  3002. scale(value: number): Quaternion;
  3003. /**
  3004. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3005. * @param scale defines the scale factor
  3006. * @param result defines the Quaternion object where to store the result
  3007. * @returns the unmodified current quaternion
  3008. */
  3009. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3010. /**
  3011. * Multiplies in place the current quaternion by a scale factor
  3012. * @param value defines the scale factor
  3013. * @returns the current modified quaternion
  3014. */
  3015. scaleInPlace(value: number): Quaternion;
  3016. /**
  3017. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3018. * @param scale defines the scale factor
  3019. * @param result defines the Quaternion object where to store the result
  3020. * @returns the unmodified current quaternion
  3021. */
  3022. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3023. /**
  3024. * Multiplies two quaternions
  3025. * @param q1 defines the second operand
  3026. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3027. */
  3028. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3029. /**
  3030. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3031. * @param q1 defines the second operand
  3032. * @param result defines the target quaternion
  3033. * @returns the current quaternion
  3034. */
  3035. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3036. /**
  3037. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3038. * @param q1 defines the second operand
  3039. * @returns the currentupdated quaternion
  3040. */
  3041. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3042. /**
  3043. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3044. * @param ref defines the target quaternion
  3045. * @returns the current quaternion
  3046. */
  3047. conjugateToRef(ref: Quaternion): Quaternion;
  3048. /**
  3049. * Conjugates in place (1-q) the current quaternion
  3050. * @returns the current updated quaternion
  3051. */
  3052. conjugateInPlace(): Quaternion;
  3053. /**
  3054. * Conjugates in place (1-q) the current quaternion
  3055. * @returns a new quaternion
  3056. */
  3057. conjugate(): Quaternion;
  3058. /**
  3059. * Gets length of current quaternion
  3060. * @returns the quaternion length (float)
  3061. */
  3062. length(): number;
  3063. /**
  3064. * Normalize in place the current quaternion
  3065. * @returns the current updated quaternion
  3066. */
  3067. normalize(): Quaternion;
  3068. /**
  3069. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3070. * @param order is a reserved parameter and is ignore for now
  3071. * @returns a new Vector3 containing the Euler angles
  3072. */
  3073. toEulerAngles(order?: string): Vector3;
  3074. /**
  3075. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3076. * @param result defines the vector which will be filled with the Euler angles
  3077. * @param order is a reserved parameter and is ignore for now
  3078. * @returns the current unchanged quaternion
  3079. */
  3080. toEulerAnglesToRef(result: Vector3): Quaternion;
  3081. /**
  3082. * Updates the given rotation matrix with the current quaternion values
  3083. * @param result defines the target matrix
  3084. * @returns the current unchanged quaternion
  3085. */
  3086. toRotationMatrix(result: Matrix): Quaternion;
  3087. /**
  3088. * Updates the current quaternion from the given rotation matrix values
  3089. * @param matrix defines the source matrix
  3090. * @returns the current updated quaternion
  3091. */
  3092. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3093. /**
  3094. * Creates a new quaternion from a rotation matrix
  3095. * @param matrix defines the source matrix
  3096. * @returns a new quaternion created from the given rotation matrix values
  3097. */
  3098. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3099. /**
  3100. * Updates the given quaternion with the given rotation matrix values
  3101. * @param matrix defines the source matrix
  3102. * @param result defines the target quaternion
  3103. */
  3104. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3105. /**
  3106. * Returns the dot product (float) between the quaternions "left" and "right"
  3107. * @param left defines the left operand
  3108. * @param right defines the right operand
  3109. * @returns the dot product
  3110. */
  3111. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3112. /**
  3113. * Checks if the two quaternions are close to each other
  3114. * @param quat0 defines the first quaternion to check
  3115. * @param quat1 defines the second quaternion to check
  3116. * @returns true if the two quaternions are close to each other
  3117. */
  3118. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3119. /**
  3120. * Creates an empty quaternion
  3121. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3122. */
  3123. static Zero(): Quaternion;
  3124. /**
  3125. * Inverse a given quaternion
  3126. * @param q defines the source quaternion
  3127. * @returns a new quaternion as the inverted current quaternion
  3128. */
  3129. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3130. /**
  3131. * Inverse a given quaternion
  3132. * @param q defines the source quaternion
  3133. * @param result the quaternion the result will be stored in
  3134. * @returns the result quaternion
  3135. */
  3136. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3137. /**
  3138. * Creates an identity quaternion
  3139. * @returns the identity quaternion
  3140. */
  3141. static Identity(): Quaternion;
  3142. /**
  3143. * Gets a boolean indicating if the given quaternion is identity
  3144. * @param quaternion defines the quaternion to check
  3145. * @returns true if the quaternion is identity
  3146. */
  3147. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3148. /**
  3149. * Creates a quaternion from a rotation around an axis
  3150. * @param axis defines the axis to use
  3151. * @param angle defines the angle to use
  3152. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3153. */
  3154. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3155. /**
  3156. * Creates a rotation around an axis and stores it into the given quaternion
  3157. * @param axis defines the axis to use
  3158. * @param angle defines the angle to use
  3159. * @param result defines the target quaternion
  3160. * @returns the target quaternion
  3161. */
  3162. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3163. /**
  3164. * Creates a new quaternion from data stored into an array
  3165. * @param array defines the data source
  3166. * @param offset defines the offset in the source array where the data starts
  3167. * @returns a new quaternion
  3168. */
  3169. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3170. /**
  3171. * Create a quaternion from Euler rotation angles
  3172. * @param x Pitch
  3173. * @param y Yaw
  3174. * @param z Roll
  3175. * @returns the new Quaternion
  3176. */
  3177. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3178. /**
  3179. * Updates a quaternion from Euler rotation angles
  3180. * @param x Pitch
  3181. * @param y Yaw
  3182. * @param z Roll
  3183. * @param result the quaternion to store the result
  3184. * @returns the updated quaternion
  3185. */
  3186. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3187. /**
  3188. * Create a quaternion from Euler rotation vector
  3189. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3190. * @returns the new Quaternion
  3191. */
  3192. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3193. /**
  3194. * Updates a quaternion from Euler rotation vector
  3195. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3196. * @param result the quaternion to store the result
  3197. * @returns the updated quaternion
  3198. */
  3199. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3200. /**
  3201. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3202. * @param yaw defines the rotation around Y axis
  3203. * @param pitch defines the rotation around X axis
  3204. * @param roll defines the rotation around Z axis
  3205. * @returns the new quaternion
  3206. */
  3207. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3208. /**
  3209. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3210. * @param yaw defines the rotation around Y axis
  3211. * @param pitch defines the rotation around X axis
  3212. * @param roll defines the rotation around Z axis
  3213. * @param result defines the target quaternion
  3214. */
  3215. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3216. /**
  3217. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3218. * @param alpha defines the rotation around first axis
  3219. * @param beta defines the rotation around second axis
  3220. * @param gamma defines the rotation around third axis
  3221. * @returns the new quaternion
  3222. */
  3223. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3224. /**
  3225. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3226. * @param alpha defines the rotation around first axis
  3227. * @param beta defines the rotation around second axis
  3228. * @param gamma defines the rotation around third axis
  3229. * @param result defines the target quaternion
  3230. */
  3231. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3232. /**
  3233. * 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)
  3234. * @param axis1 defines the first axis
  3235. * @param axis2 defines the second axis
  3236. * @param axis3 defines the third axis
  3237. * @returns the new quaternion
  3238. */
  3239. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3240. /**
  3241. * 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
  3242. * @param axis1 defines the first axis
  3243. * @param axis2 defines the second axis
  3244. * @param axis3 defines the third axis
  3245. * @param ref defines the target quaternion
  3246. */
  3247. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3248. /**
  3249. * Interpolates between two quaternions
  3250. * @param left defines first quaternion
  3251. * @param right defines second quaternion
  3252. * @param amount defines the gradient to use
  3253. * @returns the new interpolated quaternion
  3254. */
  3255. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3256. /**
  3257. * Interpolates between two quaternions and stores it into a target quaternion
  3258. * @param left defines first quaternion
  3259. * @param right defines second quaternion
  3260. * @param amount defines the gradient to use
  3261. * @param result defines the target quaternion
  3262. */
  3263. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3264. /**
  3265. * Interpolate between two quaternions using Hermite interpolation
  3266. * @param value1 defines first quaternion
  3267. * @param tangent1 defines the incoming tangent
  3268. * @param value2 defines second quaternion
  3269. * @param tangent2 defines the outgoing tangent
  3270. * @param amount defines the target quaternion
  3271. * @returns the new interpolated quaternion
  3272. */
  3273. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3274. }
  3275. /**
  3276. * Class used to store matrix data (4x4)
  3277. */
  3278. export class Matrix {
  3279. private static _updateFlagSeed;
  3280. private static _identityReadOnly;
  3281. private _isIdentity;
  3282. private _isIdentityDirty;
  3283. private _isIdentity3x2;
  3284. private _isIdentity3x2Dirty;
  3285. /**
  3286. * Gets the update flag of the matrix which is an unique number for the matrix.
  3287. * It will be incremented every time the matrix data change.
  3288. * You can use it to speed the comparison between two versions of the same matrix.
  3289. */
  3290. updateFlag: number;
  3291. private readonly _m;
  3292. /**
  3293. * Gets the internal data of the matrix
  3294. */
  3295. readonly m: DeepImmutable<Float32Array>;
  3296. /** @hidden */
  3297. _markAsUpdated(): void;
  3298. /** @hidden */
  3299. private _updateIdentityStatus;
  3300. /**
  3301. * Creates an empty matrix (filled with zeros)
  3302. */
  3303. constructor();
  3304. /**
  3305. * Check if the current matrix is identity
  3306. * @returns true is the matrix is the identity matrix
  3307. */
  3308. isIdentity(): boolean;
  3309. /**
  3310. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3311. * @returns true is the matrix is the identity matrix
  3312. */
  3313. isIdentityAs3x2(): boolean;
  3314. /**
  3315. * Gets the determinant of the matrix
  3316. * @returns the matrix determinant
  3317. */
  3318. determinant(): number;
  3319. /**
  3320. * Returns the matrix as a Float32Array
  3321. * @returns the matrix underlying array
  3322. */
  3323. toArray(): DeepImmutable<Float32Array>;
  3324. /**
  3325. * Returns the matrix as a Float32Array
  3326. * @returns the matrix underlying array.
  3327. */
  3328. asArray(): DeepImmutable<Float32Array>;
  3329. /**
  3330. * Inverts the current matrix in place
  3331. * @returns the current inverted matrix
  3332. */
  3333. invert(): Matrix;
  3334. /**
  3335. * Sets all the matrix elements to zero
  3336. * @returns the current matrix
  3337. */
  3338. reset(): Matrix;
  3339. /**
  3340. * Adds the current matrix with a second one
  3341. * @param other defines the matrix to add
  3342. * @returns a new matrix as the addition of the current matrix and the given one
  3343. */
  3344. add(other: DeepImmutable<Matrix>): Matrix;
  3345. /**
  3346. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3347. * @param other defines the matrix to add
  3348. * @param result defines the target matrix
  3349. * @returns the current matrix
  3350. */
  3351. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3352. /**
  3353. * Adds in place the given matrix to the current matrix
  3354. * @param other defines the second operand
  3355. * @returns the current updated matrix
  3356. */
  3357. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3358. /**
  3359. * Sets the given matrix to the current inverted Matrix
  3360. * @param other defines the target matrix
  3361. * @returns the unmodified current matrix
  3362. */
  3363. invertToRef(other: Matrix): Matrix;
  3364. /**
  3365. * add a value at the specified position in the current Matrix
  3366. * @param index the index of the value within the matrix. between 0 and 15.
  3367. * @param value the value to be added
  3368. * @returns the current updated matrix
  3369. */
  3370. addAtIndex(index: number, value: number): Matrix;
  3371. /**
  3372. * mutiply the specified position in the current Matrix by a value
  3373. * @param index the index of the value within the matrix. between 0 and 15.
  3374. * @param value the value to be added
  3375. * @returns the current updated matrix
  3376. */
  3377. multiplyAtIndex(index: number, value: number): Matrix;
  3378. /**
  3379. * Inserts the translation vector (using 3 floats) in the current matrix
  3380. * @param x defines the 1st component of the translation
  3381. * @param y defines the 2nd component of the translation
  3382. * @param z defines the 3rd component of the translation
  3383. * @returns the current updated matrix
  3384. */
  3385. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3386. /**
  3387. * Adds the translation vector (using 3 floats) in the current matrix
  3388. * @param x defines the 1st component of the translation
  3389. * @param y defines the 2nd component of the translation
  3390. * @param z defines the 3rd component of the translation
  3391. * @returns the current updated matrix
  3392. */
  3393. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3394. /**
  3395. * Inserts the translation vector in the current matrix
  3396. * @param vector3 defines the translation to insert
  3397. * @returns the current updated matrix
  3398. */
  3399. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3400. /**
  3401. * Gets the translation value of the current matrix
  3402. * @returns a new Vector3 as the extracted translation from the matrix
  3403. */
  3404. getTranslation(): Vector3;
  3405. /**
  3406. * Fill a Vector3 with the extracted translation from the matrix
  3407. * @param result defines the Vector3 where to store the translation
  3408. * @returns the current matrix
  3409. */
  3410. getTranslationToRef(result: Vector3): Matrix;
  3411. /**
  3412. * Remove rotation and scaling part from the matrix
  3413. * @returns the updated matrix
  3414. */
  3415. removeRotationAndScaling(): Matrix;
  3416. /**
  3417. * Multiply two matrices
  3418. * @param other defines the second operand
  3419. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3420. */
  3421. multiply(other: DeepImmutable<Matrix>): Matrix;
  3422. /**
  3423. * Copy the current matrix from the given one
  3424. * @param other defines the source matrix
  3425. * @returns the current updated matrix
  3426. */
  3427. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3428. /**
  3429. * Populates the given array from the starting index with the current matrix values
  3430. * @param array defines the target array
  3431. * @param offset defines the offset in the target array where to start storing values
  3432. * @returns the current matrix
  3433. */
  3434. copyToArray(array: Float32Array, offset?: number): Matrix;
  3435. /**
  3436. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3437. * @param other defines the second operand
  3438. * @param result defines the matrix where to store the multiplication
  3439. * @returns the current matrix
  3440. */
  3441. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3442. /**
  3443. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3444. * @param other defines the second operand
  3445. * @param result defines the array where to store the multiplication
  3446. * @param offset defines the offset in the target array where to start storing values
  3447. * @returns the current matrix
  3448. */
  3449. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3450. /**
  3451. * Check equality between this matrix and a second one
  3452. * @param value defines the second matrix to compare
  3453. * @returns true is the current matrix and the given one values are strictly equal
  3454. */
  3455. equals(value: DeepImmutable<Matrix>): boolean;
  3456. /**
  3457. * Clone the current matrix
  3458. * @returns a new matrix from the current matrix
  3459. */
  3460. clone(): Matrix;
  3461. /**
  3462. * Returns the name of the current matrix class
  3463. * @returns the string "Matrix"
  3464. */
  3465. getClassName(): string;
  3466. /**
  3467. * Gets the hash code of the current matrix
  3468. * @returns the hash code
  3469. */
  3470. getHashCode(): number;
  3471. /**
  3472. * Decomposes the current Matrix into a translation, rotation and scaling components
  3473. * @param scale defines the scale vector3 given as a reference to update
  3474. * @param rotation defines the rotation quaternion given as a reference to update
  3475. * @param translation defines the translation vector3 given as a reference to update
  3476. * @returns true if operation was successful
  3477. */
  3478. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3479. /**
  3480. * Gets specific row of the matrix
  3481. * @param index defines the number of the row to get
  3482. * @returns the index-th row of the current matrix as a new Vector4
  3483. */
  3484. getRow(index: number): Nullable<Vector4>;
  3485. /**
  3486. * Sets the index-th row of the current matrix to the vector4 values
  3487. * @param index defines the number of the row to set
  3488. * @param row defines the target vector4
  3489. * @returns the updated current matrix
  3490. */
  3491. setRow(index: number, row: Vector4): Matrix;
  3492. /**
  3493. * Compute the transpose of the matrix
  3494. * @returns the new transposed matrix
  3495. */
  3496. transpose(): Matrix;
  3497. /**
  3498. * Compute the transpose of the matrix and store it in a given matrix
  3499. * @param result defines the target matrix
  3500. * @returns the current matrix
  3501. */
  3502. transposeToRef(result: Matrix): Matrix;
  3503. /**
  3504. * Sets the index-th row of the current matrix with the given 4 x float values
  3505. * @param index defines the row index
  3506. * @param x defines the x component to set
  3507. * @param y defines the y component to set
  3508. * @param z defines the z component to set
  3509. * @param w defines the w component to set
  3510. * @returns the updated current matrix
  3511. */
  3512. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3513. /**
  3514. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3515. * @param scale defines the scale factor
  3516. * @returns a new matrix
  3517. */
  3518. scale(scale: number): Matrix;
  3519. /**
  3520. * Scale the current matrix values by a factor to a given result matrix
  3521. * @param scale defines the scale factor
  3522. * @param result defines the matrix to store the result
  3523. * @returns the current matrix
  3524. */
  3525. scaleToRef(scale: number, result: Matrix): Matrix;
  3526. /**
  3527. * Scale the current matrix values by a factor and add the result to a given matrix
  3528. * @param scale defines the scale factor
  3529. * @param result defines the Matrix to store the result
  3530. * @returns the current matrix
  3531. */
  3532. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3533. /**
  3534. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3535. * @param ref matrix to store the result
  3536. */
  3537. toNormalMatrix(ref: Matrix): void;
  3538. /**
  3539. * Gets only rotation part of the current matrix
  3540. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3541. */
  3542. getRotationMatrix(): Matrix;
  3543. /**
  3544. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3545. * @param result defines the target matrix to store data to
  3546. * @returns the current matrix
  3547. */
  3548. getRotationMatrixToRef(result: Matrix): Matrix;
  3549. /**
  3550. * Toggles model matrix from being right handed to left handed in place and vice versa
  3551. */
  3552. toggleModelMatrixHandInPlace(): void;
  3553. /**
  3554. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3555. */
  3556. toggleProjectionMatrixHandInPlace(): void;
  3557. /**
  3558. * Creates a matrix from an array
  3559. * @param array defines the source array
  3560. * @param offset defines an offset in the source array
  3561. * @returns a new Matrix set from the starting index of the given array
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3564. /**
  3565. * Copy the content of an array into a given matrix
  3566. * @param array defines the source array
  3567. * @param offset defines an offset in the source array
  3568. * @param result defines the target matrix
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3571. /**
  3572. * Stores an array into a matrix after having multiplied each component by a given factor
  3573. * @param array defines the source array
  3574. * @param offset defines the offset in the source array
  3575. * @param scale defines the scaling factor
  3576. * @param result defines the target matrix
  3577. */
  3578. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3579. /**
  3580. * Gets an identity matrix that must not be updated
  3581. */
  3582. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3583. /**
  3584. * Stores a list of values (16) inside a given matrix
  3585. * @param initialM11 defines 1st value of 1st row
  3586. * @param initialM12 defines 2nd value of 1st row
  3587. * @param initialM13 defines 3rd value of 1st row
  3588. * @param initialM14 defines 4th value of 1st row
  3589. * @param initialM21 defines 1st value of 2nd row
  3590. * @param initialM22 defines 2nd value of 2nd row
  3591. * @param initialM23 defines 3rd value of 2nd row
  3592. * @param initialM24 defines 4th value of 2nd row
  3593. * @param initialM31 defines 1st value of 3rd row
  3594. * @param initialM32 defines 2nd value of 3rd row
  3595. * @param initialM33 defines 3rd value of 3rd row
  3596. * @param initialM34 defines 4th value of 3rd row
  3597. * @param initialM41 defines 1st value of 4th row
  3598. * @param initialM42 defines 2nd value of 4th row
  3599. * @param initialM43 defines 3rd value of 4th row
  3600. * @param initialM44 defines 4th value of 4th row
  3601. * @param result defines the target matrix
  3602. */
  3603. 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;
  3604. /**
  3605. * Creates new matrix from a list of values (16)
  3606. * @param initialM11 defines 1st value of 1st row
  3607. * @param initialM12 defines 2nd value of 1st row
  3608. * @param initialM13 defines 3rd value of 1st row
  3609. * @param initialM14 defines 4th value of 1st row
  3610. * @param initialM21 defines 1st value of 2nd row
  3611. * @param initialM22 defines 2nd value of 2nd row
  3612. * @param initialM23 defines 3rd value of 2nd row
  3613. * @param initialM24 defines 4th value of 2nd row
  3614. * @param initialM31 defines 1st value of 3rd row
  3615. * @param initialM32 defines 2nd value of 3rd row
  3616. * @param initialM33 defines 3rd value of 3rd row
  3617. * @param initialM34 defines 4th value of 3rd row
  3618. * @param initialM41 defines 1st value of 4th row
  3619. * @param initialM42 defines 2nd value of 4th row
  3620. * @param initialM43 defines 3rd value of 4th row
  3621. * @param initialM44 defines 4th value of 4th row
  3622. * @returns the new matrix
  3623. */
  3624. 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;
  3625. /**
  3626. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3627. * @param scale defines the scale vector3
  3628. * @param rotation defines the rotation quaternion
  3629. * @param translation defines the translation vector3
  3630. * @returns a new matrix
  3631. */
  3632. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3633. /**
  3634. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3635. * @param scale defines the scale vector3
  3636. * @param rotation defines the rotation quaternion
  3637. * @param translation defines the translation vector3
  3638. * @param result defines the target matrix
  3639. */
  3640. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3641. /**
  3642. * Creates a new identity matrix
  3643. * @returns a new identity matrix
  3644. */
  3645. static Identity(): Matrix;
  3646. /**
  3647. * Creates a new identity matrix and stores the result in a given matrix
  3648. * @param result defines the target matrix
  3649. */
  3650. static IdentityToRef(result: Matrix): void;
  3651. /**
  3652. * Creates a new zero matrix
  3653. * @returns a new zero matrix
  3654. */
  3655. static Zero(): Matrix;
  3656. /**
  3657. * Creates a new rotation matrix for "angle" radians around the X axis
  3658. * @param angle defines the angle (in radians) to use
  3659. * @return the new matrix
  3660. */
  3661. static RotationX(angle: number): Matrix;
  3662. /**
  3663. * Creates a new matrix as the invert of a given matrix
  3664. * @param source defines the source matrix
  3665. * @returns the new matrix
  3666. */
  3667. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3668. /**
  3669. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3670. * @param angle defines the angle (in radians) to use
  3671. * @param result defines the target matrix
  3672. */
  3673. static RotationXToRef(angle: number, result: Matrix): void;
  3674. /**
  3675. * Creates a new rotation matrix for "angle" radians around the Y axis
  3676. * @param angle defines the angle (in radians) to use
  3677. * @return the new matrix
  3678. */
  3679. static RotationY(angle: number): Matrix;
  3680. /**
  3681. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3682. * @param angle defines the angle (in radians) to use
  3683. * @param result defines the target matrix
  3684. */
  3685. static RotationYToRef(angle: number, result: Matrix): void;
  3686. /**
  3687. * Creates a new rotation matrix for "angle" radians around the Z axis
  3688. * @param angle defines the angle (in radians) to use
  3689. * @return the new matrix
  3690. */
  3691. static RotationZ(angle: number): Matrix;
  3692. /**
  3693. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3694. * @param angle defines the angle (in radians) to use
  3695. * @param result defines the target matrix
  3696. */
  3697. static RotationZToRef(angle: number, result: Matrix): void;
  3698. /**
  3699. * Creates a new rotation matrix for "angle" radians around the given axis
  3700. * @param axis defines the axis to use
  3701. * @param angle defines the angle (in radians) to use
  3702. * @return the new matrix
  3703. */
  3704. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3705. /**
  3706. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3707. * @param axis defines the axis to use
  3708. * @param angle defines the angle (in radians) to use
  3709. * @param result defines the target matrix
  3710. */
  3711. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3712. /**
  3713. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3714. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3715. * @param from defines the vector to align
  3716. * @param to defines the vector to align to
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3720. /**
  3721. * Creates a rotation matrix
  3722. * @param yaw defines the yaw angle in radians (Y axis)
  3723. * @param pitch defines the pitch angle in radians (X axis)
  3724. * @param roll defines the roll angle in radians (X axis)
  3725. * @returns the new rotation matrix
  3726. */
  3727. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3728. /**
  3729. * Creates a rotation matrix and stores it in a given matrix
  3730. * @param yaw defines the yaw angle in radians (Y axis)
  3731. * @param pitch defines the pitch angle in radians (X axis)
  3732. * @param roll defines the roll angle in radians (X axis)
  3733. * @param result defines the target matrix
  3734. */
  3735. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3736. /**
  3737. * Creates a scaling matrix
  3738. * @param x defines the scale factor on X axis
  3739. * @param y defines the scale factor on Y axis
  3740. * @param z defines the scale factor on Z axis
  3741. * @returns the new matrix
  3742. */
  3743. static Scaling(x: number, y: number, z: number): Matrix;
  3744. /**
  3745. * Creates a scaling matrix and stores it in a given matrix
  3746. * @param x defines the scale factor on X axis
  3747. * @param y defines the scale factor on Y axis
  3748. * @param z defines the scale factor on Z axis
  3749. * @param result defines the target matrix
  3750. */
  3751. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3752. /**
  3753. * Creates a translation matrix
  3754. * @param x defines the translation on X axis
  3755. * @param y defines the translation on Y axis
  3756. * @param z defines the translationon Z axis
  3757. * @returns the new matrix
  3758. */
  3759. static Translation(x: number, y: number, z: number): Matrix;
  3760. /**
  3761. * Creates a translation matrix and stores it in a given matrix
  3762. * @param x defines the translation on X axis
  3763. * @param y defines the translation on Y axis
  3764. * @param z defines the translationon Z axis
  3765. * @param result defines the target matrix
  3766. */
  3767. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3768. /**
  3769. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3770. * @param startValue defines the start value
  3771. * @param endValue defines the end value
  3772. * @param gradient defines the gradient factor
  3773. * @returns the new matrix
  3774. */
  3775. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3776. /**
  3777. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3778. * @param startValue defines the start value
  3779. * @param endValue defines the end value
  3780. * @param gradient defines the gradient factor
  3781. * @param result defines the Matrix object where to store data
  3782. */
  3783. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3784. /**
  3785. * Builds a new matrix whose values are computed by:
  3786. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3787. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3788. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3789. * @param startValue defines the first matrix
  3790. * @param endValue defines the second matrix
  3791. * @param gradient defines the gradient between the two matrices
  3792. * @returns the new matrix
  3793. */
  3794. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3795. /**
  3796. * Update a matrix to values which are computed by:
  3797. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3798. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3799. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3800. * @param startValue defines the first matrix
  3801. * @param endValue defines the second matrix
  3802. * @param gradient defines the gradient between the two matrices
  3803. * @param result defines the target matrix
  3804. */
  3805. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * 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"
  3808. * This function works in left handed mode
  3809. * @param eye defines the final position of the entity
  3810. * @param target defines where the entity should look at
  3811. * @param up defines the up vector for the entity
  3812. * @returns the new matrix
  3813. */
  3814. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3815. /**
  3816. * 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".
  3817. * This function works in left handed mode
  3818. * @param eye defines the final position of the entity
  3819. * @param target defines where the entity should look at
  3820. * @param up defines the up vector for the entity
  3821. * @param result defines the target matrix
  3822. */
  3823. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3824. /**
  3825. * 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"
  3826. * This function works in right handed mode
  3827. * @param eye defines the final position of the entity
  3828. * @param target defines where the entity should look at
  3829. * @param up defines the up vector for the entity
  3830. * @returns the new matrix
  3831. */
  3832. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3833. /**
  3834. * 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".
  3835. * This function works in right handed mode
  3836. * @param eye defines the final position of the entity
  3837. * @param target defines where the entity should look at
  3838. * @param up defines the up vector for the entity
  3839. * @param result defines the target matrix
  3840. */
  3841. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3842. /**
  3843. * Create a left-handed orthographic projection matrix
  3844. * @param width defines the viewport width
  3845. * @param height defines the viewport height
  3846. * @param znear defines the near clip plane
  3847. * @param zfar defines the far clip plane
  3848. * @returns a new matrix as a left-handed orthographic projection matrix
  3849. */
  3850. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3851. /**
  3852. * Store a left-handed orthographic projection to a given matrix
  3853. * @param width defines the viewport width
  3854. * @param height defines the viewport height
  3855. * @param znear defines the near clip plane
  3856. * @param zfar defines the far clip plane
  3857. * @param result defines the target matrix
  3858. */
  3859. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3860. /**
  3861. * Create a left-handed orthographic projection matrix
  3862. * @param left defines the viewport left coordinate
  3863. * @param right defines the viewport right coordinate
  3864. * @param bottom defines the viewport bottom coordinate
  3865. * @param top defines the viewport top coordinate
  3866. * @param znear defines the near clip plane
  3867. * @param zfar defines the far clip plane
  3868. * @returns a new matrix as a left-handed orthographic projection matrix
  3869. */
  3870. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3871. /**
  3872. * Stores a left-handed orthographic projection into a given matrix
  3873. * @param left defines the viewport left coordinate
  3874. * @param right defines the viewport right coordinate
  3875. * @param bottom defines the viewport bottom coordinate
  3876. * @param top defines the viewport top coordinate
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Creates a right-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a right-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a right-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a left-handed perspective projection matrix
  3906. * @param width defines the viewport width
  3907. * @param height defines the viewport height
  3908. * @param znear defines the near clip plane
  3909. * @param zfar defines the far clip plane
  3910. * @returns a new matrix as a left-handed perspective projection matrix
  3911. */
  3912. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3913. /**
  3914. * Creates a left-handed perspective projection matrix
  3915. * @param fov defines the horizontal field of view
  3916. * @param aspect defines the aspect ratio
  3917. * @param znear defines the near clip plane
  3918. * @param zfar defines the far clip plane
  3919. * @returns a new matrix as a left-handed perspective projection matrix
  3920. */
  3921. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3922. /**
  3923. * Stores a left-handed perspective projection into a given matrix
  3924. * @param fov defines the horizontal field of view
  3925. * @param aspect defines the aspect ratio
  3926. * @param znear defines the near clip plane
  3927. * @param zfar defines the far clip plane
  3928. * @param result defines the target matrix
  3929. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3930. */
  3931. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3932. /**
  3933. * Creates a right-handed perspective projection matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @returns a new matrix as a right-handed perspective projection matrix
  3939. */
  3940. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3941. /**
  3942. * Stores a right-handed perspective projection into a given matrix
  3943. * @param fov defines the horizontal field of view
  3944. * @param aspect defines the aspect ratio
  3945. * @param znear defines the near clip plane
  3946. * @param zfar defines the far clip plane
  3947. * @param result defines the target matrix
  3948. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3949. */
  3950. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3951. /**
  3952. * Stores a perspective projection for WebVR info a given matrix
  3953. * @param fov defines the field of view
  3954. * @param znear defines the near clip plane
  3955. * @param zfar defines the far clip plane
  3956. * @param result defines the target matrix
  3957. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3958. */
  3959. static PerspectiveFovWebVRToRef(fov: {
  3960. upDegrees: number;
  3961. downDegrees: number;
  3962. leftDegrees: number;
  3963. rightDegrees: number;
  3964. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3965. /**
  3966. * Computes a complete transformation matrix
  3967. * @param viewport defines the viewport to use
  3968. * @param world defines the world matrix
  3969. * @param view defines the view matrix
  3970. * @param projection defines the projection matrix
  3971. * @param zmin defines the near clip plane
  3972. * @param zmax defines the far clip plane
  3973. * @returns the transformation matrix
  3974. */
  3975. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3976. /**
  3977. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3978. * @param matrix defines the matrix to use
  3979. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3980. */
  3981. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3982. /**
  3983. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3984. * @param matrix defines the matrix to use
  3985. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3986. */
  3987. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3988. /**
  3989. * Compute the transpose of a given matrix
  3990. * @param matrix defines the matrix to transpose
  3991. * @returns the new matrix
  3992. */
  3993. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3994. /**
  3995. * Compute the transpose of a matrix and store it in a target matrix
  3996. * @param matrix defines the matrix to transpose
  3997. * @param result defines the target matrix
  3998. */
  3999. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4000. /**
  4001. * Computes a reflection matrix from a plane
  4002. * @param plane defines the reflection plane
  4003. * @returns a new matrix
  4004. */
  4005. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4006. /**
  4007. * Computes a reflection matrix from a plane
  4008. * @param plane defines the reflection plane
  4009. * @param result defines the target matrix
  4010. */
  4011. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4012. /**
  4013. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4014. * @param xaxis defines the value of the 1st axis
  4015. * @param yaxis defines the value of the 2nd axis
  4016. * @param zaxis defines the value of the 3rd axis
  4017. * @param result defines the target matrix
  4018. */
  4019. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4020. /**
  4021. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4022. * @param quat defines the quaternion to use
  4023. * @param result defines the target matrix
  4024. */
  4025. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4026. }
  4027. /**
  4028. * @hidden
  4029. */
  4030. export class TmpVectors {
  4031. static Vector2: Vector2[];
  4032. static Vector3: Vector3[];
  4033. static Vector4: Vector4[];
  4034. static Quaternion: Quaternion[];
  4035. static Matrix: Matrix[];
  4036. }
  4037. }
  4038. declare module BABYLON {
  4039. /** Defines the cross module used constants to avoid circular dependncies */
  4040. export class Constants {
  4041. /** Defines that alpha blending is disabled */
  4042. static readonly ALPHA_DISABLE: number;
  4043. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4044. static readonly ALPHA_ADD: number;
  4045. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4046. static readonly ALPHA_COMBINE: number;
  4047. /** Defines that alpha blending to DEST - SRC * DEST */
  4048. static readonly ALPHA_SUBTRACT: number;
  4049. /** Defines that alpha blending to SRC * DEST */
  4050. static readonly ALPHA_MULTIPLY: number;
  4051. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4052. static readonly ALPHA_MAXIMIZED: number;
  4053. /** Defines that alpha blending to SRC + DEST */
  4054. static readonly ALPHA_ONEONE: number;
  4055. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_PREMULTIPLIED: number;
  4057. /**
  4058. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4059. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4060. */
  4061. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4062. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4063. static readonly ALPHA_INTERPOLATE: number;
  4064. /**
  4065. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4066. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4067. */
  4068. static readonly ALPHA_SCREENMODE: number;
  4069. /** Defines that the ressource is not delayed*/
  4070. static readonly DELAYLOADSTATE_NONE: number;
  4071. /** Defines that the ressource was successfully delay loaded */
  4072. static readonly DELAYLOADSTATE_LOADED: number;
  4073. /** Defines that the ressource is currently delay loading */
  4074. static readonly DELAYLOADSTATE_LOADING: number;
  4075. /** Defines that the ressource is delayed and has not started loading */
  4076. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4078. static readonly NEVER: number;
  4079. /** 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 */
  4080. static readonly ALWAYS: number;
  4081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4082. static readonly LESS: number;
  4083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4084. static readonly EQUAL: number;
  4085. /** 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 */
  4086. static readonly LEQUAL: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4088. static readonly GREATER: number;
  4089. /** 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 */
  4090. static readonly GEQUAL: number;
  4091. /** 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 */
  4092. static readonly NOTEQUAL: number;
  4093. /** Passed to stencilOperation to specify that stencil value must be kept */
  4094. static readonly KEEP: number;
  4095. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4096. static readonly REPLACE: number;
  4097. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4098. static readonly INCR: number;
  4099. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4100. static readonly DECR: number;
  4101. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4102. static readonly INVERT: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4104. static readonly INCR_WRAP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4106. static readonly DECR_WRAP: number;
  4107. /** Texture is not repeating outside of 0..1 UVs */
  4108. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4109. /** Texture is repeating outside of 0..1 UVs */
  4110. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4111. /** Texture is repeating and mirrored */
  4112. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4113. /** ALPHA */
  4114. static readonly TEXTUREFORMAT_ALPHA: number;
  4115. /** LUMINANCE */
  4116. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4117. /** LUMINANCE_ALPHA */
  4118. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4119. /** RGB */
  4120. static readonly TEXTUREFORMAT_RGB: number;
  4121. /** RGBA */
  4122. static readonly TEXTUREFORMAT_RGBA: number;
  4123. /** RED */
  4124. static readonly TEXTUREFORMAT_RED: number;
  4125. /** RED (2nd reference) */
  4126. static readonly TEXTUREFORMAT_R: number;
  4127. /** RG */
  4128. static readonly TEXTUREFORMAT_RG: number;
  4129. /** RED_INTEGER */
  4130. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4131. /** RED_INTEGER (2nd reference) */
  4132. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4133. /** RG_INTEGER */
  4134. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4135. /** RGB_INTEGER */
  4136. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4137. /** RGBA_INTEGER */
  4138. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4139. /** UNSIGNED_BYTE */
  4140. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4141. /** UNSIGNED_BYTE (2nd reference) */
  4142. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4143. /** FLOAT */
  4144. static readonly TEXTURETYPE_FLOAT: number;
  4145. /** HALF_FLOAT */
  4146. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4147. /** BYTE */
  4148. static readonly TEXTURETYPE_BYTE: number;
  4149. /** SHORT */
  4150. static readonly TEXTURETYPE_SHORT: number;
  4151. /** UNSIGNED_SHORT */
  4152. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4153. /** INT */
  4154. static readonly TEXTURETYPE_INT: number;
  4155. /** UNSIGNED_INT */
  4156. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4157. /** UNSIGNED_SHORT_4_4_4_4 */
  4158. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4159. /** UNSIGNED_SHORT_5_5_5_1 */
  4160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4161. /** UNSIGNED_SHORT_5_6_5 */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4163. /** UNSIGNED_INT_2_10_10_10_REV */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4165. /** UNSIGNED_INT_24_8 */
  4166. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4167. /** UNSIGNED_INT_10F_11F_11F_REV */
  4168. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4169. /** UNSIGNED_INT_5_9_9_9_REV */
  4170. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4171. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4172. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4173. /** nearest is mag = nearest and min = nearest and mip = linear */
  4174. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4175. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4176. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4177. /** Trilinear is mag = linear and min = linear and mip = linear */
  4178. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4179. /** nearest is mag = nearest and min = nearest and mip = linear */
  4180. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4181. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4182. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4183. /** Trilinear is mag = linear and min = linear and mip = linear */
  4184. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4185. /** mag = nearest and min = nearest and mip = nearest */
  4186. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4187. /** mag = nearest and min = linear and mip = nearest */
  4188. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4189. /** mag = nearest and min = linear and mip = linear */
  4190. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4191. /** mag = nearest and min = linear and mip = none */
  4192. static readonly TEXTURE_NEAREST_LINEAR: number;
  4193. /** mag = nearest and min = nearest and mip = none */
  4194. static readonly TEXTURE_NEAREST_NEAREST: number;
  4195. /** mag = linear and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4197. /** mag = linear and min = nearest and mip = linear */
  4198. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4199. /** mag = linear and min = linear and mip = none */
  4200. static readonly TEXTURE_LINEAR_LINEAR: number;
  4201. /** mag = linear and min = nearest and mip = none */
  4202. static readonly TEXTURE_LINEAR_NEAREST: number;
  4203. /** Explicit coordinates mode */
  4204. static readonly TEXTURE_EXPLICIT_MODE: number;
  4205. /** Spherical coordinates mode */
  4206. static readonly TEXTURE_SPHERICAL_MODE: number;
  4207. /** Planar coordinates mode */
  4208. static readonly TEXTURE_PLANAR_MODE: number;
  4209. /** Cubic coordinates mode */
  4210. static readonly TEXTURE_CUBIC_MODE: number;
  4211. /** Projection coordinates mode */
  4212. static readonly TEXTURE_PROJECTION_MODE: number;
  4213. /** Skybox coordinates mode */
  4214. static readonly TEXTURE_SKYBOX_MODE: number;
  4215. /** Inverse Cubic coordinates mode */
  4216. static readonly TEXTURE_INVCUBIC_MODE: number;
  4217. /** Equirectangular coordinates mode */
  4218. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4219. /** Equirectangular Fixed coordinates mode */
  4220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4221. /** Equirectangular Fixed Mirrored coordinates mode */
  4222. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4223. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4224. static readonly SCALEMODE_FLOOR: number;
  4225. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4226. static readonly SCALEMODE_NEAREST: number;
  4227. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4228. static readonly SCALEMODE_CEILING: number;
  4229. /**
  4230. * The dirty texture flag value
  4231. */
  4232. static readonly MATERIAL_TextureDirtyFlag: number;
  4233. /**
  4234. * The dirty light flag value
  4235. */
  4236. static readonly MATERIAL_LightDirtyFlag: number;
  4237. /**
  4238. * The dirty fresnel flag value
  4239. */
  4240. static readonly MATERIAL_FresnelDirtyFlag: number;
  4241. /**
  4242. * The dirty attribute flag value
  4243. */
  4244. static readonly MATERIAL_AttributesDirtyFlag: number;
  4245. /**
  4246. * The dirty misc flag value
  4247. */
  4248. static readonly MATERIAL_MiscDirtyFlag: number;
  4249. /**
  4250. * The all dirty flag value
  4251. */
  4252. static readonly MATERIAL_AllDirtyFlag: number;
  4253. /**
  4254. * Returns the triangle fill mode
  4255. */
  4256. static readonly MATERIAL_TriangleFillMode: number;
  4257. /**
  4258. * Returns the wireframe mode
  4259. */
  4260. static readonly MATERIAL_WireFrameFillMode: number;
  4261. /**
  4262. * Returns the point fill mode
  4263. */
  4264. static readonly MATERIAL_PointFillMode: number;
  4265. /**
  4266. * Returns the point list draw mode
  4267. */
  4268. static readonly MATERIAL_PointListDrawMode: number;
  4269. /**
  4270. * Returns the line list draw mode
  4271. */
  4272. static readonly MATERIAL_LineListDrawMode: number;
  4273. /**
  4274. * Returns the line loop draw mode
  4275. */
  4276. static readonly MATERIAL_LineLoopDrawMode: number;
  4277. /**
  4278. * Returns the line strip draw mode
  4279. */
  4280. static readonly MATERIAL_LineStripDrawMode: number;
  4281. /**
  4282. * Returns the triangle strip draw mode
  4283. */
  4284. static readonly MATERIAL_TriangleStripDrawMode: number;
  4285. /**
  4286. * Returns the triangle fan draw mode
  4287. */
  4288. static readonly MATERIAL_TriangleFanDrawMode: number;
  4289. /**
  4290. * Stores the clock-wise side orientation
  4291. */
  4292. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4293. /**
  4294. * Stores the counter clock-wise side orientation
  4295. */
  4296. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4297. /**
  4298. * Nothing
  4299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4300. */
  4301. static readonly ACTION_NothingTrigger: number;
  4302. /**
  4303. * On pick
  4304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4305. */
  4306. static readonly ACTION_OnPickTrigger: number;
  4307. /**
  4308. * On left pick
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_OnLeftPickTrigger: number;
  4312. /**
  4313. * On right pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnRightPickTrigger: number;
  4317. /**
  4318. * On center pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnCenterPickTrigger: number;
  4322. /**
  4323. * On pick down
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnPickDownTrigger: number;
  4327. /**
  4328. * On double pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnDoublePickTrigger: number;
  4332. /**
  4333. * On pick up
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickUpTrigger: number;
  4337. /**
  4338. * On pick out.
  4339. * This trigger will only be raised if you also declared a OnPickDown
  4340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4341. */
  4342. static readonly ACTION_OnPickOutTrigger: number;
  4343. /**
  4344. * On long press
  4345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4346. */
  4347. static readonly ACTION_OnLongPressTrigger: number;
  4348. /**
  4349. * On pointer over
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPointerOverTrigger: number;
  4353. /**
  4354. * On pointer out
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPointerOutTrigger: number;
  4358. /**
  4359. * On every frame
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnEveryFrameTrigger: number;
  4363. /**
  4364. * On intersection enter
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4368. /**
  4369. * On intersection exit
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnIntersectionExitTrigger: number;
  4373. /**
  4374. * On key down
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnKeyDownTrigger: number;
  4378. /**
  4379. * On key up
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnKeyUpTrigger: number;
  4383. /**
  4384. * Billboard mode will only apply to Y axis
  4385. */
  4386. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4387. /**
  4388. * Billboard mode will apply to all axes
  4389. */
  4390. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4391. /**
  4392. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4393. */
  4394. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4395. /**
  4396. * Gets or sets base Assets URL
  4397. */
  4398. static PARTICLES_BaseAssetsUrl: string;
  4399. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4400. * Test order :
  4401. * Is the bounding sphere outside the frustum ?
  4402. * If not, are the bounding box vertices outside the frustum ?
  4403. * It not, then the cullable object is in the frustum.
  4404. */
  4405. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4406. /** Culling strategy : Bounding Sphere Only.
  4407. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4408. * It's also less accurate than the standard because some not visible objects can still be selected.
  4409. * Test : is the bounding sphere outside the frustum ?
  4410. * If not, then the cullable object is in the frustum.
  4411. */
  4412. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4413. /** Culling strategy : Optimistic Inclusion.
  4414. * This in an inclusion test first, then the standard exclusion test.
  4415. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4416. * 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.
  4417. * Anyway, it's as accurate as the standard strategy.
  4418. * Test :
  4419. * Is the cullable object bounding sphere center in the frustum ?
  4420. * If not, apply the default culling strategy.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4423. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4424. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4425. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4426. * 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.
  4427. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4433. /**
  4434. * No logging while loading
  4435. */
  4436. static readonly SCENELOADER_NO_LOGGING: number;
  4437. /**
  4438. * Minimal logging while loading
  4439. */
  4440. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4441. /**
  4442. * Summary logging while loading
  4443. */
  4444. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4445. /**
  4446. * Detailled logging while loading
  4447. */
  4448. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4449. }
  4450. }
  4451. declare module BABYLON {
  4452. /**
  4453. * Class used to store and describe the pipeline context associated with an effect
  4454. */
  4455. export interface IPipelineContext {
  4456. /**
  4457. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4458. */
  4459. isAsync: boolean;
  4460. /**
  4461. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4462. */
  4463. isReady: boolean;
  4464. /** @hidden */
  4465. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4466. }
  4467. }
  4468. declare module BABYLON {
  4469. /** @hidden */
  4470. export interface IShaderProcessor {
  4471. attributeProcessor?: (attribute: string) => string;
  4472. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4473. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4474. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4475. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4476. lineProcessor?: (line: string, isFragment: boolean) => string;
  4477. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4478. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4479. }
  4480. }
  4481. declare module BABYLON {
  4482. /** @hidden */
  4483. export interface ProcessingOptions {
  4484. defines: string[];
  4485. indexParameters: any;
  4486. isFragment: boolean;
  4487. shouldUseHighPrecisionShader: boolean;
  4488. supportsUniformBuffers: boolean;
  4489. shadersRepository: string;
  4490. includesShadersStore: {
  4491. [key: string]: string;
  4492. };
  4493. processor?: IShaderProcessor;
  4494. version: string;
  4495. platformName: string;
  4496. lookForClosingBracketForUniformBuffer?: boolean;
  4497. }
  4498. }
  4499. declare module BABYLON {
  4500. /**
  4501. * Helper to manipulate strings
  4502. */
  4503. export class StringTools {
  4504. /**
  4505. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4506. * @param str Source string
  4507. * @param suffix Suffix to search for in the source string
  4508. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4509. */
  4510. static EndsWith(str: string, suffix: string): boolean;
  4511. /**
  4512. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4513. * @param str Source string
  4514. * @param suffix Suffix to search for in the source string
  4515. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4516. */
  4517. static StartsWith(str: string, suffix: string): boolean;
  4518. }
  4519. }
  4520. declare module BABYLON {
  4521. /** @hidden */
  4522. export class ShaderCodeNode {
  4523. line: string;
  4524. children: ShaderCodeNode[];
  4525. additionalDefineKey?: string;
  4526. additionalDefineValue?: string;
  4527. isValid(preprocessors: {
  4528. [key: string]: string;
  4529. }): boolean;
  4530. process(preprocessors: {
  4531. [key: string]: string;
  4532. }, options: ProcessingOptions): string;
  4533. }
  4534. }
  4535. declare module BABYLON {
  4536. /** @hidden */
  4537. export class ShaderCodeCursor {
  4538. private _lines;
  4539. lineIndex: number;
  4540. readonly currentLine: string;
  4541. readonly canRead: boolean;
  4542. lines: string[];
  4543. }
  4544. }
  4545. declare module BABYLON {
  4546. /** @hidden */
  4547. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4548. process(preprocessors: {
  4549. [key: string]: string;
  4550. }, options: ProcessingOptions): string;
  4551. }
  4552. }
  4553. declare module BABYLON {
  4554. /** @hidden */
  4555. export class ShaderDefineExpression {
  4556. isTrue(preprocessors: {
  4557. [key: string]: string;
  4558. }): boolean;
  4559. }
  4560. }
  4561. declare module BABYLON {
  4562. /** @hidden */
  4563. export class ShaderCodeTestNode extends ShaderCodeNode {
  4564. testExpression: ShaderDefineExpression;
  4565. isValid(preprocessors: {
  4566. [key: string]: string;
  4567. }): boolean;
  4568. }
  4569. }
  4570. declare module BABYLON {
  4571. /** @hidden */
  4572. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4573. define: string;
  4574. not: boolean;
  4575. constructor(define: string, not?: boolean);
  4576. isTrue(preprocessors: {
  4577. [key: string]: string;
  4578. }): boolean;
  4579. }
  4580. }
  4581. declare module BABYLON {
  4582. /** @hidden */
  4583. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4584. leftOperand: ShaderDefineExpression;
  4585. rightOperand: ShaderDefineExpression;
  4586. isTrue(preprocessors: {
  4587. [key: string]: string;
  4588. }): boolean;
  4589. }
  4590. }
  4591. declare module BABYLON {
  4592. /** @hidden */
  4593. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4594. leftOperand: ShaderDefineExpression;
  4595. rightOperand: ShaderDefineExpression;
  4596. isTrue(preprocessors: {
  4597. [key: string]: string;
  4598. }): boolean;
  4599. }
  4600. }
  4601. declare module BABYLON {
  4602. /** @hidden */
  4603. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4604. define: string;
  4605. operand: string;
  4606. testValue: string;
  4607. constructor(define: string, operand: string, testValue: string);
  4608. isTrue(preprocessors: {
  4609. [key: string]: string;
  4610. }): boolean;
  4611. }
  4612. }
  4613. declare module BABYLON {
  4614. /**
  4615. * @ignore
  4616. * Application error to support additional information when loading a file
  4617. */
  4618. export class LoadFileError extends Error {
  4619. /** defines the optional web request */
  4620. request?: WebRequest | undefined;
  4621. private static _setPrototypeOf;
  4622. /**
  4623. * Creates a new LoadFileError
  4624. * @param message defines the message of the error
  4625. * @param request defines the optional web request
  4626. */
  4627. constructor(message: string,
  4628. /** defines the optional web request */
  4629. request?: WebRequest | undefined);
  4630. }
  4631. }
  4632. declare module BABYLON {
  4633. /**
  4634. * Class used to enable access to offline support
  4635. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4636. */
  4637. export interface IOfflineProvider {
  4638. /**
  4639. * Gets a boolean indicating if scene must be saved in the database
  4640. */
  4641. enableSceneOffline: boolean;
  4642. /**
  4643. * Gets a boolean indicating if textures must be saved in the database
  4644. */
  4645. enableTexturesOffline: boolean;
  4646. /**
  4647. * Open the offline support and make it available
  4648. * @param successCallback defines the callback to call on success
  4649. * @param errorCallback defines the callback to call on error
  4650. */
  4651. open(successCallback: () => void, errorCallback: () => void): void;
  4652. /**
  4653. * Loads an image from the offline support
  4654. * @param url defines the url to load from
  4655. * @param image defines the target DOM image
  4656. */
  4657. loadImage(url: string, image: HTMLImageElement): void;
  4658. /**
  4659. * Loads a file from offline support
  4660. * @param url defines the URL to load from
  4661. * @param sceneLoaded defines a callback to call on success
  4662. * @param progressCallBack defines a callback to call when progress changed
  4663. * @param errorCallback defines a callback to call on error
  4664. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4665. */
  4666. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4667. }
  4668. }
  4669. declare module BABYLON {
  4670. /**
  4671. * Class used to help managing file picking and drag'n'drop
  4672. * File Storage
  4673. */
  4674. export class FilesInputStore {
  4675. /**
  4676. * List of files ready to be loaded
  4677. */
  4678. static FilesToLoad: {
  4679. [key: string]: File;
  4680. };
  4681. }
  4682. }
  4683. declare module BABYLON {
  4684. /**
  4685. * Class used to define a retry strategy when error happens while loading assets
  4686. */
  4687. export class RetryStrategy {
  4688. /**
  4689. * Function used to defines an exponential back off strategy
  4690. * @param maxRetries defines the maximum number of retries (3 by default)
  4691. * @param baseInterval defines the interval between retries
  4692. * @returns the strategy function to use
  4693. */
  4694. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4695. }
  4696. }
  4697. declare module BABYLON {
  4698. /**
  4699. * @hidden
  4700. */
  4701. export class FileTools {
  4702. /**
  4703. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4704. */
  4705. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4706. /**
  4707. * Gets or sets the base URL to use to load assets
  4708. */
  4709. static BaseUrl: string;
  4710. /**
  4711. * Default behaviour for cors in the application.
  4712. * It can be a string if the expected behavior is identical in the entire app.
  4713. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4714. */
  4715. static CorsBehavior: string | ((url: string | string[]) => string);
  4716. /**
  4717. * Gets or sets a function used to pre-process url before using them to load assets
  4718. */
  4719. static PreprocessUrl: (url: string) => string;
  4720. /**
  4721. * Removes unwanted characters from an url
  4722. * @param url defines the url to clean
  4723. * @returns the cleaned url
  4724. */
  4725. private static _CleanUrl;
  4726. /**
  4727. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4728. * @param url define the url we are trying
  4729. * @param element define the dom element where to configure the cors policy
  4730. */
  4731. static SetCorsBehavior(url: string | string[], element: {
  4732. crossOrigin: string | null;
  4733. }): void;
  4734. /**
  4735. * Loads an image as an HTMLImageElement.
  4736. * @param input url string, ArrayBuffer, or Blob to load
  4737. * @param onLoad callback called when the image successfully loads
  4738. * @param onError callback called when the image fails to load
  4739. * @param offlineProvider offline provider for caching
  4740. * @returns the HTMLImageElement of the loaded image
  4741. */
  4742. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4743. /**
  4744. * Loads a file
  4745. * @param fileToLoad defines the file to load
  4746. * @param callback defines the callback to call when data is loaded
  4747. * @param progressCallBack defines the callback to call during loading process
  4748. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4749. * @returns a file request object
  4750. */
  4751. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4752. /**
  4753. * Loads a file
  4754. * @param url url string, ArrayBuffer, or Blob to load
  4755. * @param onSuccess callback called when the file successfully loads
  4756. * @param onProgress callback called while file is loading (if the server supports this mode)
  4757. * @param offlineProvider defines the offline provider for caching
  4758. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4759. * @param onError callback called when the file fails to load
  4760. * @returns a file request object
  4761. */
  4762. 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;
  4763. /**
  4764. * Checks if the loaded document was accessed via `file:`-Protocol.
  4765. * @returns boolean
  4766. */
  4767. static IsFileURL(): boolean;
  4768. }
  4769. }
  4770. declare module BABYLON {
  4771. /** @hidden */
  4772. export class ShaderProcessor {
  4773. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4774. private static _ProcessPrecision;
  4775. private static _ExtractOperation;
  4776. private static _BuildSubExpression;
  4777. private static _BuildExpression;
  4778. private static _MoveCursorWithinIf;
  4779. private static _MoveCursor;
  4780. private static _EvaluatePreProcessors;
  4781. private static _PreparePreProcessors;
  4782. private static _ProcessShaderConversion;
  4783. private static _ProcessIncludes;
  4784. }
  4785. }
  4786. declare module BABYLON {
  4787. /**
  4788. * Class used to hold a RBG color
  4789. */
  4790. export class Color3 {
  4791. /**
  4792. * Defines the red component (between 0 and 1, default is 0)
  4793. */
  4794. r: number;
  4795. /**
  4796. * Defines the green component (between 0 and 1, default is 0)
  4797. */
  4798. g: number;
  4799. /**
  4800. * Defines the blue component (between 0 and 1, default is 0)
  4801. */
  4802. b: number;
  4803. /**
  4804. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4805. * @param r defines the red component (between 0 and 1, default is 0)
  4806. * @param g defines the green component (between 0 and 1, default is 0)
  4807. * @param b defines the blue component (between 0 and 1, default is 0)
  4808. */
  4809. constructor(
  4810. /**
  4811. * Defines the red component (between 0 and 1, default is 0)
  4812. */
  4813. r?: number,
  4814. /**
  4815. * Defines the green component (between 0 and 1, default is 0)
  4816. */
  4817. g?: number,
  4818. /**
  4819. * Defines the blue component (between 0 and 1, default is 0)
  4820. */
  4821. b?: number);
  4822. /**
  4823. * Creates a string with the Color3 current values
  4824. * @returns the string representation of the Color3 object
  4825. */
  4826. toString(): string;
  4827. /**
  4828. * Returns the string "Color3"
  4829. * @returns "Color3"
  4830. */
  4831. getClassName(): string;
  4832. /**
  4833. * Compute the Color3 hash code
  4834. * @returns an unique number that can be used to hash Color3 objects
  4835. */
  4836. getHashCode(): number;
  4837. /**
  4838. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4839. * @param array defines the array where to store the r,g,b components
  4840. * @param index defines an optional index in the target array to define where to start storing values
  4841. * @returns the current Color3 object
  4842. */
  4843. toArray(array: FloatArray, index?: number): Color3;
  4844. /**
  4845. * Returns a new Color4 object from the current Color3 and the given alpha
  4846. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4847. * @returns a new Color4 object
  4848. */
  4849. toColor4(alpha?: number): Color4;
  4850. /**
  4851. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4852. * @returns the new array
  4853. */
  4854. asArray(): number[];
  4855. /**
  4856. * Returns the luminance value
  4857. * @returns a float value
  4858. */
  4859. toLuminance(): number;
  4860. /**
  4861. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4862. * @param otherColor defines the second operand
  4863. * @returns the new Color3 object
  4864. */
  4865. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4866. /**
  4867. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4868. * @param otherColor defines the second operand
  4869. * @param result defines the Color3 object where to store the result
  4870. * @returns the current Color3
  4871. */
  4872. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4873. /**
  4874. * Determines equality between Color3 objects
  4875. * @param otherColor defines the second operand
  4876. * @returns true if the rgb values are equal to the given ones
  4877. */
  4878. equals(otherColor: DeepImmutable<Color3>): boolean;
  4879. /**
  4880. * Determines equality between the current Color3 object and a set of r,b,g values
  4881. * @param r defines the red component to check
  4882. * @param g defines the green component to check
  4883. * @param b defines the blue component to check
  4884. * @returns true if the rgb values are equal to the given ones
  4885. */
  4886. equalsFloats(r: number, g: number, b: number): boolean;
  4887. /**
  4888. * Multiplies in place each rgb value by scale
  4889. * @param scale defines the scaling factor
  4890. * @returns the updated Color3
  4891. */
  4892. scale(scale: number): Color3;
  4893. /**
  4894. * Multiplies the rgb values by scale and stores the result into "result"
  4895. * @param scale defines the scaling factor
  4896. * @param result defines the Color3 object where to store the result
  4897. * @returns the unmodified current Color3
  4898. */
  4899. scaleToRef(scale: number, result: Color3): Color3;
  4900. /**
  4901. * Scale the current Color3 values by a factor and add the result to a given Color3
  4902. * @param scale defines the scale factor
  4903. * @param result defines color to store the result into
  4904. * @returns the unmodified current Color3
  4905. */
  4906. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4907. /**
  4908. * Clamps the rgb values by the min and max values and stores the result into "result"
  4909. * @param min defines minimum clamping value (default is 0)
  4910. * @param max defines maximum clamping value (default is 1)
  4911. * @param result defines color to store the result into
  4912. * @returns the original Color3
  4913. */
  4914. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4915. /**
  4916. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4917. * @param otherColor defines the second operand
  4918. * @returns the new Color3
  4919. */
  4920. add(otherColor: DeepImmutable<Color3>): Color3;
  4921. /**
  4922. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4923. * @param otherColor defines the second operand
  4924. * @param result defines Color3 object to store the result into
  4925. * @returns the unmodified current Color3
  4926. */
  4927. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4928. /**
  4929. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4930. * @param otherColor defines the second operand
  4931. * @returns the new Color3
  4932. */
  4933. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4934. /**
  4935. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4936. * @param otherColor defines the second operand
  4937. * @param result defines Color3 object to store the result into
  4938. * @returns the unmodified current Color3
  4939. */
  4940. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4941. /**
  4942. * Copy the current object
  4943. * @returns a new Color3 copied the current one
  4944. */
  4945. clone(): Color3;
  4946. /**
  4947. * Copies the rgb values from the source in the current Color3
  4948. * @param source defines the source Color3 object
  4949. * @returns the updated Color3 object
  4950. */
  4951. copyFrom(source: DeepImmutable<Color3>): Color3;
  4952. /**
  4953. * Updates the Color3 rgb values from the given floats
  4954. * @param r defines the red component to read from
  4955. * @param g defines the green component to read from
  4956. * @param b defines the blue component to read from
  4957. * @returns the current Color3 object
  4958. */
  4959. copyFromFloats(r: number, g: number, b: number): Color3;
  4960. /**
  4961. * Updates the Color3 rgb values from the given floats
  4962. * @param r defines the red component to read from
  4963. * @param g defines the green component to read from
  4964. * @param b defines the blue component to read from
  4965. * @returns the current Color3 object
  4966. */
  4967. set(r: number, g: number, b: number): Color3;
  4968. /**
  4969. * Compute the Color3 hexadecimal code as a string
  4970. * @returns a string containing the hexadecimal representation of the Color3 object
  4971. */
  4972. toHexString(): string;
  4973. /**
  4974. * Computes a new Color3 converted from the current one to linear space
  4975. * @returns a new Color3 object
  4976. */
  4977. toLinearSpace(): Color3;
  4978. /**
  4979. * Converts current color in rgb space to HSV values
  4980. * @returns a new color3 representing the HSV values
  4981. */
  4982. toHSV(): Color3;
  4983. /**
  4984. * Converts current color in rgb space to HSV values
  4985. * @param result defines the Color3 where to store the HSV values
  4986. */
  4987. toHSVToRef(result: Color3): void;
  4988. /**
  4989. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4990. * @param convertedColor defines the Color3 object where to store the linear space version
  4991. * @returns the unmodified Color3
  4992. */
  4993. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4994. /**
  4995. * Computes a new Color3 converted from the current one to gamma space
  4996. * @returns a new Color3 object
  4997. */
  4998. toGammaSpace(): Color3;
  4999. /**
  5000. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5001. * @param convertedColor defines the Color3 object where to store the gamma space version
  5002. * @returns the unmodified Color3
  5003. */
  5004. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5005. private static _BlackReadOnly;
  5006. /**
  5007. * Convert Hue, saturation and value to a Color3 (RGB)
  5008. * @param hue defines the hue
  5009. * @param saturation defines the saturation
  5010. * @param value defines the value
  5011. * @param result defines the Color3 where to store the RGB values
  5012. */
  5013. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5014. /**
  5015. * Creates a new Color3 from the string containing valid hexadecimal values
  5016. * @param hex defines a string containing valid hexadecimal values
  5017. * @returns a new Color3 object
  5018. */
  5019. static FromHexString(hex: string): Color3;
  5020. /**
  5021. * Creates a new Color3 from the starting index of the given array
  5022. * @param array defines the source array
  5023. * @param offset defines an offset in the source array
  5024. * @returns a new Color3 object
  5025. */
  5026. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5027. /**
  5028. * Creates a new Color3 from integer values (< 256)
  5029. * @param r defines the red component to read from (value between 0 and 255)
  5030. * @param g defines the green component to read from (value between 0 and 255)
  5031. * @param b defines the blue component to read from (value between 0 and 255)
  5032. * @returns a new Color3 object
  5033. */
  5034. static FromInts(r: number, g: number, b: number): Color3;
  5035. /**
  5036. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5037. * @param start defines the start Color3 value
  5038. * @param end defines the end Color3 value
  5039. * @param amount defines the gradient value between start and end
  5040. * @returns a new Color3 object
  5041. */
  5042. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5043. /**
  5044. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5045. * @param left defines the start value
  5046. * @param right defines the end value
  5047. * @param amount defines the gradient factor
  5048. * @param result defines the Color3 object where to store the result
  5049. */
  5050. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5051. /**
  5052. * Returns a Color3 value containing a red color
  5053. * @returns a new Color3 object
  5054. */
  5055. static Red(): Color3;
  5056. /**
  5057. * Returns a Color3 value containing a green color
  5058. * @returns a new Color3 object
  5059. */
  5060. static Green(): Color3;
  5061. /**
  5062. * Returns a Color3 value containing a blue color
  5063. * @returns a new Color3 object
  5064. */
  5065. static Blue(): Color3;
  5066. /**
  5067. * Returns a Color3 value containing a black color
  5068. * @returns a new Color3 object
  5069. */
  5070. static Black(): Color3;
  5071. /**
  5072. * Gets a Color3 value containing a black color that must not be updated
  5073. */
  5074. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5075. /**
  5076. * Returns a Color3 value containing a white color
  5077. * @returns a new Color3 object
  5078. */
  5079. static White(): Color3;
  5080. /**
  5081. * Returns a Color3 value containing a purple color
  5082. * @returns a new Color3 object
  5083. */
  5084. static Purple(): Color3;
  5085. /**
  5086. * Returns a Color3 value containing a magenta color
  5087. * @returns a new Color3 object
  5088. */
  5089. static Magenta(): Color3;
  5090. /**
  5091. * Returns a Color3 value containing a yellow color
  5092. * @returns a new Color3 object
  5093. */
  5094. static Yellow(): Color3;
  5095. /**
  5096. * Returns a Color3 value containing a gray color
  5097. * @returns a new Color3 object
  5098. */
  5099. static Gray(): Color3;
  5100. /**
  5101. * Returns a Color3 value containing a teal color
  5102. * @returns a new Color3 object
  5103. */
  5104. static Teal(): Color3;
  5105. /**
  5106. * Returns a Color3 value containing a random color
  5107. * @returns a new Color3 object
  5108. */
  5109. static Random(): Color3;
  5110. }
  5111. /**
  5112. * Class used to hold a RBGA color
  5113. */
  5114. export class Color4 {
  5115. /**
  5116. * Defines the red component (between 0 and 1, default is 0)
  5117. */
  5118. r: number;
  5119. /**
  5120. * Defines the green component (between 0 and 1, default is 0)
  5121. */
  5122. g: number;
  5123. /**
  5124. * Defines the blue component (between 0 and 1, default is 0)
  5125. */
  5126. b: number;
  5127. /**
  5128. * Defines the alpha component (between 0 and 1, default is 1)
  5129. */
  5130. a: number;
  5131. /**
  5132. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5133. * @param r defines the red component (between 0 and 1, default is 0)
  5134. * @param g defines the green component (between 0 and 1, default is 0)
  5135. * @param b defines the blue component (between 0 and 1, default is 0)
  5136. * @param a defines the alpha component (between 0 and 1, default is 1)
  5137. */
  5138. constructor(
  5139. /**
  5140. * Defines the red component (between 0 and 1, default is 0)
  5141. */
  5142. r?: number,
  5143. /**
  5144. * Defines the green component (between 0 and 1, default is 0)
  5145. */
  5146. g?: number,
  5147. /**
  5148. * Defines the blue component (between 0 and 1, default is 0)
  5149. */
  5150. b?: number,
  5151. /**
  5152. * Defines the alpha component (between 0 and 1, default is 1)
  5153. */
  5154. a?: number);
  5155. /**
  5156. * Adds in place the given Color4 values to the current Color4 object
  5157. * @param right defines the second operand
  5158. * @returns the current updated Color4 object
  5159. */
  5160. addInPlace(right: DeepImmutable<Color4>): Color4;
  5161. /**
  5162. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5163. * @returns the new array
  5164. */
  5165. asArray(): number[];
  5166. /**
  5167. * Stores from the starting index in the given array the Color4 successive values
  5168. * @param array defines the array where to store the r,g,b components
  5169. * @param index defines an optional index in the target array to define where to start storing values
  5170. * @returns the current Color4 object
  5171. */
  5172. toArray(array: number[], index?: number): Color4;
  5173. /**
  5174. * Determines equality between Color4 objects
  5175. * @param otherColor defines the second operand
  5176. * @returns true if the rgba values are equal to the given ones
  5177. */
  5178. equals(otherColor: DeepImmutable<Color4>): boolean;
  5179. /**
  5180. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5181. * @param right defines the second operand
  5182. * @returns a new Color4 object
  5183. */
  5184. add(right: DeepImmutable<Color4>): Color4;
  5185. /**
  5186. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5187. * @param right defines the second operand
  5188. * @returns a new Color4 object
  5189. */
  5190. subtract(right: DeepImmutable<Color4>): Color4;
  5191. /**
  5192. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5193. * @param right defines the second operand
  5194. * @param result defines the Color4 object where to store the result
  5195. * @returns the current Color4 object
  5196. */
  5197. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5198. /**
  5199. * Creates a new Color4 with the current Color4 values multiplied by scale
  5200. * @param scale defines the scaling factor to apply
  5201. * @returns a new Color4 object
  5202. */
  5203. scale(scale: number): Color4;
  5204. /**
  5205. * Multiplies the current Color4 values by scale and stores the result in "result"
  5206. * @param scale defines the scaling factor to apply
  5207. * @param result defines the Color4 object where to store the result
  5208. * @returns the current unmodified Color4
  5209. */
  5210. scaleToRef(scale: number, result: Color4): Color4;
  5211. /**
  5212. * Scale the current Color4 values by a factor and add the result to a given Color4
  5213. * @param scale defines the scale factor
  5214. * @param result defines the Color4 object where to store the result
  5215. * @returns the unmodified current Color4
  5216. */
  5217. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5218. /**
  5219. * Clamps the rgb values by the min and max values and stores the result into "result"
  5220. * @param min defines minimum clamping value (default is 0)
  5221. * @param max defines maximum clamping value (default is 1)
  5222. * @param result defines color to store the result into.
  5223. * @returns the cuurent Color4
  5224. */
  5225. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5226. /**
  5227. * Multipy an Color4 value by another and return a new Color4 object
  5228. * @param color defines the Color4 value to multiply by
  5229. * @returns a new Color4 object
  5230. */
  5231. multiply(color: Color4): Color4;
  5232. /**
  5233. * Multipy a Color4 value by another and push the result in a reference value
  5234. * @param color defines the Color4 value to multiply by
  5235. * @param result defines the Color4 to fill the result in
  5236. * @returns the result Color4
  5237. */
  5238. multiplyToRef(color: Color4, result: Color4): Color4;
  5239. /**
  5240. * Creates a string with the Color4 current values
  5241. * @returns the string representation of the Color4 object
  5242. */
  5243. toString(): string;
  5244. /**
  5245. * Returns the string "Color4"
  5246. * @returns "Color4"
  5247. */
  5248. getClassName(): string;
  5249. /**
  5250. * Compute the Color4 hash code
  5251. * @returns an unique number that can be used to hash Color4 objects
  5252. */
  5253. getHashCode(): number;
  5254. /**
  5255. * Creates a new Color4 copied from the current one
  5256. * @returns a new Color4 object
  5257. */
  5258. clone(): Color4;
  5259. /**
  5260. * Copies the given Color4 values into the current one
  5261. * @param source defines the source Color4 object
  5262. * @returns the current updated Color4 object
  5263. */
  5264. copyFrom(source: Color4): Color4;
  5265. /**
  5266. * Copies the given float values into the current one
  5267. * @param r defines the red component to read from
  5268. * @param g defines the green component to read from
  5269. * @param b defines the blue component to read from
  5270. * @param a defines the alpha component to read from
  5271. * @returns the current updated Color4 object
  5272. */
  5273. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5274. /**
  5275. * Copies the given float values into the current one
  5276. * @param r defines the red component to read from
  5277. * @param g defines the green component to read from
  5278. * @param b defines the blue component to read from
  5279. * @param a defines the alpha component to read from
  5280. * @returns the current updated Color4 object
  5281. */
  5282. set(r: number, g: number, b: number, a: number): Color4;
  5283. /**
  5284. * Compute the Color4 hexadecimal code as a string
  5285. * @returns a string containing the hexadecimal representation of the Color4 object
  5286. */
  5287. toHexString(): string;
  5288. /**
  5289. * Computes a new Color4 converted from the current one to linear space
  5290. * @returns a new Color4 object
  5291. */
  5292. toLinearSpace(): Color4;
  5293. /**
  5294. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5295. * @param convertedColor defines the Color4 object where to store the linear space version
  5296. * @returns the unmodified Color4
  5297. */
  5298. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5299. /**
  5300. * Computes a new Color4 converted from the current one to gamma space
  5301. * @returns a new Color4 object
  5302. */
  5303. toGammaSpace(): Color4;
  5304. /**
  5305. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5306. * @param convertedColor defines the Color4 object where to store the gamma space version
  5307. * @returns the unmodified Color4
  5308. */
  5309. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5310. /**
  5311. * Creates a new Color4 from the string containing valid hexadecimal values
  5312. * @param hex defines a string containing valid hexadecimal values
  5313. * @returns a new Color4 object
  5314. */
  5315. static FromHexString(hex: string): Color4;
  5316. /**
  5317. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5318. * @param left defines the start value
  5319. * @param right defines the end value
  5320. * @param amount defines the gradient factor
  5321. * @returns a new Color4 object
  5322. */
  5323. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5324. /**
  5325. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5326. * @param left defines the start value
  5327. * @param right defines the end value
  5328. * @param amount defines the gradient factor
  5329. * @param result defines the Color4 object where to store data
  5330. */
  5331. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5332. /**
  5333. * Creates a new Color4 from a Color3 and an alpha value
  5334. * @param color3 defines the source Color3 to read from
  5335. * @param alpha defines the alpha component (1.0 by default)
  5336. * @returns a new Color4 object
  5337. */
  5338. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5339. /**
  5340. * Creates a new Color4 from the starting index element of the given array
  5341. * @param array defines the source array to read from
  5342. * @param offset defines the offset in the source array
  5343. * @returns a new Color4 object
  5344. */
  5345. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5346. /**
  5347. * Creates a new Color3 from integer values (< 256)
  5348. * @param r defines the red component to read from (value between 0 and 255)
  5349. * @param g defines the green component to read from (value between 0 and 255)
  5350. * @param b defines the blue component to read from (value between 0 and 255)
  5351. * @param a defines the alpha component to read from (value between 0 and 255)
  5352. * @returns a new Color3 object
  5353. */
  5354. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5355. /**
  5356. * Check the content of a given array and convert it to an array containing RGBA data
  5357. * If the original array was already containing count * 4 values then it is returned directly
  5358. * @param colors defines the array to check
  5359. * @param count defines the number of RGBA data to expect
  5360. * @returns an array containing count * 4 values (RGBA)
  5361. */
  5362. static CheckColors4(colors: number[], count: number): number[];
  5363. }
  5364. /**
  5365. * @hidden
  5366. */
  5367. export class TmpColors {
  5368. static Color3: Color3[];
  5369. static Color4: Color4[];
  5370. }
  5371. }
  5372. declare module BABYLON {
  5373. /**
  5374. * Class representing spherical harmonics coefficients to the 3rd degree
  5375. */
  5376. export class SphericalHarmonics {
  5377. /**
  5378. * Defines whether or not the harmonics have been prescaled for rendering.
  5379. */
  5380. preScaled: boolean;
  5381. /**
  5382. * The l0,0 coefficients of the spherical harmonics
  5383. */
  5384. l00: Vector3;
  5385. /**
  5386. * The l1,-1 coefficients of the spherical harmonics
  5387. */
  5388. l1_1: Vector3;
  5389. /**
  5390. * The l1,0 coefficients of the spherical harmonics
  5391. */
  5392. l10: Vector3;
  5393. /**
  5394. * The l1,1 coefficients of the spherical harmonics
  5395. */
  5396. l11: Vector3;
  5397. /**
  5398. * The l2,-2 coefficients of the spherical harmonics
  5399. */
  5400. l2_2: Vector3;
  5401. /**
  5402. * The l2,-1 coefficients of the spherical harmonics
  5403. */
  5404. l2_1: Vector3;
  5405. /**
  5406. * The l2,0 coefficients of the spherical harmonics
  5407. */
  5408. l20: Vector3;
  5409. /**
  5410. * The l2,1 coefficients of the spherical harmonics
  5411. */
  5412. l21: Vector3;
  5413. /**
  5414. * The l2,2 coefficients of the spherical harmonics
  5415. */
  5416. l22: Vector3;
  5417. /**
  5418. * Adds a light to the spherical harmonics
  5419. * @param direction the direction of the light
  5420. * @param color the color of the light
  5421. * @param deltaSolidAngle the delta solid angle of the light
  5422. */
  5423. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5424. /**
  5425. * Scales the spherical harmonics by the given amount
  5426. * @param scale the amount to scale
  5427. */
  5428. scaleInPlace(scale: number): void;
  5429. /**
  5430. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5431. *
  5432. * ```
  5433. * E_lm = A_l * L_lm
  5434. * ```
  5435. *
  5436. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5437. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5438. * the scaling factors are given in equation 9.
  5439. */
  5440. convertIncidentRadianceToIrradiance(): void;
  5441. /**
  5442. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5443. *
  5444. * ```
  5445. * L = (1/pi) * E * rho
  5446. * ```
  5447. *
  5448. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5449. */
  5450. convertIrradianceToLambertianRadiance(): void;
  5451. /**
  5452. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5453. * required operations at run time.
  5454. *
  5455. * This is simply done by scaling back the SH with Ylm constants parameter.
  5456. * The trigonometric part being applied by the shader at run time.
  5457. */
  5458. preScaleForRendering(): void;
  5459. /**
  5460. * Constructs a spherical harmonics from an array.
  5461. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5462. * @returns the spherical harmonics
  5463. */
  5464. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5465. /**
  5466. * Gets the spherical harmonics from polynomial
  5467. * @param polynomial the spherical polynomial
  5468. * @returns the spherical harmonics
  5469. */
  5470. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5471. }
  5472. /**
  5473. * Class representing spherical polynomial coefficients to the 3rd degree
  5474. */
  5475. export class SphericalPolynomial {
  5476. private _harmonics;
  5477. /**
  5478. * The spherical harmonics used to create the polynomials.
  5479. */
  5480. readonly preScaledHarmonics: SphericalHarmonics;
  5481. /**
  5482. * The x coefficients of the spherical polynomial
  5483. */
  5484. x: Vector3;
  5485. /**
  5486. * The y coefficients of the spherical polynomial
  5487. */
  5488. y: Vector3;
  5489. /**
  5490. * The z coefficients of the spherical polynomial
  5491. */
  5492. z: Vector3;
  5493. /**
  5494. * The xx coefficients of the spherical polynomial
  5495. */
  5496. xx: Vector3;
  5497. /**
  5498. * The yy coefficients of the spherical polynomial
  5499. */
  5500. yy: Vector3;
  5501. /**
  5502. * The zz coefficients of the spherical polynomial
  5503. */
  5504. zz: Vector3;
  5505. /**
  5506. * The xy coefficients of the spherical polynomial
  5507. */
  5508. xy: Vector3;
  5509. /**
  5510. * The yz coefficients of the spherical polynomial
  5511. */
  5512. yz: Vector3;
  5513. /**
  5514. * The zx coefficients of the spherical polynomial
  5515. */
  5516. zx: Vector3;
  5517. /**
  5518. * Adds an ambient color to the spherical polynomial
  5519. * @param color the color to add
  5520. */
  5521. addAmbient(color: Color3): void;
  5522. /**
  5523. * Scales the spherical polynomial by the given amount
  5524. * @param scale the amount to scale
  5525. */
  5526. scaleInPlace(scale: number): void;
  5527. /**
  5528. * Gets the spherical polynomial from harmonics
  5529. * @param harmonics the spherical harmonics
  5530. * @returns the spherical polynomial
  5531. */
  5532. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5533. /**
  5534. * Constructs a spherical polynomial from an array.
  5535. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5536. * @returns the spherical polynomial
  5537. */
  5538. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5539. }
  5540. }
  5541. declare module BABYLON {
  5542. /**
  5543. * Define options used to create a render target texture
  5544. */
  5545. export class RenderTargetCreationOptions {
  5546. /**
  5547. * Specifies is mipmaps must be generated
  5548. */
  5549. generateMipMaps?: boolean;
  5550. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5551. generateDepthBuffer?: boolean;
  5552. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5553. generateStencilBuffer?: boolean;
  5554. /** Defines texture type (int by default) */
  5555. type?: number;
  5556. /** Defines sampling mode (trilinear by default) */
  5557. samplingMode?: number;
  5558. /** Defines format (RGBA by default) */
  5559. format?: number;
  5560. }
  5561. }
  5562. declare module BABYLON {
  5563. /**
  5564. * @hidden
  5565. **/
  5566. export class _AlphaState {
  5567. private _isAlphaBlendDirty;
  5568. private _isBlendFunctionParametersDirty;
  5569. private _isBlendEquationParametersDirty;
  5570. private _isBlendConstantsDirty;
  5571. private _alphaBlend;
  5572. private _blendFunctionParameters;
  5573. private _blendEquationParameters;
  5574. private _blendConstants;
  5575. /**
  5576. * Initializes the state.
  5577. */
  5578. constructor();
  5579. readonly isDirty: boolean;
  5580. alphaBlend: boolean;
  5581. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5582. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5583. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5584. reset(): void;
  5585. apply(gl: WebGLRenderingContext): void;
  5586. }
  5587. }
  5588. declare module BABYLON {
  5589. /**
  5590. * @hidden
  5591. **/
  5592. export class _DepthCullingState {
  5593. private _isDepthTestDirty;
  5594. private _isDepthMaskDirty;
  5595. private _isDepthFuncDirty;
  5596. private _isCullFaceDirty;
  5597. private _isCullDirty;
  5598. private _isZOffsetDirty;
  5599. private _isFrontFaceDirty;
  5600. private _depthTest;
  5601. private _depthMask;
  5602. private _depthFunc;
  5603. private _cull;
  5604. private _cullFace;
  5605. private _zOffset;
  5606. private _frontFace;
  5607. /**
  5608. * Initializes the state.
  5609. */
  5610. constructor();
  5611. readonly isDirty: boolean;
  5612. zOffset: number;
  5613. cullFace: Nullable<number>;
  5614. cull: Nullable<boolean>;
  5615. depthFunc: Nullable<number>;
  5616. depthMask: boolean;
  5617. depthTest: boolean;
  5618. frontFace: Nullable<number>;
  5619. reset(): void;
  5620. apply(gl: WebGLRenderingContext): void;
  5621. }
  5622. }
  5623. declare module BABYLON {
  5624. /**
  5625. * @hidden
  5626. **/
  5627. export class _StencilState {
  5628. /** 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 */
  5629. static readonly ALWAYS: number;
  5630. /** Passed to stencilOperation to specify that stencil value must be kept */
  5631. static readonly KEEP: number;
  5632. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5633. static readonly REPLACE: number;
  5634. private _isStencilTestDirty;
  5635. private _isStencilMaskDirty;
  5636. private _isStencilFuncDirty;
  5637. private _isStencilOpDirty;
  5638. private _stencilTest;
  5639. private _stencilMask;
  5640. private _stencilFunc;
  5641. private _stencilFuncRef;
  5642. private _stencilFuncMask;
  5643. private _stencilOpStencilFail;
  5644. private _stencilOpDepthFail;
  5645. private _stencilOpStencilDepthPass;
  5646. readonly isDirty: boolean;
  5647. stencilFunc: number;
  5648. stencilFuncRef: number;
  5649. stencilFuncMask: number;
  5650. stencilOpStencilFail: number;
  5651. stencilOpDepthFail: number;
  5652. stencilOpStencilDepthPass: number;
  5653. stencilMask: number;
  5654. stencilTest: boolean;
  5655. constructor();
  5656. reset(): void;
  5657. apply(gl: WebGLRenderingContext): void;
  5658. }
  5659. }
  5660. declare module BABYLON {
  5661. /**
  5662. * @hidden
  5663. **/
  5664. export class _TimeToken {
  5665. _startTimeQuery: Nullable<WebGLQuery>;
  5666. _endTimeQuery: Nullable<WebGLQuery>;
  5667. _timeElapsedQuery: Nullable<WebGLQuery>;
  5668. _timeElapsedQueryEnded: boolean;
  5669. }
  5670. }
  5671. declare module BABYLON {
  5672. /**
  5673. * Class used to evalaute queries containing `and` and `or` operators
  5674. */
  5675. export class AndOrNotEvaluator {
  5676. /**
  5677. * Evaluate a query
  5678. * @param query defines the query to evaluate
  5679. * @param evaluateCallback defines the callback used to filter result
  5680. * @returns true if the query matches
  5681. */
  5682. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5683. private static _HandleParenthesisContent;
  5684. private static _SimplifyNegation;
  5685. }
  5686. }
  5687. declare module BABYLON {
  5688. /**
  5689. * Class used to store custom tags
  5690. */
  5691. export class Tags {
  5692. /**
  5693. * Adds support for tags on the given object
  5694. * @param obj defines the object to use
  5695. */
  5696. static EnableFor(obj: any): void;
  5697. /**
  5698. * Removes tags support
  5699. * @param obj defines the object to use
  5700. */
  5701. static DisableFor(obj: any): void;
  5702. /**
  5703. * Gets a boolean indicating if the given object has tags
  5704. * @param obj defines the object to use
  5705. * @returns a boolean
  5706. */
  5707. static HasTags(obj: any): boolean;
  5708. /**
  5709. * Gets the tags available on a given object
  5710. * @param obj defines the object to use
  5711. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5712. * @returns the tags
  5713. */
  5714. static GetTags(obj: any, asString?: boolean): any;
  5715. /**
  5716. * Adds tags to an object
  5717. * @param obj defines the object to use
  5718. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5719. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5720. */
  5721. static AddTagsTo(obj: any, tagsString: string): void;
  5722. /**
  5723. * @hidden
  5724. */
  5725. static _AddTagTo(obj: any, tag: string): void;
  5726. /**
  5727. * Removes specific tags from a specific object
  5728. * @param obj defines the object to use
  5729. * @param tagsString defines the tags to remove
  5730. */
  5731. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5732. /**
  5733. * @hidden
  5734. */
  5735. static _RemoveTagFrom(obj: any, tag: string): void;
  5736. /**
  5737. * Defines if tags hosted on an object match a given query
  5738. * @param obj defines the object to use
  5739. * @param tagsQuery defines the tag query
  5740. * @returns a boolean
  5741. */
  5742. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5743. }
  5744. }
  5745. declare module BABYLON {
  5746. /**
  5747. * Defines potential orientation for back face culling
  5748. */
  5749. export enum Orientation {
  5750. /**
  5751. * Clockwise
  5752. */
  5753. CW = 0,
  5754. /** Counter clockwise */
  5755. CCW = 1
  5756. }
  5757. /** Class used to represent a Bezier curve */
  5758. export class BezierCurve {
  5759. /**
  5760. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5761. * @param t defines the time
  5762. * @param x1 defines the left coordinate on X axis
  5763. * @param y1 defines the left coordinate on Y axis
  5764. * @param x2 defines the right coordinate on X axis
  5765. * @param y2 defines the right coordinate on Y axis
  5766. * @returns the interpolated value
  5767. */
  5768. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5769. }
  5770. /**
  5771. * Defines angle representation
  5772. */
  5773. export class Angle {
  5774. private _radians;
  5775. /**
  5776. * Creates an Angle object of "radians" radians (float).
  5777. * @param radians the angle in radians
  5778. */
  5779. constructor(radians: number);
  5780. /**
  5781. * Get value in degrees
  5782. * @returns the Angle value in degrees (float)
  5783. */
  5784. degrees(): number;
  5785. /**
  5786. * Get value in radians
  5787. * @returns the Angle value in radians (float)
  5788. */
  5789. radians(): number;
  5790. /**
  5791. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5792. * @param a defines first vector
  5793. * @param b defines second vector
  5794. * @returns a new Angle
  5795. */
  5796. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5797. /**
  5798. * Gets a new Angle object from the given float in radians
  5799. * @param radians defines the angle value in radians
  5800. * @returns a new Angle
  5801. */
  5802. static FromRadians(radians: number): Angle;
  5803. /**
  5804. * Gets a new Angle object from the given float in degrees
  5805. * @param degrees defines the angle value in degrees
  5806. * @returns a new Angle
  5807. */
  5808. static FromDegrees(degrees: number): Angle;
  5809. }
  5810. /**
  5811. * This represents an arc in a 2d space.
  5812. */
  5813. export class Arc2 {
  5814. /** Defines the start point of the arc */
  5815. startPoint: Vector2;
  5816. /** Defines the mid point of the arc */
  5817. midPoint: Vector2;
  5818. /** Defines the end point of the arc */
  5819. endPoint: Vector2;
  5820. /**
  5821. * Defines the center point of the arc.
  5822. */
  5823. centerPoint: Vector2;
  5824. /**
  5825. * Defines the radius of the arc.
  5826. */
  5827. radius: number;
  5828. /**
  5829. * Defines the angle of the arc (from mid point to end point).
  5830. */
  5831. angle: Angle;
  5832. /**
  5833. * Defines the start angle of the arc (from start point to middle point).
  5834. */
  5835. startAngle: Angle;
  5836. /**
  5837. * Defines the orientation of the arc (clock wise/counter clock wise).
  5838. */
  5839. orientation: Orientation;
  5840. /**
  5841. * Creates an Arc object from the three given points : start, middle and end.
  5842. * @param startPoint Defines the start point of the arc
  5843. * @param midPoint Defines the midlle point of the arc
  5844. * @param endPoint Defines the end point of the arc
  5845. */
  5846. constructor(
  5847. /** Defines the start point of the arc */
  5848. startPoint: Vector2,
  5849. /** Defines the mid point of the arc */
  5850. midPoint: Vector2,
  5851. /** Defines the end point of the arc */
  5852. endPoint: Vector2);
  5853. }
  5854. /**
  5855. * Represents a 2D path made up of multiple 2D points
  5856. */
  5857. export class Path2 {
  5858. private _points;
  5859. private _length;
  5860. /**
  5861. * If the path start and end point are the same
  5862. */
  5863. closed: boolean;
  5864. /**
  5865. * Creates a Path2 object from the starting 2D coordinates x and y.
  5866. * @param x the starting points x value
  5867. * @param y the starting points y value
  5868. */
  5869. constructor(x: number, y: number);
  5870. /**
  5871. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5872. * @param x the added points x value
  5873. * @param y the added points y value
  5874. * @returns the updated Path2.
  5875. */
  5876. addLineTo(x: number, y: number): Path2;
  5877. /**
  5878. * 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.
  5879. * @param midX middle point x value
  5880. * @param midY middle point y value
  5881. * @param endX end point x value
  5882. * @param endY end point y value
  5883. * @param numberOfSegments (default: 36)
  5884. * @returns the updated Path2.
  5885. */
  5886. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5887. /**
  5888. * Closes the Path2.
  5889. * @returns the Path2.
  5890. */
  5891. close(): Path2;
  5892. /**
  5893. * Gets the sum of the distance between each sequential point in the path
  5894. * @returns the Path2 total length (float).
  5895. */
  5896. length(): number;
  5897. /**
  5898. * Gets the points which construct the path
  5899. * @returns the Path2 internal array of points.
  5900. */
  5901. getPoints(): Vector2[];
  5902. /**
  5903. * Retreives the point at the distance aways from the starting point
  5904. * @param normalizedLengthPosition the length along the path to retreive the point from
  5905. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5906. */
  5907. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5908. /**
  5909. * Creates a new path starting from an x and y position
  5910. * @param x starting x value
  5911. * @param y starting y value
  5912. * @returns a new Path2 starting at the coordinates (x, y).
  5913. */
  5914. static StartingAt(x: number, y: number): Path2;
  5915. }
  5916. /**
  5917. * Represents a 3D path made up of multiple 3D points
  5918. */
  5919. export class Path3D {
  5920. /**
  5921. * an array of Vector3, the curve axis of the Path3D
  5922. */
  5923. path: Vector3[];
  5924. private _curve;
  5925. private _distances;
  5926. private _tangents;
  5927. private _normals;
  5928. private _binormals;
  5929. private _raw;
  5930. /**
  5931. * new Path3D(path, normal, raw)
  5932. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5933. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5934. * @param path an array of Vector3, the curve axis of the Path3D
  5935. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5936. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5937. */
  5938. constructor(
  5939. /**
  5940. * an array of Vector3, the curve axis of the Path3D
  5941. */
  5942. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5943. /**
  5944. * Returns the Path3D array of successive Vector3 designing its curve.
  5945. * @returns the Path3D array of successive Vector3 designing its curve.
  5946. */
  5947. getCurve(): Vector3[];
  5948. /**
  5949. * Returns an array populated with tangent vectors on each Path3D curve point.
  5950. * @returns an array populated with tangent vectors on each Path3D curve point.
  5951. */
  5952. getTangents(): Vector3[];
  5953. /**
  5954. * Returns an array populated with normal vectors on each Path3D curve point.
  5955. * @returns an array populated with normal vectors on each Path3D curve point.
  5956. */
  5957. getNormals(): Vector3[];
  5958. /**
  5959. * Returns an array populated with binormal vectors on each Path3D curve point.
  5960. * @returns an array populated with binormal vectors on each Path3D curve point.
  5961. */
  5962. getBinormals(): Vector3[];
  5963. /**
  5964. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5965. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5966. */
  5967. getDistances(): number[];
  5968. /**
  5969. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5970. * @param path path which all values are copied into the curves points
  5971. * @param firstNormal which should be projected onto the curve
  5972. * @returns the same object updated.
  5973. */
  5974. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5975. private _compute;
  5976. private _getFirstNonNullVector;
  5977. private _getLastNonNullVector;
  5978. private _normalVector;
  5979. }
  5980. /**
  5981. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5982. * A Curve3 is designed from a series of successive Vector3.
  5983. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5984. */
  5985. export class Curve3 {
  5986. private _points;
  5987. private _length;
  5988. /**
  5989. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5990. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5991. * @param v1 (Vector3) the control point
  5992. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5993. * @param nbPoints (integer) the wanted number of points in the curve
  5994. * @returns the created Curve3
  5995. */
  5996. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5997. /**
  5998. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5999. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6000. * @param v1 (Vector3) the first control point
  6001. * @param v2 (Vector3) the second control point
  6002. * @param v3 (Vector3) the end point of the Cubic Bezier
  6003. * @param nbPoints (integer) the wanted number of points in the curve
  6004. * @returns the created Curve3
  6005. */
  6006. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6007. /**
  6008. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6009. * @param p1 (Vector3) the origin point of the Hermite Spline
  6010. * @param t1 (Vector3) the tangent vector at the origin point
  6011. * @param p2 (Vector3) the end point of the Hermite Spline
  6012. * @param t2 (Vector3) the tangent vector at the end point
  6013. * @param nbPoints (integer) the wanted number of points in the curve
  6014. * @returns the created Curve3
  6015. */
  6016. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6017. /**
  6018. * Returns a Curve3 object along a CatmullRom Spline curve :
  6019. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6020. * @param nbPoints (integer) the wanted number of points between each curve control points
  6021. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6022. * @returns the created Curve3
  6023. */
  6024. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6025. /**
  6026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6027. * A Curve3 is designed from a series of successive Vector3.
  6028. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6029. * @param points points which make up the curve
  6030. */
  6031. constructor(points: Vector3[]);
  6032. /**
  6033. * @returns the Curve3 stored array of successive Vector3
  6034. */
  6035. getPoints(): Vector3[];
  6036. /**
  6037. * @returns the computed length (float) of the curve.
  6038. */
  6039. length(): number;
  6040. /**
  6041. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6042. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6043. * curveA and curveB keep unchanged.
  6044. * @param curve the curve to continue from this curve
  6045. * @returns the newly constructed curve
  6046. */
  6047. continue(curve: DeepImmutable<Curve3>): Curve3;
  6048. private _computeLength;
  6049. }
  6050. }
  6051. declare module BABYLON {
  6052. /**
  6053. * This represents the main contract an easing function should follow.
  6054. * Easing functions are used throughout the animation system.
  6055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6056. */
  6057. export interface IEasingFunction {
  6058. /**
  6059. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6060. * of the easing function.
  6061. * The link below provides some of the most common examples of easing functions.
  6062. * @see https://easings.net/
  6063. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6064. * @returns the corresponding value on the curve defined by the easing function
  6065. */
  6066. ease(gradient: number): number;
  6067. }
  6068. /**
  6069. * Base class used for every default easing function.
  6070. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6071. */
  6072. export class EasingFunction implements IEasingFunction {
  6073. /**
  6074. * Interpolation follows the mathematical formula associated with the easing function.
  6075. */
  6076. static readonly EASINGMODE_EASEIN: number;
  6077. /**
  6078. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6079. */
  6080. static readonly EASINGMODE_EASEOUT: number;
  6081. /**
  6082. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6083. */
  6084. static readonly EASINGMODE_EASEINOUT: number;
  6085. private _easingMode;
  6086. /**
  6087. * Sets the easing mode of the current function.
  6088. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6089. */
  6090. setEasingMode(easingMode: number): void;
  6091. /**
  6092. * Gets the current easing mode.
  6093. * @returns the easing mode
  6094. */
  6095. getEasingMode(): number;
  6096. /**
  6097. * @hidden
  6098. */
  6099. easeInCore(gradient: number): number;
  6100. /**
  6101. * Given an input gradient between 0 and 1, this returns the corresponding value
  6102. * of the easing function.
  6103. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6104. * @returns the corresponding value on the curve defined by the easing function
  6105. */
  6106. ease(gradient: number): number;
  6107. }
  6108. /**
  6109. * Easing function with a circle shape (see link below).
  6110. * @see https://easings.net/#easeInCirc
  6111. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6112. */
  6113. export class CircleEase extends EasingFunction implements IEasingFunction {
  6114. /** @hidden */
  6115. easeInCore(gradient: number): number;
  6116. }
  6117. /**
  6118. * Easing function with a ease back shape (see link below).
  6119. * @see https://easings.net/#easeInBack
  6120. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6121. */
  6122. export class BackEase extends EasingFunction implements IEasingFunction {
  6123. /** Defines the amplitude of the function */
  6124. amplitude: number;
  6125. /**
  6126. * Instantiates a back ease easing
  6127. * @see https://easings.net/#easeInBack
  6128. * @param amplitude Defines the amplitude of the function
  6129. */
  6130. constructor(
  6131. /** Defines the amplitude of the function */
  6132. amplitude?: number);
  6133. /** @hidden */
  6134. easeInCore(gradient: number): number;
  6135. }
  6136. /**
  6137. * Easing function with a bouncing shape (see link below).
  6138. * @see https://easings.net/#easeInBounce
  6139. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6140. */
  6141. export class BounceEase extends EasingFunction implements IEasingFunction {
  6142. /** Defines the number of bounces */
  6143. bounces: number;
  6144. /** Defines the amplitude of the bounce */
  6145. bounciness: number;
  6146. /**
  6147. * Instantiates a bounce easing
  6148. * @see https://easings.net/#easeInBounce
  6149. * @param bounces Defines the number of bounces
  6150. * @param bounciness Defines the amplitude of the bounce
  6151. */
  6152. constructor(
  6153. /** Defines the number of bounces */
  6154. bounces?: number,
  6155. /** Defines the amplitude of the bounce */
  6156. bounciness?: number);
  6157. /** @hidden */
  6158. easeInCore(gradient: number): number;
  6159. }
  6160. /**
  6161. * Easing function with a power of 3 shape (see link below).
  6162. * @see https://easings.net/#easeInCubic
  6163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6164. */
  6165. export class CubicEase extends EasingFunction implements IEasingFunction {
  6166. /** @hidden */
  6167. easeInCore(gradient: number): number;
  6168. }
  6169. /**
  6170. * Easing function with an elastic shape (see link below).
  6171. * @see https://easings.net/#easeInElastic
  6172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6173. */
  6174. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6175. /** Defines the number of oscillations*/
  6176. oscillations: number;
  6177. /** Defines the amplitude of the oscillations*/
  6178. springiness: number;
  6179. /**
  6180. * Instantiates an elastic easing function
  6181. * @see https://easings.net/#easeInElastic
  6182. * @param oscillations Defines the number of oscillations
  6183. * @param springiness Defines the amplitude of the oscillations
  6184. */
  6185. constructor(
  6186. /** Defines the number of oscillations*/
  6187. oscillations?: number,
  6188. /** Defines the amplitude of the oscillations*/
  6189. springiness?: number);
  6190. /** @hidden */
  6191. easeInCore(gradient: number): number;
  6192. }
  6193. /**
  6194. * Easing function with an exponential shape (see link below).
  6195. * @see https://easings.net/#easeInExpo
  6196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6197. */
  6198. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6199. /** Defines the exponent of the function */
  6200. exponent: number;
  6201. /**
  6202. * Instantiates an exponential easing function
  6203. * @see https://easings.net/#easeInExpo
  6204. * @param exponent Defines the exponent of the function
  6205. */
  6206. constructor(
  6207. /** Defines the exponent of the function */
  6208. exponent?: number);
  6209. /** @hidden */
  6210. easeInCore(gradient: number): number;
  6211. }
  6212. /**
  6213. * Easing function with a power shape (see link below).
  6214. * @see https://easings.net/#easeInQuad
  6215. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6216. */
  6217. export class PowerEase extends EasingFunction implements IEasingFunction {
  6218. /** Defines the power of the function */
  6219. power: number;
  6220. /**
  6221. * Instantiates an power base easing function
  6222. * @see https://easings.net/#easeInQuad
  6223. * @param power Defines the power of the function
  6224. */
  6225. constructor(
  6226. /** Defines the power of the function */
  6227. power?: number);
  6228. /** @hidden */
  6229. easeInCore(gradient: number): number;
  6230. }
  6231. /**
  6232. * Easing function with a power of 2 shape (see link below).
  6233. * @see https://easings.net/#easeInQuad
  6234. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6235. */
  6236. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6237. /** @hidden */
  6238. easeInCore(gradient: number): number;
  6239. }
  6240. /**
  6241. * Easing function with a power of 4 shape (see link below).
  6242. * @see https://easings.net/#easeInQuart
  6243. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6244. */
  6245. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6246. /** @hidden */
  6247. easeInCore(gradient: number): number;
  6248. }
  6249. /**
  6250. * Easing function with a power of 5 shape (see link below).
  6251. * @see https://easings.net/#easeInQuint
  6252. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6253. */
  6254. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6255. /** @hidden */
  6256. easeInCore(gradient: number): number;
  6257. }
  6258. /**
  6259. * Easing function with a sin shape (see link below).
  6260. * @see https://easings.net/#easeInSine
  6261. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6262. */
  6263. export class SineEase extends EasingFunction implements IEasingFunction {
  6264. /** @hidden */
  6265. easeInCore(gradient: number): number;
  6266. }
  6267. /**
  6268. * Easing function with a bezier shape (see link below).
  6269. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6270. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6271. */
  6272. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6273. /** Defines the x component of the start tangent in the bezier curve */
  6274. x1: number;
  6275. /** Defines the y component of the start tangent in the bezier curve */
  6276. y1: number;
  6277. /** Defines the x component of the end tangent in the bezier curve */
  6278. x2: number;
  6279. /** Defines the y component of the end tangent in the bezier curve */
  6280. y2: number;
  6281. /**
  6282. * Instantiates a bezier function
  6283. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6284. * @param x1 Defines the x component of the start tangent in the bezier curve
  6285. * @param y1 Defines the y component of the start tangent in the bezier curve
  6286. * @param x2 Defines the x component of the end tangent in the bezier curve
  6287. * @param y2 Defines the y component of the end tangent in the bezier curve
  6288. */
  6289. constructor(
  6290. /** Defines the x component of the start tangent in the bezier curve */
  6291. x1?: number,
  6292. /** Defines the y component of the start tangent in the bezier curve */
  6293. y1?: number,
  6294. /** Defines the x component of the end tangent in the bezier curve */
  6295. x2?: number,
  6296. /** Defines the y component of the end tangent in the bezier curve */
  6297. y2?: number);
  6298. /** @hidden */
  6299. easeInCore(gradient: number): number;
  6300. }
  6301. }
  6302. declare module BABYLON {
  6303. /**
  6304. * Defines an interface which represents an animation key frame
  6305. */
  6306. export interface IAnimationKey {
  6307. /**
  6308. * Frame of the key frame
  6309. */
  6310. frame: number;
  6311. /**
  6312. * Value at the specifies key frame
  6313. */
  6314. value: any;
  6315. /**
  6316. * The input tangent for the cubic hermite spline
  6317. */
  6318. inTangent?: any;
  6319. /**
  6320. * The output tangent for the cubic hermite spline
  6321. */
  6322. outTangent?: any;
  6323. /**
  6324. * The animation interpolation type
  6325. */
  6326. interpolation?: AnimationKeyInterpolation;
  6327. }
  6328. /**
  6329. * Enum for the animation key frame interpolation type
  6330. */
  6331. export enum AnimationKeyInterpolation {
  6332. /**
  6333. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6334. */
  6335. STEP = 1
  6336. }
  6337. }
  6338. declare module BABYLON {
  6339. /**
  6340. * Represents the range of an animation
  6341. */
  6342. export class AnimationRange {
  6343. /**The name of the animation range**/
  6344. name: string;
  6345. /**The starting frame of the animation */
  6346. from: number;
  6347. /**The ending frame of the animation*/
  6348. to: number;
  6349. /**
  6350. * Initializes the range of an animation
  6351. * @param name The name of the animation range
  6352. * @param from The starting frame of the animation
  6353. * @param to The ending frame of the animation
  6354. */
  6355. constructor(
  6356. /**The name of the animation range**/
  6357. name: string,
  6358. /**The starting frame of the animation */
  6359. from: number,
  6360. /**The ending frame of the animation*/
  6361. to: number);
  6362. /**
  6363. * Makes a copy of the animation range
  6364. * @returns A copy of the animation range
  6365. */
  6366. clone(): AnimationRange;
  6367. }
  6368. }
  6369. declare module BABYLON {
  6370. /**
  6371. * Composed of a frame, and an action function
  6372. */
  6373. export class AnimationEvent {
  6374. /** The frame for which the event is triggered **/
  6375. frame: number;
  6376. /** The event to perform when triggered **/
  6377. action: (currentFrame: number) => void;
  6378. /** Specifies if the event should be triggered only once**/
  6379. onlyOnce?: boolean | undefined;
  6380. /**
  6381. * Specifies if the animation event is done
  6382. */
  6383. isDone: boolean;
  6384. /**
  6385. * Initializes the animation event
  6386. * @param frame The frame for which the event is triggered
  6387. * @param action The event to perform when triggered
  6388. * @param onlyOnce Specifies if the event should be triggered only once
  6389. */
  6390. constructor(
  6391. /** The frame for which the event is triggered **/
  6392. frame: number,
  6393. /** The event to perform when triggered **/
  6394. action: (currentFrame: number) => void,
  6395. /** Specifies if the event should be triggered only once**/
  6396. onlyOnce?: boolean | undefined);
  6397. /** @hidden */
  6398. _clone(): AnimationEvent;
  6399. }
  6400. }
  6401. declare module BABYLON {
  6402. /**
  6403. * Interface used to define a behavior
  6404. */
  6405. export interface Behavior<T> {
  6406. /** gets or sets behavior's name */
  6407. name: string;
  6408. /**
  6409. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6410. */
  6411. init(): void;
  6412. /**
  6413. * Called when the behavior is attached to a target
  6414. * @param target defines the target where the behavior is attached to
  6415. */
  6416. attach(target: T): void;
  6417. /**
  6418. * Called when the behavior is detached from its target
  6419. */
  6420. detach(): void;
  6421. }
  6422. /**
  6423. * Interface implemented by classes supporting behaviors
  6424. */
  6425. export interface IBehaviorAware<T> {
  6426. /**
  6427. * Attach a behavior
  6428. * @param behavior defines the behavior to attach
  6429. * @returns the current host
  6430. */
  6431. addBehavior(behavior: Behavior<T>): T;
  6432. /**
  6433. * Remove a behavior from the current object
  6434. * @param behavior defines the behavior to detach
  6435. * @returns the current host
  6436. */
  6437. removeBehavior(behavior: Behavior<T>): T;
  6438. /**
  6439. * Gets a behavior using its name to search
  6440. * @param name defines the name to search
  6441. * @returns the behavior or null if not found
  6442. */
  6443. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6444. }
  6445. }
  6446. declare module BABYLON {
  6447. /**
  6448. * Defines an array and its length.
  6449. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6450. */
  6451. export interface ISmartArrayLike<T> {
  6452. /**
  6453. * The data of the array.
  6454. */
  6455. data: Array<T>;
  6456. /**
  6457. * The active length of the array.
  6458. */
  6459. length: number;
  6460. }
  6461. /**
  6462. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6463. */
  6464. export class SmartArray<T> implements ISmartArrayLike<T> {
  6465. /**
  6466. * The full set of data from the array.
  6467. */
  6468. data: Array<T>;
  6469. /**
  6470. * The active length of the array.
  6471. */
  6472. length: number;
  6473. protected _id: number;
  6474. /**
  6475. * Instantiates a Smart Array.
  6476. * @param capacity defines the default capacity of the array.
  6477. */
  6478. constructor(capacity: number);
  6479. /**
  6480. * Pushes a value at the end of the active data.
  6481. * @param value defines the object to push in the array.
  6482. */
  6483. push(value: T): void;
  6484. /**
  6485. * Iterates over the active data and apply the lambda to them.
  6486. * @param func defines the action to apply on each value.
  6487. */
  6488. forEach(func: (content: T) => void): void;
  6489. /**
  6490. * Sorts the full sets of data.
  6491. * @param compareFn defines the comparison function to apply.
  6492. */
  6493. sort(compareFn: (a: T, b: T) => number): void;
  6494. /**
  6495. * Resets the active data to an empty array.
  6496. */
  6497. reset(): void;
  6498. /**
  6499. * Releases all the data from the array as well as the array.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Concats the active data with a given array.
  6504. * @param array defines the data to concatenate with.
  6505. */
  6506. concat(array: any): void;
  6507. /**
  6508. * Returns the position of a value in the active data.
  6509. * @param value defines the value to find the index for
  6510. * @returns the index if found in the active data otherwise -1
  6511. */
  6512. indexOf(value: T): number;
  6513. /**
  6514. * Returns whether an element is part of the active data.
  6515. * @param value defines the value to look for
  6516. * @returns true if found in the active data otherwise false
  6517. */
  6518. contains(value: T): boolean;
  6519. private static _GlobalId;
  6520. }
  6521. /**
  6522. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6523. * The data in this array can only be present once
  6524. */
  6525. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6526. private _duplicateId;
  6527. /**
  6528. * Pushes a value at the end of the active data.
  6529. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6530. * @param value defines the object to push in the array.
  6531. */
  6532. push(value: T): void;
  6533. /**
  6534. * Pushes a value at the end of the active data.
  6535. * If the data is already present, it won t be added again
  6536. * @param value defines the object to push in the array.
  6537. * @returns true if added false if it was already present
  6538. */
  6539. pushNoDuplicate(value: T): boolean;
  6540. /**
  6541. * Resets the active data to an empty array.
  6542. */
  6543. reset(): void;
  6544. /**
  6545. * Concats the active data with a given array.
  6546. * This ensures no dupplicate will be present in the result.
  6547. * @param array defines the data to concatenate with.
  6548. */
  6549. concatWithNoDuplicate(array: any): void;
  6550. }
  6551. }
  6552. declare module BABYLON {
  6553. /**
  6554. * @ignore
  6555. * This is a list of all the different input types that are available in the application.
  6556. * Fo instance: ArcRotateCameraGamepadInput...
  6557. */
  6558. export var CameraInputTypes: {};
  6559. /**
  6560. * This is the contract to implement in order to create a new input class.
  6561. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6562. */
  6563. export interface ICameraInput<TCamera extends Camera> {
  6564. /**
  6565. * Defines the camera the input is attached to.
  6566. */
  6567. camera: Nullable<TCamera>;
  6568. /**
  6569. * Gets the class name of the current intput.
  6570. * @returns the class name
  6571. */
  6572. getClassName(): string;
  6573. /**
  6574. * Get the friendly name associated with the input class.
  6575. * @returns the input friendly name
  6576. */
  6577. getSimpleName(): string;
  6578. /**
  6579. * Attach the input controls to a specific dom element to get the input from.
  6580. * @param element Defines the element the controls should be listened from
  6581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6582. */
  6583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6584. /**
  6585. * Detach the current controls from the specified dom element.
  6586. * @param element Defines the element to stop listening the inputs from
  6587. */
  6588. detachControl(element: Nullable<HTMLElement>): void;
  6589. /**
  6590. * Update the current camera state depending on the inputs that have been used this frame.
  6591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6592. */
  6593. checkInputs?: () => void;
  6594. }
  6595. /**
  6596. * Represents a map of input types to input instance or input index to input instance.
  6597. */
  6598. export interface CameraInputsMap<TCamera extends Camera> {
  6599. /**
  6600. * Accessor to the input by input type.
  6601. */
  6602. [name: string]: ICameraInput<TCamera>;
  6603. /**
  6604. * Accessor to the input by input index.
  6605. */
  6606. [idx: number]: ICameraInput<TCamera>;
  6607. }
  6608. /**
  6609. * This represents the input manager used within a camera.
  6610. * It helps dealing with all the different kind of input attached to a camera.
  6611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6612. */
  6613. export class CameraInputsManager<TCamera extends Camera> {
  6614. /**
  6615. * Defines the list of inputs attahed to the camera.
  6616. */
  6617. attached: CameraInputsMap<TCamera>;
  6618. /**
  6619. * Defines the dom element the camera is collecting inputs from.
  6620. * This is null if the controls have not been attached.
  6621. */
  6622. attachedElement: Nullable<HTMLElement>;
  6623. /**
  6624. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6625. */
  6626. noPreventDefault: boolean;
  6627. /**
  6628. * Defined the camera the input manager belongs to.
  6629. */
  6630. camera: TCamera;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs: () => void;
  6636. /**
  6637. * Instantiate a new Camera Input Manager.
  6638. * @param camera Defines the camera the input manager blongs to
  6639. */
  6640. constructor(camera: TCamera);
  6641. /**
  6642. * Add an input method to a camera
  6643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6644. * @param input camera input method
  6645. */
  6646. add(input: ICameraInput<TCamera>): void;
  6647. /**
  6648. * Remove a specific input method from a camera
  6649. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6650. * @param inputToRemove camera input method
  6651. */
  6652. remove(inputToRemove: ICameraInput<TCamera>): void;
  6653. /**
  6654. * Remove a specific input type from a camera
  6655. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6656. * @param inputType the type of the input to remove
  6657. */
  6658. removeByType(inputType: string): void;
  6659. private _addCheckInputs;
  6660. /**
  6661. * Attach the input controls to the currently attached dom element to listen the events from.
  6662. * @param input Defines the input to attach
  6663. */
  6664. attachInput(input: ICameraInput<TCamera>): void;
  6665. /**
  6666. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6667. * @param element Defines the dom element to collect the events from
  6668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6669. */
  6670. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6671. /**
  6672. * Detach the current manager inputs controls from a specific dom element.
  6673. * @param element Defines the dom element to collect the events from
  6674. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6675. */
  6676. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6677. /**
  6678. * Rebuild the dynamic inputCheck function from the current list of
  6679. * defined inputs in the manager.
  6680. */
  6681. rebuildInputCheck(): void;
  6682. /**
  6683. * Remove all attached input methods from a camera
  6684. */
  6685. clear(): void;
  6686. /**
  6687. * Serialize the current input manager attached to a camera.
  6688. * This ensures than once parsed,
  6689. * the input associated to the camera will be identical to the current ones
  6690. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6691. */
  6692. serialize(serializedCamera: any): void;
  6693. /**
  6694. * Parses an input manager serialized JSON to restore the previous list of inputs
  6695. * and states associated to a camera.
  6696. * @param parsedCamera Defines the JSON to parse
  6697. */
  6698. parse(parsedCamera: any): void;
  6699. }
  6700. }
  6701. declare module BABYLON {
  6702. /**
  6703. * @hidden
  6704. */
  6705. export class IntersectionInfo {
  6706. bu: Nullable<number>;
  6707. bv: Nullable<number>;
  6708. distance: number;
  6709. faceId: number;
  6710. subMeshId: number;
  6711. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6712. }
  6713. }
  6714. declare module BABYLON {
  6715. /**
  6716. * Represens a plane by the equation ax + by + cz + d = 0
  6717. */
  6718. export class Plane {
  6719. private static _TmpMatrix;
  6720. /**
  6721. * Normal of the plane (a,b,c)
  6722. */
  6723. normal: Vector3;
  6724. /**
  6725. * d component of the plane
  6726. */
  6727. d: number;
  6728. /**
  6729. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6730. * @param a a component of the plane
  6731. * @param b b component of the plane
  6732. * @param c c component of the plane
  6733. * @param d d component of the plane
  6734. */
  6735. constructor(a: number, b: number, c: number, d: number);
  6736. /**
  6737. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6738. */
  6739. asArray(): number[];
  6740. /**
  6741. * @returns a new plane copied from the current Plane.
  6742. */
  6743. clone(): Plane;
  6744. /**
  6745. * @returns the string "Plane".
  6746. */
  6747. getClassName(): string;
  6748. /**
  6749. * @returns the Plane hash code.
  6750. */
  6751. getHashCode(): number;
  6752. /**
  6753. * Normalize the current Plane in place.
  6754. * @returns the updated Plane.
  6755. */
  6756. normalize(): Plane;
  6757. /**
  6758. * Applies a transformation the plane and returns the result
  6759. * @param transformation the transformation matrix to be applied to the plane
  6760. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6761. */
  6762. transform(transformation: DeepImmutable<Matrix>): Plane;
  6763. /**
  6764. * Calcualtte the dot product between the point and the plane normal
  6765. * @param point point to calculate the dot product with
  6766. * @returns the dot product (float) of the point coordinates and the plane normal.
  6767. */
  6768. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6769. /**
  6770. * Updates the current Plane from the plane defined by the three given points.
  6771. * @param point1 one of the points used to contruct the plane
  6772. * @param point2 one of the points used to contruct the plane
  6773. * @param point3 one of the points used to contruct the plane
  6774. * @returns the updated Plane.
  6775. */
  6776. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6777. /**
  6778. * Checks if the plane is facing a given direction
  6779. * @param direction the direction to check if the plane is facing
  6780. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6781. * @returns True is the vector "direction" is the same side than the plane normal.
  6782. */
  6783. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6784. /**
  6785. * Calculates the distance to a point
  6786. * @param point point to calculate distance to
  6787. * @returns the signed distance (float) from the given point to the Plane.
  6788. */
  6789. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6790. /**
  6791. * Creates a plane from an array
  6792. * @param array the array to create a plane from
  6793. * @returns a new Plane from the given array.
  6794. */
  6795. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6796. /**
  6797. * Creates a plane from three points
  6798. * @param point1 point used to create the plane
  6799. * @param point2 point used to create the plane
  6800. * @param point3 point used to create the plane
  6801. * @returns a new Plane defined by the three given points.
  6802. */
  6803. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6804. /**
  6805. * Creates a plane from an origin point and a normal
  6806. * @param origin origin of the plane to be constructed
  6807. * @param normal normal of the plane to be constructed
  6808. * @returns a new Plane the normal vector to this plane at the given origin point.
  6809. * Note : the vector "normal" is updated because normalized.
  6810. */
  6811. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6812. /**
  6813. * Calculates the distance from a plane and a point
  6814. * @param origin origin of the plane to be constructed
  6815. * @param normal normal of the plane to be constructed
  6816. * @param point point to calculate distance to
  6817. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6818. */
  6819. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6820. }
  6821. }
  6822. declare module BABYLON {
  6823. /**
  6824. * Class used to store bounding sphere information
  6825. */
  6826. export class BoundingSphere {
  6827. /**
  6828. * Gets the center of the bounding sphere in local space
  6829. */
  6830. readonly center: Vector3;
  6831. /**
  6832. * Radius of the bounding sphere in local space
  6833. */
  6834. radius: number;
  6835. /**
  6836. * Gets the center of the bounding sphere in world space
  6837. */
  6838. readonly centerWorld: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in world space
  6841. */
  6842. radiusWorld: number;
  6843. /**
  6844. * Gets the minimum vector in local space
  6845. */
  6846. readonly minimum: Vector3;
  6847. /**
  6848. * Gets the maximum vector in local space
  6849. */
  6850. readonly maximum: Vector3;
  6851. private _worldMatrix;
  6852. private static readonly TmpVector3;
  6853. /**
  6854. * Creates a new bounding sphere
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding sphere by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingSphere;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding sphere is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding sphere center is in between the frustum planes.
  6888. * Used for optimistic fast inclusion.
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @returns true if the sphere center is in between the frustum planes
  6891. */
  6892. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if a point is inside the bounding sphere
  6895. * @param point defines the point to test
  6896. * @returns true if the point is inside the bounding sphere
  6897. */
  6898. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6899. /**
  6900. * Checks if two sphere intersct
  6901. * @param sphere0 sphere 0
  6902. * @param sphere1 sphere 1
  6903. * @returns true if the speres intersect
  6904. */
  6905. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Class used to store bounding box information
  6911. */
  6912. export class BoundingBox implements ICullable {
  6913. /**
  6914. * Gets the 8 vectors representing the bounding box in local space
  6915. */
  6916. readonly vectors: Vector3[];
  6917. /**
  6918. * Gets the center of the bounding box in local space
  6919. */
  6920. readonly center: Vector3;
  6921. /**
  6922. * Gets the center of the bounding box in world space
  6923. */
  6924. readonly centerWorld: Vector3;
  6925. /**
  6926. * Gets the extend size in local space
  6927. */
  6928. readonly extendSize: Vector3;
  6929. /**
  6930. * Gets the extend size in world space
  6931. */
  6932. readonly extendSizeWorld: Vector3;
  6933. /**
  6934. * Gets the OBB (object bounding box) directions
  6935. */
  6936. readonly directions: Vector3[];
  6937. /**
  6938. * Gets the 8 vectors representing the bounding box in world space
  6939. */
  6940. readonly vectorsWorld: Vector3[];
  6941. /**
  6942. * Gets the minimum vector in world space
  6943. */
  6944. readonly minimumWorld: Vector3;
  6945. /**
  6946. * Gets the maximum vector in world space
  6947. */
  6948. readonly maximumWorld: Vector3;
  6949. /**
  6950. * Gets the minimum vector in local space
  6951. */
  6952. readonly minimum: Vector3;
  6953. /**
  6954. * Gets the maximum vector in local space
  6955. */
  6956. readonly maximum: Vector3;
  6957. private _worldMatrix;
  6958. private static readonly TmpVector3;
  6959. /**
  6960. * @hidden
  6961. */
  6962. _tag: number;
  6963. /**
  6964. * Creates a new bounding box
  6965. * @param min defines the minimum vector (in local space)
  6966. * @param max defines the maximum vector (in local space)
  6967. * @param worldMatrix defines the new world matrix
  6968. */
  6969. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6970. /**
  6971. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6972. * @param min defines the new minimum vector (in local space)
  6973. * @param max defines the new maximum vector (in local space)
  6974. * @param worldMatrix defines the new world matrix
  6975. */
  6976. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6977. /**
  6978. * Scale the current bounding box by applying a scale factor
  6979. * @param factor defines the scale factor to apply
  6980. * @returns the current bounding box
  6981. */
  6982. scale(factor: number): BoundingBox;
  6983. /**
  6984. * Gets the world matrix of the bounding box
  6985. * @returns a matrix
  6986. */
  6987. getWorldMatrix(): DeepImmutable<Matrix>;
  6988. /** @hidden */
  6989. _update(world: DeepImmutable<Matrix>): void;
  6990. /**
  6991. * Tests if the bounding box is intersecting the frustum planes
  6992. * @param frustumPlanes defines the frustum planes to test
  6993. * @returns true if there is an intersection
  6994. */
  6995. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6996. /**
  6997. * Tests if the bounding box is entirely inside the frustum planes
  6998. * @param frustumPlanes defines the frustum planes to test
  6999. * @returns true if there is an inclusion
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /**
  7003. * Tests if a point is inside the bounding box
  7004. * @param point defines the point to test
  7005. * @returns true if the point is inside the bounding box
  7006. */
  7007. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7008. /**
  7009. * Tests if the bounding box intersects with a bounding sphere
  7010. * @param sphere defines the sphere to test
  7011. * @returns true if there is an intersection
  7012. */
  7013. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7014. /**
  7015. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7016. * @param min defines the min vector to use
  7017. * @param max defines the max vector to use
  7018. * @returns true if there is an intersection
  7019. */
  7020. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7021. /**
  7022. * Tests if two bounding boxes are intersections
  7023. * @param box0 defines the first box to test
  7024. * @param box1 defines the second box to test
  7025. * @returns true if there is an intersection
  7026. */
  7027. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7028. /**
  7029. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7030. * @param minPoint defines the minimum vector of the bounding box
  7031. * @param maxPoint defines the maximum vector of the bounding box
  7032. * @param sphereCenter defines the sphere center
  7033. * @param sphereRadius defines the sphere radius
  7034. * @returns true if there is an intersection
  7035. */
  7036. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7037. /**
  7038. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7039. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7040. * @param frustumPlanes defines the frustum planes to test
  7041. * @return true if there is an inclusion
  7042. */
  7043. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7044. /**
  7045. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7046. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7047. * @param frustumPlanes defines the frustum planes to test
  7048. * @return true if there is an intersection
  7049. */
  7050. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7051. }
  7052. }
  7053. declare module BABYLON {
  7054. /** @hidden */
  7055. export class Collider {
  7056. /** Define if a collision was found */
  7057. collisionFound: boolean;
  7058. /**
  7059. * Define last intersection point in local space
  7060. */
  7061. intersectionPoint: Vector3;
  7062. /**
  7063. * Define last collided mesh
  7064. */
  7065. collidedMesh: Nullable<AbstractMesh>;
  7066. private _collisionPoint;
  7067. private _planeIntersectionPoint;
  7068. private _tempVector;
  7069. private _tempVector2;
  7070. private _tempVector3;
  7071. private _tempVector4;
  7072. private _edge;
  7073. private _baseToVertex;
  7074. private _destinationPoint;
  7075. private _slidePlaneNormal;
  7076. private _displacementVector;
  7077. /** @hidden */
  7078. _radius: Vector3;
  7079. /** @hidden */
  7080. _retry: number;
  7081. private _velocity;
  7082. private _basePoint;
  7083. private _epsilon;
  7084. /** @hidden */
  7085. _velocityWorldLength: number;
  7086. /** @hidden */
  7087. _basePointWorld: Vector3;
  7088. private _velocityWorld;
  7089. private _normalizedVelocity;
  7090. /** @hidden */
  7091. _initialVelocity: Vector3;
  7092. /** @hidden */
  7093. _initialPosition: Vector3;
  7094. private _nearestDistance;
  7095. private _collisionMask;
  7096. collisionMask: number;
  7097. /**
  7098. * Gets the plane normal used to compute the sliding response (in local space)
  7099. */
  7100. readonly slidePlaneNormal: Vector3;
  7101. /** @hidden */
  7102. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7103. /** @hidden */
  7104. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7105. /** @hidden */
  7106. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7107. /** @hidden */
  7108. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7109. /** @hidden */
  7110. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7111. /** @hidden */
  7112. _getResponse(pos: Vector3, vel: Vector3): void;
  7113. }
  7114. }
  7115. declare module BABYLON {
  7116. /**
  7117. * Interface for cullable objects
  7118. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7119. */
  7120. export interface ICullable {
  7121. /**
  7122. * Checks if the object or part of the object is in the frustum
  7123. * @param frustumPlanes Camera near/planes
  7124. * @returns true if the object is in frustum otherwise false
  7125. */
  7126. isInFrustum(frustumPlanes: Plane[]): boolean;
  7127. /**
  7128. * Checks if a cullable object (mesh...) is in the camera frustum
  7129. * Unlike isInFrustum this cheks the full bounding box
  7130. * @param frustumPlanes Camera near/planes
  7131. * @returns true if the object is in frustum otherwise false
  7132. */
  7133. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7134. }
  7135. /**
  7136. * Info for a bounding data of a mesh
  7137. */
  7138. export class BoundingInfo implements ICullable {
  7139. /**
  7140. * Bounding box for the mesh
  7141. */
  7142. readonly boundingBox: BoundingBox;
  7143. /**
  7144. * Bounding sphere for the mesh
  7145. */
  7146. readonly boundingSphere: BoundingSphere;
  7147. private _isLocked;
  7148. private static readonly TmpVector3;
  7149. /**
  7150. * Constructs bounding info
  7151. * @param minimum min vector of the bounding box/sphere
  7152. * @param maximum max vector of the bounding box/sphere
  7153. * @param worldMatrix defines the new world matrix
  7154. */
  7155. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7156. /**
  7157. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7158. * @param min defines the new minimum vector (in local space)
  7159. * @param max defines the new maximum vector (in local space)
  7160. * @param worldMatrix defines the new world matrix
  7161. */
  7162. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7163. /**
  7164. * min vector of the bounding box/sphere
  7165. */
  7166. readonly minimum: Vector3;
  7167. /**
  7168. * max vector of the bounding box/sphere
  7169. */
  7170. readonly maximum: Vector3;
  7171. /**
  7172. * If the info is locked and won't be updated to avoid perf overhead
  7173. */
  7174. isLocked: boolean;
  7175. /**
  7176. * Updates the bounding sphere and box
  7177. * @param world world matrix to be used to update
  7178. */
  7179. update(world: DeepImmutable<Matrix>): void;
  7180. /**
  7181. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7182. * @param center New center of the bounding info
  7183. * @param extend New extend of the bounding info
  7184. * @returns the current bounding info
  7185. */
  7186. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7187. /**
  7188. * Scale the current bounding info by applying a scale factor
  7189. * @param factor defines the scale factor to apply
  7190. * @returns the current bounding info
  7191. */
  7192. scale(factor: number): BoundingInfo;
  7193. /**
  7194. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7195. * @param frustumPlanes defines the frustum to test
  7196. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7197. * @returns true if the bounding info is in the frustum planes
  7198. */
  7199. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7200. /**
  7201. * Gets the world distance between the min and max points of the bounding box
  7202. */
  7203. readonly diagonalLength: number;
  7204. /**
  7205. * Checks if a cullable object (mesh...) is in the camera frustum
  7206. * Unlike isInFrustum this cheks the full bounding box
  7207. * @param frustumPlanes Camera near/planes
  7208. * @returns true if the object is in frustum otherwise false
  7209. */
  7210. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7211. /** @hidden */
  7212. _checkCollision(collider: Collider): boolean;
  7213. /**
  7214. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7215. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7216. * @param point the point to check intersection with
  7217. * @returns if the point intersects
  7218. */
  7219. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7220. /**
  7221. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7222. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7223. * @param boundingInfo the bounding info to check intersection with
  7224. * @param precise if the intersection should be done using OBB
  7225. * @returns if the bounding info intersects
  7226. */
  7227. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7228. }
  7229. }
  7230. declare module BABYLON {
  7231. /**
  7232. * Extracts minimum and maximum values from a list of indexed positions
  7233. * @param positions defines the positions to use
  7234. * @param indices defines the indices to the positions
  7235. * @param indexStart defines the start index
  7236. * @param indexCount defines the end index
  7237. * @param bias defines bias value to add to the result
  7238. * @return minimum and maximum values
  7239. */
  7240. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7241. minimum: Vector3;
  7242. maximum: Vector3;
  7243. };
  7244. /**
  7245. * Extracts minimum and maximum values from a list of positions
  7246. * @param positions defines the positions to use
  7247. * @param start defines the start index in the positions array
  7248. * @param count defines the number of positions to handle
  7249. * @param bias defines bias value to add to the result
  7250. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7251. * @return minimum and maximum values
  7252. */
  7253. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7254. minimum: Vector3;
  7255. maximum: Vector3;
  7256. };
  7257. }
  7258. declare module BABYLON {
  7259. /**
  7260. * Enum that determines the text-wrapping mode to use.
  7261. */
  7262. export enum InspectableType {
  7263. /**
  7264. * Checkbox for booleans
  7265. */
  7266. Checkbox = 0,
  7267. /**
  7268. * Sliders for numbers
  7269. */
  7270. Slider = 1,
  7271. /**
  7272. * Vector3
  7273. */
  7274. Vector3 = 2,
  7275. /**
  7276. * Quaternions
  7277. */
  7278. Quaternion = 3,
  7279. /**
  7280. * Color3
  7281. */
  7282. Color3 = 4,
  7283. /**
  7284. * String
  7285. */
  7286. String = 5
  7287. }
  7288. /**
  7289. * Interface used to define custom inspectable properties.
  7290. * This interface is used by the inspector to display custom property grids
  7291. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7292. */
  7293. export interface IInspectable {
  7294. /**
  7295. * Gets the label to display
  7296. */
  7297. label: string;
  7298. /**
  7299. * Gets the name of the property to edit
  7300. */
  7301. propertyName: string;
  7302. /**
  7303. * Gets the type of the editor to use
  7304. */
  7305. type: InspectableType;
  7306. /**
  7307. * Gets the minimum value of the property when using in "slider" mode
  7308. */
  7309. min?: number;
  7310. /**
  7311. * Gets the maximum value of the property when using in "slider" mode
  7312. */
  7313. max?: number;
  7314. /**
  7315. * Gets the setp to use when using in "slider" mode
  7316. */
  7317. step?: number;
  7318. }
  7319. }
  7320. declare module BABYLON {
  7321. /**
  7322. * Class used to provide helper for timing
  7323. */
  7324. export class TimingTools {
  7325. /**
  7326. * Polyfill for setImmediate
  7327. * @param action defines the action to execute after the current execution block
  7328. */
  7329. static SetImmediate(action: () => void): void;
  7330. }
  7331. }
  7332. declare module BABYLON {
  7333. /**
  7334. * Class used to enable instatition of objects by class name
  7335. */
  7336. export class InstantiationTools {
  7337. /**
  7338. * Use this object to register external classes like custom textures or material
  7339. * to allow the laoders to instantiate them
  7340. */
  7341. static RegisteredExternalClasses: {
  7342. [key: string]: Object;
  7343. };
  7344. /**
  7345. * Tries to instantiate a new object from a given class name
  7346. * @param className defines the class name to instantiate
  7347. * @returns the new object or null if the system was not able to do the instantiation
  7348. */
  7349. static Instantiate(className: string): any;
  7350. }
  7351. }
  7352. declare module BABYLON {
  7353. /**
  7354. * This represents the required contract to create a new type of texture loader.
  7355. */
  7356. export interface IInternalTextureLoader {
  7357. /**
  7358. * Defines wether the loader supports cascade loading the different faces.
  7359. */
  7360. supportCascades: boolean;
  7361. /**
  7362. * This returns if the loader support the current file information.
  7363. * @param extension defines the file extension of the file being loaded
  7364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7365. * @param fallback defines the fallback internal texture if any
  7366. * @param isBase64 defines whether the texture is encoded as a base64
  7367. * @param isBuffer defines whether the texture data are stored as a buffer
  7368. * @returns true if the loader can load the specified file
  7369. */
  7370. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7371. /**
  7372. * Transform the url before loading if required.
  7373. * @param rootUrl the url of the texture
  7374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7375. * @returns the transformed texture
  7376. */
  7377. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7378. /**
  7379. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7380. * @param rootUrl the url of the texture
  7381. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7382. * @returns the fallback texture
  7383. */
  7384. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7385. /**
  7386. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7387. * @param data contains the texture data
  7388. * @param texture defines the BabylonJS internal texture
  7389. * @param createPolynomials will be true if polynomials have been requested
  7390. * @param onLoad defines the callback to trigger once the texture is ready
  7391. * @param onError defines the callback to trigger in case of error
  7392. */
  7393. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7394. /**
  7395. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7396. * @param data contains the texture data
  7397. * @param texture defines the BabylonJS internal texture
  7398. * @param callback defines the method to call once ready to upload
  7399. */
  7400. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7401. }
  7402. }
  7403. declare module BABYLON {
  7404. interface Engine {
  7405. /**
  7406. * Creates a depth stencil cube texture.
  7407. * This is only available in WebGL 2.
  7408. * @param size The size of face edge in the cube texture.
  7409. * @param options The options defining the cube texture.
  7410. * @returns The cube texture
  7411. */
  7412. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7413. /**
  7414. * Creates a cube texture
  7415. * @param rootUrl defines the url where the files to load is located
  7416. * @param scene defines the current scene
  7417. * @param files defines the list of files to load (1 per face)
  7418. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7419. * @param onLoad defines an optional callback raised when the texture is loaded
  7420. * @param onError defines an optional callback raised if there is an issue to load the texture
  7421. * @param format defines the format of the data
  7422. * @param forcedExtension defines the extension to use to pick the right loader
  7423. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7424. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7425. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7426. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7427. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7428. * @returns the cube texture as an InternalTexture
  7429. */
  7430. 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;
  7431. /**
  7432. * Creates a cube texture
  7433. * @param rootUrl defines the url where the files to load is located
  7434. * @param scene defines the current scene
  7435. * @param files defines the list of files to load (1 per face)
  7436. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7437. * @param onLoad defines an optional callback raised when the texture is loaded
  7438. * @param onError defines an optional callback raised if there is an issue to load the texture
  7439. * @param format defines the format of the data
  7440. * @param forcedExtension defines the extension to use to pick the right loader
  7441. * @returns the cube texture as an InternalTexture
  7442. */
  7443. 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;
  7444. /**
  7445. * Creates a cube texture
  7446. * @param rootUrl defines the url where the files to load is located
  7447. * @param scene defines the current scene
  7448. * @param files defines the list of files to load (1 per face)
  7449. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7450. * @param onLoad defines an optional callback raised when the texture is loaded
  7451. * @param onError defines an optional callback raised if there is an issue to load the texture
  7452. * @param format defines the format of the data
  7453. * @param forcedExtension defines the extension to use to pick the right loader
  7454. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7455. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7456. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7457. * @returns the cube texture as an InternalTexture
  7458. */
  7459. 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;
  7460. /** @hidden */
  7461. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7462. /** @hidden */
  7463. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7464. /** @hidden */
  7465. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7466. /** @hidden */
  7467. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7468. }
  7469. }
  7470. declare module BABYLON {
  7471. /**
  7472. * Class for creating a cube texture
  7473. */
  7474. export class CubeTexture extends BaseTexture {
  7475. private _delayedOnLoad;
  7476. /**
  7477. * The url of the texture
  7478. */
  7479. url: string;
  7480. /**
  7481. * Gets or sets the center of the bounding box associated with the cube texture.
  7482. * It must define where the camera used to render the texture was set
  7483. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7484. */
  7485. boundingBoxPosition: Vector3;
  7486. private _boundingBoxSize;
  7487. /**
  7488. * Gets or sets the size of the bounding box associated with the cube texture
  7489. * When defined, the cubemap will switch to local mode
  7490. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7491. * @example https://www.babylonjs-playground.com/#RNASML
  7492. */
  7493. /**
  7494. * Returns the bounding box size
  7495. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7496. */
  7497. boundingBoxSize: Vector3;
  7498. protected _rotationY: number;
  7499. /**
  7500. * Sets texture matrix rotation angle around Y axis in radians.
  7501. */
  7502. /**
  7503. * Gets texture matrix rotation angle around Y axis radians.
  7504. */
  7505. rotationY: number;
  7506. /**
  7507. * Are mip maps generated for this texture or not.
  7508. */
  7509. readonly noMipmap: boolean;
  7510. private _noMipmap;
  7511. private _files;
  7512. private _extensions;
  7513. private _textureMatrix;
  7514. private _format;
  7515. private _createPolynomials;
  7516. /** @hidden */
  7517. _prefiltered: boolean;
  7518. /**
  7519. * Creates a cube texture from an array of image urls
  7520. * @param files defines an array of image urls
  7521. * @param scene defines the hosting scene
  7522. * @param noMipmap specifies if mip maps are not used
  7523. * @returns a cube texture
  7524. */
  7525. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7526. /**
  7527. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7528. * @param url defines the url of the prefiltered texture
  7529. * @param scene defines the scene the texture is attached to
  7530. * @param forcedExtension defines the extension of the file if different from the url
  7531. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7532. * @return the prefiltered texture
  7533. */
  7534. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7535. /**
  7536. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7537. * as prefiltered data.
  7538. * @param rootUrl defines the url of the texture or the root name of the six images
  7539. * @param scene defines the scene the texture is attached to
  7540. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7541. * @param noMipmap defines if mipmaps should be created or not
  7542. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7543. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7544. * @param onError defines a callback triggered in case of error during load
  7545. * @param format defines the internal format to use for the texture once loaded
  7546. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7547. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7548. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7549. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7550. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7551. * @return the cube texture
  7552. */
  7553. 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);
  7554. /**
  7555. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7556. */
  7557. readonly isPrefiltered: boolean;
  7558. /**
  7559. * Get the current class name of the texture useful for serialization or dynamic coding.
  7560. * @returns "CubeTexture"
  7561. */
  7562. getClassName(): string;
  7563. /**
  7564. * Update the url (and optional buffer) of this texture if url was null during construction.
  7565. * @param url the url of the texture
  7566. * @param forcedExtension defines the extension to use
  7567. * @param onLoad callback called when the texture is loaded (defaults to null)
  7568. */
  7569. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7570. /**
  7571. * Delays loading of the cube texture
  7572. * @param forcedExtension defines the extension to use
  7573. */
  7574. delayLoad(forcedExtension?: string): void;
  7575. /**
  7576. * Returns the reflection texture matrix
  7577. * @returns the reflection texture matrix
  7578. */
  7579. getReflectionTextureMatrix(): Matrix;
  7580. /**
  7581. * Sets the reflection texture matrix
  7582. * @param value Reflection texture matrix
  7583. */
  7584. setReflectionTextureMatrix(value: Matrix): void;
  7585. /**
  7586. * Parses text to create a cube texture
  7587. * @param parsedTexture define the serialized text to read from
  7588. * @param scene defines the hosting scene
  7589. * @param rootUrl defines the root url of the cube texture
  7590. * @returns a cube texture
  7591. */
  7592. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7593. /**
  7594. * Makes a clone, or deep copy, of the cube texture
  7595. * @returns a new cube texture
  7596. */
  7597. clone(): CubeTexture;
  7598. }
  7599. }
  7600. declare module BABYLON {
  7601. /**
  7602. * Manages the defines for the Material
  7603. */
  7604. export class MaterialDefines {
  7605. /** @hidden */
  7606. protected _keys: string[];
  7607. private _isDirty;
  7608. /** @hidden */
  7609. _renderId: number;
  7610. /** @hidden */
  7611. _areLightsDirty: boolean;
  7612. /** @hidden */
  7613. _areAttributesDirty: boolean;
  7614. /** @hidden */
  7615. _areTexturesDirty: boolean;
  7616. /** @hidden */
  7617. _areFresnelDirty: boolean;
  7618. /** @hidden */
  7619. _areMiscDirty: boolean;
  7620. /** @hidden */
  7621. _areImageProcessingDirty: boolean;
  7622. /** @hidden */
  7623. _normals: boolean;
  7624. /** @hidden */
  7625. _uvs: boolean;
  7626. /** @hidden */
  7627. _needNormals: boolean;
  7628. /** @hidden */
  7629. _needUVs: boolean;
  7630. [id: string]: any;
  7631. /**
  7632. * Specifies if the material needs to be re-calculated
  7633. */
  7634. readonly isDirty: boolean;
  7635. /**
  7636. * Marks the material to indicate that it has been re-calculated
  7637. */
  7638. markAsProcessed(): void;
  7639. /**
  7640. * Marks the material to indicate that it needs to be re-calculated
  7641. */
  7642. markAsUnprocessed(): void;
  7643. /**
  7644. * Marks the material to indicate all of its defines need to be re-calculated
  7645. */
  7646. markAllAsDirty(): void;
  7647. /**
  7648. * Marks the material to indicate that image processing needs to be re-calculated
  7649. */
  7650. markAsImageProcessingDirty(): void;
  7651. /**
  7652. * Marks the material to indicate the lights need to be re-calculated
  7653. */
  7654. markAsLightDirty(): void;
  7655. /**
  7656. * Marks the attribute state as changed
  7657. */
  7658. markAsAttributesDirty(): void;
  7659. /**
  7660. * Marks the texture state as changed
  7661. */
  7662. markAsTexturesDirty(): void;
  7663. /**
  7664. * Marks the fresnel state as changed
  7665. */
  7666. markAsFresnelDirty(): void;
  7667. /**
  7668. * Marks the misc state as changed
  7669. */
  7670. markAsMiscDirty(): void;
  7671. /**
  7672. * Rebuilds the material defines
  7673. */
  7674. rebuild(): void;
  7675. /**
  7676. * Specifies if two material defines are equal
  7677. * @param other - A material define instance to compare to
  7678. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7679. */
  7680. isEqual(other: MaterialDefines): boolean;
  7681. /**
  7682. * Clones this instance's defines to another instance
  7683. * @param other - material defines to clone values to
  7684. */
  7685. cloneTo(other: MaterialDefines): void;
  7686. /**
  7687. * Resets the material define values
  7688. */
  7689. reset(): void;
  7690. /**
  7691. * Converts the material define values to a string
  7692. * @returns - String of material define information
  7693. */
  7694. toString(): string;
  7695. }
  7696. }
  7697. declare module BABYLON {
  7698. /**
  7699. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7700. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7701. * 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;
  7702. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7703. */
  7704. export class ColorCurves {
  7705. private _dirty;
  7706. private _tempColor;
  7707. private _globalCurve;
  7708. private _highlightsCurve;
  7709. private _midtonesCurve;
  7710. private _shadowsCurve;
  7711. private _positiveCurve;
  7712. private _negativeCurve;
  7713. private _globalHue;
  7714. private _globalDensity;
  7715. private _globalSaturation;
  7716. private _globalExposure;
  7717. /**
  7718. * Gets the global Hue value.
  7719. * 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).
  7720. */
  7721. /**
  7722. * Sets the global Hue value.
  7723. * 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).
  7724. */
  7725. globalHue: number;
  7726. /**
  7727. * Gets the global Density value.
  7728. * 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.
  7729. * Values less than zero provide a filter of opposite hue.
  7730. */
  7731. /**
  7732. * Sets the global Density value.
  7733. * 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.
  7734. * Values less than zero provide a filter of opposite hue.
  7735. */
  7736. globalDensity: number;
  7737. /**
  7738. * Gets the global Saturation value.
  7739. * 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.
  7740. */
  7741. /**
  7742. * Sets the global Saturation value.
  7743. * 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.
  7744. */
  7745. globalSaturation: number;
  7746. /**
  7747. * Gets the global Exposure value.
  7748. * 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.
  7749. */
  7750. /**
  7751. * Sets the global Exposure value.
  7752. * 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.
  7753. */
  7754. globalExposure: number;
  7755. private _highlightsHue;
  7756. private _highlightsDensity;
  7757. private _highlightsSaturation;
  7758. private _highlightsExposure;
  7759. /**
  7760. * Gets the highlights Hue value.
  7761. * 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).
  7762. */
  7763. /**
  7764. * Sets the highlights Hue value.
  7765. * 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).
  7766. */
  7767. highlightsHue: number;
  7768. /**
  7769. * Gets the highlights Density value.
  7770. * 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.
  7771. * Values less than zero provide a filter of opposite hue.
  7772. */
  7773. /**
  7774. * Sets the highlights Density value.
  7775. * 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.
  7776. * Values less than zero provide a filter of opposite hue.
  7777. */
  7778. highlightsDensity: number;
  7779. /**
  7780. * Gets the highlights Saturation value.
  7781. * 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.
  7782. */
  7783. /**
  7784. * Sets the highlights Saturation value.
  7785. * 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.
  7786. */
  7787. highlightsSaturation: number;
  7788. /**
  7789. * Gets the highlights Exposure value.
  7790. * 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.
  7791. */
  7792. /**
  7793. * Sets the highlights Exposure value.
  7794. * 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.
  7795. */
  7796. highlightsExposure: number;
  7797. private _midtonesHue;
  7798. private _midtonesDensity;
  7799. private _midtonesSaturation;
  7800. private _midtonesExposure;
  7801. /**
  7802. * Gets the midtones Hue value.
  7803. * 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).
  7804. */
  7805. /**
  7806. * Sets the midtones Hue value.
  7807. * 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).
  7808. */
  7809. midtonesHue: number;
  7810. /**
  7811. * Gets the midtones Density value.
  7812. * 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.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. /**
  7816. * Sets the midtones Density value.
  7817. * 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.
  7818. * Values less than zero provide a filter of opposite hue.
  7819. */
  7820. midtonesDensity: number;
  7821. /**
  7822. * Gets the midtones Saturation value.
  7823. * 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.
  7824. */
  7825. /**
  7826. * Sets the midtones Saturation value.
  7827. * 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.
  7828. */
  7829. midtonesSaturation: number;
  7830. /**
  7831. * Gets the midtones Exposure value.
  7832. * 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.
  7833. */
  7834. /**
  7835. * Sets the midtones Exposure value.
  7836. * 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.
  7837. */
  7838. midtonesExposure: number;
  7839. private _shadowsHue;
  7840. private _shadowsDensity;
  7841. private _shadowsSaturation;
  7842. private _shadowsExposure;
  7843. /**
  7844. * Gets the shadows Hue value.
  7845. * 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).
  7846. */
  7847. /**
  7848. * Sets the shadows Hue value.
  7849. * 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).
  7850. */
  7851. shadowsHue: number;
  7852. /**
  7853. * Gets the shadows Density value.
  7854. * 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.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. /**
  7858. * Sets the shadows Density value.
  7859. * 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.
  7860. * Values less than zero provide a filter of opposite hue.
  7861. */
  7862. shadowsDensity: number;
  7863. /**
  7864. * Gets the shadows Saturation value.
  7865. * 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.
  7866. */
  7867. /**
  7868. * Sets the shadows Saturation value.
  7869. * 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.
  7870. */
  7871. shadowsSaturation: number;
  7872. /**
  7873. * Gets the shadows Exposure value.
  7874. * 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.
  7875. */
  7876. /**
  7877. * Sets the shadows Exposure value.
  7878. * 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.
  7879. */
  7880. shadowsExposure: number;
  7881. /**
  7882. * Returns the class name
  7883. * @returns The class name
  7884. */
  7885. getClassName(): string;
  7886. /**
  7887. * Binds the color curves to the shader.
  7888. * @param colorCurves The color curve to bind
  7889. * @param effect The effect to bind to
  7890. * @param positiveUniform The positive uniform shader parameter
  7891. * @param neutralUniform The neutral uniform shader parameter
  7892. * @param negativeUniform The negative uniform shader parameter
  7893. */
  7894. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7895. /**
  7896. * Prepare the list of uniforms associated with the ColorCurves effects.
  7897. * @param uniformsList The list of uniforms used in the effect
  7898. */
  7899. static PrepareUniforms(uniformsList: string[]): void;
  7900. /**
  7901. * Returns color grading data based on a hue, density, saturation and exposure value.
  7902. * @param filterHue The hue of the color filter.
  7903. * @param filterDensity The density of the color filter.
  7904. * @param saturation The saturation.
  7905. * @param exposure The exposure.
  7906. * @param result The result data container.
  7907. */
  7908. private getColorGradingDataToRef;
  7909. /**
  7910. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7911. * @param value The input slider value in range [-100,100].
  7912. * @returns Adjusted value.
  7913. */
  7914. private static applyColorGradingSliderNonlinear;
  7915. /**
  7916. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7917. * @param hue The hue (H) input.
  7918. * @param saturation The saturation (S) input.
  7919. * @param brightness The brightness (B) input.
  7920. * @result An RGBA color represented as Vector4.
  7921. */
  7922. private static fromHSBToRef;
  7923. /**
  7924. * Returns a value clamped between min and max
  7925. * @param value The value to clamp
  7926. * @param min The minimum of value
  7927. * @param max The maximum of value
  7928. * @returns The clamped value.
  7929. */
  7930. private static clamp;
  7931. /**
  7932. * Clones the current color curve instance.
  7933. * @return The cloned curves
  7934. */
  7935. clone(): ColorCurves;
  7936. /**
  7937. * Serializes the current color curve instance to a json representation.
  7938. * @return a JSON representation
  7939. */
  7940. serialize(): any;
  7941. /**
  7942. * Parses the color curve from a json representation.
  7943. * @param source the JSON source to parse
  7944. * @return The parsed curves
  7945. */
  7946. static Parse(source: any): ColorCurves;
  7947. }
  7948. }
  7949. declare module BABYLON {
  7950. /**
  7951. * Interface to follow in your material defines to integrate easily the
  7952. * Image proccessing functions.
  7953. * @hidden
  7954. */
  7955. export interface IImageProcessingConfigurationDefines {
  7956. IMAGEPROCESSING: boolean;
  7957. VIGNETTE: boolean;
  7958. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7959. VIGNETTEBLENDMODEOPAQUE: boolean;
  7960. TONEMAPPING: boolean;
  7961. TONEMAPPING_ACES: boolean;
  7962. CONTRAST: boolean;
  7963. EXPOSURE: boolean;
  7964. COLORCURVES: boolean;
  7965. COLORGRADING: boolean;
  7966. COLORGRADING3D: boolean;
  7967. SAMPLER3DGREENDEPTH: boolean;
  7968. SAMPLER3DBGRMAP: boolean;
  7969. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7970. }
  7971. /**
  7972. * @hidden
  7973. */
  7974. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7975. IMAGEPROCESSING: boolean;
  7976. VIGNETTE: boolean;
  7977. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7978. VIGNETTEBLENDMODEOPAQUE: boolean;
  7979. TONEMAPPING: boolean;
  7980. TONEMAPPING_ACES: boolean;
  7981. CONTRAST: boolean;
  7982. COLORCURVES: boolean;
  7983. COLORGRADING: boolean;
  7984. COLORGRADING3D: boolean;
  7985. SAMPLER3DGREENDEPTH: boolean;
  7986. SAMPLER3DBGRMAP: boolean;
  7987. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7988. EXPOSURE: boolean;
  7989. constructor();
  7990. }
  7991. /**
  7992. * This groups together the common properties used for image processing either in direct forward pass
  7993. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7994. * or not.
  7995. */
  7996. export class ImageProcessingConfiguration {
  7997. /**
  7998. * Default tone mapping applied in BabylonJS.
  7999. */
  8000. static readonly TONEMAPPING_STANDARD: number;
  8001. /**
  8002. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8003. * to other engines rendering to increase portability.
  8004. */
  8005. static readonly TONEMAPPING_ACES: number;
  8006. /**
  8007. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8008. */
  8009. colorCurves: Nullable<ColorCurves>;
  8010. private _colorCurvesEnabled;
  8011. /**
  8012. * Gets wether the color curves effect is enabled.
  8013. */
  8014. /**
  8015. * Sets wether the color curves effect is enabled.
  8016. */
  8017. colorCurvesEnabled: boolean;
  8018. private _colorGradingTexture;
  8019. /**
  8020. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8021. */
  8022. /**
  8023. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8024. */
  8025. colorGradingTexture: Nullable<BaseTexture>;
  8026. private _colorGradingEnabled;
  8027. /**
  8028. * Gets wether the color grading effect is enabled.
  8029. */
  8030. /**
  8031. * Sets wether the color grading effect is enabled.
  8032. */
  8033. colorGradingEnabled: boolean;
  8034. private _colorGradingWithGreenDepth;
  8035. /**
  8036. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8037. */
  8038. /**
  8039. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8040. */
  8041. colorGradingWithGreenDepth: boolean;
  8042. private _colorGradingBGR;
  8043. /**
  8044. * Gets wether the color grading texture contains BGR values.
  8045. */
  8046. /**
  8047. * Sets wether the color grading texture contains BGR values.
  8048. */
  8049. colorGradingBGR: boolean;
  8050. /** @hidden */
  8051. _exposure: number;
  8052. /**
  8053. * Gets the Exposure used in the effect.
  8054. */
  8055. /**
  8056. * Sets the Exposure used in the effect.
  8057. */
  8058. exposure: number;
  8059. private _toneMappingEnabled;
  8060. /**
  8061. * Gets wether the tone mapping effect is enabled.
  8062. */
  8063. /**
  8064. * Sets wether the tone mapping effect is enabled.
  8065. */
  8066. toneMappingEnabled: boolean;
  8067. private _toneMappingType;
  8068. /**
  8069. * Gets the type of tone mapping effect.
  8070. */
  8071. /**
  8072. * Sets the type of tone mapping effect used in BabylonJS.
  8073. */
  8074. toneMappingType: number;
  8075. protected _contrast: number;
  8076. /**
  8077. * Gets the contrast used in the effect.
  8078. */
  8079. /**
  8080. * Sets the contrast used in the effect.
  8081. */
  8082. contrast: number;
  8083. /**
  8084. * Vignette stretch size.
  8085. */
  8086. vignetteStretch: number;
  8087. /**
  8088. * Vignette centre X Offset.
  8089. */
  8090. vignetteCentreX: number;
  8091. /**
  8092. * Vignette centre Y Offset.
  8093. */
  8094. vignetteCentreY: number;
  8095. /**
  8096. * Vignette weight or intensity of the vignette effect.
  8097. */
  8098. vignetteWeight: number;
  8099. /**
  8100. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8101. * if vignetteEnabled is set to true.
  8102. */
  8103. vignetteColor: Color4;
  8104. /**
  8105. * Camera field of view used by the Vignette effect.
  8106. */
  8107. vignetteCameraFov: number;
  8108. private _vignetteBlendMode;
  8109. /**
  8110. * Gets the vignette blend mode allowing different kind of effect.
  8111. */
  8112. /**
  8113. * Sets the vignette blend mode allowing different kind of effect.
  8114. */
  8115. vignetteBlendMode: number;
  8116. private _vignetteEnabled;
  8117. /**
  8118. * Gets wether the vignette effect is enabled.
  8119. */
  8120. /**
  8121. * Sets wether the vignette effect is enabled.
  8122. */
  8123. vignetteEnabled: boolean;
  8124. private _applyByPostProcess;
  8125. /**
  8126. * Gets wether the image processing is applied through a post process or not.
  8127. */
  8128. /**
  8129. * Sets wether the image processing is applied through a post process or not.
  8130. */
  8131. applyByPostProcess: boolean;
  8132. private _isEnabled;
  8133. /**
  8134. * Gets wether the image processing is enabled or not.
  8135. */
  8136. /**
  8137. * Sets wether the image processing is enabled or not.
  8138. */
  8139. isEnabled: boolean;
  8140. /**
  8141. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8142. */
  8143. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8144. /**
  8145. * Method called each time the image processing information changes requires to recompile the effect.
  8146. */
  8147. protected _updateParameters(): void;
  8148. /**
  8149. * Gets the current class name.
  8150. * @return "ImageProcessingConfiguration"
  8151. */
  8152. getClassName(): string;
  8153. /**
  8154. * Prepare the list of uniforms associated with the Image Processing effects.
  8155. * @param uniforms The list of uniforms used in the effect
  8156. * @param defines the list of defines currently in use
  8157. */
  8158. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8159. /**
  8160. * Prepare the list of samplers associated with the Image Processing effects.
  8161. * @param samplersList The list of uniforms used in the effect
  8162. * @param defines the list of defines currently in use
  8163. */
  8164. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8165. /**
  8166. * Prepare the list of defines associated to the shader.
  8167. * @param defines the list of defines to complete
  8168. * @param forPostProcess Define if we are currently in post process mode or not
  8169. */
  8170. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8171. /**
  8172. * Returns true if all the image processing information are ready.
  8173. * @returns True if ready, otherwise, false
  8174. */
  8175. isReady(): boolean;
  8176. /**
  8177. * Binds the image processing to the shader.
  8178. * @param effect The effect to bind to
  8179. * @param aspectRatio Define the current aspect ratio of the effect
  8180. */
  8181. bind(effect: Effect, aspectRatio?: number): void;
  8182. /**
  8183. * Clones the current image processing instance.
  8184. * @return The cloned image processing
  8185. */
  8186. clone(): ImageProcessingConfiguration;
  8187. /**
  8188. * Serializes the current image processing instance to a json representation.
  8189. * @return a JSON representation
  8190. */
  8191. serialize(): any;
  8192. /**
  8193. * Parses the image processing from a json representation.
  8194. * @param source the JSON source to parse
  8195. * @return The parsed image processing
  8196. */
  8197. static Parse(source: any): ImageProcessingConfiguration;
  8198. private static _VIGNETTEMODE_MULTIPLY;
  8199. private static _VIGNETTEMODE_OPAQUE;
  8200. /**
  8201. * Used to apply the vignette as a mix with the pixel color.
  8202. */
  8203. static readonly VIGNETTEMODE_MULTIPLY: number;
  8204. /**
  8205. * Used to apply the vignette as a replacement of the pixel color.
  8206. */
  8207. static readonly VIGNETTEMODE_OPAQUE: number;
  8208. }
  8209. }
  8210. declare module BABYLON {
  8211. /** @hidden */
  8212. export var postprocessVertexShader: {
  8213. name: string;
  8214. shader: string;
  8215. };
  8216. }
  8217. declare module BABYLON {
  8218. /** Defines supported spaces */
  8219. export enum Space {
  8220. /** Local (object) space */
  8221. LOCAL = 0,
  8222. /** World space */
  8223. WORLD = 1,
  8224. /** Bone space */
  8225. BONE = 2
  8226. }
  8227. /** Defines the 3 main axes */
  8228. export class Axis {
  8229. /** X axis */
  8230. static X: Vector3;
  8231. /** Y axis */
  8232. static Y: Vector3;
  8233. /** Z axis */
  8234. static Z: Vector3;
  8235. }
  8236. }
  8237. declare module BABYLON {
  8238. /**
  8239. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8240. * This is the base of the follow, arc rotate cameras and Free camera
  8241. * @see http://doc.babylonjs.com/features/cameras
  8242. */
  8243. export class TargetCamera extends Camera {
  8244. private static _RigCamTransformMatrix;
  8245. private static _TargetTransformMatrix;
  8246. private static _TargetFocalPoint;
  8247. /**
  8248. * Define the current direction the camera is moving to
  8249. */
  8250. cameraDirection: Vector3;
  8251. /**
  8252. * Define the current rotation the camera is rotating to
  8253. */
  8254. cameraRotation: Vector2;
  8255. /**
  8256. * When set, the up vector of the camera will be updated by the rotation of the camera
  8257. */
  8258. updateUpVectorFromRotation: boolean;
  8259. private _tmpQuaternion;
  8260. /**
  8261. * Define the current rotation of the camera
  8262. */
  8263. rotation: Vector3;
  8264. /**
  8265. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8266. */
  8267. rotationQuaternion: Quaternion;
  8268. /**
  8269. * Define the current speed of the camera
  8270. */
  8271. speed: number;
  8272. /**
  8273. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8274. * around all axis.
  8275. */
  8276. noRotationConstraint: boolean;
  8277. /**
  8278. * Define the current target of the camera as an object or a position.
  8279. */
  8280. lockedTarget: any;
  8281. /** @hidden */
  8282. _currentTarget: Vector3;
  8283. /** @hidden */
  8284. _initialFocalDistance: number;
  8285. /** @hidden */
  8286. _viewMatrix: Matrix;
  8287. /** @hidden */
  8288. _camMatrix: Matrix;
  8289. /** @hidden */
  8290. _cameraTransformMatrix: Matrix;
  8291. /** @hidden */
  8292. _cameraRotationMatrix: Matrix;
  8293. /** @hidden */
  8294. _referencePoint: Vector3;
  8295. /** @hidden */
  8296. _transformedReferencePoint: Vector3;
  8297. protected _globalCurrentTarget: Vector3;
  8298. protected _globalCurrentUpVector: Vector3;
  8299. /** @hidden */
  8300. _reset: () => void;
  8301. private _defaultUp;
  8302. /**
  8303. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8304. * This is the base of the follow, arc rotate cameras and Free camera
  8305. * @see http://doc.babylonjs.com/features/cameras
  8306. * @param name Defines the name of the camera in the scene
  8307. * @param position Defines the start position of the camera in the scene
  8308. * @param scene Defines the scene the camera belongs to
  8309. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8310. */
  8311. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8312. /**
  8313. * Gets the position in front of the camera at a given distance.
  8314. * @param distance The distance from the camera we want the position to be
  8315. * @returns the position
  8316. */
  8317. getFrontPosition(distance: number): Vector3;
  8318. /** @hidden */
  8319. _getLockedTargetPosition(): Nullable<Vector3>;
  8320. private _storedPosition;
  8321. private _storedRotation;
  8322. private _storedRotationQuaternion;
  8323. /**
  8324. * Store current camera state of the camera (fov, position, rotation, etc..)
  8325. * @returns the camera
  8326. */
  8327. storeState(): Camera;
  8328. /**
  8329. * Restored camera state. You must call storeState() first
  8330. * @returns whether it was successful or not
  8331. * @hidden
  8332. */
  8333. _restoreStateValues(): boolean;
  8334. /** @hidden */
  8335. _initCache(): void;
  8336. /** @hidden */
  8337. _updateCache(ignoreParentClass?: boolean): void;
  8338. /** @hidden */
  8339. _isSynchronizedViewMatrix(): boolean;
  8340. /** @hidden */
  8341. _computeLocalCameraSpeed(): number;
  8342. /**
  8343. * Defines the target the camera should look at.
  8344. * @param target Defines the new target as a Vector or a mesh
  8345. */
  8346. setTarget(target: Vector3): void;
  8347. /**
  8348. * Return the current target position of the camera. This value is expressed in local space.
  8349. * @returns the target position
  8350. */
  8351. getTarget(): Vector3;
  8352. /** @hidden */
  8353. _decideIfNeedsToMove(): boolean;
  8354. /** @hidden */
  8355. _updatePosition(): void;
  8356. /** @hidden */
  8357. _checkInputs(): void;
  8358. protected _updateCameraRotationMatrix(): void;
  8359. /**
  8360. * 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)
  8361. * @returns the current camera
  8362. */
  8363. private _rotateUpVectorWithCameraRotationMatrix;
  8364. private _cachedRotationZ;
  8365. private _cachedQuaternionRotationZ;
  8366. /** @hidden */
  8367. _getViewMatrix(): Matrix;
  8368. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8369. /**
  8370. * @hidden
  8371. */
  8372. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8373. /**
  8374. * @hidden
  8375. */
  8376. _updateRigCameras(): void;
  8377. private _getRigCamPositionAndTarget;
  8378. /**
  8379. * Gets the current object class name.
  8380. * @return the class name
  8381. */
  8382. getClassName(): string;
  8383. }
  8384. }
  8385. declare module BABYLON {
  8386. /**
  8387. * Gather the list of keyboard event types as constants.
  8388. */
  8389. export class KeyboardEventTypes {
  8390. /**
  8391. * The keydown event is fired when a key becomes active (pressed).
  8392. */
  8393. static readonly KEYDOWN: number;
  8394. /**
  8395. * The keyup event is fired when a key has been released.
  8396. */
  8397. static readonly KEYUP: number;
  8398. }
  8399. /**
  8400. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8401. */
  8402. export class KeyboardInfo {
  8403. /**
  8404. * Defines the type of event (KeyboardEventTypes)
  8405. */
  8406. type: number;
  8407. /**
  8408. * Defines the related dom event
  8409. */
  8410. event: KeyboardEvent;
  8411. /**
  8412. * Instantiates a new keyboard info.
  8413. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8414. * @param type Defines the type of event (KeyboardEventTypes)
  8415. * @param event Defines the related dom event
  8416. */
  8417. constructor(
  8418. /**
  8419. * Defines the type of event (KeyboardEventTypes)
  8420. */
  8421. type: number,
  8422. /**
  8423. * Defines the related dom event
  8424. */
  8425. event: KeyboardEvent);
  8426. }
  8427. /**
  8428. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8429. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8430. */
  8431. export class KeyboardInfoPre extends KeyboardInfo {
  8432. /**
  8433. * Defines the type of event (KeyboardEventTypes)
  8434. */
  8435. type: number;
  8436. /**
  8437. * Defines the related dom event
  8438. */
  8439. event: KeyboardEvent;
  8440. /**
  8441. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8442. */
  8443. skipOnPointerObservable: boolean;
  8444. /**
  8445. * Instantiates a new keyboard pre info.
  8446. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8447. * @param type Defines the type of event (KeyboardEventTypes)
  8448. * @param event Defines the related dom event
  8449. */
  8450. constructor(
  8451. /**
  8452. * Defines the type of event (KeyboardEventTypes)
  8453. */
  8454. type: number,
  8455. /**
  8456. * Defines the related dom event
  8457. */
  8458. event: KeyboardEvent);
  8459. }
  8460. }
  8461. declare module BABYLON {
  8462. /**
  8463. * Manage the keyboard inputs to control the movement of a free camera.
  8464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8465. */
  8466. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8467. /**
  8468. * Defines the camera the input is attached to.
  8469. */
  8470. camera: FreeCamera;
  8471. /**
  8472. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8473. */
  8474. keysUp: number[];
  8475. /**
  8476. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8477. */
  8478. keysDown: number[];
  8479. /**
  8480. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8481. */
  8482. keysLeft: number[];
  8483. /**
  8484. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8485. */
  8486. keysRight: number[];
  8487. private _keys;
  8488. private _onCanvasBlurObserver;
  8489. private _onKeyboardObserver;
  8490. private _engine;
  8491. private _scene;
  8492. /**
  8493. * Attach the input controls to a specific dom element to get the input from.
  8494. * @param element Defines the element the controls should be listened from
  8495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8496. */
  8497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8498. /**
  8499. * Detach the current controls from the specified dom element.
  8500. * @param element Defines the element to stop listening the inputs from
  8501. */
  8502. detachControl(element: Nullable<HTMLElement>): void;
  8503. /**
  8504. * Update the current camera state depending on the inputs that have been used this frame.
  8505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8506. */
  8507. checkInputs(): void;
  8508. /**
  8509. * Gets the class name of the current intput.
  8510. * @returns the class name
  8511. */
  8512. getClassName(): string;
  8513. /** @hidden */
  8514. _onLostFocus(): void;
  8515. /**
  8516. * Get the friendly name associated with the input class.
  8517. * @returns the input friendly name
  8518. */
  8519. getSimpleName(): string;
  8520. }
  8521. }
  8522. declare module BABYLON {
  8523. /**
  8524. * Interface describing all the common properties and methods a shadow light needs to implement.
  8525. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8526. * as well as binding the different shadow properties to the effects.
  8527. */
  8528. export interface IShadowLight extends Light {
  8529. /**
  8530. * The light id in the scene (used in scene.findLighById for instance)
  8531. */
  8532. id: string;
  8533. /**
  8534. * The position the shdow will be casted from.
  8535. */
  8536. position: Vector3;
  8537. /**
  8538. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8539. */
  8540. direction: Vector3;
  8541. /**
  8542. * The transformed position. Position of the light in world space taking parenting in account.
  8543. */
  8544. transformedPosition: Vector3;
  8545. /**
  8546. * The transformed direction. Direction of the light in world space taking parenting in account.
  8547. */
  8548. transformedDirection: Vector3;
  8549. /**
  8550. * The friendly name of the light in the scene.
  8551. */
  8552. name: string;
  8553. /**
  8554. * Defines the shadow projection clipping minimum z value.
  8555. */
  8556. shadowMinZ: number;
  8557. /**
  8558. * Defines the shadow projection clipping maximum z value.
  8559. */
  8560. shadowMaxZ: number;
  8561. /**
  8562. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8563. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8564. */
  8565. computeTransformedInformation(): boolean;
  8566. /**
  8567. * Gets the scene the light belongs to.
  8568. * @returns The scene
  8569. */
  8570. getScene(): Scene;
  8571. /**
  8572. * Callback defining a custom Projection Matrix Builder.
  8573. * This can be used to override the default projection matrix computation.
  8574. */
  8575. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8576. /**
  8577. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8578. * @param matrix The materix to updated with the projection information
  8579. * @param viewMatrix The transform matrix of the light
  8580. * @param renderList The list of mesh to render in the map
  8581. * @returns The current light
  8582. */
  8583. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8584. /**
  8585. * Gets the current depth scale used in ESM.
  8586. * @returns The scale
  8587. */
  8588. getDepthScale(): number;
  8589. /**
  8590. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8591. * @returns true if a cube texture needs to be use
  8592. */
  8593. needCube(): boolean;
  8594. /**
  8595. * Detects if the projection matrix requires to be recomputed this frame.
  8596. * @returns true if it requires to be recomputed otherwise, false.
  8597. */
  8598. needProjectionMatrixCompute(): boolean;
  8599. /**
  8600. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8601. */
  8602. forceProjectionMatrixCompute(): void;
  8603. /**
  8604. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8605. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8606. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8607. */
  8608. getShadowDirection(faceIndex?: number): Vector3;
  8609. /**
  8610. * Gets the minZ used for shadow according to both the scene and the light.
  8611. * @param activeCamera The camera we are returning the min for
  8612. * @returns the depth min z
  8613. */
  8614. getDepthMinZ(activeCamera: Camera): number;
  8615. /**
  8616. * Gets the maxZ used for shadow according to both the scene and the light.
  8617. * @param activeCamera The camera we are returning the max for
  8618. * @returns the depth max z
  8619. */
  8620. getDepthMaxZ(activeCamera: Camera): number;
  8621. }
  8622. /**
  8623. * Base implementation IShadowLight
  8624. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8625. */
  8626. export abstract class ShadowLight extends Light implements IShadowLight {
  8627. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8628. protected _position: Vector3;
  8629. protected _setPosition(value: Vector3): void;
  8630. /**
  8631. * Sets the position the shadow will be casted from. Also use as the light position for both
  8632. * point and spot lights.
  8633. */
  8634. /**
  8635. * Sets the position the shadow will be casted from. Also use as the light position for both
  8636. * point and spot lights.
  8637. */
  8638. position: Vector3;
  8639. protected _direction: Vector3;
  8640. protected _setDirection(value: Vector3): void;
  8641. /**
  8642. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8643. * Also use as the light direction on spot and directional lights.
  8644. */
  8645. /**
  8646. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8647. * Also use as the light direction on spot and directional lights.
  8648. */
  8649. direction: Vector3;
  8650. private _shadowMinZ;
  8651. /**
  8652. * Gets the shadow projection clipping minimum z value.
  8653. */
  8654. /**
  8655. * Sets the shadow projection clipping minimum z value.
  8656. */
  8657. shadowMinZ: number;
  8658. private _shadowMaxZ;
  8659. /**
  8660. * Sets the shadow projection clipping maximum z value.
  8661. */
  8662. /**
  8663. * Gets the shadow projection clipping maximum z value.
  8664. */
  8665. shadowMaxZ: number;
  8666. /**
  8667. * Callback defining a custom Projection Matrix Builder.
  8668. * This can be used to override the default projection matrix computation.
  8669. */
  8670. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8671. /**
  8672. * The transformed position. Position of the light in world space taking parenting in account.
  8673. */
  8674. transformedPosition: Vector3;
  8675. /**
  8676. * The transformed direction. Direction of the light in world space taking parenting in account.
  8677. */
  8678. transformedDirection: Vector3;
  8679. private _needProjectionMatrixCompute;
  8680. /**
  8681. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8682. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8683. */
  8684. computeTransformedInformation(): boolean;
  8685. /**
  8686. * Return the depth scale used for the shadow map.
  8687. * @returns the depth scale.
  8688. */
  8689. getDepthScale(): number;
  8690. /**
  8691. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8692. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8693. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8694. */
  8695. getShadowDirection(faceIndex?: number): Vector3;
  8696. /**
  8697. * Returns the ShadowLight absolute position in the World.
  8698. * @returns the position vector in world space
  8699. */
  8700. getAbsolutePosition(): Vector3;
  8701. /**
  8702. * Sets the ShadowLight direction toward the passed target.
  8703. * @param target The point to target in local space
  8704. * @returns the updated ShadowLight direction
  8705. */
  8706. setDirectionToTarget(target: Vector3): Vector3;
  8707. /**
  8708. * Returns the light rotation in euler definition.
  8709. * @returns the x y z rotation in local space.
  8710. */
  8711. getRotation(): Vector3;
  8712. /**
  8713. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8714. * @returns true if a cube texture needs to be use
  8715. */
  8716. needCube(): boolean;
  8717. /**
  8718. * Detects if the projection matrix requires to be recomputed this frame.
  8719. * @returns true if it requires to be recomputed otherwise, false.
  8720. */
  8721. needProjectionMatrixCompute(): boolean;
  8722. /**
  8723. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8724. */
  8725. forceProjectionMatrixCompute(): void;
  8726. /** @hidden */
  8727. _initCache(): void;
  8728. /** @hidden */
  8729. _isSynchronized(): boolean;
  8730. /**
  8731. * Computes the world matrix of the node
  8732. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8733. * @returns the world matrix
  8734. */
  8735. computeWorldMatrix(force?: boolean): Matrix;
  8736. /**
  8737. * Gets the minZ used for shadow according to both the scene and the light.
  8738. * @param activeCamera The camera we are returning the min for
  8739. * @returns the depth min z
  8740. */
  8741. getDepthMinZ(activeCamera: Camera): number;
  8742. /**
  8743. * Gets the maxZ used for shadow according to both the scene and the light.
  8744. * @param activeCamera The camera we are returning the max for
  8745. * @returns the depth max z
  8746. */
  8747. getDepthMaxZ(activeCamera: Camera): number;
  8748. /**
  8749. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8750. * @param matrix The materix to updated with the projection information
  8751. * @param viewMatrix The transform matrix of the light
  8752. * @param renderList The list of mesh to render in the map
  8753. * @returns The current light
  8754. */
  8755. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8756. }
  8757. }
  8758. declare module BABYLON {
  8759. /**
  8760. * "Static Class" containing the most commonly used helper while dealing with material for
  8761. * rendering purpose.
  8762. *
  8763. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8764. *
  8765. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8766. */
  8767. export class MaterialHelper {
  8768. /**
  8769. * Bind the current view position to an effect.
  8770. * @param effect The effect to be bound
  8771. * @param scene The scene the eyes position is used from
  8772. */
  8773. static BindEyePosition(effect: Effect, scene: Scene): void;
  8774. /**
  8775. * Helps preparing the defines values about the UVs in used in the effect.
  8776. * UVs are shared as much as we can accross channels in the shaders.
  8777. * @param texture The texture we are preparing the UVs for
  8778. * @param defines The defines to update
  8779. * @param key The channel key "diffuse", "specular"... used in the shader
  8780. */
  8781. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8782. /**
  8783. * Binds a texture matrix value to its corrsponding uniform
  8784. * @param texture The texture to bind the matrix for
  8785. * @param uniformBuffer The uniform buffer receivin the data
  8786. * @param key The channel key "diffuse", "specular"... used in the shader
  8787. */
  8788. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8789. /**
  8790. * Gets the current status of the fog (should it be enabled?)
  8791. * @param mesh defines the mesh to evaluate for fog support
  8792. * @param scene defines the hosting scene
  8793. * @returns true if fog must be enabled
  8794. */
  8795. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8796. /**
  8797. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8798. * @param mesh defines the current mesh
  8799. * @param scene defines the current scene
  8800. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8801. * @param pointsCloud defines if point cloud rendering has to be turned on
  8802. * @param fogEnabled defines if fog has to be turned on
  8803. * @param alphaTest defines if alpha testing has to be turned on
  8804. * @param defines defines the current list of defines
  8805. */
  8806. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8807. /**
  8808. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8809. * @param scene defines the current scene
  8810. * @param engine defines the current engine
  8811. * @param defines specifies the list of active defines
  8812. * @param useInstances defines if instances have to be turned on
  8813. * @param useClipPlane defines if clip plane have to be turned on
  8814. */
  8815. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8816. /**
  8817. * Prepares the defines for bones
  8818. * @param mesh The mesh containing the geometry data we will draw
  8819. * @param defines The defines to update
  8820. */
  8821. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8822. /**
  8823. * Prepares the defines for morph targets
  8824. * @param mesh The mesh containing the geometry data we will draw
  8825. * @param defines The defines to update
  8826. */
  8827. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8828. /**
  8829. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8830. * @param mesh The mesh containing the geometry data we will draw
  8831. * @param defines The defines to update
  8832. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8833. * @param useBones Precise whether bones should be used or not (override mesh info)
  8834. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8835. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8836. * @returns false if defines are considered not dirty and have not been checked
  8837. */
  8838. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8839. /**
  8840. * Prepares the defines related to multiview
  8841. * @param scene The scene we are intending to draw
  8842. * @param defines The defines to update
  8843. */
  8844. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8845. /**
  8846. * Prepares the defines related to the light information passed in parameter
  8847. * @param scene The scene we are intending to draw
  8848. * @param mesh The mesh the effect is compiling for
  8849. * @param light The light the effect is compiling for
  8850. * @param lightIndex The index of the light
  8851. * @param defines The defines to update
  8852. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8853. * @param state Defines the current state regarding what is needed (normals, etc...)
  8854. */
  8855. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8856. needNormals: boolean;
  8857. needRebuild: boolean;
  8858. shadowEnabled: boolean;
  8859. specularEnabled: boolean;
  8860. lightmapMode: boolean;
  8861. }): void;
  8862. /**
  8863. * Prepares the defines related to the light information passed in parameter
  8864. * @param scene The scene we are intending to draw
  8865. * @param mesh The mesh the effect is compiling for
  8866. * @param defines The defines to update
  8867. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8868. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8869. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8870. * @returns true if normals will be required for the rest of the effect
  8871. */
  8872. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8873. /**
  8874. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8875. * @param lightIndex defines the light index
  8876. * @param uniformsList The uniform list
  8877. * @param samplersList The sampler list
  8878. * @param projectedLightTexture defines if projected texture must be used
  8879. * @param uniformBuffersList defines an optional list of uniform buffers
  8880. */
  8881. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8882. /**
  8883. * Prepares the uniforms and samplers list to be used in the effect
  8884. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8885. * @param samplersList The sampler list
  8886. * @param defines The defines helping in the list generation
  8887. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8888. */
  8889. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8890. /**
  8891. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8892. * @param defines The defines to update while falling back
  8893. * @param fallbacks The authorized effect fallbacks
  8894. * @param maxSimultaneousLights The maximum number of lights allowed
  8895. * @param rank the current rank of the Effect
  8896. * @returns The newly affected rank
  8897. */
  8898. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8899. private static _TmpMorphInfluencers;
  8900. /**
  8901. * Prepares the list of attributes required for morph targets according to the effect defines.
  8902. * @param attribs The current list of supported attribs
  8903. * @param mesh The mesh to prepare the morph targets attributes for
  8904. * @param influencers The number of influencers
  8905. */
  8906. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8907. /**
  8908. * Prepares the list of attributes required for morph targets according to the effect defines.
  8909. * @param attribs The current list of supported attribs
  8910. * @param mesh The mesh to prepare the morph targets attributes for
  8911. * @param defines The current Defines of the effect
  8912. */
  8913. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8914. /**
  8915. * Prepares the list of attributes required for bones according to the effect defines.
  8916. * @param attribs The current list of supported attribs
  8917. * @param mesh The mesh to prepare the bones attributes for
  8918. * @param defines The current Defines of the effect
  8919. * @param fallbacks The current efffect fallback strategy
  8920. */
  8921. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8922. /**
  8923. * Check and prepare the list of attributes required for instances according to the effect defines.
  8924. * @param attribs The current list of supported attribs
  8925. * @param defines The current MaterialDefines of the effect
  8926. */
  8927. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8928. /**
  8929. * Add the list of attributes required for instances to the attribs array.
  8930. * @param attribs The current list of supported attribs
  8931. */
  8932. static PushAttributesForInstances(attribs: string[]): void;
  8933. /**
  8934. * Binds the light shadow information to the effect for the given mesh.
  8935. * @param light The light containing the generator
  8936. * @param scene The scene the lights belongs to
  8937. * @param mesh The mesh we are binding the information to render
  8938. * @param lightIndex The light index in the effect used to render the mesh
  8939. * @param effect The effect we are binding the data to
  8940. */
  8941. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8942. /**
  8943. * Binds the light information to the effect.
  8944. * @param light The light containing the generator
  8945. * @param effect The effect we are binding the data to
  8946. * @param lightIndex The light index in the effect used to render
  8947. */
  8948. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8949. /**
  8950. * Binds the lights information from the scene to the effect for the given mesh.
  8951. * @param light Light to bind
  8952. * @param lightIndex Light index
  8953. * @param scene The scene where the light belongs to
  8954. * @param mesh The mesh we are binding the information to render
  8955. * @param effect The effect we are binding the data to
  8956. * @param useSpecular Defines if specular is supported
  8957. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8958. */
  8959. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  8960. /**
  8961. * Binds the lights information from the scene to the effect for the given mesh.
  8962. * @param scene The scene the lights belongs to
  8963. * @param mesh The mesh we are binding the information to render
  8964. * @param effect The effect we are binding the data to
  8965. * @param defines The generated defines for the effect
  8966. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8967. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8968. */
  8969. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8970. private static _tempFogColor;
  8971. /**
  8972. * Binds the fog information from the scene to the effect for the given mesh.
  8973. * @param scene The scene the lights belongs to
  8974. * @param mesh The mesh we are binding the information to render
  8975. * @param effect The effect we are binding the data to
  8976. * @param linearSpace Defines if the fog effect is applied in linear space
  8977. */
  8978. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8979. /**
  8980. * Binds the bones information from the mesh to the effect.
  8981. * @param mesh The mesh we are binding the information to render
  8982. * @param effect The effect we are binding the data to
  8983. */
  8984. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8985. /**
  8986. * Binds the morph targets information from the mesh to the effect.
  8987. * @param abstractMesh The mesh we are binding the information to render
  8988. * @param effect The effect we are binding the data to
  8989. */
  8990. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8991. /**
  8992. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8993. * @param defines The generated defines used in the effect
  8994. * @param effect The effect we are binding the data to
  8995. * @param scene The scene we are willing to render with logarithmic scale for
  8996. */
  8997. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8998. /**
  8999. * Binds the clip plane information from the scene to the effect.
  9000. * @param scene The scene the clip plane information are extracted from
  9001. * @param effect The effect we are binding the data to
  9002. */
  9003. static BindClipPlane(effect: Effect, scene: Scene): void;
  9004. }
  9005. }
  9006. declare module BABYLON {
  9007. /** @hidden */
  9008. export var packingFunctions: {
  9009. name: string;
  9010. shader: string;
  9011. };
  9012. }
  9013. declare module BABYLON {
  9014. /** @hidden */
  9015. export var shadowMapPixelShader: {
  9016. name: string;
  9017. shader: string;
  9018. };
  9019. }
  9020. declare module BABYLON {
  9021. /** @hidden */
  9022. export var bonesDeclaration: {
  9023. name: string;
  9024. shader: string;
  9025. };
  9026. }
  9027. declare module BABYLON {
  9028. /** @hidden */
  9029. export var morphTargetsVertexGlobalDeclaration: {
  9030. name: string;
  9031. shader: string;
  9032. };
  9033. }
  9034. declare module BABYLON {
  9035. /** @hidden */
  9036. export var morphTargetsVertexDeclaration: {
  9037. name: string;
  9038. shader: string;
  9039. };
  9040. }
  9041. declare module BABYLON {
  9042. /** @hidden */
  9043. export var instancesDeclaration: {
  9044. name: string;
  9045. shader: string;
  9046. };
  9047. }
  9048. declare module BABYLON {
  9049. /** @hidden */
  9050. export var helperFunctions: {
  9051. name: string;
  9052. shader: string;
  9053. };
  9054. }
  9055. declare module BABYLON {
  9056. /** @hidden */
  9057. export var morphTargetsVertex: {
  9058. name: string;
  9059. shader: string;
  9060. };
  9061. }
  9062. declare module BABYLON {
  9063. /** @hidden */
  9064. export var instancesVertex: {
  9065. name: string;
  9066. shader: string;
  9067. };
  9068. }
  9069. declare module BABYLON {
  9070. /** @hidden */
  9071. export var bonesVertex: {
  9072. name: string;
  9073. shader: string;
  9074. };
  9075. }
  9076. declare module BABYLON {
  9077. /** @hidden */
  9078. export var shadowMapVertexShader: {
  9079. name: string;
  9080. shader: string;
  9081. };
  9082. }
  9083. declare module BABYLON {
  9084. /** @hidden */
  9085. export var depthBoxBlurPixelShader: {
  9086. name: string;
  9087. shader: string;
  9088. };
  9089. }
  9090. declare module BABYLON {
  9091. /**
  9092. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9093. */
  9094. export interface ICustomShaderOptions {
  9095. /**
  9096. * Gets or sets the custom shader name to use
  9097. */
  9098. shaderName: string;
  9099. /**
  9100. * The list of attribute names used in the shader
  9101. */
  9102. attributes?: string[];
  9103. /**
  9104. * The list of unifrom names used in the shader
  9105. */
  9106. uniforms?: string[];
  9107. /**
  9108. * The list of sampler names used in the shader
  9109. */
  9110. samplers?: string[];
  9111. /**
  9112. * The list of defines used in the shader
  9113. */
  9114. defines?: string[];
  9115. }
  9116. /**
  9117. * Interface to implement to create a shadow generator compatible with BJS.
  9118. */
  9119. export interface IShadowGenerator {
  9120. /**
  9121. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9122. * @returns The render target texture if present otherwise, null
  9123. */
  9124. getShadowMap(): Nullable<RenderTargetTexture>;
  9125. /**
  9126. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9127. * @returns The render target texture if the shadow map is present otherwise, null
  9128. */
  9129. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9130. /**
  9131. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9132. * @param subMesh The submesh we want to render in the shadow map
  9133. * @param useInstances Defines wether will draw in the map using instances
  9134. * @returns true if ready otherwise, false
  9135. */
  9136. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9137. /**
  9138. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9139. * @param defines Defines of the material we want to update
  9140. * @param lightIndex Index of the light in the enabled light list of the material
  9141. */
  9142. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9143. /**
  9144. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9145. * defined in the generator but impacting the effect).
  9146. * It implies the unifroms available on the materials are the standard BJS ones.
  9147. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9148. * @param effect The effect we are binfing the information for
  9149. */
  9150. bindShadowLight(lightIndex: string, effect: Effect): void;
  9151. /**
  9152. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9153. * (eq to shadow prjection matrix * light transform matrix)
  9154. * @returns The transform matrix used to create the shadow map
  9155. */
  9156. getTransformMatrix(): Matrix;
  9157. /**
  9158. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9159. * Cube and 2D textures for instance.
  9160. */
  9161. recreateShadowMap(): void;
  9162. /**
  9163. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9164. * @param onCompiled Callback triggered at the and of the effects compilation
  9165. * @param options Sets of optional options forcing the compilation with different modes
  9166. */
  9167. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9168. useInstances: boolean;
  9169. }>): void;
  9170. /**
  9171. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9172. * @param options Sets of optional options forcing the compilation with different modes
  9173. * @returns A promise that resolves when the compilation completes
  9174. */
  9175. forceCompilationAsync(options?: Partial<{
  9176. useInstances: boolean;
  9177. }>): Promise<void>;
  9178. /**
  9179. * Serializes the shadow generator setup to a json object.
  9180. * @returns The serialized JSON object
  9181. */
  9182. serialize(): any;
  9183. /**
  9184. * Disposes the Shadow map and related Textures and effects.
  9185. */
  9186. dispose(): void;
  9187. }
  9188. /**
  9189. * Default implementation IShadowGenerator.
  9190. * This is the main object responsible of generating shadows in the framework.
  9191. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9192. */
  9193. export class ShadowGenerator implements IShadowGenerator {
  9194. /**
  9195. * Shadow generator mode None: no filtering applied.
  9196. */
  9197. static readonly FILTER_NONE: number;
  9198. /**
  9199. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9200. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9201. */
  9202. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9203. /**
  9204. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9205. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9206. */
  9207. static readonly FILTER_POISSONSAMPLING: number;
  9208. /**
  9209. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9210. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9211. */
  9212. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9213. /**
  9214. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9215. * edge artifacts on steep falloff.
  9216. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9217. */
  9218. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9219. /**
  9220. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9221. * edge artifacts on steep falloff.
  9222. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9223. */
  9224. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9225. /**
  9226. * Shadow generator mode PCF: Percentage Closer Filtering
  9227. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9228. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9229. */
  9230. static readonly FILTER_PCF: number;
  9231. /**
  9232. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9233. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9234. * Contact Hardening
  9235. */
  9236. static readonly FILTER_PCSS: number;
  9237. /**
  9238. * Reserved for PCF and PCSS
  9239. * Highest Quality.
  9240. *
  9241. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9242. *
  9243. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9244. */
  9245. static readonly QUALITY_HIGH: number;
  9246. /**
  9247. * Reserved for PCF and PCSS
  9248. * Good tradeoff for quality/perf cross devices
  9249. *
  9250. * Execute PCF on a 3*3 kernel.
  9251. *
  9252. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9253. */
  9254. static readonly QUALITY_MEDIUM: number;
  9255. /**
  9256. * Reserved for PCF and PCSS
  9257. * The lowest quality but the fastest.
  9258. *
  9259. * Execute PCF on a 1*1 kernel.
  9260. *
  9261. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9262. */
  9263. static readonly QUALITY_LOW: number;
  9264. /** Gets or sets the custom shader name to use */
  9265. customShaderOptions: ICustomShaderOptions;
  9266. /**
  9267. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9268. */
  9269. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9270. /**
  9271. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9272. */
  9273. onAfterShadowMapRenderObservable: Observable<Effect>;
  9274. /**
  9275. * Observable triggered before a mesh is rendered in the shadow map.
  9276. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9277. */
  9278. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9279. /**
  9280. * Observable triggered after a mesh is rendered in the shadow map.
  9281. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9282. */
  9283. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9284. private _bias;
  9285. /**
  9286. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9287. */
  9288. /**
  9289. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9290. */
  9291. bias: number;
  9292. private _normalBias;
  9293. /**
  9294. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9295. */
  9296. /**
  9297. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9298. */
  9299. normalBias: number;
  9300. private _blurBoxOffset;
  9301. /**
  9302. * Gets the blur box offset: offset applied during the blur pass.
  9303. * Only useful if useKernelBlur = false
  9304. */
  9305. /**
  9306. * Sets the blur box offset: offset applied during the blur pass.
  9307. * Only useful if useKernelBlur = false
  9308. */
  9309. blurBoxOffset: number;
  9310. private _blurScale;
  9311. /**
  9312. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9313. * 2 means half of the size.
  9314. */
  9315. /**
  9316. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9317. * 2 means half of the size.
  9318. */
  9319. blurScale: number;
  9320. private _blurKernel;
  9321. /**
  9322. * Gets the blur kernel: kernel size of the blur pass.
  9323. * Only useful if useKernelBlur = true
  9324. */
  9325. /**
  9326. * Sets the blur kernel: kernel size of the blur pass.
  9327. * Only useful if useKernelBlur = true
  9328. */
  9329. blurKernel: number;
  9330. private _useKernelBlur;
  9331. /**
  9332. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9333. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9334. */
  9335. /**
  9336. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9337. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9338. */
  9339. useKernelBlur: boolean;
  9340. private _depthScale;
  9341. /**
  9342. * Gets the depth scale used in ESM mode.
  9343. */
  9344. /**
  9345. * Sets the depth scale used in ESM mode.
  9346. * This can override the scale stored on the light.
  9347. */
  9348. depthScale: number;
  9349. private _filter;
  9350. /**
  9351. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9352. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9353. */
  9354. /**
  9355. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9356. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9357. */
  9358. filter: number;
  9359. /**
  9360. * Gets if the current filter is set to Poisson Sampling.
  9361. */
  9362. /**
  9363. * Sets the current filter to Poisson Sampling.
  9364. */
  9365. usePoissonSampling: boolean;
  9366. /**
  9367. * Gets if the current filter is set to ESM.
  9368. */
  9369. /**
  9370. * Sets the current filter is to ESM.
  9371. */
  9372. useExponentialShadowMap: boolean;
  9373. /**
  9374. * Gets if the current filter is set to filtered ESM.
  9375. */
  9376. /**
  9377. * Gets if the current filter is set to filtered ESM.
  9378. */
  9379. useBlurExponentialShadowMap: boolean;
  9380. /**
  9381. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9382. * exponential to prevent steep falloff artifacts).
  9383. */
  9384. /**
  9385. * Sets the current filter to "close ESM" (using the inverse of the
  9386. * exponential to prevent steep falloff artifacts).
  9387. */
  9388. useCloseExponentialShadowMap: boolean;
  9389. /**
  9390. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9391. * exponential to prevent steep falloff artifacts).
  9392. */
  9393. /**
  9394. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9395. * exponential to prevent steep falloff artifacts).
  9396. */
  9397. useBlurCloseExponentialShadowMap: boolean;
  9398. /**
  9399. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9400. */
  9401. /**
  9402. * Sets the current filter to "PCF" (percentage closer filtering).
  9403. */
  9404. usePercentageCloserFiltering: boolean;
  9405. private _filteringQuality;
  9406. /**
  9407. * Gets the PCF or PCSS Quality.
  9408. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9409. */
  9410. /**
  9411. * Sets the PCF or PCSS Quality.
  9412. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9413. */
  9414. filteringQuality: number;
  9415. /**
  9416. * Gets if the current filter is set to "PCSS" (contact hardening).
  9417. */
  9418. /**
  9419. * Sets the current filter to "PCSS" (contact hardening).
  9420. */
  9421. useContactHardeningShadow: boolean;
  9422. private _contactHardeningLightSizeUVRatio;
  9423. /**
  9424. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9425. * Using a ratio helps keeping shape stability independently of the map size.
  9426. *
  9427. * It does not account for the light projection as it was having too much
  9428. * instability during the light setup or during light position changes.
  9429. *
  9430. * Only valid if useContactHardeningShadow is true.
  9431. */
  9432. /**
  9433. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9434. * Using a ratio helps keeping shape stability independently of the map size.
  9435. *
  9436. * It does not account for the light projection as it was having too much
  9437. * instability during the light setup or during light position changes.
  9438. *
  9439. * Only valid if useContactHardeningShadow is true.
  9440. */
  9441. contactHardeningLightSizeUVRatio: number;
  9442. private _darkness;
  9443. /** Gets or sets the actual darkness of a shadow */
  9444. darkness: number;
  9445. /**
  9446. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9447. * 0 means strongest and 1 would means no shadow.
  9448. * @returns the darkness.
  9449. */
  9450. getDarkness(): number;
  9451. /**
  9452. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9453. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9454. * @returns the shadow generator allowing fluent coding.
  9455. */
  9456. setDarkness(darkness: number): ShadowGenerator;
  9457. private _transparencyShadow;
  9458. /** Gets or sets the ability to have transparent shadow */
  9459. transparencyShadow: boolean;
  9460. /**
  9461. * Sets the ability to have transparent shadow (boolean).
  9462. * @param transparent True if transparent else False
  9463. * @returns the shadow generator allowing fluent coding
  9464. */
  9465. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9466. private _shadowMap;
  9467. private _shadowMap2;
  9468. /**
  9469. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9470. * @returns The render target texture if present otherwise, null
  9471. */
  9472. getShadowMap(): Nullable<RenderTargetTexture>;
  9473. /**
  9474. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9475. * @returns The render target texture if the shadow map is present otherwise, null
  9476. */
  9477. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9478. /**
  9479. * Gets the class name of that object
  9480. * @returns "ShadowGenerator"
  9481. */
  9482. getClassName(): string;
  9483. /**
  9484. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9485. * @param mesh Mesh to add
  9486. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9487. * @returns the Shadow Generator itself
  9488. */
  9489. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9490. /**
  9491. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9492. * @param mesh Mesh to remove
  9493. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9494. * @returns the Shadow Generator itself
  9495. */
  9496. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9497. /**
  9498. * Controls the extent to which the shadows fade out at the edge of the frustum
  9499. * Used only by directionals and spots
  9500. */
  9501. frustumEdgeFalloff: number;
  9502. private _light;
  9503. /**
  9504. * Returns the associated light object.
  9505. * @returns the light generating the shadow
  9506. */
  9507. getLight(): IShadowLight;
  9508. /**
  9509. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9510. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9511. * It might on the other hand introduce peter panning.
  9512. */
  9513. forceBackFacesOnly: boolean;
  9514. private _scene;
  9515. private _lightDirection;
  9516. private _effect;
  9517. private _viewMatrix;
  9518. private _projectionMatrix;
  9519. private _transformMatrix;
  9520. private _cachedPosition;
  9521. private _cachedDirection;
  9522. private _cachedDefines;
  9523. private _currentRenderID;
  9524. private _boxBlurPostprocess;
  9525. private _kernelBlurXPostprocess;
  9526. private _kernelBlurYPostprocess;
  9527. private _blurPostProcesses;
  9528. private _mapSize;
  9529. private _currentFaceIndex;
  9530. private _currentFaceIndexCache;
  9531. private _textureType;
  9532. private _defaultTextureMatrix;
  9533. /** @hidden */
  9534. static _SceneComponentInitialization: (scene: Scene) => void;
  9535. /**
  9536. * Creates a ShadowGenerator object.
  9537. * A ShadowGenerator is the required tool to use the shadows.
  9538. * Each light casting shadows needs to use its own ShadowGenerator.
  9539. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9540. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9541. * @param light The light object generating the shadows.
  9542. * @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.
  9543. */
  9544. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9545. private _initializeGenerator;
  9546. private _initializeShadowMap;
  9547. private _initializeBlurRTTAndPostProcesses;
  9548. private _renderForShadowMap;
  9549. private _renderSubMeshForShadowMap;
  9550. private _applyFilterValues;
  9551. /**
  9552. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9553. * @param onCompiled Callback triggered at the and of the effects compilation
  9554. * @param options Sets of optional options forcing the compilation with different modes
  9555. */
  9556. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9557. useInstances: boolean;
  9558. }>): void;
  9559. /**
  9560. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9561. * @param options Sets of optional options forcing the compilation with different modes
  9562. * @returns A promise that resolves when the compilation completes
  9563. */
  9564. forceCompilationAsync(options?: Partial<{
  9565. useInstances: boolean;
  9566. }>): Promise<void>;
  9567. /**
  9568. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9569. * @param subMesh The submesh we want to render in the shadow map
  9570. * @param useInstances Defines wether will draw in the map using instances
  9571. * @returns true if ready otherwise, false
  9572. */
  9573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9574. /**
  9575. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9576. * @param defines Defines of the material we want to update
  9577. * @param lightIndex Index of the light in the enabled light list of the material
  9578. */
  9579. prepareDefines(defines: any, lightIndex: number): void;
  9580. /**
  9581. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9582. * defined in the generator but impacting the effect).
  9583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9584. * @param effect The effect we are binfing the information for
  9585. */
  9586. bindShadowLight(lightIndex: string, effect: Effect): void;
  9587. /**
  9588. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9589. * (eq to shadow prjection matrix * light transform matrix)
  9590. * @returns The transform matrix used to create the shadow map
  9591. */
  9592. getTransformMatrix(): Matrix;
  9593. /**
  9594. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9595. * Cube and 2D textures for instance.
  9596. */
  9597. recreateShadowMap(): void;
  9598. private _disposeBlurPostProcesses;
  9599. private _disposeRTTandPostProcesses;
  9600. /**
  9601. * Disposes the ShadowGenerator.
  9602. * Returns nothing.
  9603. */
  9604. dispose(): void;
  9605. /**
  9606. * Serializes the shadow generator setup to a json object.
  9607. * @returns The serialized JSON object
  9608. */
  9609. serialize(): any;
  9610. /**
  9611. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9612. * @param parsedShadowGenerator The JSON object to parse
  9613. * @param scene The scene to create the shadow map for
  9614. * @returns The parsed shadow generator
  9615. */
  9616. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9617. }
  9618. }
  9619. declare module BABYLON {
  9620. /**
  9621. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9622. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9623. * 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.
  9624. */
  9625. export abstract class Light extends Node {
  9626. /**
  9627. * Falloff Default: light is falling off following the material specification:
  9628. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9629. */
  9630. static readonly FALLOFF_DEFAULT: number;
  9631. /**
  9632. * Falloff Physical: light is falling off following the inverse squared distance law.
  9633. */
  9634. static readonly FALLOFF_PHYSICAL: number;
  9635. /**
  9636. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9637. * to enhance interoperability with other engines.
  9638. */
  9639. static readonly FALLOFF_GLTF: number;
  9640. /**
  9641. * Falloff Standard: light is falling off like in the standard material
  9642. * to enhance interoperability with other materials.
  9643. */
  9644. static readonly FALLOFF_STANDARD: number;
  9645. /**
  9646. * If every light affecting the material is in this lightmapMode,
  9647. * material.lightmapTexture adds or multiplies
  9648. * (depends on material.useLightmapAsShadowmap)
  9649. * after every other light calculations.
  9650. */
  9651. static readonly LIGHTMAP_DEFAULT: number;
  9652. /**
  9653. * material.lightmapTexture as only diffuse lighting from this light
  9654. * adds only specular lighting from this light
  9655. * adds dynamic shadows
  9656. */
  9657. static readonly LIGHTMAP_SPECULAR: number;
  9658. /**
  9659. * material.lightmapTexture as only lighting
  9660. * no light calculation from this light
  9661. * only adds dynamic shadows from this light
  9662. */
  9663. static readonly LIGHTMAP_SHADOWSONLY: number;
  9664. /**
  9665. * Each light type uses the default quantity according to its type:
  9666. * point/spot lights use luminous intensity
  9667. * directional lights use illuminance
  9668. */
  9669. static readonly INTENSITYMODE_AUTOMATIC: number;
  9670. /**
  9671. * lumen (lm)
  9672. */
  9673. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9674. /**
  9675. * candela (lm/sr)
  9676. */
  9677. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9678. /**
  9679. * lux (lm/m^2)
  9680. */
  9681. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9682. /**
  9683. * nit (cd/m^2)
  9684. */
  9685. static readonly INTENSITYMODE_LUMINANCE: number;
  9686. /**
  9687. * Light type const id of the point light.
  9688. */
  9689. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9690. /**
  9691. * Light type const id of the directional light.
  9692. */
  9693. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9694. /**
  9695. * Light type const id of the spot light.
  9696. */
  9697. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9698. /**
  9699. * Light type const id of the hemispheric light.
  9700. */
  9701. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9702. /**
  9703. * Diffuse gives the basic color to an object.
  9704. */
  9705. diffuse: Color3;
  9706. /**
  9707. * Specular produces a highlight color on an object.
  9708. * Note: This is note affecting PBR materials.
  9709. */
  9710. specular: Color3;
  9711. /**
  9712. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9713. * falling off base on range or angle.
  9714. * This can be set to any values in Light.FALLOFF_x.
  9715. *
  9716. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9717. * other types of materials.
  9718. */
  9719. falloffType: number;
  9720. /**
  9721. * Strength of the light.
  9722. * Note: By default it is define in the framework own unit.
  9723. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9724. */
  9725. intensity: number;
  9726. private _range;
  9727. protected _inverseSquaredRange: number;
  9728. /**
  9729. * Defines how far from the source the light is impacting in scene units.
  9730. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9731. */
  9732. /**
  9733. * Defines how far from the source the light is impacting in scene units.
  9734. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9735. */
  9736. range: number;
  9737. /**
  9738. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9739. * of light.
  9740. */
  9741. private _photometricScale;
  9742. private _intensityMode;
  9743. /**
  9744. * Gets the photometric scale used to interpret the intensity.
  9745. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9746. */
  9747. /**
  9748. * Sets the photometric scale used to interpret the intensity.
  9749. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9750. */
  9751. intensityMode: number;
  9752. private _radius;
  9753. /**
  9754. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9755. */
  9756. /**
  9757. * sets the light radius used by PBR Materials to simulate soft area lights.
  9758. */
  9759. radius: number;
  9760. private _renderPriority;
  9761. /**
  9762. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9763. * exceeding the number allowed of the materials.
  9764. */
  9765. renderPriority: number;
  9766. private _shadowEnabled;
  9767. /**
  9768. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9769. * the current shadow generator.
  9770. */
  9771. /**
  9772. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9773. * the current shadow generator.
  9774. */
  9775. shadowEnabled: boolean;
  9776. private _includedOnlyMeshes;
  9777. /**
  9778. * Gets the only meshes impacted by this light.
  9779. */
  9780. /**
  9781. * Sets the only meshes impacted by this light.
  9782. */
  9783. includedOnlyMeshes: AbstractMesh[];
  9784. private _excludedMeshes;
  9785. /**
  9786. * Gets the meshes not impacted by this light.
  9787. */
  9788. /**
  9789. * Sets the meshes not impacted by this light.
  9790. */
  9791. excludedMeshes: AbstractMesh[];
  9792. private _excludeWithLayerMask;
  9793. /**
  9794. * Gets the layer id use to find what meshes are not impacted by the light.
  9795. * Inactive if 0
  9796. */
  9797. /**
  9798. * Sets the layer id use to find what meshes are not impacted by the light.
  9799. * Inactive if 0
  9800. */
  9801. excludeWithLayerMask: number;
  9802. private _includeOnlyWithLayerMask;
  9803. /**
  9804. * Gets the layer id use to find what meshes are impacted by the light.
  9805. * Inactive if 0
  9806. */
  9807. /**
  9808. * Sets the layer id use to find what meshes are impacted by the light.
  9809. * Inactive if 0
  9810. */
  9811. includeOnlyWithLayerMask: number;
  9812. private _lightmapMode;
  9813. /**
  9814. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9815. */
  9816. /**
  9817. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9818. */
  9819. lightmapMode: number;
  9820. /**
  9821. * Shadow generator associted to the light.
  9822. * @hidden Internal use only.
  9823. */
  9824. _shadowGenerator: Nullable<IShadowGenerator>;
  9825. /**
  9826. * @hidden Internal use only.
  9827. */
  9828. _excludedMeshesIds: string[];
  9829. /**
  9830. * @hidden Internal use only.
  9831. */
  9832. _includedOnlyMeshesIds: string[];
  9833. /**
  9834. * The current light unifom buffer.
  9835. * @hidden Internal use only.
  9836. */
  9837. _uniformBuffer: UniformBuffer;
  9838. /**
  9839. * Creates a Light object in the scene.
  9840. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9841. * @param name The firendly name of the light
  9842. * @param scene The scene the light belongs too
  9843. */
  9844. constructor(name: string, scene: Scene);
  9845. protected abstract _buildUniformLayout(): void;
  9846. /**
  9847. * Sets the passed Effect "effect" with the Light information.
  9848. * @param effect The effect to update
  9849. * @param lightIndex The index of the light in the effect to update
  9850. * @returns The light
  9851. */
  9852. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9853. /**
  9854. * Returns the string "Light".
  9855. * @returns the class name
  9856. */
  9857. getClassName(): string;
  9858. /** @hidden */
  9859. readonly _isLight: boolean;
  9860. /**
  9861. * Converts the light information to a readable string for debug purpose.
  9862. * @param fullDetails Supports for multiple levels of logging within scene loading
  9863. * @returns the human readable light info
  9864. */
  9865. toString(fullDetails?: boolean): string;
  9866. /** @hidden */
  9867. protected _syncParentEnabledState(): void;
  9868. /**
  9869. * Set the enabled state of this node.
  9870. * @param value - the new enabled state
  9871. */
  9872. setEnabled(value: boolean): void;
  9873. /**
  9874. * Returns the Light associated shadow generator if any.
  9875. * @return the associated shadow generator.
  9876. */
  9877. getShadowGenerator(): Nullable<IShadowGenerator>;
  9878. /**
  9879. * Returns a Vector3, the absolute light position in the World.
  9880. * @returns the world space position of the light
  9881. */
  9882. getAbsolutePosition(): Vector3;
  9883. /**
  9884. * Specifies if the light will affect the passed mesh.
  9885. * @param mesh The mesh to test against the light
  9886. * @return true the mesh is affected otherwise, false.
  9887. */
  9888. canAffectMesh(mesh: AbstractMesh): boolean;
  9889. /**
  9890. * Sort function to order lights for rendering.
  9891. * @param a First Light object to compare to second.
  9892. * @param b Second Light object to compare first.
  9893. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9894. */
  9895. static CompareLightsPriority(a: Light, b: Light): number;
  9896. /**
  9897. * Releases resources associated with this node.
  9898. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9899. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9900. */
  9901. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9902. /**
  9903. * Returns the light type ID (integer).
  9904. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9905. */
  9906. getTypeID(): number;
  9907. /**
  9908. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9909. * @returns the scaled intensity in intensity mode unit
  9910. */
  9911. getScaledIntensity(): number;
  9912. /**
  9913. * Returns a new Light object, named "name", from the current one.
  9914. * @param name The name of the cloned light
  9915. * @returns the new created light
  9916. */
  9917. clone(name: string): Nullable<Light>;
  9918. /**
  9919. * Serializes the current light into a Serialization object.
  9920. * @returns the serialized object.
  9921. */
  9922. serialize(): any;
  9923. /**
  9924. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9925. * This new light is named "name" and added to the passed scene.
  9926. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9927. * @param name The friendly name of the light
  9928. * @param scene The scene the new light will belong to
  9929. * @returns the constructor function
  9930. */
  9931. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9932. /**
  9933. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9934. * @param parsedLight The JSON representation of the light
  9935. * @param scene The scene to create the parsed light in
  9936. * @returns the created light after parsing
  9937. */
  9938. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9939. private _hookArrayForExcluded;
  9940. private _hookArrayForIncludedOnly;
  9941. private _resyncMeshes;
  9942. /**
  9943. * Forces the meshes to update their light related information in their rendering used effects
  9944. * @hidden Internal Use Only
  9945. */
  9946. _markMeshesAsLightDirty(): void;
  9947. /**
  9948. * Recomputes the cached photometric scale if needed.
  9949. */
  9950. private _computePhotometricScale;
  9951. /**
  9952. * Returns the Photometric Scale according to the light type and intensity mode.
  9953. */
  9954. private _getPhotometricScale;
  9955. /**
  9956. * Reorder the light in the scene according to their defined priority.
  9957. * @hidden Internal Use Only
  9958. */
  9959. _reorderLightsInScene(): void;
  9960. /**
  9961. * Prepares the list of defines specific to the light type.
  9962. * @param defines the list of defines
  9963. * @param lightIndex defines the index of the light for the effect
  9964. */
  9965. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9966. }
  9967. }
  9968. declare module BABYLON {
  9969. /**
  9970. * Interface used to define Action
  9971. */
  9972. export interface IAction {
  9973. /**
  9974. * Trigger for the action
  9975. */
  9976. trigger: number;
  9977. /** Options of the trigger */
  9978. triggerOptions: any;
  9979. /**
  9980. * Gets the trigger parameters
  9981. * @returns the trigger parameters
  9982. */
  9983. getTriggerParameter(): any;
  9984. /**
  9985. * Internal only - executes current action event
  9986. * @hidden
  9987. */
  9988. _executeCurrent(evt?: ActionEvent): void;
  9989. /**
  9990. * Serialize placeholder for child classes
  9991. * @param parent of child
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. /**
  9996. * Internal only
  9997. * @hidden
  9998. */
  9999. _prepare(): void;
  10000. /**
  10001. * Internal only - manager for action
  10002. * @hidden
  10003. */
  10004. _actionManager: AbstractActionManager;
  10005. /**
  10006. * Adds action to chain of actions, may be a DoNothingAction
  10007. * @param action defines the next action to execute
  10008. * @returns The action passed in
  10009. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10010. */
  10011. then(action: IAction): IAction;
  10012. }
  10013. /**
  10014. * The action to be carried out following a trigger
  10015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10016. */
  10017. export class Action implements IAction {
  10018. /** the trigger, with or without parameters, for the action */
  10019. triggerOptions: any;
  10020. /**
  10021. * Trigger for the action
  10022. */
  10023. trigger: number;
  10024. /**
  10025. * Internal only - manager for action
  10026. * @hidden
  10027. */
  10028. _actionManager: ActionManager;
  10029. private _nextActiveAction;
  10030. private _child;
  10031. private _condition?;
  10032. private _triggerParameter;
  10033. /**
  10034. * An event triggered prior to action being executed.
  10035. */
  10036. onBeforeExecuteObservable: Observable<Action>;
  10037. /**
  10038. * Creates a new Action
  10039. * @param triggerOptions the trigger, with or without parameters, for the action
  10040. * @param condition an optional determinant of action
  10041. */
  10042. constructor(
  10043. /** the trigger, with or without parameters, for the action */
  10044. triggerOptions: any, condition?: Condition);
  10045. /**
  10046. * Internal only
  10047. * @hidden
  10048. */
  10049. _prepare(): void;
  10050. /**
  10051. * Gets the trigger parameters
  10052. * @returns the trigger parameters
  10053. */
  10054. getTriggerParameter(): any;
  10055. /**
  10056. * Internal only - executes current action event
  10057. * @hidden
  10058. */
  10059. _executeCurrent(evt?: ActionEvent): void;
  10060. /**
  10061. * Execute placeholder for child classes
  10062. * @param evt optional action event
  10063. */
  10064. execute(evt?: ActionEvent): void;
  10065. /**
  10066. * Skips to next active action
  10067. */
  10068. skipToNextActiveAction(): void;
  10069. /**
  10070. * Adds action to chain of actions, may be a DoNothingAction
  10071. * @param action defines the next action to execute
  10072. * @returns The action passed in
  10073. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10074. */
  10075. then(action: Action): Action;
  10076. /**
  10077. * Internal only
  10078. * @hidden
  10079. */
  10080. _getProperty(propertyPath: string): string;
  10081. /**
  10082. * Internal only
  10083. * @hidden
  10084. */
  10085. _getEffectiveTarget(target: any, propertyPath: string): any;
  10086. /**
  10087. * Serialize placeholder for child classes
  10088. * @param parent of child
  10089. * @returns the serialized object
  10090. */
  10091. serialize(parent: any): any;
  10092. /**
  10093. * Internal only called by serialize
  10094. * @hidden
  10095. */
  10096. protected _serialize(serializedAction: any, parent?: any): any;
  10097. /**
  10098. * Internal only
  10099. * @hidden
  10100. */
  10101. static _SerializeValueAsString: (value: any) => string;
  10102. /**
  10103. * Internal only
  10104. * @hidden
  10105. */
  10106. static _GetTargetProperty: (target: Node | Scene) => {
  10107. name: string;
  10108. targetType: string;
  10109. value: string;
  10110. };
  10111. }
  10112. }
  10113. declare module BABYLON {
  10114. /**
  10115. * A Condition applied to an Action
  10116. */
  10117. export class Condition {
  10118. /**
  10119. * Internal only - manager for action
  10120. * @hidden
  10121. */
  10122. _actionManager: ActionManager;
  10123. /**
  10124. * Internal only
  10125. * @hidden
  10126. */
  10127. _evaluationId: number;
  10128. /**
  10129. * Internal only
  10130. * @hidden
  10131. */
  10132. _currentResult: boolean;
  10133. /**
  10134. * Creates a new Condition
  10135. * @param actionManager the manager of the action the condition is applied to
  10136. */
  10137. constructor(actionManager: ActionManager);
  10138. /**
  10139. * Check if the current condition is valid
  10140. * @returns a boolean
  10141. */
  10142. isValid(): boolean;
  10143. /**
  10144. * Internal only
  10145. * @hidden
  10146. */
  10147. _getProperty(propertyPath: string): string;
  10148. /**
  10149. * Internal only
  10150. * @hidden
  10151. */
  10152. _getEffectiveTarget(target: any, propertyPath: string): any;
  10153. /**
  10154. * Serialize placeholder for child classes
  10155. * @returns the serialized object
  10156. */
  10157. serialize(): any;
  10158. /**
  10159. * Internal only
  10160. * @hidden
  10161. */
  10162. protected _serialize(serializedCondition: any): any;
  10163. }
  10164. /**
  10165. * Defines specific conditional operators as extensions of Condition
  10166. */
  10167. export class ValueCondition extends Condition {
  10168. /** path to specify the property of the target the conditional operator uses */
  10169. propertyPath: string;
  10170. /** the value compared by the conditional operator against the current value of the property */
  10171. value: any;
  10172. /** the conditional operator, default ValueCondition.IsEqual */
  10173. operator: number;
  10174. /**
  10175. * Internal only
  10176. * @hidden
  10177. */
  10178. private static _IsEqual;
  10179. /**
  10180. * Internal only
  10181. * @hidden
  10182. */
  10183. private static _IsDifferent;
  10184. /**
  10185. * Internal only
  10186. * @hidden
  10187. */
  10188. private static _IsGreater;
  10189. /**
  10190. * Internal only
  10191. * @hidden
  10192. */
  10193. private static _IsLesser;
  10194. /**
  10195. * returns the number for IsEqual
  10196. */
  10197. static readonly IsEqual: number;
  10198. /**
  10199. * Returns the number for IsDifferent
  10200. */
  10201. static readonly IsDifferent: number;
  10202. /**
  10203. * Returns the number for IsGreater
  10204. */
  10205. static readonly IsGreater: number;
  10206. /**
  10207. * Returns the number for IsLesser
  10208. */
  10209. static readonly IsLesser: number;
  10210. /**
  10211. * Internal only The action manager for the condition
  10212. * @hidden
  10213. */
  10214. _actionManager: ActionManager;
  10215. /**
  10216. * Internal only
  10217. * @hidden
  10218. */
  10219. private _target;
  10220. /**
  10221. * Internal only
  10222. * @hidden
  10223. */
  10224. private _effectiveTarget;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. private _property;
  10230. /**
  10231. * Creates a new ValueCondition
  10232. * @param actionManager manager for the action the condition applies to
  10233. * @param target for the action
  10234. * @param propertyPath path to specify the property of the target the conditional operator uses
  10235. * @param value the value compared by the conditional operator against the current value of the property
  10236. * @param operator the conditional operator, default ValueCondition.IsEqual
  10237. */
  10238. constructor(actionManager: ActionManager, target: any,
  10239. /** path to specify the property of the target the conditional operator uses */
  10240. propertyPath: string,
  10241. /** the value compared by the conditional operator against the current value of the property */
  10242. value: any,
  10243. /** the conditional operator, default ValueCondition.IsEqual */
  10244. operator?: number);
  10245. /**
  10246. * Compares the given value with the property value for the specified conditional operator
  10247. * @returns the result of the comparison
  10248. */
  10249. isValid(): boolean;
  10250. /**
  10251. * Serialize the ValueCondition into a JSON compatible object
  10252. * @returns serialization object
  10253. */
  10254. serialize(): any;
  10255. /**
  10256. * Gets the name of the conditional operator for the ValueCondition
  10257. * @param operator the conditional operator
  10258. * @returns the name
  10259. */
  10260. static GetOperatorName(operator: number): string;
  10261. }
  10262. /**
  10263. * Defines a predicate condition as an extension of Condition
  10264. */
  10265. export class PredicateCondition extends Condition {
  10266. /** defines the predicate function used to validate the condition */
  10267. predicate: () => boolean;
  10268. /**
  10269. * Internal only - manager for action
  10270. * @hidden
  10271. */
  10272. _actionManager: ActionManager;
  10273. /**
  10274. * Creates a new PredicateCondition
  10275. * @param actionManager manager for the action the condition applies to
  10276. * @param predicate defines the predicate function used to validate the condition
  10277. */
  10278. constructor(actionManager: ActionManager,
  10279. /** defines the predicate function used to validate the condition */
  10280. predicate: () => boolean);
  10281. /**
  10282. * @returns the validity of the predicate condition
  10283. */
  10284. isValid(): boolean;
  10285. }
  10286. /**
  10287. * Defines a state condition as an extension of Condition
  10288. */
  10289. export class StateCondition extends Condition {
  10290. /** Value to compare with target state */
  10291. value: string;
  10292. /**
  10293. * Internal only - manager for action
  10294. * @hidden
  10295. */
  10296. _actionManager: ActionManager;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. private _target;
  10302. /**
  10303. * Creates a new StateCondition
  10304. * @param actionManager manager for the action the condition applies to
  10305. * @param target of the condition
  10306. * @param value to compare with target state
  10307. */
  10308. constructor(actionManager: ActionManager, target: any,
  10309. /** Value to compare with target state */
  10310. value: string);
  10311. /**
  10312. * Gets a boolean indicating if the current condition is met
  10313. * @returns the validity of the state
  10314. */
  10315. isValid(): boolean;
  10316. /**
  10317. * Serialize the StateCondition into a JSON compatible object
  10318. * @returns serialization object
  10319. */
  10320. serialize(): any;
  10321. }
  10322. }
  10323. declare module BABYLON {
  10324. /**
  10325. * This defines an action responsible to toggle a boolean once triggered.
  10326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10327. */
  10328. export class SwitchBooleanAction extends Action {
  10329. /**
  10330. * The path to the boolean property in the target object
  10331. */
  10332. propertyPath: string;
  10333. private _target;
  10334. private _effectiveTarget;
  10335. private _property;
  10336. /**
  10337. * Instantiate the action
  10338. * @param triggerOptions defines the trigger options
  10339. * @param target defines the object containing the boolean
  10340. * @param propertyPath defines the path to the boolean property in the target object
  10341. * @param condition defines the trigger related conditions
  10342. */
  10343. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10344. /** @hidden */
  10345. _prepare(): void;
  10346. /**
  10347. * Execute the action toggle the boolean value.
  10348. */
  10349. execute(): void;
  10350. /**
  10351. * Serializes the actions and its related information.
  10352. * @param parent defines the object to serialize in
  10353. * @returns the serialized object
  10354. */
  10355. serialize(parent: any): any;
  10356. }
  10357. /**
  10358. * This defines an action responsible to set a the state field of the target
  10359. * to a desired value once triggered.
  10360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10361. */
  10362. export class SetStateAction extends Action {
  10363. /**
  10364. * The value to store in the state field.
  10365. */
  10366. value: string;
  10367. private _target;
  10368. /**
  10369. * Instantiate the action
  10370. * @param triggerOptions defines the trigger options
  10371. * @param target defines the object containing the state property
  10372. * @param value defines the value to store in the state field
  10373. * @param condition defines the trigger related conditions
  10374. */
  10375. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10376. /**
  10377. * Execute the action and store the value on the target state property.
  10378. */
  10379. execute(): void;
  10380. /**
  10381. * Serializes the actions and its related information.
  10382. * @param parent defines the object to serialize in
  10383. * @returns the serialized object
  10384. */
  10385. serialize(parent: any): any;
  10386. }
  10387. /**
  10388. * This defines an action responsible to set a property of the target
  10389. * to a desired value once triggered.
  10390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10391. */
  10392. export class SetValueAction extends Action {
  10393. /**
  10394. * The path of the property to set in the target.
  10395. */
  10396. propertyPath: string;
  10397. /**
  10398. * The value to set in the property
  10399. */
  10400. value: any;
  10401. private _target;
  10402. private _effectiveTarget;
  10403. private _property;
  10404. /**
  10405. * Instantiate the action
  10406. * @param triggerOptions defines the trigger options
  10407. * @param target defines the object containing the property
  10408. * @param propertyPath defines the path of the property to set in the target
  10409. * @param value defines the value to set in the property
  10410. * @param condition defines the trigger related conditions
  10411. */
  10412. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10413. /** @hidden */
  10414. _prepare(): void;
  10415. /**
  10416. * Execute the action and set the targetted property to the desired value.
  10417. */
  10418. execute(): void;
  10419. /**
  10420. * Serializes the actions and its related information.
  10421. * @param parent defines the object to serialize in
  10422. * @returns the serialized object
  10423. */
  10424. serialize(parent: any): any;
  10425. }
  10426. /**
  10427. * This defines an action responsible to increment the target value
  10428. * to a desired value once triggered.
  10429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10430. */
  10431. export class IncrementValueAction extends Action {
  10432. /**
  10433. * The path of the property to increment in the target.
  10434. */
  10435. propertyPath: string;
  10436. /**
  10437. * The value we should increment the property by.
  10438. */
  10439. value: any;
  10440. private _target;
  10441. private _effectiveTarget;
  10442. private _property;
  10443. /**
  10444. * Instantiate the action
  10445. * @param triggerOptions defines the trigger options
  10446. * @param target defines the object containing the property
  10447. * @param propertyPath defines the path of the property to increment in the target
  10448. * @param value defines the value value we should increment the property by
  10449. * @param condition defines the trigger related conditions
  10450. */
  10451. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10452. /** @hidden */
  10453. _prepare(): void;
  10454. /**
  10455. * Execute the action and increment the target of the value amount.
  10456. */
  10457. execute(): void;
  10458. /**
  10459. * Serializes the actions and its related information.
  10460. * @param parent defines the object to serialize in
  10461. * @returns the serialized object
  10462. */
  10463. serialize(parent: any): any;
  10464. }
  10465. /**
  10466. * This defines an action responsible to start an animation once triggered.
  10467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10468. */
  10469. export class PlayAnimationAction extends Action {
  10470. /**
  10471. * Where the animation should start (animation frame)
  10472. */
  10473. from: number;
  10474. /**
  10475. * Where the animation should stop (animation frame)
  10476. */
  10477. to: number;
  10478. /**
  10479. * Define if the animation should loop or stop after the first play.
  10480. */
  10481. loop?: boolean;
  10482. private _target;
  10483. /**
  10484. * Instantiate the action
  10485. * @param triggerOptions defines the trigger options
  10486. * @param target defines the target animation or animation name
  10487. * @param from defines from where the animation should start (animation frame)
  10488. * @param end defines where the animation should stop (animation frame)
  10489. * @param loop defines if the animation should loop or stop after the first play
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action and play the animation.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to stop an animation once triggered.
  10508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10509. */
  10510. export class StopAnimationAction extends Action {
  10511. private _target;
  10512. /**
  10513. * Instantiate the action
  10514. * @param triggerOptions defines the trigger options
  10515. * @param target defines the target animation or animation name
  10516. * @param condition defines the trigger related conditions
  10517. */
  10518. constructor(triggerOptions: any, target: any, condition?: Condition);
  10519. /** @hidden */
  10520. _prepare(): void;
  10521. /**
  10522. * Execute the action and stop the animation.
  10523. */
  10524. execute(): void;
  10525. /**
  10526. * Serializes the actions and its related information.
  10527. * @param parent defines the object to serialize in
  10528. * @returns the serialized object
  10529. */
  10530. serialize(parent: any): any;
  10531. }
  10532. /**
  10533. * This defines an action responsible that does nothing once triggered.
  10534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10535. */
  10536. export class DoNothingAction extends Action {
  10537. /**
  10538. * Instantiate the action
  10539. * @param triggerOptions defines the trigger options
  10540. * @param condition defines the trigger related conditions
  10541. */
  10542. constructor(triggerOptions?: any, condition?: Condition);
  10543. /**
  10544. * Execute the action and do nothing.
  10545. */
  10546. execute(): void;
  10547. /**
  10548. * Serializes the actions and its related information.
  10549. * @param parent defines the object to serialize in
  10550. * @returns the serialized object
  10551. */
  10552. serialize(parent: any): any;
  10553. }
  10554. /**
  10555. * This defines an action responsible to trigger several actions once triggered.
  10556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10557. */
  10558. export class CombineAction extends Action {
  10559. /**
  10560. * The list of aggregated animations to run.
  10561. */
  10562. children: Action[];
  10563. /**
  10564. * Instantiate the action
  10565. * @param triggerOptions defines the trigger options
  10566. * @param children defines the list of aggregated animations to run
  10567. * @param condition defines the trigger related conditions
  10568. */
  10569. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10570. /** @hidden */
  10571. _prepare(): void;
  10572. /**
  10573. * Execute the action and executes all the aggregated actions.
  10574. */
  10575. execute(evt: ActionEvent): void;
  10576. /**
  10577. * Serializes the actions and its related information.
  10578. * @param parent defines the object to serialize in
  10579. * @returns the serialized object
  10580. */
  10581. serialize(parent: any): any;
  10582. }
  10583. /**
  10584. * This defines an action responsible to run code (external event) once triggered.
  10585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10586. */
  10587. export class ExecuteCodeAction extends Action {
  10588. /**
  10589. * The callback function to run.
  10590. */
  10591. func: (evt: ActionEvent) => void;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param func defines the callback function to run
  10596. * @param condition defines the trigger related conditions
  10597. */
  10598. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10599. /**
  10600. * Execute the action and run the attached code.
  10601. */
  10602. execute(evt: ActionEvent): void;
  10603. }
  10604. /**
  10605. * This defines an action responsible to set the parent property of the target once triggered.
  10606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10607. */
  10608. export class SetParentAction extends Action {
  10609. private _parent;
  10610. private _target;
  10611. /**
  10612. * Instantiate the action
  10613. * @param triggerOptions defines the trigger options
  10614. * @param target defines the target containing the parent property
  10615. * @param parent defines from where the animation should start (animation frame)
  10616. * @param condition defines the trigger related conditions
  10617. */
  10618. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10619. /** @hidden */
  10620. _prepare(): void;
  10621. /**
  10622. * Execute the action and set the parent property.
  10623. */
  10624. execute(): void;
  10625. /**
  10626. * Serializes the actions and its related information.
  10627. * @param parent defines the object to serialize in
  10628. * @returns the serialized object
  10629. */
  10630. serialize(parent: any): any;
  10631. }
  10632. }
  10633. declare module BABYLON {
  10634. /**
  10635. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10636. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10638. */
  10639. export class ActionManager extends AbstractActionManager {
  10640. /**
  10641. * Nothing
  10642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10643. */
  10644. static readonly NothingTrigger: number;
  10645. /**
  10646. * On pick
  10647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10648. */
  10649. static readonly OnPickTrigger: number;
  10650. /**
  10651. * On left pick
  10652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10653. */
  10654. static readonly OnLeftPickTrigger: number;
  10655. /**
  10656. * On right pick
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10658. */
  10659. static readonly OnRightPickTrigger: number;
  10660. /**
  10661. * On center pick
  10662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10663. */
  10664. static readonly OnCenterPickTrigger: number;
  10665. /**
  10666. * On pick down
  10667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10668. */
  10669. static readonly OnPickDownTrigger: number;
  10670. /**
  10671. * On double pick
  10672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10673. */
  10674. static readonly OnDoublePickTrigger: number;
  10675. /**
  10676. * On pick up
  10677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10678. */
  10679. static readonly OnPickUpTrigger: number;
  10680. /**
  10681. * On pick out.
  10682. * This trigger will only be raised if you also declared a OnPickDown
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10684. */
  10685. static readonly OnPickOutTrigger: number;
  10686. /**
  10687. * On long press
  10688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10689. */
  10690. static readonly OnLongPressTrigger: number;
  10691. /**
  10692. * On pointer over
  10693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10694. */
  10695. static readonly OnPointerOverTrigger: number;
  10696. /**
  10697. * On pointer out
  10698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10699. */
  10700. static readonly OnPointerOutTrigger: number;
  10701. /**
  10702. * On every frame
  10703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10704. */
  10705. static readonly OnEveryFrameTrigger: number;
  10706. /**
  10707. * On intersection enter
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10709. */
  10710. static readonly OnIntersectionEnterTrigger: number;
  10711. /**
  10712. * On intersection exit
  10713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10714. */
  10715. static readonly OnIntersectionExitTrigger: number;
  10716. /**
  10717. * On key down
  10718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10719. */
  10720. static readonly OnKeyDownTrigger: number;
  10721. /**
  10722. * On key up
  10723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10724. */
  10725. static readonly OnKeyUpTrigger: number;
  10726. private _scene;
  10727. /**
  10728. * Creates a new action manager
  10729. * @param scene defines the hosting scene
  10730. */
  10731. constructor(scene: Scene);
  10732. /**
  10733. * Releases all associated resources
  10734. */
  10735. dispose(): void;
  10736. /**
  10737. * Gets hosting scene
  10738. * @returns the hosting scene
  10739. */
  10740. getScene(): Scene;
  10741. /**
  10742. * Does this action manager handles actions of any of the given triggers
  10743. * @param triggers defines the triggers to be tested
  10744. * @return a boolean indicating whether one (or more) of the triggers is handled
  10745. */
  10746. hasSpecificTriggers(triggers: number[]): boolean;
  10747. /**
  10748. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10749. * speed.
  10750. * @param triggerA defines the trigger to be tested
  10751. * @param triggerB defines the trigger to be tested
  10752. * @return a boolean indicating whether one (or more) of the triggers is handled
  10753. */
  10754. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10755. /**
  10756. * Does this action manager handles actions of a given trigger
  10757. * @param trigger defines the trigger to be tested
  10758. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10759. * @return whether the trigger is handled
  10760. */
  10761. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10762. /**
  10763. * Does this action manager has pointer triggers
  10764. */
  10765. readonly hasPointerTriggers: boolean;
  10766. /**
  10767. * Does this action manager has pick triggers
  10768. */
  10769. readonly hasPickTriggers: boolean;
  10770. /**
  10771. * Registers an action to this action manager
  10772. * @param action defines the action to be registered
  10773. * @return the action amended (prepared) after registration
  10774. */
  10775. registerAction(action: IAction): Nullable<IAction>;
  10776. /**
  10777. * Unregisters an action to this action manager
  10778. * @param action defines the action to be unregistered
  10779. * @return a boolean indicating whether the action has been unregistered
  10780. */
  10781. unregisterAction(action: IAction): Boolean;
  10782. /**
  10783. * Process a specific trigger
  10784. * @param trigger defines the trigger to process
  10785. * @param evt defines the event details to be processed
  10786. */
  10787. processTrigger(trigger: number, evt?: IActionEvent): void;
  10788. /** @hidden */
  10789. _getEffectiveTarget(target: any, propertyPath: string): any;
  10790. /** @hidden */
  10791. _getProperty(propertyPath: string): string;
  10792. /**
  10793. * Serialize this manager to a JSON object
  10794. * @param name defines the property name to store this manager
  10795. * @returns a JSON representation of this manager
  10796. */
  10797. serialize(name: string): any;
  10798. /**
  10799. * Creates a new ActionManager from a JSON data
  10800. * @param parsedActions defines the JSON data to read from
  10801. * @param object defines the hosting mesh
  10802. * @param scene defines the hosting scene
  10803. */
  10804. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10805. /**
  10806. * Get a trigger name by index
  10807. * @param trigger defines the trigger index
  10808. * @returns a trigger name
  10809. */
  10810. static GetTriggerName(trigger: number): string;
  10811. }
  10812. }
  10813. declare module BABYLON {
  10814. /**
  10815. * Class representing a ray with position and direction
  10816. */
  10817. export class Ray {
  10818. /** origin point */
  10819. origin: Vector3;
  10820. /** direction */
  10821. direction: Vector3;
  10822. /** length of the ray */
  10823. length: number;
  10824. private static readonly TmpVector3;
  10825. private _tmpRay;
  10826. /**
  10827. * Creates a new ray
  10828. * @param origin origin point
  10829. * @param direction direction
  10830. * @param length length of the ray
  10831. */
  10832. constructor(
  10833. /** origin point */
  10834. origin: Vector3,
  10835. /** direction */
  10836. direction: Vector3,
  10837. /** length of the ray */
  10838. length?: number);
  10839. /**
  10840. * Checks if the ray intersects a box
  10841. * @param minimum bound of the box
  10842. * @param maximum bound of the box
  10843. * @param intersectionTreshold extra extend to be added to the box in all direction
  10844. * @returns if the box was hit
  10845. */
  10846. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10847. /**
  10848. * Checks if the ray intersects a box
  10849. * @param box the bounding box to check
  10850. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10851. * @returns if the box was hit
  10852. */
  10853. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10854. /**
  10855. * If the ray hits a sphere
  10856. * @param sphere the bounding sphere to check
  10857. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10858. * @returns true if it hits the sphere
  10859. */
  10860. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10861. /**
  10862. * If the ray hits a triange
  10863. * @param vertex0 triangle vertex
  10864. * @param vertex1 triangle vertex
  10865. * @param vertex2 triangle vertex
  10866. * @returns intersection information if hit
  10867. */
  10868. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10869. /**
  10870. * Checks if ray intersects a plane
  10871. * @param plane the plane to check
  10872. * @returns the distance away it was hit
  10873. */
  10874. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10875. /**
  10876. * Calculate the intercept of a ray on a given axis
  10877. * @param axis to check 'x' | 'y' | 'z'
  10878. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10879. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10880. */
  10881. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10882. /**
  10883. * Checks if ray intersects a mesh
  10884. * @param mesh the mesh to check
  10885. * @param fastCheck if only the bounding box should checked
  10886. * @returns picking info of the intersecton
  10887. */
  10888. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10889. /**
  10890. * Checks if ray intersects a mesh
  10891. * @param meshes the meshes to check
  10892. * @param fastCheck if only the bounding box should checked
  10893. * @param results array to store result in
  10894. * @returns Array of picking infos
  10895. */
  10896. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10897. private _comparePickingInfo;
  10898. private static smallnum;
  10899. private static rayl;
  10900. /**
  10901. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10902. * @param sega the first point of the segment to test the intersection against
  10903. * @param segb the second point of the segment to test the intersection against
  10904. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10905. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10906. */
  10907. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10908. /**
  10909. * Update the ray from viewport position
  10910. * @param x position
  10911. * @param y y position
  10912. * @param viewportWidth viewport width
  10913. * @param viewportHeight viewport height
  10914. * @param world world matrix
  10915. * @param view view matrix
  10916. * @param projection projection matrix
  10917. * @returns this ray updated
  10918. */
  10919. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10920. /**
  10921. * Creates a ray with origin and direction of 0,0,0
  10922. * @returns the new ray
  10923. */
  10924. static Zero(): Ray;
  10925. /**
  10926. * Creates a new ray from screen space and viewport
  10927. * @param x position
  10928. * @param y y position
  10929. * @param viewportWidth viewport width
  10930. * @param viewportHeight viewport height
  10931. * @param world world matrix
  10932. * @param view view matrix
  10933. * @param projection projection matrix
  10934. * @returns new ray
  10935. */
  10936. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10937. /**
  10938. * 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
  10939. * transformed to the given world matrix.
  10940. * @param origin The origin point
  10941. * @param end The end point
  10942. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10943. * @returns the new ray
  10944. */
  10945. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10946. /**
  10947. * Transforms a ray by a matrix
  10948. * @param ray ray to transform
  10949. * @param matrix matrix to apply
  10950. * @returns the resulting new ray
  10951. */
  10952. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10953. /**
  10954. * Transforms a ray by a matrix
  10955. * @param ray ray to transform
  10956. * @param matrix matrix to apply
  10957. * @param result ray to store result in
  10958. */
  10959. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10960. /**
  10961. * Unproject a ray from screen space to object space
  10962. * @param sourceX defines the screen space x coordinate to use
  10963. * @param sourceY defines the screen space y coordinate to use
  10964. * @param viewportWidth defines the current width of the viewport
  10965. * @param viewportHeight defines the current height of the viewport
  10966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10967. * @param view defines the view matrix to use
  10968. * @param projection defines the projection matrix to use
  10969. */
  10970. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10971. }
  10972. /**
  10973. * Type used to define predicate used to select faces when a mesh intersection is detected
  10974. */
  10975. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10976. interface Scene {
  10977. /** @hidden */
  10978. _tempPickingRay: Nullable<Ray>;
  10979. /** @hidden */
  10980. _cachedRayForTransform: Ray;
  10981. /** @hidden */
  10982. _pickWithRayInverseMatrix: Matrix;
  10983. /** @hidden */
  10984. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10985. /** @hidden */
  10986. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10987. }
  10988. }
  10989. declare module BABYLON {
  10990. /**
  10991. * Groups all the scene component constants in one place to ease maintenance.
  10992. * @hidden
  10993. */
  10994. export class SceneComponentConstants {
  10995. static readonly NAME_EFFECTLAYER: string;
  10996. static readonly NAME_LAYER: string;
  10997. static readonly NAME_LENSFLARESYSTEM: string;
  10998. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10999. static readonly NAME_PARTICLESYSTEM: string;
  11000. static readonly NAME_GAMEPAD: string;
  11001. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11002. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11003. static readonly NAME_DEPTHRENDERER: string;
  11004. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11005. static readonly NAME_SPRITE: string;
  11006. static readonly NAME_OUTLINERENDERER: string;
  11007. static readonly NAME_PROCEDURALTEXTURE: string;
  11008. static readonly NAME_SHADOWGENERATOR: string;
  11009. static readonly NAME_OCTREE: string;
  11010. static readonly NAME_PHYSICSENGINE: string;
  11011. static readonly NAME_AUDIO: string;
  11012. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11013. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11014. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11015. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11016. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11017. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11018. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11019. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11020. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11021. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11022. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11023. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11024. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11025. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11026. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11027. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11028. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11029. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11030. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11031. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11032. static readonly STEP_AFTERRENDER_AUDIO: number;
  11033. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11034. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11035. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11036. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11037. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11038. static readonly STEP_POINTERMOVE_SPRITE: number;
  11039. static readonly STEP_POINTERDOWN_SPRITE: number;
  11040. static readonly STEP_POINTERUP_SPRITE: number;
  11041. }
  11042. /**
  11043. * This represents a scene component.
  11044. *
  11045. * This is used to decouple the dependency the scene is having on the different workloads like
  11046. * layers, post processes...
  11047. */
  11048. export interface ISceneComponent {
  11049. /**
  11050. * The name of the component. Each component must have a unique name.
  11051. */
  11052. name: string;
  11053. /**
  11054. * The scene the component belongs to.
  11055. */
  11056. scene: Scene;
  11057. /**
  11058. * Register the component to one instance of a scene.
  11059. */
  11060. register(): void;
  11061. /**
  11062. * Rebuilds the elements related to this component in case of
  11063. * context lost for instance.
  11064. */
  11065. rebuild(): void;
  11066. /**
  11067. * Disposes the component and the associated ressources.
  11068. */
  11069. dispose(): void;
  11070. }
  11071. /**
  11072. * This represents a SERIALIZABLE scene component.
  11073. *
  11074. * This extends Scene Component to add Serialization methods on top.
  11075. */
  11076. export interface ISceneSerializableComponent extends ISceneComponent {
  11077. /**
  11078. * Adds all the elements from the container to the scene
  11079. * @param container the container holding the elements
  11080. */
  11081. addFromContainer(container: AbstractScene): void;
  11082. /**
  11083. * Removes all the elements in the container from the scene
  11084. * @param container contains the elements to remove
  11085. * @param dispose if the removed element should be disposed (default: false)
  11086. */
  11087. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11088. /**
  11089. * Serializes the component data to the specified json object
  11090. * @param serializationObject The object to serialize to
  11091. */
  11092. serialize(serializationObject: any): void;
  11093. }
  11094. /**
  11095. * Strong typing of a Mesh related stage step action
  11096. */
  11097. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11098. /**
  11099. * Strong typing of a Evaluate Sub Mesh related stage step action
  11100. */
  11101. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11102. /**
  11103. * Strong typing of a Active Mesh related stage step action
  11104. */
  11105. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11106. /**
  11107. * Strong typing of a Camera related stage step action
  11108. */
  11109. export type CameraStageAction = (camera: Camera) => void;
  11110. /**
  11111. * Strong typing of a Camera Frame buffer related stage step action
  11112. */
  11113. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11114. /**
  11115. * Strong typing of a Render Target related stage step action
  11116. */
  11117. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11118. /**
  11119. * Strong typing of a RenderingGroup related stage step action
  11120. */
  11121. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11122. /**
  11123. * Strong typing of a Mesh Render related stage step action
  11124. */
  11125. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11126. /**
  11127. * Strong typing of a simple stage step action
  11128. */
  11129. export type SimpleStageAction = () => void;
  11130. /**
  11131. * Strong typing of a render target action.
  11132. */
  11133. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11134. /**
  11135. * Strong typing of a pointer move action.
  11136. */
  11137. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11138. /**
  11139. * Strong typing of a pointer up/down action.
  11140. */
  11141. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11142. /**
  11143. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11144. * @hidden
  11145. */
  11146. export class Stage<T extends Function> extends Array<{
  11147. index: number;
  11148. component: ISceneComponent;
  11149. action: T;
  11150. }> {
  11151. /**
  11152. * Hide ctor from the rest of the world.
  11153. * @param items The items to add.
  11154. */
  11155. private constructor();
  11156. /**
  11157. * Creates a new Stage.
  11158. * @returns A new instance of a Stage
  11159. */
  11160. static Create<T extends Function>(): Stage<T>;
  11161. /**
  11162. * Registers a step in an ordered way in the targeted stage.
  11163. * @param index Defines the position to register the step in
  11164. * @param component Defines the component attached to the step
  11165. * @param action Defines the action to launch during the step
  11166. */
  11167. registerStep(index: number, component: ISceneComponent, action: T): void;
  11168. /**
  11169. * Clears all the steps from the stage.
  11170. */
  11171. clear(): void;
  11172. }
  11173. }
  11174. declare module BABYLON {
  11175. interface Scene {
  11176. /** @hidden */
  11177. _pointerOverSprite: Nullable<Sprite>;
  11178. /** @hidden */
  11179. _pickedDownSprite: Nullable<Sprite>;
  11180. /** @hidden */
  11181. _tempSpritePickingRay: Nullable<Ray>;
  11182. /**
  11183. * All of the sprite managers added to this scene
  11184. * @see http://doc.babylonjs.com/babylon101/sprites
  11185. */
  11186. spriteManagers: Array<ISpriteManager>;
  11187. /**
  11188. * An event triggered when sprites rendering is about to start
  11189. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11190. */
  11191. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11192. /**
  11193. * An event triggered when sprites rendering is done
  11194. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11195. */
  11196. onAfterSpritesRenderingObservable: Observable<Scene>;
  11197. /** @hidden */
  11198. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11199. /** Launch a ray to try to pick a sprite in the scene
  11200. * @param x position on screen
  11201. * @param y position on screen
  11202. * @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
  11203. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11204. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11205. * @returns a PickingInfo
  11206. */
  11207. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11208. /** Use the given ray to pick a sprite in the scene
  11209. * @param ray The ray (in world space) to use to pick meshes
  11210. * @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
  11211. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11212. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11213. * @returns a PickingInfo
  11214. */
  11215. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11216. /**
  11217. * Force the sprite under the pointer
  11218. * @param sprite defines the sprite to use
  11219. */
  11220. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11221. /**
  11222. * Gets the sprite under the pointer
  11223. * @returns a Sprite or null if no sprite is under the pointer
  11224. */
  11225. getPointerOverSprite(): Nullable<Sprite>;
  11226. }
  11227. /**
  11228. * Defines the sprite scene component responsible to manage sprites
  11229. * in a given scene.
  11230. */
  11231. export class SpriteSceneComponent implements ISceneComponent {
  11232. /**
  11233. * The component name helpfull to identify the component in the list of scene components.
  11234. */
  11235. readonly name: string;
  11236. /**
  11237. * The scene the component belongs to.
  11238. */
  11239. scene: Scene;
  11240. /** @hidden */
  11241. private _spritePredicate;
  11242. /**
  11243. * Creates a new instance of the component for the given scene
  11244. * @param scene Defines the scene to register the component in
  11245. */
  11246. constructor(scene: Scene);
  11247. /**
  11248. * Registers the component in a given scene
  11249. */
  11250. register(): void;
  11251. /**
  11252. * Rebuilds the elements related to this component in case of
  11253. * context lost for instance.
  11254. */
  11255. rebuild(): void;
  11256. /**
  11257. * Disposes the component and the associated ressources.
  11258. */
  11259. dispose(): void;
  11260. private _pickSpriteButKeepRay;
  11261. private _pointerMove;
  11262. private _pointerDown;
  11263. private _pointerUp;
  11264. }
  11265. }
  11266. declare module BABYLON {
  11267. /** @hidden */
  11268. export var fogFragmentDeclaration: {
  11269. name: string;
  11270. shader: string;
  11271. };
  11272. }
  11273. declare module BABYLON {
  11274. /** @hidden */
  11275. export var fogFragment: {
  11276. name: string;
  11277. shader: string;
  11278. };
  11279. }
  11280. declare module BABYLON {
  11281. /** @hidden */
  11282. export var spritesPixelShader: {
  11283. name: string;
  11284. shader: string;
  11285. };
  11286. }
  11287. declare module BABYLON {
  11288. /** @hidden */
  11289. export var fogVertexDeclaration: {
  11290. name: string;
  11291. shader: string;
  11292. };
  11293. }
  11294. declare module BABYLON {
  11295. /** @hidden */
  11296. export var spritesVertexShader: {
  11297. name: string;
  11298. shader: string;
  11299. };
  11300. }
  11301. declare module BABYLON {
  11302. /**
  11303. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11304. */
  11305. export interface ISpriteManager extends IDisposable {
  11306. /**
  11307. * Restricts the camera to viewing objects with the same layerMask.
  11308. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11309. */
  11310. layerMask: number;
  11311. /**
  11312. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11313. */
  11314. isPickable: boolean;
  11315. /**
  11316. * Specifies the rendering group id for this mesh (0 by default)
  11317. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11318. */
  11319. renderingGroupId: number;
  11320. /**
  11321. * Defines the list of sprites managed by the manager.
  11322. */
  11323. sprites: Array<Sprite>;
  11324. /**
  11325. * Tests the intersection of a sprite with a specific ray.
  11326. * @param ray The ray we are sending to test the collision
  11327. * @param camera The camera space we are sending rays in
  11328. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11329. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11330. * @returns picking info or null.
  11331. */
  11332. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11333. /**
  11334. * Renders the list of sprites on screen.
  11335. */
  11336. render(): void;
  11337. }
  11338. /**
  11339. * Class used to manage multiple sprites on the same spritesheet
  11340. * @see http://doc.babylonjs.com/babylon101/sprites
  11341. */
  11342. export class SpriteManager implements ISpriteManager {
  11343. /** defines the manager's name */
  11344. name: string;
  11345. /** Gets the list of sprites */
  11346. sprites: Sprite[];
  11347. /** Gets or sets the rendering group id (0 by default) */
  11348. renderingGroupId: number;
  11349. /** Gets or sets camera layer mask */
  11350. layerMask: number;
  11351. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11352. fogEnabled: boolean;
  11353. /** Gets or sets a boolean indicating if the sprites are pickable */
  11354. isPickable: boolean;
  11355. /** Defines the default width of a cell in the spritesheet */
  11356. cellWidth: number;
  11357. /** Defines the default height of a cell in the spritesheet */
  11358. cellHeight: number;
  11359. /**
  11360. * An event triggered when the manager is disposed.
  11361. */
  11362. onDisposeObservable: Observable<SpriteManager>;
  11363. private _onDisposeObserver;
  11364. /**
  11365. * Callback called when the manager is disposed
  11366. */
  11367. onDispose: () => void;
  11368. private _capacity;
  11369. private _spriteTexture;
  11370. private _epsilon;
  11371. private _scene;
  11372. private _vertexData;
  11373. private _buffer;
  11374. private _vertexBuffers;
  11375. private _indexBuffer;
  11376. private _effectBase;
  11377. private _effectFog;
  11378. /**
  11379. * Gets or sets the spritesheet texture
  11380. */
  11381. texture: Texture;
  11382. /**
  11383. * Creates a new sprite manager
  11384. * @param name defines the manager's name
  11385. * @param imgUrl defines the sprite sheet url
  11386. * @param capacity defines the maximum allowed number of sprites
  11387. * @param cellSize defines the size of a sprite cell
  11388. * @param scene defines the hosting scene
  11389. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11390. * @param samplingMode defines the smapling mode to use with spritesheet
  11391. */
  11392. constructor(
  11393. /** defines the manager's name */
  11394. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11395. private _appendSpriteVertex;
  11396. /**
  11397. * Intersects the sprites with a ray
  11398. * @param ray defines the ray to intersect with
  11399. * @param camera defines the current active camera
  11400. * @param predicate defines a predicate used to select candidate sprites
  11401. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11402. * @returns null if no hit or a PickingInfo
  11403. */
  11404. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11405. /**
  11406. * Render all child sprites
  11407. */
  11408. render(): void;
  11409. /**
  11410. * Release associated resources
  11411. */
  11412. dispose(): void;
  11413. }
  11414. }
  11415. declare module BABYLON {
  11416. /**
  11417. * Class used to represent a sprite
  11418. * @see http://doc.babylonjs.com/babylon101/sprites
  11419. */
  11420. export class Sprite {
  11421. /** defines the name */
  11422. name: string;
  11423. /** Gets or sets the current world position */
  11424. position: Vector3;
  11425. /** Gets or sets the main color */
  11426. color: Color4;
  11427. /** Gets or sets the width */
  11428. width: number;
  11429. /** Gets or sets the height */
  11430. height: number;
  11431. /** Gets or sets rotation angle */
  11432. angle: number;
  11433. /** Gets or sets the cell index in the sprite sheet */
  11434. cellIndex: number;
  11435. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11436. invertU: number;
  11437. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11438. invertV: number;
  11439. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11440. disposeWhenFinishedAnimating: boolean;
  11441. /** Gets the list of attached animations */
  11442. animations: Animation[];
  11443. /** Gets or sets a boolean indicating if the sprite can be picked */
  11444. isPickable: boolean;
  11445. /**
  11446. * Gets or sets the associated action manager
  11447. */
  11448. actionManager: Nullable<ActionManager>;
  11449. private _animationStarted;
  11450. private _loopAnimation;
  11451. private _fromIndex;
  11452. private _toIndex;
  11453. private _delay;
  11454. private _direction;
  11455. private _manager;
  11456. private _time;
  11457. private _onAnimationEnd;
  11458. /**
  11459. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11460. */
  11461. isVisible: boolean;
  11462. /**
  11463. * Gets or sets the sprite size
  11464. */
  11465. size: number;
  11466. /**
  11467. * Creates a new Sprite
  11468. * @param name defines the name
  11469. * @param manager defines the manager
  11470. */
  11471. constructor(
  11472. /** defines the name */
  11473. name: string, manager: ISpriteManager);
  11474. /**
  11475. * Starts an animation
  11476. * @param from defines the initial key
  11477. * @param to defines the end key
  11478. * @param loop defines if the animation must loop
  11479. * @param delay defines the start delay (in ms)
  11480. * @param onAnimationEnd defines a callback to call when animation ends
  11481. */
  11482. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11483. /** Stops current animation (if any) */
  11484. stopAnimation(): void;
  11485. /** @hidden */
  11486. _animate(deltaTime: number): void;
  11487. /** Release associated resources */
  11488. dispose(): void;
  11489. }
  11490. }
  11491. declare module BABYLON {
  11492. /**
  11493. * Information about the result of picking within a scene
  11494. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11495. */
  11496. export class PickingInfo {
  11497. /** @hidden */
  11498. _pickingUnavailable: boolean;
  11499. /**
  11500. * If the pick collided with an object
  11501. */
  11502. hit: boolean;
  11503. /**
  11504. * Distance away where the pick collided
  11505. */
  11506. distance: number;
  11507. /**
  11508. * The location of pick collision
  11509. */
  11510. pickedPoint: Nullable<Vector3>;
  11511. /**
  11512. * The mesh corresponding the the pick collision
  11513. */
  11514. pickedMesh: Nullable<AbstractMesh>;
  11515. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11516. bu: number;
  11517. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11518. bv: number;
  11519. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11520. faceId: number;
  11521. /** Id of the the submesh that was picked */
  11522. subMeshId: number;
  11523. /** If a sprite was picked, this will be the sprite the pick collided with */
  11524. pickedSprite: Nullable<Sprite>;
  11525. /**
  11526. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11527. */
  11528. originMesh: Nullable<AbstractMesh>;
  11529. /**
  11530. * The ray that was used to perform the picking.
  11531. */
  11532. ray: Nullable<Ray>;
  11533. /**
  11534. * Gets the normal correspodning to the face the pick collided with
  11535. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11536. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11537. * @returns The normal correspodning to the face the pick collided with
  11538. */
  11539. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11540. /**
  11541. * Gets the texture coordinates of where the pick occured
  11542. * @returns the vector containing the coordnates of the texture
  11543. */
  11544. getTextureCoordinates(): Nullable<Vector2>;
  11545. }
  11546. }
  11547. declare module BABYLON {
  11548. /**
  11549. * Gather the list of pointer event types as constants.
  11550. */
  11551. export class PointerEventTypes {
  11552. /**
  11553. * 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.
  11554. */
  11555. static readonly POINTERDOWN: number;
  11556. /**
  11557. * The pointerup event is fired when a pointer is no longer active.
  11558. */
  11559. static readonly POINTERUP: number;
  11560. /**
  11561. * The pointermove event is fired when a pointer changes coordinates.
  11562. */
  11563. static readonly POINTERMOVE: number;
  11564. /**
  11565. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11566. */
  11567. static readonly POINTERWHEEL: number;
  11568. /**
  11569. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11570. */
  11571. static readonly POINTERPICK: number;
  11572. /**
  11573. * The pointertap event is fired when a the object has been touched and released without drag.
  11574. */
  11575. static readonly POINTERTAP: number;
  11576. /**
  11577. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11578. */
  11579. static readonly POINTERDOUBLETAP: number;
  11580. }
  11581. /**
  11582. * Base class of pointer info types.
  11583. */
  11584. export class PointerInfoBase {
  11585. /**
  11586. * Defines the type of event (PointerEventTypes)
  11587. */
  11588. type: number;
  11589. /**
  11590. * Defines the related dom event
  11591. */
  11592. event: PointerEvent | MouseWheelEvent;
  11593. /**
  11594. * Instantiates the base class of pointers info.
  11595. * @param type Defines the type of event (PointerEventTypes)
  11596. * @param event Defines the related dom event
  11597. */
  11598. constructor(
  11599. /**
  11600. * Defines the type of event (PointerEventTypes)
  11601. */
  11602. type: number,
  11603. /**
  11604. * Defines the related dom event
  11605. */
  11606. event: PointerEvent | MouseWheelEvent);
  11607. }
  11608. /**
  11609. * This class is used to store pointer related info for the onPrePointerObservable event.
  11610. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11611. */
  11612. export class PointerInfoPre extends PointerInfoBase {
  11613. /**
  11614. * Ray from a pointer if availible (eg. 6dof controller)
  11615. */
  11616. ray: Nullable<Ray>;
  11617. /**
  11618. * Defines the local position of the pointer on the canvas.
  11619. */
  11620. localPosition: Vector2;
  11621. /**
  11622. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11623. */
  11624. skipOnPointerObservable: boolean;
  11625. /**
  11626. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11627. * @param type Defines the type of event (PointerEventTypes)
  11628. * @param event Defines the related dom event
  11629. * @param localX Defines the local x coordinates of the pointer when the event occured
  11630. * @param localY Defines the local y coordinates of the pointer when the event occured
  11631. */
  11632. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11633. }
  11634. /**
  11635. * This type contains all the data related to a pointer event in Babylon.js.
  11636. * 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.
  11637. */
  11638. export class PointerInfo extends PointerInfoBase {
  11639. /**
  11640. * Defines the picking info associated to the info (if any)\
  11641. */
  11642. pickInfo: Nullable<PickingInfo>;
  11643. /**
  11644. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11645. * @param type Defines the type of event (PointerEventTypes)
  11646. * @param event Defines the related dom event
  11647. * @param pickInfo Defines the picking info associated to the info (if any)\
  11648. */
  11649. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11650. /**
  11651. * Defines the picking info associated to the info (if any)\
  11652. */
  11653. pickInfo: Nullable<PickingInfo>);
  11654. }
  11655. /**
  11656. * Data relating to a touch event on the screen.
  11657. */
  11658. export interface PointerTouch {
  11659. /**
  11660. * X coordinate of touch.
  11661. */
  11662. x: number;
  11663. /**
  11664. * Y coordinate of touch.
  11665. */
  11666. y: number;
  11667. /**
  11668. * Id of touch. Unique for each finger.
  11669. */
  11670. pointerId: number;
  11671. /**
  11672. * Event type passed from DOM.
  11673. */
  11674. type: any;
  11675. }
  11676. }
  11677. declare module BABYLON {
  11678. /**
  11679. * Manage the mouse inputs to control the movement of a free camera.
  11680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11681. */
  11682. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11683. /**
  11684. * Define if touch is enabled in the mouse input
  11685. */
  11686. touchEnabled: boolean;
  11687. /**
  11688. * Defines the camera the input is attached to.
  11689. */
  11690. camera: FreeCamera;
  11691. /**
  11692. * Defines the buttons associated with the input to handle camera move.
  11693. */
  11694. buttons: number[];
  11695. /**
  11696. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11697. */
  11698. angularSensibility: number;
  11699. private _pointerInput;
  11700. private _onMouseMove;
  11701. private _observer;
  11702. private previousPosition;
  11703. /**
  11704. * Observable for when a pointer move event occurs containing the move offset
  11705. */
  11706. onPointerMovedObservable: Observable<{
  11707. offsetX: number;
  11708. offsetY: number;
  11709. }>;
  11710. /**
  11711. * @hidden
  11712. * If the camera should be rotated automatically based on pointer movement
  11713. */
  11714. _allowCameraRotation: boolean;
  11715. /**
  11716. * Manage the mouse inputs to control the movement of a free camera.
  11717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11718. * @param touchEnabled Defines if touch is enabled or not
  11719. */
  11720. constructor(
  11721. /**
  11722. * Define if touch is enabled in the mouse input
  11723. */
  11724. touchEnabled?: boolean);
  11725. /**
  11726. * Attach the input controls to a specific dom element to get the input from.
  11727. * @param element Defines the element the controls should be listened from
  11728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11729. */
  11730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11731. /**
  11732. * Called on JS contextmenu event.
  11733. * Override this method to provide functionality.
  11734. */
  11735. protected onContextMenu(evt: PointerEvent): void;
  11736. /**
  11737. * Detach the current controls from the specified dom element.
  11738. * @param element Defines the element to stop listening the inputs from
  11739. */
  11740. detachControl(element: Nullable<HTMLElement>): void;
  11741. /**
  11742. * Gets the class name of the current intput.
  11743. * @returns the class name
  11744. */
  11745. getClassName(): string;
  11746. /**
  11747. * Get the friendly name associated with the input class.
  11748. * @returns the input friendly name
  11749. */
  11750. getSimpleName(): string;
  11751. }
  11752. }
  11753. declare module BABYLON {
  11754. /**
  11755. * Manage the touch inputs to control the movement of a free camera.
  11756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11757. */
  11758. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11759. /**
  11760. * Defines the camera the input is attached to.
  11761. */
  11762. camera: FreeCamera;
  11763. /**
  11764. * Defines the touch sensibility for rotation.
  11765. * The higher the faster.
  11766. */
  11767. touchAngularSensibility: number;
  11768. /**
  11769. * Defines the touch sensibility for move.
  11770. * The higher the faster.
  11771. */
  11772. touchMoveSensibility: number;
  11773. private _offsetX;
  11774. private _offsetY;
  11775. private _pointerPressed;
  11776. private _pointerInput;
  11777. private _observer;
  11778. private _onLostFocus;
  11779. /**
  11780. * Attach the input controls to a specific dom element to get the input from.
  11781. * @param element Defines the element the controls should be listened from
  11782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11783. */
  11784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11785. /**
  11786. * Detach the current controls from the specified dom element.
  11787. * @param element Defines the element to stop listening the inputs from
  11788. */
  11789. detachControl(element: Nullable<HTMLElement>): void;
  11790. /**
  11791. * Update the current camera state depending on the inputs that have been used this frame.
  11792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11793. */
  11794. checkInputs(): void;
  11795. /**
  11796. * Gets the class name of the current intput.
  11797. * @returns the class name
  11798. */
  11799. getClassName(): string;
  11800. /**
  11801. * Get the friendly name associated with the input class.
  11802. * @returns the input friendly name
  11803. */
  11804. getSimpleName(): string;
  11805. }
  11806. }
  11807. declare module BABYLON {
  11808. /**
  11809. * Default Inputs manager for the FreeCamera.
  11810. * It groups all the default supported inputs for ease of use.
  11811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11812. */
  11813. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11814. /**
  11815. * @hidden
  11816. */
  11817. _mouseInput: Nullable<FreeCameraMouseInput>;
  11818. /**
  11819. * Instantiates a new FreeCameraInputsManager.
  11820. * @param camera Defines the camera the inputs belong to
  11821. */
  11822. constructor(camera: FreeCamera);
  11823. /**
  11824. * Add keyboard input support to the input manager.
  11825. * @returns the current input manager
  11826. */
  11827. addKeyboard(): FreeCameraInputsManager;
  11828. /**
  11829. * Add mouse input support to the input manager.
  11830. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11831. * @returns the current input manager
  11832. */
  11833. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11834. /**
  11835. * Removes the mouse input support from the manager
  11836. * @returns the current input manager
  11837. */
  11838. removeMouse(): FreeCameraInputsManager;
  11839. /**
  11840. * Add touch input support to the input manager.
  11841. * @returns the current input manager
  11842. */
  11843. addTouch(): FreeCameraInputsManager;
  11844. /**
  11845. * Remove all attached input methods from a camera
  11846. */
  11847. clear(): void;
  11848. }
  11849. }
  11850. declare module BABYLON {
  11851. /**
  11852. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11853. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11854. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11855. */
  11856. export class FreeCamera extends TargetCamera {
  11857. /**
  11858. * Define the collision ellipsoid of the camera.
  11859. * This is helpful to simulate a camera body like the player body around the camera
  11860. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11861. */
  11862. ellipsoid: Vector3;
  11863. /**
  11864. * Define an offset for the position of the ellipsoid around the camera.
  11865. * This can be helpful to determine the center of the body near the gravity center of the body
  11866. * instead of its head.
  11867. */
  11868. ellipsoidOffset: Vector3;
  11869. /**
  11870. * Enable or disable collisions of the camera with the rest of the scene objects.
  11871. */
  11872. checkCollisions: boolean;
  11873. /**
  11874. * Enable or disable gravity on the camera.
  11875. */
  11876. applyGravity: boolean;
  11877. /**
  11878. * Define the input manager associated to the camera.
  11879. */
  11880. inputs: FreeCameraInputsManager;
  11881. /**
  11882. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11883. * Higher values reduce sensitivity.
  11884. */
  11885. /**
  11886. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11887. * Higher values reduce sensitivity.
  11888. */
  11889. angularSensibility: number;
  11890. /**
  11891. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11892. */
  11893. keysUp: number[];
  11894. /**
  11895. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11896. */
  11897. keysDown: number[];
  11898. /**
  11899. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11900. */
  11901. keysLeft: number[];
  11902. /**
  11903. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11904. */
  11905. keysRight: number[];
  11906. /**
  11907. * Event raised when the camera collide with a mesh in the scene.
  11908. */
  11909. onCollide: (collidedMesh: AbstractMesh) => void;
  11910. private _collider;
  11911. private _needMoveForGravity;
  11912. private _oldPosition;
  11913. private _diffPosition;
  11914. private _newPosition;
  11915. /** @hidden */
  11916. _localDirection: Vector3;
  11917. /** @hidden */
  11918. _transformedDirection: Vector3;
  11919. /**
  11920. * Instantiates a Free Camera.
  11921. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11922. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11923. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11924. * @param name Define the name of the camera in the scene
  11925. * @param position Define the start position of the camera in the scene
  11926. * @param scene Define the scene the camera belongs to
  11927. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11928. */
  11929. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11930. /**
  11931. * Attached controls to the current camera.
  11932. * @param element Defines the element the controls should be listened from
  11933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11934. */
  11935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11936. /**
  11937. * Detach the current controls from the camera.
  11938. * The camera will stop reacting to inputs.
  11939. * @param element Defines the element to stop listening the inputs from
  11940. */
  11941. detachControl(element: HTMLElement): void;
  11942. private _collisionMask;
  11943. /**
  11944. * Define a collision mask to limit the list of object the camera can collide with
  11945. */
  11946. collisionMask: number;
  11947. /** @hidden */
  11948. _collideWithWorld(displacement: Vector3): void;
  11949. private _onCollisionPositionChange;
  11950. /** @hidden */
  11951. _checkInputs(): void;
  11952. /** @hidden */
  11953. _decideIfNeedsToMove(): boolean;
  11954. /** @hidden */
  11955. _updatePosition(): void;
  11956. /**
  11957. * Destroy the camera and release the current resources hold by it.
  11958. */
  11959. dispose(): void;
  11960. /**
  11961. * Gets the current object class name.
  11962. * @return the class name
  11963. */
  11964. getClassName(): string;
  11965. }
  11966. }
  11967. declare module BABYLON {
  11968. /**
  11969. * Represents a gamepad control stick position
  11970. */
  11971. export class StickValues {
  11972. /**
  11973. * The x component of the control stick
  11974. */
  11975. x: number;
  11976. /**
  11977. * The y component of the control stick
  11978. */
  11979. y: number;
  11980. /**
  11981. * Initializes the gamepad x and y control stick values
  11982. * @param x The x component of the gamepad control stick value
  11983. * @param y The y component of the gamepad control stick value
  11984. */
  11985. constructor(
  11986. /**
  11987. * The x component of the control stick
  11988. */
  11989. x: number,
  11990. /**
  11991. * The y component of the control stick
  11992. */
  11993. y: number);
  11994. }
  11995. /**
  11996. * An interface which manages callbacks for gamepad button changes
  11997. */
  11998. export interface GamepadButtonChanges {
  11999. /**
  12000. * Called when a gamepad has been changed
  12001. */
  12002. changed: boolean;
  12003. /**
  12004. * Called when a gamepad press event has been triggered
  12005. */
  12006. pressChanged: boolean;
  12007. /**
  12008. * Called when a touch event has been triggered
  12009. */
  12010. touchChanged: boolean;
  12011. /**
  12012. * Called when a value has changed
  12013. */
  12014. valueChanged: boolean;
  12015. }
  12016. /**
  12017. * Represents a gamepad
  12018. */
  12019. export class Gamepad {
  12020. /**
  12021. * The id of the gamepad
  12022. */
  12023. id: string;
  12024. /**
  12025. * The index of the gamepad
  12026. */
  12027. index: number;
  12028. /**
  12029. * The browser gamepad
  12030. */
  12031. browserGamepad: any;
  12032. /**
  12033. * Specifies what type of gamepad this represents
  12034. */
  12035. type: number;
  12036. private _leftStick;
  12037. private _rightStick;
  12038. /** @hidden */
  12039. _isConnected: boolean;
  12040. private _leftStickAxisX;
  12041. private _leftStickAxisY;
  12042. private _rightStickAxisX;
  12043. private _rightStickAxisY;
  12044. /**
  12045. * Triggered when the left control stick has been changed
  12046. */
  12047. private _onleftstickchanged;
  12048. /**
  12049. * Triggered when the right control stick has been changed
  12050. */
  12051. private _onrightstickchanged;
  12052. /**
  12053. * Represents a gamepad controller
  12054. */
  12055. static GAMEPAD: number;
  12056. /**
  12057. * Represents a generic controller
  12058. */
  12059. static GENERIC: number;
  12060. /**
  12061. * Represents an XBox controller
  12062. */
  12063. static XBOX: number;
  12064. /**
  12065. * Represents a pose-enabled controller
  12066. */
  12067. static POSE_ENABLED: number;
  12068. /**
  12069. * Specifies whether the left control stick should be Y-inverted
  12070. */
  12071. protected _invertLeftStickY: boolean;
  12072. /**
  12073. * Specifies if the gamepad has been connected
  12074. */
  12075. readonly isConnected: boolean;
  12076. /**
  12077. * Initializes the gamepad
  12078. * @param id The id of the gamepad
  12079. * @param index The index of the gamepad
  12080. * @param browserGamepad The browser gamepad
  12081. * @param leftStickX The x component of the left joystick
  12082. * @param leftStickY The y component of the left joystick
  12083. * @param rightStickX The x component of the right joystick
  12084. * @param rightStickY The y component of the right joystick
  12085. */
  12086. constructor(
  12087. /**
  12088. * The id of the gamepad
  12089. */
  12090. id: string,
  12091. /**
  12092. * The index of the gamepad
  12093. */
  12094. index: number,
  12095. /**
  12096. * The browser gamepad
  12097. */
  12098. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12099. /**
  12100. * Callback triggered when the left joystick has changed
  12101. * @param callback
  12102. */
  12103. onleftstickchanged(callback: (values: StickValues) => void): void;
  12104. /**
  12105. * Callback triggered when the right joystick has changed
  12106. * @param callback
  12107. */
  12108. onrightstickchanged(callback: (values: StickValues) => void): void;
  12109. /**
  12110. * Gets the left joystick
  12111. */
  12112. /**
  12113. * Sets the left joystick values
  12114. */
  12115. leftStick: StickValues;
  12116. /**
  12117. * Gets the right joystick
  12118. */
  12119. /**
  12120. * Sets the right joystick value
  12121. */
  12122. rightStick: StickValues;
  12123. /**
  12124. * Updates the gamepad joystick positions
  12125. */
  12126. update(): void;
  12127. /**
  12128. * Disposes the gamepad
  12129. */
  12130. dispose(): void;
  12131. }
  12132. /**
  12133. * Represents a generic gamepad
  12134. */
  12135. export class GenericPad extends Gamepad {
  12136. private _buttons;
  12137. private _onbuttondown;
  12138. private _onbuttonup;
  12139. /**
  12140. * Observable triggered when a button has been pressed
  12141. */
  12142. onButtonDownObservable: Observable<number>;
  12143. /**
  12144. * Observable triggered when a button has been released
  12145. */
  12146. onButtonUpObservable: Observable<number>;
  12147. /**
  12148. * Callback triggered when a button has been pressed
  12149. * @param callback Called when a button has been pressed
  12150. */
  12151. onbuttondown(callback: (buttonPressed: number) => void): void;
  12152. /**
  12153. * Callback triggered when a button has been released
  12154. * @param callback Called when a button has been released
  12155. */
  12156. onbuttonup(callback: (buttonReleased: number) => void): void;
  12157. /**
  12158. * Initializes the generic gamepad
  12159. * @param id The id of the generic gamepad
  12160. * @param index The index of the generic gamepad
  12161. * @param browserGamepad The browser gamepad
  12162. */
  12163. constructor(id: string, index: number, browserGamepad: any);
  12164. private _setButtonValue;
  12165. /**
  12166. * Updates the generic gamepad
  12167. */
  12168. update(): void;
  12169. /**
  12170. * Disposes the generic gamepad
  12171. */
  12172. dispose(): void;
  12173. }
  12174. }
  12175. declare module BABYLON {
  12176. interface Engine {
  12177. /**
  12178. * Creates a raw texture
  12179. * @param data defines the data to store in the texture
  12180. * @param width defines the width of the texture
  12181. * @param height defines the height of the texture
  12182. * @param format defines the format of the data
  12183. * @param generateMipMaps defines if the engine should generate the mip levels
  12184. * @param invertY defines if data must be stored with Y axis inverted
  12185. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12186. * @param compression defines the compression used (null by default)
  12187. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12188. * @returns the raw texture inside an InternalTexture
  12189. */
  12190. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12191. /**
  12192. * Update a raw texture
  12193. * @param texture defines the texture to update
  12194. * @param data defines the data to store in the texture
  12195. * @param format defines the format of the data
  12196. * @param invertY defines if data must be stored with Y axis inverted
  12197. */
  12198. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12199. /**
  12200. * Update a raw texture
  12201. * @param texture defines the texture to update
  12202. * @param data defines the data to store in the texture
  12203. * @param format defines the format of the data
  12204. * @param invertY defines if data must be stored with Y axis inverted
  12205. * @param compression defines the compression used (null by default)
  12206. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12207. */
  12208. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12209. /**
  12210. * Creates a new raw cube texture
  12211. * @param data defines the array of data to use to create each face
  12212. * @param size defines the size of the textures
  12213. * @param format defines the format of the data
  12214. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12215. * @param generateMipMaps defines if the engine should generate the mip levels
  12216. * @param invertY defines if data must be stored with Y axis inverted
  12217. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12218. * @param compression defines the compression used (null by default)
  12219. * @returns the cube texture as an InternalTexture
  12220. */
  12221. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12222. /**
  12223. * Update a raw cube texture
  12224. * @param texture defines the texture to udpdate
  12225. * @param data defines the data to store
  12226. * @param format defines the data format
  12227. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12228. * @param invertY defines if data must be stored with Y axis inverted
  12229. */
  12230. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12231. /**
  12232. * Update a raw cube texture
  12233. * @param texture defines the texture to udpdate
  12234. * @param data defines the data to store
  12235. * @param format defines the data format
  12236. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12237. * @param invertY defines if data must be stored with Y axis inverted
  12238. * @param compression defines the compression used (null by default)
  12239. */
  12240. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12241. /**
  12242. * Update a raw cube texture
  12243. * @param texture defines the texture to udpdate
  12244. * @param data defines the data to store
  12245. * @param format defines the data format
  12246. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12247. * @param invertY defines if data must be stored with Y axis inverted
  12248. * @param compression defines the compression used (null by default)
  12249. * @param level defines which level of the texture to update
  12250. */
  12251. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12252. /**
  12253. * Creates a new raw cube texture from a specified url
  12254. * @param url defines the url where the data is located
  12255. * @param scene defines the current scene
  12256. * @param size defines the size of the textures
  12257. * @param format defines the format of the data
  12258. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12259. * @param noMipmap defines if the engine should avoid generating the mip levels
  12260. * @param callback defines a callback used to extract texture data from loaded data
  12261. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12262. * @param onLoad defines a callback called when texture is loaded
  12263. * @param onError defines a callback called if there is an error
  12264. * @returns the cube texture as an InternalTexture
  12265. */
  12266. 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;
  12267. /**
  12268. * Creates a new raw cube texture from a specified url
  12269. * @param url defines the url where the data is located
  12270. * @param scene defines the current scene
  12271. * @param size defines the size of the textures
  12272. * @param format defines the format of the data
  12273. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12274. * @param noMipmap defines if the engine should avoid generating the mip levels
  12275. * @param callback defines a callback used to extract texture data from loaded data
  12276. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12277. * @param onLoad defines a callback called when texture is loaded
  12278. * @param onError defines a callback called if there is an error
  12279. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12280. * @param invertY defines if data must be stored with Y axis inverted
  12281. * @returns the cube texture as an InternalTexture
  12282. */
  12283. 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;
  12284. /**
  12285. * Creates a new raw 3D texture
  12286. * @param data defines the data used to create the texture
  12287. * @param width defines the width of the texture
  12288. * @param height defines the height of the texture
  12289. * @param depth defines the depth of the texture
  12290. * @param format defines the format of the texture
  12291. * @param generateMipMaps defines if the engine must generate mip levels
  12292. * @param invertY defines if data must be stored with Y axis inverted
  12293. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12294. * @param compression defines the compressed used (can be null)
  12295. * @param textureType defines the compressed used (can be null)
  12296. * @returns a new raw 3D texture (stored in an InternalTexture)
  12297. */
  12298. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12299. /**
  12300. * Update a raw 3D texture
  12301. * @param texture defines the texture to update
  12302. * @param data defines the data to store
  12303. * @param format defines the data format
  12304. * @param invertY defines if data must be stored with Y axis inverted
  12305. */
  12306. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12307. /**
  12308. * Update a raw 3D texture
  12309. * @param texture defines the texture to update
  12310. * @param data defines the data to store
  12311. * @param format defines the data format
  12312. * @param invertY defines if data must be stored with Y axis inverted
  12313. * @param compression defines the used compression (can be null)
  12314. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12315. */
  12316. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12317. }
  12318. }
  12319. declare module BABYLON {
  12320. /**
  12321. * Raw texture can help creating a texture directly from an array of data.
  12322. * This can be super useful if you either get the data from an uncompressed source or
  12323. * if you wish to create your texture pixel by pixel.
  12324. */
  12325. export class RawTexture extends Texture {
  12326. /**
  12327. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12328. */
  12329. format: number;
  12330. private _engine;
  12331. /**
  12332. * Instantiates a new RawTexture.
  12333. * Raw texture can help creating a texture directly from an array of data.
  12334. * This can be super useful if you either get the data from an uncompressed source or
  12335. * if you wish to create your texture pixel by pixel.
  12336. * @param data define the array of data to use to create the texture
  12337. * @param width define the width of the texture
  12338. * @param height define the height of the texture
  12339. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12340. * @param scene define the scene the texture belongs to
  12341. * @param generateMipMaps define whether mip maps should be generated or not
  12342. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12343. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12344. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12345. */
  12346. constructor(data: ArrayBufferView, width: number, height: number,
  12347. /**
  12348. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12349. */
  12350. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12351. /**
  12352. * Updates the texture underlying data.
  12353. * @param data Define the new data of the texture
  12354. */
  12355. update(data: ArrayBufferView): void;
  12356. /**
  12357. * Creates a luminance texture from some data.
  12358. * @param data Define the texture data
  12359. * @param width Define the width of the texture
  12360. * @param height Define the height of the texture
  12361. * @param scene Define the scene the texture belongs to
  12362. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12363. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12364. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12365. * @returns the luminance texture
  12366. */
  12367. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12368. /**
  12369. * Creates a luminance alpha texture from some data.
  12370. * @param data Define the texture data
  12371. * @param width Define the width of the texture
  12372. * @param height Define the height of the texture
  12373. * @param scene Define the scene the texture belongs to
  12374. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12375. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12376. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12377. * @returns the luminance alpha texture
  12378. */
  12379. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12380. /**
  12381. * Creates an alpha texture from some data.
  12382. * @param data Define the texture data
  12383. * @param width Define the width of the texture
  12384. * @param height Define the height of the texture
  12385. * @param scene Define the scene the texture belongs to
  12386. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12387. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12388. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12389. * @returns the alpha texture
  12390. */
  12391. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12392. /**
  12393. * Creates a RGB texture from some data.
  12394. * @param data Define the texture data
  12395. * @param width Define the width of the texture
  12396. * @param height Define the height of the texture
  12397. * @param scene Define the scene the texture belongs to
  12398. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12399. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12400. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12401. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12402. * @returns the RGB alpha texture
  12403. */
  12404. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12405. /**
  12406. * Creates a RGBA texture from some data.
  12407. * @param data Define the texture data
  12408. * @param width Define the width of the texture
  12409. * @param height Define the height of the texture
  12410. * @param scene Define the scene the texture belongs to
  12411. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12412. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12413. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12414. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12415. * @returns the RGBA texture
  12416. */
  12417. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12418. /**
  12419. * Creates a R texture from some data.
  12420. * @param data Define the texture data
  12421. * @param width Define the width of the texture
  12422. * @param height Define the height of the texture
  12423. * @param scene Define the scene the texture belongs to
  12424. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12425. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12426. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12427. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12428. * @returns the R texture
  12429. */
  12430. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12431. }
  12432. }
  12433. declare module BABYLON {
  12434. /**
  12435. * Interface for the size containing width and height
  12436. */
  12437. export interface ISize {
  12438. /**
  12439. * Width
  12440. */
  12441. width: number;
  12442. /**
  12443. * Heighht
  12444. */
  12445. height: number;
  12446. }
  12447. /**
  12448. * Size containing widht and height
  12449. */
  12450. export class Size implements ISize {
  12451. /**
  12452. * Width
  12453. */
  12454. width: number;
  12455. /**
  12456. * Height
  12457. */
  12458. height: number;
  12459. /**
  12460. * Creates a Size object from the given width and height (floats).
  12461. * @param width width of the new size
  12462. * @param height height of the new size
  12463. */
  12464. constructor(width: number, height: number);
  12465. /**
  12466. * Returns a string with the Size width and height
  12467. * @returns a string with the Size width and height
  12468. */
  12469. toString(): string;
  12470. /**
  12471. * "Size"
  12472. * @returns the string "Size"
  12473. */
  12474. getClassName(): string;
  12475. /**
  12476. * Returns the Size hash code.
  12477. * @returns a hash code for a unique width and height
  12478. */
  12479. getHashCode(): number;
  12480. /**
  12481. * Updates the current size from the given one.
  12482. * @param src the given size
  12483. */
  12484. copyFrom(src: Size): void;
  12485. /**
  12486. * Updates in place the current Size from the given floats.
  12487. * @param width width of the new size
  12488. * @param height height of the new size
  12489. * @returns the updated Size.
  12490. */
  12491. copyFromFloats(width: number, height: number): Size;
  12492. /**
  12493. * Updates in place the current Size from the given floats.
  12494. * @param width width to set
  12495. * @param height height to set
  12496. * @returns the updated Size.
  12497. */
  12498. set(width: number, height: number): Size;
  12499. /**
  12500. * Multiplies the width and height by numbers
  12501. * @param w factor to multiple the width by
  12502. * @param h factor to multiple the height by
  12503. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12504. */
  12505. multiplyByFloats(w: number, h: number): Size;
  12506. /**
  12507. * Clones the size
  12508. * @returns a new Size copied from the given one.
  12509. */
  12510. clone(): Size;
  12511. /**
  12512. * True if the current Size and the given one width and height are strictly equal.
  12513. * @param other the other size to compare against
  12514. * @returns True if the current Size and the given one width and height are strictly equal.
  12515. */
  12516. equals(other: Size): boolean;
  12517. /**
  12518. * The surface of the Size : width * height (float).
  12519. */
  12520. readonly surface: number;
  12521. /**
  12522. * Create a new size of zero
  12523. * @returns a new Size set to (0.0, 0.0)
  12524. */
  12525. static Zero(): Size;
  12526. /**
  12527. * Sums the width and height of two sizes
  12528. * @param otherSize size to add to this size
  12529. * @returns a new Size set as the addition result of the current Size and the given one.
  12530. */
  12531. add(otherSize: Size): Size;
  12532. /**
  12533. * Subtracts the width and height of two
  12534. * @param otherSize size to subtract to this size
  12535. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12536. */
  12537. subtract(otherSize: Size): Size;
  12538. /**
  12539. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12540. * @param start starting size to lerp between
  12541. * @param end end size to lerp between
  12542. * @param amount amount to lerp between the start and end values
  12543. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12544. */
  12545. static Lerp(start: Size, end: Size, amount: number): Size;
  12546. }
  12547. }
  12548. declare module BABYLON {
  12549. /**
  12550. * Defines a runtime animation
  12551. */
  12552. export class RuntimeAnimation {
  12553. private _events;
  12554. /**
  12555. * The current frame of the runtime animation
  12556. */
  12557. private _currentFrame;
  12558. /**
  12559. * The animation used by the runtime animation
  12560. */
  12561. private _animation;
  12562. /**
  12563. * The target of the runtime animation
  12564. */
  12565. private _target;
  12566. /**
  12567. * The initiating animatable
  12568. */
  12569. private _host;
  12570. /**
  12571. * The original value of the runtime animation
  12572. */
  12573. private _originalValue;
  12574. /**
  12575. * The original blend value of the runtime animation
  12576. */
  12577. private _originalBlendValue;
  12578. /**
  12579. * The offsets cache of the runtime animation
  12580. */
  12581. private _offsetsCache;
  12582. /**
  12583. * The high limits cache of the runtime animation
  12584. */
  12585. private _highLimitsCache;
  12586. /**
  12587. * Specifies if the runtime animation has been stopped
  12588. */
  12589. private _stopped;
  12590. /**
  12591. * The blending factor of the runtime animation
  12592. */
  12593. private _blendingFactor;
  12594. /**
  12595. * The BabylonJS scene
  12596. */
  12597. private _scene;
  12598. /**
  12599. * The current value of the runtime animation
  12600. */
  12601. private _currentValue;
  12602. /** @hidden */
  12603. _animationState: _IAnimationState;
  12604. /**
  12605. * The active target of the runtime animation
  12606. */
  12607. private _activeTargets;
  12608. private _currentActiveTarget;
  12609. private _directTarget;
  12610. /**
  12611. * The target path of the runtime animation
  12612. */
  12613. private _targetPath;
  12614. /**
  12615. * The weight of the runtime animation
  12616. */
  12617. private _weight;
  12618. /**
  12619. * The ratio offset of the runtime animation
  12620. */
  12621. private _ratioOffset;
  12622. /**
  12623. * The previous delay of the runtime animation
  12624. */
  12625. private _previousDelay;
  12626. /**
  12627. * The previous ratio of the runtime animation
  12628. */
  12629. private _previousRatio;
  12630. private _enableBlending;
  12631. private _keys;
  12632. private _minFrame;
  12633. private _maxFrame;
  12634. private _minValue;
  12635. private _maxValue;
  12636. private _targetIsArray;
  12637. /**
  12638. * Gets the current frame of the runtime animation
  12639. */
  12640. readonly currentFrame: number;
  12641. /**
  12642. * Gets the weight of the runtime animation
  12643. */
  12644. readonly weight: number;
  12645. /**
  12646. * Gets the current value of the runtime animation
  12647. */
  12648. readonly currentValue: any;
  12649. /**
  12650. * Gets the target path of the runtime animation
  12651. */
  12652. readonly targetPath: string;
  12653. /**
  12654. * Gets the actual target of the runtime animation
  12655. */
  12656. readonly target: any;
  12657. /** @hidden */
  12658. _onLoop: () => void;
  12659. /**
  12660. * Create a new RuntimeAnimation object
  12661. * @param target defines the target of the animation
  12662. * @param animation defines the source animation object
  12663. * @param scene defines the hosting scene
  12664. * @param host defines the initiating Animatable
  12665. */
  12666. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12667. private _preparePath;
  12668. /**
  12669. * Gets the animation from the runtime animation
  12670. */
  12671. readonly animation: Animation;
  12672. /**
  12673. * Resets the runtime animation to the beginning
  12674. * @param restoreOriginal defines whether to restore the target property to the original value
  12675. */
  12676. reset(restoreOriginal?: boolean): void;
  12677. /**
  12678. * Specifies if the runtime animation is stopped
  12679. * @returns Boolean specifying if the runtime animation is stopped
  12680. */
  12681. isStopped(): boolean;
  12682. /**
  12683. * Disposes of the runtime animation
  12684. */
  12685. dispose(): void;
  12686. /**
  12687. * Apply the interpolated value to the target
  12688. * @param currentValue defines the value computed by the animation
  12689. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12690. */
  12691. setValue(currentValue: any, weight: number): void;
  12692. private _getOriginalValues;
  12693. private _setValue;
  12694. /**
  12695. * Gets the loop pmode of the runtime animation
  12696. * @returns Loop Mode
  12697. */
  12698. private _getCorrectLoopMode;
  12699. /**
  12700. * Move the current animation to a given frame
  12701. * @param frame defines the frame to move to
  12702. */
  12703. goToFrame(frame: number): void;
  12704. /**
  12705. * @hidden Internal use only
  12706. */
  12707. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12708. /**
  12709. * Execute the current animation
  12710. * @param delay defines the delay to add to the current frame
  12711. * @param from defines the lower bound of the animation range
  12712. * @param to defines the upper bound of the animation range
  12713. * @param loop defines if the current animation must loop
  12714. * @param speedRatio defines the current speed ratio
  12715. * @param weight defines the weight of the animation (default is -1 so no weight)
  12716. * @param onLoop optional callback called when animation loops
  12717. * @returns a boolean indicating if the animation is running
  12718. */
  12719. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12720. }
  12721. }
  12722. declare module BABYLON {
  12723. /**
  12724. * Class used to store an actual running animation
  12725. */
  12726. export class Animatable {
  12727. /** defines the target object */
  12728. target: any;
  12729. /** defines the starting frame number (default is 0) */
  12730. fromFrame: number;
  12731. /** defines the ending frame number (default is 100) */
  12732. toFrame: number;
  12733. /** defines if the animation must loop (default is false) */
  12734. loopAnimation: boolean;
  12735. /** defines a callback to call when animation ends if it is not looping */
  12736. onAnimationEnd?: (() => void) | null | undefined;
  12737. /** defines a callback to call when animation loops */
  12738. onAnimationLoop?: (() => void) | null | undefined;
  12739. private _localDelayOffset;
  12740. private _pausedDelay;
  12741. private _runtimeAnimations;
  12742. private _paused;
  12743. private _scene;
  12744. private _speedRatio;
  12745. private _weight;
  12746. private _syncRoot;
  12747. /**
  12748. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12749. * This will only apply for non looping animation (default is true)
  12750. */
  12751. disposeOnEnd: boolean;
  12752. /**
  12753. * Gets a boolean indicating if the animation has started
  12754. */
  12755. animationStarted: boolean;
  12756. /**
  12757. * Observer raised when the animation ends
  12758. */
  12759. onAnimationEndObservable: Observable<Animatable>;
  12760. /**
  12761. * Observer raised when the animation loops
  12762. */
  12763. onAnimationLoopObservable: Observable<Animatable>;
  12764. /**
  12765. * Gets the root Animatable used to synchronize and normalize animations
  12766. */
  12767. readonly syncRoot: Nullable<Animatable>;
  12768. /**
  12769. * Gets the current frame of the first RuntimeAnimation
  12770. * Used to synchronize Animatables
  12771. */
  12772. readonly masterFrame: number;
  12773. /**
  12774. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12775. */
  12776. weight: number;
  12777. /**
  12778. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12779. */
  12780. speedRatio: number;
  12781. /**
  12782. * Creates a new Animatable
  12783. * @param scene defines the hosting scene
  12784. * @param target defines the target object
  12785. * @param fromFrame defines the starting frame number (default is 0)
  12786. * @param toFrame defines the ending frame number (default is 100)
  12787. * @param loopAnimation defines if the animation must loop (default is false)
  12788. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12789. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12790. * @param animations defines a group of animation to add to the new Animatable
  12791. * @param onAnimationLoop defines a callback to call when animation loops
  12792. */
  12793. constructor(scene: Scene,
  12794. /** defines the target object */
  12795. target: any,
  12796. /** defines the starting frame number (default is 0) */
  12797. fromFrame?: number,
  12798. /** defines the ending frame number (default is 100) */
  12799. toFrame?: number,
  12800. /** defines if the animation must loop (default is false) */
  12801. loopAnimation?: boolean, speedRatio?: number,
  12802. /** defines a callback to call when animation ends if it is not looping */
  12803. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12804. /** defines a callback to call when animation loops */
  12805. onAnimationLoop?: (() => void) | null | undefined);
  12806. /**
  12807. * Synchronize and normalize current Animatable with a source Animatable
  12808. * This is useful when using animation weights and when animations are not of the same length
  12809. * @param root defines the root Animatable to synchronize with
  12810. * @returns the current Animatable
  12811. */
  12812. syncWith(root: Animatable): Animatable;
  12813. /**
  12814. * Gets the list of runtime animations
  12815. * @returns an array of RuntimeAnimation
  12816. */
  12817. getAnimations(): RuntimeAnimation[];
  12818. /**
  12819. * Adds more animations to the current animatable
  12820. * @param target defines the target of the animations
  12821. * @param animations defines the new animations to add
  12822. */
  12823. appendAnimations(target: any, animations: Animation[]): void;
  12824. /**
  12825. * Gets the source animation for a specific property
  12826. * @param property defines the propertyu to look for
  12827. * @returns null or the source animation for the given property
  12828. */
  12829. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12830. /**
  12831. * Gets the runtime animation for a specific property
  12832. * @param property defines the propertyu to look for
  12833. * @returns null or the runtime animation for the given property
  12834. */
  12835. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12836. /**
  12837. * Resets the animatable to its original state
  12838. */
  12839. reset(): void;
  12840. /**
  12841. * Allows the animatable to blend with current running animations
  12842. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12843. * @param blendingSpeed defines the blending speed to use
  12844. */
  12845. enableBlending(blendingSpeed: number): void;
  12846. /**
  12847. * Disable animation blending
  12848. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12849. */
  12850. disableBlending(): void;
  12851. /**
  12852. * Jump directly to a given frame
  12853. * @param frame defines the frame to jump to
  12854. */
  12855. goToFrame(frame: number): void;
  12856. /**
  12857. * Pause the animation
  12858. */
  12859. pause(): void;
  12860. /**
  12861. * Restart the animation
  12862. */
  12863. restart(): void;
  12864. private _raiseOnAnimationEnd;
  12865. /**
  12866. * Stop and delete the current animation
  12867. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12868. * @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)
  12869. */
  12870. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12871. /**
  12872. * Wait asynchronously for the animation to end
  12873. * @returns a promise which will be fullfilled when the animation ends
  12874. */
  12875. waitAsync(): Promise<Animatable>;
  12876. /** @hidden */
  12877. _animate(delay: number): boolean;
  12878. }
  12879. interface Scene {
  12880. /** @hidden */
  12881. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12882. /** @hidden */
  12883. _processLateAnimationBindingsForMatrices(holder: {
  12884. totalWeight: number;
  12885. animations: RuntimeAnimation[];
  12886. originalValue: Matrix;
  12887. }): any;
  12888. /** @hidden */
  12889. _processLateAnimationBindingsForQuaternions(holder: {
  12890. totalWeight: number;
  12891. animations: RuntimeAnimation[];
  12892. originalValue: Quaternion;
  12893. }, refQuaternion: Quaternion): Quaternion;
  12894. /** @hidden */
  12895. _processLateAnimationBindings(): void;
  12896. /**
  12897. * Will start the animation sequence of a given target
  12898. * @param target defines the target
  12899. * @param from defines from which frame should animation start
  12900. * @param to defines until which frame should animation run.
  12901. * @param weight defines the weight to apply to the animation (1.0 by default)
  12902. * @param loop defines if the animation loops
  12903. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12904. * @param onAnimationEnd defines the function to be executed when the animation ends
  12905. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12906. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12907. * @param onAnimationLoop defines the callback to call when an animation loops
  12908. * @returns the animatable object created for this animation
  12909. */
  12910. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12911. /**
  12912. * Will start the animation sequence of a given target
  12913. * @param target defines the target
  12914. * @param from defines from which frame should animation start
  12915. * @param to defines until which frame should animation run.
  12916. * @param loop defines if the animation loops
  12917. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12918. * @param onAnimationEnd defines the function to be executed when the animation ends
  12919. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12920. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12921. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12922. * @param onAnimationLoop defines the callback to call when an animation loops
  12923. * @returns the animatable object created for this animation
  12924. */
  12925. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12926. /**
  12927. * Will start the animation sequence of a given target and its hierarchy
  12928. * @param target defines the target
  12929. * @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.
  12930. * @param from defines from which frame should animation start
  12931. * @param to defines until which frame should animation run.
  12932. * @param loop defines if the animation loops
  12933. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12934. * @param onAnimationEnd defines the function to be executed when the animation ends
  12935. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12936. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12937. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12938. * @param onAnimationLoop defines the callback to call when an animation loops
  12939. * @returns the list of created animatables
  12940. */
  12941. 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[];
  12942. /**
  12943. * Begin a new animation on a given node
  12944. * @param target defines the target where the animation will take place
  12945. * @param animations defines the list of animations to start
  12946. * @param from defines the initial value
  12947. * @param to defines the final value
  12948. * @param loop defines if you want animation to loop (off by default)
  12949. * @param speedRatio defines the speed ratio to apply to all animations
  12950. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12951. * @param onAnimationLoop defines the callback to call when an animation loops
  12952. * @returns the list of created animatables
  12953. */
  12954. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12955. /**
  12956. * Begin a new animation on a given node and its hierarchy
  12957. * @param target defines the root node where the animation will take place
  12958. * @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.
  12959. * @param animations defines the list of animations to start
  12960. * @param from defines the initial value
  12961. * @param to defines the final value
  12962. * @param loop defines if you want animation to loop (off by default)
  12963. * @param speedRatio defines the speed ratio to apply to all animations
  12964. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12965. * @param onAnimationLoop defines the callback to call when an animation loops
  12966. * @returns the list of animatables created for all nodes
  12967. */
  12968. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12969. /**
  12970. * Gets the animatable associated with a specific target
  12971. * @param target defines the target of the animatable
  12972. * @returns the required animatable if found
  12973. */
  12974. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12975. /**
  12976. * Gets all animatables associated with a given target
  12977. * @param target defines the target to look animatables for
  12978. * @returns an array of Animatables
  12979. */
  12980. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12981. /**
  12982. * Stops and removes all animations that have been applied to the scene
  12983. */
  12984. stopAllAnimations(): void;
  12985. }
  12986. interface Bone {
  12987. /**
  12988. * Copy an animation range from another bone
  12989. * @param source defines the source bone
  12990. * @param rangeName defines the range name to copy
  12991. * @param frameOffset defines the frame offset
  12992. * @param rescaleAsRequired defines if rescaling must be applied if required
  12993. * @param skelDimensionsRatio defines the scaling ratio
  12994. * @returns true if operation was successful
  12995. */
  12996. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  12997. }
  12998. }
  12999. declare module BABYLON {
  13000. /**
  13001. * Class used to override all child animations of a given target
  13002. */
  13003. export class AnimationPropertiesOverride {
  13004. /**
  13005. * Gets or sets a value indicating if animation blending must be used
  13006. */
  13007. enableBlending: boolean;
  13008. /**
  13009. * Gets or sets the blending speed to use when enableBlending is true
  13010. */
  13011. blendingSpeed: number;
  13012. /**
  13013. * Gets or sets the default loop mode to use
  13014. */
  13015. loopMode: number;
  13016. }
  13017. }
  13018. declare module BABYLON {
  13019. /**
  13020. * Class used to handle skinning animations
  13021. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13022. */
  13023. export class Skeleton implements IAnimatable {
  13024. /** defines the skeleton name */
  13025. name: string;
  13026. /** defines the skeleton Id */
  13027. id: string;
  13028. /**
  13029. * Defines the list of child bones
  13030. */
  13031. bones: Bone[];
  13032. /**
  13033. * Defines an estimate of the dimension of the skeleton at rest
  13034. */
  13035. dimensionsAtRest: Vector3;
  13036. /**
  13037. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13038. */
  13039. needInitialSkinMatrix: boolean;
  13040. /**
  13041. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13042. */
  13043. overrideMesh: Nullable<AbstractMesh>;
  13044. /**
  13045. * Gets the list of animations attached to this skeleton
  13046. */
  13047. animations: Array<Animation>;
  13048. private _scene;
  13049. private _isDirty;
  13050. private _transformMatrices;
  13051. private _transformMatrixTexture;
  13052. private _meshesWithPoseMatrix;
  13053. private _animatables;
  13054. private _identity;
  13055. private _synchronizedWithMesh;
  13056. private _ranges;
  13057. private _lastAbsoluteTransformsUpdateId;
  13058. private _canUseTextureForBones;
  13059. private _uniqueId;
  13060. /** @hidden */
  13061. _numBonesWithLinkedTransformNode: number;
  13062. /** @hidden */
  13063. _hasWaitingData: Nullable<boolean>;
  13064. /**
  13065. * Specifies if the skeleton should be serialized
  13066. */
  13067. doNotSerialize: boolean;
  13068. private _useTextureToStoreBoneMatrices;
  13069. /**
  13070. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13071. * Please note that this option is not available if the hardware does not support it
  13072. */
  13073. useTextureToStoreBoneMatrices: boolean;
  13074. private _animationPropertiesOverride;
  13075. /**
  13076. * Gets or sets the animation properties override
  13077. */
  13078. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13079. /**
  13080. * List of inspectable custom properties (used by the Inspector)
  13081. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13082. */
  13083. inspectableCustomProperties: IInspectable[];
  13084. /**
  13085. * An observable triggered before computing the skeleton's matrices
  13086. */
  13087. onBeforeComputeObservable: Observable<Skeleton>;
  13088. /**
  13089. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13090. */
  13091. readonly isUsingTextureForMatrices: boolean;
  13092. /**
  13093. * Gets the unique ID of this skeleton
  13094. */
  13095. readonly uniqueId: number;
  13096. /**
  13097. * Creates a new skeleton
  13098. * @param name defines the skeleton name
  13099. * @param id defines the skeleton Id
  13100. * @param scene defines the hosting scene
  13101. */
  13102. constructor(
  13103. /** defines the skeleton name */
  13104. name: string,
  13105. /** defines the skeleton Id */
  13106. id: string, scene: Scene);
  13107. /**
  13108. * Gets the current object class name.
  13109. * @return the class name
  13110. */
  13111. getClassName(): string;
  13112. /**
  13113. * Returns an array containing the root bones
  13114. * @returns an array containing the root bones
  13115. */
  13116. getChildren(): Array<Bone>;
  13117. /**
  13118. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13119. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13120. * @returns a Float32Array containing matrices data
  13121. */
  13122. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13123. /**
  13124. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13125. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13126. * @returns a raw texture containing the data
  13127. */
  13128. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13129. /**
  13130. * Gets the current hosting scene
  13131. * @returns a scene object
  13132. */
  13133. getScene(): Scene;
  13134. /**
  13135. * Gets a string representing the current skeleton data
  13136. * @param fullDetails defines a boolean indicating if we want a verbose version
  13137. * @returns a string representing the current skeleton data
  13138. */
  13139. toString(fullDetails?: boolean): string;
  13140. /**
  13141. * Get bone's index searching by name
  13142. * @param name defines bone's name to search for
  13143. * @return the indice of the bone. Returns -1 if not found
  13144. */
  13145. getBoneIndexByName(name: string): number;
  13146. /**
  13147. * Creater a new animation range
  13148. * @param name defines the name of the range
  13149. * @param from defines the start key
  13150. * @param to defines the end key
  13151. */
  13152. createAnimationRange(name: string, from: number, to: number): void;
  13153. /**
  13154. * Delete a specific animation range
  13155. * @param name defines the name of the range
  13156. * @param deleteFrames defines if frames must be removed as well
  13157. */
  13158. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13159. /**
  13160. * Gets a specific animation range
  13161. * @param name defines the name of the range to look for
  13162. * @returns the requested animation range or null if not found
  13163. */
  13164. getAnimationRange(name: string): Nullable<AnimationRange>;
  13165. /**
  13166. * Gets the list of all animation ranges defined on this skeleton
  13167. * @returns an array
  13168. */
  13169. getAnimationRanges(): Nullable<AnimationRange>[];
  13170. /**
  13171. * Copy animation range from a source skeleton.
  13172. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13173. * @param source defines the source skeleton
  13174. * @param name defines the name of the range to copy
  13175. * @param rescaleAsRequired defines if rescaling must be applied if required
  13176. * @returns true if operation was successful
  13177. */
  13178. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13179. /**
  13180. * Forces the skeleton to go to rest pose
  13181. */
  13182. returnToRest(): void;
  13183. private _getHighestAnimationFrame;
  13184. /**
  13185. * Begin a specific animation range
  13186. * @param name defines the name of the range to start
  13187. * @param loop defines if looping must be turned on (false by default)
  13188. * @param speedRatio defines the speed ratio to apply (1 by default)
  13189. * @param onAnimationEnd defines a callback which will be called when animation will end
  13190. * @returns a new animatable
  13191. */
  13192. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13193. /** @hidden */
  13194. _markAsDirty(): void;
  13195. /** @hidden */
  13196. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13197. /** @hidden */
  13198. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13199. private _computeTransformMatrices;
  13200. /**
  13201. * Build all resources required to render a skeleton
  13202. */
  13203. prepare(): void;
  13204. /**
  13205. * Gets the list of animatables currently running for this skeleton
  13206. * @returns an array of animatables
  13207. */
  13208. getAnimatables(): IAnimatable[];
  13209. /**
  13210. * Clone the current skeleton
  13211. * @param name defines the name of the new skeleton
  13212. * @param id defines the id of the new skeleton
  13213. * @returns the new skeleton
  13214. */
  13215. clone(name: string, id: string): Skeleton;
  13216. /**
  13217. * Enable animation blending for this skeleton
  13218. * @param blendingSpeed defines the blending speed to apply
  13219. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13220. */
  13221. enableBlending(blendingSpeed?: number): void;
  13222. /**
  13223. * Releases all resources associated with the current skeleton
  13224. */
  13225. dispose(): void;
  13226. /**
  13227. * Serialize the skeleton in a JSON object
  13228. * @returns a JSON object
  13229. */
  13230. serialize(): any;
  13231. /**
  13232. * Creates a new skeleton from serialized data
  13233. * @param parsedSkeleton defines the serialized data
  13234. * @param scene defines the hosting scene
  13235. * @returns a new skeleton
  13236. */
  13237. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13238. /**
  13239. * Compute all node absolute transforms
  13240. * @param forceUpdate defines if computation must be done even if cache is up to date
  13241. */
  13242. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13243. /**
  13244. * Gets the root pose matrix
  13245. * @returns a matrix
  13246. */
  13247. getPoseMatrix(): Nullable<Matrix>;
  13248. /**
  13249. * Sorts bones per internal index
  13250. */
  13251. sortBones(): void;
  13252. private _sortBones;
  13253. }
  13254. }
  13255. declare module BABYLON {
  13256. /**
  13257. * Class used to store bone information
  13258. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13259. */
  13260. export class Bone extends Node {
  13261. /**
  13262. * defines the bone name
  13263. */
  13264. name: string;
  13265. private static _tmpVecs;
  13266. private static _tmpQuat;
  13267. private static _tmpMats;
  13268. /**
  13269. * Gets the list of child bones
  13270. */
  13271. children: Bone[];
  13272. /** Gets the animations associated with this bone */
  13273. animations: Animation[];
  13274. /**
  13275. * Gets or sets bone length
  13276. */
  13277. length: number;
  13278. /**
  13279. * @hidden Internal only
  13280. * Set this value to map this bone to a different index in the transform matrices
  13281. * Set this value to -1 to exclude the bone from the transform matrices
  13282. */
  13283. _index: Nullable<number>;
  13284. private _skeleton;
  13285. private _localMatrix;
  13286. private _restPose;
  13287. private _baseMatrix;
  13288. private _absoluteTransform;
  13289. private _invertedAbsoluteTransform;
  13290. private _parent;
  13291. private _scalingDeterminant;
  13292. private _worldTransform;
  13293. private _localScaling;
  13294. private _localRotation;
  13295. private _localPosition;
  13296. private _needToDecompose;
  13297. private _needToCompose;
  13298. /** @hidden */
  13299. _linkedTransformNode: Nullable<TransformNode>;
  13300. /** @hidden */
  13301. _waitingTransformNodeId: Nullable<string>;
  13302. /** @hidden */
  13303. /** @hidden */
  13304. _matrix: Matrix;
  13305. /**
  13306. * Create a new bone
  13307. * @param name defines the bone name
  13308. * @param skeleton defines the parent skeleton
  13309. * @param parentBone defines the parent (can be null if the bone is the root)
  13310. * @param localMatrix defines the local matrix
  13311. * @param restPose defines the rest pose matrix
  13312. * @param baseMatrix defines the base matrix
  13313. * @param index defines index of the bone in the hiearchy
  13314. */
  13315. constructor(
  13316. /**
  13317. * defines the bone name
  13318. */
  13319. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13320. /**
  13321. * Gets the current object class name.
  13322. * @return the class name
  13323. */
  13324. getClassName(): string;
  13325. /**
  13326. * Gets the parent skeleton
  13327. * @returns a skeleton
  13328. */
  13329. getSkeleton(): Skeleton;
  13330. /**
  13331. * Gets parent bone
  13332. * @returns a bone or null if the bone is the root of the bone hierarchy
  13333. */
  13334. getParent(): Nullable<Bone>;
  13335. /**
  13336. * Returns an array containing the root bones
  13337. * @returns an array containing the root bones
  13338. */
  13339. getChildren(): Array<Bone>;
  13340. /**
  13341. * Sets the parent bone
  13342. * @param parent defines the parent (can be null if the bone is the root)
  13343. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13344. */
  13345. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13346. /**
  13347. * Gets the local matrix
  13348. * @returns a matrix
  13349. */
  13350. getLocalMatrix(): Matrix;
  13351. /**
  13352. * Gets the base matrix (initial matrix which remains unchanged)
  13353. * @returns a matrix
  13354. */
  13355. getBaseMatrix(): Matrix;
  13356. /**
  13357. * Gets the rest pose matrix
  13358. * @returns a matrix
  13359. */
  13360. getRestPose(): Matrix;
  13361. /**
  13362. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13363. */
  13364. getWorldMatrix(): Matrix;
  13365. /**
  13366. * Sets the local matrix to rest pose matrix
  13367. */
  13368. returnToRest(): void;
  13369. /**
  13370. * Gets the inverse of the absolute transform matrix.
  13371. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13372. * @returns a matrix
  13373. */
  13374. getInvertedAbsoluteTransform(): Matrix;
  13375. /**
  13376. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13377. * @returns a matrix
  13378. */
  13379. getAbsoluteTransform(): Matrix;
  13380. /**
  13381. * Links with the given transform node.
  13382. * The local matrix of this bone is copied from the transform node every frame.
  13383. * @param transformNode defines the transform node to link to
  13384. */
  13385. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13386. /** Gets or sets current position (in local space) */
  13387. position: Vector3;
  13388. /** Gets or sets current rotation (in local space) */
  13389. rotation: Vector3;
  13390. /** Gets or sets current rotation quaternion (in local space) */
  13391. rotationQuaternion: Quaternion;
  13392. /** Gets or sets current scaling (in local space) */
  13393. scaling: Vector3;
  13394. /**
  13395. * Gets the animation properties override
  13396. */
  13397. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13398. private _decompose;
  13399. private _compose;
  13400. /**
  13401. * Update the base and local matrices
  13402. * @param matrix defines the new base or local matrix
  13403. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13404. * @param updateLocalMatrix defines if the local matrix should be updated
  13405. */
  13406. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13407. /** @hidden */
  13408. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13409. /**
  13410. * Flag the bone as dirty (Forcing it to update everything)
  13411. */
  13412. markAsDirty(): void;
  13413. /** @hidden */
  13414. _markAsDirtyAndCompose(): void;
  13415. private _markAsDirtyAndDecompose;
  13416. /**
  13417. * Translate the bone in local or world space
  13418. * @param vec The amount to translate the bone
  13419. * @param space The space that the translation is in
  13420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13421. */
  13422. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13423. /**
  13424. * Set the postion of the bone in local or world space
  13425. * @param position The position to set the bone
  13426. * @param space The space that the position is in
  13427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13428. */
  13429. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13430. /**
  13431. * Set the absolute position of the bone (world space)
  13432. * @param position The position to set the bone
  13433. * @param mesh The mesh that this bone is attached to
  13434. */
  13435. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13436. /**
  13437. * Scale the bone on the x, y and z axes (in local space)
  13438. * @param x The amount to scale the bone on the x axis
  13439. * @param y The amount to scale the bone on the y axis
  13440. * @param z The amount to scale the bone on the z axis
  13441. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13442. */
  13443. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13444. /**
  13445. * Set the bone scaling in local space
  13446. * @param scale defines the scaling vector
  13447. */
  13448. setScale(scale: Vector3): void;
  13449. /**
  13450. * Gets the current scaling in local space
  13451. * @returns the current scaling vector
  13452. */
  13453. getScale(): Vector3;
  13454. /**
  13455. * Gets the current scaling in local space and stores it in a target vector
  13456. * @param result defines the target vector
  13457. */
  13458. getScaleToRef(result: Vector3): void;
  13459. /**
  13460. * Set the yaw, pitch, and roll of the bone in local or world space
  13461. * @param yaw The rotation of the bone on the y axis
  13462. * @param pitch The rotation of the bone on the x axis
  13463. * @param roll The rotation of the bone on the z axis
  13464. * @param space The space that the axes of rotation are in
  13465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13466. */
  13467. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13468. /**
  13469. * Add a rotation to the bone on an axis in local or world space
  13470. * @param axis The axis to rotate the bone on
  13471. * @param amount The amount to rotate the bone
  13472. * @param space The space that the axis is in
  13473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13474. */
  13475. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13476. /**
  13477. * Set the rotation of the bone to a particular axis angle in local or world space
  13478. * @param axis The axis to rotate the bone on
  13479. * @param angle The angle that the bone should be rotated to
  13480. * @param space The space that the axis is in
  13481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13482. */
  13483. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13484. /**
  13485. * Set the euler rotation of the bone in local of world space
  13486. * @param rotation The euler rotation that the bone should be set to
  13487. * @param space The space that the rotation is in
  13488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13489. */
  13490. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13491. /**
  13492. * Set the quaternion rotation of the bone in local of world space
  13493. * @param quat The quaternion rotation that the bone should be set to
  13494. * @param space The space that the rotation is in
  13495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13496. */
  13497. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13498. /**
  13499. * Set the rotation matrix of the bone in local of world space
  13500. * @param rotMat The rotation matrix that the bone should be set to
  13501. * @param space The space that the rotation is in
  13502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13503. */
  13504. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13505. private _rotateWithMatrix;
  13506. private _getNegativeRotationToRef;
  13507. /**
  13508. * Get the position of the bone in local or world space
  13509. * @param space The space that the returned position is in
  13510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13511. * @returns The position of the bone
  13512. */
  13513. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13514. /**
  13515. * Copy the position of the bone to a vector3 in local or world space
  13516. * @param space The space that the returned position is in
  13517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13518. * @param result The vector3 to copy the position to
  13519. */
  13520. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13521. /**
  13522. * Get the absolute position of the bone (world space)
  13523. * @param mesh The mesh that this bone is attached to
  13524. * @returns The absolute position of the bone
  13525. */
  13526. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13527. /**
  13528. * Copy the absolute position of the bone (world space) to the result param
  13529. * @param mesh The mesh that this bone is attached to
  13530. * @param result The vector3 to copy the absolute position to
  13531. */
  13532. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13533. /**
  13534. * Compute the absolute transforms of this bone and its children
  13535. */
  13536. computeAbsoluteTransforms(): void;
  13537. /**
  13538. * Get the world direction from an axis that is in the local space of the bone
  13539. * @param localAxis The local direction that is used to compute the world direction
  13540. * @param mesh The mesh that this bone is attached to
  13541. * @returns The world direction
  13542. */
  13543. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13544. /**
  13545. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13546. * @param localAxis The local direction that is used to compute the world direction
  13547. * @param mesh The mesh that this bone is attached to
  13548. * @param result The vector3 that the world direction will be copied to
  13549. */
  13550. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13551. /**
  13552. * Get the euler rotation of the bone in local or world space
  13553. * @param space The space that the rotation should be in
  13554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13555. * @returns The euler rotation
  13556. */
  13557. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13558. /**
  13559. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13560. * @param space The space that the rotation should be in
  13561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13562. * @param result The vector3 that the rotation should be copied to
  13563. */
  13564. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13565. /**
  13566. * Get the quaternion rotation of the bone in either local or world space
  13567. * @param space The space that the rotation should be in
  13568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13569. * @returns The quaternion rotation
  13570. */
  13571. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13572. /**
  13573. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13574. * @param space The space that the rotation should be in
  13575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13576. * @param result The quaternion that the rotation should be copied to
  13577. */
  13578. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13579. /**
  13580. * Get the rotation matrix of the bone in local or world space
  13581. * @param space The space that the rotation should be in
  13582. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13583. * @returns The rotation matrix
  13584. */
  13585. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13586. /**
  13587. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13588. * @param space The space that the rotation should be in
  13589. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13590. * @param result The quaternion that the rotation should be copied to
  13591. */
  13592. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13593. /**
  13594. * Get the world position of a point that is in the local space of the bone
  13595. * @param position The local position
  13596. * @param mesh The mesh that this bone is attached to
  13597. * @returns The world position
  13598. */
  13599. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13600. /**
  13601. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13602. * @param position The local position
  13603. * @param mesh The mesh that this bone is attached to
  13604. * @param result The vector3 that the world position should be copied to
  13605. */
  13606. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13607. /**
  13608. * Get the local position of a point that is in world space
  13609. * @param position The world position
  13610. * @param mesh The mesh that this bone is attached to
  13611. * @returns The local position
  13612. */
  13613. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13614. /**
  13615. * Get the local position of a point that is in world space and copy it to the result param
  13616. * @param position The world position
  13617. * @param mesh The mesh that this bone is attached to
  13618. * @param result The vector3 that the local position should be copied to
  13619. */
  13620. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13621. }
  13622. }
  13623. declare module BABYLON {
  13624. /**
  13625. * 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.
  13626. * @see https://doc.babylonjs.com/how_to/transformnode
  13627. */
  13628. export class TransformNode extends Node {
  13629. /**
  13630. * Object will not rotate to face the camera
  13631. */
  13632. static BILLBOARDMODE_NONE: number;
  13633. /**
  13634. * Object will rotate to face the camera but only on the x axis
  13635. */
  13636. static BILLBOARDMODE_X: number;
  13637. /**
  13638. * Object will rotate to face the camera but only on the y axis
  13639. */
  13640. static BILLBOARDMODE_Y: number;
  13641. /**
  13642. * Object will rotate to face the camera but only on the z axis
  13643. */
  13644. static BILLBOARDMODE_Z: number;
  13645. /**
  13646. * Object will rotate to face the camera
  13647. */
  13648. static BILLBOARDMODE_ALL: number;
  13649. private _forward;
  13650. private _forwardInverted;
  13651. private _up;
  13652. private _right;
  13653. private _rightInverted;
  13654. private _position;
  13655. private _rotation;
  13656. private _rotationQuaternion;
  13657. protected _scaling: Vector3;
  13658. protected _isDirty: boolean;
  13659. private _transformToBoneReferal;
  13660. private _billboardMode;
  13661. /**
  13662. * Gets or sets the billboard mode. Default is 0.
  13663. *
  13664. * | Value | Type | Description |
  13665. * | --- | --- | --- |
  13666. * | 0 | BILLBOARDMODE_NONE | |
  13667. * | 1 | BILLBOARDMODE_X | |
  13668. * | 2 | BILLBOARDMODE_Y | |
  13669. * | 4 | BILLBOARDMODE_Z | |
  13670. * | 7 | BILLBOARDMODE_ALL | |
  13671. *
  13672. */
  13673. billboardMode: number;
  13674. private _preserveParentRotationForBillboard;
  13675. /**
  13676. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13677. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13678. */
  13679. preserveParentRotationForBillboard: boolean;
  13680. /**
  13681. * 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
  13682. */
  13683. scalingDeterminant: number;
  13684. private _infiniteDistance;
  13685. /**
  13686. * Gets or sets the distance of the object to max, often used by skybox
  13687. */
  13688. infiniteDistance: boolean;
  13689. /**
  13690. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13691. * By default the system will update normals to compensate
  13692. */
  13693. ignoreNonUniformScaling: boolean;
  13694. /**
  13695. * 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
  13696. */
  13697. reIntegrateRotationIntoRotationQuaternion: boolean;
  13698. /** @hidden */
  13699. _poseMatrix: Nullable<Matrix>;
  13700. /** @hidden */
  13701. _localMatrix: Matrix;
  13702. private _usePivotMatrix;
  13703. private _absolutePosition;
  13704. private _pivotMatrix;
  13705. private _pivotMatrixInverse;
  13706. protected _postMultiplyPivotMatrix: boolean;
  13707. protected _isWorldMatrixFrozen: boolean;
  13708. /** @hidden */
  13709. _indexInSceneTransformNodesArray: number;
  13710. /**
  13711. * An event triggered after the world matrix is updated
  13712. */
  13713. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13714. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13715. /**
  13716. * Gets a string identifying the name of the class
  13717. * @returns "TransformNode" string
  13718. */
  13719. getClassName(): string;
  13720. /**
  13721. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13722. */
  13723. position: Vector3;
  13724. /**
  13725. * 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)).
  13726. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13727. */
  13728. rotation: Vector3;
  13729. /**
  13730. * 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)).
  13731. */
  13732. scaling: Vector3;
  13733. /**
  13734. * 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).
  13735. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13736. */
  13737. rotationQuaternion: Nullable<Quaternion>;
  13738. /**
  13739. * The forward direction of that transform in world space.
  13740. */
  13741. readonly forward: Vector3;
  13742. /**
  13743. * The up direction of that transform in world space.
  13744. */
  13745. readonly up: Vector3;
  13746. /**
  13747. * The right direction of that transform in world space.
  13748. */
  13749. readonly right: Vector3;
  13750. /**
  13751. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13752. * @param matrix the matrix to copy the pose from
  13753. * @returns this TransformNode.
  13754. */
  13755. updatePoseMatrix(matrix: Matrix): TransformNode;
  13756. /**
  13757. * Returns the mesh Pose matrix.
  13758. * @returns the pose matrix
  13759. */
  13760. getPoseMatrix(): Matrix;
  13761. /** @hidden */
  13762. _isSynchronized(): boolean;
  13763. /** @hidden */
  13764. _initCache(): void;
  13765. /**
  13766. * Flag the transform node as dirty (Forcing it to update everything)
  13767. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13768. * @returns this transform node
  13769. */
  13770. markAsDirty(property: string): TransformNode;
  13771. /**
  13772. * Returns the current mesh absolute position.
  13773. * Returns a Vector3.
  13774. */
  13775. readonly absolutePosition: Vector3;
  13776. /**
  13777. * Sets a new matrix to apply before all other transformation
  13778. * @param matrix defines the transform matrix
  13779. * @returns the current TransformNode
  13780. */
  13781. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13782. /**
  13783. * Sets a new pivot matrix to the current node
  13784. * @param matrix defines the new pivot matrix to use
  13785. * @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
  13786. * @returns the current TransformNode
  13787. */
  13788. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13789. /**
  13790. * Returns the mesh pivot matrix.
  13791. * Default : Identity.
  13792. * @returns the matrix
  13793. */
  13794. getPivotMatrix(): Matrix;
  13795. /**
  13796. * Prevents the World matrix to be computed any longer.
  13797. * @returns the TransformNode.
  13798. */
  13799. freezeWorldMatrix(): TransformNode;
  13800. /**
  13801. * Allows back the World matrix computation.
  13802. * @returns the TransformNode.
  13803. */
  13804. unfreezeWorldMatrix(): this;
  13805. /**
  13806. * True if the World matrix has been frozen.
  13807. */
  13808. readonly isWorldMatrixFrozen: boolean;
  13809. /**
  13810. * Retuns the mesh absolute position in the World.
  13811. * @returns a Vector3.
  13812. */
  13813. getAbsolutePosition(): Vector3;
  13814. /**
  13815. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13816. * @param absolutePosition the absolute position to set
  13817. * @returns the TransformNode.
  13818. */
  13819. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13820. /**
  13821. * Sets the mesh position in its local space.
  13822. * @param vector3 the position to set in localspace
  13823. * @returns the TransformNode.
  13824. */
  13825. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13826. /**
  13827. * Returns the mesh position in the local space from the current World matrix values.
  13828. * @returns a new Vector3.
  13829. */
  13830. getPositionExpressedInLocalSpace(): Vector3;
  13831. /**
  13832. * Translates the mesh along the passed Vector3 in its local space.
  13833. * @param vector3 the distance to translate in localspace
  13834. * @returns the TransformNode.
  13835. */
  13836. locallyTranslate(vector3: Vector3): TransformNode;
  13837. private static _lookAtVectorCache;
  13838. /**
  13839. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13840. * @param targetPoint the position (must be in same space as current mesh) to look at
  13841. * @param yawCor optional yaw (y-axis) correction in radians
  13842. * @param pitchCor optional pitch (x-axis) correction in radians
  13843. * @param rollCor optional roll (z-axis) correction in radians
  13844. * @param space the choosen space of the target
  13845. * @returns the TransformNode.
  13846. */
  13847. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13848. /**
  13849. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13850. * This Vector3 is expressed in the World space.
  13851. * @param localAxis axis to rotate
  13852. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13853. */
  13854. getDirection(localAxis: Vector3): Vector3;
  13855. /**
  13856. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13857. * localAxis is expressed in the mesh local space.
  13858. * result is computed in the Wordl space from the mesh World matrix.
  13859. * @param localAxis axis to rotate
  13860. * @param result the resulting transformnode
  13861. * @returns this TransformNode.
  13862. */
  13863. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13864. /**
  13865. * Sets this transform node rotation to the given local axis.
  13866. * @param localAxis the axis in local space
  13867. * @param yawCor optional yaw (y-axis) correction in radians
  13868. * @param pitchCor optional pitch (x-axis) correction in radians
  13869. * @param rollCor optional roll (z-axis) correction in radians
  13870. * @returns this TransformNode
  13871. */
  13872. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13873. /**
  13874. * Sets a new pivot point to the current node
  13875. * @param point defines the new pivot point to use
  13876. * @param space defines if the point is in world or local space (local by default)
  13877. * @returns the current TransformNode
  13878. */
  13879. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13880. /**
  13881. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13882. * @returns the pivot point
  13883. */
  13884. getPivotPoint(): Vector3;
  13885. /**
  13886. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13887. * @param result the vector3 to store the result
  13888. * @returns this TransformNode.
  13889. */
  13890. getPivotPointToRef(result: Vector3): TransformNode;
  13891. /**
  13892. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13893. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13894. */
  13895. getAbsolutePivotPoint(): Vector3;
  13896. /**
  13897. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13898. * @param result vector3 to store the result
  13899. * @returns this TransformNode.
  13900. */
  13901. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13902. /**
  13903. * Defines the passed node as the parent of the current node.
  13904. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13905. * @see https://doc.babylonjs.com/how_to/parenting
  13906. * @param node the node ot set as the parent
  13907. * @returns this TransformNode.
  13908. */
  13909. setParent(node: Nullable<Node>): TransformNode;
  13910. private _nonUniformScaling;
  13911. /**
  13912. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13913. */
  13914. readonly nonUniformScaling: boolean;
  13915. /** @hidden */
  13916. _updateNonUniformScalingState(value: boolean): boolean;
  13917. /**
  13918. * Attach the current TransformNode to another TransformNode associated with a bone
  13919. * @param bone Bone affecting the TransformNode
  13920. * @param affectedTransformNode TransformNode associated with the bone
  13921. * @returns this object
  13922. */
  13923. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13924. /**
  13925. * Detach the transform node if its associated with a bone
  13926. * @returns this object
  13927. */
  13928. detachFromBone(): TransformNode;
  13929. private static _rotationAxisCache;
  13930. /**
  13931. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13932. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13933. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13934. * The passed axis is also normalized.
  13935. * @param axis the axis to rotate around
  13936. * @param amount the amount to rotate in radians
  13937. * @param space Space to rotate in (Default: local)
  13938. * @returns the TransformNode.
  13939. */
  13940. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13941. /**
  13942. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13943. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13944. * The passed axis is also normalized. .
  13945. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13946. * @param point the point to rotate around
  13947. * @param axis the axis to rotate around
  13948. * @param amount the amount to rotate in radians
  13949. * @returns the TransformNode
  13950. */
  13951. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13952. /**
  13953. * Translates the mesh along the axis vector for the passed distance in the given space.
  13954. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13955. * @param axis the axis to translate in
  13956. * @param distance the distance to translate
  13957. * @param space Space to rotate in (Default: local)
  13958. * @returns the TransformNode.
  13959. */
  13960. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13961. /**
  13962. * Adds a rotation step to the mesh current rotation.
  13963. * x, y, z are Euler angles expressed in radians.
  13964. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13965. * This means this rotation is made in the mesh local space only.
  13966. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13967. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13968. * ```javascript
  13969. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13970. * ```
  13971. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13972. * 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.
  13973. * @param x Rotation to add
  13974. * @param y Rotation to add
  13975. * @param z Rotation to add
  13976. * @returns the TransformNode.
  13977. */
  13978. addRotation(x: number, y: number, z: number): TransformNode;
  13979. /**
  13980. * @hidden
  13981. */
  13982. protected _getEffectiveParent(): Nullable<Node>;
  13983. /**
  13984. * Computes the world matrix of the node
  13985. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13986. * @returns the world matrix
  13987. */
  13988. computeWorldMatrix(force?: boolean): Matrix;
  13989. protected _afterComputeWorldMatrix(): void;
  13990. /**
  13991. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13992. * @param func callback function to add
  13993. *
  13994. * @returns the TransformNode.
  13995. */
  13996. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13997. /**
  13998. * Removes a registered callback function.
  13999. * @param func callback function to remove
  14000. * @returns the TransformNode.
  14001. */
  14002. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14003. /**
  14004. * Gets the position of the current mesh in camera space
  14005. * @param camera defines the camera to use
  14006. * @returns a position
  14007. */
  14008. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14009. /**
  14010. * Returns the distance from the mesh to the active camera
  14011. * @param camera defines the camera to use
  14012. * @returns the distance
  14013. */
  14014. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14015. /**
  14016. * Clone the current transform node
  14017. * @param name Name of the new clone
  14018. * @param newParent New parent for the clone
  14019. * @param doNotCloneChildren Do not clone children hierarchy
  14020. * @returns the new transform node
  14021. */
  14022. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14023. /**
  14024. * Serializes the objects information.
  14025. * @param currentSerializationObject defines the object to serialize in
  14026. * @returns the serialized object
  14027. */
  14028. serialize(currentSerializationObject?: any): any;
  14029. /**
  14030. * Returns a new TransformNode object parsed from the source provided.
  14031. * @param parsedTransformNode is the source.
  14032. * @param scene the scne the object belongs to
  14033. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14034. * @returns a new TransformNode object parsed from the source provided.
  14035. */
  14036. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14037. /**
  14038. * Get all child-transformNodes of this node
  14039. * @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
  14040. * @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
  14041. * @returns an array of TransformNode
  14042. */
  14043. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14044. /**
  14045. * Releases resources associated with this transform node.
  14046. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14047. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14048. */
  14049. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14050. /**
  14051. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14052. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14053. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14054. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14055. * @returns the current mesh
  14056. */
  14057. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14058. }
  14059. }
  14060. declare module BABYLON {
  14061. /**
  14062. * Defines the types of pose enabled controllers that are supported
  14063. */
  14064. export enum PoseEnabledControllerType {
  14065. /**
  14066. * HTC Vive
  14067. */
  14068. VIVE = 0,
  14069. /**
  14070. * Oculus Rift
  14071. */
  14072. OCULUS = 1,
  14073. /**
  14074. * Windows mixed reality
  14075. */
  14076. WINDOWS = 2,
  14077. /**
  14078. * Samsung gear VR
  14079. */
  14080. GEAR_VR = 3,
  14081. /**
  14082. * Google Daydream
  14083. */
  14084. DAYDREAM = 4,
  14085. /**
  14086. * Generic
  14087. */
  14088. GENERIC = 5
  14089. }
  14090. /**
  14091. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14092. */
  14093. export interface MutableGamepadButton {
  14094. /**
  14095. * Value of the button/trigger
  14096. */
  14097. value: number;
  14098. /**
  14099. * If the button/trigger is currently touched
  14100. */
  14101. touched: boolean;
  14102. /**
  14103. * If the button/trigger is currently pressed
  14104. */
  14105. pressed: boolean;
  14106. }
  14107. /**
  14108. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14109. * @hidden
  14110. */
  14111. export interface ExtendedGamepadButton extends GamepadButton {
  14112. /**
  14113. * If the button/trigger is currently pressed
  14114. */
  14115. readonly pressed: boolean;
  14116. /**
  14117. * If the button/trigger is currently touched
  14118. */
  14119. readonly touched: boolean;
  14120. /**
  14121. * Value of the button/trigger
  14122. */
  14123. readonly value: number;
  14124. }
  14125. /** @hidden */
  14126. export interface _GamePadFactory {
  14127. /**
  14128. * Returns wether or not the current gamepad can be created for this type of controller.
  14129. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14130. * @returns true if it can be created, otherwise false
  14131. */
  14132. canCreate(gamepadInfo: any): boolean;
  14133. /**
  14134. * Creates a new instance of the Gamepad.
  14135. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14136. * @returns the new gamepad instance
  14137. */
  14138. create(gamepadInfo: any): Gamepad;
  14139. }
  14140. /**
  14141. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14142. */
  14143. export class PoseEnabledControllerHelper {
  14144. /** @hidden */
  14145. static _ControllerFactories: _GamePadFactory[];
  14146. /** @hidden */
  14147. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14148. /**
  14149. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14150. * @param vrGamepad the gamepad to initialized
  14151. * @returns a vr controller of the type the gamepad identified as
  14152. */
  14153. static InitiateController(vrGamepad: any): Gamepad;
  14154. }
  14155. /**
  14156. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14157. */
  14158. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14159. /**
  14160. * If the controller is used in a webXR session
  14161. */
  14162. isXR: boolean;
  14163. private _deviceRoomPosition;
  14164. private _deviceRoomRotationQuaternion;
  14165. /**
  14166. * The device position in babylon space
  14167. */
  14168. devicePosition: Vector3;
  14169. /**
  14170. * The device rotation in babylon space
  14171. */
  14172. deviceRotationQuaternion: Quaternion;
  14173. /**
  14174. * The scale factor of the device in babylon space
  14175. */
  14176. deviceScaleFactor: number;
  14177. /**
  14178. * (Likely devicePosition should be used instead) The device position in its room space
  14179. */
  14180. position: Vector3;
  14181. /**
  14182. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14183. */
  14184. rotationQuaternion: Quaternion;
  14185. /**
  14186. * The type of controller (Eg. Windows mixed reality)
  14187. */
  14188. controllerType: PoseEnabledControllerType;
  14189. protected _calculatedPosition: Vector3;
  14190. private _calculatedRotation;
  14191. /**
  14192. * The raw pose from the device
  14193. */
  14194. rawPose: DevicePose;
  14195. private _trackPosition;
  14196. private _maxRotationDistFromHeadset;
  14197. private _draggedRoomRotation;
  14198. /**
  14199. * @hidden
  14200. */
  14201. _disableTrackPosition(fixedPosition: Vector3): void;
  14202. /**
  14203. * Internal, the mesh attached to the controller
  14204. * @hidden
  14205. */
  14206. _mesh: Nullable<AbstractMesh>;
  14207. private _poseControlledCamera;
  14208. private _leftHandSystemQuaternion;
  14209. /**
  14210. * Internal, matrix used to convert room space to babylon space
  14211. * @hidden
  14212. */
  14213. _deviceToWorld: Matrix;
  14214. /**
  14215. * Node to be used when casting a ray from the controller
  14216. * @hidden
  14217. */
  14218. _pointingPoseNode: Nullable<TransformNode>;
  14219. /**
  14220. * Name of the child mesh that can be used to cast a ray from the controller
  14221. */
  14222. static readonly POINTING_POSE: string;
  14223. /**
  14224. * Creates a new PoseEnabledController from a gamepad
  14225. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14226. */
  14227. constructor(browserGamepad: any);
  14228. private _workingMatrix;
  14229. /**
  14230. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14231. */
  14232. update(): void;
  14233. /**
  14234. * Updates only the pose device and mesh without doing any button event checking
  14235. */
  14236. protected _updatePoseAndMesh(): void;
  14237. /**
  14238. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14239. * @param poseData raw pose fromthe device
  14240. */
  14241. updateFromDevice(poseData: DevicePose): void;
  14242. /**
  14243. * @hidden
  14244. */
  14245. _meshAttachedObservable: Observable<AbstractMesh>;
  14246. /**
  14247. * Attaches a mesh to the controller
  14248. * @param mesh the mesh to be attached
  14249. */
  14250. attachToMesh(mesh: AbstractMesh): void;
  14251. /**
  14252. * Attaches the controllers mesh to a camera
  14253. * @param camera the camera the mesh should be attached to
  14254. */
  14255. attachToPoseControlledCamera(camera: TargetCamera): void;
  14256. /**
  14257. * Disposes of the controller
  14258. */
  14259. dispose(): void;
  14260. /**
  14261. * The mesh that is attached to the controller
  14262. */
  14263. readonly mesh: Nullable<AbstractMesh>;
  14264. /**
  14265. * Gets the ray of the controller in the direction the controller is pointing
  14266. * @param length the length the resulting ray should be
  14267. * @returns a ray in the direction the controller is pointing
  14268. */
  14269. getForwardRay(length?: number): Ray;
  14270. }
  14271. }
  14272. declare module BABYLON {
  14273. /**
  14274. * Defines the WebVRController object that represents controllers tracked in 3D space
  14275. */
  14276. export abstract class WebVRController extends PoseEnabledController {
  14277. /**
  14278. * Internal, the default controller model for the controller
  14279. */
  14280. protected _defaultModel: AbstractMesh;
  14281. /**
  14282. * Fired when the trigger state has changed
  14283. */
  14284. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14285. /**
  14286. * Fired when the main button state has changed
  14287. */
  14288. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14289. /**
  14290. * Fired when the secondary button state has changed
  14291. */
  14292. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14293. /**
  14294. * Fired when the pad state has changed
  14295. */
  14296. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14297. /**
  14298. * Fired when controllers stick values have changed
  14299. */
  14300. onPadValuesChangedObservable: Observable<StickValues>;
  14301. /**
  14302. * Array of button availible on the controller
  14303. */
  14304. protected _buttons: Array<MutableGamepadButton>;
  14305. private _onButtonStateChange;
  14306. /**
  14307. * Fired when a controller button's state has changed
  14308. * @param callback the callback containing the button that was modified
  14309. */
  14310. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14311. /**
  14312. * X and Y axis corresponding to the controllers joystick
  14313. */
  14314. pad: StickValues;
  14315. /**
  14316. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14317. */
  14318. hand: string;
  14319. /**
  14320. * The default controller model for the controller
  14321. */
  14322. readonly defaultModel: AbstractMesh;
  14323. /**
  14324. * Creates a new WebVRController from a gamepad
  14325. * @param vrGamepad the gamepad that the WebVRController should be created from
  14326. */
  14327. constructor(vrGamepad: any);
  14328. /**
  14329. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14330. */
  14331. update(): void;
  14332. /**
  14333. * Function to be called when a button is modified
  14334. */
  14335. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14336. /**
  14337. * Loads a mesh and attaches it to the controller
  14338. * @param scene the scene the mesh should be added to
  14339. * @param meshLoaded callback for when the mesh has been loaded
  14340. */
  14341. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14342. private _setButtonValue;
  14343. private _changes;
  14344. private _checkChanges;
  14345. /**
  14346. * Disposes of th webVRCOntroller
  14347. */
  14348. dispose(): void;
  14349. }
  14350. }
  14351. declare module BABYLON {
  14352. /**
  14353. * The HemisphericLight simulates the ambient environment light,
  14354. * so the passed direction is the light reflection direction, not the incoming direction.
  14355. */
  14356. export class HemisphericLight extends Light {
  14357. /**
  14358. * The groundColor is the light in the opposite direction to the one specified during creation.
  14359. * 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.
  14360. */
  14361. groundColor: Color3;
  14362. /**
  14363. * The light reflection direction, not the incoming direction.
  14364. */
  14365. direction: Vector3;
  14366. /**
  14367. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14368. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14369. * The HemisphericLight can't cast shadows.
  14370. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14371. * @param name The friendly name of the light
  14372. * @param direction The direction of the light reflection
  14373. * @param scene The scene the light belongs to
  14374. */
  14375. constructor(name: string, direction: Vector3, scene: Scene);
  14376. protected _buildUniformLayout(): void;
  14377. /**
  14378. * Returns the string "HemisphericLight".
  14379. * @return The class name
  14380. */
  14381. getClassName(): string;
  14382. /**
  14383. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14384. * Returns the updated direction.
  14385. * @param target The target the direction should point to
  14386. * @return The computed direction
  14387. */
  14388. setDirectionToTarget(target: Vector3): Vector3;
  14389. /**
  14390. * Returns the shadow generator associated to the light.
  14391. * @returns Always null for hemispheric lights because it does not support shadows.
  14392. */
  14393. getShadowGenerator(): Nullable<IShadowGenerator>;
  14394. /**
  14395. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14396. * @param effect The effect to update
  14397. * @param lightIndex The index of the light in the effect to update
  14398. * @returns The hemispheric light
  14399. */
  14400. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14401. /**
  14402. * Computes the world matrix of the node
  14403. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14404. * @param useWasUpdatedFlag defines a reserved property
  14405. * @returns the world matrix
  14406. */
  14407. computeWorldMatrix(): Matrix;
  14408. /**
  14409. * Returns the integer 3.
  14410. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14411. */
  14412. getTypeID(): number;
  14413. /**
  14414. * Prepares the list of defines specific to the light type.
  14415. * @param defines the list of defines
  14416. * @param lightIndex defines the index of the light for the effect
  14417. */
  14418. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14419. }
  14420. }
  14421. declare module BABYLON {
  14422. /** @hidden */
  14423. export var vrMultiviewToSingleviewPixelShader: {
  14424. name: string;
  14425. shader: string;
  14426. };
  14427. }
  14428. declare module BABYLON {
  14429. /**
  14430. * Renders to multiple views with a single draw call
  14431. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14432. */
  14433. export class MultiviewRenderTarget extends RenderTargetTexture {
  14434. /**
  14435. * Creates a multiview render target
  14436. * @param scene scene used with the render target
  14437. * @param size the size of the render target (used for each view)
  14438. */
  14439. constructor(scene: Scene, size?: number | {
  14440. width: number;
  14441. height: number;
  14442. } | {
  14443. ratio: number;
  14444. });
  14445. /**
  14446. * @hidden
  14447. * @param faceIndex the face index, if its a cube texture
  14448. */
  14449. _bindFrameBuffer(faceIndex?: number): void;
  14450. /**
  14451. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14452. * @returns the view count
  14453. */
  14454. getViewCount(): number;
  14455. }
  14456. }
  14457. declare module BABYLON {
  14458. /**
  14459. * Reprasents a camera frustum
  14460. */
  14461. export class Frustum {
  14462. /**
  14463. * Gets the planes representing the frustum
  14464. * @param transform matrix to be applied to the returned planes
  14465. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14466. */
  14467. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14468. /**
  14469. * Gets the near frustum plane transformed by the transform matrix
  14470. * @param transform transformation matrix to be applied to the resulting frustum plane
  14471. * @param frustumPlane the resuling frustum plane
  14472. */
  14473. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14474. /**
  14475. * Gets the far frustum plane transformed by the transform matrix
  14476. * @param transform transformation matrix to be applied to the resulting frustum plane
  14477. * @param frustumPlane the resuling frustum plane
  14478. */
  14479. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14480. /**
  14481. * Gets the left frustum plane transformed by the transform matrix
  14482. * @param transform transformation matrix to be applied to the resulting frustum plane
  14483. * @param frustumPlane the resuling frustum plane
  14484. */
  14485. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14486. /**
  14487. * Gets the right frustum plane transformed by the transform matrix
  14488. * @param transform transformation matrix to be applied to the resulting frustum plane
  14489. * @param frustumPlane the resuling frustum plane
  14490. */
  14491. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14492. /**
  14493. * Gets the top frustum plane transformed by the transform matrix
  14494. * @param transform transformation matrix to be applied to the resulting frustum plane
  14495. * @param frustumPlane the resuling frustum plane
  14496. */
  14497. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14498. /**
  14499. * Gets the bottom frustum plane transformed by the transform matrix
  14500. * @param transform transformation matrix to be applied to the resulting frustum plane
  14501. * @param frustumPlane the resuling frustum plane
  14502. */
  14503. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14504. /**
  14505. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14506. * @param transform transformation matrix to be applied to the resulting frustum planes
  14507. * @param frustumPlanes the resuling frustum planes
  14508. */
  14509. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14510. }
  14511. }
  14512. declare module BABYLON {
  14513. interface Engine {
  14514. /**
  14515. * Creates a new multiview render target
  14516. * @param width defines the width of the texture
  14517. * @param height defines the height of the texture
  14518. * @returns the created multiview texture
  14519. */
  14520. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14521. /**
  14522. * Binds a multiview framebuffer to be drawn to
  14523. * @param multiviewTexture texture to bind
  14524. */
  14525. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14526. }
  14527. interface Camera {
  14528. /**
  14529. * @hidden
  14530. * 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)
  14531. */
  14532. _useMultiviewToSingleView: boolean;
  14533. /**
  14534. * @hidden
  14535. * 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)
  14536. */
  14537. _multiviewTexture: Nullable<RenderTargetTexture>;
  14538. /**
  14539. * @hidden
  14540. * ensures the multiview texture of the camera exists and has the specified width/height
  14541. * @param width height to set on the multiview texture
  14542. * @param height width to set on the multiview texture
  14543. */
  14544. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14545. }
  14546. interface Scene {
  14547. /** @hidden */
  14548. _transformMatrixR: Matrix;
  14549. /** @hidden */
  14550. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14551. /** @hidden */
  14552. _createMultiviewUbo(): void;
  14553. /** @hidden */
  14554. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14555. /** @hidden */
  14556. _renderMultiviewToSingleView(camera: Camera): void;
  14557. }
  14558. }
  14559. declare module BABYLON {
  14560. /**
  14561. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14562. * This will not be used for webXR as it supports displaying texture arrays directly
  14563. */
  14564. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14565. /**
  14566. * Initializes a VRMultiviewToSingleview
  14567. * @param name name of the post process
  14568. * @param camera camera to be applied to
  14569. * @param scaleFactor scaling factor to the size of the output texture
  14570. */
  14571. constructor(name: string, camera: Camera, scaleFactor: number);
  14572. }
  14573. }
  14574. declare module BABYLON {
  14575. interface Engine {
  14576. /** @hidden */
  14577. _vrDisplay: any;
  14578. /** @hidden */
  14579. _vrSupported: boolean;
  14580. /** @hidden */
  14581. _oldSize: Size;
  14582. /** @hidden */
  14583. _oldHardwareScaleFactor: number;
  14584. /** @hidden */
  14585. _vrExclusivePointerMode: boolean;
  14586. /** @hidden */
  14587. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14588. /** @hidden */
  14589. _onVRDisplayPointerRestricted: () => void;
  14590. /** @hidden */
  14591. _onVRDisplayPointerUnrestricted: () => void;
  14592. /** @hidden */
  14593. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14594. /** @hidden */
  14595. _onVrDisplayDisconnect: Nullable<() => void>;
  14596. /** @hidden */
  14597. _onVrDisplayPresentChange: Nullable<() => void>;
  14598. /**
  14599. * Observable signaled when VR display mode changes
  14600. */
  14601. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14602. /**
  14603. * Observable signaled when VR request present is complete
  14604. */
  14605. onVRRequestPresentComplete: Observable<boolean>;
  14606. /**
  14607. * Observable signaled when VR request present starts
  14608. */
  14609. onVRRequestPresentStart: Observable<Engine>;
  14610. /**
  14611. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14612. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14613. */
  14614. isInVRExclusivePointerMode: boolean;
  14615. /**
  14616. * Gets a boolean indicating if a webVR device was detected
  14617. * @returns true if a webVR device was detected
  14618. */
  14619. isVRDevicePresent(): boolean;
  14620. /**
  14621. * Gets the current webVR device
  14622. * @returns the current webVR device (or null)
  14623. */
  14624. getVRDevice(): any;
  14625. /**
  14626. * Initializes a webVR display and starts listening to display change events
  14627. * The onVRDisplayChangedObservable will be notified upon these changes
  14628. * @returns A promise containing a VRDisplay and if vr is supported
  14629. */
  14630. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14631. /** @hidden */
  14632. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14633. /**
  14634. * Call this function to switch to webVR mode
  14635. * Will do nothing if webVR is not supported or if there is no webVR device
  14636. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14637. */
  14638. enableVR(): void;
  14639. /** @hidden */
  14640. _onVRFullScreenTriggered(): void;
  14641. }
  14642. }
  14643. declare module BABYLON {
  14644. /**
  14645. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14646. * IMPORTANT!! The data is right-hand data.
  14647. * @export
  14648. * @interface DevicePose
  14649. */
  14650. export interface DevicePose {
  14651. /**
  14652. * The position of the device, values in array are [x,y,z].
  14653. */
  14654. readonly position: Nullable<Float32Array>;
  14655. /**
  14656. * The linearVelocity of the device, values in array are [x,y,z].
  14657. */
  14658. readonly linearVelocity: Nullable<Float32Array>;
  14659. /**
  14660. * The linearAcceleration of the device, values in array are [x,y,z].
  14661. */
  14662. readonly linearAcceleration: Nullable<Float32Array>;
  14663. /**
  14664. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14665. */
  14666. readonly orientation: Nullable<Float32Array>;
  14667. /**
  14668. * The angularVelocity of the device, values in array are [x,y,z].
  14669. */
  14670. readonly angularVelocity: Nullable<Float32Array>;
  14671. /**
  14672. * The angularAcceleration of the device, values in array are [x,y,z].
  14673. */
  14674. readonly angularAcceleration: Nullable<Float32Array>;
  14675. }
  14676. /**
  14677. * Interface representing a pose controlled object in Babylon.
  14678. * A pose controlled object has both regular pose values as well as pose values
  14679. * from an external device such as a VR head mounted display
  14680. */
  14681. export interface PoseControlled {
  14682. /**
  14683. * The position of the object in babylon space.
  14684. */
  14685. position: Vector3;
  14686. /**
  14687. * The rotation quaternion of the object in babylon space.
  14688. */
  14689. rotationQuaternion: Quaternion;
  14690. /**
  14691. * The position of the device in babylon space.
  14692. */
  14693. devicePosition?: Vector3;
  14694. /**
  14695. * The rotation quaternion of the device in babylon space.
  14696. */
  14697. deviceRotationQuaternion: Quaternion;
  14698. /**
  14699. * The raw pose coming from the device.
  14700. */
  14701. rawPose: Nullable<DevicePose>;
  14702. /**
  14703. * The scale of the device to be used when translating from device space to babylon space.
  14704. */
  14705. deviceScaleFactor: number;
  14706. /**
  14707. * Updates the poseControlled values based on the input device pose.
  14708. * @param poseData the pose data to update the object with
  14709. */
  14710. updateFromDevice(poseData: DevicePose): void;
  14711. }
  14712. /**
  14713. * Set of options to customize the webVRCamera
  14714. */
  14715. export interface WebVROptions {
  14716. /**
  14717. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14718. */
  14719. trackPosition?: boolean;
  14720. /**
  14721. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14722. */
  14723. positionScale?: number;
  14724. /**
  14725. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14726. */
  14727. displayName?: string;
  14728. /**
  14729. * Should the native controller meshes be initialized. (default: true)
  14730. */
  14731. controllerMeshes?: boolean;
  14732. /**
  14733. * Creating a default HemiLight only on controllers. (default: true)
  14734. */
  14735. defaultLightingOnControllers?: boolean;
  14736. /**
  14737. * If you don't want to use the default VR button of the helper. (default: false)
  14738. */
  14739. useCustomVRButton?: boolean;
  14740. /**
  14741. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14742. */
  14743. customVRButton?: HTMLButtonElement;
  14744. /**
  14745. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14746. */
  14747. rayLength?: number;
  14748. /**
  14749. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14750. */
  14751. defaultHeight?: number;
  14752. /**
  14753. * If multiview should be used if availible (default: false)
  14754. */
  14755. useMultiview?: boolean;
  14756. }
  14757. /**
  14758. * This represents a WebVR camera.
  14759. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14760. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14761. */
  14762. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14763. private webVROptions;
  14764. /**
  14765. * @hidden
  14766. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14767. */
  14768. _vrDevice: any;
  14769. /**
  14770. * The rawPose of the vrDevice.
  14771. */
  14772. rawPose: Nullable<DevicePose>;
  14773. private _onVREnabled;
  14774. private _specsVersion;
  14775. private _attached;
  14776. private _frameData;
  14777. protected _descendants: Array<Node>;
  14778. private _deviceRoomPosition;
  14779. /** @hidden */
  14780. _deviceRoomRotationQuaternion: Quaternion;
  14781. private _standingMatrix;
  14782. /**
  14783. * Represents device position in babylon space.
  14784. */
  14785. devicePosition: Vector3;
  14786. /**
  14787. * Represents device rotation in babylon space.
  14788. */
  14789. deviceRotationQuaternion: Quaternion;
  14790. /**
  14791. * The scale of the device to be used when translating from device space to babylon space.
  14792. */
  14793. deviceScaleFactor: number;
  14794. private _deviceToWorld;
  14795. private _worldToDevice;
  14796. /**
  14797. * References to the webVR controllers for the vrDevice.
  14798. */
  14799. controllers: Array<WebVRController>;
  14800. /**
  14801. * Emits an event when a controller is attached.
  14802. */
  14803. onControllersAttachedObservable: Observable<WebVRController[]>;
  14804. /**
  14805. * Emits an event when a controller's mesh has been loaded;
  14806. */
  14807. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14808. /**
  14809. * Emits an event when the HMD's pose has been updated.
  14810. */
  14811. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14812. private _poseSet;
  14813. /**
  14814. * If the rig cameras be used as parent instead of this camera.
  14815. */
  14816. rigParenting: boolean;
  14817. private _lightOnControllers;
  14818. private _defaultHeight?;
  14819. /**
  14820. * Instantiates a WebVRFreeCamera.
  14821. * @param name The name of the WebVRFreeCamera
  14822. * @param position The starting anchor position for the camera
  14823. * @param scene The scene the camera belongs to
  14824. * @param webVROptions a set of customizable options for the webVRCamera
  14825. */
  14826. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14827. /**
  14828. * Gets the device distance from the ground in meters.
  14829. * @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.
  14830. */
  14831. deviceDistanceToRoomGround(): number;
  14832. /**
  14833. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14834. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14835. */
  14836. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14837. /**
  14838. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14839. * @returns A promise with a boolean set to if the standing matrix is supported.
  14840. */
  14841. useStandingMatrixAsync(): Promise<boolean>;
  14842. /**
  14843. * Disposes the camera
  14844. */
  14845. dispose(): void;
  14846. /**
  14847. * Gets a vrController by name.
  14848. * @param name The name of the controller to retreive
  14849. * @returns the controller matching the name specified or null if not found
  14850. */
  14851. getControllerByName(name: string): Nullable<WebVRController>;
  14852. private _leftController;
  14853. /**
  14854. * The controller corresponding to the users left hand.
  14855. */
  14856. readonly leftController: Nullable<WebVRController>;
  14857. private _rightController;
  14858. /**
  14859. * The controller corresponding to the users right hand.
  14860. */
  14861. readonly rightController: Nullable<WebVRController>;
  14862. /**
  14863. * Casts a ray forward from the vrCamera's gaze.
  14864. * @param length Length of the ray (default: 100)
  14865. * @returns the ray corresponding to the gaze
  14866. */
  14867. getForwardRay(length?: number): Ray;
  14868. /**
  14869. * @hidden
  14870. * Updates the camera based on device's frame data
  14871. */
  14872. _checkInputs(): void;
  14873. /**
  14874. * Updates the poseControlled values based on the input device pose.
  14875. * @param poseData Pose coming from the device
  14876. */
  14877. updateFromDevice(poseData: DevicePose): void;
  14878. private _htmlElementAttached;
  14879. private _detachIfAttached;
  14880. /**
  14881. * WebVR's attach control will start broadcasting frames to the device.
  14882. * Note that in certain browsers (chrome for example) this function must be called
  14883. * within a user-interaction callback. Example:
  14884. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14885. *
  14886. * @param element html element to attach the vrDevice to
  14887. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14888. */
  14889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14890. /**
  14891. * Detaches the camera from the html element and disables VR
  14892. *
  14893. * @param element html element to detach from
  14894. */
  14895. detachControl(element: HTMLElement): void;
  14896. /**
  14897. * @returns the name of this class
  14898. */
  14899. getClassName(): string;
  14900. /**
  14901. * Calls resetPose on the vrDisplay
  14902. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14903. */
  14904. resetToCurrentRotation(): void;
  14905. /**
  14906. * @hidden
  14907. * Updates the rig cameras (left and right eye)
  14908. */
  14909. _updateRigCameras(): void;
  14910. private _workingVector;
  14911. private _oneVector;
  14912. private _workingMatrix;
  14913. private updateCacheCalled;
  14914. private _correctPositionIfNotTrackPosition;
  14915. /**
  14916. * @hidden
  14917. * Updates the cached values of the camera
  14918. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14919. */
  14920. _updateCache(ignoreParentClass?: boolean): void;
  14921. /**
  14922. * @hidden
  14923. * Get current device position in babylon world
  14924. */
  14925. _computeDevicePosition(): void;
  14926. /**
  14927. * Updates the current device position and rotation in the babylon world
  14928. */
  14929. update(): void;
  14930. /**
  14931. * @hidden
  14932. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14933. * @returns an identity matrix
  14934. */
  14935. _getViewMatrix(): Matrix;
  14936. private _tmpMatrix;
  14937. /**
  14938. * This function is called by the two RIG cameras.
  14939. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14940. * @hidden
  14941. */
  14942. _getWebVRViewMatrix(): Matrix;
  14943. /** @hidden */
  14944. _getWebVRProjectionMatrix(): Matrix;
  14945. private _onGamepadConnectedObserver;
  14946. private _onGamepadDisconnectedObserver;
  14947. private _updateCacheWhenTrackingDisabledObserver;
  14948. /**
  14949. * Initializes the controllers and their meshes
  14950. */
  14951. initControllers(): void;
  14952. }
  14953. }
  14954. declare module BABYLON {
  14955. /**
  14956. * Size options for a post process
  14957. */
  14958. export type PostProcessOptions = {
  14959. width: number;
  14960. height: number;
  14961. };
  14962. /**
  14963. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14964. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14965. */
  14966. export class PostProcess {
  14967. /** Name of the PostProcess. */
  14968. name: string;
  14969. /**
  14970. * Gets or sets the unique id of the post process
  14971. */
  14972. uniqueId: number;
  14973. /**
  14974. * Width of the texture to apply the post process on
  14975. */
  14976. width: number;
  14977. /**
  14978. * Height of the texture to apply the post process on
  14979. */
  14980. height: number;
  14981. /**
  14982. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14983. * @hidden
  14984. */
  14985. _outputTexture: Nullable<InternalTexture>;
  14986. /**
  14987. * Sampling mode used by the shader
  14988. * See https://doc.babylonjs.com/classes/3.1/texture
  14989. */
  14990. renderTargetSamplingMode: number;
  14991. /**
  14992. * Clear color to use when screen clearing
  14993. */
  14994. clearColor: Color4;
  14995. /**
  14996. * If the buffer needs to be cleared before applying the post process. (default: true)
  14997. * Should be set to false if shader will overwrite all previous pixels.
  14998. */
  14999. autoClear: boolean;
  15000. /**
  15001. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15002. */
  15003. alphaMode: number;
  15004. /**
  15005. * Sets the setAlphaBlendConstants of the babylon engine
  15006. */
  15007. alphaConstants: Color4;
  15008. /**
  15009. * Animations to be used for the post processing
  15010. */
  15011. animations: Animation[];
  15012. /**
  15013. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15014. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15015. */
  15016. enablePixelPerfectMode: boolean;
  15017. /**
  15018. * Force the postprocess to be applied without taking in account viewport
  15019. */
  15020. forceFullscreenViewport: boolean;
  15021. /**
  15022. * List of inspectable custom properties (used by the Inspector)
  15023. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15024. */
  15025. inspectableCustomProperties: IInspectable[];
  15026. /**
  15027. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15028. *
  15029. * | Value | Type | Description |
  15030. * | ----- | ----------------------------------- | ----------- |
  15031. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15032. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15033. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15034. *
  15035. */
  15036. scaleMode: number;
  15037. /**
  15038. * Force textures to be a power of two (default: false)
  15039. */
  15040. alwaysForcePOT: boolean;
  15041. private _samples;
  15042. /**
  15043. * Number of sample textures (default: 1)
  15044. */
  15045. samples: number;
  15046. /**
  15047. * Modify the scale of the post process to be the same as the viewport (default: false)
  15048. */
  15049. adaptScaleToCurrentViewport: boolean;
  15050. private _camera;
  15051. private _scene;
  15052. private _engine;
  15053. private _options;
  15054. private _reusable;
  15055. private _textureType;
  15056. /**
  15057. * Smart array of input and output textures for the post process.
  15058. * @hidden
  15059. */
  15060. _textures: SmartArray<InternalTexture>;
  15061. /**
  15062. * The index in _textures that corresponds to the output texture.
  15063. * @hidden
  15064. */
  15065. _currentRenderTextureInd: number;
  15066. private _effect;
  15067. private _samplers;
  15068. private _fragmentUrl;
  15069. private _vertexUrl;
  15070. private _parameters;
  15071. private _scaleRatio;
  15072. protected _indexParameters: any;
  15073. private _shareOutputWithPostProcess;
  15074. private _texelSize;
  15075. private _forcedOutputTexture;
  15076. /**
  15077. * Returns the fragment url or shader name used in the post process.
  15078. * @returns the fragment url or name in the shader store.
  15079. */
  15080. getEffectName(): string;
  15081. /**
  15082. * An event triggered when the postprocess is activated.
  15083. */
  15084. onActivateObservable: Observable<Camera>;
  15085. private _onActivateObserver;
  15086. /**
  15087. * A function that is added to the onActivateObservable
  15088. */
  15089. onActivate: Nullable<(camera: Camera) => void>;
  15090. /**
  15091. * An event triggered when the postprocess changes its size.
  15092. */
  15093. onSizeChangedObservable: Observable<PostProcess>;
  15094. private _onSizeChangedObserver;
  15095. /**
  15096. * A function that is added to the onSizeChangedObservable
  15097. */
  15098. onSizeChanged: (postProcess: PostProcess) => void;
  15099. /**
  15100. * An event triggered when the postprocess applies its effect.
  15101. */
  15102. onApplyObservable: Observable<Effect>;
  15103. private _onApplyObserver;
  15104. /**
  15105. * A function that is added to the onApplyObservable
  15106. */
  15107. onApply: (effect: Effect) => void;
  15108. /**
  15109. * An event triggered before rendering the postprocess
  15110. */
  15111. onBeforeRenderObservable: Observable<Effect>;
  15112. private _onBeforeRenderObserver;
  15113. /**
  15114. * A function that is added to the onBeforeRenderObservable
  15115. */
  15116. onBeforeRender: (effect: Effect) => void;
  15117. /**
  15118. * An event triggered after rendering the postprocess
  15119. */
  15120. onAfterRenderObservable: Observable<Effect>;
  15121. private _onAfterRenderObserver;
  15122. /**
  15123. * A function that is added to the onAfterRenderObservable
  15124. */
  15125. onAfterRender: (efect: Effect) => void;
  15126. /**
  15127. * 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
  15128. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15129. */
  15130. inputTexture: InternalTexture;
  15131. /**
  15132. * Gets the camera which post process is applied to.
  15133. * @returns The camera the post process is applied to.
  15134. */
  15135. getCamera(): Camera;
  15136. /**
  15137. * Gets the texel size of the postprocess.
  15138. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15139. */
  15140. readonly texelSize: Vector2;
  15141. /**
  15142. * Creates a new instance PostProcess
  15143. * @param name The name of the PostProcess.
  15144. * @param fragmentUrl The url of the fragment shader to be used.
  15145. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15146. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15147. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15148. * @param camera The camera to apply the render pass to.
  15149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15150. * @param engine The engine which the post process will be applied. (default: current engine)
  15151. * @param reusable If the post process can be reused on the same frame. (default: false)
  15152. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15153. * @param textureType Type of textures used when performing the post process. (default: 0)
  15154. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15155. * @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
  15156. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15157. */
  15158. constructor(
  15159. /** Name of the PostProcess. */
  15160. 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);
  15161. /**
  15162. * Gets a string idenfifying the name of the class
  15163. * @returns "PostProcess" string
  15164. */
  15165. getClassName(): string;
  15166. /**
  15167. * Gets the engine which this post process belongs to.
  15168. * @returns The engine the post process was enabled with.
  15169. */
  15170. getEngine(): Engine;
  15171. /**
  15172. * The effect that is created when initializing the post process.
  15173. * @returns The created effect corresponding the the postprocess.
  15174. */
  15175. getEffect(): Effect;
  15176. /**
  15177. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15178. * @param postProcess The post process to share the output with.
  15179. * @returns This post process.
  15180. */
  15181. shareOutputWith(postProcess: PostProcess): PostProcess;
  15182. /**
  15183. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15184. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15185. */
  15186. useOwnOutput(): void;
  15187. /**
  15188. * Updates the effect with the current post process compile time values and recompiles the shader.
  15189. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15190. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15191. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15192. * @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
  15193. * @param onCompiled Called when the shader has been compiled.
  15194. * @param onError Called if there is an error when compiling a shader.
  15195. */
  15196. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15197. /**
  15198. * The post process is reusable if it can be used multiple times within one frame.
  15199. * @returns If the post process is reusable
  15200. */
  15201. isReusable(): boolean;
  15202. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15203. markTextureDirty(): void;
  15204. /**
  15205. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15206. * 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.
  15207. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15208. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15209. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15210. * @returns The target texture that was bound to be written to.
  15211. */
  15212. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15213. /**
  15214. * If the post process is supported.
  15215. */
  15216. readonly isSupported: boolean;
  15217. /**
  15218. * The aspect ratio of the output texture.
  15219. */
  15220. readonly aspectRatio: number;
  15221. /**
  15222. * Get a value indicating if the post-process is ready to be used
  15223. * @returns true if the post-process is ready (shader is compiled)
  15224. */
  15225. isReady(): boolean;
  15226. /**
  15227. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15228. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15229. */
  15230. apply(): Nullable<Effect>;
  15231. private _disposeTextures;
  15232. /**
  15233. * Disposes the post process.
  15234. * @param camera The camera to dispose the post process on.
  15235. */
  15236. dispose(camera?: Camera): void;
  15237. }
  15238. }
  15239. declare module BABYLON {
  15240. /** @hidden */
  15241. export var kernelBlurVaryingDeclaration: {
  15242. name: string;
  15243. shader: string;
  15244. };
  15245. }
  15246. declare module BABYLON {
  15247. /** @hidden */
  15248. export var kernelBlurFragment: {
  15249. name: string;
  15250. shader: string;
  15251. };
  15252. }
  15253. declare module BABYLON {
  15254. /** @hidden */
  15255. export var kernelBlurFragment2: {
  15256. name: string;
  15257. shader: string;
  15258. };
  15259. }
  15260. declare module BABYLON {
  15261. /** @hidden */
  15262. export var kernelBlurPixelShader: {
  15263. name: string;
  15264. shader: string;
  15265. };
  15266. }
  15267. declare module BABYLON {
  15268. /** @hidden */
  15269. export var kernelBlurVertex: {
  15270. name: string;
  15271. shader: string;
  15272. };
  15273. }
  15274. declare module BABYLON {
  15275. /** @hidden */
  15276. export var kernelBlurVertexShader: {
  15277. name: string;
  15278. shader: string;
  15279. };
  15280. }
  15281. declare module BABYLON {
  15282. /**
  15283. * The Blur Post Process which blurs an image based on a kernel and direction.
  15284. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15285. */
  15286. export class BlurPostProcess extends PostProcess {
  15287. /** The direction in which to blur the image. */
  15288. direction: Vector2;
  15289. private blockCompilation;
  15290. protected _kernel: number;
  15291. protected _idealKernel: number;
  15292. protected _packedFloat: boolean;
  15293. private _staticDefines;
  15294. /**
  15295. * Sets the length in pixels of the blur sample region
  15296. */
  15297. /**
  15298. * Gets the length in pixels of the blur sample region
  15299. */
  15300. kernel: number;
  15301. /**
  15302. * Sets wether or not the blur needs to unpack/repack floats
  15303. */
  15304. /**
  15305. * Gets wether or not the blur is unpacking/repacking floats
  15306. */
  15307. packedFloat: boolean;
  15308. /**
  15309. * Creates a new instance BlurPostProcess
  15310. * @param name The name of the effect.
  15311. * @param direction The direction in which to blur the image.
  15312. * @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.
  15313. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15314. * @param camera The camera to apply the render pass to.
  15315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15316. * @param engine The engine which the post process will be applied. (default: current engine)
  15317. * @param reusable If the post process can be reused on the same frame. (default: false)
  15318. * @param textureType Type of textures used when performing the post process. (default: 0)
  15319. * @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)
  15320. */
  15321. constructor(name: string,
  15322. /** The direction in which to blur the image. */
  15323. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15324. /**
  15325. * Updates the effect with the current post process compile time values and recompiles the shader.
  15326. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15327. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15328. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15329. * @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
  15330. * @param onCompiled Called when the shader has been compiled.
  15331. * @param onError Called if there is an error when compiling a shader.
  15332. */
  15333. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15334. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15335. /**
  15336. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15337. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15338. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15339. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15340. * The gaps between physical kernels are compensated for in the weighting of the samples
  15341. * @param idealKernel Ideal blur kernel.
  15342. * @return Nearest best kernel.
  15343. */
  15344. protected _nearestBestKernel(idealKernel: number): number;
  15345. /**
  15346. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15347. * @param x The point on the Gaussian distribution to sample.
  15348. * @return the value of the Gaussian function at x.
  15349. */
  15350. protected _gaussianWeight(x: number): number;
  15351. /**
  15352. * Generates a string that can be used as a floating point number in GLSL.
  15353. * @param x Value to print.
  15354. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15355. * @return GLSL float string.
  15356. */
  15357. protected _glslFloat(x: number, decimalFigures?: number): string;
  15358. }
  15359. }
  15360. declare module BABYLON {
  15361. /**
  15362. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15363. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15364. * You can then easily use it as a reflectionTexture on a flat surface.
  15365. * In case the surface is not a plane, please consider relying on reflection probes.
  15366. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15367. */
  15368. export class MirrorTexture extends RenderTargetTexture {
  15369. private scene;
  15370. /**
  15371. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15372. * 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.
  15373. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15374. */
  15375. mirrorPlane: Plane;
  15376. /**
  15377. * Define the blur ratio used to blur the reflection if needed.
  15378. */
  15379. blurRatio: number;
  15380. /**
  15381. * Define the adaptive blur kernel used to blur the reflection if needed.
  15382. * This will autocompute the closest best match for the `blurKernel`
  15383. */
  15384. adaptiveBlurKernel: number;
  15385. /**
  15386. * Define the blur kernel used to blur the reflection if needed.
  15387. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15388. */
  15389. blurKernel: number;
  15390. /**
  15391. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15392. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15393. */
  15394. blurKernelX: number;
  15395. /**
  15396. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15397. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15398. */
  15399. blurKernelY: number;
  15400. private _autoComputeBlurKernel;
  15401. protected _onRatioRescale(): void;
  15402. private _updateGammaSpace;
  15403. private _imageProcessingConfigChangeObserver;
  15404. private _transformMatrix;
  15405. private _mirrorMatrix;
  15406. private _savedViewMatrix;
  15407. private _blurX;
  15408. private _blurY;
  15409. private _adaptiveBlurKernel;
  15410. private _blurKernelX;
  15411. private _blurKernelY;
  15412. private _blurRatio;
  15413. /**
  15414. * Instantiates a Mirror Texture.
  15415. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15416. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15417. * You can then easily use it as a reflectionTexture on a flat surface.
  15418. * In case the surface is not a plane, please consider relying on reflection probes.
  15419. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15420. * @param name
  15421. * @param size
  15422. * @param scene
  15423. * @param generateMipMaps
  15424. * @param type
  15425. * @param samplingMode
  15426. * @param generateDepthBuffer
  15427. */
  15428. constructor(name: string, size: number | {
  15429. width: number;
  15430. height: number;
  15431. } | {
  15432. ratio: number;
  15433. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15434. private _preparePostProcesses;
  15435. /**
  15436. * Clone the mirror texture.
  15437. * @returns the cloned texture
  15438. */
  15439. clone(): MirrorTexture;
  15440. /**
  15441. * Serialize the texture to a JSON representation you could use in Parse later on
  15442. * @returns the serialized JSON representation
  15443. */
  15444. serialize(): any;
  15445. /**
  15446. * Dispose the texture and release its associated resources.
  15447. */
  15448. dispose(): void;
  15449. }
  15450. }
  15451. declare module BABYLON {
  15452. /**
  15453. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15454. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15455. */
  15456. export class Texture extends BaseTexture {
  15457. /** @hidden */
  15458. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15459. /** @hidden */
  15460. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15461. /** @hidden */
  15462. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15463. /** nearest is mag = nearest and min = nearest and mip = linear */
  15464. static readonly NEAREST_SAMPLINGMODE: number;
  15465. /** nearest is mag = nearest and min = nearest and mip = linear */
  15466. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15467. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15468. static readonly BILINEAR_SAMPLINGMODE: number;
  15469. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15470. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15471. /** Trilinear is mag = linear and min = linear and mip = linear */
  15472. static readonly TRILINEAR_SAMPLINGMODE: number;
  15473. /** Trilinear is mag = linear and min = linear and mip = linear */
  15474. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15475. /** mag = nearest and min = nearest and mip = nearest */
  15476. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15477. /** mag = nearest and min = linear and mip = nearest */
  15478. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15479. /** mag = nearest and min = linear and mip = linear */
  15480. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15481. /** mag = nearest and min = linear and mip = none */
  15482. static readonly NEAREST_LINEAR: number;
  15483. /** mag = nearest and min = nearest and mip = none */
  15484. static readonly NEAREST_NEAREST: number;
  15485. /** mag = linear and min = nearest and mip = nearest */
  15486. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15487. /** mag = linear and min = nearest and mip = linear */
  15488. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15489. /** mag = linear and min = linear and mip = none */
  15490. static readonly LINEAR_LINEAR: number;
  15491. /** mag = linear and min = nearest and mip = none */
  15492. static readonly LINEAR_NEAREST: number;
  15493. /** Explicit coordinates mode */
  15494. static readonly EXPLICIT_MODE: number;
  15495. /** Spherical coordinates mode */
  15496. static readonly SPHERICAL_MODE: number;
  15497. /** Planar coordinates mode */
  15498. static readonly PLANAR_MODE: number;
  15499. /** Cubic coordinates mode */
  15500. static readonly CUBIC_MODE: number;
  15501. /** Projection coordinates mode */
  15502. static readonly PROJECTION_MODE: number;
  15503. /** Inverse Cubic coordinates mode */
  15504. static readonly SKYBOX_MODE: number;
  15505. /** Inverse Cubic coordinates mode */
  15506. static readonly INVCUBIC_MODE: number;
  15507. /** Equirectangular coordinates mode */
  15508. static readonly EQUIRECTANGULAR_MODE: number;
  15509. /** Equirectangular Fixed coordinates mode */
  15510. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15511. /** Equirectangular Fixed Mirrored coordinates mode */
  15512. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15513. /** Texture is not repeating outside of 0..1 UVs */
  15514. static readonly CLAMP_ADDRESSMODE: number;
  15515. /** Texture is repeating outside of 0..1 UVs */
  15516. static readonly WRAP_ADDRESSMODE: number;
  15517. /** Texture is repeating and mirrored */
  15518. static readonly MIRROR_ADDRESSMODE: number;
  15519. /**
  15520. * 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
  15521. */
  15522. static UseSerializedUrlIfAny: boolean;
  15523. /**
  15524. * Define the url of the texture.
  15525. */
  15526. url: Nullable<string>;
  15527. /**
  15528. * Define an offset on the texture to offset the u coordinates of the UVs
  15529. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15530. */
  15531. uOffset: number;
  15532. /**
  15533. * Define an offset on the texture to offset the v coordinates of the UVs
  15534. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15535. */
  15536. vOffset: number;
  15537. /**
  15538. * Define an offset on the texture to scale the u coordinates of the UVs
  15539. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15540. */
  15541. uScale: number;
  15542. /**
  15543. * Define an offset on the texture to scale the v coordinates of the UVs
  15544. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15545. */
  15546. vScale: number;
  15547. /**
  15548. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15549. * @see http://doc.babylonjs.com/how_to/more_materials
  15550. */
  15551. uAng: number;
  15552. /**
  15553. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15554. * @see http://doc.babylonjs.com/how_to/more_materials
  15555. */
  15556. vAng: number;
  15557. /**
  15558. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15559. * @see http://doc.babylonjs.com/how_to/more_materials
  15560. */
  15561. wAng: number;
  15562. /**
  15563. * Defines the center of rotation (U)
  15564. */
  15565. uRotationCenter: number;
  15566. /**
  15567. * Defines the center of rotation (V)
  15568. */
  15569. vRotationCenter: number;
  15570. /**
  15571. * Defines the center of rotation (W)
  15572. */
  15573. wRotationCenter: number;
  15574. /**
  15575. * Are mip maps generated for this texture or not.
  15576. */
  15577. readonly noMipmap: boolean;
  15578. /**
  15579. * List of inspectable custom properties (used by the Inspector)
  15580. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15581. */
  15582. inspectableCustomProperties: Nullable<IInspectable[]>;
  15583. private _noMipmap;
  15584. /** @hidden */
  15585. _invertY: boolean;
  15586. private _rowGenerationMatrix;
  15587. private _cachedTextureMatrix;
  15588. private _projectionModeMatrix;
  15589. private _t0;
  15590. private _t1;
  15591. private _t2;
  15592. private _cachedUOffset;
  15593. private _cachedVOffset;
  15594. private _cachedUScale;
  15595. private _cachedVScale;
  15596. private _cachedUAng;
  15597. private _cachedVAng;
  15598. private _cachedWAng;
  15599. private _cachedProjectionMatrixId;
  15600. private _cachedCoordinatesMode;
  15601. /** @hidden */
  15602. protected _initialSamplingMode: number;
  15603. /** @hidden */
  15604. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15605. private _deleteBuffer;
  15606. protected _format: Nullable<number>;
  15607. private _delayedOnLoad;
  15608. private _delayedOnError;
  15609. /**
  15610. * Observable triggered once the texture has been loaded.
  15611. */
  15612. onLoadObservable: Observable<Texture>;
  15613. protected _isBlocking: boolean;
  15614. /**
  15615. * Is the texture preventing material to render while loading.
  15616. * If false, a default texture will be used instead of the loading one during the preparation step.
  15617. */
  15618. isBlocking: boolean;
  15619. /**
  15620. * Get the current sampling mode associated with the texture.
  15621. */
  15622. readonly samplingMode: number;
  15623. /**
  15624. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15625. */
  15626. readonly invertY: boolean;
  15627. /**
  15628. * Instantiates a new texture.
  15629. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15630. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15631. * @param url define the url of the picture to load as a texture
  15632. * @param scene define the scene or engine the texture will belong to
  15633. * @param noMipmap define if the texture will require mip maps or not
  15634. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15635. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15636. * @param onLoad define a callback triggered when the texture has been loaded
  15637. * @param onError define a callback triggered when an error occurred during the loading session
  15638. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15639. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15640. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15641. */
  15642. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15643. /**
  15644. * Update the url (and optional buffer) of this texture if url was null during construction.
  15645. * @param url the url of the texture
  15646. * @param buffer the buffer of the texture (defaults to null)
  15647. * @param onLoad callback called when the texture is loaded (defaults to null)
  15648. */
  15649. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15650. /**
  15651. * Finish the loading sequence of a texture flagged as delayed load.
  15652. * @hidden
  15653. */
  15654. delayLoad(): void;
  15655. private _prepareRowForTextureGeneration;
  15656. /**
  15657. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15658. * @returns the transform matrix of the texture.
  15659. */
  15660. getTextureMatrix(): Matrix;
  15661. /**
  15662. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15663. * @returns The reflection texture transform
  15664. */
  15665. getReflectionTextureMatrix(): Matrix;
  15666. /**
  15667. * Clones the texture.
  15668. * @returns the cloned texture
  15669. */
  15670. clone(): Texture;
  15671. /**
  15672. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15673. * @returns The JSON representation of the texture
  15674. */
  15675. serialize(): any;
  15676. /**
  15677. * Get the current class name of the texture useful for serialization or dynamic coding.
  15678. * @returns "Texture"
  15679. */
  15680. getClassName(): string;
  15681. /**
  15682. * Dispose the texture and release its associated resources.
  15683. */
  15684. dispose(): void;
  15685. /**
  15686. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15687. * @param parsedTexture Define the JSON representation of the texture
  15688. * @param scene Define the scene the parsed texture should be instantiated in
  15689. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15690. * @returns The parsed texture if successful
  15691. */
  15692. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15693. /**
  15694. * Creates a texture from its base 64 representation.
  15695. * @param data Define the base64 payload without the data: prefix
  15696. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15697. * @param scene Define the scene the texture should belong to
  15698. * @param noMipmap Forces the texture to not create mip map information if true
  15699. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15700. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15701. * @param onLoad define a callback triggered when the texture has been loaded
  15702. * @param onError define a callback triggered when an error occurred during the loading session
  15703. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15704. * @returns the created texture
  15705. */
  15706. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15707. /**
  15708. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15709. * @param data Define the base64 payload without the data: prefix
  15710. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15711. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15712. * @param scene Define the scene the texture should belong to
  15713. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15714. * @param noMipmap Forces the texture to not create mip map information if true
  15715. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15716. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15717. * @param onLoad define a callback triggered when the texture has been loaded
  15718. * @param onError define a callback triggered when an error occurred during the loading session
  15719. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15720. * @returns the created texture
  15721. */
  15722. 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;
  15723. }
  15724. }
  15725. declare module BABYLON {
  15726. /**
  15727. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15728. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15729. */
  15730. export class PostProcessManager {
  15731. private _scene;
  15732. private _indexBuffer;
  15733. private _vertexBuffers;
  15734. /**
  15735. * Creates a new instance PostProcess
  15736. * @param scene The scene that the post process is associated with.
  15737. */
  15738. constructor(scene: Scene);
  15739. private _prepareBuffers;
  15740. private _buildIndexBuffer;
  15741. /**
  15742. * Rebuilds the vertex buffers of the manager.
  15743. * @hidden
  15744. */
  15745. _rebuild(): void;
  15746. /**
  15747. * Prepares a frame to be run through a post process.
  15748. * @param sourceTexture The input texture to the post procesess. (default: null)
  15749. * @param postProcesses An array of post processes to be run. (default: null)
  15750. * @returns True if the post processes were able to be run.
  15751. * @hidden
  15752. */
  15753. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15754. /**
  15755. * Manually render a set of post processes to a texture.
  15756. * @param postProcesses An array of post processes to be run.
  15757. * @param targetTexture The target texture to render to.
  15758. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15759. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15760. * @param lodLevel defines which lod of the texture to render to
  15761. */
  15762. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15763. /**
  15764. * Finalize the result of the output of the postprocesses.
  15765. * @param doNotPresent If true the result will not be displayed to the screen.
  15766. * @param targetTexture The target texture to render to.
  15767. * @param faceIndex The index of the face to bind the target texture to.
  15768. * @param postProcesses The array of post processes to render.
  15769. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15770. * @hidden
  15771. */
  15772. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15773. /**
  15774. * Disposes of the post process manager.
  15775. */
  15776. dispose(): void;
  15777. }
  15778. }
  15779. declare module BABYLON {
  15780. /** Interface used by value gradients (color, factor, ...) */
  15781. export interface IValueGradient {
  15782. /**
  15783. * Gets or sets the gradient value (between 0 and 1)
  15784. */
  15785. gradient: number;
  15786. }
  15787. /** Class used to store color4 gradient */
  15788. export class ColorGradient implements IValueGradient {
  15789. /**
  15790. * Gets or sets the gradient value (between 0 and 1)
  15791. */
  15792. gradient: number;
  15793. /**
  15794. * Gets or sets first associated color
  15795. */
  15796. color1: Color4;
  15797. /**
  15798. * Gets or sets second associated color
  15799. */
  15800. color2?: Color4;
  15801. /**
  15802. * Will get a color picked randomly between color1 and color2.
  15803. * If color2 is undefined then color1 will be used
  15804. * @param result defines the target Color4 to store the result in
  15805. */
  15806. getColorToRef(result: Color4): void;
  15807. }
  15808. /** Class used to store color 3 gradient */
  15809. export class Color3Gradient implements IValueGradient {
  15810. /**
  15811. * Gets or sets the gradient value (between 0 and 1)
  15812. */
  15813. gradient: number;
  15814. /**
  15815. * Gets or sets the associated color
  15816. */
  15817. color: Color3;
  15818. }
  15819. /** Class used to store factor gradient */
  15820. export class FactorGradient implements IValueGradient {
  15821. /**
  15822. * Gets or sets the gradient value (between 0 and 1)
  15823. */
  15824. gradient: number;
  15825. /**
  15826. * Gets or sets first associated factor
  15827. */
  15828. factor1: number;
  15829. /**
  15830. * Gets or sets second associated factor
  15831. */
  15832. factor2?: number;
  15833. /**
  15834. * Will get a number picked randomly between factor1 and factor2.
  15835. * If factor2 is undefined then factor1 will be used
  15836. * @returns the picked number
  15837. */
  15838. getFactor(): number;
  15839. }
  15840. /**
  15841. * Helper used to simplify some generic gradient tasks
  15842. */
  15843. export class GradientHelper {
  15844. /**
  15845. * Gets the current gradient from an array of IValueGradient
  15846. * @param ratio defines the current ratio to get
  15847. * @param gradients defines the array of IValueGradient
  15848. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15849. */
  15850. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15851. }
  15852. }
  15853. declare module BABYLON {
  15854. interface AbstractScene {
  15855. /**
  15856. * The list of procedural textures added to the scene
  15857. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15858. */
  15859. proceduralTextures: Array<ProceduralTexture>;
  15860. }
  15861. /**
  15862. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15863. * in a given scene.
  15864. */
  15865. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15866. /**
  15867. * The component name helpfull to identify the component in the list of scene components.
  15868. */
  15869. readonly name: string;
  15870. /**
  15871. * The scene the component belongs to.
  15872. */
  15873. scene: Scene;
  15874. /**
  15875. * Creates a new instance of the component for the given scene
  15876. * @param scene Defines the scene to register the component in
  15877. */
  15878. constructor(scene: Scene);
  15879. /**
  15880. * Registers the component in a given scene
  15881. */
  15882. register(): void;
  15883. /**
  15884. * Rebuilds the elements related to this component in case of
  15885. * context lost for instance.
  15886. */
  15887. rebuild(): void;
  15888. /**
  15889. * Disposes the component and the associated ressources.
  15890. */
  15891. dispose(): void;
  15892. private _beforeClear;
  15893. }
  15894. }
  15895. declare module BABYLON {
  15896. interface Engine {
  15897. /**
  15898. * Creates a new render target cube texture
  15899. * @param size defines the size of the texture
  15900. * @param options defines the options used to create the texture
  15901. * @returns a new render target cube texture stored in an InternalTexture
  15902. */
  15903. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15904. }
  15905. }
  15906. declare module BABYLON {
  15907. /** @hidden */
  15908. export var proceduralVertexShader: {
  15909. name: string;
  15910. shader: string;
  15911. };
  15912. }
  15913. declare module BABYLON {
  15914. /**
  15915. * 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.
  15916. * This is the base class of any Procedural texture and contains most of the shareable code.
  15917. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15918. */
  15919. export class ProceduralTexture extends Texture {
  15920. isCube: boolean;
  15921. /**
  15922. * Define if the texture is enabled or not (disabled texture will not render)
  15923. */
  15924. isEnabled: boolean;
  15925. /**
  15926. * Define if the texture must be cleared before rendering (default is true)
  15927. */
  15928. autoClear: boolean;
  15929. /**
  15930. * Callback called when the texture is generated
  15931. */
  15932. onGenerated: () => void;
  15933. /**
  15934. * Event raised when the texture is generated
  15935. */
  15936. onGeneratedObservable: Observable<ProceduralTexture>;
  15937. /** @hidden */
  15938. _generateMipMaps: boolean;
  15939. /** @hidden **/
  15940. _effect: Effect;
  15941. /** @hidden */
  15942. _textures: {
  15943. [key: string]: Texture;
  15944. };
  15945. private _size;
  15946. private _currentRefreshId;
  15947. private _refreshRate;
  15948. private _vertexBuffers;
  15949. private _indexBuffer;
  15950. private _uniforms;
  15951. private _samplers;
  15952. private _fragment;
  15953. private _floats;
  15954. private _ints;
  15955. private _floatsArrays;
  15956. private _colors3;
  15957. private _colors4;
  15958. private _vectors2;
  15959. private _vectors3;
  15960. private _matrices;
  15961. private _fallbackTexture;
  15962. private _fallbackTextureUsed;
  15963. private _engine;
  15964. private _cachedDefines;
  15965. private _contentUpdateId;
  15966. private _contentData;
  15967. /**
  15968. * Instantiates a new procedural texture.
  15969. * 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.
  15970. * This is the base class of any Procedural texture and contains most of the shareable code.
  15971. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15972. * @param name Define the name of the texture
  15973. * @param size Define the size of the texture to create
  15974. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15975. * @param scene Define the scene the texture belongs to
  15976. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15977. * @param generateMipMaps Define if the texture should creates mip maps or not
  15978. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15979. */
  15980. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  15981. /**
  15982. * The effect that is created when initializing the post process.
  15983. * @returns The created effect corresponding the the postprocess.
  15984. */
  15985. getEffect(): Effect;
  15986. /**
  15987. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  15988. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  15989. */
  15990. getContent(): Nullable<ArrayBufferView>;
  15991. private _createIndexBuffer;
  15992. /** @hidden */
  15993. _rebuild(): void;
  15994. /**
  15995. * Resets the texture in order to recreate its associated resources.
  15996. * This can be called in case of context loss
  15997. */
  15998. reset(): void;
  15999. protected _getDefines(): string;
  16000. /**
  16001. * Is the texture ready to be used ? (rendered at least once)
  16002. * @returns true if ready, otherwise, false.
  16003. */
  16004. isReady(): boolean;
  16005. /**
  16006. * Resets the refresh counter of the texture and start bak from scratch.
  16007. * Could be useful to regenerate the texture if it is setup to render only once.
  16008. */
  16009. resetRefreshCounter(): void;
  16010. /**
  16011. * Set the fragment shader to use in order to render the texture.
  16012. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16013. */
  16014. setFragment(fragment: any): void;
  16015. /**
  16016. * Define the refresh rate of the texture or the rendering frequency.
  16017. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16018. */
  16019. refreshRate: number;
  16020. /** @hidden */
  16021. _shouldRender(): boolean;
  16022. /**
  16023. * Get the size the texture is rendering at.
  16024. * @returns the size (texture is always squared)
  16025. */
  16026. getRenderSize(): number;
  16027. /**
  16028. * Resize the texture to new value.
  16029. * @param size Define the new size the texture should have
  16030. * @param generateMipMaps Define whether the new texture should create mip maps
  16031. */
  16032. resize(size: number, generateMipMaps: boolean): void;
  16033. private _checkUniform;
  16034. /**
  16035. * Set a texture in the shader program used to render.
  16036. * @param name Define the name of the uniform samplers as defined in the shader
  16037. * @param texture Define the texture to bind to this sampler
  16038. * @return the texture itself allowing "fluent" like uniform updates
  16039. */
  16040. setTexture(name: string, texture: Texture): ProceduralTexture;
  16041. /**
  16042. * Set a float in the shader.
  16043. * @param name Define the name of the uniform as defined in the shader
  16044. * @param value Define the value to give to the uniform
  16045. * @return the texture itself allowing "fluent" like uniform updates
  16046. */
  16047. setFloat(name: string, value: number): ProceduralTexture;
  16048. /**
  16049. * Set a int in the shader.
  16050. * @param name Define the name of the uniform as defined in the shader
  16051. * @param value Define the value to give to the uniform
  16052. * @return the texture itself allowing "fluent" like uniform updates
  16053. */
  16054. setInt(name: string, value: number): ProceduralTexture;
  16055. /**
  16056. * Set an array of floats in the shader.
  16057. * @param name Define the name of the uniform as defined in the shader
  16058. * @param value Define the value to give to the uniform
  16059. * @return the texture itself allowing "fluent" like uniform updates
  16060. */
  16061. setFloats(name: string, value: number[]): ProceduralTexture;
  16062. /**
  16063. * Set a vec3 in the shader from a Color3.
  16064. * @param name Define the name of the uniform as defined in the shader
  16065. * @param value Define the value to give to the uniform
  16066. * @return the texture itself allowing "fluent" like uniform updates
  16067. */
  16068. setColor3(name: string, value: Color3): ProceduralTexture;
  16069. /**
  16070. * Set a vec4 in the shader from a Color4.
  16071. * @param name Define the name of the uniform as defined in the shader
  16072. * @param value Define the value to give to the uniform
  16073. * @return the texture itself allowing "fluent" like uniform updates
  16074. */
  16075. setColor4(name: string, value: Color4): ProceduralTexture;
  16076. /**
  16077. * Set a vec2 in the shader from a Vector2.
  16078. * @param name Define the name of the uniform as defined in the shader
  16079. * @param value Define the value to give to the uniform
  16080. * @return the texture itself allowing "fluent" like uniform updates
  16081. */
  16082. setVector2(name: string, value: Vector2): ProceduralTexture;
  16083. /**
  16084. * Set a vec3 in the shader from a Vector3.
  16085. * @param name Define the name of the uniform as defined in the shader
  16086. * @param value Define the value to give to the uniform
  16087. * @return the texture itself allowing "fluent" like uniform updates
  16088. */
  16089. setVector3(name: string, value: Vector3): ProceduralTexture;
  16090. /**
  16091. * Set a mat4 in the shader from a MAtrix.
  16092. * @param name Define the name of the uniform as defined in the shader
  16093. * @param value Define the value to give to the uniform
  16094. * @return the texture itself allowing "fluent" like uniform updates
  16095. */
  16096. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16097. /**
  16098. * Render the texture to its associated render target.
  16099. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16100. */
  16101. render(useCameraPostProcess?: boolean): void;
  16102. /**
  16103. * Clone the texture.
  16104. * @returns the cloned texture
  16105. */
  16106. clone(): ProceduralTexture;
  16107. /**
  16108. * Dispose the texture and release its asoociated resources.
  16109. */
  16110. dispose(): void;
  16111. }
  16112. }
  16113. declare module BABYLON {
  16114. /**
  16115. * This represents the base class for particle system in Babylon.
  16116. * 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.
  16117. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16118. * @example https://doc.babylonjs.com/babylon101/particles
  16119. */
  16120. export class BaseParticleSystem {
  16121. /**
  16122. * Source color is added to the destination color without alpha affecting the result
  16123. */
  16124. static BLENDMODE_ONEONE: number;
  16125. /**
  16126. * Blend current color and particle color using particle’s alpha
  16127. */
  16128. static BLENDMODE_STANDARD: number;
  16129. /**
  16130. * Add current color and particle color multiplied by particle’s alpha
  16131. */
  16132. static BLENDMODE_ADD: number;
  16133. /**
  16134. * Multiply current color with particle color
  16135. */
  16136. static BLENDMODE_MULTIPLY: number;
  16137. /**
  16138. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16139. */
  16140. static BLENDMODE_MULTIPLYADD: number;
  16141. /**
  16142. * List of animations used by the particle system.
  16143. */
  16144. animations: Animation[];
  16145. /**
  16146. * The id of the Particle system.
  16147. */
  16148. id: string;
  16149. /**
  16150. * The friendly name of the Particle system.
  16151. */
  16152. name: string;
  16153. /**
  16154. * The rendering group used by the Particle system to chose when to render.
  16155. */
  16156. renderingGroupId: number;
  16157. /**
  16158. * The emitter represents the Mesh or position we are attaching the particle system to.
  16159. */
  16160. emitter: Nullable<AbstractMesh | Vector3>;
  16161. /**
  16162. * The maximum number of particles to emit per frame
  16163. */
  16164. emitRate: number;
  16165. /**
  16166. * If you want to launch only a few particles at once, that can be done, as well.
  16167. */
  16168. manualEmitCount: number;
  16169. /**
  16170. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16171. */
  16172. updateSpeed: number;
  16173. /**
  16174. * The amount of time the particle system is running (depends of the overall update speed).
  16175. */
  16176. targetStopDuration: number;
  16177. /**
  16178. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16179. */
  16180. disposeOnStop: boolean;
  16181. /**
  16182. * Minimum power of emitting particles.
  16183. */
  16184. minEmitPower: number;
  16185. /**
  16186. * Maximum power of emitting particles.
  16187. */
  16188. maxEmitPower: number;
  16189. /**
  16190. * Minimum life time of emitting particles.
  16191. */
  16192. minLifeTime: number;
  16193. /**
  16194. * Maximum life time of emitting particles.
  16195. */
  16196. maxLifeTime: number;
  16197. /**
  16198. * Minimum Size of emitting particles.
  16199. */
  16200. minSize: number;
  16201. /**
  16202. * Maximum Size of emitting particles.
  16203. */
  16204. maxSize: number;
  16205. /**
  16206. * Minimum scale of emitting particles on X axis.
  16207. */
  16208. minScaleX: number;
  16209. /**
  16210. * Maximum scale of emitting particles on X axis.
  16211. */
  16212. maxScaleX: number;
  16213. /**
  16214. * Minimum scale of emitting particles on Y axis.
  16215. */
  16216. minScaleY: number;
  16217. /**
  16218. * Maximum scale of emitting particles on Y axis.
  16219. */
  16220. maxScaleY: number;
  16221. /**
  16222. * Gets or sets the minimal initial rotation in radians.
  16223. */
  16224. minInitialRotation: number;
  16225. /**
  16226. * Gets or sets the maximal initial rotation in radians.
  16227. */
  16228. maxInitialRotation: number;
  16229. /**
  16230. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16231. */
  16232. minAngularSpeed: number;
  16233. /**
  16234. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16235. */
  16236. maxAngularSpeed: number;
  16237. /**
  16238. * The texture used to render each particle. (this can be a spritesheet)
  16239. */
  16240. particleTexture: Nullable<Texture>;
  16241. /**
  16242. * The layer mask we are rendering the particles through.
  16243. */
  16244. layerMask: number;
  16245. /**
  16246. * This can help using your own shader to render the particle system.
  16247. * The according effect will be created
  16248. */
  16249. customShader: any;
  16250. /**
  16251. * By default particle system starts as soon as they are created. This prevents the
  16252. * automatic start to happen and let you decide when to start emitting particles.
  16253. */
  16254. preventAutoStart: boolean;
  16255. private _noiseTexture;
  16256. /**
  16257. * Gets or sets a texture used to add random noise to particle positions
  16258. */
  16259. noiseTexture: Nullable<ProceduralTexture>;
  16260. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16261. noiseStrength: Vector3;
  16262. /**
  16263. * Callback triggered when the particle animation is ending.
  16264. */
  16265. onAnimationEnd: Nullable<() => void>;
  16266. /**
  16267. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16268. */
  16269. blendMode: number;
  16270. /**
  16271. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16272. * to override the particles.
  16273. */
  16274. forceDepthWrite: boolean;
  16275. /** 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 */
  16276. preWarmCycles: number;
  16277. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16278. preWarmStepOffset: number;
  16279. /**
  16280. * 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)
  16281. */
  16282. spriteCellChangeSpeed: number;
  16283. /**
  16284. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16285. */
  16286. startSpriteCellID: number;
  16287. /**
  16288. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16289. */
  16290. endSpriteCellID: number;
  16291. /**
  16292. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16293. */
  16294. spriteCellWidth: number;
  16295. /**
  16296. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16297. */
  16298. spriteCellHeight: number;
  16299. /**
  16300. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16301. */
  16302. spriteRandomStartCell: boolean;
  16303. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16304. translationPivot: Vector2;
  16305. /** @hidden */
  16306. protected _isAnimationSheetEnabled: boolean;
  16307. /**
  16308. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16309. */
  16310. beginAnimationOnStart: boolean;
  16311. /**
  16312. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16313. */
  16314. beginAnimationFrom: number;
  16315. /**
  16316. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16317. */
  16318. beginAnimationTo: number;
  16319. /**
  16320. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16321. */
  16322. beginAnimationLoop: boolean;
  16323. /**
  16324. * Gets or sets a world offset applied to all particles
  16325. */
  16326. worldOffset: Vector3;
  16327. /**
  16328. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16329. */
  16330. isAnimationSheetEnabled: boolean;
  16331. /**
  16332. * Get hosting scene
  16333. * @returns the scene
  16334. */
  16335. getScene(): Scene;
  16336. /**
  16337. * You can use gravity if you want to give an orientation to your particles.
  16338. */
  16339. gravity: Vector3;
  16340. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16341. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16342. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16343. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16344. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16345. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16346. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16347. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16348. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16349. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16350. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16351. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16352. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16353. /**
  16354. * Defines the delay in milliseconds before starting the system (0 by default)
  16355. */
  16356. startDelay: number;
  16357. /**
  16358. * Gets the current list of drag gradients.
  16359. * You must use addDragGradient and removeDragGradient to udpate this list
  16360. * @returns the list of drag gradients
  16361. */
  16362. getDragGradients(): Nullable<Array<FactorGradient>>;
  16363. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16364. limitVelocityDamping: number;
  16365. /**
  16366. * Gets the current list of limit velocity gradients.
  16367. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16368. * @returns the list of limit velocity gradients
  16369. */
  16370. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16371. /**
  16372. * Gets the current list of color gradients.
  16373. * You must use addColorGradient and removeColorGradient to udpate this list
  16374. * @returns the list of color gradients
  16375. */
  16376. getColorGradients(): Nullable<Array<ColorGradient>>;
  16377. /**
  16378. * Gets the current list of size gradients.
  16379. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16380. * @returns the list of size gradients
  16381. */
  16382. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16383. /**
  16384. * Gets the current list of color remap gradients.
  16385. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16386. * @returns the list of color remap gradients
  16387. */
  16388. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16389. /**
  16390. * Gets the current list of alpha remap gradients.
  16391. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16392. * @returns the list of alpha remap gradients
  16393. */
  16394. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16395. /**
  16396. * Gets the current list of life time gradients.
  16397. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16398. * @returns the list of life time gradients
  16399. */
  16400. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16401. /**
  16402. * Gets the current list of angular speed gradients.
  16403. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16404. * @returns the list of angular speed gradients
  16405. */
  16406. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16407. /**
  16408. * Gets the current list of velocity gradients.
  16409. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16410. * @returns the list of velocity gradients
  16411. */
  16412. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16413. /**
  16414. * Gets the current list of start size gradients.
  16415. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16416. * @returns the list of start size gradients
  16417. */
  16418. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16419. /**
  16420. * Gets the current list of emit rate gradients.
  16421. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16422. * @returns the list of emit rate gradients
  16423. */
  16424. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16425. /**
  16426. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16427. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16428. */
  16429. direction1: Vector3;
  16430. /**
  16431. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16432. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16433. */
  16434. direction2: Vector3;
  16435. /**
  16436. * 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.
  16437. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16438. */
  16439. minEmitBox: Vector3;
  16440. /**
  16441. * 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.
  16442. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16443. */
  16444. maxEmitBox: Vector3;
  16445. /**
  16446. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16447. */
  16448. color1: Color4;
  16449. /**
  16450. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16451. */
  16452. color2: Color4;
  16453. /**
  16454. * Color the particle will have at the end of its lifetime
  16455. */
  16456. colorDead: Color4;
  16457. /**
  16458. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16459. */
  16460. textureMask: Color4;
  16461. /**
  16462. * The particle emitter type defines the emitter used by the particle system.
  16463. * It can be for example box, sphere, or cone...
  16464. */
  16465. particleEmitterType: IParticleEmitterType;
  16466. /** @hidden */
  16467. _isSubEmitter: boolean;
  16468. /**
  16469. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16470. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16471. */
  16472. billboardMode: number;
  16473. protected _isBillboardBased: boolean;
  16474. /**
  16475. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16476. */
  16477. isBillboardBased: boolean;
  16478. /**
  16479. * The scene the particle system belongs to.
  16480. */
  16481. protected _scene: Scene;
  16482. /**
  16483. * Local cache of defines for image processing.
  16484. */
  16485. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16486. /**
  16487. * Default configuration related to image processing available in the standard Material.
  16488. */
  16489. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16490. /**
  16491. * Gets the image processing configuration used either in this material.
  16492. */
  16493. /**
  16494. * Sets the Default image processing configuration used either in the this material.
  16495. *
  16496. * If sets to null, the scene one is in use.
  16497. */
  16498. imageProcessingConfiguration: ImageProcessingConfiguration;
  16499. /**
  16500. * Attaches a new image processing configuration to the Standard Material.
  16501. * @param configuration
  16502. */
  16503. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16504. /** @hidden */
  16505. protected _reset(): void;
  16506. /** @hidden */
  16507. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16508. /**
  16509. * Instantiates a particle system.
  16510. * 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.
  16511. * @param name The name of the particle system
  16512. */
  16513. constructor(name: string);
  16514. /**
  16515. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16516. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16517. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16518. * @returns the emitter
  16519. */
  16520. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16521. /**
  16522. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16523. * @param radius The radius of the hemisphere to emit from
  16524. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16525. * @returns the emitter
  16526. */
  16527. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16528. /**
  16529. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16530. * @param radius The radius of the sphere to emit from
  16531. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16532. * @returns the emitter
  16533. */
  16534. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16535. /**
  16536. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16537. * @param radius The radius of the sphere to emit from
  16538. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16539. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16540. * @returns the emitter
  16541. */
  16542. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16543. /**
  16544. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16545. * @param radius The radius of the emission cylinder
  16546. * @param height The height of the emission cylinder
  16547. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16548. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16549. * @returns the emitter
  16550. */
  16551. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16552. /**
  16553. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16554. * @param radius The radius of the cylinder to emit from
  16555. * @param height The height of the emission cylinder
  16556. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16559. * @returns the emitter
  16560. */
  16561. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16562. /**
  16563. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16564. * @param radius The radius of the cone to emit from
  16565. * @param angle The base angle of the cone
  16566. * @returns the emitter
  16567. */
  16568. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16569. /**
  16570. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16573. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16574. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16575. * @returns the emitter
  16576. */
  16577. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16578. }
  16579. }
  16580. declare module BABYLON {
  16581. /**
  16582. * Type of sub emitter
  16583. */
  16584. export enum SubEmitterType {
  16585. /**
  16586. * Attached to the particle over it's lifetime
  16587. */
  16588. ATTACHED = 0,
  16589. /**
  16590. * Created when the particle dies
  16591. */
  16592. END = 1
  16593. }
  16594. /**
  16595. * Sub emitter class used to emit particles from an existing particle
  16596. */
  16597. export class SubEmitter {
  16598. /**
  16599. * the particle system to be used by the sub emitter
  16600. */
  16601. particleSystem: ParticleSystem;
  16602. /**
  16603. * Type of the submitter (Default: END)
  16604. */
  16605. type: SubEmitterType;
  16606. /**
  16607. * 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)
  16608. * Note: This only is supported when using an emitter of type Mesh
  16609. */
  16610. inheritDirection: boolean;
  16611. /**
  16612. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16613. */
  16614. inheritedVelocityAmount: number;
  16615. /**
  16616. * Creates a sub emitter
  16617. * @param particleSystem the particle system to be used by the sub emitter
  16618. */
  16619. constructor(
  16620. /**
  16621. * the particle system to be used by the sub emitter
  16622. */
  16623. particleSystem: ParticleSystem);
  16624. /**
  16625. * Clones the sub emitter
  16626. * @returns the cloned sub emitter
  16627. */
  16628. clone(): SubEmitter;
  16629. /**
  16630. * Serialize current object to a JSON object
  16631. * @returns the serialized object
  16632. */
  16633. serialize(): any;
  16634. /** @hidden */
  16635. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16636. /**
  16637. * Creates a new SubEmitter from a serialized JSON version
  16638. * @param serializationObject defines the JSON object to read from
  16639. * @param scene defines the hosting scene
  16640. * @param rootUrl defines the rootUrl for data loading
  16641. * @returns a new SubEmitter
  16642. */
  16643. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16644. /** Release associated resources */
  16645. dispose(): void;
  16646. }
  16647. }
  16648. declare module BABYLON {
  16649. /** @hidden */
  16650. export var clipPlaneFragmentDeclaration: {
  16651. name: string;
  16652. shader: string;
  16653. };
  16654. }
  16655. declare module BABYLON {
  16656. /** @hidden */
  16657. export var imageProcessingDeclaration: {
  16658. name: string;
  16659. shader: string;
  16660. };
  16661. }
  16662. declare module BABYLON {
  16663. /** @hidden */
  16664. export var imageProcessingFunctions: {
  16665. name: string;
  16666. shader: string;
  16667. };
  16668. }
  16669. declare module BABYLON {
  16670. /** @hidden */
  16671. export var clipPlaneFragment: {
  16672. name: string;
  16673. shader: string;
  16674. };
  16675. }
  16676. declare module BABYLON {
  16677. /** @hidden */
  16678. export var particlesPixelShader: {
  16679. name: string;
  16680. shader: string;
  16681. };
  16682. }
  16683. declare module BABYLON {
  16684. /** @hidden */
  16685. export var clipPlaneVertexDeclaration: {
  16686. name: string;
  16687. shader: string;
  16688. };
  16689. }
  16690. declare module BABYLON {
  16691. /** @hidden */
  16692. export var clipPlaneVertex: {
  16693. name: string;
  16694. shader: string;
  16695. };
  16696. }
  16697. declare module BABYLON {
  16698. /** @hidden */
  16699. export var particlesVertexShader: {
  16700. name: string;
  16701. shader: string;
  16702. };
  16703. }
  16704. declare module BABYLON {
  16705. /**
  16706. * This represents a particle system in Babylon.
  16707. * 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.
  16708. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16709. * @example https://doc.babylonjs.com/babylon101/particles
  16710. */
  16711. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16712. /**
  16713. * Billboard mode will only apply to Y axis
  16714. */
  16715. static readonly BILLBOARDMODE_Y: number;
  16716. /**
  16717. * Billboard mode will apply to all axes
  16718. */
  16719. static readonly BILLBOARDMODE_ALL: number;
  16720. /**
  16721. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16722. */
  16723. static readonly BILLBOARDMODE_STRETCHED: number;
  16724. /**
  16725. * This function can be defined to provide custom update for active particles.
  16726. * This function will be called instead of regular update (age, position, color, etc.).
  16727. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16728. */
  16729. updateFunction: (particles: Particle[]) => void;
  16730. private _emitterWorldMatrix;
  16731. /**
  16732. * This function can be defined to specify initial direction for every new particle.
  16733. * It by default use the emitterType defined function
  16734. */
  16735. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16736. /**
  16737. * This function can be defined to specify initial position for every new particle.
  16738. * It by default use the emitterType defined function
  16739. */
  16740. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16741. /**
  16742. * @hidden
  16743. */
  16744. _inheritedVelocityOffset: Vector3;
  16745. /**
  16746. * An event triggered when the system is disposed
  16747. */
  16748. onDisposeObservable: Observable<ParticleSystem>;
  16749. private _onDisposeObserver;
  16750. /**
  16751. * Sets a callback that will be triggered when the system is disposed
  16752. */
  16753. onDispose: () => void;
  16754. private _particles;
  16755. private _epsilon;
  16756. private _capacity;
  16757. private _stockParticles;
  16758. private _newPartsExcess;
  16759. private _vertexData;
  16760. private _vertexBuffer;
  16761. private _vertexBuffers;
  16762. private _spriteBuffer;
  16763. private _indexBuffer;
  16764. private _effect;
  16765. private _customEffect;
  16766. private _cachedDefines;
  16767. private _scaledColorStep;
  16768. private _colorDiff;
  16769. private _scaledDirection;
  16770. private _scaledGravity;
  16771. private _currentRenderId;
  16772. private _alive;
  16773. private _useInstancing;
  16774. private _started;
  16775. private _stopped;
  16776. private _actualFrame;
  16777. private _scaledUpdateSpeed;
  16778. private _vertexBufferSize;
  16779. /** @hidden */
  16780. _currentEmitRateGradient: Nullable<FactorGradient>;
  16781. /** @hidden */
  16782. _currentEmitRate1: number;
  16783. /** @hidden */
  16784. _currentEmitRate2: number;
  16785. /** @hidden */
  16786. _currentStartSizeGradient: Nullable<FactorGradient>;
  16787. /** @hidden */
  16788. _currentStartSize1: number;
  16789. /** @hidden */
  16790. _currentStartSize2: number;
  16791. private readonly _rawTextureWidth;
  16792. private _rampGradientsTexture;
  16793. private _useRampGradients;
  16794. /** Gets or sets a boolean indicating that ramp gradients must be used
  16795. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16796. */
  16797. useRampGradients: boolean;
  16798. /**
  16799. * 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.
  16800. * 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: [])
  16801. */
  16802. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16803. private _subEmitters;
  16804. /**
  16805. * @hidden
  16806. * If the particle systems emitter should be disposed when the particle system is disposed
  16807. */
  16808. _disposeEmitterOnDispose: boolean;
  16809. /**
  16810. * The current active Sub-systems, this property is used by the root particle system only.
  16811. */
  16812. activeSubSystems: Array<ParticleSystem>;
  16813. private _rootParticleSystem;
  16814. /**
  16815. * Gets the current list of active particles
  16816. */
  16817. readonly particles: Particle[];
  16818. /**
  16819. * Returns the string "ParticleSystem"
  16820. * @returns a string containing the class name
  16821. */
  16822. getClassName(): string;
  16823. /**
  16824. * Instantiates a particle system.
  16825. * 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.
  16826. * @param name The name of the particle system
  16827. * @param capacity The max number of particles alive at the same time
  16828. * @param scene The scene the particle system belongs to
  16829. * @param customEffect a custom effect used to change the way particles are rendered by default
  16830. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16831. * @param epsilon Offset used to render the particles
  16832. */
  16833. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16834. private _addFactorGradient;
  16835. private _removeFactorGradient;
  16836. /**
  16837. * Adds a new life time gradient
  16838. * @param gradient defines the gradient to use (between 0 and 1)
  16839. * @param factor defines the life time factor to affect to the specified gradient
  16840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16841. * @returns the current particle system
  16842. */
  16843. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16844. /**
  16845. * Remove a specific life time gradient
  16846. * @param gradient defines the gradient to remove
  16847. * @returns the current particle system
  16848. */
  16849. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16850. /**
  16851. * Adds a new size gradient
  16852. * @param gradient defines the gradient to use (between 0 and 1)
  16853. * @param factor defines the size factor to affect to the specified gradient
  16854. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16855. * @returns the current particle system
  16856. */
  16857. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16858. /**
  16859. * Remove a specific size gradient
  16860. * @param gradient defines the gradient to remove
  16861. * @returns the current particle system
  16862. */
  16863. removeSizeGradient(gradient: number): IParticleSystem;
  16864. /**
  16865. * Adds a new color remap gradient
  16866. * @param gradient defines the gradient to use (between 0 and 1)
  16867. * @param min defines the color remap minimal range
  16868. * @param max defines the color remap maximal range
  16869. * @returns the current particle system
  16870. */
  16871. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16872. /**
  16873. * Remove a specific color remap gradient
  16874. * @param gradient defines the gradient to remove
  16875. * @returns the current particle system
  16876. */
  16877. removeColorRemapGradient(gradient: number): IParticleSystem;
  16878. /**
  16879. * Adds a new alpha remap gradient
  16880. * @param gradient defines the gradient to use (between 0 and 1)
  16881. * @param min defines the alpha remap minimal range
  16882. * @param max defines the alpha remap maximal range
  16883. * @returns the current particle system
  16884. */
  16885. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16886. /**
  16887. * Remove a specific alpha remap gradient
  16888. * @param gradient defines the gradient to remove
  16889. * @returns the current particle system
  16890. */
  16891. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16892. /**
  16893. * Adds a new angular speed gradient
  16894. * @param gradient defines the gradient to use (between 0 and 1)
  16895. * @param factor defines the angular speed to affect to the specified gradient
  16896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16897. * @returns the current particle system
  16898. */
  16899. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16900. /**
  16901. * Remove a specific angular speed gradient
  16902. * @param gradient defines the gradient to remove
  16903. * @returns the current particle system
  16904. */
  16905. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16906. /**
  16907. * Adds a new velocity gradient
  16908. * @param gradient defines the gradient to use (between 0 and 1)
  16909. * @param factor defines the velocity to affect to the specified gradient
  16910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16911. * @returns the current particle system
  16912. */
  16913. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16914. /**
  16915. * Remove a specific velocity gradient
  16916. * @param gradient defines the gradient to remove
  16917. * @returns the current particle system
  16918. */
  16919. removeVelocityGradient(gradient: number): IParticleSystem;
  16920. /**
  16921. * Adds a new limit velocity gradient
  16922. * @param gradient defines the gradient to use (between 0 and 1)
  16923. * @param factor defines the limit velocity value to affect to the specified gradient
  16924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16925. * @returns the current particle system
  16926. */
  16927. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16928. /**
  16929. * Remove a specific limit velocity gradient
  16930. * @param gradient defines the gradient to remove
  16931. * @returns the current particle system
  16932. */
  16933. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16934. /**
  16935. * Adds a new drag gradient
  16936. * @param gradient defines the gradient to use (between 0 and 1)
  16937. * @param factor defines the drag value to affect to the specified gradient
  16938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16939. * @returns the current particle system
  16940. */
  16941. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16942. /**
  16943. * Remove a specific drag gradient
  16944. * @param gradient defines the gradient to remove
  16945. * @returns the current particle system
  16946. */
  16947. removeDragGradient(gradient: number): IParticleSystem;
  16948. /**
  16949. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16950. * @param gradient defines the gradient to use (between 0 and 1)
  16951. * @param factor defines the emit rate value to affect to the specified gradient
  16952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16953. * @returns the current particle system
  16954. */
  16955. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16956. /**
  16957. * Remove a specific emit rate gradient
  16958. * @param gradient defines the gradient to remove
  16959. * @returns the current particle system
  16960. */
  16961. removeEmitRateGradient(gradient: number): IParticleSystem;
  16962. /**
  16963. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16964. * @param gradient defines the gradient to use (between 0 and 1)
  16965. * @param factor defines the start size value to affect to the specified gradient
  16966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16967. * @returns the current particle system
  16968. */
  16969. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16970. /**
  16971. * Remove a specific start size gradient
  16972. * @param gradient defines the gradient to remove
  16973. * @returns the current particle system
  16974. */
  16975. removeStartSizeGradient(gradient: number): IParticleSystem;
  16976. private _createRampGradientTexture;
  16977. /**
  16978. * Gets the current list of ramp gradients.
  16979. * You must use addRampGradient and removeRampGradient to udpate this list
  16980. * @returns the list of ramp gradients
  16981. */
  16982. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16983. /**
  16984. * Adds a new ramp gradient used to remap particle colors
  16985. * @param gradient defines the gradient to use (between 0 and 1)
  16986. * @param color defines the color to affect to the specified gradient
  16987. * @returns the current particle system
  16988. */
  16989. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16990. /**
  16991. * Remove a specific ramp gradient
  16992. * @param gradient defines the gradient to remove
  16993. * @returns the current particle system
  16994. */
  16995. removeRampGradient(gradient: number): ParticleSystem;
  16996. /**
  16997. * Adds a new color gradient
  16998. * @param gradient defines the gradient to use (between 0 and 1)
  16999. * @param color1 defines the color to affect to the specified gradient
  17000. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17001. * @returns this particle system
  17002. */
  17003. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17004. /**
  17005. * Remove a specific color gradient
  17006. * @param gradient defines the gradient to remove
  17007. * @returns this particle system
  17008. */
  17009. removeColorGradient(gradient: number): IParticleSystem;
  17010. private _fetchR;
  17011. protected _reset(): void;
  17012. private _resetEffect;
  17013. private _createVertexBuffers;
  17014. private _createIndexBuffer;
  17015. /**
  17016. * Gets the maximum number of particles active at the same time.
  17017. * @returns The max number of active particles.
  17018. */
  17019. getCapacity(): number;
  17020. /**
  17021. * Gets whether there are still active particles in the system.
  17022. * @returns True if it is alive, otherwise false.
  17023. */
  17024. isAlive(): boolean;
  17025. /**
  17026. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17027. * @returns True if it has been started, otherwise false.
  17028. */
  17029. isStarted(): boolean;
  17030. private _prepareSubEmitterInternalArray;
  17031. /**
  17032. * Starts the particle system and begins to emit
  17033. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17034. */
  17035. start(delay?: number): void;
  17036. /**
  17037. * Stops the particle system.
  17038. * @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.
  17039. */
  17040. stop(stopSubEmitters?: boolean): void;
  17041. /**
  17042. * Remove all active particles
  17043. */
  17044. reset(): void;
  17045. /**
  17046. * @hidden (for internal use only)
  17047. */
  17048. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17049. /**
  17050. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17051. * Its lifetime will start back at 0.
  17052. */
  17053. recycleParticle: (particle: Particle) => void;
  17054. private _stopSubEmitters;
  17055. private _createParticle;
  17056. private _removeFromRoot;
  17057. private _emitFromParticle;
  17058. private _update;
  17059. /** @hidden */
  17060. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17061. /** @hidden */
  17062. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17063. /** @hidden */
  17064. private _getEffect;
  17065. /**
  17066. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17067. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17068. */
  17069. animate(preWarmOnly?: boolean): void;
  17070. private _appendParticleVertices;
  17071. /**
  17072. * Rebuilds the particle system.
  17073. */
  17074. rebuild(): void;
  17075. /**
  17076. * Is this system ready to be used/rendered
  17077. * @return true if the system is ready
  17078. */
  17079. isReady(): boolean;
  17080. private _render;
  17081. /**
  17082. * Renders the particle system in its current state.
  17083. * @returns the current number of particles
  17084. */
  17085. render(): number;
  17086. /**
  17087. * Disposes the particle system and free the associated resources
  17088. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17089. */
  17090. dispose(disposeTexture?: boolean): void;
  17091. /**
  17092. * Clones the particle system.
  17093. * @param name The name of the cloned object
  17094. * @param newEmitter The new emitter to use
  17095. * @returns the cloned particle system
  17096. */
  17097. clone(name: string, newEmitter: any): ParticleSystem;
  17098. /**
  17099. * Serializes the particle system to a JSON object.
  17100. * @returns the JSON object
  17101. */
  17102. serialize(): any;
  17103. /** @hidden */
  17104. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17105. /** @hidden */
  17106. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17107. /**
  17108. * Parses a JSON object to create a particle system.
  17109. * @param parsedParticleSystem The JSON object to parse
  17110. * @param scene The scene to create the particle system in
  17111. * @param rootUrl The root url to use to load external dependencies like texture
  17112. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17113. * @returns the Parsed particle system
  17114. */
  17115. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17116. }
  17117. }
  17118. declare module BABYLON {
  17119. /**
  17120. * A particle represents one of the element emitted by a particle system.
  17121. * This is mainly define by its coordinates, direction, velocity and age.
  17122. */
  17123. export class Particle {
  17124. /**
  17125. * The particle system the particle belongs to.
  17126. */
  17127. particleSystem: ParticleSystem;
  17128. private static _Count;
  17129. /**
  17130. * Unique ID of the particle
  17131. */
  17132. id: number;
  17133. /**
  17134. * The world position of the particle in the scene.
  17135. */
  17136. position: Vector3;
  17137. /**
  17138. * The world direction of the particle in the scene.
  17139. */
  17140. direction: Vector3;
  17141. /**
  17142. * The color of the particle.
  17143. */
  17144. color: Color4;
  17145. /**
  17146. * The color change of the particle per step.
  17147. */
  17148. colorStep: Color4;
  17149. /**
  17150. * Defines how long will the life of the particle be.
  17151. */
  17152. lifeTime: number;
  17153. /**
  17154. * The current age of the particle.
  17155. */
  17156. age: number;
  17157. /**
  17158. * The current size of the particle.
  17159. */
  17160. size: number;
  17161. /**
  17162. * The current scale of the particle.
  17163. */
  17164. scale: Vector2;
  17165. /**
  17166. * The current angle of the particle.
  17167. */
  17168. angle: number;
  17169. /**
  17170. * Defines how fast is the angle changing.
  17171. */
  17172. angularSpeed: number;
  17173. /**
  17174. * Defines the cell index used by the particle to be rendered from a sprite.
  17175. */
  17176. cellIndex: number;
  17177. /**
  17178. * The information required to support color remapping
  17179. */
  17180. remapData: Vector4;
  17181. /** @hidden */
  17182. _randomCellOffset?: number;
  17183. /** @hidden */
  17184. _initialDirection: Nullable<Vector3>;
  17185. /** @hidden */
  17186. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17187. /** @hidden */
  17188. _initialStartSpriteCellID: number;
  17189. /** @hidden */
  17190. _initialEndSpriteCellID: number;
  17191. /** @hidden */
  17192. _currentColorGradient: Nullable<ColorGradient>;
  17193. /** @hidden */
  17194. _currentColor1: Color4;
  17195. /** @hidden */
  17196. _currentColor2: Color4;
  17197. /** @hidden */
  17198. _currentSizeGradient: Nullable<FactorGradient>;
  17199. /** @hidden */
  17200. _currentSize1: number;
  17201. /** @hidden */
  17202. _currentSize2: number;
  17203. /** @hidden */
  17204. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17205. /** @hidden */
  17206. _currentAngularSpeed1: number;
  17207. /** @hidden */
  17208. _currentAngularSpeed2: number;
  17209. /** @hidden */
  17210. _currentVelocityGradient: Nullable<FactorGradient>;
  17211. /** @hidden */
  17212. _currentVelocity1: number;
  17213. /** @hidden */
  17214. _currentVelocity2: number;
  17215. /** @hidden */
  17216. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17217. /** @hidden */
  17218. _currentLimitVelocity1: number;
  17219. /** @hidden */
  17220. _currentLimitVelocity2: number;
  17221. /** @hidden */
  17222. _currentDragGradient: Nullable<FactorGradient>;
  17223. /** @hidden */
  17224. _currentDrag1: number;
  17225. /** @hidden */
  17226. _currentDrag2: number;
  17227. /** @hidden */
  17228. _randomNoiseCoordinates1: Vector3;
  17229. /** @hidden */
  17230. _randomNoiseCoordinates2: Vector3;
  17231. /**
  17232. * Creates a new instance Particle
  17233. * @param particleSystem the particle system the particle belongs to
  17234. */
  17235. constructor(
  17236. /**
  17237. * The particle system the particle belongs to.
  17238. */
  17239. particleSystem: ParticleSystem);
  17240. private updateCellInfoFromSystem;
  17241. /**
  17242. * Defines how the sprite cell index is updated for the particle
  17243. */
  17244. updateCellIndex(): void;
  17245. /** @hidden */
  17246. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17247. /** @hidden */
  17248. _inheritParticleInfoToSubEmitters(): void;
  17249. /** @hidden */
  17250. _reset(): void;
  17251. /**
  17252. * Copy the properties of particle to another one.
  17253. * @param other the particle to copy the information to.
  17254. */
  17255. copyTo(other: Particle): void;
  17256. }
  17257. }
  17258. declare module BABYLON {
  17259. /**
  17260. * Particle emitter represents a volume emitting particles.
  17261. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17262. */
  17263. export interface IParticleEmitterType {
  17264. /**
  17265. * Called by the particle System when the direction is computed for the created particle.
  17266. * @param worldMatrix is the world matrix of the particle system
  17267. * @param directionToUpdate is the direction vector to update with the result
  17268. * @param particle is the particle we are computed the direction for
  17269. */
  17270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17271. /**
  17272. * Called by the particle System when the position is computed for the created particle.
  17273. * @param worldMatrix is the world matrix of the particle system
  17274. * @param positionToUpdate is the position vector to update with the result
  17275. * @param particle is the particle we are computed the position for
  17276. */
  17277. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17278. /**
  17279. * Clones the current emitter and returns a copy of it
  17280. * @returns the new emitter
  17281. */
  17282. clone(): IParticleEmitterType;
  17283. /**
  17284. * Called by the GPUParticleSystem to setup the update shader
  17285. * @param effect defines the update shader
  17286. */
  17287. applyToShader(effect: Effect): void;
  17288. /**
  17289. * Returns a string to use to update the GPU particles update shader
  17290. * @returns the effect defines string
  17291. */
  17292. getEffectDefines(): string;
  17293. /**
  17294. * Returns a string representing the class name
  17295. * @returns a string containing the class name
  17296. */
  17297. getClassName(): string;
  17298. /**
  17299. * Serializes the particle system to a JSON object.
  17300. * @returns the JSON object
  17301. */
  17302. serialize(): any;
  17303. /**
  17304. * Parse properties from a JSON object
  17305. * @param serializationObject defines the JSON object
  17306. */
  17307. parse(serializationObject: any): void;
  17308. }
  17309. }
  17310. declare module BABYLON {
  17311. /**
  17312. * Particle emitter emitting particles from the inside of a box.
  17313. * It emits the particles randomly between 2 given directions.
  17314. */
  17315. export class BoxParticleEmitter implements IParticleEmitterType {
  17316. /**
  17317. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17318. */
  17319. direction1: Vector3;
  17320. /**
  17321. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17322. */
  17323. direction2: Vector3;
  17324. /**
  17325. * 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.
  17326. */
  17327. minEmitBox: Vector3;
  17328. /**
  17329. * 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.
  17330. */
  17331. maxEmitBox: Vector3;
  17332. /**
  17333. * Creates a new instance BoxParticleEmitter
  17334. */
  17335. constructor();
  17336. /**
  17337. * Called by the particle System when the direction is computed for the created particle.
  17338. * @param worldMatrix is the world matrix of the particle system
  17339. * @param directionToUpdate is the direction vector to update with the result
  17340. * @param particle is the particle we are computed the direction for
  17341. */
  17342. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17343. /**
  17344. * Called by the particle System when the position is computed for the created particle.
  17345. * @param worldMatrix is the world matrix of the particle system
  17346. * @param positionToUpdate is the position vector to update with the result
  17347. * @param particle is the particle we are computed the position for
  17348. */
  17349. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17350. /**
  17351. * Clones the current emitter and returns a copy of it
  17352. * @returns the new emitter
  17353. */
  17354. clone(): BoxParticleEmitter;
  17355. /**
  17356. * Called by the GPUParticleSystem to setup the update shader
  17357. * @param effect defines the update shader
  17358. */
  17359. applyToShader(effect: Effect): void;
  17360. /**
  17361. * Returns a string to use to update the GPU particles update shader
  17362. * @returns a string containng the defines string
  17363. */
  17364. getEffectDefines(): string;
  17365. /**
  17366. * Returns the string "BoxParticleEmitter"
  17367. * @returns a string containing the class name
  17368. */
  17369. getClassName(): string;
  17370. /**
  17371. * Serializes the particle system to a JSON object.
  17372. * @returns the JSON object
  17373. */
  17374. serialize(): any;
  17375. /**
  17376. * Parse properties from a JSON object
  17377. * @param serializationObject defines the JSON object
  17378. */
  17379. parse(serializationObject: any): void;
  17380. }
  17381. }
  17382. declare module BABYLON {
  17383. /**
  17384. * Particle emitter emitting particles from the inside of a cone.
  17385. * It emits the particles alongside the cone volume from the base to the particle.
  17386. * The emission direction might be randomized.
  17387. */
  17388. export class ConeParticleEmitter implements IParticleEmitterType {
  17389. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17390. directionRandomizer: number;
  17391. private _radius;
  17392. private _angle;
  17393. private _height;
  17394. /**
  17395. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17396. */
  17397. radiusRange: number;
  17398. /**
  17399. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17400. */
  17401. heightRange: number;
  17402. /**
  17403. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17404. */
  17405. emitFromSpawnPointOnly: boolean;
  17406. /**
  17407. * Gets or sets the radius of the emission cone
  17408. */
  17409. radius: number;
  17410. /**
  17411. * Gets or sets the angle of the emission cone
  17412. */
  17413. angle: number;
  17414. private _buildHeight;
  17415. /**
  17416. * Creates a new instance ConeParticleEmitter
  17417. * @param radius the radius of the emission cone (1 by default)
  17418. * @param angle the cone base angle (PI by default)
  17419. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17420. */
  17421. constructor(radius?: number, angle?: number,
  17422. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17423. directionRandomizer?: number);
  17424. /**
  17425. * Called by the particle System when the direction is computed for the created particle.
  17426. * @param worldMatrix is the world matrix of the particle system
  17427. * @param directionToUpdate is the direction vector to update with the result
  17428. * @param particle is the particle we are computed the direction for
  17429. */
  17430. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17431. /**
  17432. * Called by the particle System when the position is computed for the created particle.
  17433. * @param worldMatrix is the world matrix of the particle system
  17434. * @param positionToUpdate is the position vector to update with the result
  17435. * @param particle is the particle we are computed the position for
  17436. */
  17437. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17438. /**
  17439. * Clones the current emitter and returns a copy of it
  17440. * @returns the new emitter
  17441. */
  17442. clone(): ConeParticleEmitter;
  17443. /**
  17444. * Called by the GPUParticleSystem to setup the update shader
  17445. * @param effect defines the update shader
  17446. */
  17447. applyToShader(effect: Effect): void;
  17448. /**
  17449. * Returns a string to use to update the GPU particles update shader
  17450. * @returns a string containng the defines string
  17451. */
  17452. getEffectDefines(): string;
  17453. /**
  17454. * Returns the string "ConeParticleEmitter"
  17455. * @returns a string containing the class name
  17456. */
  17457. getClassName(): string;
  17458. /**
  17459. * Serializes the particle system to a JSON object.
  17460. * @returns the JSON object
  17461. */
  17462. serialize(): any;
  17463. /**
  17464. * Parse properties from a JSON object
  17465. * @param serializationObject defines the JSON object
  17466. */
  17467. parse(serializationObject: any): void;
  17468. }
  17469. }
  17470. declare module BABYLON {
  17471. /**
  17472. * Particle emitter emitting particles from the inside of a cylinder.
  17473. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17474. */
  17475. export class CylinderParticleEmitter implements IParticleEmitterType {
  17476. /**
  17477. * The radius of the emission cylinder.
  17478. */
  17479. radius: number;
  17480. /**
  17481. * The height of the emission cylinder.
  17482. */
  17483. height: number;
  17484. /**
  17485. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17486. */
  17487. radiusRange: number;
  17488. /**
  17489. * How much to randomize the particle direction [0-1].
  17490. */
  17491. directionRandomizer: number;
  17492. /**
  17493. * Creates a new instance CylinderParticleEmitter
  17494. * @param radius the radius of the emission cylinder (1 by default)
  17495. * @param height the height of the emission cylinder (1 by default)
  17496. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17497. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17498. */
  17499. constructor(
  17500. /**
  17501. * The radius of the emission cylinder.
  17502. */
  17503. radius?: number,
  17504. /**
  17505. * The height of the emission cylinder.
  17506. */
  17507. height?: number,
  17508. /**
  17509. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17510. */
  17511. radiusRange?: number,
  17512. /**
  17513. * How much to randomize the particle direction [0-1].
  17514. */
  17515. directionRandomizer?: number);
  17516. /**
  17517. * Called by the particle System when the direction is computed for the created particle.
  17518. * @param worldMatrix is the world matrix of the particle system
  17519. * @param directionToUpdate is the direction vector to update with the result
  17520. * @param particle is the particle we are computed the direction for
  17521. */
  17522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17523. /**
  17524. * Called by the particle System when the position is computed for the created particle.
  17525. * @param worldMatrix is the world matrix of the particle system
  17526. * @param positionToUpdate is the position vector to update with the result
  17527. * @param particle is the particle we are computed the position for
  17528. */
  17529. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17530. /**
  17531. * Clones the current emitter and returns a copy of it
  17532. * @returns the new emitter
  17533. */
  17534. clone(): CylinderParticleEmitter;
  17535. /**
  17536. * Called by the GPUParticleSystem to setup the update shader
  17537. * @param effect defines the update shader
  17538. */
  17539. applyToShader(effect: Effect): void;
  17540. /**
  17541. * Returns a string to use to update the GPU particles update shader
  17542. * @returns a string containng the defines string
  17543. */
  17544. getEffectDefines(): string;
  17545. /**
  17546. * Returns the string "CylinderParticleEmitter"
  17547. * @returns a string containing the class name
  17548. */
  17549. getClassName(): string;
  17550. /**
  17551. * Serializes the particle system to a JSON object.
  17552. * @returns the JSON object
  17553. */
  17554. serialize(): any;
  17555. /**
  17556. * Parse properties from a JSON object
  17557. * @param serializationObject defines the JSON object
  17558. */
  17559. parse(serializationObject: any): void;
  17560. }
  17561. /**
  17562. * Particle emitter emitting particles from the inside of a cylinder.
  17563. * It emits the particles randomly between two vectors.
  17564. */
  17565. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17566. /**
  17567. * The min limit of the emission direction.
  17568. */
  17569. direction1: Vector3;
  17570. /**
  17571. * The max limit of the emission direction.
  17572. */
  17573. direction2: Vector3;
  17574. /**
  17575. * Creates a new instance CylinderDirectedParticleEmitter
  17576. * @param radius the radius of the emission cylinder (1 by default)
  17577. * @param height the height of the emission cylinder (1 by default)
  17578. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17579. * @param direction1 the min limit of the emission direction (up vector by default)
  17580. * @param direction2 the max limit of the emission direction (up vector by default)
  17581. */
  17582. constructor(radius?: number, height?: number, radiusRange?: number,
  17583. /**
  17584. * The min limit of the emission direction.
  17585. */
  17586. direction1?: Vector3,
  17587. /**
  17588. * The max limit of the emission direction.
  17589. */
  17590. direction2?: Vector3);
  17591. /**
  17592. * Called by the particle System when the direction is computed for the created particle.
  17593. * @param worldMatrix is the world matrix of the particle system
  17594. * @param directionToUpdate is the direction vector to update with the result
  17595. * @param particle is the particle we are computed the direction for
  17596. */
  17597. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17598. /**
  17599. * Clones the current emitter and returns a copy of it
  17600. * @returns the new emitter
  17601. */
  17602. clone(): CylinderDirectedParticleEmitter;
  17603. /**
  17604. * Called by the GPUParticleSystem to setup the update shader
  17605. * @param effect defines the update shader
  17606. */
  17607. applyToShader(effect: Effect): void;
  17608. /**
  17609. * Returns a string to use to update the GPU particles update shader
  17610. * @returns a string containng the defines string
  17611. */
  17612. getEffectDefines(): string;
  17613. /**
  17614. * Returns the string "CylinderDirectedParticleEmitter"
  17615. * @returns a string containing the class name
  17616. */
  17617. getClassName(): string;
  17618. /**
  17619. * Serializes the particle system to a JSON object.
  17620. * @returns the JSON object
  17621. */
  17622. serialize(): any;
  17623. /**
  17624. * Parse properties from a JSON object
  17625. * @param serializationObject defines the JSON object
  17626. */
  17627. parse(serializationObject: any): void;
  17628. }
  17629. }
  17630. declare module BABYLON {
  17631. /**
  17632. * Particle emitter emitting particles from the inside of a hemisphere.
  17633. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17634. */
  17635. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17636. /**
  17637. * The radius of the emission hemisphere.
  17638. */
  17639. radius: number;
  17640. /**
  17641. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17642. */
  17643. radiusRange: number;
  17644. /**
  17645. * How much to randomize the particle direction [0-1].
  17646. */
  17647. directionRandomizer: number;
  17648. /**
  17649. * Creates a new instance HemisphericParticleEmitter
  17650. * @param radius the radius of the emission hemisphere (1 by default)
  17651. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17652. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17653. */
  17654. constructor(
  17655. /**
  17656. * The radius of the emission hemisphere.
  17657. */
  17658. radius?: number,
  17659. /**
  17660. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17661. */
  17662. radiusRange?: number,
  17663. /**
  17664. * How much to randomize the particle direction [0-1].
  17665. */
  17666. directionRandomizer?: number);
  17667. /**
  17668. * Called by the particle System when the direction is computed for the created particle.
  17669. * @param worldMatrix is the world matrix of the particle system
  17670. * @param directionToUpdate is the direction vector to update with the result
  17671. * @param particle is the particle we are computed the direction for
  17672. */
  17673. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17674. /**
  17675. * Called by the particle System when the position is computed for the created particle.
  17676. * @param worldMatrix is the world matrix of the particle system
  17677. * @param positionToUpdate is the position vector to update with the result
  17678. * @param particle is the particle we are computed the position for
  17679. */
  17680. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17681. /**
  17682. * Clones the current emitter and returns a copy of it
  17683. * @returns the new emitter
  17684. */
  17685. clone(): HemisphericParticleEmitter;
  17686. /**
  17687. * Called by the GPUParticleSystem to setup the update shader
  17688. * @param effect defines the update shader
  17689. */
  17690. applyToShader(effect: Effect): void;
  17691. /**
  17692. * Returns a string to use to update the GPU particles update shader
  17693. * @returns a string containng the defines string
  17694. */
  17695. getEffectDefines(): string;
  17696. /**
  17697. * Returns the string "HemisphericParticleEmitter"
  17698. * @returns a string containing the class name
  17699. */
  17700. getClassName(): string;
  17701. /**
  17702. * Serializes the particle system to a JSON object.
  17703. * @returns the JSON object
  17704. */
  17705. serialize(): any;
  17706. /**
  17707. * Parse properties from a JSON object
  17708. * @param serializationObject defines the JSON object
  17709. */
  17710. parse(serializationObject: any): void;
  17711. }
  17712. }
  17713. declare module BABYLON {
  17714. /**
  17715. * Particle emitter emitting particles from a point.
  17716. * It emits the particles randomly between 2 given directions.
  17717. */
  17718. export class PointParticleEmitter implements IParticleEmitterType {
  17719. /**
  17720. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17721. */
  17722. direction1: Vector3;
  17723. /**
  17724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17725. */
  17726. direction2: Vector3;
  17727. /**
  17728. * Creates a new instance PointParticleEmitter
  17729. */
  17730. constructor();
  17731. /**
  17732. * Called by the particle System when the direction is computed for the created particle.
  17733. * @param worldMatrix is the world matrix of the particle system
  17734. * @param directionToUpdate is the direction vector to update with the result
  17735. * @param particle is the particle we are computed the direction for
  17736. */
  17737. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17738. /**
  17739. * Called by the particle System when the position is computed for the created particle.
  17740. * @param worldMatrix is the world matrix of the particle system
  17741. * @param positionToUpdate is the position vector to update with the result
  17742. * @param particle is the particle we are computed the position for
  17743. */
  17744. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17745. /**
  17746. * Clones the current emitter and returns a copy of it
  17747. * @returns the new emitter
  17748. */
  17749. clone(): PointParticleEmitter;
  17750. /**
  17751. * Called by the GPUParticleSystem to setup the update shader
  17752. * @param effect defines the update shader
  17753. */
  17754. applyToShader(effect: Effect): void;
  17755. /**
  17756. * Returns a string to use to update the GPU particles update shader
  17757. * @returns a string containng the defines string
  17758. */
  17759. getEffectDefines(): string;
  17760. /**
  17761. * Returns the string "PointParticleEmitter"
  17762. * @returns a string containing the class name
  17763. */
  17764. getClassName(): string;
  17765. /**
  17766. * Serializes the particle system to a JSON object.
  17767. * @returns the JSON object
  17768. */
  17769. serialize(): any;
  17770. /**
  17771. * Parse properties from a JSON object
  17772. * @param serializationObject defines the JSON object
  17773. */
  17774. parse(serializationObject: any): void;
  17775. }
  17776. }
  17777. declare module BABYLON {
  17778. /**
  17779. * Particle emitter emitting particles from the inside of a sphere.
  17780. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17781. */
  17782. export class SphereParticleEmitter implements IParticleEmitterType {
  17783. /**
  17784. * The radius of the emission sphere.
  17785. */
  17786. radius: number;
  17787. /**
  17788. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17789. */
  17790. radiusRange: number;
  17791. /**
  17792. * How much to randomize the particle direction [0-1].
  17793. */
  17794. directionRandomizer: number;
  17795. /**
  17796. * Creates a new instance SphereParticleEmitter
  17797. * @param radius the radius of the emission sphere (1 by default)
  17798. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17799. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17800. */
  17801. constructor(
  17802. /**
  17803. * The radius of the emission sphere.
  17804. */
  17805. radius?: number,
  17806. /**
  17807. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17808. */
  17809. radiusRange?: number,
  17810. /**
  17811. * How much to randomize the particle direction [0-1].
  17812. */
  17813. directionRandomizer?: number);
  17814. /**
  17815. * Called by the particle System when the direction is computed for the created particle.
  17816. * @param worldMatrix is the world matrix of the particle system
  17817. * @param directionToUpdate is the direction vector to update with the result
  17818. * @param particle is the particle we are computed the direction for
  17819. */
  17820. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17821. /**
  17822. * Called by the particle System when the position is computed for the created particle.
  17823. * @param worldMatrix is the world matrix of the particle system
  17824. * @param positionToUpdate is the position vector to update with the result
  17825. * @param particle is the particle we are computed the position for
  17826. */
  17827. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17828. /**
  17829. * Clones the current emitter and returns a copy of it
  17830. * @returns the new emitter
  17831. */
  17832. clone(): SphereParticleEmitter;
  17833. /**
  17834. * Called by the GPUParticleSystem to setup the update shader
  17835. * @param effect defines the update shader
  17836. */
  17837. applyToShader(effect: Effect): void;
  17838. /**
  17839. * Returns a string to use to update the GPU particles update shader
  17840. * @returns a string containng the defines string
  17841. */
  17842. getEffectDefines(): string;
  17843. /**
  17844. * Returns the string "SphereParticleEmitter"
  17845. * @returns a string containing the class name
  17846. */
  17847. getClassName(): string;
  17848. /**
  17849. * Serializes the particle system to a JSON object.
  17850. * @returns the JSON object
  17851. */
  17852. serialize(): any;
  17853. /**
  17854. * Parse properties from a JSON object
  17855. * @param serializationObject defines the JSON object
  17856. */
  17857. parse(serializationObject: any): void;
  17858. }
  17859. /**
  17860. * Particle emitter emitting particles from the inside of a sphere.
  17861. * It emits the particles randomly between two vectors.
  17862. */
  17863. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17864. /**
  17865. * The min limit of the emission direction.
  17866. */
  17867. direction1: Vector3;
  17868. /**
  17869. * The max limit of the emission direction.
  17870. */
  17871. direction2: Vector3;
  17872. /**
  17873. * Creates a new instance SphereDirectedParticleEmitter
  17874. * @param radius the radius of the emission sphere (1 by default)
  17875. * @param direction1 the min limit of the emission direction (up vector by default)
  17876. * @param direction2 the max limit of the emission direction (up vector by default)
  17877. */
  17878. constructor(radius?: number,
  17879. /**
  17880. * The min limit of the emission direction.
  17881. */
  17882. direction1?: Vector3,
  17883. /**
  17884. * The max limit of the emission direction.
  17885. */
  17886. direction2?: Vector3);
  17887. /**
  17888. * Called by the particle System when the direction is computed for the created particle.
  17889. * @param worldMatrix is the world matrix of the particle system
  17890. * @param directionToUpdate is the direction vector to update with the result
  17891. * @param particle is the particle we are computed the direction for
  17892. */
  17893. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17894. /**
  17895. * Clones the current emitter and returns a copy of it
  17896. * @returns the new emitter
  17897. */
  17898. clone(): SphereDirectedParticleEmitter;
  17899. /**
  17900. * Called by the GPUParticleSystem to setup the update shader
  17901. * @param effect defines the update shader
  17902. */
  17903. applyToShader(effect: Effect): void;
  17904. /**
  17905. * Returns a string to use to update the GPU particles update shader
  17906. * @returns a string containng the defines string
  17907. */
  17908. getEffectDefines(): string;
  17909. /**
  17910. * Returns the string "SphereDirectedParticleEmitter"
  17911. * @returns a string containing the class name
  17912. */
  17913. getClassName(): string;
  17914. /**
  17915. * Serializes the particle system to a JSON object.
  17916. * @returns the JSON object
  17917. */
  17918. serialize(): any;
  17919. /**
  17920. * Parse properties from a JSON object
  17921. * @param serializationObject defines the JSON object
  17922. */
  17923. parse(serializationObject: any): void;
  17924. }
  17925. }
  17926. declare module BABYLON {
  17927. /**
  17928. * Interface representing a particle system in Babylon.js.
  17929. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17930. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17931. */
  17932. export interface IParticleSystem {
  17933. /**
  17934. * List of animations used by the particle system.
  17935. */
  17936. animations: Animation[];
  17937. /**
  17938. * The id of the Particle system.
  17939. */
  17940. id: string;
  17941. /**
  17942. * The name of the Particle system.
  17943. */
  17944. name: string;
  17945. /**
  17946. * The emitter represents the Mesh or position we are attaching the particle system to.
  17947. */
  17948. emitter: Nullable<AbstractMesh | Vector3>;
  17949. /**
  17950. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17951. */
  17952. isBillboardBased: boolean;
  17953. /**
  17954. * The rendering group used by the Particle system to chose when to render.
  17955. */
  17956. renderingGroupId: number;
  17957. /**
  17958. * The layer mask we are rendering the particles through.
  17959. */
  17960. layerMask: number;
  17961. /**
  17962. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17963. */
  17964. updateSpeed: number;
  17965. /**
  17966. * The amount of time the particle system is running (depends of the overall update speed).
  17967. */
  17968. targetStopDuration: number;
  17969. /**
  17970. * The texture used to render each particle. (this can be a spritesheet)
  17971. */
  17972. particleTexture: Nullable<Texture>;
  17973. /**
  17974. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17975. */
  17976. blendMode: number;
  17977. /**
  17978. * Minimum life time of emitting particles.
  17979. */
  17980. minLifeTime: number;
  17981. /**
  17982. * Maximum life time of emitting particles.
  17983. */
  17984. maxLifeTime: number;
  17985. /**
  17986. * Minimum Size of emitting particles.
  17987. */
  17988. minSize: number;
  17989. /**
  17990. * Maximum Size of emitting particles.
  17991. */
  17992. maxSize: number;
  17993. /**
  17994. * Minimum scale of emitting particles on X axis.
  17995. */
  17996. minScaleX: number;
  17997. /**
  17998. * Maximum scale of emitting particles on X axis.
  17999. */
  18000. maxScaleX: number;
  18001. /**
  18002. * Minimum scale of emitting particles on Y axis.
  18003. */
  18004. minScaleY: number;
  18005. /**
  18006. * Maximum scale of emitting particles on Y axis.
  18007. */
  18008. maxScaleY: number;
  18009. /**
  18010. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18011. */
  18012. color1: Color4;
  18013. /**
  18014. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18015. */
  18016. color2: Color4;
  18017. /**
  18018. * Color the particle will have at the end of its lifetime.
  18019. */
  18020. colorDead: Color4;
  18021. /**
  18022. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18023. */
  18024. emitRate: number;
  18025. /**
  18026. * You can use gravity if you want to give an orientation to your particles.
  18027. */
  18028. gravity: Vector3;
  18029. /**
  18030. * Minimum power of emitting particles.
  18031. */
  18032. minEmitPower: number;
  18033. /**
  18034. * Maximum power of emitting particles.
  18035. */
  18036. maxEmitPower: number;
  18037. /**
  18038. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18039. */
  18040. minAngularSpeed: number;
  18041. /**
  18042. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18043. */
  18044. maxAngularSpeed: number;
  18045. /**
  18046. * Gets or sets the minimal initial rotation in radians.
  18047. */
  18048. minInitialRotation: number;
  18049. /**
  18050. * Gets or sets the maximal initial rotation in radians.
  18051. */
  18052. maxInitialRotation: number;
  18053. /**
  18054. * The particle emitter type defines the emitter used by the particle system.
  18055. * It can be for example box, sphere, or cone...
  18056. */
  18057. particleEmitterType: Nullable<IParticleEmitterType>;
  18058. /**
  18059. * Defines the delay in milliseconds before starting the system (0 by default)
  18060. */
  18061. startDelay: number;
  18062. /**
  18063. * 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
  18064. */
  18065. preWarmCycles: number;
  18066. /**
  18067. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18068. */
  18069. preWarmStepOffset: number;
  18070. /**
  18071. * 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)
  18072. */
  18073. spriteCellChangeSpeed: number;
  18074. /**
  18075. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18076. */
  18077. startSpriteCellID: number;
  18078. /**
  18079. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18080. */
  18081. endSpriteCellID: number;
  18082. /**
  18083. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18084. */
  18085. spriteCellWidth: number;
  18086. /**
  18087. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18088. */
  18089. spriteCellHeight: number;
  18090. /**
  18091. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18092. */
  18093. spriteRandomStartCell: boolean;
  18094. /**
  18095. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18096. */
  18097. isAnimationSheetEnabled: boolean;
  18098. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18099. translationPivot: Vector2;
  18100. /**
  18101. * Gets or sets a texture used to add random noise to particle positions
  18102. */
  18103. noiseTexture: Nullable<BaseTexture>;
  18104. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18105. noiseStrength: Vector3;
  18106. /**
  18107. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18108. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18109. */
  18110. billboardMode: number;
  18111. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18112. limitVelocityDamping: number;
  18113. /**
  18114. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18115. */
  18116. beginAnimationOnStart: boolean;
  18117. /**
  18118. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18119. */
  18120. beginAnimationFrom: number;
  18121. /**
  18122. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18123. */
  18124. beginAnimationTo: number;
  18125. /**
  18126. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18127. */
  18128. beginAnimationLoop: boolean;
  18129. /**
  18130. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18131. */
  18132. disposeOnStop: boolean;
  18133. /**
  18134. * Gets the maximum number of particles active at the same time.
  18135. * @returns The max number of active particles.
  18136. */
  18137. getCapacity(): number;
  18138. /**
  18139. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18140. * @returns True if it has been started, otherwise false.
  18141. */
  18142. isStarted(): boolean;
  18143. /**
  18144. * Animates the particle system for this frame.
  18145. */
  18146. animate(): void;
  18147. /**
  18148. * Renders the particle system in its current state.
  18149. * @returns the current number of particles
  18150. */
  18151. render(): number;
  18152. /**
  18153. * Dispose the particle system and frees its associated resources.
  18154. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18155. */
  18156. dispose(disposeTexture?: boolean): void;
  18157. /**
  18158. * Clones the particle system.
  18159. * @param name The name of the cloned object
  18160. * @param newEmitter The new emitter to use
  18161. * @returns the cloned particle system
  18162. */
  18163. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18164. /**
  18165. * Serializes the particle system to a JSON object.
  18166. * @returns the JSON object
  18167. */
  18168. serialize(): any;
  18169. /**
  18170. * Rebuild the particle system
  18171. */
  18172. rebuild(): void;
  18173. /**
  18174. * Starts the particle system and begins to emit
  18175. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18176. */
  18177. start(delay?: number): void;
  18178. /**
  18179. * Stops the particle system.
  18180. */
  18181. stop(): void;
  18182. /**
  18183. * Remove all active particles
  18184. */
  18185. reset(): void;
  18186. /**
  18187. * Is this system ready to be used/rendered
  18188. * @return true if the system is ready
  18189. */
  18190. isReady(): boolean;
  18191. /**
  18192. * Adds a new color gradient
  18193. * @param gradient defines the gradient to use (between 0 and 1)
  18194. * @param color1 defines the color to affect to the specified gradient
  18195. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18196. * @returns the current particle system
  18197. */
  18198. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18199. /**
  18200. * Remove a specific color gradient
  18201. * @param gradient defines the gradient to remove
  18202. * @returns the current particle system
  18203. */
  18204. removeColorGradient(gradient: number): IParticleSystem;
  18205. /**
  18206. * Adds a new size gradient
  18207. * @param gradient defines the gradient to use (between 0 and 1)
  18208. * @param factor defines the size factor to affect to the specified gradient
  18209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18210. * @returns the current particle system
  18211. */
  18212. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18213. /**
  18214. * Remove a specific size gradient
  18215. * @param gradient defines the gradient to remove
  18216. * @returns the current particle system
  18217. */
  18218. removeSizeGradient(gradient: number): IParticleSystem;
  18219. /**
  18220. * Gets the current list of color gradients.
  18221. * You must use addColorGradient and removeColorGradient to udpate this list
  18222. * @returns the list of color gradients
  18223. */
  18224. getColorGradients(): Nullable<Array<ColorGradient>>;
  18225. /**
  18226. * Gets the current list of size gradients.
  18227. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18228. * @returns the list of size gradients
  18229. */
  18230. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18231. /**
  18232. * Gets the current list of angular speed gradients.
  18233. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18234. * @returns the list of angular speed gradients
  18235. */
  18236. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18237. /**
  18238. * Adds a new angular speed gradient
  18239. * @param gradient defines the gradient to use (between 0 and 1)
  18240. * @param factor defines the angular speed to affect to the specified gradient
  18241. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18242. * @returns the current particle system
  18243. */
  18244. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18245. /**
  18246. * Remove a specific angular speed gradient
  18247. * @param gradient defines the gradient to remove
  18248. * @returns the current particle system
  18249. */
  18250. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18251. /**
  18252. * Gets the current list of velocity gradients.
  18253. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18254. * @returns the list of velocity gradients
  18255. */
  18256. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18257. /**
  18258. * Adds a new velocity gradient
  18259. * @param gradient defines the gradient to use (between 0 and 1)
  18260. * @param factor defines the velocity to affect to the specified gradient
  18261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18262. * @returns the current particle system
  18263. */
  18264. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18265. /**
  18266. * Remove a specific velocity gradient
  18267. * @param gradient defines the gradient to remove
  18268. * @returns the current particle system
  18269. */
  18270. removeVelocityGradient(gradient: number): IParticleSystem;
  18271. /**
  18272. * Gets the current list of limit velocity gradients.
  18273. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18274. * @returns the list of limit velocity gradients
  18275. */
  18276. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18277. /**
  18278. * Adds a new limit velocity gradient
  18279. * @param gradient defines the gradient to use (between 0 and 1)
  18280. * @param factor defines the limit velocity to affect to the specified gradient
  18281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18282. * @returns the current particle system
  18283. */
  18284. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18285. /**
  18286. * Remove a specific limit velocity gradient
  18287. * @param gradient defines the gradient to remove
  18288. * @returns the current particle system
  18289. */
  18290. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18291. /**
  18292. * Adds a new drag gradient
  18293. * @param gradient defines the gradient to use (between 0 and 1)
  18294. * @param factor defines the drag to affect to the specified gradient
  18295. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18296. * @returns the current particle system
  18297. */
  18298. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18299. /**
  18300. * Remove a specific drag gradient
  18301. * @param gradient defines the gradient to remove
  18302. * @returns the current particle system
  18303. */
  18304. removeDragGradient(gradient: number): IParticleSystem;
  18305. /**
  18306. * Gets the current list of drag gradients.
  18307. * You must use addDragGradient and removeDragGradient to udpate this list
  18308. * @returns the list of drag gradients
  18309. */
  18310. getDragGradients(): Nullable<Array<FactorGradient>>;
  18311. /**
  18312. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18313. * @param gradient defines the gradient to use (between 0 and 1)
  18314. * @param factor defines the emit rate to affect to the specified gradient
  18315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18316. * @returns the current particle system
  18317. */
  18318. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18319. /**
  18320. * Remove a specific emit rate gradient
  18321. * @param gradient defines the gradient to remove
  18322. * @returns the current particle system
  18323. */
  18324. removeEmitRateGradient(gradient: number): IParticleSystem;
  18325. /**
  18326. * Gets the current list of emit rate gradients.
  18327. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18328. * @returns the list of emit rate gradients
  18329. */
  18330. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18331. /**
  18332. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18333. * @param gradient defines the gradient to use (between 0 and 1)
  18334. * @param factor defines the start size to affect to the specified gradient
  18335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18336. * @returns the current particle system
  18337. */
  18338. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18339. /**
  18340. * Remove a specific start size gradient
  18341. * @param gradient defines the gradient to remove
  18342. * @returns the current particle system
  18343. */
  18344. removeStartSizeGradient(gradient: number): IParticleSystem;
  18345. /**
  18346. * Gets the current list of start size gradients.
  18347. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18348. * @returns the list of start size gradients
  18349. */
  18350. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18351. /**
  18352. * Adds a new life time gradient
  18353. * @param gradient defines the gradient to use (between 0 and 1)
  18354. * @param factor defines the life time factor to affect to the specified gradient
  18355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18356. * @returns the current particle system
  18357. */
  18358. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18359. /**
  18360. * Remove a specific life time gradient
  18361. * @param gradient defines the gradient to remove
  18362. * @returns the current particle system
  18363. */
  18364. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18365. /**
  18366. * Gets the current list of life time gradients.
  18367. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18368. * @returns the list of life time gradients
  18369. */
  18370. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18371. /**
  18372. * Gets the current list of color gradients.
  18373. * You must use addColorGradient and removeColorGradient to udpate this list
  18374. * @returns the list of color gradients
  18375. */
  18376. getColorGradients(): Nullable<Array<ColorGradient>>;
  18377. /**
  18378. * Adds a new ramp gradient used to remap particle colors
  18379. * @param gradient defines the gradient to use (between 0 and 1)
  18380. * @param color defines the color to affect to the specified gradient
  18381. * @returns the current particle system
  18382. */
  18383. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18384. /**
  18385. * Gets the current list of ramp gradients.
  18386. * You must use addRampGradient and removeRampGradient to udpate this list
  18387. * @returns the list of ramp gradients
  18388. */
  18389. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18390. /** Gets or sets a boolean indicating that ramp gradients must be used
  18391. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18392. */
  18393. useRampGradients: boolean;
  18394. /**
  18395. * Adds a new color remap gradient
  18396. * @param gradient defines the gradient to use (between 0 and 1)
  18397. * @param min defines the color remap minimal range
  18398. * @param max defines the color remap maximal range
  18399. * @returns the current particle system
  18400. */
  18401. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18402. /**
  18403. * Gets the current list of color remap gradients.
  18404. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18405. * @returns the list of color remap gradients
  18406. */
  18407. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18408. /**
  18409. * Adds a new alpha remap gradient
  18410. * @param gradient defines the gradient to use (between 0 and 1)
  18411. * @param min defines the alpha remap minimal range
  18412. * @param max defines the alpha remap maximal range
  18413. * @returns the current particle system
  18414. */
  18415. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18416. /**
  18417. * Gets the current list of alpha remap gradients.
  18418. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18419. * @returns the list of alpha remap gradients
  18420. */
  18421. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18422. /**
  18423. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18424. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18425. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18426. * @returns the emitter
  18427. */
  18428. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18429. /**
  18430. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18431. * @param radius The radius of the hemisphere to emit from
  18432. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18433. * @returns the emitter
  18434. */
  18435. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18436. /**
  18437. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18438. * @param radius The radius of the sphere to emit from
  18439. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18440. * @returns the emitter
  18441. */
  18442. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18443. /**
  18444. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18445. * @param radius The radius of the sphere to emit from
  18446. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18447. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18448. * @returns the emitter
  18449. */
  18450. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18451. /**
  18452. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18453. * @param radius The radius of the emission cylinder
  18454. * @param height The height of the emission cylinder
  18455. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18456. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18457. * @returns the emitter
  18458. */
  18459. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18460. /**
  18461. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18462. * @param radius The radius of the cylinder to emit from
  18463. * @param height The height of the emission cylinder
  18464. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18467. * @returns the emitter
  18468. */
  18469. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18470. /**
  18471. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18472. * @param radius The radius of the cone to emit from
  18473. * @param angle The base angle of the cone
  18474. * @returns the emitter
  18475. */
  18476. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18477. /**
  18478. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18479. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18480. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18481. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18482. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18483. * @returns the emitter
  18484. */
  18485. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18486. /**
  18487. * Get hosting scene
  18488. * @returns the scene
  18489. */
  18490. getScene(): Scene;
  18491. }
  18492. }
  18493. declare module BABYLON {
  18494. /**
  18495. * Creates an instance based on a source mesh.
  18496. */
  18497. export class InstancedMesh extends AbstractMesh {
  18498. private _sourceMesh;
  18499. private _currentLOD;
  18500. /** @hidden */
  18501. _indexInSourceMeshInstanceArray: number;
  18502. constructor(name: string, source: Mesh);
  18503. /**
  18504. * Returns the string "InstancedMesh".
  18505. */
  18506. getClassName(): string;
  18507. /** Gets the list of lights affecting that mesh */
  18508. readonly lightSources: Light[];
  18509. _resyncLightSources(): void;
  18510. _resyncLighSource(light: Light): void;
  18511. _removeLightSource(light: Light): void;
  18512. /**
  18513. * If the source mesh receives shadows
  18514. */
  18515. readonly receiveShadows: boolean;
  18516. /**
  18517. * The material of the source mesh
  18518. */
  18519. readonly material: Nullable<Material>;
  18520. /**
  18521. * Visibility of the source mesh
  18522. */
  18523. readonly visibility: number;
  18524. /**
  18525. * Skeleton of the source mesh
  18526. */
  18527. readonly skeleton: Nullable<Skeleton>;
  18528. /**
  18529. * Rendering ground id of the source mesh
  18530. */
  18531. renderingGroupId: number;
  18532. /**
  18533. * Returns the total number of vertices (integer).
  18534. */
  18535. getTotalVertices(): number;
  18536. /**
  18537. * Returns a positive integer : the total number of indices in this mesh geometry.
  18538. * @returns the numner of indices or zero if the mesh has no geometry.
  18539. */
  18540. getTotalIndices(): number;
  18541. /**
  18542. * The source mesh of the instance
  18543. */
  18544. readonly sourceMesh: Mesh;
  18545. /**
  18546. * Is this node ready to be used/rendered
  18547. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18548. * @return {boolean} is it ready
  18549. */
  18550. isReady(completeCheck?: boolean): boolean;
  18551. /**
  18552. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18553. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18554. * @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.
  18555. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18556. */
  18557. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18558. /**
  18559. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18560. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18561. * The `data` are either a numeric array either a Float32Array.
  18562. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18563. * 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).
  18564. * Note that a new underlying VertexBuffer object is created each call.
  18565. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18566. *
  18567. * Possible `kind` values :
  18568. * - VertexBuffer.PositionKind
  18569. * - VertexBuffer.UVKind
  18570. * - VertexBuffer.UV2Kind
  18571. * - VertexBuffer.UV3Kind
  18572. * - VertexBuffer.UV4Kind
  18573. * - VertexBuffer.UV5Kind
  18574. * - VertexBuffer.UV6Kind
  18575. * - VertexBuffer.ColorKind
  18576. * - VertexBuffer.MatricesIndicesKind
  18577. * - VertexBuffer.MatricesIndicesExtraKind
  18578. * - VertexBuffer.MatricesWeightsKind
  18579. * - VertexBuffer.MatricesWeightsExtraKind
  18580. *
  18581. * Returns the Mesh.
  18582. */
  18583. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  18584. /**
  18585. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18586. * If the mesh has no geometry, it is simply returned as it is.
  18587. * The `data` are either a numeric array either a Float32Array.
  18588. * No new underlying VertexBuffer object is created.
  18589. * 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.
  18590. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18591. *
  18592. * Possible `kind` values :
  18593. * - VertexBuffer.PositionKind
  18594. * - VertexBuffer.UVKind
  18595. * - VertexBuffer.UV2Kind
  18596. * - VertexBuffer.UV3Kind
  18597. * - VertexBuffer.UV4Kind
  18598. * - VertexBuffer.UV5Kind
  18599. * - VertexBuffer.UV6Kind
  18600. * - VertexBuffer.ColorKind
  18601. * - VertexBuffer.MatricesIndicesKind
  18602. * - VertexBuffer.MatricesIndicesExtraKind
  18603. * - VertexBuffer.MatricesWeightsKind
  18604. * - VertexBuffer.MatricesWeightsExtraKind
  18605. *
  18606. * Returns the Mesh.
  18607. */
  18608. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18609. /**
  18610. * Sets the mesh indices.
  18611. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18612. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18613. * This method creates a new index buffer each call.
  18614. * Returns the Mesh.
  18615. */
  18616. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18617. /**
  18618. * Boolean : True if the mesh owns the requested kind of data.
  18619. */
  18620. isVerticesDataPresent(kind: string): boolean;
  18621. /**
  18622. * Returns an array of indices (IndicesArray).
  18623. */
  18624. getIndices(): Nullable<IndicesArray>;
  18625. readonly _positions: Nullable<Vector3[]>;
  18626. /**
  18627. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18628. * This means the mesh underlying bounding box and sphere are recomputed.
  18629. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18630. * @returns the current mesh
  18631. */
  18632. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18633. /** @hidden */
  18634. _preActivate(): InstancedMesh;
  18635. /** @hidden */
  18636. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18637. /** @hidden */
  18638. _postActivate(): void;
  18639. getWorldMatrix(): Matrix;
  18640. readonly isAnInstance: boolean;
  18641. /**
  18642. * Returns the current associated LOD AbstractMesh.
  18643. */
  18644. getLOD(camera: Camera): AbstractMesh;
  18645. /** @hidden */
  18646. _syncSubMeshes(): InstancedMesh;
  18647. /** @hidden */
  18648. _generatePointsArray(): boolean;
  18649. /**
  18650. * Creates a new InstancedMesh from the current mesh.
  18651. * - name (string) : the cloned mesh name
  18652. * - newParent (optional Node) : the optional Node to parent the clone to.
  18653. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18654. *
  18655. * Returns the clone.
  18656. */
  18657. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  18658. /**
  18659. * Disposes the InstancedMesh.
  18660. * Returns nothing.
  18661. */
  18662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18663. }
  18664. }
  18665. declare module BABYLON {
  18666. /**
  18667. * Defines the options associated with the creation of a shader material.
  18668. */
  18669. export interface IShaderMaterialOptions {
  18670. /**
  18671. * Does the material work in alpha blend mode
  18672. */
  18673. needAlphaBlending: boolean;
  18674. /**
  18675. * Does the material work in alpha test mode
  18676. */
  18677. needAlphaTesting: boolean;
  18678. /**
  18679. * The list of attribute names used in the shader
  18680. */
  18681. attributes: string[];
  18682. /**
  18683. * The list of unifrom names used in the shader
  18684. */
  18685. uniforms: string[];
  18686. /**
  18687. * The list of UBO names used in the shader
  18688. */
  18689. uniformBuffers: string[];
  18690. /**
  18691. * The list of sampler names used in the shader
  18692. */
  18693. samplers: string[];
  18694. /**
  18695. * The list of defines used in the shader
  18696. */
  18697. defines: string[];
  18698. }
  18699. /**
  18700. * 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.
  18701. *
  18702. * This returned material effects how the mesh will look based on the code in the shaders.
  18703. *
  18704. * @see http://doc.babylonjs.com/how_to/shader_material
  18705. */
  18706. export class ShaderMaterial extends Material {
  18707. private _shaderPath;
  18708. private _options;
  18709. private _textures;
  18710. private _textureArrays;
  18711. private _floats;
  18712. private _ints;
  18713. private _floatsArrays;
  18714. private _colors3;
  18715. private _colors3Arrays;
  18716. private _colors4;
  18717. private _colors4Arrays;
  18718. private _vectors2;
  18719. private _vectors3;
  18720. private _vectors4;
  18721. private _matrices;
  18722. private _matrices3x3;
  18723. private _matrices2x2;
  18724. private _vectors2Arrays;
  18725. private _vectors3Arrays;
  18726. private _vectors4Arrays;
  18727. private _cachedWorldViewMatrix;
  18728. private _cachedWorldViewProjectionMatrix;
  18729. private _renderId;
  18730. /**
  18731. * Instantiate a new shader material.
  18732. * 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.
  18733. * This returned material effects how the mesh will look based on the code in the shaders.
  18734. * @see http://doc.babylonjs.com/how_to/shader_material
  18735. * @param name Define the name of the material in the scene
  18736. * @param scene Define the scene the material belongs to
  18737. * @param shaderPath Defines the route to the shader code in one of three ways:
  18738. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18739. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18740. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18741. * @param options Define the options used to create the shader
  18742. */
  18743. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18744. /**
  18745. * Gets the options used to compile the shader.
  18746. * They can be modified to trigger a new compilation
  18747. */
  18748. readonly options: IShaderMaterialOptions;
  18749. /**
  18750. * Gets the current class name of the material e.g. "ShaderMaterial"
  18751. * Mainly use in serialization.
  18752. * @returns the class name
  18753. */
  18754. getClassName(): string;
  18755. /**
  18756. * Specifies if the material will require alpha blending
  18757. * @returns a boolean specifying if alpha blending is needed
  18758. */
  18759. needAlphaBlending(): boolean;
  18760. /**
  18761. * Specifies if this material should be rendered in alpha test mode
  18762. * @returns a boolean specifying if an alpha test is needed.
  18763. */
  18764. needAlphaTesting(): boolean;
  18765. private _checkUniform;
  18766. /**
  18767. * Set a texture in the shader.
  18768. * @param name Define the name of the uniform samplers as defined in the shader
  18769. * @param texture Define the texture to bind to this sampler
  18770. * @return the material itself allowing "fluent" like uniform updates
  18771. */
  18772. setTexture(name: string, texture: Texture): ShaderMaterial;
  18773. /**
  18774. * Set a texture array in the shader.
  18775. * @param name Define the name of the uniform sampler array as defined in the shader
  18776. * @param textures Define the list of textures to bind to this sampler
  18777. * @return the material itself allowing "fluent" like uniform updates
  18778. */
  18779. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18780. /**
  18781. * Set a float in the shader.
  18782. * @param name Define the name of the uniform as defined in the shader
  18783. * @param value Define the value to give to the uniform
  18784. * @return the material itself allowing "fluent" like uniform updates
  18785. */
  18786. setFloat(name: string, value: number): ShaderMaterial;
  18787. /**
  18788. * Set a int in the shader.
  18789. * @param name Define the name of the uniform as defined in the shader
  18790. * @param value Define the value to give to the uniform
  18791. * @return the material itself allowing "fluent" like uniform updates
  18792. */
  18793. setInt(name: string, value: number): ShaderMaterial;
  18794. /**
  18795. * Set an array of floats in the shader.
  18796. * @param name Define the name of the uniform as defined in the shader
  18797. * @param value Define the value to give to the uniform
  18798. * @return the material itself allowing "fluent" like uniform updates
  18799. */
  18800. setFloats(name: string, value: number[]): ShaderMaterial;
  18801. /**
  18802. * Set a vec3 in the shader from a Color3.
  18803. * @param name Define the name of the uniform as defined in the shader
  18804. * @param value Define the value to give to the uniform
  18805. * @return the material itself allowing "fluent" like uniform updates
  18806. */
  18807. setColor3(name: string, value: Color3): ShaderMaterial;
  18808. /**
  18809. * Set a vec3 array in the shader from a Color3 array.
  18810. * @param name Define the name of the uniform as defined in the shader
  18811. * @param value Define the value to give to the uniform
  18812. * @return the material itself allowing "fluent" like uniform updates
  18813. */
  18814. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18815. /**
  18816. * Set a vec4 in the shader from a Color4.
  18817. * @param name Define the name of the uniform as defined in the shader
  18818. * @param value Define the value to give to the uniform
  18819. * @return the material itself allowing "fluent" like uniform updates
  18820. */
  18821. setColor4(name: string, value: Color4): ShaderMaterial;
  18822. /**
  18823. * Set a vec4 array in the shader from a Color4 array.
  18824. * @param name Define the name of the uniform as defined in the shader
  18825. * @param value Define the value to give to the uniform
  18826. * @return the material itself allowing "fluent" like uniform updates
  18827. */
  18828. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18829. /**
  18830. * Set a vec2 in the shader from a Vector2.
  18831. * @param name Define the name of the uniform as defined in the shader
  18832. * @param value Define the value to give to the uniform
  18833. * @return the material itself allowing "fluent" like uniform updates
  18834. */
  18835. setVector2(name: string, value: Vector2): ShaderMaterial;
  18836. /**
  18837. * Set a vec3 in the shader from a Vector3.
  18838. * @param name Define the name of the uniform as defined in the shader
  18839. * @param value Define the value to give to the uniform
  18840. * @return the material itself allowing "fluent" like uniform updates
  18841. */
  18842. setVector3(name: string, value: Vector3): ShaderMaterial;
  18843. /**
  18844. * Set a vec4 in the shader from a Vector4.
  18845. * @param name Define the name of the uniform as defined in the shader
  18846. * @param value Define the value to give to the uniform
  18847. * @return the material itself allowing "fluent" like uniform updates
  18848. */
  18849. setVector4(name: string, value: Vector4): ShaderMaterial;
  18850. /**
  18851. * Set a mat4 in the shader from a Matrix.
  18852. * @param name Define the name of the uniform as defined in the shader
  18853. * @param value Define the value to give to the uniform
  18854. * @return the material itself allowing "fluent" like uniform updates
  18855. */
  18856. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18857. /**
  18858. * Set a mat3 in the shader from a Float32Array.
  18859. * @param name Define the name of the uniform as defined in the shader
  18860. * @param value Define the value to give to the uniform
  18861. * @return the material itself allowing "fluent" like uniform updates
  18862. */
  18863. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18864. /**
  18865. * Set a mat2 in the shader from a Float32Array.
  18866. * @param name Define the name of the uniform as defined in the shader
  18867. * @param value Define the value to give to the uniform
  18868. * @return the material itself allowing "fluent" like uniform updates
  18869. */
  18870. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18871. /**
  18872. * Set a vec2 array in the shader from a number array.
  18873. * @param name Define the name of the uniform as defined in the shader
  18874. * @param value Define the value to give to the uniform
  18875. * @return the material itself allowing "fluent" like uniform updates
  18876. */
  18877. setArray2(name: string, value: number[]): ShaderMaterial;
  18878. /**
  18879. * Set a vec3 array in the shader from a number array.
  18880. * @param name Define the name of the uniform as defined in the shader
  18881. * @param value Define the value to give to the uniform
  18882. * @return the material itself allowing "fluent" like uniform updates
  18883. */
  18884. setArray3(name: string, value: number[]): ShaderMaterial;
  18885. /**
  18886. * Set a vec4 array in the shader from a number array.
  18887. * @param name Define the name of the uniform as defined in the shader
  18888. * @param value Define the value to give to the uniform
  18889. * @return the material itself allowing "fluent" like uniform updates
  18890. */
  18891. setArray4(name: string, value: number[]): ShaderMaterial;
  18892. private _checkCache;
  18893. /**
  18894. * Specifies that the submesh is ready to be used
  18895. * @param mesh defines the mesh to check
  18896. * @param subMesh defines which submesh to check
  18897. * @param useInstances specifies that instances should be used
  18898. * @returns a boolean indicating that the submesh is ready or not
  18899. */
  18900. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18901. /**
  18902. * Checks if the material is ready to render the requested mesh
  18903. * @param mesh Define the mesh to render
  18904. * @param useInstances Define whether or not the material is used with instances
  18905. * @returns true if ready, otherwise false
  18906. */
  18907. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18908. /**
  18909. * Binds the world matrix to the material
  18910. * @param world defines the world transformation matrix
  18911. */
  18912. bindOnlyWorldMatrix(world: Matrix): void;
  18913. /**
  18914. * Binds the material to the mesh
  18915. * @param world defines the world transformation matrix
  18916. * @param mesh defines the mesh to bind the material to
  18917. */
  18918. bind(world: Matrix, mesh?: Mesh): void;
  18919. /**
  18920. * Gets the active textures from the material
  18921. * @returns an array of textures
  18922. */
  18923. getActiveTextures(): BaseTexture[];
  18924. /**
  18925. * Specifies if the material uses a texture
  18926. * @param texture defines the texture to check against the material
  18927. * @returns a boolean specifying if the material uses the texture
  18928. */
  18929. hasTexture(texture: BaseTexture): boolean;
  18930. /**
  18931. * Makes a duplicate of the material, and gives it a new name
  18932. * @param name defines the new name for the duplicated material
  18933. * @returns the cloned material
  18934. */
  18935. clone(name: string): ShaderMaterial;
  18936. /**
  18937. * Disposes the material
  18938. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18939. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18940. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18941. */
  18942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18943. /**
  18944. * Serializes this material in a JSON representation
  18945. * @returns the serialized material object
  18946. */
  18947. serialize(): any;
  18948. /**
  18949. * Creates a shader material from parsed shader material data
  18950. * @param source defines the JSON represnetation of the material
  18951. * @param scene defines the hosting scene
  18952. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18953. * @returns a new material
  18954. */
  18955. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18956. }
  18957. }
  18958. declare module BABYLON {
  18959. /** @hidden */
  18960. export var colorPixelShader: {
  18961. name: string;
  18962. shader: string;
  18963. };
  18964. }
  18965. declare module BABYLON {
  18966. /** @hidden */
  18967. export var colorVertexShader: {
  18968. name: string;
  18969. shader: string;
  18970. };
  18971. }
  18972. declare module BABYLON {
  18973. /**
  18974. * Line mesh
  18975. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18976. */
  18977. export class LinesMesh extends Mesh {
  18978. /**
  18979. * If vertex color should be applied to the mesh
  18980. */
  18981. readonly useVertexColor?: boolean | undefined;
  18982. /**
  18983. * If vertex alpha should be applied to the mesh
  18984. */
  18985. readonly useVertexAlpha?: boolean | undefined;
  18986. /**
  18987. * Color of the line (Default: White)
  18988. */
  18989. color: Color3;
  18990. /**
  18991. * Alpha of the line (Default: 1)
  18992. */
  18993. alpha: number;
  18994. /**
  18995. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18996. * This margin is expressed in world space coordinates, so its value may vary.
  18997. * Default value is 0.1
  18998. */
  18999. intersectionThreshold: number;
  19000. private _colorShader;
  19001. private color4;
  19002. /**
  19003. * Creates a new LinesMesh
  19004. * @param name defines the name
  19005. * @param scene defines the hosting scene
  19006. * @param parent defines the parent mesh if any
  19007. * @param source defines the optional source LinesMesh used to clone data from
  19008. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19009. * When false, achieved by calling a clone(), also passing False.
  19010. * This will make creation of children, recursive.
  19011. * @param useVertexColor defines if this LinesMesh supports vertex color
  19012. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19013. */
  19014. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19015. /**
  19016. * If vertex color should be applied to the mesh
  19017. */
  19018. useVertexColor?: boolean | undefined,
  19019. /**
  19020. * If vertex alpha should be applied to the mesh
  19021. */
  19022. useVertexAlpha?: boolean | undefined);
  19023. private _addClipPlaneDefine;
  19024. private _removeClipPlaneDefine;
  19025. isReady(): boolean;
  19026. /**
  19027. * Returns the string "LineMesh"
  19028. */
  19029. getClassName(): string;
  19030. /**
  19031. * @hidden
  19032. */
  19033. /**
  19034. * @hidden
  19035. */
  19036. material: Material;
  19037. /**
  19038. * @hidden
  19039. */
  19040. readonly checkCollisions: boolean;
  19041. /** @hidden */
  19042. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19043. /** @hidden */
  19044. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19045. /**
  19046. * Disposes of the line mesh
  19047. * @param doNotRecurse If children should be disposed
  19048. */
  19049. dispose(doNotRecurse?: boolean): void;
  19050. /**
  19051. * Returns a new LineMesh object cloned from the current one.
  19052. */
  19053. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19054. /**
  19055. * Creates a new InstancedLinesMesh object from the mesh model.
  19056. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19057. * @param name defines the name of the new instance
  19058. * @returns a new InstancedLinesMesh
  19059. */
  19060. createInstance(name: string): InstancedLinesMesh;
  19061. }
  19062. /**
  19063. * Creates an instance based on a source LinesMesh
  19064. */
  19065. export class InstancedLinesMesh extends InstancedMesh {
  19066. /**
  19067. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19068. * This margin is expressed in world space coordinates, so its value may vary.
  19069. * Initilized with the intersectionThreshold value of the source LinesMesh
  19070. */
  19071. intersectionThreshold: number;
  19072. constructor(name: string, source: LinesMesh);
  19073. /**
  19074. * Returns the string "InstancedLinesMesh".
  19075. */
  19076. getClassName(): string;
  19077. }
  19078. }
  19079. declare module BABYLON {
  19080. /** @hidden */
  19081. export var linePixelShader: {
  19082. name: string;
  19083. shader: string;
  19084. };
  19085. }
  19086. declare module BABYLON {
  19087. /** @hidden */
  19088. export var lineVertexShader: {
  19089. name: string;
  19090. shader: string;
  19091. };
  19092. }
  19093. declare module BABYLON {
  19094. interface AbstractMesh {
  19095. /**
  19096. * Gets the edgesRenderer associated with the mesh
  19097. */
  19098. edgesRenderer: Nullable<EdgesRenderer>;
  19099. }
  19100. interface LinesMesh {
  19101. /**
  19102. * Enables the edge rendering mode on the mesh.
  19103. * This mode makes the mesh edges visible
  19104. * @param epsilon defines the maximal distance between two angles to detect a face
  19105. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19106. * @returns the currentAbstractMesh
  19107. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19108. */
  19109. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19110. }
  19111. interface InstancedLinesMesh {
  19112. /**
  19113. * Enables the edge rendering mode on the mesh.
  19114. * This mode makes the mesh edges visible
  19115. * @param epsilon defines the maximal distance between two angles to detect a face
  19116. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19117. * @returns the current InstancedLinesMesh
  19118. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19119. */
  19120. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19121. }
  19122. /**
  19123. * Defines the minimum contract an Edges renderer should follow.
  19124. */
  19125. export interface IEdgesRenderer extends IDisposable {
  19126. /**
  19127. * Gets or sets a boolean indicating if the edgesRenderer is active
  19128. */
  19129. isEnabled: boolean;
  19130. /**
  19131. * Renders the edges of the attached mesh,
  19132. */
  19133. render(): void;
  19134. /**
  19135. * Checks wether or not the edges renderer is ready to render.
  19136. * @return true if ready, otherwise false.
  19137. */
  19138. isReady(): boolean;
  19139. }
  19140. /**
  19141. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19142. */
  19143. export class EdgesRenderer implements IEdgesRenderer {
  19144. /**
  19145. * Define the size of the edges with an orthographic camera
  19146. */
  19147. edgesWidthScalerForOrthographic: number;
  19148. /**
  19149. * Define the size of the edges with a perspective camera
  19150. */
  19151. edgesWidthScalerForPerspective: number;
  19152. protected _source: AbstractMesh;
  19153. protected _linesPositions: number[];
  19154. protected _linesNormals: number[];
  19155. protected _linesIndices: number[];
  19156. protected _epsilon: number;
  19157. protected _indicesCount: number;
  19158. protected _lineShader: ShaderMaterial;
  19159. protected _ib: DataBuffer;
  19160. protected _buffers: {
  19161. [key: string]: Nullable<VertexBuffer>;
  19162. };
  19163. protected _checkVerticesInsteadOfIndices: boolean;
  19164. private _meshRebuildObserver;
  19165. private _meshDisposeObserver;
  19166. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19167. isEnabled: boolean;
  19168. /**
  19169. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19170. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19171. * @param source Mesh used to create edges
  19172. * @param epsilon sum of angles in adjacency to check for edge
  19173. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19174. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19175. */
  19176. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19177. protected _prepareRessources(): void;
  19178. /** @hidden */
  19179. _rebuild(): void;
  19180. /**
  19181. * Releases the required resources for the edges renderer
  19182. */
  19183. dispose(): void;
  19184. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19185. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19186. /**
  19187. * Checks if the pair of p0 and p1 is en edge
  19188. * @param faceIndex
  19189. * @param edge
  19190. * @param faceNormals
  19191. * @param p0
  19192. * @param p1
  19193. * @private
  19194. */
  19195. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19196. /**
  19197. * push line into the position, normal and index buffer
  19198. * @protected
  19199. */
  19200. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19201. /**
  19202. * Generates lines edges from adjacencjes
  19203. * @private
  19204. */
  19205. _generateEdgesLines(): void;
  19206. /**
  19207. * Checks wether or not the edges renderer is ready to render.
  19208. * @return true if ready, otherwise false.
  19209. */
  19210. isReady(): boolean;
  19211. /**
  19212. * Renders the edges of the attached mesh,
  19213. */
  19214. render(): void;
  19215. }
  19216. /**
  19217. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19218. */
  19219. export class LineEdgesRenderer extends EdgesRenderer {
  19220. /**
  19221. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19222. * @param source LineMesh used to generate edges
  19223. * @param epsilon not important (specified angle for edge detection)
  19224. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19225. */
  19226. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19227. /**
  19228. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19229. */
  19230. _generateEdgesLines(): void;
  19231. }
  19232. }
  19233. declare module BABYLON {
  19234. /**
  19235. * This represents the object necessary to create a rendering group.
  19236. * This is exclusively used and created by the rendering manager.
  19237. * To modify the behavior, you use the available helpers in your scene or meshes.
  19238. * @hidden
  19239. */
  19240. export class RenderingGroup {
  19241. index: number;
  19242. private static _zeroVector;
  19243. private _scene;
  19244. private _opaqueSubMeshes;
  19245. private _transparentSubMeshes;
  19246. private _alphaTestSubMeshes;
  19247. private _depthOnlySubMeshes;
  19248. private _particleSystems;
  19249. private _spriteManagers;
  19250. private _opaqueSortCompareFn;
  19251. private _alphaTestSortCompareFn;
  19252. private _transparentSortCompareFn;
  19253. private _renderOpaque;
  19254. private _renderAlphaTest;
  19255. private _renderTransparent;
  19256. /** @hidden */
  19257. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19258. onBeforeTransparentRendering: () => void;
  19259. /**
  19260. * Set the opaque sort comparison function.
  19261. * If null the sub meshes will be render in the order they were created
  19262. */
  19263. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19264. /**
  19265. * Set the alpha test sort comparison function.
  19266. * If null the sub meshes will be render in the order they were created
  19267. */
  19268. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19269. /**
  19270. * Set the transparent sort comparison function.
  19271. * If null the sub meshes will be render in the order they were created
  19272. */
  19273. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19274. /**
  19275. * Creates a new rendering group.
  19276. * @param index The rendering group index
  19277. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19278. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19279. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19280. */
  19281. 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>);
  19282. /**
  19283. * Render all the sub meshes contained in the group.
  19284. * @param customRenderFunction Used to override the default render behaviour of the group.
  19285. * @returns true if rendered some submeshes.
  19286. */
  19287. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19288. /**
  19289. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19290. * @param subMeshes The submeshes to render
  19291. */
  19292. private renderOpaqueSorted;
  19293. /**
  19294. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19295. * @param subMeshes The submeshes to render
  19296. */
  19297. private renderAlphaTestSorted;
  19298. /**
  19299. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19300. * @param subMeshes The submeshes to render
  19301. */
  19302. private renderTransparentSorted;
  19303. /**
  19304. * Renders the submeshes in a specified order.
  19305. * @param subMeshes The submeshes to sort before render
  19306. * @param sortCompareFn The comparison function use to sort
  19307. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19308. * @param transparent Specifies to activate blending if true
  19309. */
  19310. private static renderSorted;
  19311. /**
  19312. * Renders the submeshes in the order they were dispatched (no sort applied).
  19313. * @param subMeshes The submeshes to render
  19314. */
  19315. private static renderUnsorted;
  19316. /**
  19317. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19318. * are rendered back to front if in the same alpha index.
  19319. *
  19320. * @param a The first submesh
  19321. * @param b The second submesh
  19322. * @returns The result of the comparison
  19323. */
  19324. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19325. /**
  19326. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19327. * are rendered back to front.
  19328. *
  19329. * @param a The first submesh
  19330. * @param b The second submesh
  19331. * @returns The result of the comparison
  19332. */
  19333. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19334. /**
  19335. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19336. * are rendered front to back (prevent overdraw).
  19337. *
  19338. * @param a The first submesh
  19339. * @param b The second submesh
  19340. * @returns The result of the comparison
  19341. */
  19342. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19343. /**
  19344. * Resets the different lists of submeshes to prepare a new frame.
  19345. */
  19346. prepare(): void;
  19347. dispose(): void;
  19348. /**
  19349. * Inserts the submesh in its correct queue depending on its material.
  19350. * @param subMesh The submesh to dispatch
  19351. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19352. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19353. */
  19354. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19355. dispatchSprites(spriteManager: ISpriteManager): void;
  19356. dispatchParticles(particleSystem: IParticleSystem): void;
  19357. private _renderParticles;
  19358. private _renderSprites;
  19359. }
  19360. }
  19361. declare module BABYLON {
  19362. /**
  19363. * Interface describing the different options available in the rendering manager
  19364. * regarding Auto Clear between groups.
  19365. */
  19366. export interface IRenderingManagerAutoClearSetup {
  19367. /**
  19368. * Defines whether or not autoclear is enable.
  19369. */
  19370. autoClear: boolean;
  19371. /**
  19372. * Defines whether or not to autoclear the depth buffer.
  19373. */
  19374. depth: boolean;
  19375. /**
  19376. * Defines whether or not to autoclear the stencil buffer.
  19377. */
  19378. stencil: boolean;
  19379. }
  19380. /**
  19381. * This class is used by the onRenderingGroupObservable
  19382. */
  19383. export class RenderingGroupInfo {
  19384. /**
  19385. * The Scene that being rendered
  19386. */
  19387. scene: Scene;
  19388. /**
  19389. * The camera currently used for the rendering pass
  19390. */
  19391. camera: Nullable<Camera>;
  19392. /**
  19393. * The ID of the renderingGroup being processed
  19394. */
  19395. renderingGroupId: number;
  19396. }
  19397. /**
  19398. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19399. * It is enable to manage the different groups as well as the different necessary sort functions.
  19400. * This should not be used directly aside of the few static configurations
  19401. */
  19402. export class RenderingManager {
  19403. /**
  19404. * The max id used for rendering groups (not included)
  19405. */
  19406. static MAX_RENDERINGGROUPS: number;
  19407. /**
  19408. * The min id used for rendering groups (included)
  19409. */
  19410. static MIN_RENDERINGGROUPS: number;
  19411. /**
  19412. * Used to globally prevent autoclearing scenes.
  19413. */
  19414. static AUTOCLEAR: boolean;
  19415. /**
  19416. * @hidden
  19417. */
  19418. _useSceneAutoClearSetup: boolean;
  19419. private _scene;
  19420. private _renderingGroups;
  19421. private _depthStencilBufferAlreadyCleaned;
  19422. private _autoClearDepthStencil;
  19423. private _customOpaqueSortCompareFn;
  19424. private _customAlphaTestSortCompareFn;
  19425. private _customTransparentSortCompareFn;
  19426. private _renderingGroupInfo;
  19427. /**
  19428. * Instantiates a new rendering group for a particular scene
  19429. * @param scene Defines the scene the groups belongs to
  19430. */
  19431. constructor(scene: Scene);
  19432. private _clearDepthStencilBuffer;
  19433. /**
  19434. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19435. * @hidden
  19436. */
  19437. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19438. /**
  19439. * Resets the different information of the group to prepare a new frame
  19440. * @hidden
  19441. */
  19442. reset(): void;
  19443. /**
  19444. * Dispose and release the group and its associated resources.
  19445. * @hidden
  19446. */
  19447. dispose(): void;
  19448. /**
  19449. * Clear the info related to rendering groups preventing retention points during dispose.
  19450. */
  19451. freeRenderingGroups(): void;
  19452. private _prepareRenderingGroup;
  19453. /**
  19454. * Add a sprite manager to the rendering manager in order to render it this frame.
  19455. * @param spriteManager Define the sprite manager to render
  19456. */
  19457. dispatchSprites(spriteManager: ISpriteManager): void;
  19458. /**
  19459. * Add a particle system to the rendering manager in order to render it this frame.
  19460. * @param particleSystem Define the particle system to render
  19461. */
  19462. dispatchParticles(particleSystem: IParticleSystem): void;
  19463. /**
  19464. * Add a submesh to the manager in order to render it this frame
  19465. * @param subMesh The submesh to dispatch
  19466. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19467. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19468. */
  19469. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19470. /**
  19471. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19472. * This allowed control for front to back rendering or reversly depending of the special needs.
  19473. *
  19474. * @param renderingGroupId The rendering group id corresponding to its index
  19475. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19476. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19477. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19478. */
  19479. 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;
  19480. /**
  19481. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19482. *
  19483. * @param renderingGroupId The rendering group id corresponding to its index
  19484. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19485. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19486. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19487. */
  19488. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19489. /**
  19490. * Gets the current auto clear configuration for one rendering group of the rendering
  19491. * manager.
  19492. * @param index the rendering group index to get the information for
  19493. * @returns The auto clear setup for the requested rendering group
  19494. */
  19495. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19496. }
  19497. }
  19498. declare module BABYLON {
  19499. /**
  19500. * This Helps creating a texture that will be created from a camera in your scene.
  19501. * It is basically a dynamic texture that could be used to create special effects for instance.
  19502. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19503. */
  19504. export class RenderTargetTexture extends Texture {
  19505. isCube: boolean;
  19506. /**
  19507. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19508. */
  19509. static readonly REFRESHRATE_RENDER_ONCE: number;
  19510. /**
  19511. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19512. */
  19513. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19514. /**
  19515. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19516. * the central point of your effect and can save a lot of performances.
  19517. */
  19518. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19519. /**
  19520. * Use this predicate to dynamically define the list of mesh you want to render.
  19521. * If set, the renderList property will be overwritten.
  19522. */
  19523. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19524. private _renderList;
  19525. /**
  19526. * Use this list to define the list of mesh you want to render.
  19527. */
  19528. renderList: Nullable<Array<AbstractMesh>>;
  19529. private _hookArray;
  19530. /**
  19531. * Define if particles should be rendered in your texture.
  19532. */
  19533. renderParticles: boolean;
  19534. /**
  19535. * Define if sprites should be rendered in your texture.
  19536. */
  19537. renderSprites: boolean;
  19538. /**
  19539. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19540. */
  19541. coordinatesMode: number;
  19542. /**
  19543. * Define the camera used to render the texture.
  19544. */
  19545. activeCamera: Nullable<Camera>;
  19546. /**
  19547. * Override the render function of the texture with your own one.
  19548. */
  19549. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19550. /**
  19551. * Define if camera post processes should be use while rendering the texture.
  19552. */
  19553. useCameraPostProcesses: boolean;
  19554. /**
  19555. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19556. */
  19557. ignoreCameraViewport: boolean;
  19558. private _postProcessManager;
  19559. private _postProcesses;
  19560. private _resizeObserver;
  19561. /**
  19562. * An event triggered when the texture is unbind.
  19563. */
  19564. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19565. /**
  19566. * An event triggered when the texture is unbind.
  19567. */
  19568. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19569. private _onAfterUnbindObserver;
  19570. /**
  19571. * Set a after unbind callback in the texture.
  19572. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19573. */
  19574. onAfterUnbind: () => void;
  19575. /**
  19576. * An event triggered before rendering the texture
  19577. */
  19578. onBeforeRenderObservable: Observable<number>;
  19579. private _onBeforeRenderObserver;
  19580. /**
  19581. * Set a before render callback in the texture.
  19582. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19583. */
  19584. onBeforeRender: (faceIndex: number) => void;
  19585. /**
  19586. * An event triggered after rendering the texture
  19587. */
  19588. onAfterRenderObservable: Observable<number>;
  19589. private _onAfterRenderObserver;
  19590. /**
  19591. * Set a after render callback in the texture.
  19592. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19593. */
  19594. onAfterRender: (faceIndex: number) => void;
  19595. /**
  19596. * An event triggered after the texture clear
  19597. */
  19598. onClearObservable: Observable<Engine>;
  19599. private _onClearObserver;
  19600. /**
  19601. * Set a clear callback in the texture.
  19602. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19603. */
  19604. onClear: (Engine: Engine) => void;
  19605. /**
  19606. * Define the clear color of the Render Target if it should be different from the scene.
  19607. */
  19608. clearColor: Color4;
  19609. protected _size: number | {
  19610. width: number;
  19611. height: number;
  19612. };
  19613. protected _initialSizeParameter: number | {
  19614. width: number;
  19615. height: number;
  19616. } | {
  19617. ratio: number;
  19618. };
  19619. protected _sizeRatio: Nullable<number>;
  19620. /** @hidden */
  19621. _generateMipMaps: boolean;
  19622. protected _renderingManager: RenderingManager;
  19623. /** @hidden */
  19624. _waitingRenderList: string[];
  19625. protected _doNotChangeAspectRatio: boolean;
  19626. protected _currentRefreshId: number;
  19627. protected _refreshRate: number;
  19628. protected _textureMatrix: Matrix;
  19629. protected _samples: number;
  19630. protected _renderTargetOptions: RenderTargetCreationOptions;
  19631. /**
  19632. * Gets render target creation options that were used.
  19633. */
  19634. readonly renderTargetOptions: RenderTargetCreationOptions;
  19635. protected _engine: Engine;
  19636. protected _onRatioRescale(): void;
  19637. /**
  19638. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19639. * It must define where the camera used to render the texture is set
  19640. */
  19641. boundingBoxPosition: Vector3;
  19642. private _boundingBoxSize;
  19643. /**
  19644. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19645. * When defined, the cubemap will switch to local mode
  19646. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19647. * @example https://www.babylonjs-playground.com/#RNASML
  19648. */
  19649. boundingBoxSize: Vector3;
  19650. /**
  19651. * In case the RTT has been created with a depth texture, get the associated
  19652. * depth texture.
  19653. * Otherwise, return null.
  19654. */
  19655. depthStencilTexture: Nullable<InternalTexture>;
  19656. /**
  19657. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19658. * or used a shadow, depth texture...
  19659. * @param name The friendly name of the texture
  19660. * @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)
  19661. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19662. * @param generateMipMaps True if mip maps need to be generated after render.
  19663. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19664. * @param type The type of the buffer in the RTT (int, half float, float...)
  19665. * @param isCube True if a cube texture needs to be created
  19666. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19667. * @param generateDepthBuffer True to generate a depth buffer
  19668. * @param generateStencilBuffer True to generate a stencil buffer
  19669. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19670. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19671. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19672. */
  19673. constructor(name: string, size: number | {
  19674. width: number;
  19675. height: number;
  19676. } | {
  19677. ratio: number;
  19678. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19679. /**
  19680. * Creates a depth stencil texture.
  19681. * This is only available in WebGL 2 or with the depth texture extension available.
  19682. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19683. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19684. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19685. */
  19686. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19687. private _processSizeParameter;
  19688. /**
  19689. * Define the number of samples to use in case of MSAA.
  19690. * It defaults to one meaning no MSAA has been enabled.
  19691. */
  19692. samples: number;
  19693. /**
  19694. * Resets the refresh counter of the texture and start bak from scratch.
  19695. * Could be useful to regenerate the texture if it is setup to render only once.
  19696. */
  19697. resetRefreshCounter(): void;
  19698. /**
  19699. * Define the refresh rate of the texture or the rendering frequency.
  19700. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19701. */
  19702. refreshRate: number;
  19703. /**
  19704. * Adds a post process to the render target rendering passes.
  19705. * @param postProcess define the post process to add
  19706. */
  19707. addPostProcess(postProcess: PostProcess): void;
  19708. /**
  19709. * Clear all the post processes attached to the render target
  19710. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19711. */
  19712. clearPostProcesses(dispose?: boolean): void;
  19713. /**
  19714. * Remove one of the post process from the list of attached post processes to the texture
  19715. * @param postProcess define the post process to remove from the list
  19716. */
  19717. removePostProcess(postProcess: PostProcess): void;
  19718. /** @hidden */
  19719. _shouldRender(): boolean;
  19720. /**
  19721. * Gets the actual render size of the texture.
  19722. * @returns the width of the render size
  19723. */
  19724. getRenderSize(): number;
  19725. /**
  19726. * Gets the actual render width of the texture.
  19727. * @returns the width of the render size
  19728. */
  19729. getRenderWidth(): number;
  19730. /**
  19731. * Gets the actual render height of the texture.
  19732. * @returns the height of the render size
  19733. */
  19734. getRenderHeight(): number;
  19735. /**
  19736. * Get if the texture can be rescaled or not.
  19737. */
  19738. readonly canRescale: boolean;
  19739. /**
  19740. * Resize the texture using a ratio.
  19741. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19742. */
  19743. scale(ratio: number): void;
  19744. /**
  19745. * Get the texture reflection matrix used to rotate/transform the reflection.
  19746. * @returns the reflection matrix
  19747. */
  19748. getReflectionTextureMatrix(): Matrix;
  19749. /**
  19750. * Resize the texture to a new desired size.
  19751. * Be carrefull as it will recreate all the data in the new texture.
  19752. * @param size Define the new size. It can be:
  19753. * - a number for squared texture,
  19754. * - an object containing { width: number, height: number }
  19755. * - or an object containing a ratio { ratio: number }
  19756. */
  19757. resize(size: number | {
  19758. width: number;
  19759. height: number;
  19760. } | {
  19761. ratio: number;
  19762. }): void;
  19763. /**
  19764. * Renders all the objects from the render list into the texture.
  19765. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19766. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19767. */
  19768. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19769. private _bestReflectionRenderTargetDimension;
  19770. /**
  19771. * @hidden
  19772. * @param faceIndex face index to bind to if this is a cubetexture
  19773. */
  19774. _bindFrameBuffer(faceIndex?: number): void;
  19775. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19776. private renderToTarget;
  19777. /**
  19778. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19779. * This allowed control for front to back rendering or reversly depending of the special needs.
  19780. *
  19781. * @param renderingGroupId The rendering group id corresponding to its index
  19782. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19783. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19784. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19785. */
  19786. 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;
  19787. /**
  19788. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19789. *
  19790. * @param renderingGroupId The rendering group id corresponding to its index
  19791. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19792. */
  19793. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19794. /**
  19795. * Clones the texture.
  19796. * @returns the cloned texture
  19797. */
  19798. clone(): RenderTargetTexture;
  19799. /**
  19800. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19801. * @returns The JSON representation of the texture
  19802. */
  19803. serialize(): any;
  19804. /**
  19805. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19806. */
  19807. disposeFramebufferObjects(): void;
  19808. /**
  19809. * Dispose the texture and release its associated resources.
  19810. */
  19811. dispose(): void;
  19812. /** @hidden */
  19813. _rebuild(): void;
  19814. /**
  19815. * Clear the info related to rendering groups preventing retention point in material dispose.
  19816. */
  19817. freeRenderingGroups(): void;
  19818. /**
  19819. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19820. * @returns the view count
  19821. */
  19822. getViewCount(): number;
  19823. }
  19824. }
  19825. declare module BABYLON {
  19826. /**
  19827. * Base class for the main features of a material in Babylon.js
  19828. */
  19829. export class Material implements IAnimatable {
  19830. /**
  19831. * Returns the triangle fill mode
  19832. */
  19833. static readonly TriangleFillMode: number;
  19834. /**
  19835. * Returns the wireframe mode
  19836. */
  19837. static readonly WireFrameFillMode: number;
  19838. /**
  19839. * Returns the point fill mode
  19840. */
  19841. static readonly PointFillMode: number;
  19842. /**
  19843. * Returns the point list draw mode
  19844. */
  19845. static readonly PointListDrawMode: number;
  19846. /**
  19847. * Returns the line list draw mode
  19848. */
  19849. static readonly LineListDrawMode: number;
  19850. /**
  19851. * Returns the line loop draw mode
  19852. */
  19853. static readonly LineLoopDrawMode: number;
  19854. /**
  19855. * Returns the line strip draw mode
  19856. */
  19857. static readonly LineStripDrawMode: number;
  19858. /**
  19859. * Returns the triangle strip draw mode
  19860. */
  19861. static readonly TriangleStripDrawMode: number;
  19862. /**
  19863. * Returns the triangle fan draw mode
  19864. */
  19865. static readonly TriangleFanDrawMode: number;
  19866. /**
  19867. * Stores the clock-wise side orientation
  19868. */
  19869. static readonly ClockWiseSideOrientation: number;
  19870. /**
  19871. * Stores the counter clock-wise side orientation
  19872. */
  19873. static readonly CounterClockWiseSideOrientation: number;
  19874. /**
  19875. * The dirty texture flag value
  19876. */
  19877. static readonly TextureDirtyFlag: number;
  19878. /**
  19879. * The dirty light flag value
  19880. */
  19881. static readonly LightDirtyFlag: number;
  19882. /**
  19883. * The dirty fresnel flag value
  19884. */
  19885. static readonly FresnelDirtyFlag: number;
  19886. /**
  19887. * The dirty attribute flag value
  19888. */
  19889. static readonly AttributesDirtyFlag: number;
  19890. /**
  19891. * The dirty misc flag value
  19892. */
  19893. static readonly MiscDirtyFlag: number;
  19894. /**
  19895. * The all dirty flag value
  19896. */
  19897. static readonly AllDirtyFlag: number;
  19898. /**
  19899. * The ID of the material
  19900. */
  19901. id: string;
  19902. /**
  19903. * Gets or sets the unique id of the material
  19904. */
  19905. uniqueId: number;
  19906. /**
  19907. * The name of the material
  19908. */
  19909. name: string;
  19910. /**
  19911. * Gets or sets user defined metadata
  19912. */
  19913. metadata: any;
  19914. /**
  19915. * For internal use only. Please do not use.
  19916. */
  19917. reservedDataStore: any;
  19918. /**
  19919. * Specifies if the ready state should be checked on each call
  19920. */
  19921. checkReadyOnEveryCall: boolean;
  19922. /**
  19923. * Specifies if the ready state should be checked once
  19924. */
  19925. checkReadyOnlyOnce: boolean;
  19926. /**
  19927. * The state of the material
  19928. */
  19929. state: string;
  19930. /**
  19931. * The alpha value of the material
  19932. */
  19933. protected _alpha: number;
  19934. /**
  19935. * List of inspectable custom properties (used by the Inspector)
  19936. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19937. */
  19938. inspectableCustomProperties: IInspectable[];
  19939. /**
  19940. * Sets the alpha value of the material
  19941. */
  19942. /**
  19943. * Gets the alpha value of the material
  19944. */
  19945. alpha: number;
  19946. /**
  19947. * Specifies if back face culling is enabled
  19948. */
  19949. protected _backFaceCulling: boolean;
  19950. /**
  19951. * Sets the back-face culling state
  19952. */
  19953. /**
  19954. * Gets the back-face culling state
  19955. */
  19956. backFaceCulling: boolean;
  19957. /**
  19958. * Stores the value for side orientation
  19959. */
  19960. sideOrientation: number;
  19961. /**
  19962. * Callback triggered when the material is compiled
  19963. */
  19964. onCompiled: Nullable<(effect: Effect) => void>;
  19965. /**
  19966. * Callback triggered when an error occurs
  19967. */
  19968. onError: Nullable<(effect: Effect, errors: string) => void>;
  19969. /**
  19970. * Callback triggered to get the render target textures
  19971. */
  19972. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  19973. /**
  19974. * Gets a boolean indicating that current material needs to register RTT
  19975. */
  19976. readonly hasRenderTargetTextures: boolean;
  19977. /**
  19978. * Specifies if the material should be serialized
  19979. */
  19980. doNotSerialize: boolean;
  19981. /**
  19982. * @hidden
  19983. */
  19984. _storeEffectOnSubMeshes: boolean;
  19985. /**
  19986. * Stores the animations for the material
  19987. */
  19988. animations: Nullable<Array<Animation>>;
  19989. /**
  19990. * An event triggered when the material is disposed
  19991. */
  19992. onDisposeObservable: Observable<Material>;
  19993. /**
  19994. * An observer which watches for dispose events
  19995. */
  19996. private _onDisposeObserver;
  19997. private _onUnBindObservable;
  19998. /**
  19999. * Called during a dispose event
  20000. */
  20001. onDispose: () => void;
  20002. private _onBindObservable;
  20003. /**
  20004. * An event triggered when the material is bound
  20005. */
  20006. readonly onBindObservable: Observable<AbstractMesh>;
  20007. /**
  20008. * An observer which watches for bind events
  20009. */
  20010. private _onBindObserver;
  20011. /**
  20012. * Called during a bind event
  20013. */
  20014. onBind: (Mesh: AbstractMesh) => void;
  20015. /**
  20016. * An event triggered when the material is unbound
  20017. */
  20018. readonly onUnBindObservable: Observable<Material>;
  20019. /**
  20020. * Stores the value of the alpha mode
  20021. */
  20022. private _alphaMode;
  20023. /**
  20024. * Sets the value of the alpha mode.
  20025. *
  20026. * | Value | Type | Description |
  20027. * | --- | --- | --- |
  20028. * | 0 | ALPHA_DISABLE | |
  20029. * | 1 | ALPHA_ADD | |
  20030. * | 2 | ALPHA_COMBINE | |
  20031. * | 3 | ALPHA_SUBTRACT | |
  20032. * | 4 | ALPHA_MULTIPLY | |
  20033. * | 5 | ALPHA_MAXIMIZED | |
  20034. * | 6 | ALPHA_ONEONE | |
  20035. * | 7 | ALPHA_PREMULTIPLIED | |
  20036. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20037. * | 9 | ALPHA_INTERPOLATE | |
  20038. * | 10 | ALPHA_SCREENMODE | |
  20039. *
  20040. */
  20041. /**
  20042. * Gets the value of the alpha mode
  20043. */
  20044. alphaMode: number;
  20045. /**
  20046. * Stores the state of the need depth pre-pass value
  20047. */
  20048. private _needDepthPrePass;
  20049. /**
  20050. * Sets the need depth pre-pass value
  20051. */
  20052. /**
  20053. * Gets the depth pre-pass value
  20054. */
  20055. needDepthPrePass: boolean;
  20056. /**
  20057. * Specifies if depth writing should be disabled
  20058. */
  20059. disableDepthWrite: boolean;
  20060. /**
  20061. * Specifies if depth writing should be forced
  20062. */
  20063. forceDepthWrite: boolean;
  20064. /**
  20065. * Specifies if there should be a separate pass for culling
  20066. */
  20067. separateCullingPass: boolean;
  20068. /**
  20069. * Stores the state specifing if fog should be enabled
  20070. */
  20071. private _fogEnabled;
  20072. /**
  20073. * Sets the state for enabling fog
  20074. */
  20075. /**
  20076. * Gets the value of the fog enabled state
  20077. */
  20078. fogEnabled: boolean;
  20079. /**
  20080. * Stores the size of points
  20081. */
  20082. pointSize: number;
  20083. /**
  20084. * Stores the z offset value
  20085. */
  20086. zOffset: number;
  20087. /**
  20088. * Gets a value specifying if wireframe mode is enabled
  20089. */
  20090. /**
  20091. * Sets the state of wireframe mode
  20092. */
  20093. wireframe: boolean;
  20094. /**
  20095. * Gets the value specifying if point clouds are enabled
  20096. */
  20097. /**
  20098. * Sets the state of point cloud mode
  20099. */
  20100. pointsCloud: boolean;
  20101. /**
  20102. * Gets the material fill mode
  20103. */
  20104. /**
  20105. * Sets the material fill mode
  20106. */
  20107. fillMode: number;
  20108. /**
  20109. * @hidden
  20110. * Stores the effects for the material
  20111. */
  20112. _effect: Nullable<Effect>;
  20113. /**
  20114. * @hidden
  20115. * Specifies if the material was previously ready
  20116. */
  20117. _wasPreviouslyReady: boolean;
  20118. /**
  20119. * Specifies if uniform buffers should be used
  20120. */
  20121. private _useUBO;
  20122. /**
  20123. * Stores a reference to the scene
  20124. */
  20125. private _scene;
  20126. /**
  20127. * Stores the fill mode state
  20128. */
  20129. private _fillMode;
  20130. /**
  20131. * Specifies if the depth write state should be cached
  20132. */
  20133. private _cachedDepthWriteState;
  20134. /**
  20135. * Stores the uniform buffer
  20136. */
  20137. protected _uniformBuffer: UniformBuffer;
  20138. /** @hidden */
  20139. _indexInSceneMaterialArray: number;
  20140. /** @hidden */
  20141. meshMap: Nullable<{
  20142. [id: string]: AbstractMesh | undefined;
  20143. }>;
  20144. /**
  20145. * Creates a material instance
  20146. * @param name defines the name of the material
  20147. * @param scene defines the scene to reference
  20148. * @param doNotAdd specifies if the material should be added to the scene
  20149. */
  20150. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20151. /**
  20152. * Returns a string representation of the current material
  20153. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20154. * @returns a string with material information
  20155. */
  20156. toString(fullDetails?: boolean): string;
  20157. /**
  20158. * Gets the class name of the material
  20159. * @returns a string with the class name of the material
  20160. */
  20161. getClassName(): string;
  20162. /**
  20163. * Specifies if updates for the material been locked
  20164. */
  20165. readonly isFrozen: boolean;
  20166. /**
  20167. * Locks updates for the material
  20168. */
  20169. freeze(): void;
  20170. /**
  20171. * Unlocks updates for the material
  20172. */
  20173. unfreeze(): void;
  20174. /**
  20175. * Specifies if the material is ready to be used
  20176. * @param mesh defines the mesh to check
  20177. * @param useInstances specifies if instances should be used
  20178. * @returns a boolean indicating if the material is ready to be used
  20179. */
  20180. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20181. /**
  20182. * Specifies that the submesh is ready to be used
  20183. * @param mesh defines the mesh to check
  20184. * @param subMesh defines which submesh to check
  20185. * @param useInstances specifies that instances should be used
  20186. * @returns a boolean indicating that the submesh is ready or not
  20187. */
  20188. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20189. /**
  20190. * Returns the material effect
  20191. * @returns the effect associated with the material
  20192. */
  20193. getEffect(): Nullable<Effect>;
  20194. /**
  20195. * Returns the current scene
  20196. * @returns a Scene
  20197. */
  20198. getScene(): Scene;
  20199. /**
  20200. * Specifies if the material will require alpha blending
  20201. * @returns a boolean specifying if alpha blending is needed
  20202. */
  20203. needAlphaBlending(): boolean;
  20204. /**
  20205. * Specifies if the mesh will require alpha blending
  20206. * @param mesh defines the mesh to check
  20207. * @returns a boolean specifying if alpha blending is needed for the mesh
  20208. */
  20209. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20210. /**
  20211. * Specifies if this material should be rendered in alpha test mode
  20212. * @returns a boolean specifying if an alpha test is needed.
  20213. */
  20214. needAlphaTesting(): boolean;
  20215. /**
  20216. * Gets the texture used for the alpha test
  20217. * @returns the texture to use for alpha testing
  20218. */
  20219. getAlphaTestTexture(): Nullable<BaseTexture>;
  20220. /**
  20221. * Marks the material to indicate that it needs to be re-calculated
  20222. */
  20223. markDirty(): void;
  20224. /** @hidden */
  20225. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20226. /**
  20227. * Binds the material to the mesh
  20228. * @param world defines the world transformation matrix
  20229. * @param mesh defines the mesh to bind the material to
  20230. */
  20231. bind(world: Matrix, mesh?: Mesh): void;
  20232. /**
  20233. * Binds the submesh to the material
  20234. * @param world defines the world transformation matrix
  20235. * @param mesh defines the mesh containing the submesh
  20236. * @param subMesh defines the submesh to bind the material to
  20237. */
  20238. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20239. /**
  20240. * Binds the world matrix to the material
  20241. * @param world defines the world transformation matrix
  20242. */
  20243. bindOnlyWorldMatrix(world: Matrix): void;
  20244. /**
  20245. * Binds the scene's uniform buffer to the effect.
  20246. * @param effect defines the effect to bind to the scene uniform buffer
  20247. * @param sceneUbo defines the uniform buffer storing scene data
  20248. */
  20249. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20250. /**
  20251. * Binds the view matrix to the effect
  20252. * @param effect defines the effect to bind the view matrix to
  20253. */
  20254. bindView(effect: Effect): void;
  20255. /**
  20256. * Binds the view projection matrix to the effect
  20257. * @param effect defines the effect to bind the view projection matrix to
  20258. */
  20259. bindViewProjection(effect: Effect): void;
  20260. /**
  20261. * Specifies if material alpha testing should be turned on for the mesh
  20262. * @param mesh defines the mesh to check
  20263. */
  20264. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20265. /**
  20266. * Processes to execute after binding the material to a mesh
  20267. * @param mesh defines the rendered mesh
  20268. */
  20269. protected _afterBind(mesh?: Mesh): void;
  20270. /**
  20271. * Unbinds the material from the mesh
  20272. */
  20273. unbind(): void;
  20274. /**
  20275. * Gets the active textures from the material
  20276. * @returns an array of textures
  20277. */
  20278. getActiveTextures(): BaseTexture[];
  20279. /**
  20280. * Specifies if the material uses a texture
  20281. * @param texture defines the texture to check against the material
  20282. * @returns a boolean specifying if the material uses the texture
  20283. */
  20284. hasTexture(texture: BaseTexture): boolean;
  20285. /**
  20286. * Makes a duplicate of the material, and gives it a new name
  20287. * @param name defines the new name for the duplicated material
  20288. * @returns the cloned material
  20289. */
  20290. clone(name: string): Nullable<Material>;
  20291. /**
  20292. * Gets the meshes bound to the material
  20293. * @returns an array of meshes bound to the material
  20294. */
  20295. getBindedMeshes(): AbstractMesh[];
  20296. /**
  20297. * Force shader compilation
  20298. * @param mesh defines the mesh associated with this material
  20299. * @param onCompiled defines a function to execute once the material is compiled
  20300. * @param options defines the options to configure the compilation
  20301. */
  20302. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20303. clipPlane: boolean;
  20304. }>): void;
  20305. /**
  20306. * Force shader compilation
  20307. * @param mesh defines the mesh that will use this material
  20308. * @param options defines additional options for compiling the shaders
  20309. * @returns a promise that resolves when the compilation completes
  20310. */
  20311. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20312. clipPlane: boolean;
  20313. }>): Promise<void>;
  20314. private static readonly _AllDirtyCallBack;
  20315. private static readonly _ImageProcessingDirtyCallBack;
  20316. private static readonly _TextureDirtyCallBack;
  20317. private static readonly _FresnelDirtyCallBack;
  20318. private static readonly _MiscDirtyCallBack;
  20319. private static readonly _LightsDirtyCallBack;
  20320. private static readonly _AttributeDirtyCallBack;
  20321. private static _FresnelAndMiscDirtyCallBack;
  20322. private static _TextureAndMiscDirtyCallBack;
  20323. private static readonly _DirtyCallbackArray;
  20324. private static readonly _RunDirtyCallBacks;
  20325. /**
  20326. * Marks a define in the material to indicate that it needs to be re-computed
  20327. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20328. */
  20329. markAsDirty(flag: number): void;
  20330. /**
  20331. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20332. * @param func defines a function which checks material defines against the submeshes
  20333. */
  20334. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20335. /**
  20336. * Indicates that we need to re-calculated for all submeshes
  20337. */
  20338. protected _markAllSubMeshesAsAllDirty(): void;
  20339. /**
  20340. * Indicates that image processing needs to be re-calculated for all submeshes
  20341. */
  20342. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20343. /**
  20344. * Indicates that textures need to be re-calculated for all submeshes
  20345. */
  20346. protected _markAllSubMeshesAsTexturesDirty(): void;
  20347. /**
  20348. * Indicates that fresnel needs to be re-calculated for all submeshes
  20349. */
  20350. protected _markAllSubMeshesAsFresnelDirty(): void;
  20351. /**
  20352. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20353. */
  20354. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20355. /**
  20356. * Indicates that lights need to be re-calculated for all submeshes
  20357. */
  20358. protected _markAllSubMeshesAsLightsDirty(): void;
  20359. /**
  20360. * Indicates that attributes need to be re-calculated for all submeshes
  20361. */
  20362. protected _markAllSubMeshesAsAttributesDirty(): void;
  20363. /**
  20364. * Indicates that misc needs to be re-calculated for all submeshes
  20365. */
  20366. protected _markAllSubMeshesAsMiscDirty(): void;
  20367. /**
  20368. * Indicates that textures and misc need to be re-calculated for all submeshes
  20369. */
  20370. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20371. /**
  20372. * Disposes the material
  20373. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20374. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20375. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20376. */
  20377. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20378. /** @hidden */
  20379. private releaseVertexArrayObject;
  20380. /**
  20381. * Serializes this material
  20382. * @returns the serialized material object
  20383. */
  20384. serialize(): any;
  20385. /**
  20386. * Creates a material from parsed material data
  20387. * @param parsedMaterial defines parsed material data
  20388. * @param scene defines the hosting scene
  20389. * @param rootUrl defines the root URL to use to load textures
  20390. * @returns a new material
  20391. */
  20392. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20393. }
  20394. }
  20395. declare module BABYLON {
  20396. /**
  20397. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20398. * separate meshes. This can be use to improve performances.
  20399. * @see http://doc.babylonjs.com/how_to/multi_materials
  20400. */
  20401. export class MultiMaterial extends Material {
  20402. private _subMaterials;
  20403. /**
  20404. * Gets or Sets the list of Materials used within the multi material.
  20405. * They need to be ordered according to the submeshes order in the associated mesh
  20406. */
  20407. subMaterials: Nullable<Material>[];
  20408. /**
  20409. * Function used to align with Node.getChildren()
  20410. * @returns the list of Materials used within the multi material
  20411. */
  20412. getChildren(): Nullable<Material>[];
  20413. /**
  20414. * Instantiates a new Multi Material
  20415. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20416. * separate meshes. This can be use to improve performances.
  20417. * @see http://doc.babylonjs.com/how_to/multi_materials
  20418. * @param name Define the name in the scene
  20419. * @param scene Define the scene the material belongs to
  20420. */
  20421. constructor(name: string, scene: Scene);
  20422. private _hookArray;
  20423. /**
  20424. * Get one of the submaterial by its index in the submaterials array
  20425. * @param index The index to look the sub material at
  20426. * @returns The Material if the index has been defined
  20427. */
  20428. getSubMaterial(index: number): Nullable<Material>;
  20429. /**
  20430. * Get the list of active textures for the whole sub materials list.
  20431. * @returns All the textures that will be used during the rendering
  20432. */
  20433. getActiveTextures(): BaseTexture[];
  20434. /**
  20435. * Gets the current class name of the material e.g. "MultiMaterial"
  20436. * Mainly use in serialization.
  20437. * @returns the class name
  20438. */
  20439. getClassName(): string;
  20440. /**
  20441. * Checks if the material is ready to render the requested sub mesh
  20442. * @param mesh Define the mesh the submesh belongs to
  20443. * @param subMesh Define the sub mesh to look readyness for
  20444. * @param useInstances Define whether or not the material is used with instances
  20445. * @returns true if ready, otherwise false
  20446. */
  20447. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20448. /**
  20449. * Clones the current material and its related sub materials
  20450. * @param name Define the name of the newly cloned material
  20451. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20452. * @returns the cloned material
  20453. */
  20454. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20455. /**
  20456. * Serializes the materials into a JSON representation.
  20457. * @returns the JSON representation
  20458. */
  20459. serialize(): any;
  20460. /**
  20461. * Dispose the material and release its associated resources
  20462. * @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)
  20463. * @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)
  20464. * @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)
  20465. */
  20466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20467. /**
  20468. * Creates a MultiMaterial from parsed MultiMaterial data.
  20469. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20470. * @param scene defines the hosting scene
  20471. * @returns a new MultiMaterial
  20472. */
  20473. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20474. }
  20475. }
  20476. declare module BABYLON {
  20477. /**
  20478. * Base class for submeshes
  20479. */
  20480. export class BaseSubMesh {
  20481. /** @hidden */
  20482. _materialDefines: Nullable<MaterialDefines>;
  20483. /** @hidden */
  20484. _materialEffect: Nullable<Effect>;
  20485. /**
  20486. * Gets associated effect
  20487. */
  20488. readonly effect: Nullable<Effect>;
  20489. /**
  20490. * Sets associated effect (effect used to render this submesh)
  20491. * @param effect defines the effect to associate with
  20492. * @param defines defines the set of defines used to compile this effect
  20493. */
  20494. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20495. }
  20496. /**
  20497. * Defines a subdivision inside a mesh
  20498. */
  20499. export class SubMesh extends BaseSubMesh implements ICullable {
  20500. /** the material index to use */
  20501. materialIndex: number;
  20502. /** vertex index start */
  20503. verticesStart: number;
  20504. /** vertices count */
  20505. verticesCount: number;
  20506. /** index start */
  20507. indexStart: number;
  20508. /** indices count */
  20509. indexCount: number;
  20510. /** @hidden */
  20511. _linesIndexCount: number;
  20512. private _mesh;
  20513. private _renderingMesh;
  20514. private _boundingInfo;
  20515. private _linesIndexBuffer;
  20516. /** @hidden */
  20517. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20518. /** @hidden */
  20519. _trianglePlanes: Plane[];
  20520. /** @hidden */
  20521. _lastColliderTransformMatrix: Nullable<Matrix>;
  20522. /** @hidden */
  20523. _renderId: number;
  20524. /** @hidden */
  20525. _alphaIndex: number;
  20526. /** @hidden */
  20527. _distanceToCamera: number;
  20528. /** @hidden */
  20529. _id: number;
  20530. private _currentMaterial;
  20531. /**
  20532. * Add a new submesh to a mesh
  20533. * @param materialIndex defines the material index to use
  20534. * @param verticesStart defines vertex index start
  20535. * @param verticesCount defines vertices count
  20536. * @param indexStart defines index start
  20537. * @param indexCount defines indices count
  20538. * @param mesh defines the parent mesh
  20539. * @param renderingMesh defines an optional rendering mesh
  20540. * @param createBoundingBox defines if bounding box should be created for this submesh
  20541. * @returns the new submesh
  20542. */
  20543. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20544. /**
  20545. * Creates a new submesh
  20546. * @param materialIndex defines the material index to use
  20547. * @param verticesStart defines vertex index start
  20548. * @param verticesCount defines vertices count
  20549. * @param indexStart defines index start
  20550. * @param indexCount defines indices count
  20551. * @param mesh defines the parent mesh
  20552. * @param renderingMesh defines an optional rendering mesh
  20553. * @param createBoundingBox defines if bounding box should be created for this submesh
  20554. */
  20555. constructor(
  20556. /** the material index to use */
  20557. materialIndex: number,
  20558. /** vertex index start */
  20559. verticesStart: number,
  20560. /** vertices count */
  20561. verticesCount: number,
  20562. /** index start */
  20563. indexStart: number,
  20564. /** indices count */
  20565. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20566. /**
  20567. * Returns true if this submesh covers the entire parent mesh
  20568. * @ignorenaming
  20569. */
  20570. readonly IsGlobal: boolean;
  20571. /**
  20572. * Returns the submesh BoudingInfo object
  20573. * @returns current bounding info (or mesh's one if the submesh is global)
  20574. */
  20575. getBoundingInfo(): BoundingInfo;
  20576. /**
  20577. * Sets the submesh BoundingInfo
  20578. * @param boundingInfo defines the new bounding info to use
  20579. * @returns the SubMesh
  20580. */
  20581. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20582. /**
  20583. * Returns the mesh of the current submesh
  20584. * @return the parent mesh
  20585. */
  20586. getMesh(): AbstractMesh;
  20587. /**
  20588. * Returns the rendering mesh of the submesh
  20589. * @returns the rendering mesh (could be different from parent mesh)
  20590. */
  20591. getRenderingMesh(): Mesh;
  20592. /**
  20593. * Returns the submesh material
  20594. * @returns null or the current material
  20595. */
  20596. getMaterial(): Nullable<Material>;
  20597. /**
  20598. * Sets a new updated BoundingInfo object to the submesh
  20599. * @param data defines an optional position array to use to determine the bounding info
  20600. * @returns the SubMesh
  20601. */
  20602. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20603. /** @hidden */
  20604. _checkCollision(collider: Collider): boolean;
  20605. /**
  20606. * Updates the submesh BoundingInfo
  20607. * @param world defines the world matrix to use to update the bounding info
  20608. * @returns the submesh
  20609. */
  20610. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20611. /**
  20612. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20613. * @param frustumPlanes defines the frustum planes
  20614. * @returns true if the submesh is intersecting with the frustum
  20615. */
  20616. isInFrustum(frustumPlanes: Plane[]): boolean;
  20617. /**
  20618. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20619. * @param frustumPlanes defines the frustum planes
  20620. * @returns true if the submesh is inside the frustum
  20621. */
  20622. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20623. /**
  20624. * Renders the submesh
  20625. * @param enableAlphaMode defines if alpha needs to be used
  20626. * @returns the submesh
  20627. */
  20628. render(enableAlphaMode: boolean): SubMesh;
  20629. /**
  20630. * @hidden
  20631. */
  20632. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20633. /**
  20634. * Checks if the submesh intersects with a ray
  20635. * @param ray defines the ray to test
  20636. * @returns true is the passed ray intersects the submesh bounding box
  20637. */
  20638. canIntersects(ray: Ray): boolean;
  20639. /**
  20640. * Intersects current submesh with a ray
  20641. * @param ray defines the ray to test
  20642. * @param positions defines mesh's positions array
  20643. * @param indices defines mesh's indices array
  20644. * @param fastCheck defines if only bounding info should be used
  20645. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20646. * @returns intersection info or null if no intersection
  20647. */
  20648. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20649. /** @hidden */
  20650. private _intersectLines;
  20651. /** @hidden */
  20652. private _intersectUnIndexedLines;
  20653. /** @hidden */
  20654. private _intersectTriangles;
  20655. /** @hidden */
  20656. private _intersectUnIndexedTriangles;
  20657. /** @hidden */
  20658. _rebuild(): void;
  20659. /**
  20660. * Creates a new submesh from the passed mesh
  20661. * @param newMesh defines the new hosting mesh
  20662. * @param newRenderingMesh defines an optional rendering mesh
  20663. * @returns the new submesh
  20664. */
  20665. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20666. /**
  20667. * Release associated resources
  20668. */
  20669. dispose(): void;
  20670. /**
  20671. * Gets the class name
  20672. * @returns the string "SubMesh".
  20673. */
  20674. getClassName(): string;
  20675. /**
  20676. * Creates a new submesh from indices data
  20677. * @param materialIndex the index of the main mesh material
  20678. * @param startIndex the index where to start the copy in the mesh indices array
  20679. * @param indexCount the number of indices to copy then from the startIndex
  20680. * @param mesh the main mesh to create the submesh from
  20681. * @param renderingMesh the optional rendering mesh
  20682. * @returns a new submesh
  20683. */
  20684. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20685. }
  20686. }
  20687. declare module BABYLON {
  20688. /**
  20689. * Class used to represent data loading progression
  20690. */
  20691. export class SceneLoaderFlags {
  20692. private static _ForceFullSceneLoadingForIncremental;
  20693. private static _ShowLoadingScreen;
  20694. private static _CleanBoneMatrixWeights;
  20695. private static _loggingLevel;
  20696. /**
  20697. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20698. */
  20699. static ForceFullSceneLoadingForIncremental: boolean;
  20700. /**
  20701. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20702. */
  20703. static ShowLoadingScreen: boolean;
  20704. /**
  20705. * Defines the current logging level (while loading the scene)
  20706. * @ignorenaming
  20707. */
  20708. static loggingLevel: number;
  20709. /**
  20710. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20711. */
  20712. static CleanBoneMatrixWeights: boolean;
  20713. }
  20714. }
  20715. declare module BABYLON {
  20716. /**
  20717. * Class used to store geometry data (vertex buffers + index buffer)
  20718. */
  20719. export class Geometry implements IGetSetVerticesData {
  20720. /**
  20721. * Gets or sets the ID of the geometry
  20722. */
  20723. id: string;
  20724. /**
  20725. * Gets or sets the unique ID of the geometry
  20726. */
  20727. uniqueId: number;
  20728. /**
  20729. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20730. */
  20731. delayLoadState: number;
  20732. /**
  20733. * Gets the file containing the data to load when running in delay load state
  20734. */
  20735. delayLoadingFile: Nullable<string>;
  20736. /**
  20737. * Callback called when the geometry is updated
  20738. */
  20739. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20740. private _scene;
  20741. private _engine;
  20742. private _meshes;
  20743. private _totalVertices;
  20744. /** @hidden */
  20745. _indices: IndicesArray;
  20746. /** @hidden */
  20747. _vertexBuffers: {
  20748. [key: string]: VertexBuffer;
  20749. };
  20750. private _isDisposed;
  20751. private _extend;
  20752. private _boundingBias;
  20753. /** @hidden */
  20754. _delayInfo: Array<string>;
  20755. private _indexBuffer;
  20756. private _indexBufferIsUpdatable;
  20757. /** @hidden */
  20758. _boundingInfo: Nullable<BoundingInfo>;
  20759. /** @hidden */
  20760. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20761. /** @hidden */
  20762. _softwareSkinningFrameId: number;
  20763. private _vertexArrayObjects;
  20764. private _updatable;
  20765. /** @hidden */
  20766. _positions: Nullable<Vector3[]>;
  20767. /**
  20768. * 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
  20769. */
  20770. /**
  20771. * 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
  20772. */
  20773. boundingBias: Vector2;
  20774. /**
  20775. * Static function used to attach a new empty geometry to a mesh
  20776. * @param mesh defines the mesh to attach the geometry to
  20777. * @returns the new Geometry
  20778. */
  20779. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20780. /**
  20781. * Creates a new geometry
  20782. * @param id defines the unique ID
  20783. * @param scene defines the hosting scene
  20784. * @param vertexData defines the VertexData used to get geometry data
  20785. * @param updatable defines if geometry must be updatable (false by default)
  20786. * @param mesh defines the mesh that will be associated with the geometry
  20787. */
  20788. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20789. /**
  20790. * Gets the current extend of the geometry
  20791. */
  20792. readonly extend: {
  20793. minimum: Vector3;
  20794. maximum: Vector3;
  20795. };
  20796. /**
  20797. * Gets the hosting scene
  20798. * @returns the hosting Scene
  20799. */
  20800. getScene(): Scene;
  20801. /**
  20802. * Gets the hosting engine
  20803. * @returns the hosting Engine
  20804. */
  20805. getEngine(): Engine;
  20806. /**
  20807. * Defines if the geometry is ready to use
  20808. * @returns true if the geometry is ready to be used
  20809. */
  20810. isReady(): boolean;
  20811. /**
  20812. * Gets a value indicating that the geometry should not be serialized
  20813. */
  20814. readonly doNotSerialize: boolean;
  20815. /** @hidden */
  20816. _rebuild(): void;
  20817. /**
  20818. * Affects all geometry data in one call
  20819. * @param vertexData defines the geometry data
  20820. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20821. */
  20822. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20823. /**
  20824. * Set specific vertex data
  20825. * @param kind defines the data kind (Position, normal, etc...)
  20826. * @param data defines the vertex data to use
  20827. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20828. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20829. */
  20830. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20831. /**
  20832. * Removes a specific vertex data
  20833. * @param kind defines the data kind (Position, normal, etc...)
  20834. */
  20835. removeVerticesData(kind: string): void;
  20836. /**
  20837. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20838. * @param buffer defines the vertex buffer to use
  20839. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20840. */
  20841. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20842. /**
  20843. * Update a specific vertex buffer
  20844. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20845. * It will do nothing if the buffer is not updatable
  20846. * @param kind defines the data kind (Position, normal, etc...)
  20847. * @param data defines the data to use
  20848. * @param offset defines the offset in the target buffer where to store the data
  20849. * @param useBytes set to true if the offset is in bytes
  20850. */
  20851. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20852. /**
  20853. * Update a specific vertex buffer
  20854. * This function will create a new buffer if the current one is not updatable
  20855. * @param kind defines the data kind (Position, normal, etc...)
  20856. * @param data defines the data to use
  20857. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20858. */
  20859. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20860. private _updateBoundingInfo;
  20861. /** @hidden */
  20862. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20863. /**
  20864. * Gets total number of vertices
  20865. * @returns the total number of vertices
  20866. */
  20867. getTotalVertices(): number;
  20868. /**
  20869. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20870. * @param kind defines the data kind (Position, normal, etc...)
  20871. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20872. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20873. * @returns a float array containing vertex data
  20874. */
  20875. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20876. /**
  20877. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20878. * @param kind defines the data kind (Position, normal, etc...)
  20879. * @returns true if the vertex buffer with the specified kind is updatable
  20880. */
  20881. isVertexBufferUpdatable(kind: string): boolean;
  20882. /**
  20883. * Gets a specific vertex buffer
  20884. * @param kind defines the data kind (Position, normal, etc...)
  20885. * @returns a VertexBuffer
  20886. */
  20887. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20888. /**
  20889. * Returns all vertex buffers
  20890. * @return an object holding all vertex buffers indexed by kind
  20891. */
  20892. getVertexBuffers(): Nullable<{
  20893. [key: string]: VertexBuffer;
  20894. }>;
  20895. /**
  20896. * Gets a boolean indicating if specific vertex buffer is present
  20897. * @param kind defines the data kind (Position, normal, etc...)
  20898. * @returns true if data is present
  20899. */
  20900. isVerticesDataPresent(kind: string): boolean;
  20901. /**
  20902. * Gets a list of all attached data kinds (Position, normal, etc...)
  20903. * @returns a list of string containing all kinds
  20904. */
  20905. getVerticesDataKinds(): string[];
  20906. /**
  20907. * Update index buffer
  20908. * @param indices defines the indices to store in the index buffer
  20909. * @param offset defines the offset in the target buffer where to store the data
  20910. * @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)
  20911. */
  20912. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20913. /**
  20914. * Creates a new index buffer
  20915. * @param indices defines the indices to store in the index buffer
  20916. * @param totalVertices defines the total number of vertices (could be null)
  20917. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20918. */
  20919. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20920. /**
  20921. * Return the total number of indices
  20922. * @returns the total number of indices
  20923. */
  20924. getTotalIndices(): number;
  20925. /**
  20926. * Gets the index buffer array
  20927. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20928. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20929. * @returns the index buffer array
  20930. */
  20931. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20932. /**
  20933. * Gets the index buffer
  20934. * @return the index buffer
  20935. */
  20936. getIndexBuffer(): Nullable<DataBuffer>;
  20937. /** @hidden */
  20938. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20939. /**
  20940. * Release the associated resources for a specific mesh
  20941. * @param mesh defines the source mesh
  20942. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20943. */
  20944. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20945. /**
  20946. * Apply current geometry to a given mesh
  20947. * @param mesh defines the mesh to apply geometry to
  20948. */
  20949. applyToMesh(mesh: Mesh): void;
  20950. private _updateExtend;
  20951. private _applyToMesh;
  20952. private notifyUpdate;
  20953. /**
  20954. * Load the geometry if it was flagged as delay loaded
  20955. * @param scene defines the hosting scene
  20956. * @param onLoaded defines a callback called when the geometry is loaded
  20957. */
  20958. load(scene: Scene, onLoaded?: () => void): void;
  20959. private _queueLoad;
  20960. /**
  20961. * Invert the geometry to move from a right handed system to a left handed one.
  20962. */
  20963. toLeftHanded(): void;
  20964. /** @hidden */
  20965. _resetPointsArrayCache(): void;
  20966. /** @hidden */
  20967. _generatePointsArray(): boolean;
  20968. /**
  20969. * Gets a value indicating if the geometry is disposed
  20970. * @returns true if the geometry was disposed
  20971. */
  20972. isDisposed(): boolean;
  20973. private _disposeVertexArrayObjects;
  20974. /**
  20975. * Free all associated resources
  20976. */
  20977. dispose(): void;
  20978. /**
  20979. * Clone the current geometry into a new geometry
  20980. * @param id defines the unique ID of the new geometry
  20981. * @returns a new geometry object
  20982. */
  20983. copy(id: string): Geometry;
  20984. /**
  20985. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20986. * @return a JSON representation of the current geometry data (without the vertices data)
  20987. */
  20988. serialize(): any;
  20989. private toNumberArray;
  20990. /**
  20991. * Serialize all vertices data into a JSON oject
  20992. * @returns a JSON representation of the current geometry data
  20993. */
  20994. serializeVerticeData(): any;
  20995. /**
  20996. * Extracts a clone of a mesh geometry
  20997. * @param mesh defines the source mesh
  20998. * @param id defines the unique ID of the new geometry object
  20999. * @returns the new geometry object
  21000. */
  21001. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21002. /**
  21003. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21004. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21005. * Be aware Math.random() could cause collisions, but:
  21006. * "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"
  21007. * @returns a string containing a new GUID
  21008. */
  21009. static RandomId(): string;
  21010. /** @hidden */
  21011. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21012. private static _CleanMatricesWeights;
  21013. /**
  21014. * Create a new geometry from persisted data (Using .babylon file format)
  21015. * @param parsedVertexData defines the persisted data
  21016. * @param scene defines the hosting scene
  21017. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21018. * @returns the new geometry object
  21019. */
  21020. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21021. }
  21022. }
  21023. declare module BABYLON {
  21024. /**
  21025. * Define an interface for all classes that will get and set the data on vertices
  21026. */
  21027. export interface IGetSetVerticesData {
  21028. /**
  21029. * Gets a boolean indicating if specific vertex data is present
  21030. * @param kind defines the vertex data kind to use
  21031. * @returns true is data kind is present
  21032. */
  21033. isVerticesDataPresent(kind: string): boolean;
  21034. /**
  21035. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21036. * @param kind defines the data kind (Position, normal, etc...)
  21037. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21038. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21039. * @returns a float array containing vertex data
  21040. */
  21041. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21042. /**
  21043. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21044. * @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.
  21045. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21046. * @returns the indices array or an empty array if the mesh has no geometry
  21047. */
  21048. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21049. /**
  21050. * Set specific vertex data
  21051. * @param kind defines the data kind (Position, normal, etc...)
  21052. * @param data defines the vertex data to use
  21053. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21054. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21055. */
  21056. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21057. /**
  21058. * Update a specific associated vertex buffer
  21059. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21060. * - VertexBuffer.PositionKind
  21061. * - VertexBuffer.UVKind
  21062. * - VertexBuffer.UV2Kind
  21063. * - VertexBuffer.UV3Kind
  21064. * - VertexBuffer.UV4Kind
  21065. * - VertexBuffer.UV5Kind
  21066. * - VertexBuffer.UV6Kind
  21067. * - VertexBuffer.ColorKind
  21068. * - VertexBuffer.MatricesIndicesKind
  21069. * - VertexBuffer.MatricesIndicesExtraKind
  21070. * - VertexBuffer.MatricesWeightsKind
  21071. * - VertexBuffer.MatricesWeightsExtraKind
  21072. * @param data defines the data source
  21073. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21074. * @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)
  21075. */
  21076. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21077. /**
  21078. * Creates a new index buffer
  21079. * @param indices defines the indices to store in the index buffer
  21080. * @param totalVertices defines the total number of vertices (could be null)
  21081. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21082. */
  21083. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21084. }
  21085. /**
  21086. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21087. */
  21088. export class VertexData {
  21089. /**
  21090. * Mesh side orientation : usually the external or front surface
  21091. */
  21092. static readonly FRONTSIDE: number;
  21093. /**
  21094. * Mesh side orientation : usually the internal or back surface
  21095. */
  21096. static readonly BACKSIDE: number;
  21097. /**
  21098. * Mesh side orientation : both internal and external or front and back surfaces
  21099. */
  21100. static readonly DOUBLESIDE: number;
  21101. /**
  21102. * Mesh side orientation : by default, `FRONTSIDE`
  21103. */
  21104. static readonly DEFAULTSIDE: number;
  21105. /**
  21106. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21107. */
  21108. positions: Nullable<FloatArray>;
  21109. /**
  21110. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21111. */
  21112. normals: Nullable<FloatArray>;
  21113. /**
  21114. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21115. */
  21116. tangents: Nullable<FloatArray>;
  21117. /**
  21118. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21119. */
  21120. uvs: Nullable<FloatArray>;
  21121. /**
  21122. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21123. */
  21124. uvs2: Nullable<FloatArray>;
  21125. /**
  21126. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21127. */
  21128. uvs3: Nullable<FloatArray>;
  21129. /**
  21130. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21131. */
  21132. uvs4: Nullable<FloatArray>;
  21133. /**
  21134. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21135. */
  21136. uvs5: Nullable<FloatArray>;
  21137. /**
  21138. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21139. */
  21140. uvs6: Nullable<FloatArray>;
  21141. /**
  21142. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21143. */
  21144. colors: Nullable<FloatArray>;
  21145. /**
  21146. * 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).
  21147. */
  21148. matricesIndices: Nullable<FloatArray>;
  21149. /**
  21150. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21151. */
  21152. matricesWeights: Nullable<FloatArray>;
  21153. /**
  21154. * An array extending the number of possible indices
  21155. */
  21156. matricesIndicesExtra: Nullable<FloatArray>;
  21157. /**
  21158. * An array extending the number of possible weights when the number of indices is extended
  21159. */
  21160. matricesWeightsExtra: Nullable<FloatArray>;
  21161. /**
  21162. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21163. */
  21164. indices: Nullable<IndicesArray>;
  21165. /**
  21166. * Uses the passed data array to set the set the values for the specified kind of data
  21167. * @param data a linear array of floating numbers
  21168. * @param kind the type of data that is being set, eg positions, colors etc
  21169. */
  21170. set(data: FloatArray, kind: string): void;
  21171. /**
  21172. * Associates the vertexData to the passed Mesh.
  21173. * Sets it as updatable or not (default `false`)
  21174. * @param mesh the mesh the vertexData is applied to
  21175. * @param updatable when used and having the value true allows new data to update the vertexData
  21176. * @returns the VertexData
  21177. */
  21178. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21179. /**
  21180. * Associates the vertexData to the passed Geometry.
  21181. * Sets it as updatable or not (default `false`)
  21182. * @param geometry the geometry the vertexData is applied to
  21183. * @param updatable when used and having the value true allows new data to update the vertexData
  21184. * @returns VertexData
  21185. */
  21186. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21187. /**
  21188. * Updates the associated mesh
  21189. * @param mesh the mesh to be updated
  21190. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21191. * @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
  21192. * @returns VertexData
  21193. */
  21194. updateMesh(mesh: Mesh): VertexData;
  21195. /**
  21196. * Updates the associated geometry
  21197. * @param geometry the geometry to be updated
  21198. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21199. * @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
  21200. * @returns VertexData.
  21201. */
  21202. updateGeometry(geometry: Geometry): VertexData;
  21203. private _applyTo;
  21204. private _update;
  21205. /**
  21206. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21207. * @param matrix the transforming matrix
  21208. * @returns the VertexData
  21209. */
  21210. transform(matrix: Matrix): VertexData;
  21211. /**
  21212. * Merges the passed VertexData into the current one
  21213. * @param other the VertexData to be merged into the current one
  21214. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21215. * @returns the modified VertexData
  21216. */
  21217. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21218. private _mergeElement;
  21219. private _validate;
  21220. /**
  21221. * Serializes the VertexData
  21222. * @returns a serialized object
  21223. */
  21224. serialize(): any;
  21225. /**
  21226. * Extracts the vertexData from a mesh
  21227. * @param mesh the mesh from which to extract the VertexData
  21228. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21229. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21230. * @returns the object VertexData associated to the passed mesh
  21231. */
  21232. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21233. /**
  21234. * Extracts the vertexData from the geometry
  21235. * @param geometry the geometry from which to extract the VertexData
  21236. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21237. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21238. * @returns the object VertexData associated to the passed mesh
  21239. */
  21240. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21241. private static _ExtractFrom;
  21242. /**
  21243. * Creates the VertexData for a Ribbon
  21244. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21245. * * pathArray array of paths, each of which an array of successive Vector3
  21246. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21247. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21248. * * 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
  21249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21250. * * 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)
  21251. * * 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)
  21252. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21253. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21254. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21255. * @returns the VertexData of the ribbon
  21256. */
  21257. static CreateRibbon(options: {
  21258. pathArray: Vector3[][];
  21259. closeArray?: boolean;
  21260. closePath?: boolean;
  21261. offset?: number;
  21262. sideOrientation?: number;
  21263. frontUVs?: Vector4;
  21264. backUVs?: Vector4;
  21265. invertUV?: boolean;
  21266. uvs?: Vector2[];
  21267. colors?: Color4[];
  21268. }): VertexData;
  21269. /**
  21270. * Creates the VertexData for a box
  21271. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21272. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21273. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21274. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21275. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21276. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21277. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21279. * * 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)
  21280. * * 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)
  21281. * @returns the VertexData of the box
  21282. */
  21283. static CreateBox(options: {
  21284. size?: number;
  21285. width?: number;
  21286. height?: number;
  21287. depth?: number;
  21288. faceUV?: Vector4[];
  21289. faceColors?: Color4[];
  21290. sideOrientation?: number;
  21291. frontUVs?: Vector4;
  21292. backUVs?: Vector4;
  21293. }): VertexData;
  21294. /**
  21295. * Creates the VertexData for a tiled box
  21296. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21297. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21298. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21299. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21300. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21301. * @returns the VertexData of the box
  21302. */
  21303. static CreateTiledBox(options: {
  21304. pattern?: number;
  21305. width?: number;
  21306. height?: number;
  21307. depth?: number;
  21308. tileSize?: number;
  21309. tileWidth?: number;
  21310. tileHeight?: number;
  21311. alignHorizontal?: number;
  21312. alignVertical?: number;
  21313. faceUV?: Vector4[];
  21314. faceColors?: Color4[];
  21315. sideOrientation?: number;
  21316. }): VertexData;
  21317. /**
  21318. * Creates the VertexData for a tiled plane
  21319. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21320. * * pattern a limited pattern arrangement depending on the number
  21321. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21322. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21323. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21325. * * 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)
  21326. * * 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)
  21327. * @returns the VertexData of the tiled plane
  21328. */
  21329. static CreateTiledPlane(options: {
  21330. pattern?: number;
  21331. tileSize?: number;
  21332. tileWidth?: number;
  21333. tileHeight?: number;
  21334. size?: number;
  21335. width?: number;
  21336. height?: number;
  21337. alignHorizontal?: number;
  21338. alignVertical?: number;
  21339. sideOrientation?: number;
  21340. frontUVs?: Vector4;
  21341. backUVs?: Vector4;
  21342. }): VertexData;
  21343. /**
  21344. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21345. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21346. * * segments sets the number of horizontal strips optional, default 32
  21347. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21348. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21349. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21350. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21351. * * 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
  21352. * * 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
  21353. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21354. * * 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)
  21355. * * 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)
  21356. * @returns the VertexData of the ellipsoid
  21357. */
  21358. static CreateSphere(options: {
  21359. segments?: number;
  21360. diameter?: number;
  21361. diameterX?: number;
  21362. diameterY?: number;
  21363. diameterZ?: number;
  21364. arc?: number;
  21365. slice?: number;
  21366. sideOrientation?: number;
  21367. frontUVs?: Vector4;
  21368. backUVs?: Vector4;
  21369. }): VertexData;
  21370. /**
  21371. * Creates the VertexData for a cylinder, cone or prism
  21372. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21373. * * height sets the height (y direction) of the cylinder, optional, default 2
  21374. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21375. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21376. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21377. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21378. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21379. * * 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
  21380. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21381. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21382. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21383. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21385. * * 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)
  21386. * * 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)
  21387. * @returns the VertexData of the cylinder, cone or prism
  21388. */
  21389. static CreateCylinder(options: {
  21390. height?: number;
  21391. diameterTop?: number;
  21392. diameterBottom?: number;
  21393. diameter?: number;
  21394. tessellation?: number;
  21395. subdivisions?: number;
  21396. arc?: number;
  21397. faceColors?: Color4[];
  21398. faceUV?: Vector4[];
  21399. hasRings?: boolean;
  21400. enclose?: boolean;
  21401. sideOrientation?: number;
  21402. frontUVs?: Vector4;
  21403. backUVs?: Vector4;
  21404. }): VertexData;
  21405. /**
  21406. * Creates the VertexData for a torus
  21407. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21408. * * diameter the diameter of the torus, optional default 1
  21409. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21410. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21412. * * 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)
  21413. * * 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)
  21414. * @returns the VertexData of the torus
  21415. */
  21416. static CreateTorus(options: {
  21417. diameter?: number;
  21418. thickness?: number;
  21419. tessellation?: number;
  21420. sideOrientation?: number;
  21421. frontUVs?: Vector4;
  21422. backUVs?: Vector4;
  21423. }): VertexData;
  21424. /**
  21425. * Creates the VertexData of the LineSystem
  21426. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21427. * - lines an array of lines, each line being an array of successive Vector3
  21428. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21429. * @returns the VertexData of the LineSystem
  21430. */
  21431. static CreateLineSystem(options: {
  21432. lines: Vector3[][];
  21433. colors?: Nullable<Color4[][]>;
  21434. }): VertexData;
  21435. /**
  21436. * Create the VertexData for a DashedLines
  21437. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21438. * - points an array successive Vector3
  21439. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21440. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21441. * - dashNb the intended total number of dashes, optional, default 200
  21442. * @returns the VertexData for the DashedLines
  21443. */
  21444. static CreateDashedLines(options: {
  21445. points: Vector3[];
  21446. dashSize?: number;
  21447. gapSize?: number;
  21448. dashNb?: number;
  21449. }): VertexData;
  21450. /**
  21451. * Creates the VertexData for a Ground
  21452. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21453. * - width the width (x direction) of the ground, optional, default 1
  21454. * - height the height (z direction) of the ground, optional, default 1
  21455. * - subdivisions the number of subdivisions per side, optional, default 1
  21456. * @returns the VertexData of the Ground
  21457. */
  21458. static CreateGround(options: {
  21459. width?: number;
  21460. height?: number;
  21461. subdivisions?: number;
  21462. subdivisionsX?: number;
  21463. subdivisionsY?: number;
  21464. }): VertexData;
  21465. /**
  21466. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21467. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21468. * * xmin the ground minimum X coordinate, optional, default -1
  21469. * * zmin the ground minimum Z coordinate, optional, default -1
  21470. * * xmax the ground maximum X coordinate, optional, default 1
  21471. * * zmax the ground maximum Z coordinate, optional, default 1
  21472. * * 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}
  21473. * * 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}
  21474. * @returns the VertexData of the TiledGround
  21475. */
  21476. static CreateTiledGround(options: {
  21477. xmin: number;
  21478. zmin: number;
  21479. xmax: number;
  21480. zmax: number;
  21481. subdivisions?: {
  21482. w: number;
  21483. h: number;
  21484. };
  21485. precision?: {
  21486. w: number;
  21487. h: number;
  21488. };
  21489. }): VertexData;
  21490. /**
  21491. * Creates the VertexData of the Ground designed from a heightmap
  21492. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21493. * * width the width (x direction) of the ground
  21494. * * height the height (z direction) of the ground
  21495. * * subdivisions the number of subdivisions per side
  21496. * * minHeight the minimum altitude on the ground, optional, default 0
  21497. * * maxHeight the maximum altitude on the ground, optional default 1
  21498. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21499. * * buffer the array holding the image color data
  21500. * * bufferWidth the width of image
  21501. * * bufferHeight the height of image
  21502. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21503. * @returns the VertexData of the Ground designed from a heightmap
  21504. */
  21505. static CreateGroundFromHeightMap(options: {
  21506. width: number;
  21507. height: number;
  21508. subdivisions: number;
  21509. minHeight: number;
  21510. maxHeight: number;
  21511. colorFilter: Color3;
  21512. buffer: Uint8Array;
  21513. bufferWidth: number;
  21514. bufferHeight: number;
  21515. alphaFilter: number;
  21516. }): VertexData;
  21517. /**
  21518. * Creates the VertexData for a Plane
  21519. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21520. * * size sets the width and height of the plane to the value of size, optional default 1
  21521. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21522. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21523. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21524. * * 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)
  21525. * * 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)
  21526. * @returns the VertexData of the box
  21527. */
  21528. static CreatePlane(options: {
  21529. size?: number;
  21530. width?: number;
  21531. height?: number;
  21532. sideOrientation?: number;
  21533. frontUVs?: Vector4;
  21534. backUVs?: Vector4;
  21535. }): VertexData;
  21536. /**
  21537. * Creates the VertexData of the Disc or regular Polygon
  21538. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21539. * * radius the radius of the disc, optional default 0.5
  21540. * * tessellation the number of polygon sides, optional, default 64
  21541. * * 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
  21542. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21543. * * 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)
  21544. * * 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)
  21545. * @returns the VertexData of the box
  21546. */
  21547. static CreateDisc(options: {
  21548. radius?: number;
  21549. tessellation?: number;
  21550. arc?: number;
  21551. sideOrientation?: number;
  21552. frontUVs?: Vector4;
  21553. backUVs?: Vector4;
  21554. }): VertexData;
  21555. /**
  21556. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21557. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21558. * @param polygon a mesh built from polygonTriangulation.build()
  21559. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21560. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21561. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21562. * @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)
  21563. * @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)
  21564. * @returns the VertexData of the Polygon
  21565. */
  21566. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21567. /**
  21568. * Creates the VertexData of the IcoSphere
  21569. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21570. * * radius the radius of the IcoSphere, optional default 1
  21571. * * radiusX allows stretching in the x direction, optional, default radius
  21572. * * radiusY allows stretching in the y direction, optional, default radius
  21573. * * radiusZ allows stretching in the z direction, optional, default radius
  21574. * * flat when true creates a flat shaded mesh, optional, default true
  21575. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21576. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21577. * * 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)
  21578. * * 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)
  21579. * @returns the VertexData of the IcoSphere
  21580. */
  21581. static CreateIcoSphere(options: {
  21582. radius?: number;
  21583. radiusX?: number;
  21584. radiusY?: number;
  21585. radiusZ?: number;
  21586. flat?: boolean;
  21587. subdivisions?: number;
  21588. sideOrientation?: number;
  21589. frontUVs?: Vector4;
  21590. backUVs?: Vector4;
  21591. }): VertexData;
  21592. /**
  21593. * Creates the VertexData for a Polyhedron
  21594. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21595. * * type provided types are:
  21596. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21597. * * 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)
  21598. * * size the size of the IcoSphere, optional default 1
  21599. * * sizeX allows stretching in the x direction, optional, default size
  21600. * * sizeY allows stretching in the y direction, optional, default size
  21601. * * sizeZ allows stretching in the z direction, optional, default size
  21602. * * 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
  21603. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21604. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21605. * * flat when true creates a flat shaded mesh, optional, default true
  21606. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21607. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21608. * * 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)
  21609. * * 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)
  21610. * @returns the VertexData of the Polyhedron
  21611. */
  21612. static CreatePolyhedron(options: {
  21613. type?: number;
  21614. size?: number;
  21615. sizeX?: number;
  21616. sizeY?: number;
  21617. sizeZ?: number;
  21618. custom?: any;
  21619. faceUV?: Vector4[];
  21620. faceColors?: Color4[];
  21621. flat?: boolean;
  21622. sideOrientation?: number;
  21623. frontUVs?: Vector4;
  21624. backUVs?: Vector4;
  21625. }): VertexData;
  21626. /**
  21627. * Creates the VertexData for a TorusKnot
  21628. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21629. * * radius the radius of the torus knot, optional, default 2
  21630. * * tube the thickness of the tube, optional, default 0.5
  21631. * * radialSegments the number of sides on each tube segments, optional, default 32
  21632. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21633. * * p the number of windings around the z axis, optional, default 2
  21634. * * q the number of windings around the x axis, optional, default 3
  21635. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21636. * * 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)
  21637. * * 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)
  21638. * @returns the VertexData of the Torus Knot
  21639. */
  21640. static CreateTorusKnot(options: {
  21641. radius?: number;
  21642. tube?: number;
  21643. radialSegments?: number;
  21644. tubularSegments?: number;
  21645. p?: number;
  21646. q?: number;
  21647. sideOrientation?: number;
  21648. frontUVs?: Vector4;
  21649. backUVs?: Vector4;
  21650. }): VertexData;
  21651. /**
  21652. * Compute normals for given positions and indices
  21653. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21654. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21655. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21656. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21657. * * facetNormals : optional array of facet normals (vector3)
  21658. * * facetPositions : optional array of facet positions (vector3)
  21659. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21660. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21661. * * bInfo : optional bounding info, required for facetPartitioning computation
  21662. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21663. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21664. * * useRightHandedSystem: optional boolean to for right handed system computation
  21665. * * depthSort : optional boolean to enable the facet depth sort computation
  21666. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21667. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21668. */
  21669. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21670. facetNormals?: any;
  21671. facetPositions?: any;
  21672. facetPartitioning?: any;
  21673. ratio?: number;
  21674. bInfo?: any;
  21675. bbSize?: Vector3;
  21676. subDiv?: any;
  21677. useRightHandedSystem?: boolean;
  21678. depthSort?: boolean;
  21679. distanceTo?: Vector3;
  21680. depthSortedFacets?: any;
  21681. }): void;
  21682. /** @hidden */
  21683. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21684. /**
  21685. * Applies VertexData created from the imported parameters to the geometry
  21686. * @param parsedVertexData the parsed data from an imported file
  21687. * @param geometry the geometry to apply the VertexData to
  21688. */
  21689. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21690. }
  21691. }
  21692. declare module BABYLON {
  21693. /**
  21694. * Defines a target to use with MorphTargetManager
  21695. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21696. */
  21697. export class MorphTarget implements IAnimatable {
  21698. /** defines the name of the target */
  21699. name: string;
  21700. /**
  21701. * Gets or sets the list of animations
  21702. */
  21703. animations: Animation[];
  21704. private _scene;
  21705. private _positions;
  21706. private _normals;
  21707. private _tangents;
  21708. private _uvs;
  21709. private _influence;
  21710. /**
  21711. * Observable raised when the influence changes
  21712. */
  21713. onInfluenceChanged: Observable<boolean>;
  21714. /** @hidden */
  21715. _onDataLayoutChanged: Observable<void>;
  21716. /**
  21717. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21718. */
  21719. influence: number;
  21720. /**
  21721. * Gets or sets the id of the morph Target
  21722. */
  21723. id: string;
  21724. private _animationPropertiesOverride;
  21725. /**
  21726. * Gets or sets the animation properties override
  21727. */
  21728. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21729. /**
  21730. * Creates a new MorphTarget
  21731. * @param name defines the name of the target
  21732. * @param influence defines the influence to use
  21733. * @param scene defines the scene the morphtarget belongs to
  21734. */
  21735. constructor(
  21736. /** defines the name of the target */
  21737. name: string, influence?: number, scene?: Nullable<Scene>);
  21738. /**
  21739. * Gets a boolean defining if the target contains position data
  21740. */
  21741. readonly hasPositions: boolean;
  21742. /**
  21743. * Gets a boolean defining if the target contains normal data
  21744. */
  21745. readonly hasNormals: boolean;
  21746. /**
  21747. * Gets a boolean defining if the target contains tangent data
  21748. */
  21749. readonly hasTangents: boolean;
  21750. /**
  21751. * Gets a boolean defining if the target contains texture coordinates data
  21752. */
  21753. readonly hasUVs: boolean;
  21754. /**
  21755. * Affects position data to this target
  21756. * @param data defines the position data to use
  21757. */
  21758. setPositions(data: Nullable<FloatArray>): void;
  21759. /**
  21760. * Gets the position data stored in this target
  21761. * @returns a FloatArray containing the position data (or null if not present)
  21762. */
  21763. getPositions(): Nullable<FloatArray>;
  21764. /**
  21765. * Affects normal data to this target
  21766. * @param data defines the normal data to use
  21767. */
  21768. setNormals(data: Nullable<FloatArray>): void;
  21769. /**
  21770. * Gets the normal data stored in this target
  21771. * @returns a FloatArray containing the normal data (or null if not present)
  21772. */
  21773. getNormals(): Nullable<FloatArray>;
  21774. /**
  21775. * Affects tangent data to this target
  21776. * @param data defines the tangent data to use
  21777. */
  21778. setTangents(data: Nullable<FloatArray>): void;
  21779. /**
  21780. * Gets the tangent data stored in this target
  21781. * @returns a FloatArray containing the tangent data (or null if not present)
  21782. */
  21783. getTangents(): Nullable<FloatArray>;
  21784. /**
  21785. * Affects texture coordinates data to this target
  21786. * @param data defines the texture coordinates data to use
  21787. */
  21788. setUVs(data: Nullable<FloatArray>): void;
  21789. /**
  21790. * Gets the texture coordinates data stored in this target
  21791. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21792. */
  21793. getUVs(): Nullable<FloatArray>;
  21794. /**
  21795. * Serializes the current target into a Serialization object
  21796. * @returns the serialized object
  21797. */
  21798. serialize(): any;
  21799. /**
  21800. * Returns the string "MorphTarget"
  21801. * @returns "MorphTarget"
  21802. */
  21803. getClassName(): string;
  21804. /**
  21805. * Creates a new target from serialized data
  21806. * @param serializationObject defines the serialized data to use
  21807. * @returns a new MorphTarget
  21808. */
  21809. static Parse(serializationObject: any): MorphTarget;
  21810. /**
  21811. * Creates a MorphTarget from mesh data
  21812. * @param mesh defines the source mesh
  21813. * @param name defines the name to use for the new target
  21814. * @param influence defines the influence to attach to the target
  21815. * @returns a new MorphTarget
  21816. */
  21817. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21818. }
  21819. }
  21820. declare module BABYLON {
  21821. /**
  21822. * This class is used to deform meshes using morphing between different targets
  21823. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21824. */
  21825. export class MorphTargetManager {
  21826. private _targets;
  21827. private _targetInfluenceChangedObservers;
  21828. private _targetDataLayoutChangedObservers;
  21829. private _activeTargets;
  21830. private _scene;
  21831. private _influences;
  21832. private _supportsNormals;
  21833. private _supportsTangents;
  21834. private _supportsUVs;
  21835. private _vertexCount;
  21836. private _uniqueId;
  21837. private _tempInfluences;
  21838. /**
  21839. * Gets or sets a boolean indicating if normals must be morphed
  21840. */
  21841. enableNormalMorphing: boolean;
  21842. /**
  21843. * Gets or sets a boolean indicating if tangents must be morphed
  21844. */
  21845. enableTangentMorphing: boolean;
  21846. /**
  21847. * Gets or sets a boolean indicating if UV must be morphed
  21848. */
  21849. enableUVMorphing: boolean;
  21850. /**
  21851. * Creates a new MorphTargetManager
  21852. * @param scene defines the current scene
  21853. */
  21854. constructor(scene?: Nullable<Scene>);
  21855. /**
  21856. * Gets the unique ID of this manager
  21857. */
  21858. readonly uniqueId: number;
  21859. /**
  21860. * Gets the number of vertices handled by this manager
  21861. */
  21862. readonly vertexCount: number;
  21863. /**
  21864. * Gets a boolean indicating if this manager supports morphing of normals
  21865. */
  21866. readonly supportsNormals: boolean;
  21867. /**
  21868. * Gets a boolean indicating if this manager supports morphing of tangents
  21869. */
  21870. readonly supportsTangents: boolean;
  21871. /**
  21872. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21873. */
  21874. readonly supportsUVs: boolean;
  21875. /**
  21876. * Gets the number of targets stored in this manager
  21877. */
  21878. readonly numTargets: number;
  21879. /**
  21880. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21881. */
  21882. readonly numInfluencers: number;
  21883. /**
  21884. * Gets the list of influences (one per target)
  21885. */
  21886. readonly influences: Float32Array;
  21887. /**
  21888. * Gets the active target at specified index. An active target is a target with an influence > 0
  21889. * @param index defines the index to check
  21890. * @returns the requested target
  21891. */
  21892. getActiveTarget(index: number): MorphTarget;
  21893. /**
  21894. * Gets the target at specified index
  21895. * @param index defines the index to check
  21896. * @returns the requested target
  21897. */
  21898. getTarget(index: number): MorphTarget;
  21899. /**
  21900. * Add a new target to this manager
  21901. * @param target defines the target to add
  21902. */
  21903. addTarget(target: MorphTarget): void;
  21904. /**
  21905. * Removes a target from the manager
  21906. * @param target defines the target to remove
  21907. */
  21908. removeTarget(target: MorphTarget): void;
  21909. /**
  21910. * Serializes the current manager into a Serialization object
  21911. * @returns the serialized object
  21912. */
  21913. serialize(): any;
  21914. private _syncActiveTargets;
  21915. /**
  21916. * Syncrhonize the targets with all the meshes using this morph target manager
  21917. */
  21918. synchronize(): void;
  21919. /**
  21920. * Creates a new MorphTargetManager from serialized data
  21921. * @param serializationObject defines the serialized data
  21922. * @param scene defines the hosting scene
  21923. * @returns the new MorphTargetManager
  21924. */
  21925. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21926. }
  21927. }
  21928. declare module BABYLON {
  21929. /**
  21930. * Class used to represent a specific level of detail of a mesh
  21931. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21932. */
  21933. export class MeshLODLevel {
  21934. /** Defines the distance where this level should star being displayed */
  21935. distance: number;
  21936. /** Defines the mesh to use to render this level */
  21937. mesh: Nullable<Mesh>;
  21938. /**
  21939. * Creates a new LOD level
  21940. * @param distance defines the distance where this level should star being displayed
  21941. * @param mesh defines the mesh to use to render this level
  21942. */
  21943. constructor(
  21944. /** Defines the distance where this level should star being displayed */
  21945. distance: number,
  21946. /** Defines the mesh to use to render this level */
  21947. mesh: Nullable<Mesh>);
  21948. }
  21949. }
  21950. declare module BABYLON {
  21951. /**
  21952. * Mesh representing the gorund
  21953. */
  21954. export class GroundMesh extends Mesh {
  21955. /** If octree should be generated */
  21956. generateOctree: boolean;
  21957. private _heightQuads;
  21958. /** @hidden */
  21959. _subdivisionsX: number;
  21960. /** @hidden */
  21961. _subdivisionsY: number;
  21962. /** @hidden */
  21963. _width: number;
  21964. /** @hidden */
  21965. _height: number;
  21966. /** @hidden */
  21967. _minX: number;
  21968. /** @hidden */
  21969. _maxX: number;
  21970. /** @hidden */
  21971. _minZ: number;
  21972. /** @hidden */
  21973. _maxZ: number;
  21974. constructor(name: string, scene: Scene);
  21975. /**
  21976. * "GroundMesh"
  21977. * @returns "GroundMesh"
  21978. */
  21979. getClassName(): string;
  21980. /**
  21981. * The minimum of x and y subdivisions
  21982. */
  21983. readonly subdivisions: number;
  21984. /**
  21985. * X subdivisions
  21986. */
  21987. readonly subdivisionsX: number;
  21988. /**
  21989. * Y subdivisions
  21990. */
  21991. readonly subdivisionsY: number;
  21992. /**
  21993. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  21994. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  21995. * @param chunksCount the number of subdivisions for x and y
  21996. * @param octreeBlocksSize (Default: 32)
  21997. */
  21998. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21999. /**
  22000. * Returns a height (y) value in the Worl system :
  22001. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22002. * @param x x coordinate
  22003. * @param z z coordinate
  22004. * @returns the ground y position if (x, z) are outside the ground surface.
  22005. */
  22006. getHeightAtCoordinates(x: number, z: number): number;
  22007. /**
  22008. * Returns a normalized vector (Vector3) orthogonal to the ground
  22009. * at the ground coordinates (x, z) expressed in the World system.
  22010. * @param x x coordinate
  22011. * @param z z coordinate
  22012. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22013. */
  22014. getNormalAtCoordinates(x: number, z: number): Vector3;
  22015. /**
  22016. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22017. * at the ground coordinates (x, z) expressed in the World system.
  22018. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22019. * @param x x coordinate
  22020. * @param z z coordinate
  22021. * @param ref vector to store the result
  22022. * @returns the GroundMesh.
  22023. */
  22024. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22025. /**
  22026. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22027. * if the ground has been updated.
  22028. * This can be used in the render loop.
  22029. * @returns the GroundMesh.
  22030. */
  22031. updateCoordinateHeights(): GroundMesh;
  22032. private _getFacetAt;
  22033. private _initHeightQuads;
  22034. private _computeHeightQuads;
  22035. /**
  22036. * Serializes this ground mesh
  22037. * @param serializationObject object to write serialization to
  22038. */
  22039. serialize(serializationObject: any): void;
  22040. /**
  22041. * Parses a serialized ground mesh
  22042. * @param parsedMesh the serialized mesh
  22043. * @param scene the scene to create the ground mesh in
  22044. * @returns the created ground mesh
  22045. */
  22046. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22047. }
  22048. }
  22049. declare module BABYLON {
  22050. /**
  22051. * Interface for Physics-Joint data
  22052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22053. */
  22054. export interface PhysicsJointData {
  22055. /**
  22056. * The main pivot of the joint
  22057. */
  22058. mainPivot?: Vector3;
  22059. /**
  22060. * The connected pivot of the joint
  22061. */
  22062. connectedPivot?: Vector3;
  22063. /**
  22064. * The main axis of the joint
  22065. */
  22066. mainAxis?: Vector3;
  22067. /**
  22068. * The connected axis of the joint
  22069. */
  22070. connectedAxis?: Vector3;
  22071. /**
  22072. * The collision of the joint
  22073. */
  22074. collision?: boolean;
  22075. /**
  22076. * Native Oimo/Cannon/Energy data
  22077. */
  22078. nativeParams?: any;
  22079. }
  22080. /**
  22081. * This is a holder class for the physics joint created by the physics plugin
  22082. * It holds a set of functions to control the underlying joint
  22083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22084. */
  22085. export class PhysicsJoint {
  22086. /**
  22087. * The type of the physics joint
  22088. */
  22089. type: number;
  22090. /**
  22091. * The data for the physics joint
  22092. */
  22093. jointData: PhysicsJointData;
  22094. private _physicsJoint;
  22095. protected _physicsPlugin: IPhysicsEnginePlugin;
  22096. /**
  22097. * Initializes the physics joint
  22098. * @param type The type of the physics joint
  22099. * @param jointData The data for the physics joint
  22100. */
  22101. constructor(
  22102. /**
  22103. * The type of the physics joint
  22104. */
  22105. type: number,
  22106. /**
  22107. * The data for the physics joint
  22108. */
  22109. jointData: PhysicsJointData);
  22110. /**
  22111. * Gets the physics joint
  22112. */
  22113. /**
  22114. * Sets the physics joint
  22115. */
  22116. physicsJoint: any;
  22117. /**
  22118. * Sets the physics plugin
  22119. */
  22120. physicsPlugin: IPhysicsEnginePlugin;
  22121. /**
  22122. * Execute a function that is physics-plugin specific.
  22123. * @param {Function} func the function that will be executed.
  22124. * It accepts two parameters: the physics world and the physics joint
  22125. */
  22126. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22127. /**
  22128. * Distance-Joint type
  22129. */
  22130. static DistanceJoint: number;
  22131. /**
  22132. * Hinge-Joint type
  22133. */
  22134. static HingeJoint: number;
  22135. /**
  22136. * Ball-and-Socket joint type
  22137. */
  22138. static BallAndSocketJoint: number;
  22139. /**
  22140. * Wheel-Joint type
  22141. */
  22142. static WheelJoint: number;
  22143. /**
  22144. * Slider-Joint type
  22145. */
  22146. static SliderJoint: number;
  22147. /**
  22148. * Prismatic-Joint type
  22149. */
  22150. static PrismaticJoint: number;
  22151. /**
  22152. * Universal-Joint type
  22153. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22154. */
  22155. static UniversalJoint: number;
  22156. /**
  22157. * Hinge-Joint 2 type
  22158. */
  22159. static Hinge2Joint: number;
  22160. /**
  22161. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22162. */
  22163. static PointToPointJoint: number;
  22164. /**
  22165. * Spring-Joint type
  22166. */
  22167. static SpringJoint: number;
  22168. /**
  22169. * Lock-Joint type
  22170. */
  22171. static LockJoint: number;
  22172. }
  22173. /**
  22174. * A class representing a physics distance joint
  22175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22176. */
  22177. export class DistanceJoint extends PhysicsJoint {
  22178. /**
  22179. *
  22180. * @param jointData The data for the Distance-Joint
  22181. */
  22182. constructor(jointData: DistanceJointData);
  22183. /**
  22184. * Update the predefined distance.
  22185. * @param maxDistance The maximum preferred distance
  22186. * @param minDistance The minimum preferred distance
  22187. */
  22188. updateDistance(maxDistance: number, minDistance?: number): void;
  22189. }
  22190. /**
  22191. * Represents a Motor-Enabled Joint
  22192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22193. */
  22194. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22195. /**
  22196. * Initializes the Motor-Enabled Joint
  22197. * @param type The type of the joint
  22198. * @param jointData The physica joint data for the joint
  22199. */
  22200. constructor(type: number, jointData: PhysicsJointData);
  22201. /**
  22202. * Set the motor values.
  22203. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22204. * @param force the force to apply
  22205. * @param maxForce max force for this motor.
  22206. */
  22207. setMotor(force?: number, maxForce?: number): void;
  22208. /**
  22209. * Set the motor's limits.
  22210. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22211. * @param upperLimit The upper limit of the motor
  22212. * @param lowerLimit The lower limit of the motor
  22213. */
  22214. setLimit(upperLimit: number, lowerLimit?: number): void;
  22215. }
  22216. /**
  22217. * This class represents a single physics Hinge-Joint
  22218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22219. */
  22220. export class HingeJoint extends MotorEnabledJoint {
  22221. /**
  22222. * Initializes the Hinge-Joint
  22223. * @param jointData The joint data for the Hinge-Joint
  22224. */
  22225. constructor(jointData: PhysicsJointData);
  22226. /**
  22227. * Set the motor values.
  22228. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22229. * @param {number} force the force to apply
  22230. * @param {number} maxForce max force for this motor.
  22231. */
  22232. setMotor(force?: number, maxForce?: number): void;
  22233. /**
  22234. * Set the motor's limits.
  22235. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22236. * @param upperLimit The upper limit of the motor
  22237. * @param lowerLimit The lower limit of the motor
  22238. */
  22239. setLimit(upperLimit: number, lowerLimit?: number): void;
  22240. }
  22241. /**
  22242. * This class represents a dual hinge physics joint (same as wheel joint)
  22243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22244. */
  22245. export class Hinge2Joint extends MotorEnabledJoint {
  22246. /**
  22247. * Initializes the Hinge2-Joint
  22248. * @param jointData The joint data for the Hinge2-Joint
  22249. */
  22250. constructor(jointData: PhysicsJointData);
  22251. /**
  22252. * Set the motor values.
  22253. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22254. * @param {number} targetSpeed the speed the motor is to reach
  22255. * @param {number} maxForce max force for this motor.
  22256. * @param {motorIndex} the motor's index, 0 or 1.
  22257. */
  22258. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22259. /**
  22260. * Set the motor limits.
  22261. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22262. * @param {number} upperLimit the upper limit
  22263. * @param {number} lowerLimit lower limit
  22264. * @param {motorIndex} the motor's index, 0 or 1.
  22265. */
  22266. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22267. }
  22268. /**
  22269. * Interface for a motor enabled joint
  22270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22271. */
  22272. export interface IMotorEnabledJoint {
  22273. /**
  22274. * Physics joint
  22275. */
  22276. physicsJoint: any;
  22277. /**
  22278. * Sets the motor of the motor-enabled joint
  22279. * @param force The force of the motor
  22280. * @param maxForce The maximum force of the motor
  22281. * @param motorIndex The index of the motor
  22282. */
  22283. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22284. /**
  22285. * Sets the limit of the motor
  22286. * @param upperLimit The upper limit of the motor
  22287. * @param lowerLimit The lower limit of the motor
  22288. * @param motorIndex The index of the motor
  22289. */
  22290. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22291. }
  22292. /**
  22293. * Joint data for a Distance-Joint
  22294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22295. */
  22296. export interface DistanceJointData extends PhysicsJointData {
  22297. /**
  22298. * Max distance the 2 joint objects can be apart
  22299. */
  22300. maxDistance: number;
  22301. }
  22302. /**
  22303. * Joint data from a spring joint
  22304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22305. */
  22306. export interface SpringJointData extends PhysicsJointData {
  22307. /**
  22308. * Length of the spring
  22309. */
  22310. length: number;
  22311. /**
  22312. * Stiffness of the spring
  22313. */
  22314. stiffness: number;
  22315. /**
  22316. * Damping of the spring
  22317. */
  22318. damping: number;
  22319. /** this callback will be called when applying the force to the impostors. */
  22320. forceApplicationCallback: () => void;
  22321. }
  22322. }
  22323. declare module BABYLON {
  22324. /**
  22325. * Holds the data for the raycast result
  22326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22327. */
  22328. export class PhysicsRaycastResult {
  22329. private _hasHit;
  22330. private _hitDistance;
  22331. private _hitNormalWorld;
  22332. private _hitPointWorld;
  22333. private _rayFromWorld;
  22334. private _rayToWorld;
  22335. /**
  22336. * Gets if there was a hit
  22337. */
  22338. readonly hasHit: boolean;
  22339. /**
  22340. * Gets the distance from the hit
  22341. */
  22342. readonly hitDistance: number;
  22343. /**
  22344. * Gets the hit normal/direction in the world
  22345. */
  22346. readonly hitNormalWorld: Vector3;
  22347. /**
  22348. * Gets the hit point in the world
  22349. */
  22350. readonly hitPointWorld: Vector3;
  22351. /**
  22352. * Gets the ray "start point" of the ray in the world
  22353. */
  22354. readonly rayFromWorld: Vector3;
  22355. /**
  22356. * Gets the ray "end point" of the ray in the world
  22357. */
  22358. readonly rayToWorld: Vector3;
  22359. /**
  22360. * Sets the hit data (normal & point in world space)
  22361. * @param hitNormalWorld defines the normal in world space
  22362. * @param hitPointWorld defines the point in world space
  22363. */
  22364. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22365. /**
  22366. * Sets the distance from the start point to the hit point
  22367. * @param distance
  22368. */
  22369. setHitDistance(distance: number): void;
  22370. /**
  22371. * Calculates the distance manually
  22372. */
  22373. calculateHitDistance(): void;
  22374. /**
  22375. * Resets all the values to default
  22376. * @param from The from point on world space
  22377. * @param to The to point on world space
  22378. */
  22379. reset(from?: Vector3, to?: Vector3): void;
  22380. }
  22381. /**
  22382. * Interface for the size containing width and height
  22383. */
  22384. interface IXYZ {
  22385. /**
  22386. * X
  22387. */
  22388. x: number;
  22389. /**
  22390. * Y
  22391. */
  22392. y: number;
  22393. /**
  22394. * Z
  22395. */
  22396. z: number;
  22397. }
  22398. }
  22399. declare module BABYLON {
  22400. /**
  22401. * Interface used to describe a physics joint
  22402. */
  22403. export interface PhysicsImpostorJoint {
  22404. /** Defines the main impostor to which the joint is linked */
  22405. mainImpostor: PhysicsImpostor;
  22406. /** Defines the impostor that is connected to the main impostor using this joint */
  22407. connectedImpostor: PhysicsImpostor;
  22408. /** Defines the joint itself */
  22409. joint: PhysicsJoint;
  22410. }
  22411. /** @hidden */
  22412. export interface IPhysicsEnginePlugin {
  22413. world: any;
  22414. name: string;
  22415. setGravity(gravity: Vector3): void;
  22416. setTimeStep(timeStep: number): void;
  22417. getTimeStep(): number;
  22418. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22419. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22420. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22421. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22422. removePhysicsBody(impostor: PhysicsImpostor): void;
  22423. generateJoint(joint: PhysicsImpostorJoint): void;
  22424. removeJoint(joint: PhysicsImpostorJoint): void;
  22425. isSupported(): boolean;
  22426. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22427. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22428. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22429. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22430. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22431. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22432. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22433. getBodyMass(impostor: PhysicsImpostor): number;
  22434. getBodyFriction(impostor: PhysicsImpostor): number;
  22435. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22436. getBodyRestitution(impostor: PhysicsImpostor): number;
  22437. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22438. getBodyPressure?(impostor: PhysicsImpostor): number;
  22439. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22440. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22441. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22442. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22443. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22444. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22445. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22446. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22447. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22448. sleepBody(impostor: PhysicsImpostor): void;
  22449. wakeUpBody(impostor: PhysicsImpostor): void;
  22450. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22451. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22452. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22453. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22454. getRadius(impostor: PhysicsImpostor): number;
  22455. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22456. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22457. dispose(): void;
  22458. }
  22459. /**
  22460. * Interface used to define a physics engine
  22461. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22462. */
  22463. export interface IPhysicsEngine {
  22464. /**
  22465. * Gets the gravity vector used by the simulation
  22466. */
  22467. gravity: Vector3;
  22468. /**
  22469. * Sets the gravity vector used by the simulation
  22470. * @param gravity defines the gravity vector to use
  22471. */
  22472. setGravity(gravity: Vector3): void;
  22473. /**
  22474. * Set the time step of the physics engine.
  22475. * Default is 1/60.
  22476. * To slow it down, enter 1/600 for example.
  22477. * To speed it up, 1/30
  22478. * @param newTimeStep the new timestep to apply to this world.
  22479. */
  22480. setTimeStep(newTimeStep: number): void;
  22481. /**
  22482. * Get the time step of the physics engine.
  22483. * @returns the current time step
  22484. */
  22485. getTimeStep(): number;
  22486. /**
  22487. * Release all resources
  22488. */
  22489. dispose(): void;
  22490. /**
  22491. * Gets the name of the current physics plugin
  22492. * @returns the name of the plugin
  22493. */
  22494. getPhysicsPluginName(): string;
  22495. /**
  22496. * Adding a new impostor for the impostor tracking.
  22497. * This will be done by the impostor itself.
  22498. * @param impostor the impostor to add
  22499. */
  22500. addImpostor(impostor: PhysicsImpostor): void;
  22501. /**
  22502. * Remove an impostor from the engine.
  22503. * This impostor and its mesh will not longer be updated by the physics engine.
  22504. * @param impostor the impostor to remove
  22505. */
  22506. removeImpostor(impostor: PhysicsImpostor): void;
  22507. /**
  22508. * Add a joint to the physics engine
  22509. * @param mainImpostor defines the main impostor to which the joint is added.
  22510. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22511. * @param joint defines the joint that will connect both impostors.
  22512. */
  22513. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22514. /**
  22515. * Removes a joint from the simulation
  22516. * @param mainImpostor defines the impostor used with the joint
  22517. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22518. * @param joint defines the joint to remove
  22519. */
  22520. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22521. /**
  22522. * Gets the current plugin used to run the simulation
  22523. * @returns current plugin
  22524. */
  22525. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22526. /**
  22527. * Gets the list of physic impostors
  22528. * @returns an array of PhysicsImpostor
  22529. */
  22530. getImpostors(): Array<PhysicsImpostor>;
  22531. /**
  22532. * Gets the impostor for a physics enabled object
  22533. * @param object defines the object impersonated by the impostor
  22534. * @returns the PhysicsImpostor or null if not found
  22535. */
  22536. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22537. /**
  22538. * Gets the impostor for a physics body object
  22539. * @param body defines physics body used by the impostor
  22540. * @returns the PhysicsImpostor or null if not found
  22541. */
  22542. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22543. /**
  22544. * Does a raycast in the physics world
  22545. * @param from when should the ray start?
  22546. * @param to when should the ray end?
  22547. * @returns PhysicsRaycastResult
  22548. */
  22549. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22550. /**
  22551. * Called by the scene. No need to call it.
  22552. * @param delta defines the timespam between frames
  22553. */
  22554. _step(delta: number): void;
  22555. }
  22556. }
  22557. declare module BABYLON {
  22558. /**
  22559. * The interface for the physics imposter parameters
  22560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22561. */
  22562. export interface PhysicsImpostorParameters {
  22563. /**
  22564. * The mass of the physics imposter
  22565. */
  22566. mass: number;
  22567. /**
  22568. * The friction of the physics imposter
  22569. */
  22570. friction?: number;
  22571. /**
  22572. * The coefficient of restitution of the physics imposter
  22573. */
  22574. restitution?: number;
  22575. /**
  22576. * The native options of the physics imposter
  22577. */
  22578. nativeOptions?: any;
  22579. /**
  22580. * Specifies if the parent should be ignored
  22581. */
  22582. ignoreParent?: boolean;
  22583. /**
  22584. * Specifies if bi-directional transformations should be disabled
  22585. */
  22586. disableBidirectionalTransformation?: boolean;
  22587. /**
  22588. * The pressure inside the physics imposter, soft object only
  22589. */
  22590. pressure?: number;
  22591. /**
  22592. * The stiffness the physics imposter, soft object only
  22593. */
  22594. stiffness?: number;
  22595. /**
  22596. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22597. */
  22598. velocityIterations?: number;
  22599. /**
  22600. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22601. */
  22602. positionIterations?: number;
  22603. /**
  22604. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22605. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22606. * Add to fix multiple points
  22607. */
  22608. fixedPoints?: number;
  22609. /**
  22610. * The collision margin around a soft object
  22611. */
  22612. margin?: number;
  22613. /**
  22614. * The collision margin around a soft object
  22615. */
  22616. damping?: number;
  22617. /**
  22618. * The path for a rope based on an extrusion
  22619. */
  22620. path?: any;
  22621. /**
  22622. * The shape of an extrusion used for a rope based on an extrusion
  22623. */
  22624. shape?: any;
  22625. }
  22626. /**
  22627. * Interface for a physics-enabled object
  22628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22629. */
  22630. export interface IPhysicsEnabledObject {
  22631. /**
  22632. * The position of the physics-enabled object
  22633. */
  22634. position: Vector3;
  22635. /**
  22636. * The rotation of the physics-enabled object
  22637. */
  22638. rotationQuaternion: Nullable<Quaternion>;
  22639. /**
  22640. * The scale of the physics-enabled object
  22641. */
  22642. scaling: Vector3;
  22643. /**
  22644. * The rotation of the physics-enabled object
  22645. */
  22646. rotation?: Vector3;
  22647. /**
  22648. * The parent of the physics-enabled object
  22649. */
  22650. parent?: any;
  22651. /**
  22652. * The bounding info of the physics-enabled object
  22653. * @returns The bounding info of the physics-enabled object
  22654. */
  22655. getBoundingInfo(): BoundingInfo;
  22656. /**
  22657. * Computes the world matrix
  22658. * @param force Specifies if the world matrix should be computed by force
  22659. * @returns A world matrix
  22660. */
  22661. computeWorldMatrix(force: boolean): Matrix;
  22662. /**
  22663. * Gets the world matrix
  22664. * @returns A world matrix
  22665. */
  22666. getWorldMatrix?(): Matrix;
  22667. /**
  22668. * Gets the child meshes
  22669. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22670. * @returns An array of abstract meshes
  22671. */
  22672. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22673. /**
  22674. * Gets the vertex data
  22675. * @param kind The type of vertex data
  22676. * @returns A nullable array of numbers, or a float32 array
  22677. */
  22678. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22679. /**
  22680. * Gets the indices from the mesh
  22681. * @returns A nullable array of index arrays
  22682. */
  22683. getIndices?(): Nullable<IndicesArray>;
  22684. /**
  22685. * Gets the scene from the mesh
  22686. * @returns the indices array or null
  22687. */
  22688. getScene?(): Scene;
  22689. /**
  22690. * Gets the absolute position from the mesh
  22691. * @returns the absolute position
  22692. */
  22693. getAbsolutePosition(): Vector3;
  22694. /**
  22695. * Gets the absolute pivot point from the mesh
  22696. * @returns the absolute pivot point
  22697. */
  22698. getAbsolutePivotPoint(): Vector3;
  22699. /**
  22700. * Rotates the mesh
  22701. * @param axis The axis of rotation
  22702. * @param amount The amount of rotation
  22703. * @param space The space of the rotation
  22704. * @returns The rotation transform node
  22705. */
  22706. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22707. /**
  22708. * Translates the mesh
  22709. * @param axis The axis of translation
  22710. * @param distance The distance of translation
  22711. * @param space The space of the translation
  22712. * @returns The transform node
  22713. */
  22714. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22715. /**
  22716. * Sets the absolute position of the mesh
  22717. * @param absolutePosition The absolute position of the mesh
  22718. * @returns The transform node
  22719. */
  22720. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22721. /**
  22722. * Gets the class name of the mesh
  22723. * @returns The class name
  22724. */
  22725. getClassName(): string;
  22726. }
  22727. /**
  22728. * Represents a physics imposter
  22729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22730. */
  22731. export class PhysicsImpostor {
  22732. /**
  22733. * The physics-enabled object used as the physics imposter
  22734. */
  22735. object: IPhysicsEnabledObject;
  22736. /**
  22737. * The type of the physics imposter
  22738. */
  22739. type: number;
  22740. private _options;
  22741. private _scene?;
  22742. /**
  22743. * The default object size of the imposter
  22744. */
  22745. static DEFAULT_OBJECT_SIZE: Vector3;
  22746. /**
  22747. * The identity quaternion of the imposter
  22748. */
  22749. static IDENTITY_QUATERNION: Quaternion;
  22750. /** @hidden */
  22751. _pluginData: any;
  22752. private _physicsEngine;
  22753. private _physicsBody;
  22754. private _bodyUpdateRequired;
  22755. private _onBeforePhysicsStepCallbacks;
  22756. private _onAfterPhysicsStepCallbacks;
  22757. /** @hidden */
  22758. _onPhysicsCollideCallbacks: Array<{
  22759. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22760. otherImpostors: Array<PhysicsImpostor>;
  22761. }>;
  22762. private _deltaPosition;
  22763. private _deltaRotation;
  22764. private _deltaRotationConjugated;
  22765. /** @hidden */
  22766. _isFromLine: boolean;
  22767. private _parent;
  22768. private _isDisposed;
  22769. private static _tmpVecs;
  22770. private static _tmpQuat;
  22771. /**
  22772. * Specifies if the physics imposter is disposed
  22773. */
  22774. readonly isDisposed: boolean;
  22775. /**
  22776. * Gets the mass of the physics imposter
  22777. */
  22778. mass: number;
  22779. /**
  22780. * Gets the coefficient of friction
  22781. */
  22782. /**
  22783. * Sets the coefficient of friction
  22784. */
  22785. friction: number;
  22786. /**
  22787. * Gets the coefficient of restitution
  22788. */
  22789. /**
  22790. * Sets the coefficient of restitution
  22791. */
  22792. restitution: number;
  22793. /**
  22794. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22795. */
  22796. /**
  22797. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22798. */
  22799. pressure: number;
  22800. /**
  22801. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22802. */
  22803. /**
  22804. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22805. */
  22806. stiffness: number;
  22807. /**
  22808. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22809. */
  22810. /**
  22811. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22812. */
  22813. velocityIterations: number;
  22814. /**
  22815. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22816. */
  22817. /**
  22818. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22819. */
  22820. positionIterations: number;
  22821. /**
  22822. * The unique id of the physics imposter
  22823. * set by the physics engine when adding this impostor to the array
  22824. */
  22825. uniqueId: number;
  22826. /**
  22827. * @hidden
  22828. */
  22829. soft: boolean;
  22830. /**
  22831. * @hidden
  22832. */
  22833. segments: number;
  22834. private _joints;
  22835. /**
  22836. * Initializes the physics imposter
  22837. * @param object The physics-enabled object used as the physics imposter
  22838. * @param type The type of the physics imposter
  22839. * @param _options The options for the physics imposter
  22840. * @param _scene The Babylon scene
  22841. */
  22842. constructor(
  22843. /**
  22844. * The physics-enabled object used as the physics imposter
  22845. */
  22846. object: IPhysicsEnabledObject,
  22847. /**
  22848. * The type of the physics imposter
  22849. */
  22850. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22851. /**
  22852. * This function will completly initialize this impostor.
  22853. * It will create a new body - but only if this mesh has no parent.
  22854. * If it has, this impostor will not be used other than to define the impostor
  22855. * of the child mesh.
  22856. * @hidden
  22857. */
  22858. _init(): void;
  22859. private _getPhysicsParent;
  22860. /**
  22861. * Should a new body be generated.
  22862. * @returns boolean specifying if body initialization is required
  22863. */
  22864. isBodyInitRequired(): boolean;
  22865. /**
  22866. * Sets the updated scaling
  22867. * @param updated Specifies if the scaling is updated
  22868. */
  22869. setScalingUpdated(): void;
  22870. /**
  22871. * Force a regeneration of this or the parent's impostor's body.
  22872. * Use under cautious - This will remove all joints already implemented.
  22873. */
  22874. forceUpdate(): void;
  22875. /**
  22876. * Gets the body that holds this impostor. Either its own, or its parent.
  22877. */
  22878. /**
  22879. * Set the physics body. Used mainly by the physics engine/plugin
  22880. */
  22881. physicsBody: any;
  22882. /**
  22883. * Get the parent of the physics imposter
  22884. * @returns Physics imposter or null
  22885. */
  22886. /**
  22887. * Sets the parent of the physics imposter
  22888. */
  22889. parent: Nullable<PhysicsImpostor>;
  22890. /**
  22891. * Resets the update flags
  22892. */
  22893. resetUpdateFlags(): void;
  22894. /**
  22895. * Gets the object extend size
  22896. * @returns the object extend size
  22897. */
  22898. getObjectExtendSize(): Vector3;
  22899. /**
  22900. * Gets the object center
  22901. * @returns The object center
  22902. */
  22903. getObjectCenter(): Vector3;
  22904. /**
  22905. * Get a specific parametes from the options parameter
  22906. * @param paramName The object parameter name
  22907. * @returns The object parameter
  22908. */
  22909. getParam(paramName: string): any;
  22910. /**
  22911. * Sets a specific parameter in the options given to the physics plugin
  22912. * @param paramName The parameter name
  22913. * @param value The value of the parameter
  22914. */
  22915. setParam(paramName: string, value: number): void;
  22916. /**
  22917. * Specifically change the body's mass option. Won't recreate the physics body object
  22918. * @param mass The mass of the physics imposter
  22919. */
  22920. setMass(mass: number): void;
  22921. /**
  22922. * Gets the linear velocity
  22923. * @returns linear velocity or null
  22924. */
  22925. getLinearVelocity(): Nullable<Vector3>;
  22926. /**
  22927. * Sets the linear velocity
  22928. * @param velocity linear velocity or null
  22929. */
  22930. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22931. /**
  22932. * Gets the angular velocity
  22933. * @returns angular velocity or null
  22934. */
  22935. getAngularVelocity(): Nullable<Vector3>;
  22936. /**
  22937. * Sets the angular velocity
  22938. * @param velocity The velocity or null
  22939. */
  22940. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22941. /**
  22942. * Execute a function with the physics plugin native code
  22943. * Provide a function the will have two variables - the world object and the physics body object
  22944. * @param func The function to execute with the physics plugin native code
  22945. */
  22946. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22947. /**
  22948. * Register a function that will be executed before the physics world is stepping forward
  22949. * @param func The function to execute before the physics world is stepped forward
  22950. */
  22951. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22952. /**
  22953. * Unregister a function that will be executed before the physics world is stepping forward
  22954. * @param func The function to execute before the physics world is stepped forward
  22955. */
  22956. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22957. /**
  22958. * Register a function that will be executed after the physics step
  22959. * @param func The function to execute after physics step
  22960. */
  22961. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22962. /**
  22963. * Unregisters a function that will be executed after the physics step
  22964. * @param func The function to execute after physics step
  22965. */
  22966. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22967. /**
  22968. * register a function that will be executed when this impostor collides against a different body
  22969. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  22970. * @param func Callback that is executed on collision
  22971. */
  22972. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22973. /**
  22974. * Unregisters the physics imposter on contact
  22975. * @param collideAgainst The physics object to collide against
  22976. * @param func Callback to execute on collision
  22977. */
  22978. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  22979. private _tmpQuat;
  22980. private _tmpQuat2;
  22981. /**
  22982. * Get the parent rotation
  22983. * @returns The parent rotation
  22984. */
  22985. getParentsRotation(): Quaternion;
  22986. /**
  22987. * this function is executed by the physics engine.
  22988. */
  22989. beforeStep: () => void;
  22990. /**
  22991. * this function is executed by the physics engine
  22992. */
  22993. afterStep: () => void;
  22994. /**
  22995. * Legacy collision detection event support
  22996. */
  22997. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  22998. /**
  22999. * event and body object due to cannon's event-based architecture.
  23000. */
  23001. onCollide: (e: {
  23002. body: any;
  23003. }) => void;
  23004. /**
  23005. * Apply a force
  23006. * @param force The force to apply
  23007. * @param contactPoint The contact point for the force
  23008. * @returns The physics imposter
  23009. */
  23010. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23011. /**
  23012. * Apply an impulse
  23013. * @param force The impulse force
  23014. * @param contactPoint The contact point for the impulse force
  23015. * @returns The physics imposter
  23016. */
  23017. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23018. /**
  23019. * A help function to create a joint
  23020. * @param otherImpostor A physics imposter used to create a joint
  23021. * @param jointType The type of joint
  23022. * @param jointData The data for the joint
  23023. * @returns The physics imposter
  23024. */
  23025. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23026. /**
  23027. * Add a joint to this impostor with a different impostor
  23028. * @param otherImpostor A physics imposter used to add a joint
  23029. * @param joint The joint to add
  23030. * @returns The physics imposter
  23031. */
  23032. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23033. /**
  23034. * Add an anchor to a cloth impostor
  23035. * @param otherImpostor rigid impostor to anchor to
  23036. * @param width ratio across width from 0 to 1
  23037. * @param height ratio up height from 0 to 1
  23038. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23039. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23040. * @returns impostor the soft imposter
  23041. */
  23042. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23043. /**
  23044. * Add a hook to a rope impostor
  23045. * @param otherImpostor rigid impostor to anchor to
  23046. * @param length ratio across rope from 0 to 1
  23047. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23048. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23049. * @returns impostor the rope imposter
  23050. */
  23051. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23052. /**
  23053. * Will keep this body still, in a sleep mode.
  23054. * @returns the physics imposter
  23055. */
  23056. sleep(): PhysicsImpostor;
  23057. /**
  23058. * Wake the body up.
  23059. * @returns The physics imposter
  23060. */
  23061. wakeUp(): PhysicsImpostor;
  23062. /**
  23063. * Clones the physics imposter
  23064. * @param newObject The physics imposter clones to this physics-enabled object
  23065. * @returns A nullable physics imposter
  23066. */
  23067. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23068. /**
  23069. * Disposes the physics imposter
  23070. */
  23071. dispose(): void;
  23072. /**
  23073. * Sets the delta position
  23074. * @param position The delta position amount
  23075. */
  23076. setDeltaPosition(position: Vector3): void;
  23077. /**
  23078. * Sets the delta rotation
  23079. * @param rotation The delta rotation amount
  23080. */
  23081. setDeltaRotation(rotation: Quaternion): void;
  23082. /**
  23083. * Gets the box size of the physics imposter and stores the result in the input parameter
  23084. * @param result Stores the box size
  23085. * @returns The physics imposter
  23086. */
  23087. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23088. /**
  23089. * Gets the radius of the physics imposter
  23090. * @returns Radius of the physics imposter
  23091. */
  23092. getRadius(): number;
  23093. /**
  23094. * Sync a bone with this impostor
  23095. * @param bone The bone to sync to the impostor.
  23096. * @param boneMesh The mesh that the bone is influencing.
  23097. * @param jointPivot The pivot of the joint / bone in local space.
  23098. * @param distToJoint Optional distance from the impostor to the joint.
  23099. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23100. */
  23101. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23102. /**
  23103. * Sync impostor to a bone
  23104. * @param bone The bone that the impostor will be synced to.
  23105. * @param boneMesh The mesh that the bone is influencing.
  23106. * @param jointPivot The pivot of the joint / bone in local space.
  23107. * @param distToJoint Optional distance from the impostor to the joint.
  23108. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23109. * @param boneAxis Optional vector3 axis the bone is aligned with
  23110. */
  23111. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23112. /**
  23113. * No-Imposter type
  23114. */
  23115. static NoImpostor: number;
  23116. /**
  23117. * Sphere-Imposter type
  23118. */
  23119. static SphereImpostor: number;
  23120. /**
  23121. * Box-Imposter type
  23122. */
  23123. static BoxImpostor: number;
  23124. /**
  23125. * Plane-Imposter type
  23126. */
  23127. static PlaneImpostor: number;
  23128. /**
  23129. * Mesh-imposter type
  23130. */
  23131. static MeshImpostor: number;
  23132. /**
  23133. * Capsule-Impostor type (Ammo.js plugin only)
  23134. */
  23135. static CapsuleImpostor: number;
  23136. /**
  23137. * Cylinder-Imposter type
  23138. */
  23139. static CylinderImpostor: number;
  23140. /**
  23141. * Particle-Imposter type
  23142. */
  23143. static ParticleImpostor: number;
  23144. /**
  23145. * Heightmap-Imposter type
  23146. */
  23147. static HeightmapImpostor: number;
  23148. /**
  23149. * ConvexHull-Impostor type (Ammo.js plugin only)
  23150. */
  23151. static ConvexHullImpostor: number;
  23152. /**
  23153. * Rope-Imposter type
  23154. */
  23155. static RopeImpostor: number;
  23156. /**
  23157. * Cloth-Imposter type
  23158. */
  23159. static ClothImpostor: number;
  23160. /**
  23161. * Softbody-Imposter type
  23162. */
  23163. static SoftbodyImpostor: number;
  23164. }
  23165. }
  23166. declare module BABYLON {
  23167. /**
  23168. * @hidden
  23169. **/
  23170. export class _CreationDataStorage {
  23171. closePath?: boolean;
  23172. closeArray?: boolean;
  23173. idx: number[];
  23174. dashSize: number;
  23175. gapSize: number;
  23176. path3D: Path3D;
  23177. pathArray: Vector3[][];
  23178. arc: number;
  23179. radius: number;
  23180. cap: number;
  23181. tessellation: number;
  23182. }
  23183. /**
  23184. * @hidden
  23185. **/
  23186. class _InstanceDataStorage {
  23187. visibleInstances: any;
  23188. batchCache: _InstancesBatch;
  23189. instancesBufferSize: number;
  23190. instancesBuffer: Nullable<Buffer>;
  23191. instancesData: Float32Array;
  23192. overridenInstanceCount: number;
  23193. isFrozen: boolean;
  23194. previousBatch: Nullable<_InstancesBatch>;
  23195. hardwareInstancedRendering: boolean;
  23196. sideOrientation: number;
  23197. }
  23198. /**
  23199. * @hidden
  23200. **/
  23201. export class _InstancesBatch {
  23202. mustReturn: boolean;
  23203. visibleInstances: Nullable<InstancedMesh[]>[];
  23204. renderSelf: boolean[];
  23205. hardwareInstancedRendering: boolean[];
  23206. }
  23207. /**
  23208. * Class used to represent renderable models
  23209. */
  23210. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23211. /**
  23212. * Mesh side orientation : usually the external or front surface
  23213. */
  23214. static readonly FRONTSIDE: number;
  23215. /**
  23216. * Mesh side orientation : usually the internal or back surface
  23217. */
  23218. static readonly BACKSIDE: number;
  23219. /**
  23220. * Mesh side orientation : both internal and external or front and back surfaces
  23221. */
  23222. static readonly DOUBLESIDE: number;
  23223. /**
  23224. * Mesh side orientation : by default, `FRONTSIDE`
  23225. */
  23226. static readonly DEFAULTSIDE: number;
  23227. /**
  23228. * Mesh cap setting : no cap
  23229. */
  23230. static readonly NO_CAP: number;
  23231. /**
  23232. * Mesh cap setting : one cap at the beginning of the mesh
  23233. */
  23234. static readonly CAP_START: number;
  23235. /**
  23236. * Mesh cap setting : one cap at the end of the mesh
  23237. */
  23238. static readonly CAP_END: number;
  23239. /**
  23240. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23241. */
  23242. static readonly CAP_ALL: number;
  23243. /**
  23244. * Mesh pattern setting : no flip or rotate
  23245. */
  23246. static readonly NO_FLIP: number;
  23247. /**
  23248. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23249. */
  23250. static readonly FLIP_TILE: number;
  23251. /**
  23252. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23253. */
  23254. static readonly ROTATE_TILE: number;
  23255. /**
  23256. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23257. */
  23258. static readonly FLIP_ROW: number;
  23259. /**
  23260. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23261. */
  23262. static readonly ROTATE_ROW: number;
  23263. /**
  23264. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23265. */
  23266. static readonly FLIP_N_ROTATE_TILE: number;
  23267. /**
  23268. * Mesh pattern setting : rotate pattern and rotate
  23269. */
  23270. static readonly FLIP_N_ROTATE_ROW: number;
  23271. /**
  23272. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23273. */
  23274. static readonly CENTER: number;
  23275. /**
  23276. * Mesh tile positioning : part tiles on left
  23277. */
  23278. static readonly LEFT: number;
  23279. /**
  23280. * Mesh tile positioning : part tiles on right
  23281. */
  23282. static readonly RIGHT: number;
  23283. /**
  23284. * Mesh tile positioning : part tiles on top
  23285. */
  23286. static readonly TOP: number;
  23287. /**
  23288. * Mesh tile positioning : part tiles on bottom
  23289. */
  23290. static readonly BOTTOM: number;
  23291. /**
  23292. * Gets the default side orientation.
  23293. * @param orientation the orientation to value to attempt to get
  23294. * @returns the default orientation
  23295. * @hidden
  23296. */
  23297. static _GetDefaultSideOrientation(orientation?: number): number;
  23298. private _internalMeshDataInfo;
  23299. /**
  23300. * An event triggered before rendering the mesh
  23301. */
  23302. readonly onBeforeRenderObservable: Observable<Mesh>;
  23303. /**
  23304. * An event triggered before binding the mesh
  23305. */
  23306. readonly onBeforeBindObservable: Observable<Mesh>;
  23307. /**
  23308. * An event triggered after rendering the mesh
  23309. */
  23310. readonly onAfterRenderObservable: Observable<Mesh>;
  23311. /**
  23312. * An event triggered before drawing the mesh
  23313. */
  23314. readonly onBeforeDrawObservable: Observable<Mesh>;
  23315. private _onBeforeDrawObserver;
  23316. /**
  23317. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23318. */
  23319. onBeforeDraw: () => void;
  23320. /**
  23321. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23322. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23323. */
  23324. delayLoadState: number;
  23325. /**
  23326. * Gets the list of instances created from this mesh
  23327. * it is not supposed to be modified manually.
  23328. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23329. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23330. */
  23331. instances: InstancedMesh[];
  23332. /**
  23333. * Gets the file containing delay loading data for this mesh
  23334. */
  23335. delayLoadingFile: string;
  23336. /** @hidden */
  23337. _binaryInfo: any;
  23338. /**
  23339. * User defined function used to change how LOD level selection is done
  23340. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23341. */
  23342. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23343. /**
  23344. * Gets or sets the morph target manager
  23345. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23346. */
  23347. morphTargetManager: Nullable<MorphTargetManager>;
  23348. /** @hidden */
  23349. _creationDataStorage: Nullable<_CreationDataStorage>;
  23350. /** @hidden */
  23351. _geometry: Nullable<Geometry>;
  23352. /** @hidden */
  23353. _delayInfo: Array<string>;
  23354. /** @hidden */
  23355. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23356. /** @hidden */
  23357. _instanceDataStorage: _InstanceDataStorage;
  23358. private _effectiveMaterial;
  23359. /** @hidden */
  23360. _shouldGenerateFlatShading: boolean;
  23361. /** @hidden */
  23362. _originalBuilderSideOrientation: number;
  23363. /**
  23364. * Use this property to change the original side orientation defined at construction time
  23365. */
  23366. overrideMaterialSideOrientation: Nullable<number>;
  23367. /**
  23368. * Gets the source mesh (the one used to clone this one from)
  23369. */
  23370. readonly source: Nullable<Mesh>;
  23371. /**
  23372. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23373. */
  23374. isUnIndexed: boolean;
  23375. /**
  23376. * @constructor
  23377. * @param name The value used by scene.getMeshByName() to do a lookup.
  23378. * @param scene The scene to add this mesh to.
  23379. * @param parent The parent of this mesh, if it has one
  23380. * @param source An optional Mesh from which geometry is shared, cloned.
  23381. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23382. * When false, achieved by calling a clone(), also passing False.
  23383. * This will make creation of children, recursive.
  23384. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23385. */
  23386. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23387. /**
  23388. * Gets the class name
  23389. * @returns the string "Mesh".
  23390. */
  23391. getClassName(): string;
  23392. /** @hidden */
  23393. readonly _isMesh: boolean;
  23394. /**
  23395. * Returns a description of this mesh
  23396. * @param fullDetails define if full details about this mesh must be used
  23397. * @returns a descriptive string representing this mesh
  23398. */
  23399. toString(fullDetails?: boolean): string;
  23400. /** @hidden */
  23401. _unBindEffect(): void;
  23402. /**
  23403. * Gets a boolean indicating if this mesh has LOD
  23404. */
  23405. readonly hasLODLevels: boolean;
  23406. /**
  23407. * Gets the list of MeshLODLevel associated with the current mesh
  23408. * @returns an array of MeshLODLevel
  23409. */
  23410. getLODLevels(): MeshLODLevel[];
  23411. private _sortLODLevels;
  23412. /**
  23413. * Add a mesh as LOD level triggered at the given distance.
  23414. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23415. * @param distance The distance from the center of the object to show this level
  23416. * @param mesh The mesh to be added as LOD level (can be null)
  23417. * @return This mesh (for chaining)
  23418. */
  23419. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23420. /**
  23421. * Returns the LOD level mesh at the passed distance or null if not found.
  23422. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23423. * @param distance The distance from the center of the object to show this level
  23424. * @returns a Mesh or `null`
  23425. */
  23426. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23427. /**
  23428. * Remove a mesh from the LOD array
  23429. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23430. * @param mesh defines the mesh to be removed
  23431. * @return This mesh (for chaining)
  23432. */
  23433. removeLODLevel(mesh: Mesh): Mesh;
  23434. /**
  23435. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23436. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23437. * @param camera defines the camera to use to compute distance
  23438. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23439. * @return This mesh (for chaining)
  23440. */
  23441. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23442. /**
  23443. * Gets the mesh internal Geometry object
  23444. */
  23445. readonly geometry: Nullable<Geometry>;
  23446. /**
  23447. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23448. * @returns the total number of vertices
  23449. */
  23450. getTotalVertices(): number;
  23451. /**
  23452. * Returns the content of an associated vertex buffer
  23453. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23454. * - VertexBuffer.PositionKind
  23455. * - VertexBuffer.UVKind
  23456. * - VertexBuffer.UV2Kind
  23457. * - VertexBuffer.UV3Kind
  23458. * - VertexBuffer.UV4Kind
  23459. * - VertexBuffer.UV5Kind
  23460. * - VertexBuffer.UV6Kind
  23461. * - VertexBuffer.ColorKind
  23462. * - VertexBuffer.MatricesIndicesKind
  23463. * - VertexBuffer.MatricesIndicesExtraKind
  23464. * - VertexBuffer.MatricesWeightsKind
  23465. * - VertexBuffer.MatricesWeightsExtraKind
  23466. * @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
  23467. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23468. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23469. */
  23470. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23471. /**
  23472. * Returns the mesh VertexBuffer object from the requested `kind`
  23473. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23474. * - VertexBuffer.PositionKind
  23475. * - VertexBuffer.NormalKind
  23476. * - VertexBuffer.UVKind
  23477. * - VertexBuffer.UV2Kind
  23478. * - VertexBuffer.UV3Kind
  23479. * - VertexBuffer.UV4Kind
  23480. * - VertexBuffer.UV5Kind
  23481. * - VertexBuffer.UV6Kind
  23482. * - VertexBuffer.ColorKind
  23483. * - VertexBuffer.MatricesIndicesKind
  23484. * - VertexBuffer.MatricesIndicesExtraKind
  23485. * - VertexBuffer.MatricesWeightsKind
  23486. * - VertexBuffer.MatricesWeightsExtraKind
  23487. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23488. */
  23489. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23490. /**
  23491. * Tests if a specific vertex buffer is associated with this mesh
  23492. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23493. * - VertexBuffer.PositionKind
  23494. * - VertexBuffer.NormalKind
  23495. * - VertexBuffer.UVKind
  23496. * - VertexBuffer.UV2Kind
  23497. * - VertexBuffer.UV3Kind
  23498. * - VertexBuffer.UV4Kind
  23499. * - VertexBuffer.UV5Kind
  23500. * - VertexBuffer.UV6Kind
  23501. * - VertexBuffer.ColorKind
  23502. * - VertexBuffer.MatricesIndicesKind
  23503. * - VertexBuffer.MatricesIndicesExtraKind
  23504. * - VertexBuffer.MatricesWeightsKind
  23505. * - VertexBuffer.MatricesWeightsExtraKind
  23506. * @returns a boolean
  23507. */
  23508. isVerticesDataPresent(kind: string): boolean;
  23509. /**
  23510. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23511. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23512. * - VertexBuffer.PositionKind
  23513. * - VertexBuffer.UVKind
  23514. * - VertexBuffer.UV2Kind
  23515. * - VertexBuffer.UV3Kind
  23516. * - VertexBuffer.UV4Kind
  23517. * - VertexBuffer.UV5Kind
  23518. * - VertexBuffer.UV6Kind
  23519. * - VertexBuffer.ColorKind
  23520. * - VertexBuffer.MatricesIndicesKind
  23521. * - VertexBuffer.MatricesIndicesExtraKind
  23522. * - VertexBuffer.MatricesWeightsKind
  23523. * - VertexBuffer.MatricesWeightsExtraKind
  23524. * @returns a boolean
  23525. */
  23526. isVertexBufferUpdatable(kind: string): boolean;
  23527. /**
  23528. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23529. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23530. * - VertexBuffer.PositionKind
  23531. * - VertexBuffer.NormalKind
  23532. * - VertexBuffer.UVKind
  23533. * - VertexBuffer.UV2Kind
  23534. * - VertexBuffer.UV3Kind
  23535. * - VertexBuffer.UV4Kind
  23536. * - VertexBuffer.UV5Kind
  23537. * - VertexBuffer.UV6Kind
  23538. * - VertexBuffer.ColorKind
  23539. * - VertexBuffer.MatricesIndicesKind
  23540. * - VertexBuffer.MatricesIndicesExtraKind
  23541. * - VertexBuffer.MatricesWeightsKind
  23542. * - VertexBuffer.MatricesWeightsExtraKind
  23543. * @returns an array of strings
  23544. */
  23545. getVerticesDataKinds(): string[];
  23546. /**
  23547. * Returns a positive integer : the total number of indices in this mesh geometry.
  23548. * @returns the numner of indices or zero if the mesh has no geometry.
  23549. */
  23550. getTotalIndices(): number;
  23551. /**
  23552. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23553. * @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.
  23554. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23555. * @returns the indices array or an empty array if the mesh has no geometry
  23556. */
  23557. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23558. readonly isBlocked: boolean;
  23559. /**
  23560. * Determine if the current mesh is ready to be rendered
  23561. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23562. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23563. * @returns true if all associated assets are ready (material, textures, shaders)
  23564. */
  23565. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23566. /**
  23567. * 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.
  23568. */
  23569. readonly areNormalsFrozen: boolean;
  23570. /**
  23571. * 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.
  23572. * @returns the current mesh
  23573. */
  23574. freezeNormals(): Mesh;
  23575. /**
  23576. * 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
  23577. * @returns the current mesh
  23578. */
  23579. unfreezeNormals(): Mesh;
  23580. /**
  23581. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23582. */
  23583. overridenInstanceCount: number;
  23584. /** @hidden */
  23585. _preActivate(): Mesh;
  23586. /** @hidden */
  23587. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23588. /** @hidden */
  23589. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23590. /**
  23591. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23592. * This means the mesh underlying bounding box and sphere are recomputed.
  23593. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23594. * @returns the current mesh
  23595. */
  23596. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23597. /** @hidden */
  23598. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23599. /**
  23600. * This function will subdivide the mesh into multiple submeshes
  23601. * @param count defines the expected number of submeshes
  23602. */
  23603. subdivide(count: number): void;
  23604. /**
  23605. * Copy a FloatArray into a specific associated vertex buffer
  23606. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23607. * - VertexBuffer.PositionKind
  23608. * - VertexBuffer.UVKind
  23609. * - VertexBuffer.UV2Kind
  23610. * - VertexBuffer.UV3Kind
  23611. * - VertexBuffer.UV4Kind
  23612. * - VertexBuffer.UV5Kind
  23613. * - VertexBuffer.UV6Kind
  23614. * - VertexBuffer.ColorKind
  23615. * - VertexBuffer.MatricesIndicesKind
  23616. * - VertexBuffer.MatricesIndicesExtraKind
  23617. * - VertexBuffer.MatricesWeightsKind
  23618. * - VertexBuffer.MatricesWeightsExtraKind
  23619. * @param data defines the data source
  23620. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23621. * @param stride defines the data stride size (can be null)
  23622. * @returns the current mesh
  23623. */
  23624. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  23625. /**
  23626. * Flags an associated vertex buffer as updatable
  23627. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23628. * - VertexBuffer.PositionKind
  23629. * - VertexBuffer.UVKind
  23630. * - VertexBuffer.UV2Kind
  23631. * - VertexBuffer.UV3Kind
  23632. * - VertexBuffer.UV4Kind
  23633. * - VertexBuffer.UV5Kind
  23634. * - VertexBuffer.UV6Kind
  23635. * - VertexBuffer.ColorKind
  23636. * - VertexBuffer.MatricesIndicesKind
  23637. * - VertexBuffer.MatricesIndicesExtraKind
  23638. * - VertexBuffer.MatricesWeightsKind
  23639. * - VertexBuffer.MatricesWeightsExtraKind
  23640. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23641. */
  23642. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23643. /**
  23644. * Sets the mesh global Vertex Buffer
  23645. * @param buffer defines the buffer to use
  23646. * @returns the current mesh
  23647. */
  23648. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23649. /**
  23650. * Update a specific associated vertex buffer
  23651. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23652. * - VertexBuffer.PositionKind
  23653. * - VertexBuffer.UVKind
  23654. * - VertexBuffer.UV2Kind
  23655. * - VertexBuffer.UV3Kind
  23656. * - VertexBuffer.UV4Kind
  23657. * - VertexBuffer.UV5Kind
  23658. * - VertexBuffer.UV6Kind
  23659. * - VertexBuffer.ColorKind
  23660. * - VertexBuffer.MatricesIndicesKind
  23661. * - VertexBuffer.MatricesIndicesExtraKind
  23662. * - VertexBuffer.MatricesWeightsKind
  23663. * - VertexBuffer.MatricesWeightsExtraKind
  23664. * @param data defines the data source
  23665. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23666. * @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)
  23667. * @returns the current mesh
  23668. */
  23669. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  23670. /**
  23671. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23672. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23673. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23674. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23675. * @returns the current mesh
  23676. */
  23677. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23678. /**
  23679. * Creates a un-shared specific occurence of the geometry for the mesh.
  23680. * @returns the current mesh
  23681. */
  23682. makeGeometryUnique(): Mesh;
  23683. /**
  23684. * Set the index buffer of this mesh
  23685. * @param indices defines the source data
  23686. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23687. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23688. * @returns the current mesh
  23689. */
  23690. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  23691. /**
  23692. * Update the current index buffer
  23693. * @param indices defines the source data
  23694. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23695. * @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)
  23696. * @returns the current mesh
  23697. */
  23698. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  23699. /**
  23700. * Invert the geometry to move from a right handed system to a left handed one.
  23701. * @returns the current mesh
  23702. */
  23703. toLeftHanded(): Mesh;
  23704. /** @hidden */
  23705. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23706. /** @hidden */
  23707. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23708. /**
  23709. * Registers for this mesh a javascript function called just before the rendering process
  23710. * @param func defines the function to call before rendering this mesh
  23711. * @returns the current mesh
  23712. */
  23713. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23714. /**
  23715. * Disposes a previously registered javascript function called before the rendering
  23716. * @param func defines the function to remove
  23717. * @returns the current mesh
  23718. */
  23719. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23720. /**
  23721. * Registers for this mesh a javascript function called just after the rendering is complete
  23722. * @param func defines the function to call after rendering this mesh
  23723. * @returns the current mesh
  23724. */
  23725. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23726. /**
  23727. * Disposes a previously registered javascript function called after the rendering.
  23728. * @param func defines the function to remove
  23729. * @returns the current mesh
  23730. */
  23731. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23732. /** @hidden */
  23733. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23734. /** @hidden */
  23735. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23736. /** @hidden */
  23737. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23738. /** @hidden */
  23739. _rebuild(): void;
  23740. /** @hidden */
  23741. _freeze(): void;
  23742. /** @hidden */
  23743. _unFreeze(): void;
  23744. /**
  23745. * 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
  23746. * @param subMesh defines the subMesh to render
  23747. * @param enableAlphaMode defines if alpha mode can be changed
  23748. * @returns the current mesh
  23749. */
  23750. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23751. private _onBeforeDraw;
  23752. /**
  23753. * Renormalize the mesh and patch it up if there are no weights
  23754. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23755. * However in the case of zero weights then we set just a single influence to 1.
  23756. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23757. */
  23758. cleanMatrixWeights(): void;
  23759. private normalizeSkinFourWeights;
  23760. private normalizeSkinWeightsAndExtra;
  23761. /**
  23762. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23763. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23764. * the user know there was an issue with importing the mesh
  23765. * @returns a validation object with skinned, valid and report string
  23766. */
  23767. validateSkinning(): {
  23768. skinned: boolean;
  23769. valid: boolean;
  23770. report: string;
  23771. };
  23772. /** @hidden */
  23773. _checkDelayState(): Mesh;
  23774. private _queueLoad;
  23775. /**
  23776. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23777. * A mesh is in the frustum if its bounding box intersects the frustum
  23778. * @param frustumPlanes defines the frustum to test
  23779. * @returns true if the mesh is in the frustum planes
  23780. */
  23781. isInFrustum(frustumPlanes: Plane[]): boolean;
  23782. /**
  23783. * Sets the mesh material by the material or multiMaterial `id` property
  23784. * @param id is a string identifying the material or the multiMaterial
  23785. * @returns the current mesh
  23786. */
  23787. setMaterialByID(id: string): Mesh;
  23788. /**
  23789. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23790. * @returns an array of IAnimatable
  23791. */
  23792. getAnimatables(): IAnimatable[];
  23793. /**
  23794. * Modifies the mesh geometry according to the passed transformation matrix.
  23795. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23796. * The mesh normals are modified using the same transformation.
  23797. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23798. * @param transform defines the transform matrix to use
  23799. * @see http://doc.babylonjs.com/resources/baking_transformations
  23800. * @returns the current mesh
  23801. */
  23802. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23803. /**
  23804. * Modifies the mesh geometry according to its own current World Matrix.
  23805. * The mesh World Matrix is then reset.
  23806. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23807. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23808. * @see http://doc.babylonjs.com/resources/baking_transformations
  23809. * @returns the current mesh
  23810. */
  23811. bakeCurrentTransformIntoVertices(): Mesh;
  23812. /** @hidden */
  23813. readonly _positions: Nullable<Vector3[]>;
  23814. /** @hidden */
  23815. _resetPointsArrayCache(): Mesh;
  23816. /** @hidden */
  23817. _generatePointsArray(): boolean;
  23818. /**
  23819. * Returns a new Mesh object generated from the current mesh properties.
  23820. * This method must not get confused with createInstance()
  23821. * @param name is a string, the name given to the new mesh
  23822. * @param newParent can be any Node object (default `null`)
  23823. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23824. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23825. * @returns a new mesh
  23826. */
  23827. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  23828. /**
  23829. * Releases resources associated with this mesh.
  23830. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23831. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23832. */
  23833. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23834. /**
  23835. * Modifies the mesh geometry according to a displacement map.
  23836. * 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.
  23837. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23838. * @param url is a string, the URL from the image file is to be downloaded.
  23839. * @param minHeight is the lower limit of the displacement.
  23840. * @param maxHeight is the upper limit of the displacement.
  23841. * @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.
  23842. * @param uvOffset is an optional vector2 used to offset UV.
  23843. * @param uvScale is an optional vector2 used to scale UV.
  23844. * @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.
  23845. * @returns the Mesh.
  23846. */
  23847. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23848. /**
  23849. * Modifies the mesh geometry according to a displacementMap buffer.
  23850. * 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.
  23851. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23852. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23853. * @param heightMapWidth is the width of the buffer image.
  23854. * @param heightMapHeight is the height of the buffer image.
  23855. * @param minHeight is the lower limit of the displacement.
  23856. * @param maxHeight is the upper limit of the displacement.
  23857. * @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.
  23858. * @param uvOffset is an optional vector2 used to offset UV.
  23859. * @param uvScale is an optional vector2 used to scale UV.
  23860. * @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.
  23861. * @returns the Mesh.
  23862. */
  23863. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23864. /**
  23865. * Modify the mesh to get a flat shading rendering.
  23866. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23867. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23868. * @returns current mesh
  23869. */
  23870. convertToFlatShadedMesh(): Mesh;
  23871. /**
  23872. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23873. * In other words, more vertices, no more indices and a single bigger VBO.
  23874. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23875. * @returns current mesh
  23876. */
  23877. convertToUnIndexedMesh(): Mesh;
  23878. /**
  23879. * Inverses facet orientations.
  23880. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23881. * @param flipNormals will also inverts the normals
  23882. * @returns current mesh
  23883. */
  23884. flipFaces(flipNormals?: boolean): Mesh;
  23885. /**
  23886. * Increase the number of facets and hence vertices in a mesh
  23887. * Vertex normals are interpolated from existing vertex normals
  23888. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23889. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23890. */
  23891. increaseVertices(numberPerEdge: number): void;
  23892. /**
  23893. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23894. * This will undo any application of covertToFlatShadedMesh
  23895. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23896. */
  23897. forceSharedVertices(): void;
  23898. /** @hidden */
  23899. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23900. /** @hidden */
  23901. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23902. /**
  23903. * Creates a new InstancedMesh object from the mesh model.
  23904. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23905. * @param name defines the name of the new instance
  23906. * @returns a new InstancedMesh
  23907. */
  23908. createInstance(name: string): InstancedMesh;
  23909. /**
  23910. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23911. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23912. * @returns the current mesh
  23913. */
  23914. synchronizeInstances(): Mesh;
  23915. /**
  23916. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23917. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23918. * This should be used together with the simplification to avoid disappearing triangles.
  23919. * @param successCallback an optional success callback to be called after the optimization finished.
  23920. * @returns the current mesh
  23921. */
  23922. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23923. /**
  23924. * Serialize current mesh
  23925. * @param serializationObject defines the object which will receive the serialization data
  23926. */
  23927. serialize(serializationObject: any): void;
  23928. /** @hidden */
  23929. _syncGeometryWithMorphTargetManager(): void;
  23930. /** @hidden */
  23931. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23932. /**
  23933. * Returns a new Mesh object parsed from the source provided.
  23934. * @param parsedMesh is the source
  23935. * @param scene defines the hosting scene
  23936. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23937. * @returns a new Mesh
  23938. */
  23939. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23940. /**
  23941. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23942. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23943. * @param name defines the name of the mesh to create
  23944. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23945. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23946. * @param closePath creates a seam between the first and the last points of each path of the path array
  23947. * @param offset is taken in account only if the `pathArray` is containing a single path
  23948. * @param scene defines the hosting scene
  23949. * @param updatable defines if the mesh must be flagged as updatable
  23950. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23951. * @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)
  23952. * @returns a new Mesh
  23953. */
  23954. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23955. /**
  23956. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23957. * @param name defines the name of the mesh to create
  23958. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23959. * @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
  23960. * @param scene defines the hosting scene
  23961. * @param updatable defines if the mesh must be flagged as updatable
  23962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23963. * @returns a new Mesh
  23964. */
  23965. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23966. /**
  23967. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23968. * @param name defines the name of the mesh to create
  23969. * @param size sets the size (float) of each box side (default 1)
  23970. * @param scene defines the hosting scene
  23971. * @param updatable defines if the mesh must be flagged as updatable
  23972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23973. * @returns a new Mesh
  23974. */
  23975. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23976. /**
  23977. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  23978. * @param name defines the name of the mesh to create
  23979. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23980. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23981. * @param scene defines the hosting scene
  23982. * @param updatable defines if the mesh must be flagged as updatable
  23983. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23984. * @returns a new Mesh
  23985. */
  23986. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23987. /**
  23988. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  23989. * @param name defines the name of the mesh to create
  23990. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23991. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23992. * @param scene defines the hosting scene
  23993. * @returns a new Mesh
  23994. */
  23995. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  23996. /**
  23997. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  23998. * @param name defines the name of the mesh to create
  23999. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24000. * @param diameterTop set the top cap diameter (floats, default 1)
  24001. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24002. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24003. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24004. * @param scene defines the hosting scene
  24005. * @param updatable defines if the mesh must be flagged as updatable
  24006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24007. * @returns a new Mesh
  24008. */
  24009. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24010. /**
  24011. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24012. * @param name defines the name of the mesh to create
  24013. * @param diameter sets the diameter size (float) of the torus (default 1)
  24014. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24015. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24016. * @param scene defines the hosting scene
  24017. * @param updatable defines if the mesh must be flagged as updatable
  24018. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24019. * @returns a new Mesh
  24020. */
  24021. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24022. /**
  24023. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24024. * @param name defines the name of the mesh to create
  24025. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24026. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24027. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24028. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24029. * @param p the number of windings on X axis (positive integers, default 2)
  24030. * @param q the number of windings on Y axis (positive integers, default 3)
  24031. * @param scene defines the hosting scene
  24032. * @param updatable defines if the mesh must be flagged as updatable
  24033. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24034. * @returns a new Mesh
  24035. */
  24036. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24037. /**
  24038. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24039. * @param name defines the name of the mesh to create
  24040. * @param points is an array successive Vector3
  24041. * @param scene defines the hosting scene
  24042. * @param updatable defines if the mesh must be flagged as updatable
  24043. * @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).
  24044. * @returns a new Mesh
  24045. */
  24046. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24047. /**
  24048. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24049. * @param name defines the name of the mesh to create
  24050. * @param points is an array successive Vector3
  24051. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24052. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24053. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24054. * @param scene defines the hosting scene
  24055. * @param updatable defines if the mesh must be flagged as updatable
  24056. * @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)
  24057. * @returns a new Mesh
  24058. */
  24059. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24060. /**
  24061. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24062. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24063. * 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.
  24064. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24065. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24066. * Remember you can only change the shape positions, not their number when updating a polygon.
  24067. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24068. * @param name defines the name of the mesh to create
  24069. * @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
  24070. * @param scene defines the hosting scene
  24071. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24072. * @param updatable defines if the mesh must be flagged as updatable
  24073. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24074. * @param earcutInjection can be used to inject your own earcut reference
  24075. * @returns a new Mesh
  24076. */
  24077. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24078. /**
  24079. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24080. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24081. * @param name defines the name of the mesh to create
  24082. * @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
  24083. * @param depth defines the height of extrusion
  24084. * @param scene defines the hosting scene
  24085. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24086. * @param updatable defines if the mesh must be flagged as updatable
  24087. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24088. * @param earcutInjection can be used to inject your own earcut reference
  24089. * @returns a new Mesh
  24090. */
  24091. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24092. /**
  24093. * Creates an extruded shape mesh.
  24094. * 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
  24095. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24096. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24097. * @param name defines the name of the mesh to create
  24098. * @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
  24099. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24100. * @param scale is the value to scale the shape
  24101. * @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
  24102. * @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
  24103. * @param scene defines the hosting scene
  24104. * @param updatable defines if the mesh must be flagged as updatable
  24105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24106. * @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)
  24107. * @returns a new Mesh
  24108. */
  24109. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24110. /**
  24111. * Creates an custom extruded shape mesh.
  24112. * The custom extrusion is a parametric shape.
  24113. * It has no predefined shape. Its final shape will depend on the input parameters.
  24114. * Please consider using the same method from the MeshBuilder class instead
  24115. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24116. * @param name defines the name of the mesh to create
  24117. * @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
  24118. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24119. * @param scaleFunction is a custom Javascript function called on each path point
  24120. * @param rotationFunction is a custom Javascript function called on each path point
  24121. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24122. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24123. * @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
  24124. * @param scene defines the hosting scene
  24125. * @param updatable defines if the mesh must be flagged as updatable
  24126. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24127. * @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)
  24128. * @returns a new Mesh
  24129. */
  24130. 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;
  24131. /**
  24132. * Creates lathe mesh.
  24133. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24134. * Please consider using the same method from the MeshBuilder class instead
  24135. * @param name defines the name of the mesh to create
  24136. * @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
  24137. * @param radius is the radius value of the lathe
  24138. * @param tessellation is the side number of the lathe.
  24139. * @param scene defines the hosting scene
  24140. * @param updatable defines if the mesh must be flagged as updatable
  24141. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24142. * @returns a new Mesh
  24143. */
  24144. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24145. /**
  24146. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24147. * @param name defines the name of the mesh to create
  24148. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24149. * @param scene defines the hosting scene
  24150. * @param updatable defines if the mesh must be flagged as updatable
  24151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24152. * @returns a new Mesh
  24153. */
  24154. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24155. /**
  24156. * Creates a ground mesh.
  24157. * Please consider using the same method from the MeshBuilder class instead
  24158. * @param name defines the name of the mesh to create
  24159. * @param width set the width of the ground
  24160. * @param height set the height of the ground
  24161. * @param subdivisions sets the number of subdivisions per side
  24162. * @param scene defines the hosting scene
  24163. * @param updatable defines if the mesh must be flagged as updatable
  24164. * @returns a new Mesh
  24165. */
  24166. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24167. /**
  24168. * Creates a tiled ground mesh.
  24169. * Please consider using the same method from the MeshBuilder class instead
  24170. * @param name defines the name of the mesh to create
  24171. * @param xmin set the ground minimum X coordinate
  24172. * @param zmin set the ground minimum Y coordinate
  24173. * @param xmax set the ground maximum X coordinate
  24174. * @param zmax set the ground maximum Z coordinate
  24175. * @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
  24176. * @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
  24177. * @param scene defines the hosting scene
  24178. * @param updatable defines if the mesh must be flagged as updatable
  24179. * @returns a new Mesh
  24180. */
  24181. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24182. w: number;
  24183. h: number;
  24184. }, precision: {
  24185. w: number;
  24186. h: number;
  24187. }, scene: Scene, updatable?: boolean): Mesh;
  24188. /**
  24189. * Creates a ground mesh from a height map.
  24190. * Please consider using the same method from the MeshBuilder class instead
  24191. * @see http://doc.babylonjs.com/babylon101/height_map
  24192. * @param name defines the name of the mesh to create
  24193. * @param url sets the URL of the height map image resource
  24194. * @param width set the ground width size
  24195. * @param height set the ground height size
  24196. * @param subdivisions sets the number of subdivision per side
  24197. * @param minHeight is the minimum altitude on the ground
  24198. * @param maxHeight is the maximum altitude on the ground
  24199. * @param scene defines the hosting scene
  24200. * @param updatable defines if the mesh must be flagged as updatable
  24201. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24202. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24203. * @returns a new Mesh
  24204. */
  24205. 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;
  24206. /**
  24207. * Creates a tube mesh.
  24208. * The tube is a parametric shape.
  24209. * It has no predefined shape. Its final shape will depend on the input parameters.
  24210. * Please consider using the same method from the MeshBuilder class instead
  24211. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24212. * @param name defines the name of the mesh to create
  24213. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24214. * @param radius sets the tube radius size
  24215. * @param tessellation is the number of sides on the tubular surface
  24216. * @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
  24217. * @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
  24218. * @param scene defines the hosting scene
  24219. * @param updatable defines if the mesh must be flagged as updatable
  24220. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24221. * @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)
  24222. * @returns a new Mesh
  24223. */
  24224. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24225. (i: number, distance: number): number;
  24226. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24227. /**
  24228. * Creates a polyhedron mesh.
  24229. * Please consider using the same method from the MeshBuilder class instead.
  24230. * * 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
  24231. * * The parameter `size` (positive float, default 1) sets the polygon size
  24232. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24233. * * 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`
  24234. * * 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
  24235. * * 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)`)
  24236. * * 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
  24237. * * 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
  24238. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24239. * * 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
  24240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24241. * @param name defines the name of the mesh to create
  24242. * @param options defines the options used to create the mesh
  24243. * @param scene defines the hosting scene
  24244. * @returns a new Mesh
  24245. */
  24246. static CreatePolyhedron(name: string, options: {
  24247. type?: number;
  24248. size?: number;
  24249. sizeX?: number;
  24250. sizeY?: number;
  24251. sizeZ?: number;
  24252. custom?: any;
  24253. faceUV?: Vector4[];
  24254. faceColors?: Color4[];
  24255. updatable?: boolean;
  24256. sideOrientation?: number;
  24257. }, scene: Scene): Mesh;
  24258. /**
  24259. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24260. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24261. * * 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`)
  24262. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24263. * * 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
  24264. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24265. * * 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
  24266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24267. * @param name defines the name of the mesh
  24268. * @param options defines the options used to create the mesh
  24269. * @param scene defines the hosting scene
  24270. * @returns a new Mesh
  24271. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24272. */
  24273. static CreateIcoSphere(name: string, options: {
  24274. radius?: number;
  24275. flat?: boolean;
  24276. subdivisions?: number;
  24277. sideOrientation?: number;
  24278. updatable?: boolean;
  24279. }, scene: Scene): Mesh;
  24280. /**
  24281. * Creates a decal mesh.
  24282. * Please consider using the same method from the MeshBuilder class instead.
  24283. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24284. * @param name defines the name of the mesh
  24285. * @param sourceMesh defines the mesh receiving the decal
  24286. * @param position sets the position of the decal in world coordinates
  24287. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24288. * @param size sets the decal scaling
  24289. * @param angle sets the angle to rotate the decal
  24290. * @returns a new Mesh
  24291. */
  24292. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24293. /**
  24294. * Prepare internal position array for software CPU skinning
  24295. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24296. */
  24297. setPositionsForCPUSkinning(): Float32Array;
  24298. /**
  24299. * Prepare internal normal array for software CPU skinning
  24300. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24301. */
  24302. setNormalsForCPUSkinning(): Float32Array;
  24303. /**
  24304. * Updates the vertex buffer by applying transformation from the bones
  24305. * @param skeleton defines the skeleton to apply to current mesh
  24306. * @returns the current mesh
  24307. */
  24308. applySkeleton(skeleton: Skeleton): Mesh;
  24309. /**
  24310. * 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
  24311. * @param meshes defines the list of meshes to scan
  24312. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24313. */
  24314. static MinMax(meshes: AbstractMesh[]): {
  24315. min: Vector3;
  24316. max: Vector3;
  24317. };
  24318. /**
  24319. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24320. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24321. * @returns a vector3
  24322. */
  24323. static Center(meshesOrMinMaxVector: {
  24324. min: Vector3;
  24325. max: Vector3;
  24326. } | AbstractMesh[]): Vector3;
  24327. /**
  24328. * Merge the array of meshes into a single mesh for performance reasons.
  24329. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24330. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24331. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24332. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24333. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24334. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24335. * @returns a new mesh
  24336. */
  24337. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24338. /** @hidden */
  24339. addInstance(instance: InstancedMesh): void;
  24340. /** @hidden */
  24341. removeInstance(instance: InstancedMesh): void;
  24342. }
  24343. }
  24344. declare module BABYLON {
  24345. /**
  24346. * This is the base class of all the camera used in the application.
  24347. * @see http://doc.babylonjs.com/features/cameras
  24348. */
  24349. export class Camera extends Node {
  24350. /** @hidden */
  24351. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24352. /**
  24353. * This is the default projection mode used by the cameras.
  24354. * It helps recreating a feeling of perspective and better appreciate depth.
  24355. * This is the best way to simulate real life cameras.
  24356. */
  24357. static readonly PERSPECTIVE_CAMERA: number;
  24358. /**
  24359. * This helps creating camera with an orthographic mode.
  24360. * 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.
  24361. */
  24362. static readonly ORTHOGRAPHIC_CAMERA: number;
  24363. /**
  24364. * This is the default FOV mode for perspective cameras.
  24365. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24366. */
  24367. static readonly FOVMODE_VERTICAL_FIXED: number;
  24368. /**
  24369. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24370. */
  24371. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24372. /**
  24373. * This specifies ther is no need for a camera rig.
  24374. * Basically only one eye is rendered corresponding to the camera.
  24375. */
  24376. static readonly RIG_MODE_NONE: number;
  24377. /**
  24378. * Simulates a camera Rig with one blue eye and one red eye.
  24379. * This can be use with 3d blue and red glasses.
  24380. */
  24381. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24382. /**
  24383. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24384. */
  24385. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24386. /**
  24387. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24388. */
  24389. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24390. /**
  24391. * Defines that both eyes of the camera will be rendered over under each other.
  24392. */
  24393. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24394. /**
  24395. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24396. */
  24397. static readonly RIG_MODE_VR: number;
  24398. /**
  24399. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24400. */
  24401. static readonly RIG_MODE_WEBVR: number;
  24402. /**
  24403. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24404. */
  24405. static readonly RIG_MODE_CUSTOM: number;
  24406. /**
  24407. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24408. */
  24409. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24410. /**
  24411. * Define the input manager associated with the camera.
  24412. */
  24413. inputs: CameraInputsManager<Camera>;
  24414. /** @hidden */
  24415. _position: Vector3;
  24416. /**
  24417. * Define the current local position of the camera in the scene
  24418. */
  24419. position: Vector3;
  24420. /**
  24421. * The vector the camera should consider as up.
  24422. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24423. */
  24424. upVector: Vector3;
  24425. /**
  24426. * Define the current limit on the left side for an orthographic camera
  24427. * In scene unit
  24428. */
  24429. orthoLeft: Nullable<number>;
  24430. /**
  24431. * Define the current limit on the right side for an orthographic camera
  24432. * In scene unit
  24433. */
  24434. orthoRight: Nullable<number>;
  24435. /**
  24436. * Define the current limit on the bottom side for an orthographic camera
  24437. * In scene unit
  24438. */
  24439. orthoBottom: Nullable<number>;
  24440. /**
  24441. * Define the current limit on the top side for an orthographic camera
  24442. * In scene unit
  24443. */
  24444. orthoTop: Nullable<number>;
  24445. /**
  24446. * Field Of View is set in Radians. (default is 0.8)
  24447. */
  24448. fov: number;
  24449. /**
  24450. * Define the minimum distance the camera can see from.
  24451. * This is important to note that the depth buffer are not infinite and the closer it starts
  24452. * the more your scene might encounter depth fighting issue.
  24453. */
  24454. minZ: number;
  24455. /**
  24456. * Define the maximum distance the camera can see to.
  24457. * This is important to note that the depth buffer are not infinite and the further it end
  24458. * the more your scene might encounter depth fighting issue.
  24459. */
  24460. maxZ: number;
  24461. /**
  24462. * Define the default inertia of the camera.
  24463. * This helps giving a smooth feeling to the camera movement.
  24464. */
  24465. inertia: number;
  24466. /**
  24467. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24468. */
  24469. mode: number;
  24470. /**
  24471. * Define wether the camera is intermediate.
  24472. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24473. */
  24474. isIntermediate: boolean;
  24475. /**
  24476. * Define the viewport of the camera.
  24477. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24478. */
  24479. viewport: Viewport;
  24480. /**
  24481. * Restricts the camera to viewing objects with the same layerMask.
  24482. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24483. */
  24484. layerMask: number;
  24485. /**
  24486. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24487. */
  24488. fovMode: number;
  24489. /**
  24490. * Rig mode of the camera.
  24491. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24492. * This is normally controlled byt the camera themselves as internal use.
  24493. */
  24494. cameraRigMode: number;
  24495. /**
  24496. * Defines the distance between both "eyes" in case of a RIG
  24497. */
  24498. interaxialDistance: number;
  24499. /**
  24500. * Defines if stereoscopic rendering is done side by side or over under.
  24501. */
  24502. isStereoscopicSideBySide: boolean;
  24503. /**
  24504. * 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
  24505. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24506. * else in the scene. (Eg. security camera)
  24507. *
  24508. * 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)
  24509. */
  24510. customRenderTargets: RenderTargetTexture[];
  24511. /**
  24512. * When set, the camera will render to this render target instead of the default canvas
  24513. *
  24514. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24515. */
  24516. outputRenderTarget: Nullable<RenderTargetTexture>;
  24517. /**
  24518. * Observable triggered when the camera view matrix has changed.
  24519. */
  24520. onViewMatrixChangedObservable: Observable<Camera>;
  24521. /**
  24522. * Observable triggered when the camera Projection matrix has changed.
  24523. */
  24524. onProjectionMatrixChangedObservable: Observable<Camera>;
  24525. /**
  24526. * Observable triggered when the inputs have been processed.
  24527. */
  24528. onAfterCheckInputsObservable: Observable<Camera>;
  24529. /**
  24530. * Observable triggered when reset has been called and applied to the camera.
  24531. */
  24532. onRestoreStateObservable: Observable<Camera>;
  24533. /** @hidden */
  24534. _cameraRigParams: any;
  24535. /** @hidden */
  24536. _rigCameras: Camera[];
  24537. /** @hidden */
  24538. _rigPostProcess: Nullable<PostProcess>;
  24539. protected _webvrViewMatrix: Matrix;
  24540. /** @hidden */
  24541. _skipRendering: boolean;
  24542. /** @hidden */
  24543. _projectionMatrix: Matrix;
  24544. /** @hidden */
  24545. _postProcesses: Nullable<PostProcess>[];
  24546. /** @hidden */
  24547. _activeMeshes: SmartArray<AbstractMesh>;
  24548. protected _globalPosition: Vector3;
  24549. /** @hidden */
  24550. _computedViewMatrix: Matrix;
  24551. private _doNotComputeProjectionMatrix;
  24552. private _transformMatrix;
  24553. private _frustumPlanes;
  24554. private _refreshFrustumPlanes;
  24555. private _storedFov;
  24556. private _stateStored;
  24557. /**
  24558. * Instantiates a new camera object.
  24559. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24560. * @see http://doc.babylonjs.com/features/cameras
  24561. * @param name Defines the name of the camera in the scene
  24562. * @param position Defines the position of the camera
  24563. * @param scene Defines the scene the camera belongs too
  24564. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24565. */
  24566. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24567. /**
  24568. * Store current camera state (fov, position, etc..)
  24569. * @returns the camera
  24570. */
  24571. storeState(): Camera;
  24572. /**
  24573. * Restores the camera state values if it has been stored. You must call storeState() first
  24574. */
  24575. protected _restoreStateValues(): boolean;
  24576. /**
  24577. * Restored camera state. You must call storeState() first.
  24578. * @returns true if restored and false otherwise
  24579. */
  24580. restoreState(): boolean;
  24581. /**
  24582. * Gets the class name of the camera.
  24583. * @returns the class name
  24584. */
  24585. getClassName(): string;
  24586. /** @hidden */
  24587. readonly _isCamera: boolean;
  24588. /**
  24589. * Gets a string representation of the camera useful for debug purpose.
  24590. * @param fullDetails Defines that a more verboe level of logging is required
  24591. * @returns the string representation
  24592. */
  24593. toString(fullDetails?: boolean): string;
  24594. /**
  24595. * Gets the current world space position of the camera.
  24596. */
  24597. readonly globalPosition: Vector3;
  24598. /**
  24599. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24600. * @returns the active meshe list
  24601. */
  24602. getActiveMeshes(): SmartArray<AbstractMesh>;
  24603. /**
  24604. * Check wether a mesh is part of the current active mesh list of the camera
  24605. * @param mesh Defines the mesh to check
  24606. * @returns true if active, false otherwise
  24607. */
  24608. isActiveMesh(mesh: Mesh): boolean;
  24609. /**
  24610. * Is this camera ready to be used/rendered
  24611. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24612. * @return true if the camera is ready
  24613. */
  24614. isReady(completeCheck?: boolean): boolean;
  24615. /** @hidden */
  24616. _initCache(): void;
  24617. /** @hidden */
  24618. _updateCache(ignoreParentClass?: boolean): void;
  24619. /** @hidden */
  24620. _isSynchronized(): boolean;
  24621. /** @hidden */
  24622. _isSynchronizedViewMatrix(): boolean;
  24623. /** @hidden */
  24624. _isSynchronizedProjectionMatrix(): boolean;
  24625. /**
  24626. * Attach the input controls to a specific dom element to get the input from.
  24627. * @param element Defines the element the controls should be listened from
  24628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24629. */
  24630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24631. /**
  24632. * Detach the current controls from the specified dom element.
  24633. * @param element Defines the element to stop listening the inputs from
  24634. */
  24635. detachControl(element: HTMLElement): void;
  24636. /**
  24637. * Update the camera state according to the different inputs gathered during the frame.
  24638. */
  24639. update(): void;
  24640. /** @hidden */
  24641. _checkInputs(): void;
  24642. /** @hidden */
  24643. readonly rigCameras: Camera[];
  24644. /**
  24645. * Gets the post process used by the rig cameras
  24646. */
  24647. readonly rigPostProcess: Nullable<PostProcess>;
  24648. /**
  24649. * Internal, gets the first post proces.
  24650. * @returns the first post process to be run on this camera.
  24651. */
  24652. _getFirstPostProcess(): Nullable<PostProcess>;
  24653. private _cascadePostProcessesToRigCams;
  24654. /**
  24655. * Attach a post process to the camera.
  24656. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24657. * @param postProcess The post process to attach to the camera
  24658. * @param insertAt The position of the post process in case several of them are in use in the scene
  24659. * @returns the position the post process has been inserted at
  24660. */
  24661. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24662. /**
  24663. * Detach a post process to the camera.
  24664. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24665. * @param postProcess The post process to detach from the camera
  24666. */
  24667. detachPostProcess(postProcess: PostProcess): void;
  24668. /**
  24669. * Gets the current world matrix of the camera
  24670. */
  24671. getWorldMatrix(): Matrix;
  24672. /** @hidden */
  24673. _getViewMatrix(): Matrix;
  24674. /**
  24675. * Gets the current view matrix of the camera.
  24676. * @param force forces the camera to recompute the matrix without looking at the cached state
  24677. * @returns the view matrix
  24678. */
  24679. getViewMatrix(force?: boolean): Matrix;
  24680. /**
  24681. * Freeze the projection matrix.
  24682. * It will prevent the cache check of the camera projection compute and can speed up perf
  24683. * if no parameter of the camera are meant to change
  24684. * @param projection Defines manually a projection if necessary
  24685. */
  24686. freezeProjectionMatrix(projection?: Matrix): void;
  24687. /**
  24688. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24689. */
  24690. unfreezeProjectionMatrix(): void;
  24691. /**
  24692. * Gets the current projection matrix of the camera.
  24693. * @param force forces the camera to recompute the matrix without looking at the cached state
  24694. * @returns the projection matrix
  24695. */
  24696. getProjectionMatrix(force?: boolean): Matrix;
  24697. /**
  24698. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24699. * @returns a Matrix
  24700. */
  24701. getTransformationMatrix(): Matrix;
  24702. private _updateFrustumPlanes;
  24703. /**
  24704. * Checks if a cullable object (mesh...) is in the camera frustum
  24705. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24706. * @param target The object to check
  24707. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24708. * @returns true if the object is in frustum otherwise false
  24709. */
  24710. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24711. /**
  24712. * Checks if a cullable object (mesh...) is in the camera frustum
  24713. * Unlike isInFrustum this cheks the full bounding box
  24714. * @param target The object to check
  24715. * @returns true if the object is in frustum otherwise false
  24716. */
  24717. isCompletelyInFrustum(target: ICullable): boolean;
  24718. /**
  24719. * Gets a ray in the forward direction from the camera.
  24720. * @param length Defines the length of the ray to create
  24721. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24722. * @param origin Defines the start point of the ray which defaults to the camera position
  24723. * @returns the forward ray
  24724. */
  24725. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24726. /**
  24727. * Releases resources associated with this node.
  24728. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24729. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24730. */
  24731. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24732. /** @hidden */
  24733. _isLeftCamera: boolean;
  24734. /**
  24735. * Gets the left camera of a rig setup in case of Rigged Camera
  24736. */
  24737. readonly isLeftCamera: boolean;
  24738. /** @hidden */
  24739. _isRightCamera: boolean;
  24740. /**
  24741. * Gets the right camera of a rig setup in case of Rigged Camera
  24742. */
  24743. readonly isRightCamera: boolean;
  24744. /**
  24745. * Gets the left camera of a rig setup in case of Rigged Camera
  24746. */
  24747. readonly leftCamera: Nullable<FreeCamera>;
  24748. /**
  24749. * Gets the right camera of a rig setup in case of Rigged Camera
  24750. */
  24751. readonly rightCamera: Nullable<FreeCamera>;
  24752. /**
  24753. * Gets the left camera target of a rig setup in case of Rigged Camera
  24754. * @returns the target position
  24755. */
  24756. getLeftTarget(): Nullable<Vector3>;
  24757. /**
  24758. * Gets the right camera target of a rig setup in case of Rigged Camera
  24759. * @returns the target position
  24760. */
  24761. getRightTarget(): Nullable<Vector3>;
  24762. /**
  24763. * @hidden
  24764. */
  24765. setCameraRigMode(mode: number, rigParams: any): void;
  24766. /** @hidden */
  24767. static _setStereoscopicRigMode(camera: Camera): void;
  24768. /** @hidden */
  24769. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24770. /** @hidden */
  24771. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24772. /** @hidden */
  24773. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24774. /** @hidden */
  24775. _getVRProjectionMatrix(): Matrix;
  24776. protected _updateCameraRotationMatrix(): void;
  24777. protected _updateWebVRCameraRotationMatrix(): void;
  24778. /**
  24779. * This function MUST be overwritten by the different WebVR cameras available.
  24780. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24781. * @hidden
  24782. */
  24783. _getWebVRProjectionMatrix(): Matrix;
  24784. /**
  24785. * This function MUST be overwritten by the different WebVR cameras available.
  24786. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24787. * @hidden
  24788. */
  24789. _getWebVRViewMatrix(): Matrix;
  24790. /** @hidden */
  24791. setCameraRigParameter(name: string, value: any): void;
  24792. /**
  24793. * needs to be overridden by children so sub has required properties to be copied
  24794. * @hidden
  24795. */
  24796. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24797. /**
  24798. * May need to be overridden by children
  24799. * @hidden
  24800. */
  24801. _updateRigCameras(): void;
  24802. /** @hidden */
  24803. _setupInputs(): void;
  24804. /**
  24805. * Serialiaze the camera setup to a json represention
  24806. * @returns the JSON representation
  24807. */
  24808. serialize(): any;
  24809. /**
  24810. * Clones the current camera.
  24811. * @param name The cloned camera name
  24812. * @returns the cloned camera
  24813. */
  24814. clone(name: string): Camera;
  24815. /**
  24816. * Gets the direction of the camera relative to a given local axis.
  24817. * @param localAxis Defines the reference axis to provide a relative direction.
  24818. * @return the direction
  24819. */
  24820. getDirection(localAxis: Vector3): Vector3;
  24821. /**
  24822. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24823. * @param localAxis Defines the reference axis to provide a relative direction.
  24824. * @param result Defines the vector to store the result in
  24825. */
  24826. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24827. /**
  24828. * Gets a camera constructor for a given camera type
  24829. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24830. * @param name The name of the camera the result will be able to instantiate
  24831. * @param scene The scene the result will construct the camera in
  24832. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24833. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24834. * @returns a factory method to construc the camera
  24835. */
  24836. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24837. /**
  24838. * Compute the world matrix of the camera.
  24839. * @returns the camera workd matrix
  24840. */
  24841. computeWorldMatrix(): Matrix;
  24842. /**
  24843. * Parse a JSON and creates the camera from the parsed information
  24844. * @param parsedCamera The JSON to parse
  24845. * @param scene The scene to instantiate the camera in
  24846. * @returns the newly constructed camera
  24847. */
  24848. static Parse(parsedCamera: any, scene: Scene): Camera;
  24849. }
  24850. }
  24851. declare module BABYLON {
  24852. /**
  24853. * Class containing static functions to help procedurally build meshes
  24854. */
  24855. export class DiscBuilder {
  24856. /**
  24857. * Creates a plane polygonal mesh. By default, this is a disc
  24858. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24859. * * 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
  24860. * * 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
  24861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24862. * * 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
  24863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24864. * @param name defines the name of the mesh
  24865. * @param options defines the options used to create the mesh
  24866. * @param scene defines the hosting scene
  24867. * @returns the plane polygonal mesh
  24868. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24869. */
  24870. static CreateDisc(name: string, options: {
  24871. radius?: number;
  24872. tessellation?: number;
  24873. arc?: number;
  24874. updatable?: boolean;
  24875. sideOrientation?: number;
  24876. frontUVs?: Vector4;
  24877. backUVs?: Vector4;
  24878. }, scene?: Nullable<Scene>): Mesh;
  24879. }
  24880. }
  24881. declare module BABYLON {
  24882. /**
  24883. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24884. *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.
  24885. * The SPS is also a particle system. It provides some methods to manage the particles.
  24886. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24887. *
  24888. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24889. */
  24890. export class SolidParticleSystem implements IDisposable {
  24891. /**
  24892. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24893. * Example : var p = SPS.particles[i];
  24894. */
  24895. particles: SolidParticle[];
  24896. /**
  24897. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24898. */
  24899. nbParticles: number;
  24900. /**
  24901. * If the particles must ever face the camera (default false). Useful for planar particles.
  24902. */
  24903. billboard: boolean;
  24904. /**
  24905. * Recompute normals when adding a shape
  24906. */
  24907. recomputeNormals: boolean;
  24908. /**
  24909. * This a counter ofr your own usage. It's not set by any SPS functions.
  24910. */
  24911. counter: number;
  24912. /**
  24913. * The SPS name. This name is also given to the underlying mesh.
  24914. */
  24915. name: string;
  24916. /**
  24917. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24918. */
  24919. mesh: Mesh;
  24920. /**
  24921. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24922. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24923. */
  24924. vars: any;
  24925. /**
  24926. * This array is populated when the SPS is set as 'pickable'.
  24927. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24928. * Each element of this array is an object `{idx: int, faceId: int}`.
  24929. * `idx` is the picked particle index in the `SPS.particles` array
  24930. * `faceId` is the picked face index counted within this particle.
  24931. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24932. */
  24933. pickedParticles: {
  24934. idx: number;
  24935. faceId: number;
  24936. }[];
  24937. /**
  24938. * This array is populated when `enableDepthSort` is set to true.
  24939. * Each element of this array is an instance of the class DepthSortedParticle.
  24940. */
  24941. depthSortedParticles: DepthSortedParticle[];
  24942. /**
  24943. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24944. * @hidden
  24945. */
  24946. _bSphereOnly: boolean;
  24947. /**
  24948. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24949. * @hidden
  24950. */
  24951. _bSphereRadiusFactor: number;
  24952. private _scene;
  24953. private _positions;
  24954. private _indices;
  24955. private _normals;
  24956. private _colors;
  24957. private _uvs;
  24958. private _indices32;
  24959. private _positions32;
  24960. private _normals32;
  24961. private _fixedNormal32;
  24962. private _colors32;
  24963. private _uvs32;
  24964. private _index;
  24965. private _updatable;
  24966. private _pickable;
  24967. private _isVisibilityBoxLocked;
  24968. private _alwaysVisible;
  24969. private _depthSort;
  24970. private _shapeCounter;
  24971. private _copy;
  24972. private _color;
  24973. private _computeParticleColor;
  24974. private _computeParticleTexture;
  24975. private _computeParticleRotation;
  24976. private _computeParticleVertex;
  24977. private _computeBoundingBox;
  24978. private _depthSortParticles;
  24979. private _camera;
  24980. private _mustUnrotateFixedNormals;
  24981. private _particlesIntersect;
  24982. private _needs32Bits;
  24983. /**
  24984. * Creates a SPS (Solid Particle System) object.
  24985. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24986. * @param scene (Scene) is the scene in which the SPS is added.
  24987. * @param options defines the options of the sps e.g.
  24988. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24989. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24990. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24991. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24992. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24993. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24994. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24995. */
  24996. constructor(name: string, scene: Scene, options?: {
  24997. updatable?: boolean;
  24998. isPickable?: boolean;
  24999. enableDepthSort?: boolean;
  25000. particleIntersection?: boolean;
  25001. boundingSphereOnly?: boolean;
  25002. bSphereRadiusFactor?: number;
  25003. });
  25004. /**
  25005. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25006. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25007. * @returns the created mesh
  25008. */
  25009. buildMesh(): Mesh;
  25010. /**
  25011. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25012. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25013. * Thus the particles generated from `digest()` have their property `position` set yet.
  25014. * @param mesh ( Mesh ) is the mesh to be digested
  25015. * @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
  25016. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25017. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25018. * @returns the current SPS
  25019. */
  25020. digest(mesh: Mesh, options?: {
  25021. facetNb?: number;
  25022. number?: number;
  25023. delta?: number;
  25024. }): SolidParticleSystem;
  25025. private _unrotateFixedNormals;
  25026. private _resetCopy;
  25027. private _meshBuilder;
  25028. private _posToShape;
  25029. private _uvsToShapeUV;
  25030. private _addParticle;
  25031. /**
  25032. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25033. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  25034. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25035. * @param nb (positive integer) the number of particles to be created from this model
  25036. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25037. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25038. * @returns the number of shapes in the system
  25039. */
  25040. addShape(mesh: Mesh, nb: number, options?: {
  25041. positionFunction?: any;
  25042. vertexFunction?: any;
  25043. }): number;
  25044. private _rebuildParticle;
  25045. /**
  25046. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25047. * @returns the SPS.
  25048. */
  25049. rebuildMesh(): SolidParticleSystem;
  25050. /**
  25051. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25052. * This method calls `updateParticle()` for each particle of the SPS.
  25053. * For an animated SPS, it is usually called within the render loop.
  25054. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25055. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25056. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25057. * @returns the SPS.
  25058. */
  25059. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25060. /**
  25061. * Disposes the SPS.
  25062. */
  25063. dispose(): void;
  25064. /**
  25065. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25066. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25067. * @returns the SPS.
  25068. */
  25069. refreshVisibleSize(): SolidParticleSystem;
  25070. /**
  25071. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25072. * @param size the size (float) of the visibility box
  25073. * note : this doesn't lock the SPS mesh bounding box.
  25074. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25075. */
  25076. setVisibilityBox(size: number): void;
  25077. /**
  25078. * Gets whether the SPS as always visible or not
  25079. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25080. */
  25081. /**
  25082. * Sets the SPS as always visible or not
  25083. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25084. */
  25085. isAlwaysVisible: boolean;
  25086. /**
  25087. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25088. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25089. */
  25090. /**
  25091. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25092. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25093. */
  25094. isVisibilityBoxLocked: boolean;
  25095. /**
  25096. * Tells to `setParticles()` to compute the particle rotations or not.
  25097. * Default value : true. The SPS is faster when it's set to false.
  25098. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25099. */
  25100. /**
  25101. * Gets if `setParticles()` computes the particle rotations or not.
  25102. * Default value : true. The SPS is faster when it's set to false.
  25103. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25104. */
  25105. computeParticleRotation: boolean;
  25106. /**
  25107. * Tells to `setParticles()` to compute the particle colors or not.
  25108. * Default value : true. The SPS is faster when it's set to false.
  25109. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25110. */
  25111. /**
  25112. * Gets if `setParticles()` computes the particle colors or not.
  25113. * Default value : true. The SPS is faster when it's set to false.
  25114. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25115. */
  25116. computeParticleColor: boolean;
  25117. /**
  25118. * Gets if `setParticles()` computes the particle textures or not.
  25119. * Default value : true. The SPS is faster when it's set to false.
  25120. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25121. */
  25122. computeParticleTexture: boolean;
  25123. /**
  25124. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25125. * Default value : false. The SPS is faster when it's set to false.
  25126. * Note : the particle custom vertex positions aren't stored values.
  25127. */
  25128. /**
  25129. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25130. * Default value : false. The SPS is faster when it's set to false.
  25131. * Note : the particle custom vertex positions aren't stored values.
  25132. */
  25133. computeParticleVertex: boolean;
  25134. /**
  25135. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25136. */
  25137. /**
  25138. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25139. */
  25140. computeBoundingBox: boolean;
  25141. /**
  25142. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25143. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25144. * Default : `true`
  25145. */
  25146. /**
  25147. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25148. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25149. * Default : `true`
  25150. */
  25151. depthSortParticles: boolean;
  25152. /**
  25153. * This function does nothing. It may be overwritten to set all the particle first values.
  25154. * The SPS doesn't call this function, you may have to call it by your own.
  25155. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25156. */
  25157. initParticles(): void;
  25158. /**
  25159. * This function does nothing. It may be overwritten to recycle a particle.
  25160. * The SPS doesn't call this function, you may have to call it by your own.
  25161. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25162. * @param particle The particle to recycle
  25163. * @returns the recycled particle
  25164. */
  25165. recycleParticle(particle: SolidParticle): SolidParticle;
  25166. /**
  25167. * Updates a particle : this function should be overwritten by the user.
  25168. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25169. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25170. * @example : just set a particle position or velocity and recycle conditions
  25171. * @param particle The particle to update
  25172. * @returns the updated particle
  25173. */
  25174. updateParticle(particle: SolidParticle): SolidParticle;
  25175. /**
  25176. * Updates a vertex of a particle : it can be overwritten by the user.
  25177. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25178. * @param particle the current particle
  25179. * @param vertex the current index of the current particle
  25180. * @param pt the index of the current vertex in the particle shape
  25181. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  25182. * @example : just set a vertex particle position
  25183. * @returns the updated vertex
  25184. */
  25185. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25186. /**
  25187. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25188. * This does nothing and may be overwritten by the user.
  25189. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25190. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25191. * @param update the boolean update value actually passed to setParticles()
  25192. */
  25193. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25194. /**
  25195. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25196. * This will be passed three parameters.
  25197. * This does nothing and may be overwritten by the user.
  25198. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25199. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25200. * @param update the boolean update value actually passed to setParticles()
  25201. */
  25202. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25203. }
  25204. }
  25205. declare module BABYLON {
  25206. /**
  25207. * Represents one particle of a solid particle system.
  25208. */
  25209. export class SolidParticle {
  25210. /**
  25211. * particle global index
  25212. */
  25213. idx: number;
  25214. /**
  25215. * The color of the particle
  25216. */
  25217. color: Nullable<Color4>;
  25218. /**
  25219. * The world space position of the particle.
  25220. */
  25221. position: Vector3;
  25222. /**
  25223. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25224. */
  25225. rotation: Vector3;
  25226. /**
  25227. * The world space rotation quaternion of the particle.
  25228. */
  25229. rotationQuaternion: Nullable<Quaternion>;
  25230. /**
  25231. * The scaling of the particle.
  25232. */
  25233. scaling: Vector3;
  25234. /**
  25235. * The uvs of the particle.
  25236. */
  25237. uvs: Vector4;
  25238. /**
  25239. * The current speed of the particle.
  25240. */
  25241. velocity: Vector3;
  25242. /**
  25243. * The pivot point in the particle local space.
  25244. */
  25245. pivot: Vector3;
  25246. /**
  25247. * Must the particle be translated from its pivot point in its local space ?
  25248. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25249. * Default : false
  25250. */
  25251. translateFromPivot: boolean;
  25252. /**
  25253. * Is the particle active or not ?
  25254. */
  25255. alive: boolean;
  25256. /**
  25257. * Is the particle visible or not ?
  25258. */
  25259. isVisible: boolean;
  25260. /**
  25261. * Index of this particle in the global "positions" array (Internal use)
  25262. * @hidden
  25263. */
  25264. _pos: number;
  25265. /**
  25266. * @hidden Index of this particle in the global "indices" array (Internal use)
  25267. */
  25268. _ind: number;
  25269. /**
  25270. * @hidden ModelShape of this particle (Internal use)
  25271. */
  25272. _model: ModelShape;
  25273. /**
  25274. * ModelShape id of this particle
  25275. */
  25276. shapeId: number;
  25277. /**
  25278. * Index of the particle in its shape id (Internal use)
  25279. */
  25280. idxInShape: number;
  25281. /**
  25282. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25283. */
  25284. _modelBoundingInfo: BoundingInfo;
  25285. /**
  25286. * @hidden Particle BoundingInfo object (Internal use)
  25287. */
  25288. _boundingInfo: BoundingInfo;
  25289. /**
  25290. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25291. */
  25292. _sps: SolidParticleSystem;
  25293. /**
  25294. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25295. */
  25296. _stillInvisible: boolean;
  25297. /**
  25298. * @hidden Last computed particle rotation matrix
  25299. */
  25300. _rotationMatrix: number[];
  25301. /**
  25302. * Parent particle Id, if any.
  25303. * Default null.
  25304. */
  25305. parentId: Nullable<number>;
  25306. /**
  25307. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25308. * The possible values are :
  25309. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25310. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25311. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25312. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25313. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25314. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25315. * */
  25316. cullingStrategy: number;
  25317. /**
  25318. * @hidden Internal global position in the SPS.
  25319. */
  25320. _globalPosition: Vector3;
  25321. /**
  25322. * Creates a Solid Particle object.
  25323. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25324. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25325. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25326. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25327. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25328. * @param shapeId (integer) is the model shape identifier in the SPS.
  25329. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25330. * @param sps defines the sps it is associated to
  25331. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25332. */
  25333. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25334. /**
  25335. * Legacy support, changed scale to scaling
  25336. */
  25337. /**
  25338. * Legacy support, changed scale to scaling
  25339. */
  25340. scale: Vector3;
  25341. /**
  25342. * Legacy support, changed quaternion to rotationQuaternion
  25343. */
  25344. /**
  25345. * Legacy support, changed quaternion to rotationQuaternion
  25346. */
  25347. quaternion: Nullable<Quaternion>;
  25348. /**
  25349. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25350. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25351. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25352. * @returns true if it intersects
  25353. */
  25354. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25355. /**
  25356. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25357. * A particle is in the frustum if its bounding box intersects the frustum
  25358. * @param frustumPlanes defines the frustum to test
  25359. * @returns true if the particle is in the frustum planes
  25360. */
  25361. isInFrustum(frustumPlanes: Plane[]): boolean;
  25362. /**
  25363. * get the rotation matrix of the particle
  25364. * @hidden
  25365. */
  25366. getRotationMatrix(m: Matrix): void;
  25367. }
  25368. /**
  25369. * Represents the shape of the model used by one particle of a solid particle system.
  25370. * SPS internal tool, don't use it manually.
  25371. */
  25372. export class ModelShape {
  25373. /**
  25374. * The shape id
  25375. * @hidden
  25376. */
  25377. shapeID: number;
  25378. /**
  25379. * flat array of model positions (internal use)
  25380. * @hidden
  25381. */
  25382. _shape: Vector3[];
  25383. /**
  25384. * flat array of model UVs (internal use)
  25385. * @hidden
  25386. */
  25387. _shapeUV: number[];
  25388. /**
  25389. * length of the shape in the model indices array (internal use)
  25390. * @hidden
  25391. */
  25392. _indicesLength: number;
  25393. /**
  25394. * Custom position function (internal use)
  25395. * @hidden
  25396. */
  25397. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25398. /**
  25399. * Custom vertex function (internal use)
  25400. * @hidden
  25401. */
  25402. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25403. /**
  25404. * 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.
  25405. * SPS internal tool, don't use it manually.
  25406. * @hidden
  25407. */
  25408. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25409. }
  25410. /**
  25411. * Represents a Depth Sorted Particle in the solid particle system.
  25412. */
  25413. export class DepthSortedParticle {
  25414. /**
  25415. * Index of the particle in the "indices" array
  25416. */
  25417. ind: number;
  25418. /**
  25419. * Length of the particle shape in the "indices" array
  25420. */
  25421. indicesLength: number;
  25422. /**
  25423. * Squared distance from the particle to the camera
  25424. */
  25425. sqDistance: number;
  25426. }
  25427. }
  25428. declare module BABYLON {
  25429. /**
  25430. * @hidden
  25431. */
  25432. export class _MeshCollisionData {
  25433. _checkCollisions: boolean;
  25434. _collisionMask: number;
  25435. _collisionGroup: number;
  25436. _collider: Nullable<Collider>;
  25437. _oldPositionForCollisions: Vector3;
  25438. _diffPositionForCollisions: Vector3;
  25439. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25440. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25441. }
  25442. }
  25443. declare module BABYLON {
  25444. /** @hidden */
  25445. class _FacetDataStorage {
  25446. facetPositions: Vector3[];
  25447. facetNormals: Vector3[];
  25448. facetPartitioning: number[][];
  25449. facetNb: number;
  25450. partitioningSubdivisions: number;
  25451. partitioningBBoxRatio: number;
  25452. facetDataEnabled: boolean;
  25453. facetParameters: any;
  25454. bbSize: Vector3;
  25455. subDiv: {
  25456. max: number;
  25457. X: number;
  25458. Y: number;
  25459. Z: number;
  25460. };
  25461. facetDepthSort: boolean;
  25462. facetDepthSortEnabled: boolean;
  25463. depthSortedIndices: IndicesArray;
  25464. depthSortedFacets: {
  25465. ind: number;
  25466. sqDistance: number;
  25467. }[];
  25468. facetDepthSortFunction: (f1: {
  25469. ind: number;
  25470. sqDistance: number;
  25471. }, f2: {
  25472. ind: number;
  25473. sqDistance: number;
  25474. }) => number;
  25475. facetDepthSortFrom: Vector3;
  25476. facetDepthSortOrigin: Vector3;
  25477. invertedMatrix: Matrix;
  25478. }
  25479. /**
  25480. * @hidden
  25481. **/
  25482. class _InternalAbstractMeshDataInfo {
  25483. _hasVertexAlpha: boolean;
  25484. _useVertexColors: boolean;
  25485. _numBoneInfluencers: number;
  25486. _applyFog: boolean;
  25487. _receiveShadows: boolean;
  25488. _facetData: _FacetDataStorage;
  25489. _visibility: number;
  25490. _skeleton: Nullable<Skeleton>;
  25491. _layerMask: number;
  25492. _computeBonesUsingShaders: boolean;
  25493. _isActive: boolean;
  25494. _onlyForInstances: boolean;
  25495. _isActiveIntermediate: boolean;
  25496. _onlyForInstancesIntermediate: boolean;
  25497. }
  25498. /**
  25499. * Class used to store all common mesh properties
  25500. */
  25501. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25502. /** No occlusion */
  25503. static OCCLUSION_TYPE_NONE: number;
  25504. /** Occlusion set to optimisitic */
  25505. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25506. /** Occlusion set to strict */
  25507. static OCCLUSION_TYPE_STRICT: number;
  25508. /** Use an accurante occlusion algorithm */
  25509. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25510. /** Use a conservative occlusion algorithm */
  25511. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25512. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25513. * Test order :
  25514. * Is the bounding sphere outside the frustum ?
  25515. * If not, are the bounding box vertices outside the frustum ?
  25516. * It not, then the cullable object is in the frustum.
  25517. */
  25518. static readonly CULLINGSTRATEGY_STANDARD: number;
  25519. /** Culling strategy : Bounding Sphere Only.
  25520. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25521. * It's also less accurate than the standard because some not visible objects can still be selected.
  25522. * Test : is the bounding sphere outside the frustum ?
  25523. * If not, then the cullable object is in the frustum.
  25524. */
  25525. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25526. /** Culling strategy : Optimistic Inclusion.
  25527. * This in an inclusion test first, then the standard exclusion test.
  25528. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25529. * 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.
  25530. * Anyway, it's as accurate as the standard strategy.
  25531. * Test :
  25532. * Is the cullable object bounding sphere center in the frustum ?
  25533. * If not, apply the default culling strategy.
  25534. */
  25535. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25536. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25537. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25538. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25539. * 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.
  25540. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25541. * Test :
  25542. * Is the cullable object bounding sphere center in the frustum ?
  25543. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25544. */
  25545. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25546. /**
  25547. * No billboard
  25548. */
  25549. static readonly BILLBOARDMODE_NONE: number;
  25550. /** Billboard on X axis */
  25551. static readonly BILLBOARDMODE_X: number;
  25552. /** Billboard on Y axis */
  25553. static readonly BILLBOARDMODE_Y: number;
  25554. /** Billboard on Z axis */
  25555. static readonly BILLBOARDMODE_Z: number;
  25556. /** Billboard on all axes */
  25557. static readonly BILLBOARDMODE_ALL: number;
  25558. /** @hidden */
  25559. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25560. /**
  25561. * The culling strategy to use to check whether the mesh must be rendered or not.
  25562. * This value can be changed at any time and will be used on the next render mesh selection.
  25563. * The possible values are :
  25564. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25565. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25566. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25567. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25568. * Please read each static variable documentation to get details about the culling process.
  25569. * */
  25570. cullingStrategy: number;
  25571. /**
  25572. * Gets the number of facets in the mesh
  25573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25574. */
  25575. readonly facetNb: number;
  25576. /**
  25577. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25578. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25579. */
  25580. partitioningSubdivisions: number;
  25581. /**
  25582. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25583. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25584. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25585. */
  25586. partitioningBBoxRatio: number;
  25587. /**
  25588. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25589. * Works only for updatable meshes.
  25590. * Doesn't work with multi-materials
  25591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25592. */
  25593. mustDepthSortFacets: boolean;
  25594. /**
  25595. * The location (Vector3) where the facet depth sort must be computed from.
  25596. * By default, the active camera position.
  25597. * Used only when facet depth sort is enabled
  25598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25599. */
  25600. facetDepthSortFrom: Vector3;
  25601. /**
  25602. * gets a boolean indicating if facetData is enabled
  25603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25604. */
  25605. readonly isFacetDataEnabled: boolean;
  25606. /** @hidden */
  25607. _updateNonUniformScalingState(value: boolean): boolean;
  25608. /**
  25609. * An event triggered when this mesh collides with another one
  25610. */
  25611. onCollideObservable: Observable<AbstractMesh>;
  25612. /** Set a function to call when this mesh collides with another one */
  25613. onCollide: () => void;
  25614. /**
  25615. * An event triggered when the collision's position changes
  25616. */
  25617. onCollisionPositionChangeObservable: Observable<Vector3>;
  25618. /** Set a function to call when the collision's position changes */
  25619. onCollisionPositionChange: () => void;
  25620. /**
  25621. * An event triggered when material is changed
  25622. */
  25623. onMaterialChangedObservable: Observable<AbstractMesh>;
  25624. /**
  25625. * Gets or sets the orientation for POV movement & rotation
  25626. */
  25627. definedFacingForward: boolean;
  25628. /** @hidden */
  25629. _occlusionQuery: Nullable<WebGLQuery>;
  25630. /** @hidden */
  25631. _renderingGroup: Nullable<RenderingGroup>;
  25632. /**
  25633. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25634. */
  25635. /**
  25636. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25637. */
  25638. visibility: number;
  25639. /** Gets or sets the alpha index used to sort transparent meshes
  25640. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25641. */
  25642. alphaIndex: number;
  25643. /**
  25644. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25645. */
  25646. isVisible: boolean;
  25647. /**
  25648. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25649. */
  25650. isPickable: boolean;
  25651. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25652. showSubMeshesBoundingBox: boolean;
  25653. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25654. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25655. */
  25656. isBlocker: boolean;
  25657. /**
  25658. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25659. */
  25660. enablePointerMoveEvents: boolean;
  25661. /**
  25662. * Specifies the rendering group id for this mesh (0 by default)
  25663. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25664. */
  25665. renderingGroupId: number;
  25666. private _material;
  25667. /** Gets or sets current material */
  25668. material: Nullable<Material>;
  25669. /**
  25670. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25671. * @see http://doc.babylonjs.com/babylon101/shadows
  25672. */
  25673. receiveShadows: boolean;
  25674. /** Defines color to use when rendering outline */
  25675. outlineColor: Color3;
  25676. /** Define width to use when rendering outline */
  25677. outlineWidth: number;
  25678. /** Defines color to use when rendering overlay */
  25679. overlayColor: Color3;
  25680. /** Defines alpha to use when rendering overlay */
  25681. overlayAlpha: number;
  25682. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25683. hasVertexAlpha: boolean;
  25684. /** 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) */
  25685. useVertexColors: boolean;
  25686. /**
  25687. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25688. */
  25689. computeBonesUsingShaders: boolean;
  25690. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25691. numBoneInfluencers: number;
  25692. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25693. applyFog: boolean;
  25694. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25695. useOctreeForRenderingSelection: boolean;
  25696. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25697. useOctreeForPicking: boolean;
  25698. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25699. useOctreeForCollisions: boolean;
  25700. /**
  25701. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25702. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25703. */
  25704. layerMask: number;
  25705. /**
  25706. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25707. */
  25708. alwaysSelectAsActiveMesh: boolean;
  25709. /**
  25710. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25711. */
  25712. doNotSyncBoundingInfo: boolean;
  25713. /**
  25714. * Gets or sets the current action manager
  25715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25716. */
  25717. actionManager: Nullable<AbstractActionManager>;
  25718. private _meshCollisionData;
  25719. /**
  25720. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25721. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25722. */
  25723. ellipsoid: Vector3;
  25724. /**
  25725. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25726. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25727. */
  25728. ellipsoidOffset: Vector3;
  25729. /**
  25730. * Gets or sets a collision mask used to mask collisions (default is -1).
  25731. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25732. */
  25733. collisionMask: number;
  25734. /**
  25735. * Gets or sets the current collision group mask (-1 by default).
  25736. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25737. */
  25738. collisionGroup: number;
  25739. /**
  25740. * Defines edge width used when edgesRenderer is enabled
  25741. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25742. */
  25743. edgesWidth: number;
  25744. /**
  25745. * Defines edge color used when edgesRenderer is enabled
  25746. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25747. */
  25748. edgesColor: Color4;
  25749. /** @hidden */
  25750. _edgesRenderer: Nullable<IEdgesRenderer>;
  25751. /** @hidden */
  25752. _masterMesh: Nullable<AbstractMesh>;
  25753. /** @hidden */
  25754. _boundingInfo: Nullable<BoundingInfo>;
  25755. /** @hidden */
  25756. _renderId: number;
  25757. /**
  25758. * Gets or sets the list of subMeshes
  25759. * @see http://doc.babylonjs.com/how_to/multi_materials
  25760. */
  25761. subMeshes: SubMesh[];
  25762. /** @hidden */
  25763. _intersectionsInProgress: AbstractMesh[];
  25764. /** @hidden */
  25765. _unIndexed: boolean;
  25766. /** @hidden */
  25767. _lightSources: Light[];
  25768. /** Gets the list of lights affecting that mesh */
  25769. readonly lightSources: Light[];
  25770. /** @hidden */
  25771. readonly _positions: Nullable<Vector3[]>;
  25772. /** @hidden */
  25773. _waitingData: {
  25774. lods: Nullable<any>;
  25775. actions: Nullable<any>;
  25776. freezeWorldMatrix: Nullable<boolean>;
  25777. };
  25778. /** @hidden */
  25779. _bonesTransformMatrices: Nullable<Float32Array>;
  25780. /** @hidden */
  25781. _transformMatrixTexture: Nullable<RawTexture>;
  25782. /**
  25783. * Gets or sets a skeleton to apply skining transformations
  25784. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25785. */
  25786. skeleton: Nullable<Skeleton>;
  25787. /**
  25788. * An event triggered when the mesh is rebuilt.
  25789. */
  25790. onRebuildObservable: Observable<AbstractMesh>;
  25791. /**
  25792. * Creates a new AbstractMesh
  25793. * @param name defines the name of the mesh
  25794. * @param scene defines the hosting scene
  25795. */
  25796. constructor(name: string, scene?: Nullable<Scene>);
  25797. /**
  25798. * Returns the string "AbstractMesh"
  25799. * @returns "AbstractMesh"
  25800. */
  25801. getClassName(): string;
  25802. /**
  25803. * Gets a string representation of the current mesh
  25804. * @param fullDetails defines a boolean indicating if full details must be included
  25805. * @returns a string representation of the current mesh
  25806. */
  25807. toString(fullDetails?: boolean): string;
  25808. /**
  25809. * @hidden
  25810. */
  25811. protected _getEffectiveParent(): Nullable<Node>;
  25812. /** @hidden */
  25813. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25814. /** @hidden */
  25815. _rebuild(): void;
  25816. /** @hidden */
  25817. _resyncLightSources(): void;
  25818. /** @hidden */
  25819. _resyncLighSource(light: Light): void;
  25820. /** @hidden */
  25821. _unBindEffect(): void;
  25822. /** @hidden */
  25823. _removeLightSource(light: Light): void;
  25824. private _markSubMeshesAsDirty;
  25825. /** @hidden */
  25826. _markSubMeshesAsLightDirty(): void;
  25827. /** @hidden */
  25828. _markSubMeshesAsAttributesDirty(): void;
  25829. /** @hidden */
  25830. _markSubMeshesAsMiscDirty(): void;
  25831. /**
  25832. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25833. */
  25834. scaling: Vector3;
  25835. /**
  25836. * Returns true if the mesh is blocked. Implemented by child classes
  25837. */
  25838. readonly isBlocked: boolean;
  25839. /**
  25840. * Returns the mesh itself by default. Implemented by child classes
  25841. * @param camera defines the camera to use to pick the right LOD level
  25842. * @returns the currentAbstractMesh
  25843. */
  25844. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25845. /**
  25846. * Returns 0 by default. Implemented by child classes
  25847. * @returns an integer
  25848. */
  25849. getTotalVertices(): number;
  25850. /**
  25851. * Returns a positive integer : the total number of indices in this mesh geometry.
  25852. * @returns the numner of indices or zero if the mesh has no geometry.
  25853. */
  25854. getTotalIndices(): number;
  25855. /**
  25856. * Returns null by default. Implemented by child classes
  25857. * @returns null
  25858. */
  25859. getIndices(): Nullable<IndicesArray>;
  25860. /**
  25861. * Returns the array of the requested vertex data kind. Implemented by child classes
  25862. * @param kind defines the vertex data kind to use
  25863. * @returns null
  25864. */
  25865. getVerticesData(kind: string): Nullable<FloatArray>;
  25866. /**
  25867. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25868. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25869. * Note that a new underlying VertexBuffer object is created each call.
  25870. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25871. * @param kind defines vertex data kind:
  25872. * * VertexBuffer.PositionKind
  25873. * * VertexBuffer.UVKind
  25874. * * VertexBuffer.UV2Kind
  25875. * * VertexBuffer.UV3Kind
  25876. * * VertexBuffer.UV4Kind
  25877. * * VertexBuffer.UV5Kind
  25878. * * VertexBuffer.UV6Kind
  25879. * * VertexBuffer.ColorKind
  25880. * * VertexBuffer.MatricesIndicesKind
  25881. * * VertexBuffer.MatricesIndicesExtraKind
  25882. * * VertexBuffer.MatricesWeightsKind
  25883. * * VertexBuffer.MatricesWeightsExtraKind
  25884. * @param data defines the data source
  25885. * @param updatable defines if the data must be flagged as updatable (or static)
  25886. * @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
  25887. * @returns the current mesh
  25888. */
  25889. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25890. /**
  25891. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25892. * If the mesh has no geometry, it is simply returned as it is.
  25893. * @param kind defines vertex data kind:
  25894. * * VertexBuffer.PositionKind
  25895. * * VertexBuffer.UVKind
  25896. * * VertexBuffer.UV2Kind
  25897. * * VertexBuffer.UV3Kind
  25898. * * VertexBuffer.UV4Kind
  25899. * * VertexBuffer.UV5Kind
  25900. * * VertexBuffer.UV6Kind
  25901. * * VertexBuffer.ColorKind
  25902. * * VertexBuffer.MatricesIndicesKind
  25903. * * VertexBuffer.MatricesIndicesExtraKind
  25904. * * VertexBuffer.MatricesWeightsKind
  25905. * * VertexBuffer.MatricesWeightsExtraKind
  25906. * @param data defines the data source
  25907. * @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
  25908. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25909. * @returns the current mesh
  25910. */
  25911. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25912. /**
  25913. * Sets the mesh indices,
  25914. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25915. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25916. * @param totalVertices Defines the total number of vertices
  25917. * @returns the current mesh
  25918. */
  25919. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25920. /**
  25921. * Gets a boolean indicating if specific vertex data is present
  25922. * @param kind defines the vertex data kind to use
  25923. * @returns true is data kind is present
  25924. */
  25925. isVerticesDataPresent(kind: string): boolean;
  25926. /**
  25927. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25928. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25929. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25930. * @returns a BoundingInfo
  25931. */
  25932. getBoundingInfo(): BoundingInfo;
  25933. /**
  25934. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25935. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25936. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25937. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25938. * @returns the current mesh
  25939. */
  25940. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25941. /**
  25942. * Overwrite the current bounding info
  25943. * @param boundingInfo defines the new bounding info
  25944. * @returns the current mesh
  25945. */
  25946. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25947. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25948. readonly useBones: boolean;
  25949. /** @hidden */
  25950. _preActivate(): void;
  25951. /** @hidden */
  25952. _preActivateForIntermediateRendering(renderId: number): void;
  25953. /** @hidden */
  25954. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25955. /** @hidden */
  25956. _postActivate(): void;
  25957. /** @hidden */
  25958. _freeze(): void;
  25959. /** @hidden */
  25960. _unFreeze(): void;
  25961. /**
  25962. * Gets the current world matrix
  25963. * @returns a Matrix
  25964. */
  25965. getWorldMatrix(): Matrix;
  25966. /** @hidden */
  25967. _getWorldMatrixDeterminant(): number;
  25968. /**
  25969. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25970. */
  25971. readonly isAnInstance: boolean;
  25972. /**
  25973. * Perform relative position change from the point of view of behind the front of the mesh.
  25974. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25975. * Supports definition of mesh facing forward or backward
  25976. * @param amountRight defines the distance on the right axis
  25977. * @param amountUp defines the distance on the up axis
  25978. * @param amountForward defines the distance on the forward axis
  25979. * @returns the current mesh
  25980. */
  25981. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25982. /**
  25983. * Calculate relative position change from the point of view of behind the front of the mesh.
  25984. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25985. * Supports definition of mesh facing forward or backward
  25986. * @param amountRight defines the distance on the right axis
  25987. * @param amountUp defines the distance on the up axis
  25988. * @param amountForward defines the distance on the forward axis
  25989. * @returns the new displacement vector
  25990. */
  25991. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25992. /**
  25993. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25994. * Supports definition of mesh facing forward or backward
  25995. * @param flipBack defines the flip
  25996. * @param twirlClockwise defines the twirl
  25997. * @param tiltRight defines the tilt
  25998. * @returns the current mesh
  25999. */
  26000. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26001. /**
  26002. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26003. * Supports definition of mesh facing forward or backward.
  26004. * @param flipBack defines the flip
  26005. * @param twirlClockwise defines the twirl
  26006. * @param tiltRight defines the tilt
  26007. * @returns the new rotation vector
  26008. */
  26009. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26010. /**
  26011. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26012. * This means the mesh underlying bounding box and sphere are recomputed.
  26013. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26014. * @returns the current mesh
  26015. */
  26016. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26017. /** @hidden */
  26018. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26019. /** @hidden */
  26020. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26021. /** @hidden */
  26022. _updateBoundingInfo(): AbstractMesh;
  26023. /** @hidden */
  26024. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26025. /** @hidden */
  26026. protected _afterComputeWorldMatrix(): void;
  26027. /** @hidden */
  26028. readonly _effectiveMesh: AbstractMesh;
  26029. /**
  26030. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26031. * A mesh is in the frustum if its bounding box intersects the frustum
  26032. * @param frustumPlanes defines the frustum to test
  26033. * @returns true if the mesh is in the frustum planes
  26034. */
  26035. isInFrustum(frustumPlanes: Plane[]): boolean;
  26036. /**
  26037. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26038. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26039. * @param frustumPlanes defines the frustum to test
  26040. * @returns true if the mesh is completely in the frustum planes
  26041. */
  26042. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26043. /**
  26044. * True if the mesh intersects another mesh or a SolidParticle object
  26045. * @param mesh defines a target mesh or SolidParticle to test
  26046. * @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)
  26047. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26048. * @returns true if there is an intersection
  26049. */
  26050. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26051. /**
  26052. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26053. * @param point defines the point to test
  26054. * @returns true if there is an intersection
  26055. */
  26056. intersectsPoint(point: Vector3): boolean;
  26057. /**
  26058. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26059. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26060. */
  26061. checkCollisions: boolean;
  26062. /**
  26063. * Gets Collider object used to compute collisions (not physics)
  26064. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26065. */
  26066. readonly collider: Nullable<Collider>;
  26067. /**
  26068. * Move the mesh using collision engine
  26069. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26070. * @param displacement defines the requested displacement vector
  26071. * @returns the current mesh
  26072. */
  26073. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26074. private _onCollisionPositionChange;
  26075. /** @hidden */
  26076. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26077. /** @hidden */
  26078. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26079. /** @hidden */
  26080. _checkCollision(collider: Collider): AbstractMesh;
  26081. /** @hidden */
  26082. _generatePointsArray(): boolean;
  26083. /**
  26084. * Checks if the passed Ray intersects with the mesh
  26085. * @param ray defines the ray to use
  26086. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26087. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26088. * @returns the picking info
  26089. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26090. */
  26091. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26092. /**
  26093. * Clones the current mesh
  26094. * @param name defines the mesh name
  26095. * @param newParent defines the new mesh parent
  26096. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26097. * @returns the new mesh
  26098. */
  26099. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26100. /**
  26101. * Disposes all the submeshes of the current meshnp
  26102. * @returns the current mesh
  26103. */
  26104. releaseSubMeshes(): AbstractMesh;
  26105. /**
  26106. * Releases resources associated with this abstract mesh.
  26107. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26108. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26109. */
  26110. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26111. /**
  26112. * Adds the passed mesh as a child to the current mesh
  26113. * @param mesh defines the child mesh
  26114. * @returns the current mesh
  26115. */
  26116. addChild(mesh: AbstractMesh): AbstractMesh;
  26117. /**
  26118. * Removes the passed mesh from the current mesh children list
  26119. * @param mesh defines the child mesh
  26120. * @returns the current mesh
  26121. */
  26122. removeChild(mesh: AbstractMesh): AbstractMesh;
  26123. /** @hidden */
  26124. private _initFacetData;
  26125. /**
  26126. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26127. * This method can be called within the render loop.
  26128. * 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
  26129. * @returns the current mesh
  26130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26131. */
  26132. updateFacetData(): AbstractMesh;
  26133. /**
  26134. * Returns the facetLocalNormals array.
  26135. * The normals are expressed in the mesh local spac
  26136. * @returns an array of Vector3
  26137. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26138. */
  26139. getFacetLocalNormals(): Vector3[];
  26140. /**
  26141. * Returns the facetLocalPositions array.
  26142. * The facet positions are expressed in the mesh local space
  26143. * @returns an array of Vector3
  26144. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26145. */
  26146. getFacetLocalPositions(): Vector3[];
  26147. /**
  26148. * Returns the facetLocalPartioning array
  26149. * @returns an array of array of numbers
  26150. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26151. */
  26152. getFacetLocalPartitioning(): number[][];
  26153. /**
  26154. * Returns the i-th facet position in the world system.
  26155. * This method allocates a new Vector3 per call
  26156. * @param i defines the facet index
  26157. * @returns a new Vector3
  26158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26159. */
  26160. getFacetPosition(i: number): Vector3;
  26161. /**
  26162. * Sets the reference Vector3 with the i-th facet position in the world system
  26163. * @param i defines the facet index
  26164. * @param ref defines the target vector
  26165. * @returns the current mesh
  26166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26167. */
  26168. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26169. /**
  26170. * Returns the i-th facet normal in the world system.
  26171. * This method allocates a new Vector3 per call
  26172. * @param i defines the facet index
  26173. * @returns a new Vector3
  26174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26175. */
  26176. getFacetNormal(i: number): Vector3;
  26177. /**
  26178. * Sets the reference Vector3 with the i-th facet normal in the world system
  26179. * @param i defines the facet index
  26180. * @param ref defines the target vector
  26181. * @returns the current mesh
  26182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26183. */
  26184. getFacetNormalToRef(i: number, ref: Vector3): this;
  26185. /**
  26186. * 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)
  26187. * @param x defines x coordinate
  26188. * @param y defines y coordinate
  26189. * @param z defines z coordinate
  26190. * @returns the array of facet indexes
  26191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26192. */
  26193. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26194. /**
  26195. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26196. * @param projected sets as the (x,y,z) world projection on the facet
  26197. * @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
  26198. * @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
  26199. * @param x defines x coordinate
  26200. * @param y defines y coordinate
  26201. * @param z defines z coordinate
  26202. * @returns the face index if found (or null instead)
  26203. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26204. */
  26205. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26206. /**
  26207. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26208. * @param projected sets as the (x,y,z) local projection on the facet
  26209. * @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
  26210. * @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
  26211. * @param x defines x coordinate
  26212. * @param y defines y coordinate
  26213. * @param z defines z coordinate
  26214. * @returns the face index if found (or null instead)
  26215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26216. */
  26217. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26218. /**
  26219. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26220. * @returns the parameters
  26221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26222. */
  26223. getFacetDataParameters(): any;
  26224. /**
  26225. * Disables the feature FacetData and frees the related memory
  26226. * @returns the current mesh
  26227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26228. */
  26229. disableFacetData(): AbstractMesh;
  26230. /**
  26231. * Updates the AbstractMesh indices array
  26232. * @param indices defines the data source
  26233. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26234. * @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)
  26235. * @returns the current mesh
  26236. */
  26237. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26238. /**
  26239. * Creates new normals data for the mesh
  26240. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26241. * @returns the current mesh
  26242. */
  26243. createNormals(updatable: boolean): AbstractMesh;
  26244. /**
  26245. * Align the mesh with a normal
  26246. * @param normal defines the normal to use
  26247. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26248. * @returns the current mesh
  26249. */
  26250. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26251. /** @hidden */
  26252. _checkOcclusionQuery(): boolean;
  26253. /**
  26254. * Disables the mesh edge rendering mode
  26255. * @returns the currentAbstractMesh
  26256. */
  26257. disableEdgesRendering(): AbstractMesh;
  26258. /**
  26259. * Enables the edge rendering mode on the mesh.
  26260. * This mode makes the mesh edges visible
  26261. * @param epsilon defines the maximal distance between two angles to detect a face
  26262. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26263. * @returns the currentAbstractMesh
  26264. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26265. */
  26266. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26267. }
  26268. }
  26269. declare module BABYLON {
  26270. /**
  26271. * Interface used to define ActionEvent
  26272. */
  26273. export interface IActionEvent {
  26274. /** The mesh or sprite that triggered the action */
  26275. source: any;
  26276. /** The X mouse cursor position at the time of the event */
  26277. pointerX: number;
  26278. /** The Y mouse cursor position at the time of the event */
  26279. pointerY: number;
  26280. /** The mesh that is currently pointed at (can be null) */
  26281. meshUnderPointer: Nullable<AbstractMesh>;
  26282. /** the original (browser) event that triggered the ActionEvent */
  26283. sourceEvent?: any;
  26284. /** additional data for the event */
  26285. additionalData?: any;
  26286. }
  26287. /**
  26288. * ActionEvent is the event being sent when an action is triggered.
  26289. */
  26290. export class ActionEvent implements IActionEvent {
  26291. /** The mesh or sprite that triggered the action */
  26292. source: any;
  26293. /** The X mouse cursor position at the time of the event */
  26294. pointerX: number;
  26295. /** The Y mouse cursor position at the time of the event */
  26296. pointerY: number;
  26297. /** The mesh that is currently pointed at (can be null) */
  26298. meshUnderPointer: Nullable<AbstractMesh>;
  26299. /** the original (browser) event that triggered the ActionEvent */
  26300. sourceEvent?: any;
  26301. /** additional data for the event */
  26302. additionalData?: any;
  26303. /**
  26304. * Creates a new ActionEvent
  26305. * @param source The mesh or sprite that triggered the action
  26306. * @param pointerX The X mouse cursor position at the time of the event
  26307. * @param pointerY The Y mouse cursor position at the time of the event
  26308. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26309. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26310. * @param additionalData additional data for the event
  26311. */
  26312. constructor(
  26313. /** The mesh or sprite that triggered the action */
  26314. source: any,
  26315. /** The X mouse cursor position at the time of the event */
  26316. pointerX: number,
  26317. /** The Y mouse cursor position at the time of the event */
  26318. pointerY: number,
  26319. /** The mesh that is currently pointed at (can be null) */
  26320. meshUnderPointer: Nullable<AbstractMesh>,
  26321. /** the original (browser) event that triggered the ActionEvent */
  26322. sourceEvent?: any,
  26323. /** additional data for the event */
  26324. additionalData?: any);
  26325. /**
  26326. * Helper function to auto-create an ActionEvent from a source mesh.
  26327. * @param source The source mesh that triggered the event
  26328. * @param evt The original (browser) event
  26329. * @param additionalData additional data for the event
  26330. * @returns the new ActionEvent
  26331. */
  26332. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26333. /**
  26334. * Helper function to auto-create an ActionEvent from a source sprite
  26335. * @param source The source sprite that triggered the event
  26336. * @param scene Scene associated with the sprite
  26337. * @param evt The original (browser) event
  26338. * @param additionalData additional data for the event
  26339. * @returns the new ActionEvent
  26340. */
  26341. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26342. /**
  26343. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26344. * @param scene the scene where the event occurred
  26345. * @param evt The original (browser) event
  26346. * @returns the new ActionEvent
  26347. */
  26348. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26349. /**
  26350. * Helper function to auto-create an ActionEvent from a primitive
  26351. * @param prim defines the target primitive
  26352. * @param pointerPos defines the pointer position
  26353. * @param evt The original (browser) event
  26354. * @param additionalData additional data for the event
  26355. * @returns the new ActionEvent
  26356. */
  26357. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26358. }
  26359. }
  26360. declare module BABYLON {
  26361. /**
  26362. * Abstract class used to decouple action Manager from scene and meshes.
  26363. * Do not instantiate.
  26364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26365. */
  26366. export abstract class AbstractActionManager implements IDisposable {
  26367. /** Gets the list of active triggers */
  26368. static Triggers: {
  26369. [key: string]: number;
  26370. };
  26371. /** Gets the cursor to use when hovering items */
  26372. hoverCursor: string;
  26373. /** Gets the list of actions */
  26374. actions: IAction[];
  26375. /**
  26376. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26377. */
  26378. isRecursive: boolean;
  26379. /**
  26380. * Releases all associated resources
  26381. */
  26382. abstract dispose(): void;
  26383. /**
  26384. * Does this action manager has pointer triggers
  26385. */
  26386. abstract readonly hasPointerTriggers: boolean;
  26387. /**
  26388. * Does this action manager has pick triggers
  26389. */
  26390. abstract readonly hasPickTriggers: boolean;
  26391. /**
  26392. * Process a specific trigger
  26393. * @param trigger defines the trigger to process
  26394. * @param evt defines the event details to be processed
  26395. */
  26396. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26397. /**
  26398. * Does this action manager handles actions of any of the given triggers
  26399. * @param triggers defines the triggers to be tested
  26400. * @return a boolean indicating whether one (or more) of the triggers is handled
  26401. */
  26402. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26403. /**
  26404. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26405. * speed.
  26406. * @param triggerA defines the trigger to be tested
  26407. * @param triggerB defines the trigger to be tested
  26408. * @return a boolean indicating whether one (or more) of the triggers is handled
  26409. */
  26410. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26411. /**
  26412. * Does this action manager handles actions of a given trigger
  26413. * @param trigger defines the trigger to be tested
  26414. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26415. * @return whether the trigger is handled
  26416. */
  26417. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26418. /**
  26419. * Serialize this manager to a JSON object
  26420. * @param name defines the property name to store this manager
  26421. * @returns a JSON representation of this manager
  26422. */
  26423. abstract serialize(name: string): any;
  26424. /**
  26425. * Registers an action to this action manager
  26426. * @param action defines the action to be registered
  26427. * @return the action amended (prepared) after registration
  26428. */
  26429. abstract registerAction(action: IAction): Nullable<IAction>;
  26430. /**
  26431. * Unregisters an action to this action manager
  26432. * @param action defines the action to be unregistered
  26433. * @return a boolean indicating whether the action has been unregistered
  26434. */
  26435. abstract unregisterAction(action: IAction): Boolean;
  26436. /**
  26437. * Does exist one action manager with at least one trigger
  26438. **/
  26439. static readonly HasTriggers: boolean;
  26440. /**
  26441. * Does exist one action manager with at least one pick trigger
  26442. **/
  26443. static readonly HasPickTriggers: boolean;
  26444. /**
  26445. * Does exist one action manager that handles actions of a given trigger
  26446. * @param trigger defines the trigger to be tested
  26447. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26448. **/
  26449. static HasSpecificTrigger(trigger: number): boolean;
  26450. }
  26451. }
  26452. declare module BABYLON {
  26453. /**
  26454. * Defines how a node can be built from a string name.
  26455. */
  26456. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26457. /**
  26458. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26459. */
  26460. export class Node implements IBehaviorAware<Node> {
  26461. /** @hidden */
  26462. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26463. private static _NodeConstructors;
  26464. /**
  26465. * Add a new node constructor
  26466. * @param type defines the type name of the node to construct
  26467. * @param constructorFunc defines the constructor function
  26468. */
  26469. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26470. /**
  26471. * Returns a node constructor based on type name
  26472. * @param type defines the type name
  26473. * @param name defines the new node name
  26474. * @param scene defines the hosting scene
  26475. * @param options defines optional options to transmit to constructors
  26476. * @returns the new constructor or null
  26477. */
  26478. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26479. /**
  26480. * Gets or sets the name of the node
  26481. */
  26482. name: string;
  26483. /**
  26484. * Gets or sets the id of the node
  26485. */
  26486. id: string;
  26487. /**
  26488. * Gets or sets the unique id of the node
  26489. */
  26490. uniqueId: number;
  26491. /**
  26492. * Gets or sets a string used to store user defined state for the node
  26493. */
  26494. state: string;
  26495. /**
  26496. * Gets or sets an object used to store user defined information for the node
  26497. */
  26498. metadata: any;
  26499. /**
  26500. * For internal use only. Please do not use.
  26501. */
  26502. reservedDataStore: any;
  26503. /**
  26504. * List of inspectable custom properties (used by the Inspector)
  26505. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26506. */
  26507. inspectableCustomProperties: IInspectable[];
  26508. /**
  26509. * Gets or sets a boolean used to define if the node must be serialized
  26510. */
  26511. doNotSerialize: boolean;
  26512. /** @hidden */
  26513. _isDisposed: boolean;
  26514. /**
  26515. * Gets a list of Animations associated with the node
  26516. */
  26517. animations: Animation[];
  26518. protected _ranges: {
  26519. [name: string]: Nullable<AnimationRange>;
  26520. };
  26521. /**
  26522. * Callback raised when the node is ready to be used
  26523. */
  26524. onReady: Nullable<(node: Node) => void>;
  26525. private _isEnabled;
  26526. private _isParentEnabled;
  26527. private _isReady;
  26528. /** @hidden */
  26529. _currentRenderId: number;
  26530. private _parentUpdateId;
  26531. /** @hidden */
  26532. _childUpdateId: number;
  26533. /** @hidden */
  26534. _waitingParentId: Nullable<string>;
  26535. /** @hidden */
  26536. _scene: Scene;
  26537. /** @hidden */
  26538. _cache: any;
  26539. private _parentNode;
  26540. private _children;
  26541. /** @hidden */
  26542. _worldMatrix: Matrix;
  26543. /** @hidden */
  26544. _worldMatrixDeterminant: number;
  26545. /** @hidden */
  26546. _worldMatrixDeterminantIsDirty: boolean;
  26547. /** @hidden */
  26548. private _sceneRootNodesIndex;
  26549. /**
  26550. * Gets a boolean indicating if the node has been disposed
  26551. * @returns true if the node was disposed
  26552. */
  26553. isDisposed(): boolean;
  26554. /**
  26555. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26556. * @see https://doc.babylonjs.com/how_to/parenting
  26557. */
  26558. parent: Nullable<Node>;
  26559. private addToSceneRootNodes;
  26560. private removeFromSceneRootNodes;
  26561. private _animationPropertiesOverride;
  26562. /**
  26563. * Gets or sets the animation properties override
  26564. */
  26565. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26566. /**
  26567. * Gets a string idenfifying the name of the class
  26568. * @returns "Node" string
  26569. */
  26570. getClassName(): string;
  26571. /** @hidden */
  26572. readonly _isNode: boolean;
  26573. /**
  26574. * An event triggered when the mesh is disposed
  26575. */
  26576. onDisposeObservable: Observable<Node>;
  26577. private _onDisposeObserver;
  26578. /**
  26579. * Sets a callback that will be raised when the node will be disposed
  26580. */
  26581. onDispose: () => void;
  26582. /**
  26583. * Creates a new Node
  26584. * @param name the name and id to be given to this node
  26585. * @param scene the scene this node will be added to
  26586. * @param addToRootNodes the node will be added to scene.rootNodes
  26587. */
  26588. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26589. /**
  26590. * Gets the scene of the node
  26591. * @returns a scene
  26592. */
  26593. getScene(): Scene;
  26594. /**
  26595. * Gets the engine of the node
  26596. * @returns a Engine
  26597. */
  26598. getEngine(): Engine;
  26599. private _behaviors;
  26600. /**
  26601. * Attach a behavior to the node
  26602. * @see http://doc.babylonjs.com/features/behaviour
  26603. * @param behavior defines the behavior to attach
  26604. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26605. * @returns the current Node
  26606. */
  26607. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26608. /**
  26609. * Remove an attached behavior
  26610. * @see http://doc.babylonjs.com/features/behaviour
  26611. * @param behavior defines the behavior to attach
  26612. * @returns the current Node
  26613. */
  26614. removeBehavior(behavior: Behavior<Node>): Node;
  26615. /**
  26616. * Gets the list of attached behaviors
  26617. * @see http://doc.babylonjs.com/features/behaviour
  26618. */
  26619. readonly behaviors: Behavior<Node>[];
  26620. /**
  26621. * Gets an attached behavior by name
  26622. * @param name defines the name of the behavior to look for
  26623. * @see http://doc.babylonjs.com/features/behaviour
  26624. * @returns null if behavior was not found else the requested behavior
  26625. */
  26626. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26627. /**
  26628. * Returns the latest update of the World matrix
  26629. * @returns a Matrix
  26630. */
  26631. getWorldMatrix(): Matrix;
  26632. /** @hidden */
  26633. _getWorldMatrixDeterminant(): number;
  26634. /**
  26635. * Returns directly the latest state of the mesh World matrix.
  26636. * A Matrix is returned.
  26637. */
  26638. readonly worldMatrixFromCache: Matrix;
  26639. /** @hidden */
  26640. _initCache(): void;
  26641. /** @hidden */
  26642. updateCache(force?: boolean): void;
  26643. /** @hidden */
  26644. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26645. /** @hidden */
  26646. _updateCache(ignoreParentClass?: boolean): void;
  26647. /** @hidden */
  26648. _isSynchronized(): boolean;
  26649. /** @hidden */
  26650. _markSyncedWithParent(): void;
  26651. /** @hidden */
  26652. isSynchronizedWithParent(): boolean;
  26653. /** @hidden */
  26654. isSynchronized(): boolean;
  26655. /**
  26656. * Is this node ready to be used/rendered
  26657. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26658. * @return true if the node is ready
  26659. */
  26660. isReady(completeCheck?: boolean): boolean;
  26661. /**
  26662. * Is this node enabled?
  26663. * 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
  26664. * @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
  26665. * @return whether this node (and its parent) is enabled
  26666. */
  26667. isEnabled(checkAncestors?: boolean): boolean;
  26668. /** @hidden */
  26669. protected _syncParentEnabledState(): void;
  26670. /**
  26671. * Set the enabled state of this node
  26672. * @param value defines the new enabled state
  26673. */
  26674. setEnabled(value: boolean): void;
  26675. /**
  26676. * Is this node a descendant of the given node?
  26677. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26678. * @param ancestor defines the parent node to inspect
  26679. * @returns a boolean indicating if this node is a descendant of the given node
  26680. */
  26681. isDescendantOf(ancestor: Node): boolean;
  26682. /** @hidden */
  26683. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26684. /**
  26685. * Will return all nodes that have this node as ascendant
  26686. * @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
  26687. * @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
  26688. * @return all children nodes of all types
  26689. */
  26690. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26691. /**
  26692. * Get all child-meshes of this node
  26693. * @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)
  26694. * @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
  26695. * @returns an array of AbstractMesh
  26696. */
  26697. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26698. /**
  26699. * Get all direct children of this node
  26700. * @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
  26701. * @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)
  26702. * @returns an array of Node
  26703. */
  26704. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26705. /** @hidden */
  26706. _setReady(state: boolean): void;
  26707. /**
  26708. * Get an animation by name
  26709. * @param name defines the name of the animation to look for
  26710. * @returns null if not found else the requested animation
  26711. */
  26712. getAnimationByName(name: string): Nullable<Animation>;
  26713. /**
  26714. * Creates an animation range for this node
  26715. * @param name defines the name of the range
  26716. * @param from defines the starting key
  26717. * @param to defines the end key
  26718. */
  26719. createAnimationRange(name: string, from: number, to: number): void;
  26720. /**
  26721. * Delete a specific animation range
  26722. * @param name defines the name of the range to delete
  26723. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26724. */
  26725. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26726. /**
  26727. * Get an animation range by name
  26728. * @param name defines the name of the animation range to look for
  26729. * @returns null if not found else the requested animation range
  26730. */
  26731. getAnimationRange(name: string): Nullable<AnimationRange>;
  26732. /**
  26733. * Gets the list of all animation ranges defined on this node
  26734. * @returns an array
  26735. */
  26736. getAnimationRanges(): Nullable<AnimationRange>[];
  26737. /**
  26738. * Will start the animation sequence
  26739. * @param name defines the range frames for animation sequence
  26740. * @param loop defines if the animation should loop (false by default)
  26741. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26742. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26743. * @returns the object created for this animation. If range does not exist, it will return null
  26744. */
  26745. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26746. /**
  26747. * Serialize animation ranges into a JSON compatible object
  26748. * @returns serialization object
  26749. */
  26750. serializeAnimationRanges(): any;
  26751. /**
  26752. * Computes the world matrix of the node
  26753. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26754. * @returns the world matrix
  26755. */
  26756. computeWorldMatrix(force?: boolean): Matrix;
  26757. /**
  26758. * Releases resources associated with this node.
  26759. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26760. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26761. */
  26762. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26763. /**
  26764. * Parse animation range data from a serialization object and store them into a given node
  26765. * @param node defines where to store the animation ranges
  26766. * @param parsedNode defines the serialization object to read data from
  26767. * @param scene defines the hosting scene
  26768. */
  26769. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26770. /**
  26771. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26772. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26773. * @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
  26774. * @returns the new bounding vectors
  26775. */
  26776. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26777. min: Vector3;
  26778. max: Vector3;
  26779. };
  26780. }
  26781. }
  26782. declare module BABYLON {
  26783. /**
  26784. * @hidden
  26785. */
  26786. export class _IAnimationState {
  26787. key: number;
  26788. repeatCount: number;
  26789. workValue?: any;
  26790. loopMode?: number;
  26791. offsetValue?: any;
  26792. highLimitValue?: any;
  26793. }
  26794. /**
  26795. * Class used to store any kind of animation
  26796. */
  26797. export class Animation {
  26798. /**Name of the animation */
  26799. name: string;
  26800. /**Property to animate */
  26801. targetProperty: string;
  26802. /**The frames per second of the animation */
  26803. framePerSecond: number;
  26804. /**The data type of the animation */
  26805. dataType: number;
  26806. /**The loop mode of the animation */
  26807. loopMode?: number | undefined;
  26808. /**Specifies if blending should be enabled */
  26809. enableBlending?: boolean | undefined;
  26810. /**
  26811. * Use matrix interpolation instead of using direct key value when animating matrices
  26812. */
  26813. static AllowMatricesInterpolation: boolean;
  26814. /**
  26815. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26816. */
  26817. static AllowMatrixDecomposeForInterpolation: boolean;
  26818. /**
  26819. * Stores the key frames of the animation
  26820. */
  26821. private _keys;
  26822. /**
  26823. * Stores the easing function of the animation
  26824. */
  26825. private _easingFunction;
  26826. /**
  26827. * @hidden Internal use only
  26828. */
  26829. _runtimeAnimations: RuntimeAnimation[];
  26830. /**
  26831. * The set of event that will be linked to this animation
  26832. */
  26833. private _events;
  26834. /**
  26835. * Stores an array of target property paths
  26836. */
  26837. targetPropertyPath: string[];
  26838. /**
  26839. * Stores the blending speed of the animation
  26840. */
  26841. blendingSpeed: number;
  26842. /**
  26843. * Stores the animation ranges for the animation
  26844. */
  26845. private _ranges;
  26846. /**
  26847. * @hidden Internal use
  26848. */
  26849. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26850. /**
  26851. * Sets up an animation
  26852. * @param property The property to animate
  26853. * @param animationType The animation type to apply
  26854. * @param framePerSecond The frames per second of the animation
  26855. * @param easingFunction The easing function used in the animation
  26856. * @returns The created animation
  26857. */
  26858. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26859. /**
  26860. * Create and start an animation on a node
  26861. * @param name defines the name of the global animation that will be run on all nodes
  26862. * @param node defines the root node where the animation will take place
  26863. * @param targetProperty defines property to animate
  26864. * @param framePerSecond defines the number of frame per second yo use
  26865. * @param totalFrame defines the number of frames in total
  26866. * @param from defines the initial value
  26867. * @param to defines the final value
  26868. * @param loopMode defines which loop mode you want to use (off by default)
  26869. * @param easingFunction defines the easing function to use (linear by default)
  26870. * @param onAnimationEnd defines the callback to call when animation end
  26871. * @returns the animatable created for this animation
  26872. */
  26873. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26874. /**
  26875. * Create and start an animation on a node and its descendants
  26876. * @param name defines the name of the global animation that will be run on all nodes
  26877. * @param node defines the root node where the animation will take place
  26878. * @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
  26879. * @param targetProperty defines property to animate
  26880. * @param framePerSecond defines the number of frame per second to use
  26881. * @param totalFrame defines the number of frames in total
  26882. * @param from defines the initial value
  26883. * @param to defines the final value
  26884. * @param loopMode defines which loop mode you want to use (off by default)
  26885. * @param easingFunction defines the easing function to use (linear by default)
  26886. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26887. * @returns the list of animatables created for all nodes
  26888. * @example https://www.babylonjs-playground.com/#MH0VLI
  26889. */
  26890. 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[]>;
  26891. /**
  26892. * Creates a new animation, merges it with the existing animations and starts it
  26893. * @param name Name of the animation
  26894. * @param node Node which contains the scene that begins the animations
  26895. * @param targetProperty Specifies which property to animate
  26896. * @param framePerSecond The frames per second of the animation
  26897. * @param totalFrame The total number of frames
  26898. * @param from The frame at the beginning of the animation
  26899. * @param to The frame at the end of the animation
  26900. * @param loopMode Specifies the loop mode of the animation
  26901. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26902. * @param onAnimationEnd Callback to run once the animation is complete
  26903. * @returns Nullable animation
  26904. */
  26905. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26906. /**
  26907. * Transition property of an host to the target Value
  26908. * @param property The property to transition
  26909. * @param targetValue The target Value of the property
  26910. * @param host The object where the property to animate belongs
  26911. * @param scene Scene used to run the animation
  26912. * @param frameRate Framerate (in frame/s) to use
  26913. * @param transition The transition type we want to use
  26914. * @param duration The duration of the animation, in milliseconds
  26915. * @param onAnimationEnd Callback trigger at the end of the animation
  26916. * @returns Nullable animation
  26917. */
  26918. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26919. /**
  26920. * Return the array of runtime animations currently using this animation
  26921. */
  26922. readonly runtimeAnimations: RuntimeAnimation[];
  26923. /**
  26924. * Specifies if any of the runtime animations are currently running
  26925. */
  26926. readonly hasRunningRuntimeAnimations: boolean;
  26927. /**
  26928. * Initializes the animation
  26929. * @param name Name of the animation
  26930. * @param targetProperty Property to animate
  26931. * @param framePerSecond The frames per second of the animation
  26932. * @param dataType The data type of the animation
  26933. * @param loopMode The loop mode of the animation
  26934. * @param enableBlending Specifies if blending should be enabled
  26935. */
  26936. constructor(
  26937. /**Name of the animation */
  26938. name: string,
  26939. /**Property to animate */
  26940. targetProperty: string,
  26941. /**The frames per second of the animation */
  26942. framePerSecond: number,
  26943. /**The data type of the animation */
  26944. dataType: number,
  26945. /**The loop mode of the animation */
  26946. loopMode?: number | undefined,
  26947. /**Specifies if blending should be enabled */
  26948. enableBlending?: boolean | undefined);
  26949. /**
  26950. * Converts the animation to a string
  26951. * @param fullDetails support for multiple levels of logging within scene loading
  26952. * @returns String form of the animation
  26953. */
  26954. toString(fullDetails?: boolean): string;
  26955. /**
  26956. * Add an event to this animation
  26957. * @param event Event to add
  26958. */
  26959. addEvent(event: AnimationEvent): void;
  26960. /**
  26961. * Remove all events found at the given frame
  26962. * @param frame The frame to remove events from
  26963. */
  26964. removeEvents(frame: number): void;
  26965. /**
  26966. * Retrieves all the events from the animation
  26967. * @returns Events from the animation
  26968. */
  26969. getEvents(): AnimationEvent[];
  26970. /**
  26971. * Creates an animation range
  26972. * @param name Name of the animation range
  26973. * @param from Starting frame of the animation range
  26974. * @param to Ending frame of the animation
  26975. */
  26976. createRange(name: string, from: number, to: number): void;
  26977. /**
  26978. * Deletes an animation range by name
  26979. * @param name Name of the animation range to delete
  26980. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26981. */
  26982. deleteRange(name: string, deleteFrames?: boolean): void;
  26983. /**
  26984. * Gets the animation range by name, or null if not defined
  26985. * @param name Name of the animation range
  26986. * @returns Nullable animation range
  26987. */
  26988. getRange(name: string): Nullable<AnimationRange>;
  26989. /**
  26990. * Gets the key frames from the animation
  26991. * @returns The key frames of the animation
  26992. */
  26993. getKeys(): Array<IAnimationKey>;
  26994. /**
  26995. * Gets the highest frame rate of the animation
  26996. * @returns Highest frame rate of the animation
  26997. */
  26998. getHighestFrame(): number;
  26999. /**
  27000. * Gets the easing function of the animation
  27001. * @returns Easing function of the animation
  27002. */
  27003. getEasingFunction(): IEasingFunction;
  27004. /**
  27005. * Sets the easing function of the animation
  27006. * @param easingFunction A custom mathematical formula for animation
  27007. */
  27008. setEasingFunction(easingFunction: EasingFunction): void;
  27009. /**
  27010. * Interpolates a scalar linearly
  27011. * @param startValue Start value of the animation curve
  27012. * @param endValue End value of the animation curve
  27013. * @param gradient Scalar amount to interpolate
  27014. * @returns Interpolated scalar value
  27015. */
  27016. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27017. /**
  27018. * Interpolates a scalar cubically
  27019. * @param startValue Start value of the animation curve
  27020. * @param outTangent End tangent of the animation
  27021. * @param endValue End value of the animation curve
  27022. * @param inTangent Start tangent of the animation curve
  27023. * @param gradient Scalar amount to interpolate
  27024. * @returns Interpolated scalar value
  27025. */
  27026. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27027. /**
  27028. * Interpolates a quaternion using a spherical linear interpolation
  27029. * @param startValue Start value of the animation curve
  27030. * @param endValue End value of the animation curve
  27031. * @param gradient Scalar amount to interpolate
  27032. * @returns Interpolated quaternion value
  27033. */
  27034. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27035. /**
  27036. * Interpolates a quaternion cubically
  27037. * @param startValue Start value of the animation curve
  27038. * @param outTangent End tangent of the animation curve
  27039. * @param endValue End value of the animation curve
  27040. * @param inTangent Start tangent of the animation curve
  27041. * @param gradient Scalar amount to interpolate
  27042. * @returns Interpolated quaternion value
  27043. */
  27044. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27045. /**
  27046. * Interpolates a Vector3 linearl
  27047. * @param startValue Start value of the animation curve
  27048. * @param endValue End value of the animation curve
  27049. * @param gradient Scalar amount to interpolate
  27050. * @returns Interpolated scalar value
  27051. */
  27052. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27053. /**
  27054. * Interpolates a Vector3 cubically
  27055. * @param startValue Start value of the animation curve
  27056. * @param outTangent End tangent of the animation
  27057. * @param endValue End value of the animation curve
  27058. * @param inTangent Start tangent of the animation curve
  27059. * @param gradient Scalar amount to interpolate
  27060. * @returns InterpolatedVector3 value
  27061. */
  27062. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27063. /**
  27064. * Interpolates a Vector2 linearly
  27065. * @param startValue Start value of the animation curve
  27066. * @param endValue End value of the animation curve
  27067. * @param gradient Scalar amount to interpolate
  27068. * @returns Interpolated Vector2 value
  27069. */
  27070. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27071. /**
  27072. * Interpolates a Vector2 cubically
  27073. * @param startValue Start value of the animation curve
  27074. * @param outTangent End tangent of the animation
  27075. * @param endValue End value of the animation curve
  27076. * @param inTangent Start tangent of the animation curve
  27077. * @param gradient Scalar amount to interpolate
  27078. * @returns Interpolated Vector2 value
  27079. */
  27080. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27081. /**
  27082. * Interpolates a size linearly
  27083. * @param startValue Start value of the animation curve
  27084. * @param endValue End value of the animation curve
  27085. * @param gradient Scalar amount to interpolate
  27086. * @returns Interpolated Size value
  27087. */
  27088. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27089. /**
  27090. * Interpolates a Color3 linearly
  27091. * @param startValue Start value of the animation curve
  27092. * @param endValue End value of the animation curve
  27093. * @param gradient Scalar amount to interpolate
  27094. * @returns Interpolated Color3 value
  27095. */
  27096. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27097. /**
  27098. * @hidden Internal use only
  27099. */
  27100. _getKeyValue(value: any): any;
  27101. /**
  27102. * @hidden Internal use only
  27103. */
  27104. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27105. /**
  27106. * Defines the function to use to interpolate matrices
  27107. * @param startValue defines the start matrix
  27108. * @param endValue defines the end matrix
  27109. * @param gradient defines the gradient between both matrices
  27110. * @param result defines an optional target matrix where to store the interpolation
  27111. * @returns the interpolated matrix
  27112. */
  27113. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27114. /**
  27115. * Makes a copy of the animation
  27116. * @returns Cloned animation
  27117. */
  27118. clone(): Animation;
  27119. /**
  27120. * Sets the key frames of the animation
  27121. * @param values The animation key frames to set
  27122. */
  27123. setKeys(values: Array<IAnimationKey>): void;
  27124. /**
  27125. * Serializes the animation to an object
  27126. * @returns Serialized object
  27127. */
  27128. serialize(): any;
  27129. /**
  27130. * Float animation type
  27131. */
  27132. private static _ANIMATIONTYPE_FLOAT;
  27133. /**
  27134. * Vector3 animation type
  27135. */
  27136. private static _ANIMATIONTYPE_VECTOR3;
  27137. /**
  27138. * Quaternion animation type
  27139. */
  27140. private static _ANIMATIONTYPE_QUATERNION;
  27141. /**
  27142. * Matrix animation type
  27143. */
  27144. private static _ANIMATIONTYPE_MATRIX;
  27145. /**
  27146. * Color3 animation type
  27147. */
  27148. private static _ANIMATIONTYPE_COLOR3;
  27149. /**
  27150. * Vector2 animation type
  27151. */
  27152. private static _ANIMATIONTYPE_VECTOR2;
  27153. /**
  27154. * Size animation type
  27155. */
  27156. private static _ANIMATIONTYPE_SIZE;
  27157. /**
  27158. * Relative Loop Mode
  27159. */
  27160. private static _ANIMATIONLOOPMODE_RELATIVE;
  27161. /**
  27162. * Cycle Loop Mode
  27163. */
  27164. private static _ANIMATIONLOOPMODE_CYCLE;
  27165. /**
  27166. * Constant Loop Mode
  27167. */
  27168. private static _ANIMATIONLOOPMODE_CONSTANT;
  27169. /**
  27170. * Get the float animation type
  27171. */
  27172. static readonly ANIMATIONTYPE_FLOAT: number;
  27173. /**
  27174. * Get the Vector3 animation type
  27175. */
  27176. static readonly ANIMATIONTYPE_VECTOR3: number;
  27177. /**
  27178. * Get the Vector2 animation type
  27179. */
  27180. static readonly ANIMATIONTYPE_VECTOR2: number;
  27181. /**
  27182. * Get the Size animation type
  27183. */
  27184. static readonly ANIMATIONTYPE_SIZE: number;
  27185. /**
  27186. * Get the Quaternion animation type
  27187. */
  27188. static readonly ANIMATIONTYPE_QUATERNION: number;
  27189. /**
  27190. * Get the Matrix animation type
  27191. */
  27192. static readonly ANIMATIONTYPE_MATRIX: number;
  27193. /**
  27194. * Get the Color3 animation type
  27195. */
  27196. static readonly ANIMATIONTYPE_COLOR3: number;
  27197. /**
  27198. * Get the Relative Loop Mode
  27199. */
  27200. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27201. /**
  27202. * Get the Cycle Loop Mode
  27203. */
  27204. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27205. /**
  27206. * Get the Constant Loop Mode
  27207. */
  27208. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27209. /** @hidden */
  27210. static _UniversalLerp(left: any, right: any, amount: number): any;
  27211. /**
  27212. * Parses an animation object and creates an animation
  27213. * @param parsedAnimation Parsed animation object
  27214. * @returns Animation object
  27215. */
  27216. static Parse(parsedAnimation: any): Animation;
  27217. /**
  27218. * Appends the serialized animations from the source animations
  27219. * @param source Source containing the animations
  27220. * @param destination Target to store the animations
  27221. */
  27222. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27223. }
  27224. }
  27225. declare module BABYLON {
  27226. /**
  27227. * Interface containing an array of animations
  27228. */
  27229. export interface IAnimatable {
  27230. /**
  27231. * Array of animations
  27232. */
  27233. animations: Nullable<Array<Animation>>;
  27234. }
  27235. }
  27236. declare module BABYLON {
  27237. /**
  27238. * This represents all the required information to add a fresnel effect on a material:
  27239. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27240. */
  27241. export class FresnelParameters {
  27242. private _isEnabled;
  27243. /**
  27244. * Define if the fresnel effect is enable or not.
  27245. */
  27246. isEnabled: boolean;
  27247. /**
  27248. * Define the color used on edges (grazing angle)
  27249. */
  27250. leftColor: Color3;
  27251. /**
  27252. * Define the color used on center
  27253. */
  27254. rightColor: Color3;
  27255. /**
  27256. * Define bias applied to computed fresnel term
  27257. */
  27258. bias: number;
  27259. /**
  27260. * Defined the power exponent applied to fresnel term
  27261. */
  27262. power: number;
  27263. /**
  27264. * Clones the current fresnel and its valuues
  27265. * @returns a clone fresnel configuration
  27266. */
  27267. clone(): FresnelParameters;
  27268. /**
  27269. * Serializes the current fresnel parameters to a JSON representation.
  27270. * @return the JSON serialization
  27271. */
  27272. serialize(): any;
  27273. /**
  27274. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27275. * @param parsedFresnelParameters Define the JSON representation
  27276. * @returns the parsed parameters
  27277. */
  27278. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27279. }
  27280. }
  27281. declare module BABYLON {
  27282. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27283. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27284. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27285. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27286. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27287. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27288. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27289. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27290. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27291. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27292. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27293. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27294. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27295. /**
  27296. * Decorator used to define property that can be serialized as reference to a camera
  27297. * @param sourceName defines the name of the property to decorate
  27298. */
  27299. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27300. /**
  27301. * Class used to help serialization objects
  27302. */
  27303. export class SerializationHelper {
  27304. /** @hidden */
  27305. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27306. /** @hidden */
  27307. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27308. /** @hidden */
  27309. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27310. /** @hidden */
  27311. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27312. /**
  27313. * Appends the serialized animations from the source animations
  27314. * @param source Source containing the animations
  27315. * @param destination Target to store the animations
  27316. */
  27317. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27318. /**
  27319. * Static function used to serialized a specific entity
  27320. * @param entity defines the entity to serialize
  27321. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27322. * @returns a JSON compatible object representing the serialization of the entity
  27323. */
  27324. static Serialize<T>(entity: T, serializationObject?: any): any;
  27325. /**
  27326. * Creates a new entity from a serialization data object
  27327. * @param creationFunction defines a function used to instanciated the new entity
  27328. * @param source defines the source serialization data
  27329. * @param scene defines the hosting scene
  27330. * @param rootUrl defines the root url for resources
  27331. * @returns a new entity
  27332. */
  27333. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27334. /**
  27335. * Clones an object
  27336. * @param creationFunction defines the function used to instanciate the new object
  27337. * @param source defines the source object
  27338. * @returns the cloned object
  27339. */
  27340. static Clone<T>(creationFunction: () => T, source: T): T;
  27341. /**
  27342. * Instanciates a new object based on a source one (some data will be shared between both object)
  27343. * @param creationFunction defines the function used to instanciate the new object
  27344. * @param source defines the source object
  27345. * @returns the new object
  27346. */
  27347. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27348. }
  27349. }
  27350. declare module BABYLON {
  27351. /**
  27352. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27353. */
  27354. export interface CubeMapInfo {
  27355. /**
  27356. * The pixel array for the front face.
  27357. * This is stored in format, left to right, up to down format.
  27358. */
  27359. front: Nullable<ArrayBufferView>;
  27360. /**
  27361. * The pixel array for the back face.
  27362. * This is stored in format, left to right, up to down format.
  27363. */
  27364. back: Nullable<ArrayBufferView>;
  27365. /**
  27366. * The pixel array for the left face.
  27367. * This is stored in format, left to right, up to down format.
  27368. */
  27369. left: Nullable<ArrayBufferView>;
  27370. /**
  27371. * The pixel array for the right face.
  27372. * This is stored in format, left to right, up to down format.
  27373. */
  27374. right: Nullable<ArrayBufferView>;
  27375. /**
  27376. * The pixel array for the up face.
  27377. * This is stored in format, left to right, up to down format.
  27378. */
  27379. up: Nullable<ArrayBufferView>;
  27380. /**
  27381. * The pixel array for the down face.
  27382. * This is stored in format, left to right, up to down format.
  27383. */
  27384. down: Nullable<ArrayBufferView>;
  27385. /**
  27386. * The size of the cubemap stored.
  27387. *
  27388. * Each faces will be size * size pixels.
  27389. */
  27390. size: number;
  27391. /**
  27392. * The format of the texture.
  27393. *
  27394. * RGBA, RGB.
  27395. */
  27396. format: number;
  27397. /**
  27398. * The type of the texture data.
  27399. *
  27400. * UNSIGNED_INT, FLOAT.
  27401. */
  27402. type: number;
  27403. /**
  27404. * Specifies whether the texture is in gamma space.
  27405. */
  27406. gammaSpace: boolean;
  27407. }
  27408. /**
  27409. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27410. */
  27411. export class PanoramaToCubeMapTools {
  27412. private static FACE_FRONT;
  27413. private static FACE_BACK;
  27414. private static FACE_RIGHT;
  27415. private static FACE_LEFT;
  27416. private static FACE_DOWN;
  27417. private static FACE_UP;
  27418. /**
  27419. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27420. *
  27421. * @param float32Array The source data.
  27422. * @param inputWidth The width of the input panorama.
  27423. * @param inputHeight The height of the input panorama.
  27424. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27425. * @return The cubemap data
  27426. */
  27427. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27428. private static CreateCubemapTexture;
  27429. private static CalcProjectionSpherical;
  27430. }
  27431. }
  27432. declare module BABYLON {
  27433. /**
  27434. * Helper class dealing with the extraction of spherical polynomial dataArray
  27435. * from a cube map.
  27436. */
  27437. export class CubeMapToSphericalPolynomialTools {
  27438. private static FileFaces;
  27439. /**
  27440. * Converts a texture to the according Spherical Polynomial data.
  27441. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27442. *
  27443. * @param texture The texture to extract the information from.
  27444. * @return The Spherical Polynomial data.
  27445. */
  27446. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27447. /**
  27448. * Converts a cubemap to the according Spherical Polynomial data.
  27449. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27450. *
  27451. * @param cubeInfo The Cube map to extract the information from.
  27452. * @return The Spherical Polynomial data.
  27453. */
  27454. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27455. }
  27456. }
  27457. declare module BABYLON {
  27458. /**
  27459. * Class used to manipulate GUIDs
  27460. */
  27461. export class GUID {
  27462. /**
  27463. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27464. * Be aware Math.random() could cause collisions, but:
  27465. * "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"
  27466. * @returns a pseudo random id
  27467. */
  27468. static RandomId(): string;
  27469. }
  27470. }
  27471. declare module BABYLON {
  27472. /**
  27473. * Base class of all the textures in babylon.
  27474. * It groups all the common properties the materials, post process, lights... might need
  27475. * in order to make a correct use of the texture.
  27476. */
  27477. export class BaseTexture implements IAnimatable {
  27478. /**
  27479. * Default anisotropic filtering level for the application.
  27480. * It is set to 4 as a good tradeoff between perf and quality.
  27481. */
  27482. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27483. /**
  27484. * Gets or sets the unique id of the texture
  27485. */
  27486. uniqueId: number;
  27487. /**
  27488. * Define the name of the texture.
  27489. */
  27490. name: string;
  27491. /**
  27492. * Gets or sets an object used to store user defined information.
  27493. */
  27494. metadata: any;
  27495. /**
  27496. * For internal use only. Please do not use.
  27497. */
  27498. reservedDataStore: any;
  27499. private _hasAlpha;
  27500. /**
  27501. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27502. */
  27503. hasAlpha: boolean;
  27504. /**
  27505. * Defines if the alpha value should be determined via the rgb values.
  27506. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27507. */
  27508. getAlphaFromRGB: boolean;
  27509. /**
  27510. * Intensity or strength of the texture.
  27511. * It is commonly used by materials to fine tune the intensity of the texture
  27512. */
  27513. level: number;
  27514. /**
  27515. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27516. * This is part of the texture as textures usually maps to one uv set.
  27517. */
  27518. coordinatesIndex: number;
  27519. private _coordinatesMode;
  27520. /**
  27521. * How a texture is mapped.
  27522. *
  27523. * | Value | Type | Description |
  27524. * | ----- | ----------------------------------- | ----------- |
  27525. * | 0 | EXPLICIT_MODE | |
  27526. * | 1 | SPHERICAL_MODE | |
  27527. * | 2 | PLANAR_MODE | |
  27528. * | 3 | CUBIC_MODE | |
  27529. * | 4 | PROJECTION_MODE | |
  27530. * | 5 | SKYBOX_MODE | |
  27531. * | 6 | INVCUBIC_MODE | |
  27532. * | 7 | EQUIRECTANGULAR_MODE | |
  27533. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27534. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27535. */
  27536. coordinatesMode: number;
  27537. /**
  27538. * | Value | Type | Description |
  27539. * | ----- | ------------------ | ----------- |
  27540. * | 0 | CLAMP_ADDRESSMODE | |
  27541. * | 1 | WRAP_ADDRESSMODE | |
  27542. * | 2 | MIRROR_ADDRESSMODE | |
  27543. */
  27544. wrapU: number;
  27545. /**
  27546. * | Value | Type | Description |
  27547. * | ----- | ------------------ | ----------- |
  27548. * | 0 | CLAMP_ADDRESSMODE | |
  27549. * | 1 | WRAP_ADDRESSMODE | |
  27550. * | 2 | MIRROR_ADDRESSMODE | |
  27551. */
  27552. wrapV: number;
  27553. /**
  27554. * | Value | Type | Description |
  27555. * | ----- | ------------------ | ----------- |
  27556. * | 0 | CLAMP_ADDRESSMODE | |
  27557. * | 1 | WRAP_ADDRESSMODE | |
  27558. * | 2 | MIRROR_ADDRESSMODE | |
  27559. */
  27560. wrapR: number;
  27561. /**
  27562. * With compliant hardware and browser (supporting anisotropic filtering)
  27563. * this defines the level of anisotropic filtering in the texture.
  27564. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27565. */
  27566. anisotropicFilteringLevel: number;
  27567. /**
  27568. * Define if the texture is a cube texture or if false a 2d texture.
  27569. */
  27570. isCube: boolean;
  27571. /**
  27572. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27573. */
  27574. is3D: boolean;
  27575. /**
  27576. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27577. * HDR texture are usually stored in linear space.
  27578. * This only impacts the PBR and Background materials
  27579. */
  27580. gammaSpace: boolean;
  27581. /**
  27582. * Gets whether or not the texture contains RGBD data.
  27583. */
  27584. readonly isRGBD: boolean;
  27585. /**
  27586. * Is Z inverted in the texture (useful in a cube texture).
  27587. */
  27588. invertZ: boolean;
  27589. /**
  27590. * Are mip maps generated for this texture or not.
  27591. */
  27592. readonly noMipmap: boolean;
  27593. /**
  27594. * @hidden
  27595. */
  27596. lodLevelInAlpha: boolean;
  27597. /**
  27598. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27599. */
  27600. lodGenerationOffset: number;
  27601. /**
  27602. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27603. */
  27604. lodGenerationScale: number;
  27605. /**
  27606. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27607. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27608. * average roughness values.
  27609. */
  27610. linearSpecularLOD: boolean;
  27611. /**
  27612. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27613. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27614. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27615. */
  27616. irradianceTexture: Nullable<BaseTexture>;
  27617. /**
  27618. * Define if the texture is a render target.
  27619. */
  27620. isRenderTarget: boolean;
  27621. /**
  27622. * Define the unique id of the texture in the scene.
  27623. */
  27624. readonly uid: string;
  27625. /**
  27626. * Return a string representation of the texture.
  27627. * @returns the texture as a string
  27628. */
  27629. toString(): string;
  27630. /**
  27631. * Get the class name of the texture.
  27632. * @returns "BaseTexture"
  27633. */
  27634. getClassName(): string;
  27635. /**
  27636. * Define the list of animation attached to the texture.
  27637. */
  27638. animations: Animation[];
  27639. /**
  27640. * An event triggered when the texture is disposed.
  27641. */
  27642. onDisposeObservable: Observable<BaseTexture>;
  27643. private _onDisposeObserver;
  27644. /**
  27645. * Callback triggered when the texture has been disposed.
  27646. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27647. */
  27648. onDispose: () => void;
  27649. /**
  27650. * Define the current state of the loading sequence when in delayed load mode.
  27651. */
  27652. delayLoadState: number;
  27653. private _scene;
  27654. /** @hidden */
  27655. _texture: Nullable<InternalTexture>;
  27656. private _uid;
  27657. /**
  27658. * Define if the texture is preventinga material to render or not.
  27659. * If not and the texture is not ready, the engine will use a default black texture instead.
  27660. */
  27661. readonly isBlocking: boolean;
  27662. /**
  27663. * Instantiates a new BaseTexture.
  27664. * Base class of all the textures in babylon.
  27665. * It groups all the common properties the materials, post process, lights... might need
  27666. * in order to make a correct use of the texture.
  27667. * @param scene Define the scene the texture blongs to
  27668. */
  27669. constructor(scene: Nullable<Scene>);
  27670. /**
  27671. * Get the scene the texture belongs to.
  27672. * @returns the scene or null if undefined
  27673. */
  27674. getScene(): Nullable<Scene>;
  27675. /**
  27676. * Get the texture transform matrix used to offset tile the texture for istance.
  27677. * @returns the transformation matrix
  27678. */
  27679. getTextureMatrix(): Matrix;
  27680. /**
  27681. * Get the texture reflection matrix used to rotate/transform the reflection.
  27682. * @returns the reflection matrix
  27683. */
  27684. getReflectionTextureMatrix(): Matrix;
  27685. /**
  27686. * Get the underlying lower level texture from Babylon.
  27687. * @returns the insternal texture
  27688. */
  27689. getInternalTexture(): Nullable<InternalTexture>;
  27690. /**
  27691. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27692. * @returns true if ready or not blocking
  27693. */
  27694. isReadyOrNotBlocking(): boolean;
  27695. /**
  27696. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27697. * @returns true if fully ready
  27698. */
  27699. isReady(): boolean;
  27700. private _cachedSize;
  27701. /**
  27702. * Get the size of the texture.
  27703. * @returns the texture size.
  27704. */
  27705. getSize(): ISize;
  27706. /**
  27707. * Get the base size of the texture.
  27708. * It can be different from the size if the texture has been resized for POT for instance
  27709. * @returns the base size
  27710. */
  27711. getBaseSize(): ISize;
  27712. /**
  27713. * Update the sampling mode of the texture.
  27714. * Default is Trilinear mode.
  27715. *
  27716. * | Value | Type | Description |
  27717. * | ----- | ------------------ | ----------- |
  27718. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27719. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27720. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27721. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27722. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27723. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27724. * | 7 | NEAREST_LINEAR | |
  27725. * | 8 | NEAREST_NEAREST | |
  27726. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27727. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27728. * | 11 | LINEAR_LINEAR | |
  27729. * | 12 | LINEAR_NEAREST | |
  27730. *
  27731. * > _mag_: magnification filter (close to the viewer)
  27732. * > _min_: minification filter (far from the viewer)
  27733. * > _mip_: filter used between mip map levels
  27734. *@param samplingMode Define the new sampling mode of the texture
  27735. */
  27736. updateSamplingMode(samplingMode: number): void;
  27737. /**
  27738. * Scales the texture if is `canRescale()`
  27739. * @param ratio the resize factor we want to use to rescale
  27740. */
  27741. scale(ratio: number): void;
  27742. /**
  27743. * Get if the texture can rescale.
  27744. */
  27745. readonly canRescale: boolean;
  27746. /** @hidden */
  27747. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27748. /** @hidden */
  27749. _rebuild(): void;
  27750. /**
  27751. * Triggers the load sequence in delayed load mode.
  27752. */
  27753. delayLoad(): void;
  27754. /**
  27755. * Clones the texture.
  27756. * @returns the cloned texture
  27757. */
  27758. clone(): Nullable<BaseTexture>;
  27759. /**
  27760. * Get the texture underlying type (INT, FLOAT...)
  27761. */
  27762. readonly textureType: number;
  27763. /**
  27764. * Get the texture underlying format (RGB, RGBA...)
  27765. */
  27766. readonly textureFormat: number;
  27767. /**
  27768. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27769. * This will returns an RGBA array buffer containing either in values (0-255) or
  27770. * float values (0-1) depending of the underlying buffer type.
  27771. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27772. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27773. * @param buffer defines a user defined buffer to fill with data (can be null)
  27774. * @returns The Array buffer containing the pixels data.
  27775. */
  27776. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27777. /**
  27778. * Release and destroy the underlying lower level texture aka internalTexture.
  27779. */
  27780. releaseInternalTexture(): void;
  27781. /**
  27782. * Get the polynomial representation of the texture data.
  27783. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27784. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27785. */
  27786. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27787. /** @hidden */
  27788. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27789. /** @hidden */
  27790. readonly _lodTextureMid: Nullable<BaseTexture>;
  27791. /** @hidden */
  27792. readonly _lodTextureLow: Nullable<BaseTexture>;
  27793. /**
  27794. * Dispose the texture and release its associated resources.
  27795. */
  27796. dispose(): void;
  27797. /**
  27798. * Serialize the texture into a JSON representation that can be parsed later on.
  27799. * @returns the JSON representation of the texture
  27800. */
  27801. serialize(): any;
  27802. /**
  27803. * Helper function to be called back once a list of texture contains only ready textures.
  27804. * @param textures Define the list of textures to wait for
  27805. * @param callback Define the callback triggered once the entire list will be ready
  27806. */
  27807. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27808. }
  27809. }
  27810. declare module BABYLON {
  27811. /**
  27812. * Class used to store data associated with WebGL texture data for the engine
  27813. * This class should not be used directly
  27814. */
  27815. export class InternalTexture {
  27816. /** @hidden */
  27817. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27818. /**
  27819. * The source of the texture data is unknown
  27820. */
  27821. static DATASOURCE_UNKNOWN: number;
  27822. /**
  27823. * Texture data comes from an URL
  27824. */
  27825. static DATASOURCE_URL: number;
  27826. /**
  27827. * Texture data is only used for temporary storage
  27828. */
  27829. static DATASOURCE_TEMP: number;
  27830. /**
  27831. * Texture data comes from raw data (ArrayBuffer)
  27832. */
  27833. static DATASOURCE_RAW: number;
  27834. /**
  27835. * Texture content is dynamic (video or dynamic texture)
  27836. */
  27837. static DATASOURCE_DYNAMIC: number;
  27838. /**
  27839. * Texture content is generated by rendering to it
  27840. */
  27841. static DATASOURCE_RENDERTARGET: number;
  27842. /**
  27843. * Texture content is part of a multi render target process
  27844. */
  27845. static DATASOURCE_MULTIRENDERTARGET: number;
  27846. /**
  27847. * Texture data comes from a cube data file
  27848. */
  27849. static DATASOURCE_CUBE: number;
  27850. /**
  27851. * Texture data comes from a raw cube data
  27852. */
  27853. static DATASOURCE_CUBERAW: number;
  27854. /**
  27855. * Texture data come from a prefiltered cube data file
  27856. */
  27857. static DATASOURCE_CUBEPREFILTERED: number;
  27858. /**
  27859. * Texture content is raw 3D data
  27860. */
  27861. static DATASOURCE_RAW3D: number;
  27862. /**
  27863. * Texture content is a depth texture
  27864. */
  27865. static DATASOURCE_DEPTHTEXTURE: number;
  27866. /**
  27867. * Texture data comes from a raw cube data encoded with RGBD
  27868. */
  27869. static DATASOURCE_CUBERAW_RGBD: number;
  27870. /**
  27871. * Defines if the texture is ready
  27872. */
  27873. isReady: boolean;
  27874. /**
  27875. * Defines if the texture is a cube texture
  27876. */
  27877. isCube: boolean;
  27878. /**
  27879. * Defines if the texture contains 3D data
  27880. */
  27881. is3D: boolean;
  27882. /**
  27883. * Defines if the texture contains multiview data
  27884. */
  27885. isMultiview: boolean;
  27886. /**
  27887. * Gets the URL used to load this texture
  27888. */
  27889. url: string;
  27890. /**
  27891. * Gets the sampling mode of the texture
  27892. */
  27893. samplingMode: number;
  27894. /**
  27895. * Gets a boolean indicating if the texture needs mipmaps generation
  27896. */
  27897. generateMipMaps: boolean;
  27898. /**
  27899. * Gets the number of samples used by the texture (WebGL2+ only)
  27900. */
  27901. samples: number;
  27902. /**
  27903. * Gets the type of the texture (int, float...)
  27904. */
  27905. type: number;
  27906. /**
  27907. * Gets the format of the texture (RGB, RGBA...)
  27908. */
  27909. format: number;
  27910. /**
  27911. * Observable called when the texture is loaded
  27912. */
  27913. onLoadedObservable: Observable<InternalTexture>;
  27914. /**
  27915. * Gets the width of the texture
  27916. */
  27917. width: number;
  27918. /**
  27919. * Gets the height of the texture
  27920. */
  27921. height: number;
  27922. /**
  27923. * Gets the depth of the texture
  27924. */
  27925. depth: number;
  27926. /**
  27927. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27928. */
  27929. baseWidth: number;
  27930. /**
  27931. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27932. */
  27933. baseHeight: number;
  27934. /**
  27935. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27936. */
  27937. baseDepth: number;
  27938. /**
  27939. * Gets a boolean indicating if the texture is inverted on Y axis
  27940. */
  27941. invertY: boolean;
  27942. /** @hidden */
  27943. _invertVScale: boolean;
  27944. /** @hidden */
  27945. _associatedChannel: number;
  27946. /** @hidden */
  27947. _dataSource: number;
  27948. /** @hidden */
  27949. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  27950. /** @hidden */
  27951. _bufferView: Nullable<ArrayBufferView>;
  27952. /** @hidden */
  27953. _bufferViewArray: Nullable<ArrayBufferView[]>;
  27954. /** @hidden */
  27955. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  27956. /** @hidden */
  27957. _size: number;
  27958. /** @hidden */
  27959. _extension: string;
  27960. /** @hidden */
  27961. _files: Nullable<string[]>;
  27962. /** @hidden */
  27963. _workingCanvas: Nullable<HTMLCanvasElement>;
  27964. /** @hidden */
  27965. _workingContext: Nullable<CanvasRenderingContext2D>;
  27966. /** @hidden */
  27967. _framebuffer: Nullable<WebGLFramebuffer>;
  27968. /** @hidden */
  27969. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  27970. /** @hidden */
  27971. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  27972. /** @hidden */
  27973. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  27974. /** @hidden */
  27975. _attachments: Nullable<number[]>;
  27976. /** @hidden */
  27977. _cachedCoordinatesMode: Nullable<number>;
  27978. /** @hidden */
  27979. _cachedWrapU: Nullable<number>;
  27980. /** @hidden */
  27981. _cachedWrapV: Nullable<number>;
  27982. /** @hidden */
  27983. _cachedWrapR: Nullable<number>;
  27984. /** @hidden */
  27985. _cachedAnisotropicFilteringLevel: Nullable<number>;
  27986. /** @hidden */
  27987. _isDisabled: boolean;
  27988. /** @hidden */
  27989. _compression: Nullable<string>;
  27990. /** @hidden */
  27991. _generateStencilBuffer: boolean;
  27992. /** @hidden */
  27993. _generateDepthBuffer: boolean;
  27994. /** @hidden */
  27995. _comparisonFunction: number;
  27996. /** @hidden */
  27997. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  27998. /** @hidden */
  27999. _lodGenerationScale: number;
  28000. /** @hidden */
  28001. _lodGenerationOffset: number;
  28002. /** @hidden */
  28003. _colorTextureArray: Nullable<WebGLTexture>;
  28004. /** @hidden */
  28005. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28006. /** @hidden */
  28007. _lodTextureHigh: Nullable<BaseTexture>;
  28008. /** @hidden */
  28009. _lodTextureMid: Nullable<BaseTexture>;
  28010. /** @hidden */
  28011. _lodTextureLow: Nullable<BaseTexture>;
  28012. /** @hidden */
  28013. _isRGBD: boolean;
  28014. /** @hidden */
  28015. _linearSpecularLOD: boolean;
  28016. /** @hidden */
  28017. _irradianceTexture: Nullable<BaseTexture>;
  28018. /** @hidden */
  28019. _webGLTexture: Nullable<WebGLTexture>;
  28020. /** @hidden */
  28021. _references: number;
  28022. private _engine;
  28023. /**
  28024. * Gets the Engine the texture belongs to.
  28025. * @returns The babylon engine
  28026. */
  28027. getEngine(): Engine;
  28028. /**
  28029. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28030. */
  28031. readonly dataSource: number;
  28032. /**
  28033. * Creates a new InternalTexture
  28034. * @param engine defines the engine to use
  28035. * @param dataSource defines the type of data that will be used
  28036. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28037. */
  28038. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28039. /**
  28040. * Increments the number of references (ie. the number of Texture that point to it)
  28041. */
  28042. incrementReferences(): void;
  28043. /**
  28044. * Change the size of the texture (not the size of the content)
  28045. * @param width defines the new width
  28046. * @param height defines the new height
  28047. * @param depth defines the new depth (1 by default)
  28048. */
  28049. updateSize(width: int, height: int, depth?: int): void;
  28050. /** @hidden */
  28051. _rebuild(): void;
  28052. /** @hidden */
  28053. _swapAndDie(target: InternalTexture): void;
  28054. /**
  28055. * Dispose the current allocated resources
  28056. */
  28057. dispose(): void;
  28058. }
  28059. }
  28060. declare module BABYLON {
  28061. /**
  28062. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28063. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28064. */
  28065. export class EffectFallbacks {
  28066. private _defines;
  28067. private _currentRank;
  28068. private _maxRank;
  28069. private _mesh;
  28070. /**
  28071. * Removes the fallback from the bound mesh.
  28072. */
  28073. unBindMesh(): void;
  28074. /**
  28075. * Adds a fallback on the specified property.
  28076. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28077. * @param define The name of the define in the shader
  28078. */
  28079. addFallback(rank: number, define: string): void;
  28080. /**
  28081. * Sets the mesh to use CPU skinning when needing to fallback.
  28082. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28083. * @param mesh The mesh to use the fallbacks.
  28084. */
  28085. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28086. /**
  28087. * Checks to see if more fallbacks are still availible.
  28088. */
  28089. readonly isMoreFallbacks: boolean;
  28090. /**
  28091. * Removes the defines that should be removed when falling back.
  28092. * @param currentDefines defines the current define statements for the shader.
  28093. * @param effect defines the current effect we try to compile
  28094. * @returns The resulting defines with defines of the current rank removed.
  28095. */
  28096. reduce(currentDefines: string, effect: Effect): string;
  28097. }
  28098. /**
  28099. * Options to be used when creating an effect.
  28100. */
  28101. export class EffectCreationOptions {
  28102. /**
  28103. * Atrributes that will be used in the shader.
  28104. */
  28105. attributes: string[];
  28106. /**
  28107. * Uniform varible names that will be set in the shader.
  28108. */
  28109. uniformsNames: string[];
  28110. /**
  28111. * Uniform buffer varible names that will be set in the shader.
  28112. */
  28113. uniformBuffersNames: string[];
  28114. /**
  28115. * Sampler texture variable names that will be set in the shader.
  28116. */
  28117. samplers: string[];
  28118. /**
  28119. * Define statements that will be set in the shader.
  28120. */
  28121. defines: any;
  28122. /**
  28123. * Possible fallbacks for this effect to improve performance when needed.
  28124. */
  28125. fallbacks: Nullable<EffectFallbacks>;
  28126. /**
  28127. * Callback that will be called when the shader is compiled.
  28128. */
  28129. onCompiled: Nullable<(effect: Effect) => void>;
  28130. /**
  28131. * Callback that will be called if an error occurs during shader compilation.
  28132. */
  28133. onError: Nullable<(effect: Effect, errors: string) => void>;
  28134. /**
  28135. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28136. */
  28137. indexParameters: any;
  28138. /**
  28139. * Max number of lights that can be used in the shader.
  28140. */
  28141. maxSimultaneousLights: number;
  28142. /**
  28143. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28144. */
  28145. transformFeedbackVaryings: Nullable<string[]>;
  28146. }
  28147. /**
  28148. * Effect containing vertex and fragment shader that can be executed on an object.
  28149. */
  28150. export class Effect implements IDisposable {
  28151. /**
  28152. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28153. */
  28154. static ShadersRepository: string;
  28155. /**
  28156. * Name of the effect.
  28157. */
  28158. name: any;
  28159. /**
  28160. * String container all the define statements that should be set on the shader.
  28161. */
  28162. defines: string;
  28163. /**
  28164. * Callback that will be called when the shader is compiled.
  28165. */
  28166. onCompiled: Nullable<(effect: Effect) => void>;
  28167. /**
  28168. * Callback that will be called if an error occurs during shader compilation.
  28169. */
  28170. onError: Nullable<(effect: Effect, errors: string) => void>;
  28171. /**
  28172. * Callback that will be called when effect is bound.
  28173. */
  28174. onBind: Nullable<(effect: Effect) => void>;
  28175. /**
  28176. * Unique ID of the effect.
  28177. */
  28178. uniqueId: number;
  28179. /**
  28180. * Observable that will be called when the shader is compiled.
  28181. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28182. */
  28183. onCompileObservable: Observable<Effect>;
  28184. /**
  28185. * Observable that will be called if an error occurs during shader compilation.
  28186. */
  28187. onErrorObservable: Observable<Effect>;
  28188. /** @hidden */
  28189. _onBindObservable: Nullable<Observable<Effect>>;
  28190. /**
  28191. * Observable that will be called when effect is bound.
  28192. */
  28193. readonly onBindObservable: Observable<Effect>;
  28194. /** @hidden */
  28195. _bonesComputationForcedToCPU: boolean;
  28196. private static _uniqueIdSeed;
  28197. private _engine;
  28198. private _uniformBuffersNames;
  28199. private _uniformsNames;
  28200. private _samplerList;
  28201. private _samplers;
  28202. private _isReady;
  28203. private _compilationError;
  28204. private _attributesNames;
  28205. private _attributes;
  28206. private _uniforms;
  28207. /**
  28208. * Key for the effect.
  28209. * @hidden
  28210. */
  28211. _key: string;
  28212. private _indexParameters;
  28213. private _fallbacks;
  28214. private _vertexSourceCode;
  28215. private _fragmentSourceCode;
  28216. private _vertexSourceCodeOverride;
  28217. private _fragmentSourceCodeOverride;
  28218. private _transformFeedbackVaryings;
  28219. /**
  28220. * Compiled shader to webGL program.
  28221. * @hidden
  28222. */
  28223. _pipelineContext: Nullable<IPipelineContext>;
  28224. private _valueCache;
  28225. private static _baseCache;
  28226. /**
  28227. * Instantiates an effect.
  28228. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28229. * @param baseName Name of the effect.
  28230. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28231. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28232. * @param samplers List of sampler variables that will be passed to the shader.
  28233. * @param engine Engine to be used to render the effect
  28234. * @param defines Define statements to be added to the shader.
  28235. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28236. * @param onCompiled Callback that will be called when the shader is compiled.
  28237. * @param onError Callback that will be called if an error occurs during shader compilation.
  28238. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28239. */
  28240. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28241. private _useFinalCode;
  28242. /**
  28243. * Unique key for this effect
  28244. */
  28245. readonly key: string;
  28246. /**
  28247. * If the effect has been compiled and prepared.
  28248. * @returns if the effect is compiled and prepared.
  28249. */
  28250. isReady(): boolean;
  28251. /**
  28252. * The engine the effect was initialized with.
  28253. * @returns the engine.
  28254. */
  28255. getEngine(): Engine;
  28256. /**
  28257. * The pipeline context for this effect
  28258. * @returns the associated pipeline context
  28259. */
  28260. getPipelineContext(): Nullable<IPipelineContext>;
  28261. /**
  28262. * The set of names of attribute variables for the shader.
  28263. * @returns An array of attribute names.
  28264. */
  28265. getAttributesNames(): string[];
  28266. /**
  28267. * Returns the attribute at the given index.
  28268. * @param index The index of the attribute.
  28269. * @returns The location of the attribute.
  28270. */
  28271. getAttributeLocation(index: number): number;
  28272. /**
  28273. * Returns the attribute based on the name of the variable.
  28274. * @param name of the attribute to look up.
  28275. * @returns the attribute location.
  28276. */
  28277. getAttributeLocationByName(name: string): number;
  28278. /**
  28279. * The number of attributes.
  28280. * @returns the numnber of attributes.
  28281. */
  28282. getAttributesCount(): number;
  28283. /**
  28284. * Gets the index of a uniform variable.
  28285. * @param uniformName of the uniform to look up.
  28286. * @returns the index.
  28287. */
  28288. getUniformIndex(uniformName: string): number;
  28289. /**
  28290. * Returns the attribute based on the name of the variable.
  28291. * @param uniformName of the uniform to look up.
  28292. * @returns the location of the uniform.
  28293. */
  28294. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28295. /**
  28296. * Returns an array of sampler variable names
  28297. * @returns The array of sampler variable neames.
  28298. */
  28299. getSamplers(): string[];
  28300. /**
  28301. * The error from the last compilation.
  28302. * @returns the error string.
  28303. */
  28304. getCompilationError(): string;
  28305. /**
  28306. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28307. * @param func The callback to be used.
  28308. */
  28309. executeWhenCompiled(func: (effect: Effect) => void): void;
  28310. private _checkIsReady;
  28311. /** @hidden */
  28312. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28313. /** @hidden */
  28314. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28315. /** @hidden */
  28316. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28317. /**
  28318. * Recompiles the webGL program
  28319. * @param vertexSourceCode The source code for the vertex shader.
  28320. * @param fragmentSourceCode The source code for the fragment shader.
  28321. * @param onCompiled Callback called when completed.
  28322. * @param onError Callback called on error.
  28323. * @hidden
  28324. */
  28325. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28326. /**
  28327. * Prepares the effect
  28328. * @hidden
  28329. */
  28330. _prepareEffect(): void;
  28331. /**
  28332. * Checks if the effect is supported. (Must be called after compilation)
  28333. */
  28334. readonly isSupported: boolean;
  28335. /**
  28336. * Binds a texture to the engine to be used as output of the shader.
  28337. * @param channel Name of the output variable.
  28338. * @param texture Texture to bind.
  28339. * @hidden
  28340. */
  28341. _bindTexture(channel: string, texture: InternalTexture): void;
  28342. /**
  28343. * Sets a texture on the engine to be used in the shader.
  28344. * @param channel Name of the sampler variable.
  28345. * @param texture Texture to set.
  28346. */
  28347. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28348. /**
  28349. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28350. * @param channel Name of the sampler variable.
  28351. * @param texture Texture to set.
  28352. */
  28353. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28354. /**
  28355. * Sets an array of textures on the engine to be used in the shader.
  28356. * @param channel Name of the variable.
  28357. * @param textures Textures to set.
  28358. */
  28359. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28360. /**
  28361. * 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)
  28362. * @param channel Name of the sampler variable.
  28363. * @param postProcess Post process to get the input texture from.
  28364. */
  28365. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28366. /**
  28367. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28368. * 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)
  28369. * @param channel Name of the sampler variable.
  28370. * @param postProcess Post process to get the output texture from.
  28371. */
  28372. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28373. /** @hidden */
  28374. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28375. /** @hidden */
  28376. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28377. /** @hidden */
  28378. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28379. /** @hidden */
  28380. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28381. /**
  28382. * Binds a buffer to a uniform.
  28383. * @param buffer Buffer to bind.
  28384. * @param name Name of the uniform variable to bind to.
  28385. */
  28386. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28387. /**
  28388. * Binds block to a uniform.
  28389. * @param blockName Name of the block to bind.
  28390. * @param index Index to bind.
  28391. */
  28392. bindUniformBlock(blockName: string, index: number): void;
  28393. /**
  28394. * Sets an interger value on a uniform variable.
  28395. * @param uniformName Name of the variable.
  28396. * @param value Value to be set.
  28397. * @returns this effect.
  28398. */
  28399. setInt(uniformName: string, value: number): Effect;
  28400. /**
  28401. * Sets an int array on a uniform variable.
  28402. * @param uniformName Name of the variable.
  28403. * @param array array to be set.
  28404. * @returns this effect.
  28405. */
  28406. setIntArray(uniformName: string, array: Int32Array): Effect;
  28407. /**
  28408. * 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)
  28409. * @param uniformName Name of the variable.
  28410. * @param array array to be set.
  28411. * @returns this effect.
  28412. */
  28413. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28414. /**
  28415. * 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)
  28416. * @param uniformName Name of the variable.
  28417. * @param array array to be set.
  28418. * @returns this effect.
  28419. */
  28420. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28421. /**
  28422. * 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)
  28423. * @param uniformName Name of the variable.
  28424. * @param array array to be set.
  28425. * @returns this effect.
  28426. */
  28427. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28428. /**
  28429. * Sets an float array on a uniform variable.
  28430. * @param uniformName Name of the variable.
  28431. * @param array array to be set.
  28432. * @returns this effect.
  28433. */
  28434. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28435. /**
  28436. * 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)
  28437. * @param uniformName Name of the variable.
  28438. * @param array array to be set.
  28439. * @returns this effect.
  28440. */
  28441. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28442. /**
  28443. * 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)
  28444. * @param uniformName Name of the variable.
  28445. * @param array array to be set.
  28446. * @returns this effect.
  28447. */
  28448. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28449. /**
  28450. * 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)
  28451. * @param uniformName Name of the variable.
  28452. * @param array array to be set.
  28453. * @returns this effect.
  28454. */
  28455. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28456. /**
  28457. * Sets an array on a uniform variable.
  28458. * @param uniformName Name of the variable.
  28459. * @param array array to be set.
  28460. * @returns this effect.
  28461. */
  28462. setArray(uniformName: string, array: number[]): Effect;
  28463. /**
  28464. * 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)
  28465. * @param uniformName Name of the variable.
  28466. * @param array array to be set.
  28467. * @returns this effect.
  28468. */
  28469. setArray2(uniformName: string, array: number[]): Effect;
  28470. /**
  28471. * 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)
  28472. * @param uniformName Name of the variable.
  28473. * @param array array to be set.
  28474. * @returns this effect.
  28475. */
  28476. setArray3(uniformName: string, array: number[]): Effect;
  28477. /**
  28478. * 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)
  28479. * @param uniformName Name of the variable.
  28480. * @param array array to be set.
  28481. * @returns this effect.
  28482. */
  28483. setArray4(uniformName: string, array: number[]): Effect;
  28484. /**
  28485. * Sets matrices on a uniform variable.
  28486. * @param uniformName Name of the variable.
  28487. * @param matrices matrices to be set.
  28488. * @returns this effect.
  28489. */
  28490. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28491. /**
  28492. * Sets matrix on a uniform variable.
  28493. * @param uniformName Name of the variable.
  28494. * @param matrix matrix to be set.
  28495. * @returns this effect.
  28496. */
  28497. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28498. /**
  28499. * 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)
  28500. * @param uniformName Name of the variable.
  28501. * @param matrix matrix to be set.
  28502. * @returns this effect.
  28503. */
  28504. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28505. /**
  28506. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28507. * @param uniformName Name of the variable.
  28508. * @param matrix matrix to be set.
  28509. * @returns this effect.
  28510. */
  28511. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28512. /**
  28513. * Sets a float on a uniform variable.
  28514. * @param uniformName Name of the variable.
  28515. * @param value value to be set.
  28516. * @returns this effect.
  28517. */
  28518. setFloat(uniformName: string, value: number): Effect;
  28519. /**
  28520. * Sets a boolean on a uniform variable.
  28521. * @param uniformName Name of the variable.
  28522. * @param bool value to be set.
  28523. * @returns this effect.
  28524. */
  28525. setBool(uniformName: string, bool: boolean): Effect;
  28526. /**
  28527. * Sets a Vector2 on a uniform variable.
  28528. * @param uniformName Name of the variable.
  28529. * @param vector2 vector2 to be set.
  28530. * @returns this effect.
  28531. */
  28532. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28533. /**
  28534. * Sets a float2 on a uniform variable.
  28535. * @param uniformName Name of the variable.
  28536. * @param x First float in float2.
  28537. * @param y Second float in float2.
  28538. * @returns this effect.
  28539. */
  28540. setFloat2(uniformName: string, x: number, y: number): Effect;
  28541. /**
  28542. * Sets a Vector3 on a uniform variable.
  28543. * @param uniformName Name of the variable.
  28544. * @param vector3 Value to be set.
  28545. * @returns this effect.
  28546. */
  28547. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28548. /**
  28549. * Sets a float3 on a uniform variable.
  28550. * @param uniformName Name of the variable.
  28551. * @param x First float in float3.
  28552. * @param y Second float in float3.
  28553. * @param z Third float in float3.
  28554. * @returns this effect.
  28555. */
  28556. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28557. /**
  28558. * Sets a Vector4 on a uniform variable.
  28559. * @param uniformName Name of the variable.
  28560. * @param vector4 Value to be set.
  28561. * @returns this effect.
  28562. */
  28563. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28564. /**
  28565. * Sets a float4 on a uniform variable.
  28566. * @param uniformName Name of the variable.
  28567. * @param x First float in float4.
  28568. * @param y Second float in float4.
  28569. * @param z Third float in float4.
  28570. * @param w Fourth float in float4.
  28571. * @returns this effect.
  28572. */
  28573. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28574. /**
  28575. * Sets a Color3 on a uniform variable.
  28576. * @param uniformName Name of the variable.
  28577. * @param color3 Value to be set.
  28578. * @returns this effect.
  28579. */
  28580. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28581. /**
  28582. * Sets a Color4 on a uniform variable.
  28583. * @param uniformName Name of the variable.
  28584. * @param color3 Value to be set.
  28585. * @param alpha Alpha value to be set.
  28586. * @returns this effect.
  28587. */
  28588. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28589. /**
  28590. * Sets a Color4 on a uniform variable
  28591. * @param uniformName defines the name of the variable
  28592. * @param color4 defines the value to be set
  28593. * @returns this effect.
  28594. */
  28595. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28596. /** Release all associated resources */
  28597. dispose(): void;
  28598. /**
  28599. * This function will add a new shader to the shader store
  28600. * @param name the name of the shader
  28601. * @param pixelShader optional pixel shader content
  28602. * @param vertexShader optional vertex shader content
  28603. */
  28604. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28605. /**
  28606. * Store of each shader (The can be looked up using effect.key)
  28607. */
  28608. static ShadersStore: {
  28609. [key: string]: string;
  28610. };
  28611. /**
  28612. * Store of each included file for a shader (The can be looked up using effect.key)
  28613. */
  28614. static IncludesShadersStore: {
  28615. [key: string]: string;
  28616. };
  28617. /**
  28618. * Resets the cache of effects.
  28619. */
  28620. static ResetCache(): void;
  28621. }
  28622. }
  28623. declare module BABYLON {
  28624. /**
  28625. * Uniform buffer objects.
  28626. *
  28627. * Handles blocks of uniform on the GPU.
  28628. *
  28629. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28630. *
  28631. * For more information, please refer to :
  28632. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28633. */
  28634. export class UniformBuffer {
  28635. private _engine;
  28636. private _buffer;
  28637. private _data;
  28638. private _bufferData;
  28639. private _dynamic?;
  28640. private _uniformLocations;
  28641. private _uniformSizes;
  28642. private _uniformLocationPointer;
  28643. private _needSync;
  28644. private _noUBO;
  28645. private _currentEffect;
  28646. private static _MAX_UNIFORM_SIZE;
  28647. private static _tempBuffer;
  28648. /**
  28649. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28650. * This is dynamic to allow compat with webgl 1 and 2.
  28651. * You will need to pass the name of the uniform as well as the value.
  28652. */
  28653. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28654. /**
  28655. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28656. * This is dynamic to allow compat with webgl 1 and 2.
  28657. * You will need to pass the name of the uniform as well as the value.
  28658. */
  28659. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28660. /**
  28661. * Lambda to Update a single float in a uniform buffer.
  28662. * This is dynamic to allow compat with webgl 1 and 2.
  28663. * You will need to pass the name of the uniform as well as the value.
  28664. */
  28665. updateFloat: (name: string, x: number) => void;
  28666. /**
  28667. * Lambda to Update a vec2 of float in a uniform buffer.
  28668. * This is dynamic to allow compat with webgl 1 and 2.
  28669. * You will need to pass the name of the uniform as well as the value.
  28670. */
  28671. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28672. /**
  28673. * Lambda to Update a vec3 of float in a uniform buffer.
  28674. * This is dynamic to allow compat with webgl 1 and 2.
  28675. * You will need to pass the name of the uniform as well as the value.
  28676. */
  28677. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28678. /**
  28679. * Lambda to Update a vec4 of float in a uniform buffer.
  28680. * This is dynamic to allow compat with webgl 1 and 2.
  28681. * You will need to pass the name of the uniform as well as the value.
  28682. */
  28683. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28684. /**
  28685. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28686. * This is dynamic to allow compat with webgl 1 and 2.
  28687. * You will need to pass the name of the uniform as well as the value.
  28688. */
  28689. updateMatrix: (name: string, mat: Matrix) => void;
  28690. /**
  28691. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28692. * This is dynamic to allow compat with webgl 1 and 2.
  28693. * You will need to pass the name of the uniform as well as the value.
  28694. */
  28695. updateVector3: (name: string, vector: Vector3) => void;
  28696. /**
  28697. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28698. * This is dynamic to allow compat with webgl 1 and 2.
  28699. * You will need to pass the name of the uniform as well as the value.
  28700. */
  28701. updateVector4: (name: string, vector: Vector4) => void;
  28702. /**
  28703. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28704. * This is dynamic to allow compat with webgl 1 and 2.
  28705. * You will need to pass the name of the uniform as well as the value.
  28706. */
  28707. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28708. /**
  28709. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28710. * This is dynamic to allow compat with webgl 1 and 2.
  28711. * You will need to pass the name of the uniform as well as the value.
  28712. */
  28713. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28714. /**
  28715. * Instantiates a new Uniform buffer objects.
  28716. *
  28717. * Handles blocks of uniform on the GPU.
  28718. *
  28719. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28720. *
  28721. * For more information, please refer to :
  28722. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28723. * @param engine Define the engine the buffer is associated with
  28724. * @param data Define the data contained in the buffer
  28725. * @param dynamic Define if the buffer is updatable
  28726. */
  28727. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28728. /**
  28729. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28730. * or just falling back on setUniformXXX calls.
  28731. */
  28732. readonly useUbo: boolean;
  28733. /**
  28734. * Indicates if the WebGL underlying uniform buffer is in sync
  28735. * with the javascript cache data.
  28736. */
  28737. readonly isSync: boolean;
  28738. /**
  28739. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28740. * Also, a dynamic UniformBuffer will disable cache verification and always
  28741. * update the underlying WebGL uniform buffer to the GPU.
  28742. * @returns if Dynamic, otherwise false
  28743. */
  28744. isDynamic(): boolean;
  28745. /**
  28746. * The data cache on JS side.
  28747. * @returns the underlying data as a float array
  28748. */
  28749. getData(): Float32Array;
  28750. /**
  28751. * The underlying WebGL Uniform buffer.
  28752. * @returns the webgl buffer
  28753. */
  28754. getBuffer(): Nullable<DataBuffer>;
  28755. /**
  28756. * std140 layout specifies how to align data within an UBO structure.
  28757. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28758. * for specs.
  28759. */
  28760. private _fillAlignment;
  28761. /**
  28762. * Adds an uniform in the buffer.
  28763. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28764. * for the layout to be correct !
  28765. * @param name Name of the uniform, as used in the uniform block in the shader.
  28766. * @param size Data size, or data directly.
  28767. */
  28768. addUniform(name: string, size: number | number[]): void;
  28769. /**
  28770. * Adds a Matrix 4x4 to the uniform buffer.
  28771. * @param name Name of the uniform, as used in the uniform block in the shader.
  28772. * @param mat A 4x4 matrix.
  28773. */
  28774. addMatrix(name: string, mat: Matrix): void;
  28775. /**
  28776. * Adds a vec2 to the uniform buffer.
  28777. * @param name Name of the uniform, as used in the uniform block in the shader.
  28778. * @param x Define the x component value of the vec2
  28779. * @param y Define the y component value of the vec2
  28780. */
  28781. addFloat2(name: string, x: number, y: number): void;
  28782. /**
  28783. * Adds a vec3 to the uniform buffer.
  28784. * @param name Name of the uniform, as used in the uniform block in the shader.
  28785. * @param x Define the x component value of the vec3
  28786. * @param y Define the y component value of the vec3
  28787. * @param z Define the z component value of the vec3
  28788. */
  28789. addFloat3(name: string, x: number, y: number, z: number): void;
  28790. /**
  28791. * Adds a vec3 to the uniform buffer.
  28792. * @param name Name of the uniform, as used in the uniform block in the shader.
  28793. * @param color Define the vec3 from a Color
  28794. */
  28795. addColor3(name: string, color: Color3): void;
  28796. /**
  28797. * Adds a vec4 to the uniform buffer.
  28798. * @param name Name of the uniform, as used in the uniform block in the shader.
  28799. * @param color Define the rgb components from a Color
  28800. * @param alpha Define the a component of the vec4
  28801. */
  28802. addColor4(name: string, color: Color3, alpha: number): void;
  28803. /**
  28804. * Adds a vec3 to the uniform buffer.
  28805. * @param name Name of the uniform, as used in the uniform block in the shader.
  28806. * @param vector Define the vec3 components from a Vector
  28807. */
  28808. addVector3(name: string, vector: Vector3): void;
  28809. /**
  28810. * Adds a Matrix 3x3 to the uniform buffer.
  28811. * @param name Name of the uniform, as used in the uniform block in the shader.
  28812. */
  28813. addMatrix3x3(name: string): void;
  28814. /**
  28815. * Adds a Matrix 2x2 to the uniform buffer.
  28816. * @param name Name of the uniform, as used in the uniform block in the shader.
  28817. */
  28818. addMatrix2x2(name: string): void;
  28819. /**
  28820. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28821. */
  28822. create(): void;
  28823. /** @hidden */
  28824. _rebuild(): void;
  28825. /**
  28826. * Updates the WebGL Uniform Buffer on the GPU.
  28827. * If the `dynamic` flag is set to true, no cache comparison is done.
  28828. * Otherwise, the buffer will be updated only if the cache differs.
  28829. */
  28830. update(): void;
  28831. /**
  28832. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28833. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28834. * @param data Define the flattened data
  28835. * @param size Define the size of the data.
  28836. */
  28837. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28838. private _updateMatrix3x3ForUniform;
  28839. private _updateMatrix3x3ForEffect;
  28840. private _updateMatrix2x2ForEffect;
  28841. private _updateMatrix2x2ForUniform;
  28842. private _updateFloatForEffect;
  28843. private _updateFloatForUniform;
  28844. private _updateFloat2ForEffect;
  28845. private _updateFloat2ForUniform;
  28846. private _updateFloat3ForEffect;
  28847. private _updateFloat3ForUniform;
  28848. private _updateFloat4ForEffect;
  28849. private _updateFloat4ForUniform;
  28850. private _updateMatrixForEffect;
  28851. private _updateMatrixForUniform;
  28852. private _updateVector3ForEffect;
  28853. private _updateVector3ForUniform;
  28854. private _updateVector4ForEffect;
  28855. private _updateVector4ForUniform;
  28856. private _updateColor3ForEffect;
  28857. private _updateColor3ForUniform;
  28858. private _updateColor4ForEffect;
  28859. private _updateColor4ForUniform;
  28860. /**
  28861. * Sets a sampler uniform on the effect.
  28862. * @param name Define the name of the sampler.
  28863. * @param texture Define the texture to set in the sampler
  28864. */
  28865. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28866. /**
  28867. * Directly updates the value of the uniform in the cache AND on the GPU.
  28868. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28869. * @param data Define the flattened data
  28870. */
  28871. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28872. /**
  28873. * Binds this uniform buffer to an effect.
  28874. * @param effect Define the effect to bind the buffer to
  28875. * @param name Name of the uniform block in the shader.
  28876. */
  28877. bindToEffect(effect: Effect, name: string): void;
  28878. /**
  28879. * Disposes the uniform buffer.
  28880. */
  28881. dispose(): void;
  28882. }
  28883. }
  28884. declare module BABYLON {
  28885. /**
  28886. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28888. */
  28889. export class Analyser {
  28890. /**
  28891. * Gets or sets the smoothing
  28892. * @ignorenaming
  28893. */
  28894. SMOOTHING: number;
  28895. /**
  28896. * Gets or sets the FFT table size
  28897. * @ignorenaming
  28898. */
  28899. FFT_SIZE: number;
  28900. /**
  28901. * Gets or sets the bar graph amplitude
  28902. * @ignorenaming
  28903. */
  28904. BARGRAPHAMPLITUDE: number;
  28905. /**
  28906. * Gets or sets the position of the debug canvas
  28907. * @ignorenaming
  28908. */
  28909. DEBUGCANVASPOS: {
  28910. x: number;
  28911. y: number;
  28912. };
  28913. /**
  28914. * Gets or sets the debug canvas size
  28915. * @ignorenaming
  28916. */
  28917. DEBUGCANVASSIZE: {
  28918. width: number;
  28919. height: number;
  28920. };
  28921. private _byteFreqs;
  28922. private _byteTime;
  28923. private _floatFreqs;
  28924. private _webAudioAnalyser;
  28925. private _debugCanvas;
  28926. private _debugCanvasContext;
  28927. private _scene;
  28928. private _registerFunc;
  28929. private _audioEngine;
  28930. /**
  28931. * Creates a new analyser
  28932. * @param scene defines hosting scene
  28933. */
  28934. constructor(scene: Scene);
  28935. /**
  28936. * Get the number of data values you will have to play with for the visualization
  28937. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28938. * @returns a number
  28939. */
  28940. getFrequencyBinCount(): number;
  28941. /**
  28942. * Gets the current frequency data as a byte array
  28943. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28944. * @returns a Uint8Array
  28945. */
  28946. getByteFrequencyData(): Uint8Array;
  28947. /**
  28948. * Gets the current waveform as a byte array
  28949. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  28950. * @returns a Uint8Array
  28951. */
  28952. getByteTimeDomainData(): Uint8Array;
  28953. /**
  28954. * Gets the current frequency data as a float array
  28955. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28956. * @returns a Float32Array
  28957. */
  28958. getFloatFrequencyData(): Float32Array;
  28959. /**
  28960. * Renders the debug canvas
  28961. */
  28962. drawDebugCanvas(): void;
  28963. /**
  28964. * Stops rendering the debug canvas and removes it
  28965. */
  28966. stopDebugCanvas(): void;
  28967. /**
  28968. * Connects two audio nodes
  28969. * @param inputAudioNode defines first node to connect
  28970. * @param outputAudioNode defines second node to connect
  28971. */
  28972. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  28973. /**
  28974. * Releases all associated resources
  28975. */
  28976. dispose(): void;
  28977. }
  28978. }
  28979. declare module BABYLON {
  28980. /**
  28981. * This represents an audio engine and it is responsible
  28982. * to play, synchronize and analyse sounds throughout the application.
  28983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28984. */
  28985. export interface IAudioEngine extends IDisposable {
  28986. /**
  28987. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28988. */
  28989. readonly canUseWebAudio: boolean;
  28990. /**
  28991. * Gets the current AudioContext if available.
  28992. */
  28993. readonly audioContext: Nullable<AudioContext>;
  28994. /**
  28995. * The master gain node defines the global audio volume of your audio engine.
  28996. */
  28997. readonly masterGain: GainNode;
  28998. /**
  28999. * Gets whether or not mp3 are supported by your browser.
  29000. */
  29001. readonly isMP3supported: boolean;
  29002. /**
  29003. * Gets whether or not ogg are supported by your browser.
  29004. */
  29005. readonly isOGGsupported: boolean;
  29006. /**
  29007. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29008. * @ignoreNaming
  29009. */
  29010. WarnedWebAudioUnsupported: boolean;
  29011. /**
  29012. * Defines if the audio engine relies on a custom unlocked button.
  29013. * In this case, the embedded button will not be displayed.
  29014. */
  29015. useCustomUnlockedButton: boolean;
  29016. /**
  29017. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29018. */
  29019. readonly unlocked: boolean;
  29020. /**
  29021. * Event raised when audio has been unlocked on the browser.
  29022. */
  29023. onAudioUnlockedObservable: Observable<AudioEngine>;
  29024. /**
  29025. * Event raised when audio has been locked on the browser.
  29026. */
  29027. onAudioLockedObservable: Observable<AudioEngine>;
  29028. /**
  29029. * Flags the audio engine in Locked state.
  29030. * This happens due to new browser policies preventing audio to autoplay.
  29031. */
  29032. lock(): void;
  29033. /**
  29034. * Unlocks the audio engine once a user action has been done on the dom.
  29035. * This is helpful to resume play once browser policies have been satisfied.
  29036. */
  29037. unlock(): void;
  29038. }
  29039. /**
  29040. * This represents the default audio engine used in babylon.
  29041. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29043. */
  29044. export class AudioEngine implements IAudioEngine {
  29045. private _audioContext;
  29046. private _audioContextInitialized;
  29047. private _muteButton;
  29048. private _hostElement;
  29049. /**
  29050. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29051. */
  29052. canUseWebAudio: boolean;
  29053. /**
  29054. * The master gain node defines the global audio volume of your audio engine.
  29055. */
  29056. masterGain: GainNode;
  29057. /**
  29058. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29059. * @ignoreNaming
  29060. */
  29061. WarnedWebAudioUnsupported: boolean;
  29062. /**
  29063. * Gets whether or not mp3 are supported by your browser.
  29064. */
  29065. isMP3supported: boolean;
  29066. /**
  29067. * Gets whether or not ogg are supported by your browser.
  29068. */
  29069. isOGGsupported: boolean;
  29070. /**
  29071. * Gets whether audio has been unlocked on the device.
  29072. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29073. * a user interaction has happened.
  29074. */
  29075. unlocked: boolean;
  29076. /**
  29077. * Defines if the audio engine relies on a custom unlocked button.
  29078. * In this case, the embedded button will not be displayed.
  29079. */
  29080. useCustomUnlockedButton: boolean;
  29081. /**
  29082. * Event raised when audio has been unlocked on the browser.
  29083. */
  29084. onAudioUnlockedObservable: Observable<AudioEngine>;
  29085. /**
  29086. * Event raised when audio has been locked on the browser.
  29087. */
  29088. onAudioLockedObservable: Observable<AudioEngine>;
  29089. /**
  29090. * Gets the current AudioContext if available.
  29091. */
  29092. readonly audioContext: Nullable<AudioContext>;
  29093. private _connectedAnalyser;
  29094. /**
  29095. * Instantiates a new audio engine.
  29096. *
  29097. * There should be only one per page as some browsers restrict the number
  29098. * of audio contexts you can create.
  29099. * @param hostElement defines the host element where to display the mute icon if necessary
  29100. */
  29101. constructor(hostElement?: Nullable<HTMLElement>);
  29102. /**
  29103. * Flags the audio engine in Locked state.
  29104. * This happens due to new browser policies preventing audio to autoplay.
  29105. */
  29106. lock(): void;
  29107. /**
  29108. * Unlocks the audio engine once a user action has been done on the dom.
  29109. * This is helpful to resume play once browser policies have been satisfied.
  29110. */
  29111. unlock(): void;
  29112. private _resumeAudioContext;
  29113. private _initializeAudioContext;
  29114. private _tryToRun;
  29115. private _triggerRunningState;
  29116. private _triggerSuspendedState;
  29117. private _displayMuteButton;
  29118. private _moveButtonToTopLeft;
  29119. private _onResize;
  29120. private _hideMuteButton;
  29121. /**
  29122. * Destroy and release the resources associated with the audio ccontext.
  29123. */
  29124. dispose(): void;
  29125. /**
  29126. * Gets the global volume sets on the master gain.
  29127. * @returns the global volume if set or -1 otherwise
  29128. */
  29129. getGlobalVolume(): number;
  29130. /**
  29131. * Sets the global volume of your experience (sets on the master gain).
  29132. * @param newVolume Defines the new global volume of the application
  29133. */
  29134. setGlobalVolume(newVolume: number): void;
  29135. /**
  29136. * Connect the audio engine to an audio analyser allowing some amazing
  29137. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29138. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29139. * @param analyser The analyser to connect to the engine
  29140. */
  29141. connectToAnalyser(analyser: Analyser): void;
  29142. }
  29143. }
  29144. declare module BABYLON {
  29145. /**
  29146. * Interface used to present a loading screen while loading a scene
  29147. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29148. */
  29149. export interface ILoadingScreen {
  29150. /**
  29151. * Function called to display the loading screen
  29152. */
  29153. displayLoadingUI: () => void;
  29154. /**
  29155. * Function called to hide the loading screen
  29156. */
  29157. hideLoadingUI: () => void;
  29158. /**
  29159. * Gets or sets the color to use for the background
  29160. */
  29161. loadingUIBackgroundColor: string;
  29162. /**
  29163. * Gets or sets the text to display while loading
  29164. */
  29165. loadingUIText: string;
  29166. }
  29167. /**
  29168. * Class used for the default loading screen
  29169. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29170. */
  29171. export class DefaultLoadingScreen implements ILoadingScreen {
  29172. private _renderingCanvas;
  29173. private _loadingText;
  29174. private _loadingDivBackgroundColor;
  29175. private _loadingDiv;
  29176. private _loadingTextDiv;
  29177. /** Gets or sets the logo url to use for the default loading screen */
  29178. static DefaultLogoUrl: string;
  29179. /** Gets or sets the spinner url to use for the default loading screen */
  29180. static DefaultSpinnerUrl: string;
  29181. /**
  29182. * Creates a new default loading screen
  29183. * @param _renderingCanvas defines the canvas used to render the scene
  29184. * @param _loadingText defines the default text to display
  29185. * @param _loadingDivBackgroundColor defines the default background color
  29186. */
  29187. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29188. /**
  29189. * Function called to display the loading screen
  29190. */
  29191. displayLoadingUI(): void;
  29192. /**
  29193. * Function called to hide the loading screen
  29194. */
  29195. hideLoadingUI(): void;
  29196. /**
  29197. * Gets or sets the text to display while loading
  29198. */
  29199. loadingUIText: string;
  29200. /**
  29201. * Gets or sets the color to use for the background
  29202. */
  29203. loadingUIBackgroundColor: string;
  29204. private _resizeLoadingUI;
  29205. }
  29206. }
  29207. declare module BABYLON {
  29208. /** @hidden */
  29209. export class WebGLPipelineContext implements IPipelineContext {
  29210. engine: Engine;
  29211. program: Nullable<WebGLProgram>;
  29212. context?: WebGLRenderingContext;
  29213. vertexShader?: WebGLShader;
  29214. fragmentShader?: WebGLShader;
  29215. isParallelCompiled: boolean;
  29216. onCompiled?: () => void;
  29217. transformFeedback?: WebGLTransformFeedback | null;
  29218. readonly isAsync: boolean;
  29219. readonly isReady: boolean;
  29220. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29221. }
  29222. }
  29223. declare module BABYLON {
  29224. /** @hidden */
  29225. export class WebGLDataBuffer extends DataBuffer {
  29226. private _buffer;
  29227. constructor(resource: WebGLBuffer);
  29228. readonly underlyingResource: any;
  29229. }
  29230. }
  29231. declare module BABYLON {
  29232. /** @hidden */
  29233. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29234. attributeProcessor(attribute: string): string;
  29235. varyingProcessor(varying: string, isFragment: boolean): string;
  29236. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29237. }
  29238. }
  29239. declare module BABYLON {
  29240. /**
  29241. * This class is used to track a performance counter which is number based.
  29242. * The user has access to many properties which give statistics of different nature.
  29243. *
  29244. * The implementer can track two kinds of Performance Counter: time and count.
  29245. * 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.
  29246. * 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.
  29247. */
  29248. export class PerfCounter {
  29249. /**
  29250. * Gets or sets a global boolean to turn on and off all the counters
  29251. */
  29252. static Enabled: boolean;
  29253. /**
  29254. * Returns the smallest value ever
  29255. */
  29256. readonly min: number;
  29257. /**
  29258. * Returns the biggest value ever
  29259. */
  29260. readonly max: number;
  29261. /**
  29262. * Returns the average value since the performance counter is running
  29263. */
  29264. readonly average: number;
  29265. /**
  29266. * Returns the average value of the last second the counter was monitored
  29267. */
  29268. readonly lastSecAverage: number;
  29269. /**
  29270. * Returns the current value
  29271. */
  29272. readonly current: number;
  29273. /**
  29274. * Gets the accumulated total
  29275. */
  29276. readonly total: number;
  29277. /**
  29278. * Gets the total value count
  29279. */
  29280. readonly count: number;
  29281. /**
  29282. * Creates a new counter
  29283. */
  29284. constructor();
  29285. /**
  29286. * Call this method to start monitoring a new frame.
  29287. * 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.
  29288. */
  29289. fetchNewFrame(): void;
  29290. /**
  29291. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29292. * @param newCount the count value to add to the monitored count
  29293. * @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.
  29294. */
  29295. addCount(newCount: number, fetchResult: boolean): void;
  29296. /**
  29297. * Start monitoring this performance counter
  29298. */
  29299. beginMonitoring(): void;
  29300. /**
  29301. * Compute the time lapsed since the previous beginMonitoring() call.
  29302. * @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
  29303. */
  29304. endMonitoring(newFrame?: boolean): void;
  29305. private _fetchResult;
  29306. private _startMonitoringTime;
  29307. private _min;
  29308. private _max;
  29309. private _average;
  29310. private _current;
  29311. private _totalValueCount;
  29312. private _totalAccumulated;
  29313. private _lastSecAverage;
  29314. private _lastSecAccumulated;
  29315. private _lastSecTime;
  29316. private _lastSecValueCount;
  29317. }
  29318. }
  29319. declare module BABYLON {
  29320. /**
  29321. * Interface for any object that can request an animation frame
  29322. */
  29323. export interface ICustomAnimationFrameRequester {
  29324. /**
  29325. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29326. */
  29327. renderFunction?: Function;
  29328. /**
  29329. * Called to request the next frame to render to
  29330. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29331. */
  29332. requestAnimationFrame: Function;
  29333. /**
  29334. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29335. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29336. */
  29337. requestID?: number;
  29338. }
  29339. }
  29340. declare module BABYLON {
  29341. /**
  29342. * Settings for finer control over video usage
  29343. */
  29344. export interface VideoTextureSettings {
  29345. /**
  29346. * Applies `autoplay` to video, if specified
  29347. */
  29348. autoPlay?: boolean;
  29349. /**
  29350. * Applies `loop` to video, if specified
  29351. */
  29352. loop?: boolean;
  29353. /**
  29354. * Automatically updates internal texture from video at every frame in the render loop
  29355. */
  29356. autoUpdateTexture: boolean;
  29357. /**
  29358. * Image src displayed during the video loading or until the user interacts with the video.
  29359. */
  29360. poster?: string;
  29361. }
  29362. /**
  29363. * If you want to display a video in your scene, this is the special texture for that.
  29364. * This special texture works similar to other textures, with the exception of a few parameters.
  29365. * @see https://doc.babylonjs.com/how_to/video_texture
  29366. */
  29367. export class VideoTexture extends Texture {
  29368. /**
  29369. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29370. */
  29371. readonly autoUpdateTexture: boolean;
  29372. /**
  29373. * The video instance used by the texture internally
  29374. */
  29375. readonly video: HTMLVideoElement;
  29376. private _onUserActionRequestedObservable;
  29377. /**
  29378. * Event triggerd when a dom action is required by the user to play the video.
  29379. * This happens due to recent changes in browser policies preventing video to auto start.
  29380. */
  29381. readonly onUserActionRequestedObservable: Observable<Texture>;
  29382. private _generateMipMaps;
  29383. private _engine;
  29384. private _stillImageCaptured;
  29385. private _displayingPosterTexture;
  29386. private _settings;
  29387. private _createInternalTextureOnEvent;
  29388. /**
  29389. * Creates a video texture.
  29390. * If you want to display a video in your scene, this is the special texture for that.
  29391. * This special texture works similar to other textures, with the exception of a few parameters.
  29392. * @see https://doc.babylonjs.com/how_to/video_texture
  29393. * @param name optional name, will detect from video source, if not defined
  29394. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29395. * @param scene is obviously the current scene.
  29396. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29397. * @param invertY is false by default but can be used to invert video on Y axis
  29398. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29399. * @param settings allows finer control over video usage
  29400. */
  29401. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29402. private _getName;
  29403. private _getVideo;
  29404. private _createInternalTexture;
  29405. private reset;
  29406. /**
  29407. * @hidden Internal method to initiate `update`.
  29408. */
  29409. _rebuild(): void;
  29410. /**
  29411. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29412. */
  29413. update(): void;
  29414. /**
  29415. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29416. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29417. */
  29418. updateTexture(isVisible: boolean): void;
  29419. protected _updateInternalTexture: () => void;
  29420. /**
  29421. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29422. * @param url New url.
  29423. */
  29424. updateURL(url: string): void;
  29425. /**
  29426. * Dispose the texture and release its associated resources.
  29427. */
  29428. dispose(): void;
  29429. /**
  29430. * Creates a video texture straight from a stream.
  29431. * @param scene Define the scene the texture should be created in
  29432. * @param stream Define the stream the texture should be created from
  29433. * @returns The created video texture as a promise
  29434. */
  29435. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29436. /**
  29437. * Creates a video texture straight from your WebCam video feed.
  29438. * @param scene Define the scene the texture should be created in
  29439. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29440. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29441. * @returns The created video texture as a promise
  29442. */
  29443. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29444. minWidth: number;
  29445. maxWidth: number;
  29446. minHeight: number;
  29447. maxHeight: number;
  29448. deviceId: string;
  29449. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29450. /**
  29451. * Creates a video texture straight from your WebCam video feed.
  29452. * @param scene Define the scene the texture should be created in
  29453. * @param onReady Define a callback to triggered once the texture will be ready
  29454. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29455. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29456. */
  29457. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29458. minWidth: number;
  29459. maxWidth: number;
  29460. minHeight: number;
  29461. maxHeight: number;
  29462. deviceId: string;
  29463. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29464. }
  29465. }
  29466. declare module BABYLON {
  29467. /**
  29468. * Defines the interface used by objects containing a viewport (like a camera)
  29469. */
  29470. interface IViewportOwnerLike {
  29471. /**
  29472. * Gets or sets the viewport
  29473. */
  29474. viewport: IViewportLike;
  29475. }
  29476. /**
  29477. * Interface for attribute information associated with buffer instanciation
  29478. */
  29479. export class InstancingAttributeInfo {
  29480. /**
  29481. * Index/offset of the attribute in the vertex shader
  29482. */
  29483. index: number;
  29484. /**
  29485. * size of the attribute, 1, 2, 3 or 4
  29486. */
  29487. attributeSize: number;
  29488. /**
  29489. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29490. * default is FLOAT
  29491. */
  29492. attribyteType: number;
  29493. /**
  29494. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29495. */
  29496. normalized: boolean;
  29497. /**
  29498. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29499. */
  29500. offset: number;
  29501. /**
  29502. * Name of the GLSL attribute, for debugging purpose only
  29503. */
  29504. attributeName: string;
  29505. }
  29506. /**
  29507. * Define options used to create a depth texture
  29508. */
  29509. export class DepthTextureCreationOptions {
  29510. /** Specifies whether or not a stencil should be allocated in the texture */
  29511. generateStencil?: boolean;
  29512. /** Specifies whether or not bilinear filtering is enable on the texture */
  29513. bilinearFiltering?: boolean;
  29514. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29515. comparisonFunction?: number;
  29516. /** Specifies if the created texture is a cube texture */
  29517. isCube?: boolean;
  29518. }
  29519. /**
  29520. * Class used to describe the capabilities of the engine relatively to the current browser
  29521. */
  29522. export class EngineCapabilities {
  29523. /** Maximum textures units per fragment shader */
  29524. maxTexturesImageUnits: number;
  29525. /** Maximum texture units per vertex shader */
  29526. maxVertexTextureImageUnits: number;
  29527. /** Maximum textures units in the entire pipeline */
  29528. maxCombinedTexturesImageUnits: number;
  29529. /** Maximum texture size */
  29530. maxTextureSize: number;
  29531. /** Maximum cube texture size */
  29532. maxCubemapTextureSize: number;
  29533. /** Maximum render texture size */
  29534. maxRenderTextureSize: number;
  29535. /** Maximum number of vertex attributes */
  29536. maxVertexAttribs: number;
  29537. /** Maximum number of varyings */
  29538. maxVaryingVectors: number;
  29539. /** Maximum number of uniforms per vertex shader */
  29540. maxVertexUniformVectors: number;
  29541. /** Maximum number of uniforms per fragment shader */
  29542. maxFragmentUniformVectors: number;
  29543. /** Defines if standard derivates (dx/dy) are supported */
  29544. standardDerivatives: boolean;
  29545. /** Defines if s3tc texture compression is supported */
  29546. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29547. /** Defines if pvrtc texture compression is supported */
  29548. pvrtc: any;
  29549. /** Defines if etc1 texture compression is supported */
  29550. etc1: any;
  29551. /** Defines if etc2 texture compression is supported */
  29552. etc2: any;
  29553. /** Defines if astc texture compression is supported */
  29554. astc: any;
  29555. /** Defines if float textures are supported */
  29556. textureFloat: boolean;
  29557. /** Defines if vertex array objects are supported */
  29558. vertexArrayObject: boolean;
  29559. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29560. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29561. /** Gets the maximum level of anisotropy supported */
  29562. maxAnisotropy: number;
  29563. /** Defines if instancing is supported */
  29564. instancedArrays: boolean;
  29565. /** Defines if 32 bits indices are supported */
  29566. uintIndices: boolean;
  29567. /** Defines if high precision shaders are supported */
  29568. highPrecisionShaderSupported: boolean;
  29569. /** Defines if depth reading in the fragment shader is supported */
  29570. fragmentDepthSupported: boolean;
  29571. /** Defines if float texture linear filtering is supported*/
  29572. textureFloatLinearFiltering: boolean;
  29573. /** Defines if rendering to float textures is supported */
  29574. textureFloatRender: boolean;
  29575. /** Defines if half float textures are supported*/
  29576. textureHalfFloat: boolean;
  29577. /** Defines if half float texture linear filtering is supported*/
  29578. textureHalfFloatLinearFiltering: boolean;
  29579. /** Defines if rendering to half float textures is supported */
  29580. textureHalfFloatRender: boolean;
  29581. /** Defines if textureLOD shader command is supported */
  29582. textureLOD: boolean;
  29583. /** Defines if draw buffers extension is supported */
  29584. drawBuffersExtension: boolean;
  29585. /** Defines if depth textures are supported */
  29586. depthTextureExtension: boolean;
  29587. /** Defines if float color buffer are supported */
  29588. colorBufferFloat: boolean;
  29589. /** Gets disjoint timer query extension (null if not supported) */
  29590. timerQuery: EXT_disjoint_timer_query;
  29591. /** Defines if timestamp can be used with timer query */
  29592. canUseTimestampForTimerQuery: boolean;
  29593. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29594. multiview: any;
  29595. /** Function used to let the system compiles shaders in background */
  29596. parallelShaderCompile: {
  29597. COMPLETION_STATUS_KHR: number;
  29598. };
  29599. }
  29600. /** Interface defining initialization parameters for Engine class */
  29601. export interface EngineOptions extends WebGLContextAttributes {
  29602. /**
  29603. * Defines if the engine should no exceed a specified device ratio
  29604. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29605. */
  29606. limitDeviceRatio?: number;
  29607. /**
  29608. * Defines if webvr should be enabled automatically
  29609. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29610. */
  29611. autoEnableWebVR?: boolean;
  29612. /**
  29613. * Defines if webgl2 should be turned off even if supported
  29614. * @see http://doc.babylonjs.com/features/webgl2
  29615. */
  29616. disableWebGL2Support?: boolean;
  29617. /**
  29618. * Defines if webaudio should be initialized as well
  29619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29620. */
  29621. audioEngine?: boolean;
  29622. /**
  29623. * Defines if animations should run using a deterministic lock step
  29624. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29625. */
  29626. deterministicLockstep?: boolean;
  29627. /** Defines the maximum steps to use with deterministic lock step mode */
  29628. lockstepMaxSteps?: number;
  29629. /**
  29630. * Defines that engine should ignore context lost events
  29631. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29632. */
  29633. doNotHandleContextLost?: boolean;
  29634. /**
  29635. * Defines that engine should ignore modifying touch action attribute and style
  29636. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29637. */
  29638. doNotHandleTouchAction?: boolean;
  29639. /**
  29640. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29641. */
  29642. useHighPrecisionFloats?: boolean;
  29643. }
  29644. /**
  29645. * Defines the interface used by display changed events
  29646. */
  29647. export interface IDisplayChangedEventArgs {
  29648. /** Gets the vrDisplay object (if any) */
  29649. vrDisplay: Nullable<any>;
  29650. /** Gets a boolean indicating if webVR is supported */
  29651. vrSupported: boolean;
  29652. }
  29653. /**
  29654. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29655. */
  29656. export class Engine {
  29657. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29658. static ExceptionList: ({
  29659. key: string;
  29660. capture: string;
  29661. captureConstraint: number;
  29662. targets: string[];
  29663. } | {
  29664. key: string;
  29665. capture: null;
  29666. captureConstraint: null;
  29667. targets: string[];
  29668. })[];
  29669. /** Gets the list of created engines */
  29670. static readonly Instances: Engine[];
  29671. /**
  29672. * Gets the latest created engine
  29673. */
  29674. static readonly LastCreatedEngine: Nullable<Engine>;
  29675. /**
  29676. * Gets the latest created scene
  29677. */
  29678. static readonly LastCreatedScene: Nullable<Scene>;
  29679. /**
  29680. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29681. * @param flag defines which part of the materials must be marked as dirty
  29682. * @param predicate defines a predicate used to filter which materials should be affected
  29683. */
  29684. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29685. /** @hidden */
  29686. static _TextureLoaders: IInternalTextureLoader[];
  29687. /** Defines that alpha blending is disabled */
  29688. static readonly ALPHA_DISABLE: number;
  29689. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29690. static readonly ALPHA_ADD: number;
  29691. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29692. static readonly ALPHA_COMBINE: number;
  29693. /** Defines that alpha blending to DEST - SRC * DEST */
  29694. static readonly ALPHA_SUBTRACT: number;
  29695. /** Defines that alpha blending to SRC * DEST */
  29696. static readonly ALPHA_MULTIPLY: number;
  29697. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29698. static readonly ALPHA_MAXIMIZED: number;
  29699. /** Defines that alpha blending to SRC + DEST */
  29700. static readonly ALPHA_ONEONE: number;
  29701. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29702. static readonly ALPHA_PREMULTIPLIED: number;
  29703. /**
  29704. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29705. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29706. */
  29707. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29708. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29709. static readonly ALPHA_INTERPOLATE: number;
  29710. /**
  29711. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29712. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29713. */
  29714. static readonly ALPHA_SCREENMODE: number;
  29715. /** Defines that the ressource is not delayed*/
  29716. static readonly DELAYLOADSTATE_NONE: number;
  29717. /** Defines that the ressource was successfully delay loaded */
  29718. static readonly DELAYLOADSTATE_LOADED: number;
  29719. /** Defines that the ressource is currently delay loading */
  29720. static readonly DELAYLOADSTATE_LOADING: number;
  29721. /** Defines that the ressource is delayed and has not started loading */
  29722. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29723. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29724. static readonly NEVER: number;
  29725. /** 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 */
  29726. static readonly ALWAYS: number;
  29727. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29728. static readonly LESS: number;
  29729. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29730. static readonly EQUAL: number;
  29731. /** 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 */
  29732. static readonly LEQUAL: number;
  29733. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29734. static readonly GREATER: number;
  29735. /** 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 */
  29736. static readonly GEQUAL: number;
  29737. /** 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 */
  29738. static readonly NOTEQUAL: number;
  29739. /** Passed to stencilOperation to specify that stencil value must be kept */
  29740. static readonly KEEP: number;
  29741. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29742. static readonly REPLACE: number;
  29743. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29744. static readonly INCR: number;
  29745. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29746. static readonly DECR: number;
  29747. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29748. static readonly INVERT: number;
  29749. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29750. static readonly INCR_WRAP: number;
  29751. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29752. static readonly DECR_WRAP: number;
  29753. /** Texture is not repeating outside of 0..1 UVs */
  29754. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29755. /** Texture is repeating outside of 0..1 UVs */
  29756. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29757. /** Texture is repeating and mirrored */
  29758. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29759. /** ALPHA */
  29760. static readonly TEXTUREFORMAT_ALPHA: number;
  29761. /** LUMINANCE */
  29762. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29763. /** LUMINANCE_ALPHA */
  29764. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29765. /** RGB */
  29766. static readonly TEXTUREFORMAT_RGB: number;
  29767. /** RGBA */
  29768. static readonly TEXTUREFORMAT_RGBA: number;
  29769. /** RED */
  29770. static readonly TEXTUREFORMAT_RED: number;
  29771. /** RED (2nd reference) */
  29772. static readonly TEXTUREFORMAT_R: number;
  29773. /** RG */
  29774. static readonly TEXTUREFORMAT_RG: number;
  29775. /** RED_INTEGER */
  29776. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29777. /** RED_INTEGER (2nd reference) */
  29778. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29779. /** RG_INTEGER */
  29780. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29781. /** RGB_INTEGER */
  29782. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29783. /** RGBA_INTEGER */
  29784. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29785. /** UNSIGNED_BYTE */
  29786. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29787. /** UNSIGNED_BYTE (2nd reference) */
  29788. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29789. /** FLOAT */
  29790. static readonly TEXTURETYPE_FLOAT: number;
  29791. /** HALF_FLOAT */
  29792. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29793. /** BYTE */
  29794. static readonly TEXTURETYPE_BYTE: number;
  29795. /** SHORT */
  29796. static readonly TEXTURETYPE_SHORT: number;
  29797. /** UNSIGNED_SHORT */
  29798. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29799. /** INT */
  29800. static readonly TEXTURETYPE_INT: number;
  29801. /** UNSIGNED_INT */
  29802. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29803. /** UNSIGNED_SHORT_4_4_4_4 */
  29804. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29805. /** UNSIGNED_SHORT_5_5_5_1 */
  29806. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29807. /** UNSIGNED_SHORT_5_6_5 */
  29808. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29809. /** UNSIGNED_INT_2_10_10_10_REV */
  29810. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29811. /** UNSIGNED_INT_24_8 */
  29812. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29813. /** UNSIGNED_INT_10F_11F_11F_REV */
  29814. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29815. /** UNSIGNED_INT_5_9_9_9_REV */
  29816. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29817. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29818. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29819. /** nearest is mag = nearest and min = nearest and mip = linear */
  29820. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29821. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29822. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29823. /** Trilinear is mag = linear and min = linear and mip = linear */
  29824. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29825. /** nearest is mag = nearest and min = nearest and mip = linear */
  29826. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29827. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29828. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29829. /** Trilinear is mag = linear and min = linear and mip = linear */
  29830. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29831. /** mag = nearest and min = nearest and mip = nearest */
  29832. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29833. /** mag = nearest and min = linear and mip = nearest */
  29834. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29835. /** mag = nearest and min = linear and mip = linear */
  29836. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29837. /** mag = nearest and min = linear and mip = none */
  29838. static readonly TEXTURE_NEAREST_LINEAR: number;
  29839. /** mag = nearest and min = nearest and mip = none */
  29840. static readonly TEXTURE_NEAREST_NEAREST: number;
  29841. /** mag = linear and min = nearest and mip = nearest */
  29842. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29843. /** mag = linear and min = nearest and mip = linear */
  29844. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29845. /** mag = linear and min = linear and mip = none */
  29846. static readonly TEXTURE_LINEAR_LINEAR: number;
  29847. /** mag = linear and min = nearest and mip = none */
  29848. static readonly TEXTURE_LINEAR_NEAREST: number;
  29849. /** Explicit coordinates mode */
  29850. static readonly TEXTURE_EXPLICIT_MODE: number;
  29851. /** Spherical coordinates mode */
  29852. static readonly TEXTURE_SPHERICAL_MODE: number;
  29853. /** Planar coordinates mode */
  29854. static readonly TEXTURE_PLANAR_MODE: number;
  29855. /** Cubic coordinates mode */
  29856. static readonly TEXTURE_CUBIC_MODE: number;
  29857. /** Projection coordinates mode */
  29858. static readonly TEXTURE_PROJECTION_MODE: number;
  29859. /** Skybox coordinates mode */
  29860. static readonly TEXTURE_SKYBOX_MODE: number;
  29861. /** Inverse Cubic coordinates mode */
  29862. static readonly TEXTURE_INVCUBIC_MODE: number;
  29863. /** Equirectangular coordinates mode */
  29864. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29865. /** Equirectangular Fixed coordinates mode */
  29866. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29867. /** Equirectangular Fixed Mirrored coordinates mode */
  29868. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29869. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29870. static readonly SCALEMODE_FLOOR: number;
  29871. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29872. static readonly SCALEMODE_NEAREST: number;
  29873. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29874. static readonly SCALEMODE_CEILING: number;
  29875. /**
  29876. * Returns the current npm package of the sdk
  29877. */
  29878. static readonly NpmPackage: string;
  29879. /**
  29880. * Returns the current version of the framework
  29881. */
  29882. static readonly Version: string;
  29883. /**
  29884. * Returns a string describing the current engine
  29885. */
  29886. readonly description: string;
  29887. /**
  29888. * Gets or sets the epsilon value used by collision engine
  29889. */
  29890. static CollisionsEpsilon: number;
  29891. /**
  29892. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29893. */
  29894. static ShadersRepository: string;
  29895. /**
  29896. * Method called to create the default loading screen.
  29897. * This can be overriden in your own app.
  29898. * @param canvas The rendering canvas element
  29899. * @returns The loading screen
  29900. */
  29901. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29902. /**
  29903. * Method called to create the default rescale post process on each engine.
  29904. */
  29905. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  29906. /** @hidden */
  29907. _shaderProcessor: IShaderProcessor;
  29908. /**
  29909. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29910. */
  29911. forcePOTTextures: boolean;
  29912. /**
  29913. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29914. */
  29915. isFullscreen: boolean;
  29916. /**
  29917. * Gets a boolean indicating if the pointer is currently locked
  29918. */
  29919. isPointerLock: boolean;
  29920. /**
  29921. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29922. */
  29923. cullBackFaces: boolean;
  29924. /**
  29925. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29926. */
  29927. renderEvenInBackground: boolean;
  29928. /**
  29929. * Gets or sets a boolean indicating that cache can be kept between frames
  29930. */
  29931. preventCacheWipeBetweenFrames: boolean;
  29932. /**
  29933. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29934. **/
  29935. enableOfflineSupport: boolean;
  29936. /**
  29937. * 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)
  29938. **/
  29939. disableManifestCheck: boolean;
  29940. /**
  29941. * Gets the list of created scenes
  29942. */
  29943. scenes: Scene[];
  29944. /**
  29945. * Event raised when a new scene is created
  29946. */
  29947. onNewSceneAddedObservable: Observable<Scene>;
  29948. /**
  29949. * Gets the list of created postprocesses
  29950. */
  29951. postProcesses: PostProcess[];
  29952. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29953. validateShaderPrograms: boolean;
  29954. /**
  29955. * Observable event triggered each time the rendering canvas is resized
  29956. */
  29957. onResizeObservable: Observable<Engine>;
  29958. /**
  29959. * Observable event triggered each time the canvas loses focus
  29960. */
  29961. onCanvasBlurObservable: Observable<Engine>;
  29962. /**
  29963. * Observable event triggered each time the canvas gains focus
  29964. */
  29965. onCanvasFocusObservable: Observable<Engine>;
  29966. /**
  29967. * Observable event triggered each time the canvas receives pointerout event
  29968. */
  29969. onCanvasPointerOutObservable: Observable<PointerEvent>;
  29970. /**
  29971. * Observable event triggered before each texture is initialized
  29972. */
  29973. onBeforeTextureInitObservable: Observable<Texture>;
  29974. /**
  29975. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29976. */
  29977. disableUniformBuffers: boolean;
  29978. /** @hidden */
  29979. _uniformBuffers: UniformBuffer[];
  29980. /**
  29981. * Gets a boolean indicating that the engine supports uniform buffers
  29982. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29983. */
  29984. readonly supportsUniformBuffers: boolean;
  29985. /**
  29986. * Observable raised when the engine begins a new frame
  29987. */
  29988. onBeginFrameObservable: Observable<Engine>;
  29989. /**
  29990. * If set, will be used to request the next animation frame for the render loop
  29991. */
  29992. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  29993. /**
  29994. * Observable raised when the engine ends the current frame
  29995. */
  29996. onEndFrameObservable: Observable<Engine>;
  29997. /**
  29998. * Observable raised when the engine is about to compile a shader
  29999. */
  30000. onBeforeShaderCompilationObservable: Observable<Engine>;
  30001. /**
  30002. * Observable raised when the engine has jsut compiled a shader
  30003. */
  30004. onAfterShaderCompilationObservable: Observable<Engine>;
  30005. /** @hidden */
  30006. _gl: WebGLRenderingContext;
  30007. private _renderingCanvas;
  30008. private _windowIsBackground;
  30009. private _webGLVersion;
  30010. protected _highPrecisionShadersAllowed: boolean;
  30011. /** @hidden */
  30012. readonly _shouldUseHighPrecisionShader: boolean;
  30013. /**
  30014. * Gets a boolean indicating that only power of 2 textures are supported
  30015. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30016. */
  30017. readonly needPOTTextures: boolean;
  30018. /** @hidden */
  30019. _badOS: boolean;
  30020. /** @hidden */
  30021. _badDesktopOS: boolean;
  30022. /**
  30023. * Gets the audio engine
  30024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30025. * @ignorenaming
  30026. */
  30027. static audioEngine: IAudioEngine;
  30028. /**
  30029. * Default AudioEngine factory responsible of creating the Audio Engine.
  30030. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30031. */
  30032. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30033. /**
  30034. * Default offline support factory responsible of creating a tool used to store data locally.
  30035. * By default, this will create a Database object if the workload has been embedded.
  30036. */
  30037. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30038. private _onFocus;
  30039. private _onBlur;
  30040. private _onCanvasPointerOut;
  30041. private _onCanvasBlur;
  30042. private _onCanvasFocus;
  30043. private _onFullscreenChange;
  30044. private _onPointerLockChange;
  30045. private _hardwareScalingLevel;
  30046. /** @hidden */
  30047. _caps: EngineCapabilities;
  30048. private _pointerLockRequested;
  30049. private _isStencilEnable;
  30050. private _colorWrite;
  30051. private _loadingScreen;
  30052. /** @hidden */
  30053. _drawCalls: PerfCounter;
  30054. private _glVersion;
  30055. private _glRenderer;
  30056. private _glVendor;
  30057. private _videoTextureSupported;
  30058. private _renderingQueueLaunched;
  30059. private _activeRenderLoops;
  30060. private _deterministicLockstep;
  30061. private _lockstepMaxSteps;
  30062. /**
  30063. * Observable signaled when a context lost event is raised
  30064. */
  30065. onContextLostObservable: Observable<Engine>;
  30066. /**
  30067. * Observable signaled when a context restored event is raised
  30068. */
  30069. onContextRestoredObservable: Observable<Engine>;
  30070. private _onContextLost;
  30071. private _onContextRestored;
  30072. private _contextWasLost;
  30073. /** @hidden */
  30074. _doNotHandleContextLost: boolean;
  30075. /**
  30076. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30077. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30078. */
  30079. doNotHandleContextLost: boolean;
  30080. private _performanceMonitor;
  30081. private _fps;
  30082. private _deltaTime;
  30083. /**
  30084. * Turn this value on if you want to pause FPS computation when in background
  30085. */
  30086. disablePerformanceMonitorInBackground: boolean;
  30087. /**
  30088. * Gets the performance monitor attached to this engine
  30089. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30090. */
  30091. readonly performanceMonitor: PerformanceMonitor;
  30092. /**
  30093. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30094. */
  30095. disableVertexArrayObjects: boolean;
  30096. /** @hidden */
  30097. protected _depthCullingState: _DepthCullingState;
  30098. /** @hidden */
  30099. protected _stencilState: _StencilState;
  30100. /** @hidden */
  30101. protected _alphaState: _AlphaState;
  30102. /** @hidden */
  30103. protected _alphaMode: number;
  30104. /** @hidden */
  30105. _internalTexturesCache: InternalTexture[];
  30106. /** @hidden */
  30107. protected _activeChannel: number;
  30108. private _currentTextureChannel;
  30109. /** @hidden */
  30110. protected _boundTexturesCache: {
  30111. [key: string]: Nullable<InternalTexture>;
  30112. };
  30113. /** @hidden */
  30114. protected _currentEffect: Nullable<Effect>;
  30115. /** @hidden */
  30116. protected _currentProgram: Nullable<WebGLProgram>;
  30117. private _compiledEffects;
  30118. private _vertexAttribArraysEnabled;
  30119. /** @hidden */
  30120. protected _cachedViewport: Nullable<IViewportLike>;
  30121. private _cachedVertexArrayObject;
  30122. /** @hidden */
  30123. protected _cachedVertexBuffers: any;
  30124. /** @hidden */
  30125. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30126. /** @hidden */
  30127. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30128. /** @hidden */
  30129. _currentRenderTarget: Nullable<InternalTexture>;
  30130. private _uintIndicesCurrentlySet;
  30131. private _currentBoundBuffer;
  30132. /** @hidden */
  30133. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30134. private _currentBufferPointers;
  30135. private _currentInstanceLocations;
  30136. private _currentInstanceBuffers;
  30137. private _textureUnits;
  30138. /** @hidden */
  30139. _workingCanvas: Nullable<HTMLCanvasElement>;
  30140. /** @hidden */
  30141. _workingContext: Nullable<CanvasRenderingContext2D>;
  30142. private _rescalePostProcess;
  30143. private _dummyFramebuffer;
  30144. private _externalData;
  30145. /** @hidden */
  30146. _bindedRenderFunction: any;
  30147. private _vaoRecordInProgress;
  30148. private _mustWipeVertexAttributes;
  30149. private _emptyTexture;
  30150. private _emptyCubeTexture;
  30151. private _emptyTexture3D;
  30152. /** @hidden */
  30153. _frameHandler: number;
  30154. private _nextFreeTextureSlots;
  30155. private _maxSimultaneousTextures;
  30156. private _activeRequests;
  30157. private _texturesSupported;
  30158. /** @hidden */
  30159. _textureFormatInUse: Nullable<string>;
  30160. /**
  30161. * Gets the list of texture formats supported
  30162. */
  30163. readonly texturesSupported: Array<string>;
  30164. /**
  30165. * Gets the list of texture formats in use
  30166. */
  30167. readonly textureFormatInUse: Nullable<string>;
  30168. /**
  30169. * Gets the current viewport
  30170. */
  30171. readonly currentViewport: Nullable<IViewportLike>;
  30172. /**
  30173. * Gets the default empty texture
  30174. */
  30175. readonly emptyTexture: InternalTexture;
  30176. /**
  30177. * Gets the default empty 3D texture
  30178. */
  30179. readonly emptyTexture3D: InternalTexture;
  30180. /**
  30181. * Gets the default empty cube texture
  30182. */
  30183. readonly emptyCubeTexture: InternalTexture;
  30184. /**
  30185. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30186. */
  30187. readonly premultipliedAlpha: boolean;
  30188. /**
  30189. * Creates a new engine
  30190. * @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
  30191. * @param antialias defines enable antialiasing (default: false)
  30192. * @param options defines further options to be sent to the getContext() function
  30193. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30194. */
  30195. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30196. /**
  30197. * Initializes a webVR display and starts listening to display change events
  30198. * The onVRDisplayChangedObservable will be notified upon these changes
  30199. * @returns The onVRDisplayChangedObservable
  30200. */
  30201. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30202. /** @hidden */
  30203. _prepareVRComponent(): void;
  30204. /** @hidden */
  30205. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30206. /** @hidden */
  30207. _submitVRFrame(): void;
  30208. /**
  30209. * Call this function to leave webVR mode
  30210. * Will do nothing if webVR is not supported or if there is no webVR device
  30211. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30212. */
  30213. disableVR(): void;
  30214. /**
  30215. * Gets a boolean indicating that the system is in VR mode and is presenting
  30216. * @returns true if VR mode is engaged
  30217. */
  30218. isVRPresenting(): boolean;
  30219. /** @hidden */
  30220. _requestVRFrame(): void;
  30221. private _disableTouchAction;
  30222. private _rebuildInternalTextures;
  30223. private _rebuildEffects;
  30224. /**
  30225. * Gets a boolean indicating if all created effects are ready
  30226. * @returns true if all effects are ready
  30227. */
  30228. areAllEffectsReady(): boolean;
  30229. private _rebuildBuffers;
  30230. private _initGLContext;
  30231. /**
  30232. * Gets version of the current webGL context
  30233. */
  30234. readonly webGLVersion: number;
  30235. /**
  30236. * Gets a string idenfifying the name of the class
  30237. * @returns "Engine" string
  30238. */
  30239. getClassName(): string;
  30240. /**
  30241. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30242. */
  30243. readonly isStencilEnable: boolean;
  30244. /** @hidden */
  30245. _prepareWorkingCanvas(): void;
  30246. /**
  30247. * Reset the texture cache to empty state
  30248. */
  30249. resetTextureCache(): void;
  30250. /**
  30251. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30252. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30253. * @returns true if engine is in deterministic lock step mode
  30254. */
  30255. isDeterministicLockStep(): boolean;
  30256. /**
  30257. * Gets the max steps when engine is running in deterministic lock step
  30258. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30259. * @returns the max steps
  30260. */
  30261. getLockstepMaxSteps(): number;
  30262. /**
  30263. * Gets an object containing information about the current webGL context
  30264. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30265. */
  30266. getGlInfo(): {
  30267. vendor: string;
  30268. renderer: string;
  30269. version: string;
  30270. };
  30271. /**
  30272. * Gets current aspect ratio
  30273. * @param viewportOwner defines the camera to use to get the aspect ratio
  30274. * @param useScreen defines if screen size must be used (or the current render target if any)
  30275. * @returns a number defining the aspect ratio
  30276. */
  30277. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30278. /**
  30279. * Gets current screen aspect ratio
  30280. * @returns a number defining the aspect ratio
  30281. */
  30282. getScreenAspectRatio(): number;
  30283. /**
  30284. * Gets the current render width
  30285. * @param useScreen defines if screen size must be used (or the current render target if any)
  30286. * @returns a number defining the current render width
  30287. */
  30288. getRenderWidth(useScreen?: boolean): number;
  30289. /**
  30290. * Gets the current render height
  30291. * @param useScreen defines if screen size must be used (or the current render target if any)
  30292. * @returns a number defining the current render height
  30293. */
  30294. getRenderHeight(useScreen?: boolean): number;
  30295. /**
  30296. * Gets the HTML canvas attached with the current webGL context
  30297. * @returns a HTML canvas
  30298. */
  30299. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30300. /**
  30301. * Gets the client rect of the HTML canvas attached with the current webGL context
  30302. * @returns a client rectanglee
  30303. */
  30304. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30305. /**
  30306. * Defines the hardware scaling level.
  30307. * By default the hardware scaling level is computed from the window device ratio.
  30308. * 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.
  30309. * @param level defines the level to use
  30310. */
  30311. setHardwareScalingLevel(level: number): void;
  30312. /**
  30313. * Gets the current hardware scaling level.
  30314. * By default the hardware scaling level is computed from the window device ratio.
  30315. * 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.
  30316. * @returns a number indicating the current hardware scaling level
  30317. */
  30318. getHardwareScalingLevel(): number;
  30319. /**
  30320. * Gets the list of loaded textures
  30321. * @returns an array containing all loaded textures
  30322. */
  30323. getLoadedTexturesCache(): InternalTexture[];
  30324. /**
  30325. * Gets the object containing all engine capabilities
  30326. * @returns the EngineCapabilities object
  30327. */
  30328. getCaps(): EngineCapabilities;
  30329. /**
  30330. * Gets the current depth function
  30331. * @returns a number defining the depth function
  30332. */
  30333. getDepthFunction(): Nullable<number>;
  30334. /**
  30335. * Sets the current depth function
  30336. * @param depthFunc defines the function to use
  30337. */
  30338. setDepthFunction(depthFunc: number): void;
  30339. /**
  30340. * Sets the current depth function to GREATER
  30341. */
  30342. setDepthFunctionToGreater(): void;
  30343. /**
  30344. * Sets the current depth function to GEQUAL
  30345. */
  30346. setDepthFunctionToGreaterOrEqual(): void;
  30347. /**
  30348. * Sets the current depth function to LESS
  30349. */
  30350. setDepthFunctionToLess(): void;
  30351. private _cachedStencilBuffer;
  30352. private _cachedStencilFunction;
  30353. private _cachedStencilMask;
  30354. private _cachedStencilOperationPass;
  30355. private _cachedStencilOperationFail;
  30356. private _cachedStencilOperationDepthFail;
  30357. private _cachedStencilReference;
  30358. /**
  30359. * Caches the the state of the stencil buffer
  30360. */
  30361. cacheStencilState(): void;
  30362. /**
  30363. * Restores the state of the stencil buffer
  30364. */
  30365. restoreStencilState(): void;
  30366. /**
  30367. * Sets the current depth function to LEQUAL
  30368. */
  30369. setDepthFunctionToLessOrEqual(): void;
  30370. /**
  30371. * Gets a boolean indicating if stencil buffer is enabled
  30372. * @returns the current stencil buffer state
  30373. */
  30374. getStencilBuffer(): boolean;
  30375. /**
  30376. * Enable or disable the stencil buffer
  30377. * @param enable defines if the stencil buffer must be enabled or disabled
  30378. */
  30379. setStencilBuffer(enable: boolean): void;
  30380. /**
  30381. * Gets the current stencil mask
  30382. * @returns a number defining the new stencil mask to use
  30383. */
  30384. getStencilMask(): number;
  30385. /**
  30386. * Sets the current stencil mask
  30387. * @param mask defines the new stencil mask to use
  30388. */
  30389. setStencilMask(mask: number): void;
  30390. /**
  30391. * Gets the current stencil function
  30392. * @returns a number defining the stencil function to use
  30393. */
  30394. getStencilFunction(): number;
  30395. /**
  30396. * Gets the current stencil reference value
  30397. * @returns a number defining the stencil reference value to use
  30398. */
  30399. getStencilFunctionReference(): number;
  30400. /**
  30401. * Gets the current stencil mask
  30402. * @returns a number defining the stencil mask to use
  30403. */
  30404. getStencilFunctionMask(): number;
  30405. /**
  30406. * Sets the current stencil function
  30407. * @param stencilFunc defines the new stencil function to use
  30408. */
  30409. setStencilFunction(stencilFunc: number): void;
  30410. /**
  30411. * Sets the current stencil reference
  30412. * @param reference defines the new stencil reference to use
  30413. */
  30414. setStencilFunctionReference(reference: number): void;
  30415. /**
  30416. * Sets the current stencil mask
  30417. * @param mask defines the new stencil mask to use
  30418. */
  30419. setStencilFunctionMask(mask: number): void;
  30420. /**
  30421. * Gets the current stencil operation when stencil fails
  30422. * @returns a number defining stencil operation to use when stencil fails
  30423. */
  30424. getStencilOperationFail(): number;
  30425. /**
  30426. * Gets the current stencil operation when depth fails
  30427. * @returns a number defining stencil operation to use when depth fails
  30428. */
  30429. getStencilOperationDepthFail(): number;
  30430. /**
  30431. * Gets the current stencil operation when stencil passes
  30432. * @returns a number defining stencil operation to use when stencil passes
  30433. */
  30434. getStencilOperationPass(): number;
  30435. /**
  30436. * Sets the stencil operation to use when stencil fails
  30437. * @param operation defines the stencil operation to use when stencil fails
  30438. */
  30439. setStencilOperationFail(operation: number): void;
  30440. /**
  30441. * Sets the stencil operation to use when depth fails
  30442. * @param operation defines the stencil operation to use when depth fails
  30443. */
  30444. setStencilOperationDepthFail(operation: number): void;
  30445. /**
  30446. * Sets the stencil operation to use when stencil passes
  30447. * @param operation defines the stencil operation to use when stencil passes
  30448. */
  30449. setStencilOperationPass(operation: number): void;
  30450. /**
  30451. * Sets a boolean indicating if the dithering state is enabled or disabled
  30452. * @param value defines the dithering state
  30453. */
  30454. setDitheringState(value: boolean): void;
  30455. /**
  30456. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30457. * @param value defines the rasterizer state
  30458. */
  30459. setRasterizerState(value: boolean): void;
  30460. /**
  30461. * stop executing a render loop function and remove it from the execution array
  30462. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30463. */
  30464. stopRenderLoop(renderFunction?: () => void): void;
  30465. /** @hidden */
  30466. _renderLoop(): void;
  30467. /**
  30468. * Register and execute a render loop. The engine can have more than one render function
  30469. * @param renderFunction defines the function to continuously execute
  30470. */
  30471. runRenderLoop(renderFunction: () => void): void;
  30472. /**
  30473. * Toggle full screen mode
  30474. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30475. */
  30476. switchFullscreen(requestPointerLock: boolean): void;
  30477. /**
  30478. * Enters full screen mode
  30479. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30480. */
  30481. enterFullscreen(requestPointerLock: boolean): void;
  30482. /**
  30483. * Exits full screen mode
  30484. */
  30485. exitFullscreen(): void;
  30486. /**
  30487. * Enters Pointerlock mode
  30488. */
  30489. enterPointerlock(): void;
  30490. /**
  30491. * Exits Pointerlock mode
  30492. */
  30493. exitPointerlock(): void;
  30494. /**
  30495. * Clear the current render buffer or the current render target (if any is set up)
  30496. * @param color defines the color to use
  30497. * @param backBuffer defines if the back buffer must be cleared
  30498. * @param depth defines if the depth buffer must be cleared
  30499. * @param stencil defines if the stencil buffer must be cleared
  30500. */
  30501. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30502. /**
  30503. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30504. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30505. * @param y defines the y-coordinate of the corner of the clear rectangle
  30506. * @param width defines the width of the clear rectangle
  30507. * @param height defines the height of the clear rectangle
  30508. * @param clearColor defines the clear color
  30509. */
  30510. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30511. /**
  30512. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30513. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30514. * @param y defines the y-coordinate of the corner of the clear rectangle
  30515. * @param width defines the width of the clear rectangle
  30516. * @param height defines the height of the clear rectangle
  30517. */
  30518. enableScissor(x: number, y: number, width: number, height: number): void;
  30519. /**
  30520. * Disable previously set scissor test rectangle
  30521. */
  30522. disableScissor(): void;
  30523. private _viewportCached;
  30524. /** @hidden */
  30525. _viewport(x: number, y: number, width: number, height: number): void;
  30526. /**
  30527. * Set the WebGL's viewport
  30528. * @param viewport defines the viewport element to be used
  30529. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30530. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30531. */
  30532. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30533. /**
  30534. * Directly set the WebGL Viewport
  30535. * @param x defines the x coordinate of the viewport (in screen space)
  30536. * @param y defines the y coordinate of the viewport (in screen space)
  30537. * @param width defines the width of the viewport (in screen space)
  30538. * @param height defines the height of the viewport (in screen space)
  30539. * @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
  30540. */
  30541. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30542. /**
  30543. * Begin a new frame
  30544. */
  30545. beginFrame(): void;
  30546. /**
  30547. * Enf the current frame
  30548. */
  30549. endFrame(): void;
  30550. /**
  30551. * Resize the view according to the canvas' size
  30552. */
  30553. resize(): void;
  30554. /**
  30555. * Force a specific size of the canvas
  30556. * @param width defines the new canvas' width
  30557. * @param height defines the new canvas' height
  30558. */
  30559. setSize(width: number, height: number): void;
  30560. /**
  30561. * Binds the frame buffer to the specified texture.
  30562. * @param texture The texture to render to or null for the default canvas
  30563. * @param faceIndex The face of the texture to render to in case of cube texture
  30564. * @param requiredWidth The width of the target to render to
  30565. * @param requiredHeight The height of the target to render to
  30566. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30567. * @param depthStencilTexture The depth stencil texture to use to render
  30568. * @param lodLevel defines le lod level to bind to the frame buffer
  30569. */
  30570. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30571. /** @hidden */
  30572. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30573. /**
  30574. * Unbind the current render target texture from the webGL context
  30575. * @param texture defines the render target texture to unbind
  30576. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30577. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30578. */
  30579. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30580. /**
  30581. * Force the mipmap generation for the given render target texture
  30582. * @param texture defines the render target texture to use
  30583. */
  30584. generateMipMapsForCubemap(texture: InternalTexture): void;
  30585. /**
  30586. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30587. */
  30588. flushFramebuffer(): void;
  30589. /**
  30590. * Unbind the current render target and bind the default framebuffer
  30591. */
  30592. restoreDefaultFramebuffer(): void;
  30593. /**
  30594. * Create an uniform buffer
  30595. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30596. * @param elements defines the content of the uniform buffer
  30597. * @returns the webGL uniform buffer
  30598. */
  30599. createUniformBuffer(elements: FloatArray): DataBuffer;
  30600. /**
  30601. * Create a dynamic uniform buffer
  30602. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30603. * @param elements defines the content of the uniform buffer
  30604. * @returns the webGL uniform buffer
  30605. */
  30606. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30607. /**
  30608. * Update an existing uniform buffer
  30609. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30610. * @param uniformBuffer defines the target uniform buffer
  30611. * @param elements defines the content to update
  30612. * @param offset defines the offset in the uniform buffer where update should start
  30613. * @param count defines the size of the data to update
  30614. */
  30615. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30616. private _resetVertexBufferBinding;
  30617. /**
  30618. * Creates a vertex buffer
  30619. * @param data the data for the vertex buffer
  30620. * @returns the new WebGL static buffer
  30621. */
  30622. createVertexBuffer(data: DataArray): DataBuffer;
  30623. /**
  30624. * Creates a dynamic vertex buffer
  30625. * @param data the data for the dynamic vertex buffer
  30626. * @returns the new WebGL dynamic buffer
  30627. */
  30628. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30629. /**
  30630. * Update a dynamic index buffer
  30631. * @param indexBuffer defines the target index buffer
  30632. * @param indices defines the data to update
  30633. * @param offset defines the offset in the target index buffer where update should start
  30634. */
  30635. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30636. /**
  30637. * Updates a dynamic vertex buffer.
  30638. * @param vertexBuffer the vertex buffer to update
  30639. * @param data the data used to update the vertex buffer
  30640. * @param byteOffset the byte offset of the data
  30641. * @param byteLength the byte length of the data
  30642. */
  30643. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30644. private _resetIndexBufferBinding;
  30645. /**
  30646. * Creates a new index buffer
  30647. * @param indices defines the content of the index buffer
  30648. * @param updatable defines if the index buffer must be updatable
  30649. * @returns a new webGL buffer
  30650. */
  30651. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30652. /**
  30653. * Bind a webGL buffer to the webGL context
  30654. * @param buffer defines the buffer to bind
  30655. */
  30656. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30657. /**
  30658. * Bind an uniform buffer to the current webGL context
  30659. * @param buffer defines the buffer to bind
  30660. */
  30661. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30662. /**
  30663. * Bind a buffer to the current webGL context at a given location
  30664. * @param buffer defines the buffer to bind
  30665. * @param location defines the index where to bind the buffer
  30666. */
  30667. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30668. /**
  30669. * Bind a specific block at a given index in a specific shader program
  30670. * @param pipelineContext defines the pipeline context to use
  30671. * @param blockName defines the block name
  30672. * @param index defines the index where to bind the block
  30673. */
  30674. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30675. private bindIndexBuffer;
  30676. private bindBuffer;
  30677. /**
  30678. * update the bound buffer with the given data
  30679. * @param data defines the data to update
  30680. */
  30681. updateArrayBuffer(data: Float32Array): void;
  30682. private _vertexAttribPointer;
  30683. private _bindIndexBufferWithCache;
  30684. private _bindVertexBuffersAttributes;
  30685. /**
  30686. * Records a vertex array object
  30687. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30688. * @param vertexBuffers defines the list of vertex buffers to store
  30689. * @param indexBuffer defines the index buffer to store
  30690. * @param effect defines the effect to store
  30691. * @returns the new vertex array object
  30692. */
  30693. recordVertexArrayObject(vertexBuffers: {
  30694. [key: string]: VertexBuffer;
  30695. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30696. /**
  30697. * Bind a specific vertex array object
  30698. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30699. * @param vertexArrayObject defines the vertex array object to bind
  30700. * @param indexBuffer defines the index buffer to bind
  30701. */
  30702. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30703. /**
  30704. * Bind webGl buffers directly to the webGL context
  30705. * @param vertexBuffer defines the vertex buffer to bind
  30706. * @param indexBuffer defines the index buffer to bind
  30707. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30708. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30709. * @param effect defines the effect associated with the vertex buffer
  30710. */
  30711. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30712. private _unbindVertexArrayObject;
  30713. /**
  30714. * Bind a list of vertex buffers to the webGL context
  30715. * @param vertexBuffers defines the list of vertex buffers to bind
  30716. * @param indexBuffer defines the index buffer to bind
  30717. * @param effect defines the effect associated with the vertex buffers
  30718. */
  30719. bindBuffers(vertexBuffers: {
  30720. [key: string]: Nullable<VertexBuffer>;
  30721. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30722. /**
  30723. * Unbind all instance attributes
  30724. */
  30725. unbindInstanceAttributes(): void;
  30726. /**
  30727. * Release and free the memory of a vertex array object
  30728. * @param vao defines the vertex array object to delete
  30729. */
  30730. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30731. /** @hidden */
  30732. _releaseBuffer(buffer: DataBuffer): boolean;
  30733. /**
  30734. * Creates a webGL buffer to use with instanciation
  30735. * @param capacity defines the size of the buffer
  30736. * @returns the webGL buffer
  30737. */
  30738. createInstancesBuffer(capacity: number): DataBuffer;
  30739. /**
  30740. * Delete a webGL buffer used with instanciation
  30741. * @param buffer defines the webGL buffer to delete
  30742. */
  30743. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30744. /**
  30745. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30746. * @param instancesBuffer defines the webGL buffer to update and bind
  30747. * @param data defines the data to store in the buffer
  30748. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30749. */
  30750. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30751. /**
  30752. * Apply all cached states (depth, culling, stencil and alpha)
  30753. */
  30754. applyStates(): void;
  30755. /**
  30756. * Send a draw order
  30757. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30758. * @param indexStart defines the starting index
  30759. * @param indexCount defines the number of index to draw
  30760. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30761. */
  30762. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30763. /**
  30764. * Draw a list of points
  30765. * @param verticesStart defines the index of first vertex to draw
  30766. * @param verticesCount defines the count of vertices to draw
  30767. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30768. */
  30769. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30770. /**
  30771. * Draw a list of unindexed primitives
  30772. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30773. * @param verticesStart defines the index of first vertex to draw
  30774. * @param verticesCount defines the count of vertices to draw
  30775. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30776. */
  30777. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30778. /**
  30779. * Draw a list of indexed primitives
  30780. * @param fillMode defines the primitive to use
  30781. * @param indexStart defines the starting index
  30782. * @param indexCount defines the number of index to draw
  30783. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30784. */
  30785. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30786. /**
  30787. * Draw a list of unindexed primitives
  30788. * @param fillMode defines the primitive to use
  30789. * @param verticesStart defines the index of first vertex to draw
  30790. * @param verticesCount defines the count of vertices to draw
  30791. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30792. */
  30793. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30794. private _drawMode;
  30795. /** @hidden */
  30796. _releaseEffect(effect: Effect): void;
  30797. /** @hidden */
  30798. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30799. /**
  30800. * Create a new effect (used to store vertex/fragment shaders)
  30801. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30802. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30803. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30804. * @param samplers defines an array of string used to represent textures
  30805. * @param defines defines the string containing the defines to use to compile the shaders
  30806. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30807. * @param onCompiled defines a function to call when the effect creation is successful
  30808. * @param onError defines a function to call when the effect creation has failed
  30809. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30810. * @returns the new Effect
  30811. */
  30812. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30813. private _compileShader;
  30814. private _compileRawShader;
  30815. /**
  30816. * Directly creates a webGL program
  30817. * @param pipelineContext defines the pipeline context to attach to
  30818. * @param vertexCode defines the vertex shader code to use
  30819. * @param fragmentCode defines the fragment shader code to use
  30820. * @param context defines the webGL context to use (if not set, the current one will be used)
  30821. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30822. * @returns the new webGL program
  30823. */
  30824. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30825. /**
  30826. * Creates a webGL program
  30827. * @param pipelineContext defines the pipeline context to attach to
  30828. * @param vertexCode defines the vertex shader code to use
  30829. * @param fragmentCode defines the fragment shader code to use
  30830. * @param defines defines the string containing the defines to use to compile the shaders
  30831. * @param context defines the webGL context to use (if not set, the current one will be used)
  30832. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30833. * @returns the new webGL program
  30834. */
  30835. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30836. /**
  30837. * Creates a new pipeline context
  30838. * @returns the new pipeline
  30839. */
  30840. createPipelineContext(): WebGLPipelineContext;
  30841. private _createShaderProgram;
  30842. private _finalizePipelineContext;
  30843. /** @hidden */
  30844. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30845. /** @hidden */
  30846. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30847. /** @hidden */
  30848. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30849. /**
  30850. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30851. * @param pipelineContext defines the pipeline context to use
  30852. * @param uniformsNames defines the list of uniform names
  30853. * @returns an array of webGL uniform locations
  30854. */
  30855. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30856. /**
  30857. * Gets the lsit of active attributes for a given webGL program
  30858. * @param pipelineContext defines the pipeline context to use
  30859. * @param attributesNames defines the list of attribute names to get
  30860. * @returns an array of indices indicating the offset of each attribute
  30861. */
  30862. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30863. /**
  30864. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30865. * @param effect defines the effect to activate
  30866. */
  30867. enableEffect(effect: Nullable<Effect>): void;
  30868. /**
  30869. * Set the value of an uniform to an array of int32
  30870. * @param uniform defines the webGL uniform location where to store the value
  30871. * @param array defines the array of int32 to store
  30872. */
  30873. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30874. /**
  30875. * Set the value of an uniform to an array of int32 (stored as vec2)
  30876. * @param uniform defines the webGL uniform location where to store the value
  30877. * @param array defines the array of int32 to store
  30878. */
  30879. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30880. /**
  30881. * Set the value of an uniform to an array of int32 (stored as vec3)
  30882. * @param uniform defines the webGL uniform location where to store the value
  30883. * @param array defines the array of int32 to store
  30884. */
  30885. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30886. /**
  30887. * Set the value of an uniform to an array of int32 (stored as vec4)
  30888. * @param uniform defines the webGL uniform location where to store the value
  30889. * @param array defines the array of int32 to store
  30890. */
  30891. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30892. /**
  30893. * Set the value of an uniform to an array of float32
  30894. * @param uniform defines the webGL uniform location where to store the value
  30895. * @param array defines the array of float32 to store
  30896. */
  30897. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30898. /**
  30899. * Set the value of an uniform to an array of float32 (stored as vec2)
  30900. * @param uniform defines the webGL uniform location where to store the value
  30901. * @param array defines the array of float32 to store
  30902. */
  30903. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30904. /**
  30905. * Set the value of an uniform to an array of float32 (stored as vec3)
  30906. * @param uniform defines the webGL uniform location where to store the value
  30907. * @param array defines the array of float32 to store
  30908. */
  30909. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30910. /**
  30911. * Set the value of an uniform to an array of float32 (stored as vec4)
  30912. * @param uniform defines the webGL uniform location where to store the value
  30913. * @param array defines the array of float32 to store
  30914. */
  30915. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30916. /**
  30917. * Set the value of an uniform to an array of number
  30918. * @param uniform defines the webGL uniform location where to store the value
  30919. * @param array defines the array of number to store
  30920. */
  30921. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30922. /**
  30923. * Set the value of an uniform to an array of number (stored as vec2)
  30924. * @param uniform defines the webGL uniform location where to store the value
  30925. * @param array defines the array of number to store
  30926. */
  30927. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30928. /**
  30929. * Set the value of an uniform to an array of number (stored as vec3)
  30930. * @param uniform defines the webGL uniform location where to store the value
  30931. * @param array defines the array of number to store
  30932. */
  30933. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30934. /**
  30935. * Set the value of an uniform to an array of number (stored as vec4)
  30936. * @param uniform defines the webGL uniform location where to store the value
  30937. * @param array defines the array of number to store
  30938. */
  30939. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30940. /**
  30941. * Set the value of an uniform to an array of float32 (stored as matrices)
  30942. * @param uniform defines the webGL uniform location where to store the value
  30943. * @param matrices defines the array of float32 to store
  30944. */
  30945. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30946. /**
  30947. * Set the value of an uniform to a matrix (3x3)
  30948. * @param uniform defines the webGL uniform location where to store the value
  30949. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30950. */
  30951. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30952. /**
  30953. * Set the value of an uniform to a matrix (2x2)
  30954. * @param uniform defines the webGL uniform location where to store the value
  30955. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30956. */
  30957. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30958. /**
  30959. * Set the value of an uniform to a number (int)
  30960. * @param uniform defines the webGL uniform location where to store the value
  30961. * @param value defines the int number to store
  30962. */
  30963. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30964. /**
  30965. * Set the value of an uniform to a number (float)
  30966. * @param uniform defines the webGL uniform location where to store the value
  30967. * @param value defines the float number to store
  30968. */
  30969. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30970. /**
  30971. * Set the value of an uniform to a vec2
  30972. * @param uniform defines the webGL uniform location where to store the value
  30973. * @param x defines the 1st component of the value
  30974. * @param y defines the 2nd component of the value
  30975. */
  30976. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30977. /**
  30978. * Set the value of an uniform to a vec3
  30979. * @param uniform defines the webGL uniform location where to store the value
  30980. * @param x defines the 1st component of the value
  30981. * @param y defines the 2nd component of the value
  30982. * @param z defines the 3rd component of the value
  30983. */
  30984. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30985. /**
  30986. * Set the value of an uniform to a boolean
  30987. * @param uniform defines the webGL uniform location where to store the value
  30988. * @param bool defines the boolean to store
  30989. */
  30990. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30991. /**
  30992. * Set the value of an uniform to a vec4
  30993. * @param uniform defines the webGL uniform location where to store the value
  30994. * @param x defines the 1st component of the value
  30995. * @param y defines the 2nd component of the value
  30996. * @param z defines the 3rd component of the value
  30997. * @param w defines the 4th component of the value
  30998. */
  30999. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31000. /**
  31001. * Sets a Color4 on a uniform variable
  31002. * @param uniform defines the uniform location
  31003. * @param color4 defines the value to be set
  31004. */
  31005. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31006. /**
  31007. * Set various states to the webGL context
  31008. * @param culling defines backface culling state
  31009. * @param zOffset defines the value to apply to zOffset (0 by default)
  31010. * @param force defines if states must be applied even if cache is up to date
  31011. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31012. */
  31013. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31014. /**
  31015. * Set the z offset to apply to current rendering
  31016. * @param value defines the offset to apply
  31017. */
  31018. setZOffset(value: number): void;
  31019. /**
  31020. * Gets the current value of the zOffset
  31021. * @returns the current zOffset state
  31022. */
  31023. getZOffset(): number;
  31024. /**
  31025. * Enable or disable depth buffering
  31026. * @param enable defines the state to set
  31027. */
  31028. setDepthBuffer(enable: boolean): void;
  31029. /**
  31030. * Gets a boolean indicating if depth writing is enabled
  31031. * @returns the current depth writing state
  31032. */
  31033. getDepthWrite(): boolean;
  31034. /**
  31035. * Enable or disable depth writing
  31036. * @param enable defines the state to set
  31037. */
  31038. setDepthWrite(enable: boolean): void;
  31039. /**
  31040. * Enable or disable color writing
  31041. * @param enable defines the state to set
  31042. */
  31043. setColorWrite(enable: boolean): void;
  31044. /**
  31045. * Gets a boolean indicating if color writing is enabled
  31046. * @returns the current color writing state
  31047. */
  31048. getColorWrite(): boolean;
  31049. /**
  31050. * Sets alpha constants used by some alpha blending modes
  31051. * @param r defines the red component
  31052. * @param g defines the green component
  31053. * @param b defines the blue component
  31054. * @param a defines the alpha component
  31055. */
  31056. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31057. /**
  31058. * Sets the current alpha mode
  31059. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31060. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31061. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31062. */
  31063. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31064. /**
  31065. * Gets the current alpha mode
  31066. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31067. * @returns the current alpha mode
  31068. */
  31069. getAlphaMode(): number;
  31070. /**
  31071. * Clears the list of texture accessible through engine.
  31072. * This can help preventing texture load conflict due to name collision.
  31073. */
  31074. clearInternalTexturesCache(): void;
  31075. /**
  31076. * Force the entire cache to be cleared
  31077. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31078. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31079. */
  31080. wipeCaches(bruteForce?: boolean): void;
  31081. /**
  31082. * Set the compressed texture format to use, based on the formats you have, and the formats
  31083. * supported by the hardware / browser.
  31084. *
  31085. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31086. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31087. * to API arguments needed to compressed textures. This puts the burden on the container
  31088. * generator to house the arcane code for determining these for current & future formats.
  31089. *
  31090. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31091. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31092. *
  31093. * Note: The result of this call is not taken into account when a texture is base64.
  31094. *
  31095. * @param formatsAvailable defines the list of those format families you have created
  31096. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31097. *
  31098. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31099. * @returns The extension selected.
  31100. */
  31101. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31102. /** @hidden */
  31103. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31104. min: number;
  31105. mag: number;
  31106. };
  31107. /** @hidden */
  31108. _createTexture(): WebGLTexture;
  31109. /**
  31110. * Usually called from Texture.ts.
  31111. * Passed information to create a WebGLTexture
  31112. * @param urlArg defines a value which contains one of the following:
  31113. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31114. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31115. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31116. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31117. * @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)
  31118. * @param scene needed for loading to the correct scene
  31119. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31120. * @param onLoad optional callback to be called upon successful completion
  31121. * @param onError optional callback to be called upon failure
  31122. * @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
  31123. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31124. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31125. * @param forcedExtension defines the extension to use to pick the right loader
  31126. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31127. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31128. */
  31129. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31130. /**
  31131. * @hidden
  31132. * Rescales a texture
  31133. * @param source input texutre
  31134. * @param destination destination texture
  31135. * @param scene scene to use to render the resize
  31136. * @param internalFormat format to use when resizing
  31137. * @param onComplete callback to be called when resize has completed
  31138. */
  31139. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31140. private _unpackFlipYCached;
  31141. /**
  31142. * In case you are sharing the context with other applications, it might
  31143. * be interested to not cache the unpack flip y state to ensure a consistent
  31144. * value would be set.
  31145. */
  31146. enableUnpackFlipYCached: boolean;
  31147. /** @hidden */
  31148. _unpackFlipY(value: boolean): void;
  31149. /** @hidden */
  31150. _getUnpackAlignement(): number;
  31151. /**
  31152. * Creates a dynamic texture
  31153. * @param width defines the width of the texture
  31154. * @param height defines the height of the texture
  31155. * @param generateMipMaps defines if the engine should generate the mip levels
  31156. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31157. * @returns the dynamic texture inside an InternalTexture
  31158. */
  31159. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31160. /**
  31161. * Update the sampling mode of a given texture
  31162. * @param samplingMode defines the required sampling mode
  31163. * @param texture defines the texture to update
  31164. */
  31165. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31166. /**
  31167. * Update the content of a dynamic texture
  31168. * @param texture defines the texture to update
  31169. * @param canvas defines the canvas containing the source
  31170. * @param invertY defines if data must be stored with Y axis inverted
  31171. * @param premulAlpha defines if alpha is stored as premultiplied
  31172. * @param format defines the format of the data
  31173. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31174. */
  31175. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31176. /**
  31177. * Update a video texture
  31178. * @param texture defines the texture to update
  31179. * @param video defines the video element to use
  31180. * @param invertY defines if data must be stored with Y axis inverted
  31181. */
  31182. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31183. /**
  31184. * Updates a depth texture Comparison Mode and Function.
  31185. * If the comparison Function is equal to 0, the mode will be set to none.
  31186. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31187. * @param texture The texture to set the comparison function for
  31188. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31189. */
  31190. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31191. /** @hidden */
  31192. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31193. width: number;
  31194. height: number;
  31195. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31196. /**
  31197. * Creates a depth stencil texture.
  31198. * This is only available in WebGL 2 or with the depth texture extension available.
  31199. * @param size The size of face edge in the texture.
  31200. * @param options The options defining the texture.
  31201. * @returns The texture
  31202. */
  31203. createDepthStencilTexture(size: number | {
  31204. width: number;
  31205. height: number;
  31206. }, options: DepthTextureCreationOptions): InternalTexture;
  31207. /**
  31208. * Creates a depth stencil texture.
  31209. * This is only available in WebGL 2 or with the depth texture extension available.
  31210. * @param size The size of face edge in the texture.
  31211. * @param options The options defining the texture.
  31212. * @returns The texture
  31213. */
  31214. private _createDepthStencilTexture;
  31215. /**
  31216. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31217. * @param renderTarget The render target to set the frame buffer for
  31218. */
  31219. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31220. /**
  31221. * Creates a new render target texture
  31222. * @param size defines the size of the texture
  31223. * @param options defines the options used to create the texture
  31224. * @returns a new render target texture stored in an InternalTexture
  31225. */
  31226. createRenderTargetTexture(size: number | {
  31227. width: number;
  31228. height: number;
  31229. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31230. /** @hidden */
  31231. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31232. /**
  31233. * Updates the sample count of a render target texture
  31234. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31235. * @param texture defines the texture to update
  31236. * @param samples defines the sample count to set
  31237. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31238. */
  31239. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31240. /** @hidden */
  31241. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31242. /** @hidden */
  31243. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31244. /** @hidden */
  31245. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31246. /** @hidden */
  31247. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31248. /**
  31249. * @hidden
  31250. */
  31251. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31252. private _prepareWebGLTextureContinuation;
  31253. private _prepareWebGLTexture;
  31254. /** @hidden */
  31255. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31256. /** @hidden */
  31257. _releaseFramebufferObjects(texture: InternalTexture): void;
  31258. /** @hidden */
  31259. _releaseTexture(texture: InternalTexture): void;
  31260. private setProgram;
  31261. private _boundUniforms;
  31262. /**
  31263. * Binds an effect to the webGL context
  31264. * @param effect defines the effect to bind
  31265. */
  31266. bindSamplers(effect: Effect): void;
  31267. private _activateCurrentTexture;
  31268. /** @hidden */
  31269. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31270. /** @hidden */
  31271. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31272. /**
  31273. * Sets a texture to the webGL context from a postprocess
  31274. * @param channel defines the channel to use
  31275. * @param postProcess defines the source postprocess
  31276. */
  31277. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31278. /**
  31279. * Binds the output of the passed in post process to the texture channel specified
  31280. * @param channel The channel the texture should be bound to
  31281. * @param postProcess The post process which's output should be bound
  31282. */
  31283. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31284. /**
  31285. * Unbind all textures from the webGL context
  31286. */
  31287. unbindAllTextures(): void;
  31288. /**
  31289. * Sets a texture to the according uniform.
  31290. * @param channel The texture channel
  31291. * @param uniform The uniform to set
  31292. * @param texture The texture to apply
  31293. */
  31294. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31295. /**
  31296. * Sets a depth stencil texture from a render target to the according uniform.
  31297. * @param channel The texture channel
  31298. * @param uniform The uniform to set
  31299. * @param texture The render target texture containing the depth stencil texture to apply
  31300. */
  31301. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31302. private _bindSamplerUniformToChannel;
  31303. private _getTextureWrapMode;
  31304. private _setTexture;
  31305. /**
  31306. * Sets an array of texture to the webGL context
  31307. * @param channel defines the channel where the texture array must be set
  31308. * @param uniform defines the associated uniform location
  31309. * @param textures defines the array of textures to bind
  31310. */
  31311. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31312. /** @hidden */
  31313. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31314. private _setTextureParameterFloat;
  31315. private _setTextureParameterInteger;
  31316. /**
  31317. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31318. * @param x defines the x coordinate of the rectangle where pixels must be read
  31319. * @param y defines the y coordinate of the rectangle where pixels must be read
  31320. * @param width defines the width of the rectangle where pixels must be read
  31321. * @param height defines the height of the rectangle where pixels must be read
  31322. * @returns a Uint8Array containing RGBA colors
  31323. */
  31324. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31325. /**
  31326. * Add an externaly attached data from its key.
  31327. * This method call will fail and return false, if such key already exists.
  31328. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31329. * @param key the unique key that identifies the data
  31330. * @param data the data object to associate to the key for this Engine instance
  31331. * @return true if no such key were already present and the data was added successfully, false otherwise
  31332. */
  31333. addExternalData<T>(key: string, data: T): boolean;
  31334. /**
  31335. * Get an externaly attached data from its key
  31336. * @param key the unique key that identifies the data
  31337. * @return the associated data, if present (can be null), or undefined if not present
  31338. */
  31339. getExternalData<T>(key: string): T;
  31340. /**
  31341. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31342. * @param key the unique key that identifies the data
  31343. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31344. * @return the associated data, can be null if the factory returned null.
  31345. */
  31346. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31347. /**
  31348. * Remove an externaly attached data from the Engine instance
  31349. * @param key the unique key that identifies the data
  31350. * @return true if the data was successfully removed, false if it doesn't exist
  31351. */
  31352. removeExternalData(key: string): boolean;
  31353. /**
  31354. * Unbind all vertex attributes from the webGL context
  31355. */
  31356. unbindAllAttributes(): void;
  31357. /**
  31358. * 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
  31359. */
  31360. releaseEffects(): void;
  31361. /**
  31362. * Dispose and release all associated resources
  31363. */
  31364. dispose(): void;
  31365. /**
  31366. * Display the loading screen
  31367. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31368. */
  31369. displayLoadingUI(): void;
  31370. /**
  31371. * Hide the loading screen
  31372. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31373. */
  31374. hideLoadingUI(): void;
  31375. /**
  31376. * Gets the current loading screen object
  31377. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31378. */
  31379. /**
  31380. * Sets the current loading screen object
  31381. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31382. */
  31383. loadingScreen: ILoadingScreen;
  31384. /**
  31385. * Sets the current loading screen text
  31386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31387. */
  31388. loadingUIText: string;
  31389. /**
  31390. * Sets the current loading screen background color
  31391. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31392. */
  31393. loadingUIBackgroundColor: string;
  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. * Gets the source code of the vertex shader associated with a specific webGL program
  31406. * @param program defines the program to use
  31407. * @returns a string containing the source code of the vertex shader associated with the program
  31408. */
  31409. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31410. /**
  31411. * Gets the source code of the fragment shader associated with a specific webGL program
  31412. * @param program defines the program to use
  31413. * @returns a string containing the source code of the fragment shader associated with the program
  31414. */
  31415. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31416. /**
  31417. * Get the current error code of the webGL context
  31418. * @returns the error code
  31419. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31420. */
  31421. getError(): number;
  31422. /**
  31423. * Gets the current framerate
  31424. * @returns a number representing the framerate
  31425. */
  31426. getFps(): number;
  31427. /**
  31428. * Gets the time spent between current and previous frame
  31429. * @returns a number representing the delta time in ms
  31430. */
  31431. getDeltaTime(): number;
  31432. private _measureFps;
  31433. /** @hidden */
  31434. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31435. private _canRenderToFloatFramebuffer;
  31436. private _canRenderToHalfFloatFramebuffer;
  31437. private _canRenderToFramebuffer;
  31438. /** @hidden */
  31439. _getWebGLTextureType(type: number): number;
  31440. /** @hidden */
  31441. _getInternalFormat(format: number): number;
  31442. /** @hidden */
  31443. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31444. /** @hidden */
  31445. _getRGBAMultiSampleBufferFormat(type: number): number;
  31446. /** @hidden */
  31447. _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;
  31448. /** @hidden */
  31449. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31450. /**
  31451. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31452. * @returns true if the engine can be created
  31453. * @ignorenaming
  31454. */
  31455. static isSupported(): boolean;
  31456. /**
  31457. * Find the next highest power of two.
  31458. * @param x Number to start search from.
  31459. * @return Next highest power of two.
  31460. */
  31461. static CeilingPOT(x: number): number;
  31462. /**
  31463. * Find the next lowest power of two.
  31464. * @param x Number to start search from.
  31465. * @return Next lowest power of two.
  31466. */
  31467. static FloorPOT(x: number): number;
  31468. /**
  31469. * Find the nearest power of two.
  31470. * @param x Number to start search from.
  31471. * @return Next nearest power of two.
  31472. */
  31473. static NearestPOT(x: number): number;
  31474. /**
  31475. * Get the closest exponent of two
  31476. * @param value defines the value to approximate
  31477. * @param max defines the maximum value to return
  31478. * @param mode defines how to define the closest value
  31479. * @returns closest exponent of two of the given value
  31480. */
  31481. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31482. /**
  31483. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31484. * @param func - the function to be called
  31485. * @param requester - the object that will request the next frame. Falls back to window.
  31486. * @returns frame number
  31487. */
  31488. static QueueNewFrame(func: () => void, requester?: any): number;
  31489. /**
  31490. * Ask the browser to promote the current element to pointerlock mode
  31491. * @param element defines the DOM element to promote
  31492. */
  31493. static _RequestPointerlock(element: HTMLElement): void;
  31494. /**
  31495. * Asks the browser to exit pointerlock mode
  31496. */
  31497. static _ExitPointerlock(): void;
  31498. /**
  31499. * Ask the browser to promote the current element to fullscreen rendering mode
  31500. * @param element defines the DOM element to promote
  31501. */
  31502. static _RequestFullscreen(element: HTMLElement): void;
  31503. /**
  31504. * Asks the browser to exit fullscreen mode
  31505. */
  31506. static _ExitFullscreen(): void;
  31507. }
  31508. }
  31509. declare module BABYLON {
  31510. /**
  31511. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31512. * during the life time of the application.
  31513. */
  31514. export class EngineStore {
  31515. /** Gets the list of created engines */
  31516. static Instances: Engine[];
  31517. /** @hidden */
  31518. static _LastCreatedScene: Nullable<Scene>;
  31519. /**
  31520. * Gets the latest created engine
  31521. */
  31522. static readonly LastCreatedEngine: Nullable<Engine>;
  31523. /**
  31524. * Gets the latest created scene
  31525. */
  31526. static readonly LastCreatedScene: Nullable<Scene>;
  31527. /**
  31528. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31529. * @ignorenaming
  31530. */
  31531. static UseFallbackTexture: boolean;
  31532. /**
  31533. * Texture content used if a texture cannot loaded
  31534. * @ignorenaming
  31535. */
  31536. static FallbackTexture: string;
  31537. }
  31538. }
  31539. declare module BABYLON {
  31540. /**
  31541. * Helper class that provides a small promise polyfill
  31542. */
  31543. export class PromisePolyfill {
  31544. /**
  31545. * Static function used to check if the polyfill is required
  31546. * If this is the case then the function will inject the polyfill to window.Promise
  31547. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31548. */
  31549. static Apply(force?: boolean): void;
  31550. }
  31551. }
  31552. declare module BABYLON {
  31553. interface IColor4Like {
  31554. r: float;
  31555. g: float;
  31556. b: float;
  31557. a: float;
  31558. }
  31559. /**
  31560. * Class containing a set of static utilities functions
  31561. */
  31562. export class Tools {
  31563. /**
  31564. * Gets or sets the base URL to use to load assets
  31565. */
  31566. static BaseUrl: string;
  31567. /**
  31568. * Enable/Disable Custom HTTP Request Headers globally.
  31569. * default = false
  31570. * @see CustomRequestHeaders
  31571. */
  31572. static UseCustomRequestHeaders: boolean;
  31573. /**
  31574. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31575. * i.e. when loading files, where the server/service expects an Authorization header
  31576. */
  31577. static CustomRequestHeaders: {
  31578. [key: string]: string;
  31579. };
  31580. /**
  31581. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31582. */
  31583. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31584. /**
  31585. * Default behaviour for cors in the application.
  31586. * It can be a string if the expected behavior is identical in the entire app.
  31587. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31588. */
  31589. static CorsBehavior: string | ((url: string | string[]) => string);
  31590. /**
  31591. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31592. * @ignorenaming
  31593. */
  31594. static UseFallbackTexture: boolean;
  31595. /**
  31596. * Use this object to register external classes like custom textures or material
  31597. * to allow the laoders to instantiate them
  31598. */
  31599. static RegisteredExternalClasses: {
  31600. [key: string]: Object;
  31601. };
  31602. /**
  31603. * Texture content used if a texture cannot loaded
  31604. * @ignorenaming
  31605. */
  31606. static fallbackTexture: string;
  31607. /**
  31608. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31609. * @param u defines the coordinate on X axis
  31610. * @param v defines the coordinate on Y axis
  31611. * @param width defines the width of the source data
  31612. * @param height defines the height of the source data
  31613. * @param pixels defines the source byte array
  31614. * @param color defines the output color
  31615. */
  31616. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31617. /**
  31618. * Interpolates between a and b via alpha
  31619. * @param a The lower value (returned when alpha = 0)
  31620. * @param b The upper value (returned when alpha = 1)
  31621. * @param alpha The interpolation-factor
  31622. * @return The mixed value
  31623. */
  31624. static Mix(a: number, b: number, alpha: number): number;
  31625. /**
  31626. * Tries to instantiate a new object from a given class name
  31627. * @param className defines the class name to instantiate
  31628. * @returns the new object or null if the system was not able to do the instantiation
  31629. */
  31630. static Instantiate(className: string): any;
  31631. /**
  31632. * Provides a slice function that will work even on IE
  31633. * @param data defines the array to slice
  31634. * @param start defines the start of the data (optional)
  31635. * @param end defines the end of the data (optional)
  31636. * @returns the new sliced array
  31637. */
  31638. static Slice<T>(data: T, start?: number, end?: number): T;
  31639. /**
  31640. * Polyfill for setImmediate
  31641. * @param action defines the action to execute after the current execution block
  31642. */
  31643. static SetImmediate(action: () => void): void;
  31644. /**
  31645. * Function indicating if a number is an exponent of 2
  31646. * @param value defines the value to test
  31647. * @returns true if the value is an exponent of 2
  31648. */
  31649. static IsExponentOfTwo(value: number): boolean;
  31650. private static _tmpFloatArray;
  31651. /**
  31652. * Returns the nearest 32-bit single precision float representation of a Number
  31653. * @param value A Number. If the parameter is of a different type, it will get converted
  31654. * to a number or to NaN if it cannot be converted
  31655. * @returns number
  31656. */
  31657. static FloatRound(value: number): number;
  31658. /**
  31659. * Extracts the filename from a path
  31660. * @param path defines the path to use
  31661. * @returns the filename
  31662. */
  31663. static GetFilename(path: string): string;
  31664. /**
  31665. * Extracts the "folder" part of a path (everything before the filename).
  31666. * @param uri The URI to extract the info from
  31667. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31668. * @returns The "folder" part of the path
  31669. */
  31670. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31671. /**
  31672. * Extracts text content from a DOM element hierarchy
  31673. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31674. */
  31675. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31676. /**
  31677. * Convert an angle in radians to degrees
  31678. * @param angle defines the angle to convert
  31679. * @returns the angle in degrees
  31680. */
  31681. static ToDegrees(angle: number): number;
  31682. /**
  31683. * Convert an angle in degrees to radians
  31684. * @param angle defines the angle to convert
  31685. * @returns the angle in radians
  31686. */
  31687. static ToRadians(angle: number): number;
  31688. /**
  31689. * Encode a buffer to a base64 string
  31690. * @param buffer defines the buffer to encode
  31691. * @returns the encoded string
  31692. */
  31693. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31694. /**
  31695. * Returns an array if obj is not an array
  31696. * @param obj defines the object to evaluate as an array
  31697. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31698. * @returns either obj directly if obj is an array or a new array containing obj
  31699. */
  31700. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31701. /**
  31702. * Gets the pointer prefix to use
  31703. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31704. */
  31705. static GetPointerPrefix(): string;
  31706. /**
  31707. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31708. * @param url define the url we are trying
  31709. * @param element define the dom element where to configure the cors policy
  31710. */
  31711. static SetCorsBehavior(url: string | string[], element: {
  31712. crossOrigin: string | null;
  31713. }): void;
  31714. /**
  31715. * Removes unwanted characters from an url
  31716. * @param url defines the url to clean
  31717. * @returns the cleaned url
  31718. */
  31719. static CleanUrl(url: string): string;
  31720. /**
  31721. * Gets or sets a function used to pre-process url before using them to load assets
  31722. */
  31723. static PreprocessUrl: (url: string) => string;
  31724. /**
  31725. * Loads an image as an HTMLImageElement.
  31726. * @param input url string, ArrayBuffer, or Blob to load
  31727. * @param onLoad callback called when the image successfully loads
  31728. * @param onError callback called when the image fails to load
  31729. * @param offlineProvider offline provider for caching
  31730. * @returns the HTMLImageElement of the loaded image
  31731. */
  31732. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31733. /**
  31734. * Loads a file
  31735. * @param url url string, ArrayBuffer, or Blob to load
  31736. * @param onSuccess callback called when the file successfully loads
  31737. * @param onProgress callback called while file is loading (if the server supports this mode)
  31738. * @param offlineProvider defines the offline provider for caching
  31739. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31740. * @param onError callback called when the file fails to load
  31741. * @returns a file request object
  31742. */
  31743. 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;
  31744. /**
  31745. * Loads a file from a url
  31746. * @param url the file url to load
  31747. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31748. */
  31749. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31750. /**
  31751. * Load a script (identified by an url). When the url returns, the
  31752. * content of this file is added into a new script element, attached to the DOM (body element)
  31753. * @param scriptUrl defines the url of the script to laod
  31754. * @param onSuccess defines the callback called when the script is loaded
  31755. * @param onError defines the callback to call if an error occurs
  31756. * @param scriptId defines the id of the script element
  31757. */
  31758. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31759. /**
  31760. * Load an asynchronous script (identified by an url). When the url returns, the
  31761. * content of this file is added into a new script element, attached to the DOM (body element)
  31762. * @param scriptUrl defines the url of the script to laod
  31763. * @param scriptId defines the id of the script element
  31764. * @returns a promise request object
  31765. */
  31766. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31767. /**
  31768. * Loads a file from a blob
  31769. * @param fileToLoad defines the blob to use
  31770. * @param callback defines the callback to call when data is loaded
  31771. * @param progressCallback defines the callback to call during loading process
  31772. * @returns a file request object
  31773. */
  31774. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31775. /**
  31776. * Loads a file
  31777. * @param fileToLoad defines the file to load
  31778. * @param callback defines the callback to call when data is loaded
  31779. * @param progressCallBack defines the callback to call during loading process
  31780. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31781. * @returns a file request object
  31782. */
  31783. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31784. /**
  31785. * Creates a data url from a given string content
  31786. * @param content defines the content to convert
  31787. * @returns the new data url link
  31788. */
  31789. static FileAsURL(content: string): string;
  31790. /**
  31791. * Format the given number to a specific decimal format
  31792. * @param value defines the number to format
  31793. * @param decimals defines the number of decimals to use
  31794. * @returns the formatted string
  31795. */
  31796. static Format(value: number, decimals?: number): string;
  31797. /**
  31798. * Tries to copy an object by duplicating every property
  31799. * @param source defines the source object
  31800. * @param destination defines the target object
  31801. * @param doNotCopyList defines a list of properties to avoid
  31802. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31803. */
  31804. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31805. /**
  31806. * Gets a boolean indicating if the given object has no own property
  31807. * @param obj defines the object to test
  31808. * @returns true if object has no own property
  31809. */
  31810. static IsEmpty(obj: any): boolean;
  31811. /**
  31812. * Function used to register events at window level
  31813. * @param events defines the events to register
  31814. */
  31815. static RegisterTopRootEvents(events: {
  31816. name: string;
  31817. handler: Nullable<(e: FocusEvent) => any>;
  31818. }[]): void;
  31819. /**
  31820. * Function used to unregister events from window level
  31821. * @param events defines the events to unregister
  31822. */
  31823. static UnregisterTopRootEvents(events: {
  31824. name: string;
  31825. handler: Nullable<(e: FocusEvent) => any>;
  31826. }[]): void;
  31827. /**
  31828. * @ignore
  31829. */
  31830. static _ScreenshotCanvas: HTMLCanvasElement;
  31831. /**
  31832. * Dumps the current bound framebuffer
  31833. * @param width defines the rendering width
  31834. * @param height defines the rendering height
  31835. * @param engine defines the hosting engine
  31836. * @param successCallback defines the callback triggered once the data are available
  31837. * @param mimeType defines the mime type of the result
  31838. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31839. */
  31840. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31841. /**
  31842. * Converts the canvas data to blob.
  31843. * This acts as a polyfill for browsers not supporting the to blob function.
  31844. * @param canvas Defines the canvas to extract the data from
  31845. * @param successCallback Defines the callback triggered once the data are available
  31846. * @param mimeType Defines the mime type of the result
  31847. */
  31848. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31849. /**
  31850. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31851. * @param successCallback defines the callback triggered once the data are available
  31852. * @param mimeType defines the mime type of the result
  31853. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31854. */
  31855. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31856. /**
  31857. * Downloads a blob in the browser
  31858. * @param blob defines the blob to download
  31859. * @param fileName defines the name of the downloaded file
  31860. */
  31861. static Download(blob: Blob, fileName: string): void;
  31862. /**
  31863. * Captures a screenshot of the current rendering
  31864. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31865. * @param engine defines the rendering engine
  31866. * @param camera defines the source camera
  31867. * @param size This parameter can be set to a single number or to an object with the
  31868. * following (optional) properties: precision, width, height. If a single number is passed,
  31869. * it will be used for both width and height. If an object is passed, the screenshot size
  31870. * will be derived from the parameters. The precision property is a multiplier allowing
  31871. * rendering at a higher or lower resolution
  31872. * @param successCallback defines the callback receives a single parameter which contains the
  31873. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31874. * src parameter of an <img> to display it
  31875. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31876. * Check your browser for supported MIME types
  31877. */
  31878. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31879. /**
  31880. * Generates an image screenshot from the specified camera.
  31881. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31882. * @param engine The engine to use for rendering
  31883. * @param camera The camera to use for rendering
  31884. * @param size This parameter can be set to a single number or to an object with the
  31885. * following (optional) properties: precision, width, height. If a single number is passed,
  31886. * it will be used for both width and height. If an object is passed, the screenshot size
  31887. * will be derived from the parameters. The precision property is a multiplier allowing
  31888. * rendering at a higher or lower resolution
  31889. * @param successCallback The callback receives a single parameter which contains the
  31890. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31891. * src parameter of an <img> to display it
  31892. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31893. * Check your browser for supported MIME types
  31894. * @param samples Texture samples (default: 1)
  31895. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31896. * @param fileName A name for for the downloaded file.
  31897. */
  31898. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31899. /**
  31900. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31901. * Be aware Math.random() could cause collisions, but:
  31902. * "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"
  31903. * @returns a pseudo random id
  31904. */
  31905. static RandomId(): string;
  31906. /**
  31907. * Test if the given uri is a base64 string
  31908. * @param uri The uri to test
  31909. * @return True if the uri is a base64 string or false otherwise
  31910. */
  31911. static IsBase64(uri: string): boolean;
  31912. /**
  31913. * Decode the given base64 uri.
  31914. * @param uri The uri to decode
  31915. * @return The decoded base64 data.
  31916. */
  31917. static DecodeBase64(uri: string): ArrayBuffer;
  31918. /**
  31919. * Gets the absolute url.
  31920. * @param url the input url
  31921. * @return the absolute url
  31922. */
  31923. static GetAbsoluteUrl(url: string): string;
  31924. /**
  31925. * No log
  31926. */
  31927. static readonly NoneLogLevel: number;
  31928. /**
  31929. * Only message logs
  31930. */
  31931. static readonly MessageLogLevel: number;
  31932. /**
  31933. * Only warning logs
  31934. */
  31935. static readonly WarningLogLevel: number;
  31936. /**
  31937. * Only error logs
  31938. */
  31939. static readonly ErrorLogLevel: number;
  31940. /**
  31941. * All logs
  31942. */
  31943. static readonly AllLogLevel: number;
  31944. /**
  31945. * Gets a value indicating the number of loading errors
  31946. * @ignorenaming
  31947. */
  31948. static readonly errorsCount: number;
  31949. /**
  31950. * Callback called when a new log is added
  31951. */
  31952. static OnNewCacheEntry: (entry: string) => void;
  31953. /**
  31954. * Log a message to the console
  31955. * @param message defines the message to log
  31956. */
  31957. static Log(message: string): void;
  31958. /**
  31959. * Write a warning message to the console
  31960. * @param message defines the message to log
  31961. */
  31962. static Warn(message: string): void;
  31963. /**
  31964. * Write an error message to the console
  31965. * @param message defines the message to log
  31966. */
  31967. static Error(message: string): void;
  31968. /**
  31969. * Gets current log cache (list of logs)
  31970. */
  31971. static readonly LogCache: string;
  31972. /**
  31973. * Clears the log cache
  31974. */
  31975. static ClearLogCache(): void;
  31976. /**
  31977. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31978. */
  31979. static LogLevels: number;
  31980. /**
  31981. * Checks if the window object exists
  31982. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31983. */
  31984. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31985. /**
  31986. * No performance log
  31987. */
  31988. static readonly PerformanceNoneLogLevel: number;
  31989. /**
  31990. * Use user marks to log performance
  31991. */
  31992. static readonly PerformanceUserMarkLogLevel: number;
  31993. /**
  31994. * Log performance to the console
  31995. */
  31996. static readonly PerformanceConsoleLogLevel: number;
  31997. private static _performance;
  31998. /**
  31999. * Sets the current performance log level
  32000. */
  32001. static PerformanceLogLevel: number;
  32002. private static _StartPerformanceCounterDisabled;
  32003. private static _EndPerformanceCounterDisabled;
  32004. private static _StartUserMark;
  32005. private static _EndUserMark;
  32006. private static _StartPerformanceConsole;
  32007. private static _EndPerformanceConsole;
  32008. /**
  32009. * Starts a performance counter
  32010. */
  32011. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32012. /**
  32013. * Ends a specific performance coutner
  32014. */
  32015. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32016. /**
  32017. * Gets either window.performance.now() if supported or Date.now() else
  32018. */
  32019. static readonly Now: number;
  32020. /**
  32021. * This method will return the name of the class used to create the instance of the given object.
  32022. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32023. * @param object the object to get the class name from
  32024. * @param isType defines if the object is actually a type
  32025. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32026. */
  32027. static GetClassName(object: any, isType?: boolean): string;
  32028. /**
  32029. * Gets the first element of an array satisfying a given predicate
  32030. * @param array defines the array to browse
  32031. * @param predicate defines the predicate to use
  32032. * @returns null if not found or the element
  32033. */
  32034. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32035. /**
  32036. * This method will return the name of the full name of the class, including its owning module (if any).
  32037. * 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).
  32038. * @param object the object to get the class name from
  32039. * @param isType defines if the object is actually a type
  32040. * @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.
  32041. * @ignorenaming
  32042. */
  32043. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32044. /**
  32045. * Returns a promise that resolves after the given amount of time.
  32046. * @param delay Number of milliseconds to delay
  32047. * @returns Promise that resolves after the given amount of time
  32048. */
  32049. static DelayAsync(delay: number): Promise<void>;
  32050. }
  32051. /**
  32052. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32053. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32054. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32055. * @param name The name of the class, case should be preserved
  32056. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32057. */
  32058. export function className(name: string, module?: string): (target: Object) => void;
  32059. /**
  32060. * An implementation of a loop for asynchronous functions.
  32061. */
  32062. export class AsyncLoop {
  32063. /**
  32064. * Defines the number of iterations for the loop
  32065. */
  32066. iterations: number;
  32067. /**
  32068. * Defines the current index of the loop.
  32069. */
  32070. index: number;
  32071. private _done;
  32072. private _fn;
  32073. private _successCallback;
  32074. /**
  32075. * Constructor.
  32076. * @param iterations the number of iterations.
  32077. * @param func the function to run each iteration
  32078. * @param successCallback the callback that will be called upon succesful execution
  32079. * @param offset starting offset.
  32080. */
  32081. constructor(
  32082. /**
  32083. * Defines the number of iterations for the loop
  32084. */
  32085. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32086. /**
  32087. * Execute the next iteration. Must be called after the last iteration was finished.
  32088. */
  32089. executeNext(): void;
  32090. /**
  32091. * Break the loop and run the success callback.
  32092. */
  32093. breakLoop(): void;
  32094. /**
  32095. * Create and run an async loop.
  32096. * @param iterations the number of iterations.
  32097. * @param fn the function to run each iteration
  32098. * @param successCallback the callback that will be called upon succesful execution
  32099. * @param offset starting offset.
  32100. * @returns the created async loop object
  32101. */
  32102. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32103. /**
  32104. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32105. * @param iterations total number of iterations
  32106. * @param syncedIterations number of synchronous iterations in each async iteration.
  32107. * @param fn the function to call each iteration.
  32108. * @param callback a success call back that will be called when iterating stops.
  32109. * @param breakFunction a break condition (optional)
  32110. * @param timeout timeout settings for the setTimeout function. default - 0.
  32111. * @returns the created async loop object
  32112. */
  32113. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32114. }
  32115. }
  32116. declare module BABYLON {
  32117. /** @hidden */
  32118. export interface ICollisionCoordinator {
  32119. createCollider(): Collider;
  32120. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32121. init(scene: Scene): void;
  32122. }
  32123. /** @hidden */
  32124. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32125. private _scene;
  32126. private _scaledPosition;
  32127. private _scaledVelocity;
  32128. private _finalPosition;
  32129. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32130. createCollider(): Collider;
  32131. init(scene: Scene): void;
  32132. private _collideWithWorld;
  32133. }
  32134. }
  32135. declare module BABYLON {
  32136. /**
  32137. * Class used to manage all inputs for the scene.
  32138. */
  32139. export class InputManager {
  32140. /** The distance in pixel that you have to move to prevent some events */
  32141. static DragMovementThreshold: number;
  32142. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32143. static LongPressDelay: number;
  32144. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32145. static DoubleClickDelay: number;
  32146. /** If you need to check double click without raising a single click at first click, enable this flag */
  32147. static ExclusiveDoubleClickMode: boolean;
  32148. private _wheelEventName;
  32149. private _onPointerMove;
  32150. private _onPointerDown;
  32151. private _onPointerUp;
  32152. private _initClickEvent;
  32153. private _initActionManager;
  32154. private _delayedSimpleClick;
  32155. private _delayedSimpleClickTimeout;
  32156. private _previousDelayedSimpleClickTimeout;
  32157. private _meshPickProceed;
  32158. private _previousButtonPressed;
  32159. private _currentPickResult;
  32160. private _previousPickResult;
  32161. private _totalPointersPressed;
  32162. private _doubleClickOccured;
  32163. private _pointerOverMesh;
  32164. private _pickedDownMesh;
  32165. private _pickedUpMesh;
  32166. private _pointerX;
  32167. private _pointerY;
  32168. private _unTranslatedPointerX;
  32169. private _unTranslatedPointerY;
  32170. private _startingPointerPosition;
  32171. private _previousStartingPointerPosition;
  32172. private _startingPointerTime;
  32173. private _previousStartingPointerTime;
  32174. private _pointerCaptures;
  32175. private _onKeyDown;
  32176. private _onKeyUp;
  32177. private _onCanvasFocusObserver;
  32178. private _onCanvasBlurObserver;
  32179. private _scene;
  32180. /**
  32181. * Creates a new InputManager
  32182. * @param scene defines the hosting scene
  32183. */
  32184. constructor(scene: Scene);
  32185. /**
  32186. * Gets the mesh that is currently under the pointer
  32187. */
  32188. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32189. /**
  32190. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32191. */
  32192. readonly unTranslatedPointer: Vector2;
  32193. /**
  32194. * Gets or sets the current on-screen X position of the pointer
  32195. */
  32196. pointerX: number;
  32197. /**
  32198. * Gets or sets the current on-screen Y position of the pointer
  32199. */
  32200. pointerY: number;
  32201. private _updatePointerPosition;
  32202. private _processPointerMove;
  32203. private _setRayOnPointerInfo;
  32204. private _checkPrePointerObservable;
  32205. /**
  32206. * Use this method to simulate a pointer move on a mesh
  32207. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32208. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32209. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32210. */
  32211. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32212. /**
  32213. * Use this method to simulate a pointer down on a mesh
  32214. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32215. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32216. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32217. */
  32218. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32219. private _processPointerDown;
  32220. /** @hidden */
  32221. _isPointerSwiping(): boolean;
  32222. /**
  32223. * Use this method to simulate a pointer up on a mesh
  32224. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32225. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32226. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32227. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32228. */
  32229. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32230. private _processPointerUp;
  32231. /**
  32232. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32233. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32234. * @returns true if the pointer was captured
  32235. */
  32236. isPointerCaptured(pointerId?: number): boolean;
  32237. /**
  32238. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32239. * @param attachUp defines if you want to attach events to pointerup
  32240. * @param attachDown defines if you want to attach events to pointerdown
  32241. * @param attachMove defines if you want to attach events to pointermove
  32242. */
  32243. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32244. /**
  32245. * Detaches all event handlers
  32246. */
  32247. detachControl(): void;
  32248. /**
  32249. * Force the value of meshUnderPointer
  32250. * @param mesh defines the mesh to use
  32251. */
  32252. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32253. /**
  32254. * Gets the mesh under the pointer
  32255. * @returns a Mesh or null if no mesh is under the pointer
  32256. */
  32257. getPointerOverMesh(): Nullable<AbstractMesh>;
  32258. }
  32259. }
  32260. declare module BABYLON {
  32261. /**
  32262. * This class defines the direct association between an animation and a target
  32263. */
  32264. export class TargetedAnimation {
  32265. /**
  32266. * Animation to perform
  32267. */
  32268. animation: Animation;
  32269. /**
  32270. * Target to animate
  32271. */
  32272. target: any;
  32273. /**
  32274. * Serialize the object
  32275. * @returns the JSON object representing the current entity
  32276. */
  32277. serialize(): any;
  32278. }
  32279. /**
  32280. * Use this class to create coordinated animations on multiple targets
  32281. */
  32282. export class AnimationGroup implements IDisposable {
  32283. /** The name of the animation group */
  32284. name: string;
  32285. private _scene;
  32286. private _targetedAnimations;
  32287. private _animatables;
  32288. private _from;
  32289. private _to;
  32290. private _isStarted;
  32291. private _isPaused;
  32292. private _speedRatio;
  32293. private _loopAnimation;
  32294. /**
  32295. * Gets or sets the unique id of the node
  32296. */
  32297. uniqueId: number;
  32298. /**
  32299. * This observable will notify when one animation have ended
  32300. */
  32301. onAnimationEndObservable: Observable<TargetedAnimation>;
  32302. /**
  32303. * Observer raised when one animation loops
  32304. */
  32305. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32306. /**
  32307. * This observable will notify when all animations have ended.
  32308. */
  32309. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32310. /**
  32311. * This observable will notify when all animations have paused.
  32312. */
  32313. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32314. /**
  32315. * This observable will notify when all animations are playing.
  32316. */
  32317. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32318. /**
  32319. * Gets the first frame
  32320. */
  32321. readonly from: number;
  32322. /**
  32323. * Gets the last frame
  32324. */
  32325. readonly to: number;
  32326. /**
  32327. * Define if the animations are started
  32328. */
  32329. readonly isStarted: boolean;
  32330. /**
  32331. * Gets a value indicating that the current group is playing
  32332. */
  32333. readonly isPlaying: boolean;
  32334. /**
  32335. * Gets or sets the speed ratio to use for all animations
  32336. */
  32337. /**
  32338. * Gets or sets the speed ratio to use for all animations
  32339. */
  32340. speedRatio: number;
  32341. /**
  32342. * Gets or sets if all animations should loop or not
  32343. */
  32344. loopAnimation: boolean;
  32345. /**
  32346. * Gets the targeted animations for this animation group
  32347. */
  32348. readonly targetedAnimations: Array<TargetedAnimation>;
  32349. /**
  32350. * returning the list of animatables controlled by this animation group.
  32351. */
  32352. readonly animatables: Array<Animatable>;
  32353. /**
  32354. * Instantiates a new Animation Group.
  32355. * This helps managing several animations at once.
  32356. * @see http://doc.babylonjs.com/how_to/group
  32357. * @param name Defines the name of the group
  32358. * @param scene Defines the scene the group belongs to
  32359. */
  32360. constructor(
  32361. /** The name of the animation group */
  32362. name: string, scene?: Nullable<Scene>);
  32363. /**
  32364. * Add an animation (with its target) in the group
  32365. * @param animation defines the animation we want to add
  32366. * @param target defines the target of the animation
  32367. * @returns the TargetedAnimation object
  32368. */
  32369. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32370. /**
  32371. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32372. * It can add constant keys at begin or end
  32373. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32374. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32375. * @returns the animation group
  32376. */
  32377. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32378. /**
  32379. * Start all animations on given targets
  32380. * @param loop defines if animations must loop
  32381. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32382. * @param from defines the from key (optional)
  32383. * @param to defines the to key (optional)
  32384. * @returns the current animation group
  32385. */
  32386. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32387. /**
  32388. * Pause all animations
  32389. * @returns the animation group
  32390. */
  32391. pause(): AnimationGroup;
  32392. /**
  32393. * Play all animations to initial state
  32394. * This function will start() the animations if they were not started or will restart() them if they were paused
  32395. * @param loop defines if animations must loop
  32396. * @returns the animation group
  32397. */
  32398. play(loop?: boolean): AnimationGroup;
  32399. /**
  32400. * Reset all animations to initial state
  32401. * @returns the animation group
  32402. */
  32403. reset(): AnimationGroup;
  32404. /**
  32405. * Restart animations from key 0
  32406. * @returns the animation group
  32407. */
  32408. restart(): AnimationGroup;
  32409. /**
  32410. * Stop all animations
  32411. * @returns the animation group
  32412. */
  32413. stop(): AnimationGroup;
  32414. /**
  32415. * Set animation weight for all animatables
  32416. * @param weight defines the weight to use
  32417. * @return the animationGroup
  32418. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32419. */
  32420. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32421. /**
  32422. * Synchronize and normalize all animatables with a source animatable
  32423. * @param root defines the root animatable to synchronize with
  32424. * @return the animationGroup
  32425. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32426. */
  32427. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32428. /**
  32429. * Goes to a specific frame in this animation group
  32430. * @param frame the frame number to go to
  32431. * @return the animationGroup
  32432. */
  32433. goToFrame(frame: number): AnimationGroup;
  32434. /**
  32435. * Dispose all associated resources
  32436. */
  32437. dispose(): void;
  32438. private _checkAnimationGroupEnded;
  32439. /**
  32440. * Clone the current animation group and returns a copy
  32441. * @param newName defines the name of the new group
  32442. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32443. * @returns the new aniamtion group
  32444. */
  32445. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32446. /**
  32447. * Serializes the animationGroup to an object
  32448. * @returns Serialized object
  32449. */
  32450. serialize(): any;
  32451. /**
  32452. * Returns a new AnimationGroup object parsed from the source provided.
  32453. * @param parsedAnimationGroup defines the source
  32454. * @param scene defines the scene that will receive the animationGroup
  32455. * @returns a new AnimationGroup
  32456. */
  32457. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32458. /**
  32459. * Returns the string "AnimationGroup"
  32460. * @returns "AnimationGroup"
  32461. */
  32462. getClassName(): string;
  32463. /**
  32464. * Creates a detailled string about the object
  32465. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32466. * @returns a string representing the object
  32467. */
  32468. toString(fullDetails?: boolean): string;
  32469. }
  32470. }
  32471. declare module BABYLON {
  32472. /**
  32473. * Define an interface for all classes that will hold resources
  32474. */
  32475. export interface IDisposable {
  32476. /**
  32477. * Releases all held resources
  32478. */
  32479. dispose(): void;
  32480. }
  32481. /** Interface defining initialization parameters for Scene class */
  32482. export interface SceneOptions {
  32483. /**
  32484. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32485. * It will improve performance when the number of geometries becomes important.
  32486. */
  32487. useGeometryUniqueIdsMap?: boolean;
  32488. /**
  32489. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32490. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32491. */
  32492. useMaterialMeshMap?: boolean;
  32493. /**
  32494. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32495. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32496. */
  32497. useClonedMeshhMap?: boolean;
  32498. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32499. virtual?: boolean;
  32500. }
  32501. /**
  32502. * Represents a scene to be rendered by the engine.
  32503. * @see http://doc.babylonjs.com/features/scene
  32504. */
  32505. export class Scene extends AbstractScene implements IAnimatable {
  32506. private static _uniqueIdCounter;
  32507. /** The fog is deactivated */
  32508. static readonly FOGMODE_NONE: number;
  32509. /** The fog density is following an exponential function */
  32510. static readonly FOGMODE_EXP: number;
  32511. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32512. static readonly FOGMODE_EXP2: number;
  32513. /** The fog density is following a linear function. */
  32514. static readonly FOGMODE_LINEAR: number;
  32515. /**
  32516. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32517. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32518. */
  32519. static MinDeltaTime: number;
  32520. /**
  32521. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32522. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32523. */
  32524. static MaxDeltaTime: number;
  32525. /**
  32526. * Factory used to create the default material.
  32527. * @param name The name of the material to create
  32528. * @param scene The scene to create the material for
  32529. * @returns The default material
  32530. */
  32531. static DefaultMaterialFactory(scene: Scene): Material;
  32532. /**
  32533. * Factory used to create the a collision coordinator.
  32534. * @returns The collision coordinator
  32535. */
  32536. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32537. /** @hidden */
  32538. _inputManager: InputManager;
  32539. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32540. cameraToUseForPointers: Nullable<Camera>;
  32541. /** @hidden */
  32542. readonly _isScene: boolean;
  32543. /**
  32544. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32545. */
  32546. autoClear: boolean;
  32547. /**
  32548. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32549. */
  32550. autoClearDepthAndStencil: boolean;
  32551. /**
  32552. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32553. */
  32554. clearColor: Color4;
  32555. /**
  32556. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32557. */
  32558. ambientColor: Color3;
  32559. /**
  32560. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32561. * It should only be one of the following (if not the default embedded one):
  32562. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32563. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32564. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32565. * The material properties need to be setup according to the type of texture in use.
  32566. */
  32567. environmentBRDFTexture: BaseTexture;
  32568. /** @hidden */
  32569. protected _environmentTexture: Nullable<BaseTexture>;
  32570. /**
  32571. * Texture used in all pbr material as the reflection texture.
  32572. * As in the majority of the scene they are the same (exception for multi room and so on),
  32573. * this is easier to reference from here than from all the materials.
  32574. */
  32575. /**
  32576. * Texture used in all pbr material as the reflection texture.
  32577. * As in the majority of the scene they are the same (exception for multi room and so on),
  32578. * this is easier to set here than in all the materials.
  32579. */
  32580. environmentTexture: Nullable<BaseTexture>;
  32581. /** @hidden */
  32582. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32583. /**
  32584. * Default image processing configuration used either in the rendering
  32585. * Forward main pass or through the imageProcessingPostProcess if present.
  32586. * As in the majority of the scene they are the same (exception for multi camera),
  32587. * this is easier to reference from here than from all the materials and post process.
  32588. *
  32589. * No setter as we it is a shared configuration, you can set the values instead.
  32590. */
  32591. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32592. private _forceWireframe;
  32593. /**
  32594. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32595. */
  32596. forceWireframe: boolean;
  32597. private _forcePointsCloud;
  32598. /**
  32599. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32600. */
  32601. forcePointsCloud: boolean;
  32602. /**
  32603. * Gets or sets the active clipplane 1
  32604. */
  32605. clipPlane: Nullable<Plane>;
  32606. /**
  32607. * Gets or sets the active clipplane 2
  32608. */
  32609. clipPlane2: Nullable<Plane>;
  32610. /**
  32611. * Gets or sets the active clipplane 3
  32612. */
  32613. clipPlane3: Nullable<Plane>;
  32614. /**
  32615. * Gets or sets the active clipplane 4
  32616. */
  32617. clipPlane4: Nullable<Plane>;
  32618. /**
  32619. * Gets or sets a boolean indicating if animations are enabled
  32620. */
  32621. animationsEnabled: boolean;
  32622. private _animationPropertiesOverride;
  32623. /**
  32624. * Gets or sets the animation properties override
  32625. */
  32626. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32627. /**
  32628. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32629. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32630. */
  32631. useConstantAnimationDeltaTime: boolean;
  32632. /**
  32633. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32634. * Please note that it requires to run a ray cast through the scene on every frame
  32635. */
  32636. constantlyUpdateMeshUnderPointer: boolean;
  32637. /**
  32638. * Defines the HTML cursor to use when hovering over interactive elements
  32639. */
  32640. hoverCursor: string;
  32641. /**
  32642. * Defines the HTML default cursor to use (empty by default)
  32643. */
  32644. defaultCursor: string;
  32645. /**
  32646. * This is used to call preventDefault() on pointer down
  32647. * in order to block unwanted artifacts like system double clicks
  32648. */
  32649. preventDefaultOnPointerDown: boolean;
  32650. /**
  32651. * This is used to call preventDefault() on pointer up
  32652. * in order to block unwanted artifacts like system double clicks
  32653. */
  32654. preventDefaultOnPointerUp: boolean;
  32655. /**
  32656. * Gets or sets user defined metadata
  32657. */
  32658. metadata: any;
  32659. /**
  32660. * For internal use only. Please do not use.
  32661. */
  32662. reservedDataStore: any;
  32663. /**
  32664. * Gets the name of the plugin used to load this scene (null by default)
  32665. */
  32666. loadingPluginName: string;
  32667. /**
  32668. * Use this array to add regular expressions used to disable offline support for specific urls
  32669. */
  32670. disableOfflineSupportExceptionRules: RegExp[];
  32671. /**
  32672. * An event triggered when the scene is disposed.
  32673. */
  32674. onDisposeObservable: Observable<Scene>;
  32675. private _onDisposeObserver;
  32676. /** Sets a function to be executed when this scene is disposed. */
  32677. onDispose: () => void;
  32678. /**
  32679. * An event triggered before rendering the scene (right after animations and physics)
  32680. */
  32681. onBeforeRenderObservable: Observable<Scene>;
  32682. private _onBeforeRenderObserver;
  32683. /** Sets a function to be executed before rendering this scene */
  32684. beforeRender: Nullable<() => void>;
  32685. /**
  32686. * An event triggered after rendering the scene
  32687. */
  32688. onAfterRenderObservable: Observable<Scene>;
  32689. /**
  32690. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32691. */
  32692. onAfterRenderCameraObservable: Observable<Camera>;
  32693. private _onAfterRenderObserver;
  32694. /** Sets a function to be executed after rendering this scene */
  32695. afterRender: Nullable<() => void>;
  32696. /**
  32697. * An event triggered before animating the scene
  32698. */
  32699. onBeforeAnimationsObservable: Observable<Scene>;
  32700. /**
  32701. * An event triggered after animations processing
  32702. */
  32703. onAfterAnimationsObservable: Observable<Scene>;
  32704. /**
  32705. * An event triggered before draw calls are ready to be sent
  32706. */
  32707. onBeforeDrawPhaseObservable: Observable<Scene>;
  32708. /**
  32709. * An event triggered after draw calls have been sent
  32710. */
  32711. onAfterDrawPhaseObservable: Observable<Scene>;
  32712. /**
  32713. * An event triggered when the scene is ready
  32714. */
  32715. onReadyObservable: Observable<Scene>;
  32716. /**
  32717. * An event triggered before rendering a camera
  32718. */
  32719. onBeforeCameraRenderObservable: Observable<Camera>;
  32720. private _onBeforeCameraRenderObserver;
  32721. /** Sets a function to be executed before rendering a camera*/
  32722. beforeCameraRender: () => void;
  32723. /**
  32724. * An event triggered after rendering a camera
  32725. */
  32726. onAfterCameraRenderObservable: Observable<Camera>;
  32727. private _onAfterCameraRenderObserver;
  32728. /** Sets a function to be executed after rendering a camera*/
  32729. afterCameraRender: () => void;
  32730. /**
  32731. * An event triggered when active meshes evaluation is about to start
  32732. */
  32733. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32734. /**
  32735. * An event triggered when active meshes evaluation is done
  32736. */
  32737. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32738. /**
  32739. * An event triggered when particles rendering is about to start
  32740. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32741. */
  32742. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32743. /**
  32744. * An event triggered when particles rendering is done
  32745. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32746. */
  32747. onAfterParticlesRenderingObservable: Observable<Scene>;
  32748. /**
  32749. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32750. */
  32751. onDataLoadedObservable: Observable<Scene>;
  32752. /**
  32753. * An event triggered when a camera is created
  32754. */
  32755. onNewCameraAddedObservable: Observable<Camera>;
  32756. /**
  32757. * An event triggered when a camera is removed
  32758. */
  32759. onCameraRemovedObservable: Observable<Camera>;
  32760. /**
  32761. * An event triggered when a light is created
  32762. */
  32763. onNewLightAddedObservable: Observable<Light>;
  32764. /**
  32765. * An event triggered when a light is removed
  32766. */
  32767. onLightRemovedObservable: Observable<Light>;
  32768. /**
  32769. * An event triggered when a geometry is created
  32770. */
  32771. onNewGeometryAddedObservable: Observable<Geometry>;
  32772. /**
  32773. * An event triggered when a geometry is removed
  32774. */
  32775. onGeometryRemovedObservable: Observable<Geometry>;
  32776. /**
  32777. * An event triggered when a transform node is created
  32778. */
  32779. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32780. /**
  32781. * An event triggered when a transform node is removed
  32782. */
  32783. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32784. /**
  32785. * An event triggered when a mesh is created
  32786. */
  32787. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32788. /**
  32789. * An event triggered when a mesh is removed
  32790. */
  32791. onMeshRemovedObservable: Observable<AbstractMesh>;
  32792. /**
  32793. * An event triggered when a skeleton is created
  32794. */
  32795. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32796. /**
  32797. * An event triggered when a skeleton is removed
  32798. */
  32799. onSkeletonRemovedObservable: Observable<Skeleton>;
  32800. /**
  32801. * An event triggered when a material is created
  32802. */
  32803. onNewMaterialAddedObservable: Observable<Material>;
  32804. /**
  32805. * An event triggered when a material is removed
  32806. */
  32807. onMaterialRemovedObservable: Observable<Material>;
  32808. /**
  32809. * An event triggered when a texture is created
  32810. */
  32811. onNewTextureAddedObservable: Observable<BaseTexture>;
  32812. /**
  32813. * An event triggered when a texture is removed
  32814. */
  32815. onTextureRemovedObservable: Observable<BaseTexture>;
  32816. /**
  32817. * An event triggered when render targets are about to be rendered
  32818. * Can happen multiple times per frame.
  32819. */
  32820. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32821. /**
  32822. * An event triggered when render targets were rendered.
  32823. * Can happen multiple times per frame.
  32824. */
  32825. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32826. /**
  32827. * An event triggered before calculating deterministic simulation step
  32828. */
  32829. onBeforeStepObservable: Observable<Scene>;
  32830. /**
  32831. * An event triggered after calculating deterministic simulation step
  32832. */
  32833. onAfterStepObservable: Observable<Scene>;
  32834. /**
  32835. * An event triggered when the activeCamera property is updated
  32836. */
  32837. onActiveCameraChanged: Observable<Scene>;
  32838. /**
  32839. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32840. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32841. * 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)
  32842. */
  32843. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32844. /**
  32845. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32846. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32847. * 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)
  32848. */
  32849. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32850. /**
  32851. * This Observable will when a mesh has been imported into the scene.
  32852. */
  32853. onMeshImportedObservable: Observable<AbstractMesh>;
  32854. /**
  32855. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32856. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32857. */
  32858. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32859. /** @hidden */
  32860. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32861. /**
  32862. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32863. */
  32864. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32865. /**
  32866. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32867. */
  32868. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32869. /**
  32870. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32871. */
  32872. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32873. /** Callback called when a pointer move is detected */
  32874. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32875. /** Callback called when a pointer down is detected */
  32876. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32877. /** Callback called when a pointer up is detected */
  32878. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32879. /** Callback called when a pointer pick is detected */
  32880. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32881. /**
  32882. * 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).
  32883. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32884. */
  32885. onPrePointerObservable: Observable<PointerInfoPre>;
  32886. /**
  32887. * Observable event triggered each time an input event is received from the rendering canvas
  32888. */
  32889. onPointerObservable: Observable<PointerInfo>;
  32890. /**
  32891. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32892. */
  32893. readonly unTranslatedPointer: Vector2;
  32894. /**
  32895. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32896. */
  32897. static DragMovementThreshold: number;
  32898. /**
  32899. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32900. */
  32901. static LongPressDelay: number;
  32902. /**
  32903. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32904. */
  32905. static DoubleClickDelay: number;
  32906. /** If you need to check double click without raising a single click at first click, enable this flag */
  32907. static ExclusiveDoubleClickMode: boolean;
  32908. /** @hidden */
  32909. _mirroredCameraPosition: Nullable<Vector3>;
  32910. /**
  32911. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32912. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32913. */
  32914. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32915. /**
  32916. * Observable event triggered each time an keyboard event is received from the hosting window
  32917. */
  32918. onKeyboardObservable: Observable<KeyboardInfo>;
  32919. private _useRightHandedSystem;
  32920. /**
  32921. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32922. */
  32923. useRightHandedSystem: boolean;
  32924. private _timeAccumulator;
  32925. private _currentStepId;
  32926. private _currentInternalStep;
  32927. /**
  32928. * Sets the step Id used by deterministic lock step
  32929. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32930. * @param newStepId defines the step Id
  32931. */
  32932. setStepId(newStepId: number): void;
  32933. /**
  32934. * Gets the step Id used by deterministic lock step
  32935. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32936. * @returns the step Id
  32937. */
  32938. getStepId(): number;
  32939. /**
  32940. * Gets the internal step used by deterministic lock step
  32941. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32942. * @returns the internal step
  32943. */
  32944. getInternalStep(): number;
  32945. private _fogEnabled;
  32946. /**
  32947. * Gets or sets a boolean indicating if fog is enabled on this scene
  32948. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32949. * (Default is true)
  32950. */
  32951. fogEnabled: boolean;
  32952. private _fogMode;
  32953. /**
  32954. * Gets or sets the fog mode to use
  32955. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32956. * | mode | value |
  32957. * | --- | --- |
  32958. * | FOGMODE_NONE | 0 |
  32959. * | FOGMODE_EXP | 1 |
  32960. * | FOGMODE_EXP2 | 2 |
  32961. * | FOGMODE_LINEAR | 3 |
  32962. */
  32963. fogMode: number;
  32964. /**
  32965. * Gets or sets the fog color to use
  32966. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32967. * (Default is Color3(0.2, 0.2, 0.3))
  32968. */
  32969. fogColor: Color3;
  32970. /**
  32971. * Gets or sets the fog density to use
  32972. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32973. * (Default is 0.1)
  32974. */
  32975. fogDensity: number;
  32976. /**
  32977. * Gets or sets the fog start distance to use
  32978. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32979. * (Default is 0)
  32980. */
  32981. fogStart: number;
  32982. /**
  32983. * Gets or sets the fog end distance to use
  32984. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32985. * (Default is 1000)
  32986. */
  32987. fogEnd: number;
  32988. private _shadowsEnabled;
  32989. /**
  32990. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32991. */
  32992. shadowsEnabled: boolean;
  32993. private _lightsEnabled;
  32994. /**
  32995. * Gets or sets a boolean indicating if lights are enabled on this scene
  32996. */
  32997. lightsEnabled: boolean;
  32998. /** All of the active cameras added to this scene. */
  32999. activeCameras: Camera[];
  33000. /** @hidden */
  33001. _activeCamera: Nullable<Camera>;
  33002. /** Gets or sets the current active camera */
  33003. activeCamera: Nullable<Camera>;
  33004. private _defaultMaterial;
  33005. /** The default material used on meshes when no material is affected */
  33006. /** The default material used on meshes when no material is affected */
  33007. defaultMaterial: Material;
  33008. private _texturesEnabled;
  33009. /**
  33010. * Gets or sets a boolean indicating if textures are enabled on this scene
  33011. */
  33012. texturesEnabled: boolean;
  33013. /**
  33014. * Gets or sets a boolean indicating if particles are enabled on this scene
  33015. */
  33016. particlesEnabled: boolean;
  33017. /**
  33018. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33019. */
  33020. spritesEnabled: boolean;
  33021. private _skeletonsEnabled;
  33022. /**
  33023. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33024. */
  33025. skeletonsEnabled: boolean;
  33026. /**
  33027. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33028. */
  33029. lensFlaresEnabled: boolean;
  33030. /**
  33031. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33032. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33033. */
  33034. collisionsEnabled: boolean;
  33035. private _collisionCoordinator;
  33036. /** @hidden */
  33037. readonly collisionCoordinator: ICollisionCoordinator;
  33038. /**
  33039. * Defines the gravity applied to this scene (used only for collisions)
  33040. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33041. */
  33042. gravity: Vector3;
  33043. /**
  33044. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33045. */
  33046. postProcessesEnabled: boolean;
  33047. /**
  33048. * The list of postprocesses added to the scene
  33049. */
  33050. postProcesses: PostProcess[];
  33051. /**
  33052. * Gets the current postprocess manager
  33053. */
  33054. postProcessManager: PostProcessManager;
  33055. /**
  33056. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33057. */
  33058. renderTargetsEnabled: boolean;
  33059. /**
  33060. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33061. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33062. */
  33063. dumpNextRenderTargets: boolean;
  33064. /**
  33065. * The list of user defined render targets added to the scene
  33066. */
  33067. customRenderTargets: RenderTargetTexture[];
  33068. /**
  33069. * Defines if texture loading must be delayed
  33070. * If true, textures will only be loaded when they need to be rendered
  33071. */
  33072. useDelayedTextureLoading: boolean;
  33073. /**
  33074. * Gets the list of meshes imported to the scene through SceneLoader
  33075. */
  33076. importedMeshesFiles: String[];
  33077. /**
  33078. * Gets or sets a boolean indicating if probes are enabled on this scene
  33079. */
  33080. probesEnabled: boolean;
  33081. /**
  33082. * Gets or sets the current offline provider to use to store scene data
  33083. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33084. */
  33085. offlineProvider: IOfflineProvider;
  33086. /**
  33087. * Gets or sets the action manager associated with the scene
  33088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33089. */
  33090. actionManager: AbstractActionManager;
  33091. private _meshesForIntersections;
  33092. /**
  33093. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33094. */
  33095. proceduralTexturesEnabled: boolean;
  33096. private _engine;
  33097. private _totalVertices;
  33098. /** @hidden */
  33099. _activeIndices: PerfCounter;
  33100. /** @hidden */
  33101. _activeParticles: PerfCounter;
  33102. /** @hidden */
  33103. _activeBones: PerfCounter;
  33104. private _animationRatio;
  33105. /** @hidden */
  33106. _animationTimeLast: number;
  33107. /** @hidden */
  33108. _animationTime: number;
  33109. /**
  33110. * Gets or sets a general scale for animation speed
  33111. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33112. */
  33113. animationTimeScale: number;
  33114. /** @hidden */
  33115. _cachedMaterial: Nullable<Material>;
  33116. /** @hidden */
  33117. _cachedEffect: Nullable<Effect>;
  33118. /** @hidden */
  33119. _cachedVisibility: Nullable<number>;
  33120. private _renderId;
  33121. private _frameId;
  33122. private _executeWhenReadyTimeoutId;
  33123. private _intermediateRendering;
  33124. private _viewUpdateFlag;
  33125. private _projectionUpdateFlag;
  33126. /** @hidden */
  33127. _toBeDisposed: Nullable<IDisposable>[];
  33128. private _activeRequests;
  33129. /** @hidden */
  33130. _pendingData: any[];
  33131. private _isDisposed;
  33132. /**
  33133. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33134. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33135. */
  33136. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33137. private _activeMeshes;
  33138. private _processedMaterials;
  33139. private _renderTargets;
  33140. /** @hidden */
  33141. _activeParticleSystems: SmartArray<IParticleSystem>;
  33142. private _activeSkeletons;
  33143. private _softwareSkinnedMeshes;
  33144. private _renderingManager;
  33145. /** @hidden */
  33146. _activeAnimatables: Animatable[];
  33147. private _transformMatrix;
  33148. private _sceneUbo;
  33149. /** @hidden */
  33150. _viewMatrix: Matrix;
  33151. private _projectionMatrix;
  33152. /** @hidden */
  33153. _forcedViewPosition: Nullable<Vector3>;
  33154. /** @hidden */
  33155. _frustumPlanes: Plane[];
  33156. /**
  33157. * Gets the list of frustum planes (built from the active camera)
  33158. */
  33159. readonly frustumPlanes: Plane[];
  33160. /**
  33161. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33162. * This is useful if there are more lights that the maximum simulteanous authorized
  33163. */
  33164. requireLightSorting: boolean;
  33165. /** @hidden */
  33166. readonly useMaterialMeshMap: boolean;
  33167. /** @hidden */
  33168. readonly useClonedMeshhMap: boolean;
  33169. private _externalData;
  33170. private _uid;
  33171. /**
  33172. * @hidden
  33173. * Backing store of defined scene components.
  33174. */
  33175. _components: ISceneComponent[];
  33176. /**
  33177. * @hidden
  33178. * Backing store of defined scene components.
  33179. */
  33180. _serializableComponents: ISceneSerializableComponent[];
  33181. /**
  33182. * List of components to register on the next registration step.
  33183. */
  33184. private _transientComponents;
  33185. /**
  33186. * Registers the transient components if needed.
  33187. */
  33188. private _registerTransientComponents;
  33189. /**
  33190. * @hidden
  33191. * Add a component to the scene.
  33192. * Note that the ccomponent could be registered on th next frame if this is called after
  33193. * the register component stage.
  33194. * @param component Defines the component to add to the scene
  33195. */
  33196. _addComponent(component: ISceneComponent): void;
  33197. /**
  33198. * @hidden
  33199. * Gets a component from the scene.
  33200. * @param name defines the name of the component to retrieve
  33201. * @returns the component or null if not present
  33202. */
  33203. _getComponent(name: string): Nullable<ISceneComponent>;
  33204. /**
  33205. * @hidden
  33206. * Defines the actions happening before camera updates.
  33207. */
  33208. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33209. /**
  33210. * @hidden
  33211. * Defines the actions happening before clear the canvas.
  33212. */
  33213. _beforeClearStage: Stage<SimpleStageAction>;
  33214. /**
  33215. * @hidden
  33216. * Defines the actions when collecting render targets for the frame.
  33217. */
  33218. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33219. /**
  33220. * @hidden
  33221. * Defines the actions happening for one camera in the frame.
  33222. */
  33223. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33224. /**
  33225. * @hidden
  33226. * Defines the actions happening during the per mesh ready checks.
  33227. */
  33228. _isReadyForMeshStage: Stage<MeshStageAction>;
  33229. /**
  33230. * @hidden
  33231. * Defines the actions happening before evaluate active mesh checks.
  33232. */
  33233. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33234. /**
  33235. * @hidden
  33236. * Defines the actions happening during the evaluate sub mesh checks.
  33237. */
  33238. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33239. /**
  33240. * @hidden
  33241. * Defines the actions happening during the active mesh stage.
  33242. */
  33243. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33244. /**
  33245. * @hidden
  33246. * Defines the actions happening during the per camera render target step.
  33247. */
  33248. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33249. /**
  33250. * @hidden
  33251. * Defines the actions happening just before the active camera is drawing.
  33252. */
  33253. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33254. /**
  33255. * @hidden
  33256. * Defines the actions happening just before a render target is drawing.
  33257. */
  33258. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33259. /**
  33260. * @hidden
  33261. * Defines the actions happening just before a rendering group is drawing.
  33262. */
  33263. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33264. /**
  33265. * @hidden
  33266. * Defines the actions happening just before a mesh is drawing.
  33267. */
  33268. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33269. /**
  33270. * @hidden
  33271. * Defines the actions happening just after a mesh has been drawn.
  33272. */
  33273. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33274. /**
  33275. * @hidden
  33276. * Defines the actions happening just after a rendering group has been drawn.
  33277. */
  33278. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33279. /**
  33280. * @hidden
  33281. * Defines the actions happening just after the active camera has been drawn.
  33282. */
  33283. _afterCameraDrawStage: Stage<CameraStageAction>;
  33284. /**
  33285. * @hidden
  33286. * Defines the actions happening just after a render target has been drawn.
  33287. */
  33288. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33289. /**
  33290. * @hidden
  33291. * Defines the actions happening just after rendering all cameras and computing intersections.
  33292. */
  33293. _afterRenderStage: Stage<SimpleStageAction>;
  33294. /**
  33295. * @hidden
  33296. * Defines the actions happening when a pointer move event happens.
  33297. */
  33298. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33299. /**
  33300. * @hidden
  33301. * Defines the actions happening when a pointer down event happens.
  33302. */
  33303. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33304. /**
  33305. * @hidden
  33306. * Defines the actions happening when a pointer up event happens.
  33307. */
  33308. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33309. /**
  33310. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33311. */
  33312. private geometriesByUniqueId;
  33313. /**
  33314. * Creates a new Scene
  33315. * @param engine defines the engine to use to render this scene
  33316. * @param options defines the scene options
  33317. */
  33318. constructor(engine: Engine, options?: SceneOptions);
  33319. /**
  33320. * Gets a string idenfifying the name of the class
  33321. * @returns "Scene" string
  33322. */
  33323. getClassName(): string;
  33324. private _defaultMeshCandidates;
  33325. /**
  33326. * @hidden
  33327. */
  33328. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33329. private _defaultSubMeshCandidates;
  33330. /**
  33331. * @hidden
  33332. */
  33333. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33334. /**
  33335. * Sets the default candidate providers for the scene.
  33336. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33337. * and getCollidingSubMeshCandidates to their default function
  33338. */
  33339. setDefaultCandidateProviders(): void;
  33340. /**
  33341. * Gets the mesh that is currently under the pointer
  33342. */
  33343. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33344. /**
  33345. * Gets or sets the current on-screen X position of the pointer
  33346. */
  33347. pointerX: number;
  33348. /**
  33349. * Gets or sets the current on-screen Y position of the pointer
  33350. */
  33351. pointerY: number;
  33352. /**
  33353. * Gets the cached material (ie. the latest rendered one)
  33354. * @returns the cached material
  33355. */
  33356. getCachedMaterial(): Nullable<Material>;
  33357. /**
  33358. * Gets the cached effect (ie. the latest rendered one)
  33359. * @returns the cached effect
  33360. */
  33361. getCachedEffect(): Nullable<Effect>;
  33362. /**
  33363. * Gets the cached visibility state (ie. the latest rendered one)
  33364. * @returns the cached visibility state
  33365. */
  33366. getCachedVisibility(): Nullable<number>;
  33367. /**
  33368. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33369. * @param material defines the current material
  33370. * @param effect defines the current effect
  33371. * @param visibility defines the current visibility state
  33372. * @returns true if one parameter is not cached
  33373. */
  33374. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33375. /**
  33376. * Gets the engine associated with the scene
  33377. * @returns an Engine
  33378. */
  33379. getEngine(): Engine;
  33380. /**
  33381. * Gets the total number of vertices rendered per frame
  33382. * @returns the total number of vertices rendered per frame
  33383. */
  33384. getTotalVertices(): number;
  33385. /**
  33386. * Gets the performance counter for total vertices
  33387. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33388. */
  33389. readonly totalVerticesPerfCounter: PerfCounter;
  33390. /**
  33391. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33392. * @returns the total number of active indices rendered per frame
  33393. */
  33394. getActiveIndices(): number;
  33395. /**
  33396. * Gets the performance counter for active indices
  33397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33398. */
  33399. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33400. /**
  33401. * Gets the total number of active particles rendered per frame
  33402. * @returns the total number of active particles rendered per frame
  33403. */
  33404. getActiveParticles(): number;
  33405. /**
  33406. * Gets the performance counter for active particles
  33407. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33408. */
  33409. readonly activeParticlesPerfCounter: PerfCounter;
  33410. /**
  33411. * Gets the total number of active bones rendered per frame
  33412. * @returns the total number of active bones rendered per frame
  33413. */
  33414. getActiveBones(): number;
  33415. /**
  33416. * Gets the performance counter for active bones
  33417. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33418. */
  33419. readonly activeBonesPerfCounter: PerfCounter;
  33420. /**
  33421. * Gets the array of active meshes
  33422. * @returns an array of AbstractMesh
  33423. */
  33424. getActiveMeshes(): SmartArray<AbstractMesh>;
  33425. /**
  33426. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33427. * @returns a number
  33428. */
  33429. getAnimationRatio(): number;
  33430. /**
  33431. * Gets an unique Id for the current render phase
  33432. * @returns a number
  33433. */
  33434. getRenderId(): number;
  33435. /**
  33436. * Gets an unique Id for the current frame
  33437. * @returns a number
  33438. */
  33439. getFrameId(): number;
  33440. /** Call this function if you want to manually increment the render Id*/
  33441. incrementRenderId(): void;
  33442. private _createUbo;
  33443. /**
  33444. * Use this method to simulate a pointer move on a mesh
  33445. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33446. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33447. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33448. * @returns the current scene
  33449. */
  33450. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33451. /**
  33452. * Use this method to simulate a pointer down on a mesh
  33453. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33454. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33455. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33456. * @returns the current scene
  33457. */
  33458. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33459. /**
  33460. * Use this method to simulate a pointer up on a mesh
  33461. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33462. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33463. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33464. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33465. * @returns the current scene
  33466. */
  33467. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33468. /**
  33469. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33470. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33471. * @returns true if the pointer was captured
  33472. */
  33473. isPointerCaptured(pointerId?: number): boolean;
  33474. /**
  33475. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33476. * @param attachUp defines if you want to attach events to pointerup
  33477. * @param attachDown defines if you want to attach events to pointerdown
  33478. * @param attachMove defines if you want to attach events to pointermove
  33479. */
  33480. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33481. /** Detaches all event handlers*/
  33482. detachControl(): void;
  33483. /**
  33484. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33485. * Delay loaded resources are not taking in account
  33486. * @return true if all required resources are ready
  33487. */
  33488. isReady(): boolean;
  33489. /** Resets all cached information relative to material (including effect and visibility) */
  33490. resetCachedMaterial(): void;
  33491. /**
  33492. * Registers a function to be called before every frame render
  33493. * @param func defines the function to register
  33494. */
  33495. registerBeforeRender(func: () => void): void;
  33496. /**
  33497. * Unregisters a function called before every frame render
  33498. * @param func defines the function to unregister
  33499. */
  33500. unregisterBeforeRender(func: () => void): void;
  33501. /**
  33502. * Registers a function to be called after every frame render
  33503. * @param func defines the function to register
  33504. */
  33505. registerAfterRender(func: () => void): void;
  33506. /**
  33507. * Unregisters a function called after every frame render
  33508. * @param func defines the function to unregister
  33509. */
  33510. unregisterAfterRender(func: () => void): void;
  33511. private _executeOnceBeforeRender;
  33512. /**
  33513. * The provided function will run before render once and will be disposed afterwards.
  33514. * A timeout delay can be provided so that the function will be executed in N ms.
  33515. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33516. * @param func The function to be executed.
  33517. * @param timeout optional delay in ms
  33518. */
  33519. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33520. /** @hidden */
  33521. _addPendingData(data: any): void;
  33522. /** @hidden */
  33523. _removePendingData(data: any): void;
  33524. /**
  33525. * Returns the number of items waiting to be loaded
  33526. * @returns the number of items waiting to be loaded
  33527. */
  33528. getWaitingItemsCount(): number;
  33529. /**
  33530. * Returns a boolean indicating if the scene is still loading data
  33531. */
  33532. readonly isLoading: boolean;
  33533. /**
  33534. * Registers a function to be executed when the scene is ready
  33535. * @param {Function} func - the function to be executed
  33536. */
  33537. executeWhenReady(func: () => void): void;
  33538. /**
  33539. * Returns a promise that resolves when the scene is ready
  33540. * @returns A promise that resolves when the scene is ready
  33541. */
  33542. whenReadyAsync(): Promise<void>;
  33543. /** @hidden */
  33544. _checkIsReady(): void;
  33545. /**
  33546. * Gets all animatable attached to the scene
  33547. */
  33548. readonly animatables: Animatable[];
  33549. /**
  33550. * Resets the last animation time frame.
  33551. * Useful to override when animations start running when loading a scene for the first time.
  33552. */
  33553. resetLastAnimationTimeFrame(): void;
  33554. /**
  33555. * Gets the current view matrix
  33556. * @returns a Matrix
  33557. */
  33558. getViewMatrix(): Matrix;
  33559. /**
  33560. * Gets the current projection matrix
  33561. * @returns a Matrix
  33562. */
  33563. getProjectionMatrix(): Matrix;
  33564. /**
  33565. * Gets the current transform matrix
  33566. * @returns a Matrix made of View * Projection
  33567. */
  33568. getTransformMatrix(): Matrix;
  33569. /**
  33570. * Sets the current transform matrix
  33571. * @param viewL defines the View matrix to use
  33572. * @param projectionL defines the Projection matrix to use
  33573. * @param viewR defines the right View matrix to use (if provided)
  33574. * @param projectionR defines the right Projection matrix to use (if provided)
  33575. */
  33576. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33577. /**
  33578. * Gets the uniform buffer used to store scene data
  33579. * @returns a UniformBuffer
  33580. */
  33581. getSceneUniformBuffer(): UniformBuffer;
  33582. /**
  33583. * Gets an unique (relatively to the current scene) Id
  33584. * @returns an unique number for the scene
  33585. */
  33586. getUniqueId(): number;
  33587. /**
  33588. * Add a mesh to the list of scene's meshes
  33589. * @param newMesh defines the mesh to add
  33590. * @param recursive if all child meshes should also be added to the scene
  33591. */
  33592. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33593. /**
  33594. * Remove a mesh for the list of scene's meshes
  33595. * @param toRemove defines the mesh to remove
  33596. * @param recursive if all child meshes should also be removed from the scene
  33597. * @returns the index where the mesh was in the mesh list
  33598. */
  33599. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33600. /**
  33601. * Add a transform node to the list of scene's transform nodes
  33602. * @param newTransformNode defines the transform node to add
  33603. */
  33604. addTransformNode(newTransformNode: TransformNode): void;
  33605. /**
  33606. * Remove a transform node for the list of scene's transform nodes
  33607. * @param toRemove defines the transform node to remove
  33608. * @returns the index where the transform node was in the transform node list
  33609. */
  33610. removeTransformNode(toRemove: TransformNode): number;
  33611. /**
  33612. * Remove a skeleton for the list of scene's skeletons
  33613. * @param toRemove defines the skeleton to remove
  33614. * @returns the index where the skeleton was in the skeleton list
  33615. */
  33616. removeSkeleton(toRemove: Skeleton): number;
  33617. /**
  33618. * Remove a morph target for the list of scene's morph targets
  33619. * @param toRemove defines the morph target to remove
  33620. * @returns the index where the morph target was in the morph target list
  33621. */
  33622. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33623. /**
  33624. * Remove a light for the list of scene's lights
  33625. * @param toRemove defines the light to remove
  33626. * @returns the index where the light was in the light list
  33627. */
  33628. removeLight(toRemove: Light): number;
  33629. /**
  33630. * Remove a camera for the list of scene's cameras
  33631. * @param toRemove defines the camera to remove
  33632. * @returns the index where the camera was in the camera list
  33633. */
  33634. removeCamera(toRemove: Camera): number;
  33635. /**
  33636. * Remove a particle system for the list of scene's particle systems
  33637. * @param toRemove defines the particle system to remove
  33638. * @returns the index where the particle system was in the particle system list
  33639. */
  33640. removeParticleSystem(toRemove: IParticleSystem): number;
  33641. /**
  33642. * Remove a animation for the list of scene's animations
  33643. * @param toRemove defines the animation to remove
  33644. * @returns the index where the animation was in the animation list
  33645. */
  33646. removeAnimation(toRemove: Animation): number;
  33647. /**
  33648. * Will stop the animation of the given target
  33649. * @param target - the target
  33650. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33651. * @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)
  33652. */
  33653. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33654. /**
  33655. * Removes the given animation group from this scene.
  33656. * @param toRemove The animation group to remove
  33657. * @returns The index of the removed animation group
  33658. */
  33659. removeAnimationGroup(toRemove: AnimationGroup): number;
  33660. /**
  33661. * Removes the given multi-material from this scene.
  33662. * @param toRemove The multi-material to remove
  33663. * @returns The index of the removed multi-material
  33664. */
  33665. removeMultiMaterial(toRemove: MultiMaterial): number;
  33666. /**
  33667. * Removes the given material from this scene.
  33668. * @param toRemove The material to remove
  33669. * @returns The index of the removed material
  33670. */
  33671. removeMaterial(toRemove: Material): number;
  33672. /**
  33673. * Removes the given action manager from this scene.
  33674. * @param toRemove The action manager to remove
  33675. * @returns The index of the removed action manager
  33676. */
  33677. removeActionManager(toRemove: AbstractActionManager): number;
  33678. /**
  33679. * Removes the given texture from this scene.
  33680. * @param toRemove The texture to remove
  33681. * @returns The index of the removed texture
  33682. */
  33683. removeTexture(toRemove: BaseTexture): number;
  33684. /**
  33685. * Adds the given light to this scene
  33686. * @param newLight The light to add
  33687. */
  33688. addLight(newLight: Light): void;
  33689. /**
  33690. * Sorts the list list based on light priorities
  33691. */
  33692. sortLightsByPriority(): void;
  33693. /**
  33694. * Adds the given camera to this scene
  33695. * @param newCamera The camera to add
  33696. */
  33697. addCamera(newCamera: Camera): void;
  33698. /**
  33699. * Adds the given skeleton to this scene
  33700. * @param newSkeleton The skeleton to add
  33701. */
  33702. addSkeleton(newSkeleton: Skeleton): void;
  33703. /**
  33704. * Adds the given particle system to this scene
  33705. * @param newParticleSystem The particle system to add
  33706. */
  33707. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33708. /**
  33709. * Adds the given animation to this scene
  33710. * @param newAnimation The animation to add
  33711. */
  33712. addAnimation(newAnimation: Animation): void;
  33713. /**
  33714. * Adds the given animation group to this scene.
  33715. * @param newAnimationGroup The animation group to add
  33716. */
  33717. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33718. /**
  33719. * Adds the given multi-material to this scene
  33720. * @param newMultiMaterial The multi-material to add
  33721. */
  33722. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33723. /**
  33724. * Adds the given material to this scene
  33725. * @param newMaterial The material to add
  33726. */
  33727. addMaterial(newMaterial: Material): void;
  33728. /**
  33729. * Adds the given morph target to this scene
  33730. * @param newMorphTargetManager The morph target to add
  33731. */
  33732. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33733. /**
  33734. * Adds the given geometry to this scene
  33735. * @param newGeometry The geometry to add
  33736. */
  33737. addGeometry(newGeometry: Geometry): void;
  33738. /**
  33739. * Adds the given action manager to this scene
  33740. * @param newActionManager The action manager to add
  33741. */
  33742. addActionManager(newActionManager: AbstractActionManager): void;
  33743. /**
  33744. * Adds the given texture to this scene.
  33745. * @param newTexture The texture to add
  33746. */
  33747. addTexture(newTexture: BaseTexture): void;
  33748. /**
  33749. * Switch active camera
  33750. * @param newCamera defines the new active camera
  33751. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33752. */
  33753. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33754. /**
  33755. * sets the active camera of the scene using its ID
  33756. * @param id defines the camera's ID
  33757. * @return the new active camera or null if none found.
  33758. */
  33759. setActiveCameraByID(id: string): Nullable<Camera>;
  33760. /**
  33761. * sets the active camera of the scene using its name
  33762. * @param name defines the camera's name
  33763. * @returns the new active camera or null if none found.
  33764. */
  33765. setActiveCameraByName(name: string): Nullable<Camera>;
  33766. /**
  33767. * get an animation group using its name
  33768. * @param name defines the material's name
  33769. * @return the animation group or null if none found.
  33770. */
  33771. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33772. /**
  33773. * Get a material using its unique id
  33774. * @param uniqueId defines the material's unique id
  33775. * @return the material or null if none found.
  33776. */
  33777. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33778. /**
  33779. * get a material using its id
  33780. * @param id defines the material's ID
  33781. * @return the material or null if none found.
  33782. */
  33783. getMaterialByID(id: string): Nullable<Material>;
  33784. /**
  33785. * Gets a the last added material using a given id
  33786. * @param id defines the material's ID
  33787. * @return the last material with the given id or null if none found.
  33788. */
  33789. getLastMaterialByID(id: string): Nullable<Material>;
  33790. /**
  33791. * Gets a material using its name
  33792. * @param name defines the material's name
  33793. * @return the material or null if none found.
  33794. */
  33795. getMaterialByName(name: string): Nullable<Material>;
  33796. /**
  33797. * Gets a camera using its id
  33798. * @param id defines the id to look for
  33799. * @returns the camera or null if not found
  33800. */
  33801. getCameraByID(id: string): Nullable<Camera>;
  33802. /**
  33803. * Gets a camera using its unique id
  33804. * @param uniqueId defines the unique id to look for
  33805. * @returns the camera or null if not found
  33806. */
  33807. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33808. /**
  33809. * Gets a camera using its name
  33810. * @param name defines the camera's name
  33811. * @return the camera or null if none found.
  33812. */
  33813. getCameraByName(name: string): Nullable<Camera>;
  33814. /**
  33815. * Gets a bone using its id
  33816. * @param id defines the bone's id
  33817. * @return the bone or null if not found
  33818. */
  33819. getBoneByID(id: string): Nullable<Bone>;
  33820. /**
  33821. * Gets a bone using its id
  33822. * @param name defines the bone's name
  33823. * @return the bone or null if not found
  33824. */
  33825. getBoneByName(name: string): Nullable<Bone>;
  33826. /**
  33827. * Gets a light node using its name
  33828. * @param name defines the the light's name
  33829. * @return the light or null if none found.
  33830. */
  33831. getLightByName(name: string): Nullable<Light>;
  33832. /**
  33833. * Gets a light node using its id
  33834. * @param id defines the light's id
  33835. * @return the light or null if none found.
  33836. */
  33837. getLightByID(id: string): Nullable<Light>;
  33838. /**
  33839. * Gets a light node using its scene-generated unique ID
  33840. * @param uniqueId defines the light's unique id
  33841. * @return the light or null if none found.
  33842. */
  33843. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33844. /**
  33845. * Gets a particle system by id
  33846. * @param id defines the particle system id
  33847. * @return the corresponding system or null if none found
  33848. */
  33849. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33850. /**
  33851. * Gets a geometry using its ID
  33852. * @param id defines the geometry's id
  33853. * @return the geometry or null if none found.
  33854. */
  33855. getGeometryByID(id: string): Nullable<Geometry>;
  33856. private _getGeometryByUniqueID;
  33857. /**
  33858. * Add a new geometry to this scene
  33859. * @param geometry defines the geometry to be added to the scene.
  33860. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33861. * @return a boolean defining if the geometry was added or not
  33862. */
  33863. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33864. /**
  33865. * Removes an existing geometry
  33866. * @param geometry defines the geometry to be removed from the scene
  33867. * @return a boolean defining if the geometry was removed or not
  33868. */
  33869. removeGeometry(geometry: Geometry): boolean;
  33870. /**
  33871. * Gets the list of geometries attached to the scene
  33872. * @returns an array of Geometry
  33873. */
  33874. getGeometries(): Geometry[];
  33875. /**
  33876. * Gets the first added mesh found of a given ID
  33877. * @param id defines the id to search for
  33878. * @return the mesh found or null if not found at all
  33879. */
  33880. getMeshByID(id: string): Nullable<AbstractMesh>;
  33881. /**
  33882. * Gets a list of meshes using their id
  33883. * @param id defines the id to search for
  33884. * @returns a list of meshes
  33885. */
  33886. getMeshesByID(id: string): Array<AbstractMesh>;
  33887. /**
  33888. * Gets the first added transform node found of a given ID
  33889. * @param id defines the id to search for
  33890. * @return the found transform node or null if not found at all.
  33891. */
  33892. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33893. /**
  33894. * Gets a transform node with its auto-generated unique id
  33895. * @param uniqueId efines the unique id to search for
  33896. * @return the found transform node or null if not found at all.
  33897. */
  33898. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33899. /**
  33900. * Gets a list of transform nodes using their id
  33901. * @param id defines the id to search for
  33902. * @returns a list of transform nodes
  33903. */
  33904. getTransformNodesByID(id: string): Array<TransformNode>;
  33905. /**
  33906. * Gets a mesh with its auto-generated unique id
  33907. * @param uniqueId defines the unique id to search for
  33908. * @return the found mesh or null if not found at all.
  33909. */
  33910. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33911. /**
  33912. * Gets a the last added mesh using a given id
  33913. * @param id defines the id to search for
  33914. * @return the found mesh or null if not found at all.
  33915. */
  33916. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33917. /**
  33918. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33919. * @param id defines the id to search for
  33920. * @return the found node or null if not found at all
  33921. */
  33922. getLastEntryByID(id: string): Nullable<Node>;
  33923. /**
  33924. * Gets a node (Mesh, Camera, Light) using a given id
  33925. * @param id defines the id to search for
  33926. * @return the found node or null if not found at all
  33927. */
  33928. getNodeByID(id: string): Nullable<Node>;
  33929. /**
  33930. * Gets a node (Mesh, Camera, Light) using a given name
  33931. * @param name defines the name to search for
  33932. * @return the found node or null if not found at all.
  33933. */
  33934. getNodeByName(name: string): Nullable<Node>;
  33935. /**
  33936. * Gets a mesh using a given name
  33937. * @param name defines the name to search for
  33938. * @return the found mesh or null if not found at all.
  33939. */
  33940. getMeshByName(name: string): Nullable<AbstractMesh>;
  33941. /**
  33942. * Gets a transform node using a given name
  33943. * @param name defines the name to search for
  33944. * @return the found transform node or null if not found at all.
  33945. */
  33946. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33947. /**
  33948. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33949. * @param id defines the id to search for
  33950. * @return the found skeleton or null if not found at all.
  33951. */
  33952. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33953. /**
  33954. * Gets a skeleton using a given auto generated unique id
  33955. * @param uniqueId defines the unique id to search for
  33956. * @return the found skeleton or null if not found at all.
  33957. */
  33958. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33959. /**
  33960. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33961. * @param id defines the id to search for
  33962. * @return the found skeleton or null if not found at all.
  33963. */
  33964. getSkeletonById(id: string): Nullable<Skeleton>;
  33965. /**
  33966. * Gets a skeleton using a given name
  33967. * @param name defines the name to search for
  33968. * @return the found skeleton or null if not found at all.
  33969. */
  33970. getSkeletonByName(name: string): Nullable<Skeleton>;
  33971. /**
  33972. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33973. * @param id defines the id to search for
  33974. * @return the found morph target manager or null if not found at all.
  33975. */
  33976. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33977. /**
  33978. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33979. * @param id defines the id to search for
  33980. * @return the found morph target or null if not found at all.
  33981. */
  33982. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33983. /**
  33984. * Gets a boolean indicating if the given mesh is active
  33985. * @param mesh defines the mesh to look for
  33986. * @returns true if the mesh is in the active list
  33987. */
  33988. isActiveMesh(mesh: AbstractMesh): boolean;
  33989. /**
  33990. * Return a unique id as a string which can serve as an identifier for the scene
  33991. */
  33992. readonly uid: string;
  33993. /**
  33994. * Add an externaly attached data from its key.
  33995. * This method call will fail and return false, if such key already exists.
  33996. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33997. * @param key the unique key that identifies the data
  33998. * @param data the data object to associate to the key for this Engine instance
  33999. * @return true if no such key were already present and the data was added successfully, false otherwise
  34000. */
  34001. addExternalData<T>(key: string, data: T): boolean;
  34002. /**
  34003. * Get an externaly attached data from its key
  34004. * @param key the unique key that identifies the data
  34005. * @return the associated data, if present (can be null), or undefined if not present
  34006. */
  34007. getExternalData<T>(key: string): Nullable<T>;
  34008. /**
  34009. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34010. * @param key the unique key that identifies the data
  34011. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34012. * @return the associated data, can be null if the factory returned null.
  34013. */
  34014. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34015. /**
  34016. * Remove an externaly attached data from the Engine instance
  34017. * @param key the unique key that identifies the data
  34018. * @return true if the data was successfully removed, false if it doesn't exist
  34019. */
  34020. removeExternalData(key: string): boolean;
  34021. private _evaluateSubMesh;
  34022. /**
  34023. * Clear the processed materials smart array preventing retention point in material dispose.
  34024. */
  34025. freeProcessedMaterials(): void;
  34026. private _preventFreeActiveMeshesAndRenderingGroups;
  34027. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34028. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34029. * when disposing several meshes in a row or a hierarchy of meshes.
  34030. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34031. */
  34032. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34033. /**
  34034. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34035. */
  34036. freeActiveMeshes(): void;
  34037. /**
  34038. * Clear the info related to rendering groups preventing retention points during dispose.
  34039. */
  34040. freeRenderingGroups(): void;
  34041. /** @hidden */
  34042. _isInIntermediateRendering(): boolean;
  34043. /**
  34044. * Lambda returning the list of potentially active meshes.
  34045. */
  34046. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34047. /**
  34048. * Lambda returning the list of potentially active sub meshes.
  34049. */
  34050. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34051. /**
  34052. * Lambda returning the list of potentially intersecting sub meshes.
  34053. */
  34054. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34055. /**
  34056. * Lambda returning the list of potentially colliding sub meshes.
  34057. */
  34058. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34059. private _activeMeshesFrozen;
  34060. /**
  34061. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34062. * @returns the current scene
  34063. */
  34064. freezeActiveMeshes(): Scene;
  34065. /**
  34066. * Use this function to restart evaluating active meshes on every frame
  34067. * @returns the current scene
  34068. */
  34069. unfreezeActiveMeshes(): Scene;
  34070. private _evaluateActiveMeshes;
  34071. private _activeMesh;
  34072. /**
  34073. * Update the transform matrix to update from the current active camera
  34074. * @param force defines a boolean used to force the update even if cache is up to date
  34075. */
  34076. updateTransformMatrix(force?: boolean): void;
  34077. private _bindFrameBuffer;
  34078. /** @hidden */
  34079. _allowPostProcessClearColor: boolean;
  34080. /** @hidden */
  34081. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34082. private _processSubCameras;
  34083. private _checkIntersections;
  34084. /** @hidden */
  34085. _advancePhysicsEngineStep(step: number): void;
  34086. /**
  34087. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34088. */
  34089. getDeterministicFrameTime: () => number;
  34090. /** @hidden */
  34091. _animate(): void;
  34092. /** Execute all animations (for a frame) */
  34093. animate(): void;
  34094. /**
  34095. * Render the scene
  34096. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34097. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34098. */
  34099. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34100. /**
  34101. * Freeze all materials
  34102. * A frozen material will not be updatable but should be faster to render
  34103. */
  34104. freezeMaterials(): void;
  34105. /**
  34106. * Unfreeze all materials
  34107. * A frozen material will not be updatable but should be faster to render
  34108. */
  34109. unfreezeMaterials(): void;
  34110. /**
  34111. * Releases all held ressources
  34112. */
  34113. dispose(): void;
  34114. /**
  34115. * Gets if the scene is already disposed
  34116. */
  34117. readonly isDisposed: boolean;
  34118. /**
  34119. * Call this function to reduce memory footprint of the scene.
  34120. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34121. */
  34122. clearCachedVertexData(): void;
  34123. /**
  34124. * This function will remove the local cached buffer data from texture.
  34125. * It will save memory but will prevent the texture from being rebuilt
  34126. */
  34127. cleanCachedTextureBuffer(): void;
  34128. /**
  34129. * Get the world extend vectors with an optional filter
  34130. *
  34131. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34132. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34133. */
  34134. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34135. min: Vector3;
  34136. max: Vector3;
  34137. };
  34138. /**
  34139. * Creates a ray that can be used to pick in the scene
  34140. * @param x defines the x coordinate of the origin (on-screen)
  34141. * @param y defines the y coordinate of the origin (on-screen)
  34142. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34143. * @param camera defines the camera to use for the picking
  34144. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34145. * @returns a Ray
  34146. */
  34147. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34148. /**
  34149. * Creates a ray that can be used to pick in the scene
  34150. * @param x defines the x coordinate of the origin (on-screen)
  34151. * @param y defines the y coordinate of the origin (on-screen)
  34152. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34153. * @param result defines the ray where to store the picking ray
  34154. * @param camera defines the camera to use for the picking
  34155. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34156. * @returns the current scene
  34157. */
  34158. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34159. /**
  34160. * Creates a ray that can be used to pick in the scene
  34161. * @param x defines the x coordinate of the origin (on-screen)
  34162. * @param y defines the y coordinate of the origin (on-screen)
  34163. * @param camera defines the camera to use for the picking
  34164. * @returns a Ray
  34165. */
  34166. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34167. /**
  34168. * Creates a ray that can be used to pick in the scene
  34169. * @param x defines the x coordinate of the origin (on-screen)
  34170. * @param y defines the y coordinate of the origin (on-screen)
  34171. * @param result defines the ray where to store the picking ray
  34172. * @param camera defines the camera to use for the picking
  34173. * @returns the current scene
  34174. */
  34175. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34176. /** Launch a ray to try to pick a mesh in the scene
  34177. * @param x position on screen
  34178. * @param y position on screen
  34179. * @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
  34180. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34181. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34182. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34183. * @returns a PickingInfo
  34184. */
  34185. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34186. /** Use the given ray to pick a mesh in the scene
  34187. * @param ray The ray to use to pick meshes
  34188. * @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
  34189. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34190. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34191. * @returns a PickingInfo
  34192. */
  34193. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34194. /**
  34195. * Launch a ray to try to pick a mesh in the scene
  34196. * @param x X position on screen
  34197. * @param y Y position on screen
  34198. * @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
  34199. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34200. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34201. * @returns an array of PickingInfo
  34202. */
  34203. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34204. /**
  34205. * Launch a ray to try to pick a mesh in the scene
  34206. * @param ray Ray to use
  34207. * @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
  34208. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34209. * @returns an array of PickingInfo
  34210. */
  34211. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34212. /**
  34213. * Force the value of meshUnderPointer
  34214. * @param mesh defines the mesh to use
  34215. */
  34216. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34217. /**
  34218. * Gets the mesh under the pointer
  34219. * @returns a Mesh or null if no mesh is under the pointer
  34220. */
  34221. getPointerOverMesh(): Nullable<AbstractMesh>;
  34222. /** @hidden */
  34223. _rebuildGeometries(): void;
  34224. /** @hidden */
  34225. _rebuildTextures(): void;
  34226. private _getByTags;
  34227. /**
  34228. * Get a list of meshes by tags
  34229. * @param tagsQuery defines the tags query to use
  34230. * @param forEach defines a predicate used to filter results
  34231. * @returns an array of Mesh
  34232. */
  34233. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34234. /**
  34235. * Get a list of cameras by tags
  34236. * @param tagsQuery defines the tags query to use
  34237. * @param forEach defines a predicate used to filter results
  34238. * @returns an array of Camera
  34239. */
  34240. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34241. /**
  34242. * Get a list of lights by tags
  34243. * @param tagsQuery defines the tags query to use
  34244. * @param forEach defines a predicate used to filter results
  34245. * @returns an array of Light
  34246. */
  34247. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34248. /**
  34249. * Get a list of materials by tags
  34250. * @param tagsQuery defines the tags query to use
  34251. * @param forEach defines a predicate used to filter results
  34252. * @returns an array of Material
  34253. */
  34254. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34255. /**
  34256. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34257. * This allowed control for front to back rendering or reversly depending of the special needs.
  34258. *
  34259. * @param renderingGroupId The rendering group id corresponding to its index
  34260. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34261. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34262. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34263. */
  34264. 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;
  34265. /**
  34266. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34267. *
  34268. * @param renderingGroupId The rendering group id corresponding to its index
  34269. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34270. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34271. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34272. */
  34273. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34274. /**
  34275. * Gets the current auto clear configuration for one rendering group of the rendering
  34276. * manager.
  34277. * @param index the rendering group index to get the information for
  34278. * @returns The auto clear setup for the requested rendering group
  34279. */
  34280. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34281. private _blockMaterialDirtyMechanism;
  34282. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34283. blockMaterialDirtyMechanism: boolean;
  34284. /**
  34285. * Will flag all materials as dirty to trigger new shader compilation
  34286. * @param flag defines the flag used to specify which material part must be marked as dirty
  34287. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34288. */
  34289. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34290. /** @hidden */
  34291. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34292. /** @hidden */
  34293. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34294. }
  34295. }
  34296. declare module BABYLON {
  34297. /**
  34298. * Set of assets to keep when moving a scene into an asset container.
  34299. */
  34300. export class KeepAssets extends AbstractScene {
  34301. }
  34302. /**
  34303. * Container with a set of assets that can be added or removed from a scene.
  34304. */
  34305. export class AssetContainer extends AbstractScene {
  34306. /**
  34307. * The scene the AssetContainer belongs to.
  34308. */
  34309. scene: Scene;
  34310. /**
  34311. * Instantiates an AssetContainer.
  34312. * @param scene The scene the AssetContainer belongs to.
  34313. */
  34314. constructor(scene: Scene);
  34315. /**
  34316. * Adds all the assets from the container to the scene.
  34317. */
  34318. addAllToScene(): void;
  34319. /**
  34320. * Removes all the assets in the container from the scene
  34321. */
  34322. removeAllFromScene(): void;
  34323. /**
  34324. * Disposes all the assets in the container
  34325. */
  34326. dispose(): void;
  34327. private _moveAssets;
  34328. /**
  34329. * Removes all the assets contained in the scene and adds them to the container.
  34330. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34331. */
  34332. moveAllFromScene(keepAssets?: KeepAssets): void;
  34333. /**
  34334. * 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.
  34335. * @returns the root mesh
  34336. */
  34337. createRootMesh(): Mesh;
  34338. }
  34339. }
  34340. declare module BABYLON {
  34341. /**
  34342. * Defines how the parser contract is defined.
  34343. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34344. */
  34345. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34346. /**
  34347. * Defines how the individual parser contract is defined.
  34348. * These parser can parse an individual asset
  34349. */
  34350. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34351. /**
  34352. * Base class of the scene acting as a container for the different elements composing a scene.
  34353. * This class is dynamically extended by the different components of the scene increasing
  34354. * flexibility and reducing coupling
  34355. */
  34356. export abstract class AbstractScene {
  34357. /**
  34358. * Stores the list of available parsers in the application.
  34359. */
  34360. private static _BabylonFileParsers;
  34361. /**
  34362. * Stores the list of available individual parsers in the application.
  34363. */
  34364. private static _IndividualBabylonFileParsers;
  34365. /**
  34366. * Adds a parser in the list of available ones
  34367. * @param name Defines the name of the parser
  34368. * @param parser Defines the parser to add
  34369. */
  34370. static AddParser(name: string, parser: BabylonFileParser): void;
  34371. /**
  34372. * Gets a general parser from the list of avaialble ones
  34373. * @param name Defines the name of the parser
  34374. * @returns the requested parser or null
  34375. */
  34376. static GetParser(name: string): Nullable<BabylonFileParser>;
  34377. /**
  34378. * Adds n individual parser in the list of available ones
  34379. * @param name Defines the name of the parser
  34380. * @param parser Defines the parser to add
  34381. */
  34382. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34383. /**
  34384. * Gets an individual parser from the list of avaialble ones
  34385. * @param name Defines the name of the parser
  34386. * @returns the requested parser or null
  34387. */
  34388. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34389. /**
  34390. * Parser json data and populate both a scene and its associated container object
  34391. * @param jsonData Defines the data to parse
  34392. * @param scene Defines the scene to parse the data for
  34393. * @param container Defines the container attached to the parsing sequence
  34394. * @param rootUrl Defines the root url of the data
  34395. */
  34396. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34397. /**
  34398. * Gets the list of root nodes (ie. nodes with no parent)
  34399. */
  34400. rootNodes: Node[];
  34401. /** All of the cameras added to this scene
  34402. * @see http://doc.babylonjs.com/babylon101/cameras
  34403. */
  34404. cameras: Camera[];
  34405. /**
  34406. * All of the lights added to this scene
  34407. * @see http://doc.babylonjs.com/babylon101/lights
  34408. */
  34409. lights: Light[];
  34410. /**
  34411. * All of the (abstract) meshes added to this scene
  34412. */
  34413. meshes: AbstractMesh[];
  34414. /**
  34415. * The list of skeletons added to the scene
  34416. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34417. */
  34418. skeletons: Skeleton[];
  34419. /**
  34420. * All of the particle systems added to this scene
  34421. * @see http://doc.babylonjs.com/babylon101/particles
  34422. */
  34423. particleSystems: IParticleSystem[];
  34424. /**
  34425. * Gets a list of Animations associated with the scene
  34426. */
  34427. animations: Animation[];
  34428. /**
  34429. * All of the animation groups added to this scene
  34430. * @see http://doc.babylonjs.com/how_to/group
  34431. */
  34432. animationGroups: AnimationGroup[];
  34433. /**
  34434. * All of the multi-materials added to this scene
  34435. * @see http://doc.babylonjs.com/how_to/multi_materials
  34436. */
  34437. multiMaterials: MultiMaterial[];
  34438. /**
  34439. * All of the materials added to this scene
  34440. * In the context of a Scene, it is not supposed to be modified manually.
  34441. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34442. * Note also that the order of the Material wihin the array is not significant and might change.
  34443. * @see http://doc.babylonjs.com/babylon101/materials
  34444. */
  34445. materials: Material[];
  34446. /**
  34447. * The list of morph target managers added to the scene
  34448. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34449. */
  34450. morphTargetManagers: MorphTargetManager[];
  34451. /**
  34452. * The list of geometries used in the scene.
  34453. */
  34454. geometries: Geometry[];
  34455. /**
  34456. * All of the tranform nodes added to this scene
  34457. * In the context of a Scene, it is not supposed to be modified manually.
  34458. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34459. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34460. * @see http://doc.babylonjs.com/how_to/transformnode
  34461. */
  34462. transformNodes: TransformNode[];
  34463. /**
  34464. * ActionManagers available on the scene.
  34465. */
  34466. actionManagers: AbstractActionManager[];
  34467. /**
  34468. * Textures to keep.
  34469. */
  34470. textures: BaseTexture[];
  34471. /**
  34472. * Environment texture for the scene
  34473. */
  34474. environmentTexture: Nullable<BaseTexture>;
  34475. }
  34476. }
  34477. declare module BABYLON {
  34478. /**
  34479. * Interface used to define options for Sound class
  34480. */
  34481. export interface ISoundOptions {
  34482. /**
  34483. * Does the sound autoplay once loaded.
  34484. */
  34485. autoplay?: boolean;
  34486. /**
  34487. * Does the sound loop after it finishes playing once.
  34488. */
  34489. loop?: boolean;
  34490. /**
  34491. * Sound's volume
  34492. */
  34493. volume?: number;
  34494. /**
  34495. * Is it a spatial sound?
  34496. */
  34497. spatialSound?: boolean;
  34498. /**
  34499. * Maximum distance to hear that sound
  34500. */
  34501. maxDistance?: number;
  34502. /**
  34503. * Uses user defined attenuation function
  34504. */
  34505. useCustomAttenuation?: boolean;
  34506. /**
  34507. * Define the roll off factor of spatial sounds.
  34508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34509. */
  34510. rolloffFactor?: number;
  34511. /**
  34512. * Define the reference distance the sound should be heard perfectly.
  34513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34514. */
  34515. refDistance?: number;
  34516. /**
  34517. * Define the distance attenuation model the sound will follow.
  34518. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34519. */
  34520. distanceModel?: string;
  34521. /**
  34522. * Defines the playback speed (1 by default)
  34523. */
  34524. playbackRate?: number;
  34525. /**
  34526. * Defines if the sound is from a streaming source
  34527. */
  34528. streaming?: boolean;
  34529. /**
  34530. * Defines an optional length (in seconds) inside the sound file
  34531. */
  34532. length?: number;
  34533. /**
  34534. * Defines an optional offset (in seconds) inside the sound file
  34535. */
  34536. offset?: number;
  34537. /**
  34538. * If true, URLs will not be required to state the audio file codec to use.
  34539. */
  34540. skipCodecCheck?: boolean;
  34541. }
  34542. /**
  34543. * Defines a sound that can be played in the application.
  34544. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34546. */
  34547. export class Sound {
  34548. /**
  34549. * The name of the sound in the scene.
  34550. */
  34551. name: string;
  34552. /**
  34553. * Does the sound autoplay once loaded.
  34554. */
  34555. autoplay: boolean;
  34556. /**
  34557. * Does the sound loop after it finishes playing once.
  34558. */
  34559. loop: boolean;
  34560. /**
  34561. * Does the sound use a custom attenuation curve to simulate the falloff
  34562. * happening when the source gets further away from the camera.
  34563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34564. */
  34565. useCustomAttenuation: boolean;
  34566. /**
  34567. * The sound track id this sound belongs to.
  34568. */
  34569. soundTrackId: number;
  34570. /**
  34571. * Is this sound currently played.
  34572. */
  34573. isPlaying: boolean;
  34574. /**
  34575. * Is this sound currently paused.
  34576. */
  34577. isPaused: boolean;
  34578. /**
  34579. * Does this sound enables spatial sound.
  34580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34581. */
  34582. spatialSound: boolean;
  34583. /**
  34584. * Define the reference distance the sound should be heard perfectly.
  34585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34586. */
  34587. refDistance: number;
  34588. /**
  34589. * Define the roll off factor of spatial sounds.
  34590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34591. */
  34592. rolloffFactor: number;
  34593. /**
  34594. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34596. */
  34597. maxDistance: number;
  34598. /**
  34599. * Define the distance attenuation model the sound will follow.
  34600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34601. */
  34602. distanceModel: string;
  34603. /**
  34604. * @hidden
  34605. * Back Compat
  34606. **/
  34607. onended: () => any;
  34608. /**
  34609. * Observable event when the current playing sound finishes.
  34610. */
  34611. onEndedObservable: Observable<Sound>;
  34612. private _panningModel;
  34613. private _playbackRate;
  34614. private _streaming;
  34615. private _startTime;
  34616. private _startOffset;
  34617. private _position;
  34618. /** @hidden */
  34619. _positionInEmitterSpace: boolean;
  34620. private _localDirection;
  34621. private _volume;
  34622. private _isReadyToPlay;
  34623. private _isDirectional;
  34624. private _readyToPlayCallback;
  34625. private _audioBuffer;
  34626. private _soundSource;
  34627. private _streamingSource;
  34628. private _soundPanner;
  34629. private _soundGain;
  34630. private _inputAudioNode;
  34631. private _outputAudioNode;
  34632. private _coneInnerAngle;
  34633. private _coneOuterAngle;
  34634. private _coneOuterGain;
  34635. private _scene;
  34636. private _connectedTransformNode;
  34637. private _customAttenuationFunction;
  34638. private _registerFunc;
  34639. private _isOutputConnected;
  34640. private _htmlAudioElement;
  34641. private _urlType;
  34642. private _length?;
  34643. private _offset?;
  34644. /** @hidden */
  34645. static _SceneComponentInitialization: (scene: Scene) => void;
  34646. /**
  34647. * Create a sound and attach it to a scene
  34648. * @param name Name of your sound
  34649. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34650. * @param scene defines the scene the sound belongs to
  34651. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34652. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34653. */
  34654. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34655. /**
  34656. * Release the sound and its associated resources
  34657. */
  34658. dispose(): void;
  34659. /**
  34660. * Gets if the sounds is ready to be played or not.
  34661. * @returns true if ready, otherwise false
  34662. */
  34663. isReady(): boolean;
  34664. private _soundLoaded;
  34665. /**
  34666. * Sets the data of the sound from an audiobuffer
  34667. * @param audioBuffer The audioBuffer containing the data
  34668. */
  34669. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34670. /**
  34671. * Updates the current sounds options such as maxdistance, loop...
  34672. * @param options A JSON object containing values named as the object properties
  34673. */
  34674. updateOptions(options: ISoundOptions): void;
  34675. private _createSpatialParameters;
  34676. private _updateSpatialParameters;
  34677. /**
  34678. * Switch the panning model to HRTF:
  34679. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34681. */
  34682. switchPanningModelToHRTF(): void;
  34683. /**
  34684. * Switch the panning model to Equal Power:
  34685. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34687. */
  34688. switchPanningModelToEqualPower(): void;
  34689. private _switchPanningModel;
  34690. /**
  34691. * Connect this sound to a sound track audio node like gain...
  34692. * @param soundTrackAudioNode the sound track audio node to connect to
  34693. */
  34694. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34695. /**
  34696. * Transform this sound into a directional source
  34697. * @param coneInnerAngle Size of the inner cone in degree
  34698. * @param coneOuterAngle Size of the outer cone in degree
  34699. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34700. */
  34701. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34702. /**
  34703. * Gets or sets the inner angle for the directional cone.
  34704. */
  34705. /**
  34706. * Gets or sets the inner angle for the directional cone.
  34707. */
  34708. directionalConeInnerAngle: number;
  34709. /**
  34710. * Gets or sets the outer angle for the directional cone.
  34711. */
  34712. /**
  34713. * Gets or sets the outer angle for the directional cone.
  34714. */
  34715. directionalConeOuterAngle: number;
  34716. /**
  34717. * Sets the position of the emitter if spatial sound is enabled
  34718. * @param newPosition Defines the new posisiton
  34719. */
  34720. setPosition(newPosition: Vector3): void;
  34721. /**
  34722. * Sets the local direction of the emitter if spatial sound is enabled
  34723. * @param newLocalDirection Defines the new local direction
  34724. */
  34725. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34726. private _updateDirection;
  34727. /** @hidden */
  34728. updateDistanceFromListener(): void;
  34729. /**
  34730. * Sets a new custom attenuation function for the sound.
  34731. * @param callback Defines the function used for the attenuation
  34732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34733. */
  34734. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34735. /**
  34736. * Play the sound
  34737. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34738. * @param offset (optional) Start the sound at a specific time in seconds
  34739. * @param length (optional) Sound duration (in seconds)
  34740. */
  34741. play(time?: number, offset?: number, length?: number): void;
  34742. private _onended;
  34743. /**
  34744. * Stop the sound
  34745. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34746. */
  34747. stop(time?: number): void;
  34748. /**
  34749. * Put the sound in pause
  34750. */
  34751. pause(): void;
  34752. /**
  34753. * Sets a dedicated volume for this sounds
  34754. * @param newVolume Define the new volume of the sound
  34755. * @param time Define time for gradual change to new volume
  34756. */
  34757. setVolume(newVolume: number, time?: number): void;
  34758. /**
  34759. * Set the sound play back rate
  34760. * @param newPlaybackRate Define the playback rate the sound should be played at
  34761. */
  34762. setPlaybackRate(newPlaybackRate: number): void;
  34763. /**
  34764. * Gets the volume of the sound.
  34765. * @returns the volume of the sound
  34766. */
  34767. getVolume(): number;
  34768. /**
  34769. * Attach the sound to a dedicated mesh
  34770. * @param transformNode The transform node to connect the sound with
  34771. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34772. */
  34773. attachToMesh(transformNode: TransformNode): void;
  34774. /**
  34775. * Detach the sound from the previously attached mesh
  34776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34777. */
  34778. detachFromMesh(): void;
  34779. private _onRegisterAfterWorldMatrixUpdate;
  34780. /**
  34781. * Clone the current sound in the scene.
  34782. * @returns the new sound clone
  34783. */
  34784. clone(): Nullable<Sound>;
  34785. /**
  34786. * Gets the current underlying audio buffer containing the data
  34787. * @returns the audio buffer
  34788. */
  34789. getAudioBuffer(): Nullable<AudioBuffer>;
  34790. /**
  34791. * Serializes the Sound in a JSON representation
  34792. * @returns the JSON representation of the sound
  34793. */
  34794. serialize(): any;
  34795. /**
  34796. * Parse a JSON representation of a sound to innstantiate in a given scene
  34797. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34798. * @param scene Define the scene the new parsed sound should be created in
  34799. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34800. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34801. * @returns the newly parsed sound
  34802. */
  34803. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34804. }
  34805. }
  34806. declare module BABYLON {
  34807. /**
  34808. * This defines an action helpful to play a defined sound on a triggered action.
  34809. */
  34810. export class PlaySoundAction extends Action {
  34811. private _sound;
  34812. /**
  34813. * Instantiate the action
  34814. * @param triggerOptions defines the trigger options
  34815. * @param sound defines the sound to play
  34816. * @param condition defines the trigger related conditions
  34817. */
  34818. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34819. /** @hidden */
  34820. _prepare(): void;
  34821. /**
  34822. * Execute the action and play the sound.
  34823. */
  34824. execute(): void;
  34825. /**
  34826. * Serializes the actions and its related information.
  34827. * @param parent defines the object to serialize in
  34828. * @returns the serialized object
  34829. */
  34830. serialize(parent: any): any;
  34831. }
  34832. /**
  34833. * This defines an action helpful to stop a defined sound on a triggered action.
  34834. */
  34835. export class StopSoundAction extends Action {
  34836. private _sound;
  34837. /**
  34838. * Instantiate the action
  34839. * @param triggerOptions defines the trigger options
  34840. * @param sound defines the sound to stop
  34841. * @param condition defines the trigger related conditions
  34842. */
  34843. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34844. /** @hidden */
  34845. _prepare(): void;
  34846. /**
  34847. * Execute the action and stop the sound.
  34848. */
  34849. execute(): void;
  34850. /**
  34851. * Serializes the actions and its related information.
  34852. * @param parent defines the object to serialize in
  34853. * @returns the serialized object
  34854. */
  34855. serialize(parent: any): any;
  34856. }
  34857. }
  34858. declare module BABYLON {
  34859. /**
  34860. * This defines an action responsible to change the value of a property
  34861. * by interpolating between its current value and the newly set one once triggered.
  34862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34863. */
  34864. export class InterpolateValueAction extends Action {
  34865. /**
  34866. * Defines the path of the property where the value should be interpolated
  34867. */
  34868. propertyPath: string;
  34869. /**
  34870. * Defines the target value at the end of the interpolation.
  34871. */
  34872. value: any;
  34873. /**
  34874. * Defines the time it will take for the property to interpolate to the value.
  34875. */
  34876. duration: number;
  34877. /**
  34878. * Defines if the other scene animations should be stopped when the action has been triggered
  34879. */
  34880. stopOtherAnimations?: boolean;
  34881. /**
  34882. * Defines a callback raised once the interpolation animation has been done.
  34883. */
  34884. onInterpolationDone?: () => void;
  34885. /**
  34886. * Observable triggered once the interpolation animation has been done.
  34887. */
  34888. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34889. private _target;
  34890. private _effectiveTarget;
  34891. private _property;
  34892. /**
  34893. * Instantiate the action
  34894. * @param triggerOptions defines the trigger options
  34895. * @param target defines the object containing the value to interpolate
  34896. * @param propertyPath defines the path to the property in the target object
  34897. * @param value defines the target value at the end of the interpolation
  34898. * @param duration deines the time it will take for the property to interpolate to the value.
  34899. * @param condition defines the trigger related conditions
  34900. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34901. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34902. */
  34903. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34904. /** @hidden */
  34905. _prepare(): void;
  34906. /**
  34907. * Execute the action starts the value interpolation.
  34908. */
  34909. execute(): void;
  34910. /**
  34911. * Serializes the actions and its related information.
  34912. * @param parent defines the object to serialize in
  34913. * @returns the serialized object
  34914. */
  34915. serialize(parent: any): any;
  34916. }
  34917. }
  34918. declare module BABYLON {
  34919. /**
  34920. * Options allowed during the creation of a sound track.
  34921. */
  34922. export interface ISoundTrackOptions {
  34923. /**
  34924. * The volume the sound track should take during creation
  34925. */
  34926. volume?: number;
  34927. /**
  34928. * Define if the sound track is the main sound track of the scene
  34929. */
  34930. mainTrack?: boolean;
  34931. }
  34932. /**
  34933. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34934. * It will be also used in a future release to apply effects on a specific track.
  34935. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34936. */
  34937. export class SoundTrack {
  34938. /**
  34939. * The unique identifier of the sound track in the scene.
  34940. */
  34941. id: number;
  34942. /**
  34943. * The list of sounds included in the sound track.
  34944. */
  34945. soundCollection: Array<Sound>;
  34946. private _outputAudioNode;
  34947. private _scene;
  34948. private _isMainTrack;
  34949. private _connectedAnalyser;
  34950. private _options;
  34951. private _isInitialized;
  34952. /**
  34953. * Creates a new sound track.
  34954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34955. * @param scene Define the scene the sound track belongs to
  34956. * @param options
  34957. */
  34958. constructor(scene: Scene, options?: ISoundTrackOptions);
  34959. private _initializeSoundTrackAudioGraph;
  34960. /**
  34961. * Release the sound track and its associated resources
  34962. */
  34963. dispose(): void;
  34964. /**
  34965. * Adds a sound to this sound track
  34966. * @param sound define the cound to add
  34967. * @ignoreNaming
  34968. */
  34969. AddSound(sound: Sound): void;
  34970. /**
  34971. * Removes a sound to this sound track
  34972. * @param sound define the cound to remove
  34973. * @ignoreNaming
  34974. */
  34975. RemoveSound(sound: Sound): void;
  34976. /**
  34977. * Set a global volume for the full sound track.
  34978. * @param newVolume Define the new volume of the sound track
  34979. */
  34980. setVolume(newVolume: number): void;
  34981. /**
  34982. * Switch the panning model to HRTF:
  34983. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34985. */
  34986. switchPanningModelToHRTF(): void;
  34987. /**
  34988. * Switch the panning model to Equal Power:
  34989. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34991. */
  34992. switchPanningModelToEqualPower(): void;
  34993. /**
  34994. * Connect the sound track to an audio analyser allowing some amazing
  34995. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34997. * @param analyser The analyser to connect to the engine
  34998. */
  34999. connectToAnalyser(analyser: Analyser): void;
  35000. }
  35001. }
  35002. declare module BABYLON {
  35003. interface AbstractScene {
  35004. /**
  35005. * The list of sounds used in the scene.
  35006. */
  35007. sounds: Nullable<Array<Sound>>;
  35008. }
  35009. interface Scene {
  35010. /**
  35011. * @hidden
  35012. * Backing field
  35013. */
  35014. _mainSoundTrack: SoundTrack;
  35015. /**
  35016. * The main sound track played by the scene.
  35017. * It cotains your primary collection of sounds.
  35018. */
  35019. mainSoundTrack: SoundTrack;
  35020. /**
  35021. * The list of sound tracks added to the scene
  35022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35023. */
  35024. soundTracks: Nullable<Array<SoundTrack>>;
  35025. /**
  35026. * Gets a sound using a given name
  35027. * @param name defines the name to search for
  35028. * @return the found sound or null if not found at all.
  35029. */
  35030. getSoundByName(name: string): Nullable<Sound>;
  35031. /**
  35032. * Gets or sets if audio support is enabled
  35033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35034. */
  35035. audioEnabled: boolean;
  35036. /**
  35037. * Gets or sets if audio will be output to headphones
  35038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35039. */
  35040. headphone: boolean;
  35041. }
  35042. /**
  35043. * Defines the sound scene component responsible to manage any sounds
  35044. * in a given scene.
  35045. */
  35046. export class AudioSceneComponent implements ISceneSerializableComponent {
  35047. /**
  35048. * The component name helpfull to identify the component in the list of scene components.
  35049. */
  35050. readonly name: string;
  35051. /**
  35052. * The scene the component belongs to.
  35053. */
  35054. scene: Scene;
  35055. private _audioEnabled;
  35056. /**
  35057. * Gets whether audio is enabled or not.
  35058. * Please use related enable/disable method to switch state.
  35059. */
  35060. readonly audioEnabled: boolean;
  35061. private _headphone;
  35062. /**
  35063. * Gets whether audio is outputing to headphone or not.
  35064. * Please use the according Switch methods to change output.
  35065. */
  35066. readonly headphone: boolean;
  35067. /**
  35068. * Creates a new instance of the component for the given scene
  35069. * @param scene Defines the scene to register the component in
  35070. */
  35071. constructor(scene: Scene);
  35072. /**
  35073. * Registers the component in a given scene
  35074. */
  35075. register(): void;
  35076. /**
  35077. * Rebuilds the elements related to this component in case of
  35078. * context lost for instance.
  35079. */
  35080. rebuild(): void;
  35081. /**
  35082. * Serializes the component data to the specified json object
  35083. * @param serializationObject The object to serialize to
  35084. */
  35085. serialize(serializationObject: any): void;
  35086. /**
  35087. * Adds all the elements from the container to the scene
  35088. * @param container the container holding the elements
  35089. */
  35090. addFromContainer(container: AbstractScene): void;
  35091. /**
  35092. * Removes all the elements in the container from the scene
  35093. * @param container contains the elements to remove
  35094. * @param dispose if the removed element should be disposed (default: false)
  35095. */
  35096. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35097. /**
  35098. * Disposes the component and the associated ressources.
  35099. */
  35100. dispose(): void;
  35101. /**
  35102. * Disables audio in the associated scene.
  35103. */
  35104. disableAudio(): void;
  35105. /**
  35106. * Enables audio in the associated scene.
  35107. */
  35108. enableAudio(): void;
  35109. /**
  35110. * Switch audio to headphone output.
  35111. */
  35112. switchAudioModeForHeadphones(): void;
  35113. /**
  35114. * Switch audio to normal speakers.
  35115. */
  35116. switchAudioModeForNormalSpeakers(): void;
  35117. private _afterRender;
  35118. }
  35119. }
  35120. declare module BABYLON {
  35121. /**
  35122. * Wraps one or more Sound objects and selects one with random weight for playback.
  35123. */
  35124. export class WeightedSound {
  35125. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35126. loop: boolean;
  35127. private _coneInnerAngle;
  35128. private _coneOuterAngle;
  35129. private _volume;
  35130. /** A Sound is currently playing. */
  35131. isPlaying: boolean;
  35132. /** A Sound is currently paused. */
  35133. isPaused: boolean;
  35134. private _sounds;
  35135. private _weights;
  35136. private _currentIndex?;
  35137. /**
  35138. * Creates a new WeightedSound from the list of sounds given.
  35139. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35140. * @param sounds Array of Sounds that will be selected from.
  35141. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35142. */
  35143. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35144. /**
  35145. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35146. */
  35147. /**
  35148. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35149. */
  35150. directionalConeInnerAngle: number;
  35151. /**
  35152. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35153. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35154. */
  35155. /**
  35156. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35157. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35158. */
  35159. directionalConeOuterAngle: number;
  35160. /**
  35161. * Playback volume.
  35162. */
  35163. /**
  35164. * Playback volume.
  35165. */
  35166. volume: number;
  35167. private _onended;
  35168. /**
  35169. * Suspend playback
  35170. */
  35171. pause(): void;
  35172. /**
  35173. * Stop playback
  35174. */
  35175. stop(): void;
  35176. /**
  35177. * Start playback.
  35178. * @param startOffset Position the clip head at a specific time in seconds.
  35179. */
  35180. play(startOffset?: number): void;
  35181. }
  35182. }
  35183. declare module BABYLON {
  35184. /**
  35185. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35186. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35187. */
  35188. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35189. /**
  35190. * Gets the name of the behavior.
  35191. */
  35192. readonly name: string;
  35193. /**
  35194. * The easing function used by animations
  35195. */
  35196. static EasingFunction: BackEase;
  35197. /**
  35198. * The easing mode used by animations
  35199. */
  35200. static EasingMode: number;
  35201. /**
  35202. * The duration of the animation, in milliseconds
  35203. */
  35204. transitionDuration: number;
  35205. /**
  35206. * Length of the distance animated by the transition when lower radius is reached
  35207. */
  35208. lowerRadiusTransitionRange: number;
  35209. /**
  35210. * Length of the distance animated by the transition when upper radius is reached
  35211. */
  35212. upperRadiusTransitionRange: number;
  35213. private _autoTransitionRange;
  35214. /**
  35215. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35216. */
  35217. /**
  35218. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35219. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35220. */
  35221. autoTransitionRange: boolean;
  35222. private _attachedCamera;
  35223. private _onAfterCheckInputsObserver;
  35224. private _onMeshTargetChangedObserver;
  35225. /**
  35226. * Initializes the behavior.
  35227. */
  35228. init(): void;
  35229. /**
  35230. * Attaches the behavior to its arc rotate camera.
  35231. * @param camera Defines the camera to attach the behavior to
  35232. */
  35233. attach(camera: ArcRotateCamera): void;
  35234. /**
  35235. * Detaches the behavior from its current arc rotate camera.
  35236. */
  35237. detach(): void;
  35238. private _radiusIsAnimating;
  35239. private _radiusBounceTransition;
  35240. private _animatables;
  35241. private _cachedWheelPrecision;
  35242. /**
  35243. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35244. * @param radiusLimit The limit to check against.
  35245. * @return Bool to indicate if at limit.
  35246. */
  35247. private _isRadiusAtLimit;
  35248. /**
  35249. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35250. * @param radiusDelta The delta by which to animate to. Can be negative.
  35251. */
  35252. private _applyBoundRadiusAnimation;
  35253. /**
  35254. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35255. */
  35256. protected _clearAnimationLocks(): void;
  35257. /**
  35258. * Stops and removes all animations that have been applied to the camera
  35259. */
  35260. stopAllAnimations(): void;
  35261. }
  35262. }
  35263. declare module BABYLON {
  35264. /**
  35265. * 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.
  35266. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35267. */
  35268. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35269. /**
  35270. * Gets the name of the behavior.
  35271. */
  35272. readonly name: string;
  35273. private _mode;
  35274. private _radiusScale;
  35275. private _positionScale;
  35276. private _defaultElevation;
  35277. private _elevationReturnTime;
  35278. private _elevationReturnWaitTime;
  35279. private _zoomStopsAnimation;
  35280. private _framingTime;
  35281. /**
  35282. * The easing function used by animations
  35283. */
  35284. static EasingFunction: ExponentialEase;
  35285. /**
  35286. * The easing mode used by animations
  35287. */
  35288. static EasingMode: number;
  35289. /**
  35290. * Sets the current mode used by the behavior
  35291. */
  35292. /**
  35293. * Gets current mode used by the behavior.
  35294. */
  35295. mode: number;
  35296. /**
  35297. * Sets the scale applied to the radius (1 by default)
  35298. */
  35299. /**
  35300. * Gets the scale applied to the radius
  35301. */
  35302. radiusScale: number;
  35303. /**
  35304. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35305. */
  35306. /**
  35307. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35308. */
  35309. positionScale: number;
  35310. /**
  35311. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35312. * behaviour is triggered, in radians.
  35313. */
  35314. /**
  35315. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35316. * behaviour is triggered, in radians.
  35317. */
  35318. defaultElevation: number;
  35319. /**
  35320. * Sets the time (in milliseconds) taken to return to the default beta position.
  35321. * Negative value indicates camera should not return to default.
  35322. */
  35323. /**
  35324. * Gets the time (in milliseconds) taken to return to the default beta position.
  35325. * Negative value indicates camera should not return to default.
  35326. */
  35327. elevationReturnTime: number;
  35328. /**
  35329. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35330. */
  35331. /**
  35332. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35333. */
  35334. elevationReturnWaitTime: number;
  35335. /**
  35336. * Sets the flag that indicates if user zooming should stop animation.
  35337. */
  35338. /**
  35339. * Gets the flag that indicates if user zooming should stop animation.
  35340. */
  35341. zoomStopsAnimation: boolean;
  35342. /**
  35343. * Sets the transition time when framing the mesh, in milliseconds
  35344. */
  35345. /**
  35346. * Gets the transition time when framing the mesh, in milliseconds
  35347. */
  35348. framingTime: number;
  35349. /**
  35350. * Define if the behavior should automatically change the configured
  35351. * camera limits and sensibilities.
  35352. */
  35353. autoCorrectCameraLimitsAndSensibility: boolean;
  35354. private _onPrePointerObservableObserver;
  35355. private _onAfterCheckInputsObserver;
  35356. private _onMeshTargetChangedObserver;
  35357. private _attachedCamera;
  35358. private _isPointerDown;
  35359. private _lastInteractionTime;
  35360. /**
  35361. * Initializes the behavior.
  35362. */
  35363. init(): void;
  35364. /**
  35365. * Attaches the behavior to its arc rotate camera.
  35366. * @param camera Defines the camera to attach the behavior to
  35367. */
  35368. attach(camera: ArcRotateCamera): void;
  35369. /**
  35370. * Detaches the behavior from its current arc rotate camera.
  35371. */
  35372. detach(): void;
  35373. private _animatables;
  35374. private _betaIsAnimating;
  35375. private _betaTransition;
  35376. private _radiusTransition;
  35377. private _vectorTransition;
  35378. /**
  35379. * Targets the given mesh and updates zoom level accordingly.
  35380. * @param mesh The mesh to target.
  35381. * @param radius Optional. If a cached radius position already exists, overrides default.
  35382. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35383. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35384. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35385. */
  35386. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35387. /**
  35388. * Targets the given mesh with its children and updates zoom level accordingly.
  35389. * @param mesh The mesh to target.
  35390. * @param radius Optional. If a cached radius position already exists, overrides default.
  35391. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35392. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35393. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35394. */
  35395. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35396. /**
  35397. * Targets the given meshes with their children and updates zoom level accordingly.
  35398. * @param meshes The mesh to target.
  35399. * @param radius Optional. If a cached radius position already exists, overrides default.
  35400. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35401. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35402. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35403. */
  35404. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35405. /**
  35406. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35407. * @param minimumWorld Determines the smaller position of the bounding box extend
  35408. * @param maximumWorld Determines the bigger position of the bounding box extend
  35409. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35410. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35411. */
  35412. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35413. /**
  35414. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35415. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35416. * frustum width.
  35417. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35418. * to fully enclose the mesh in the viewing frustum.
  35419. */
  35420. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35421. /**
  35422. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35423. * is automatically returned to its default position (expected to be above ground plane).
  35424. */
  35425. private _maintainCameraAboveGround;
  35426. /**
  35427. * Returns the frustum slope based on the canvas ratio and camera FOV
  35428. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35429. */
  35430. private _getFrustumSlope;
  35431. /**
  35432. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35433. */
  35434. private _clearAnimationLocks;
  35435. /**
  35436. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35437. */
  35438. private _applyUserInteraction;
  35439. /**
  35440. * Stops and removes all animations that have been applied to the camera
  35441. */
  35442. stopAllAnimations(): void;
  35443. /**
  35444. * Gets a value indicating if the user is moving the camera
  35445. */
  35446. readonly isUserIsMoving: boolean;
  35447. /**
  35448. * The camera can move all the way towards the mesh.
  35449. */
  35450. static IgnoreBoundsSizeMode: number;
  35451. /**
  35452. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35453. */
  35454. static FitFrustumSidesMode: number;
  35455. }
  35456. }
  35457. declare module BABYLON {
  35458. /**
  35459. * Base class for Camera Pointer Inputs.
  35460. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35461. * for example usage.
  35462. */
  35463. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35464. /**
  35465. * Defines the camera the input is attached to.
  35466. */
  35467. abstract camera: Camera;
  35468. /**
  35469. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35470. */
  35471. protected _altKey: boolean;
  35472. protected _ctrlKey: boolean;
  35473. protected _metaKey: boolean;
  35474. protected _shiftKey: boolean;
  35475. /**
  35476. * Which mouse buttons were pressed at time of last mouse event.
  35477. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35478. */
  35479. protected _buttonsPressed: number;
  35480. /**
  35481. * Defines the buttons associated with the input to handle camera move.
  35482. */
  35483. buttons: number[];
  35484. /**
  35485. * Attach the input controls to a specific dom element to get the input from.
  35486. * @param element Defines the element the controls should be listened from
  35487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35488. */
  35489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35490. /**
  35491. * Detach the current controls from the specified dom element.
  35492. * @param element Defines the element to stop listening the inputs from
  35493. */
  35494. detachControl(element: Nullable<HTMLElement>): void;
  35495. /**
  35496. * Gets the class name of the current input.
  35497. * @returns the class name
  35498. */
  35499. getClassName(): string;
  35500. /**
  35501. * Get the friendly name associated with the input class.
  35502. * @returns the input friendly name
  35503. */
  35504. getSimpleName(): string;
  35505. /**
  35506. * Called on pointer POINTERDOUBLETAP event.
  35507. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35508. */
  35509. protected onDoubleTap(type: string): void;
  35510. /**
  35511. * Called on pointer POINTERMOVE event if only a single touch is active.
  35512. * Override this method to provide functionality.
  35513. */
  35514. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35515. /**
  35516. * Called on pointer POINTERMOVE event if multiple touches are active.
  35517. * Override this method to provide functionality.
  35518. */
  35519. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35520. /**
  35521. * Called on JS contextmenu event.
  35522. * Override this method to provide functionality.
  35523. */
  35524. protected onContextMenu(evt: PointerEvent): void;
  35525. /**
  35526. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35527. * press.
  35528. * Override this method to provide functionality.
  35529. */
  35530. protected onButtonDown(evt: PointerEvent): void;
  35531. /**
  35532. * Called each time a new POINTERUP event occurs. Ie, for each button
  35533. * release.
  35534. * Override this method to provide functionality.
  35535. */
  35536. protected onButtonUp(evt: PointerEvent): void;
  35537. /**
  35538. * Called when window becomes inactive.
  35539. * Override this method to provide functionality.
  35540. */
  35541. protected onLostFocus(): void;
  35542. private _pointerInput;
  35543. private _observer;
  35544. private _onLostFocus;
  35545. private pointA;
  35546. private pointB;
  35547. }
  35548. }
  35549. declare module BABYLON {
  35550. /**
  35551. * Manage the pointers inputs to control an arc rotate camera.
  35552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35553. */
  35554. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35555. /**
  35556. * Defines the camera the input is attached to.
  35557. */
  35558. camera: ArcRotateCamera;
  35559. /**
  35560. * Gets the class name of the current input.
  35561. * @returns the class name
  35562. */
  35563. getClassName(): string;
  35564. /**
  35565. * Defines the buttons associated with the input to handle camera move.
  35566. */
  35567. buttons: number[];
  35568. /**
  35569. * Defines the pointer angular sensibility along the X axis or how fast is
  35570. * the camera rotating.
  35571. */
  35572. angularSensibilityX: number;
  35573. /**
  35574. * Defines the pointer angular sensibility along the Y axis or how fast is
  35575. * the camera rotating.
  35576. */
  35577. angularSensibilityY: number;
  35578. /**
  35579. * Defines the pointer pinch precision or how fast is the camera zooming.
  35580. */
  35581. pinchPrecision: number;
  35582. /**
  35583. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35584. * from 0.
  35585. * It defines the percentage of current camera.radius to use as delta when
  35586. * pinch zoom is used.
  35587. */
  35588. pinchDeltaPercentage: number;
  35589. /**
  35590. * Defines the pointer panning sensibility or how fast is the camera moving.
  35591. */
  35592. panningSensibility: number;
  35593. /**
  35594. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35595. */
  35596. multiTouchPanning: boolean;
  35597. /**
  35598. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35599. * zoom (pinch) through multitouch.
  35600. */
  35601. multiTouchPanAndZoom: boolean;
  35602. /**
  35603. * Revers pinch action direction.
  35604. */
  35605. pinchInwards: boolean;
  35606. private _isPanClick;
  35607. private _twoFingerActivityCount;
  35608. private _isPinching;
  35609. /**
  35610. * Called on pointer POINTERMOVE event if only a single touch is active.
  35611. */
  35612. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35613. /**
  35614. * Called on pointer POINTERDOUBLETAP event.
  35615. */
  35616. protected onDoubleTap(type: string): void;
  35617. /**
  35618. * Called on pointer POINTERMOVE event if multiple touches are active.
  35619. */
  35620. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35621. /**
  35622. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35623. * press.
  35624. */
  35625. protected onButtonDown(evt: PointerEvent): void;
  35626. /**
  35627. * Called each time a new POINTERUP event occurs. Ie, for each button
  35628. * release.
  35629. */
  35630. protected onButtonUp(evt: PointerEvent): void;
  35631. /**
  35632. * Called when window becomes inactive.
  35633. */
  35634. protected onLostFocus(): void;
  35635. }
  35636. }
  35637. declare module BABYLON {
  35638. /**
  35639. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35641. */
  35642. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35643. /**
  35644. * Defines the camera the input is attached to.
  35645. */
  35646. camera: ArcRotateCamera;
  35647. /**
  35648. * Defines the list of key codes associated with the up action (increase alpha)
  35649. */
  35650. keysUp: number[];
  35651. /**
  35652. * Defines the list of key codes associated with the down action (decrease alpha)
  35653. */
  35654. keysDown: number[];
  35655. /**
  35656. * Defines the list of key codes associated with the left action (increase beta)
  35657. */
  35658. keysLeft: number[];
  35659. /**
  35660. * Defines the list of key codes associated with the right action (decrease beta)
  35661. */
  35662. keysRight: number[];
  35663. /**
  35664. * Defines the list of key codes associated with the reset action.
  35665. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35666. */
  35667. keysReset: number[];
  35668. /**
  35669. * Defines the panning sensibility of the inputs.
  35670. * (How fast is the camera paning)
  35671. */
  35672. panningSensibility: number;
  35673. /**
  35674. * Defines the zooming sensibility of the inputs.
  35675. * (How fast is the camera zooming)
  35676. */
  35677. zoomingSensibility: number;
  35678. /**
  35679. * Defines wether maintaining the alt key down switch the movement mode from
  35680. * orientation to zoom.
  35681. */
  35682. useAltToZoom: boolean;
  35683. /**
  35684. * Rotation speed of the camera
  35685. */
  35686. angularSpeed: number;
  35687. private _keys;
  35688. private _ctrlPressed;
  35689. private _altPressed;
  35690. private _onCanvasBlurObserver;
  35691. private _onKeyboardObserver;
  35692. private _engine;
  35693. private _scene;
  35694. /**
  35695. * Attach the input controls to a specific dom element to get the input from.
  35696. * @param element Defines the element the controls should be listened from
  35697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35698. */
  35699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35700. /**
  35701. * Detach the current controls from the specified dom element.
  35702. * @param element Defines the element to stop listening the inputs from
  35703. */
  35704. detachControl(element: Nullable<HTMLElement>): void;
  35705. /**
  35706. * Update the current camera state depending on the inputs that have been used this frame.
  35707. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35708. */
  35709. checkInputs(): void;
  35710. /**
  35711. * Gets the class name of the current intput.
  35712. * @returns the class name
  35713. */
  35714. getClassName(): string;
  35715. /**
  35716. * Get the friendly name associated with the input class.
  35717. * @returns the input friendly name
  35718. */
  35719. getSimpleName(): string;
  35720. }
  35721. }
  35722. declare module BABYLON {
  35723. /**
  35724. * Manage the mouse wheel inputs to control an arc rotate camera.
  35725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35726. */
  35727. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35728. /**
  35729. * Defines the camera the input is attached to.
  35730. */
  35731. camera: ArcRotateCamera;
  35732. /**
  35733. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35734. */
  35735. wheelPrecision: number;
  35736. /**
  35737. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35738. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35739. */
  35740. wheelDeltaPercentage: number;
  35741. private _wheel;
  35742. private _observer;
  35743. private computeDeltaFromMouseWheelLegacyEvent;
  35744. /**
  35745. * Attach the input controls to a specific dom element to get the input from.
  35746. * @param element Defines the element the controls should be listened from
  35747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35748. */
  35749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35750. /**
  35751. * Detach the current controls from the specified dom element.
  35752. * @param element Defines the element to stop listening the inputs from
  35753. */
  35754. detachControl(element: Nullable<HTMLElement>): void;
  35755. /**
  35756. * Gets the class name of the current intput.
  35757. * @returns the class name
  35758. */
  35759. getClassName(): string;
  35760. /**
  35761. * Get the friendly name associated with the input class.
  35762. * @returns the input friendly name
  35763. */
  35764. getSimpleName(): string;
  35765. }
  35766. }
  35767. declare module BABYLON {
  35768. /**
  35769. * Default Inputs manager for the ArcRotateCamera.
  35770. * It groups all the default supported inputs for ease of use.
  35771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35772. */
  35773. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35774. /**
  35775. * Instantiates a new ArcRotateCameraInputsManager.
  35776. * @param camera Defines the camera the inputs belong to
  35777. */
  35778. constructor(camera: ArcRotateCamera);
  35779. /**
  35780. * Add mouse wheel input support to the input manager.
  35781. * @returns the current input manager
  35782. */
  35783. addMouseWheel(): ArcRotateCameraInputsManager;
  35784. /**
  35785. * Add pointers input support to the input manager.
  35786. * @returns the current input manager
  35787. */
  35788. addPointers(): ArcRotateCameraInputsManager;
  35789. /**
  35790. * Add keyboard input support to the input manager.
  35791. * @returns the current input manager
  35792. */
  35793. addKeyboard(): ArcRotateCameraInputsManager;
  35794. }
  35795. }
  35796. declare module BABYLON {
  35797. /**
  35798. * This represents an orbital type of camera.
  35799. *
  35800. * 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.
  35801. * 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.
  35802. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35803. */
  35804. export class ArcRotateCamera extends TargetCamera {
  35805. /**
  35806. * Defines the rotation angle of the camera along the longitudinal axis.
  35807. */
  35808. alpha: number;
  35809. /**
  35810. * Defines the rotation angle of the camera along the latitudinal axis.
  35811. */
  35812. beta: number;
  35813. /**
  35814. * Defines the radius of the camera from it s target point.
  35815. */
  35816. radius: number;
  35817. protected _target: Vector3;
  35818. protected _targetHost: Nullable<AbstractMesh>;
  35819. /**
  35820. * Defines the target point of the camera.
  35821. * The camera looks towards it form the radius distance.
  35822. */
  35823. target: Vector3;
  35824. /**
  35825. * Define the current local position of the camera in the scene
  35826. */
  35827. position: Vector3;
  35828. protected _upVector: Vector3;
  35829. protected _upToYMatrix: Matrix;
  35830. protected _YToUpMatrix: Matrix;
  35831. /**
  35832. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35833. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35834. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35835. */
  35836. upVector: Vector3;
  35837. /**
  35838. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35839. */
  35840. setMatUp(): void;
  35841. /**
  35842. * Current inertia value on the longitudinal axis.
  35843. * The bigger this number the longer it will take for the camera to stop.
  35844. */
  35845. inertialAlphaOffset: number;
  35846. /**
  35847. * Current inertia value on the latitudinal axis.
  35848. * The bigger this number the longer it will take for the camera to stop.
  35849. */
  35850. inertialBetaOffset: number;
  35851. /**
  35852. * Current inertia value on the radius axis.
  35853. * The bigger this number the longer it will take for the camera to stop.
  35854. */
  35855. inertialRadiusOffset: number;
  35856. /**
  35857. * Minimum allowed angle on the longitudinal axis.
  35858. * This can help limiting how the Camera is able to move in the scene.
  35859. */
  35860. lowerAlphaLimit: Nullable<number>;
  35861. /**
  35862. * Maximum allowed angle on the longitudinal axis.
  35863. * This can help limiting how the Camera is able to move in the scene.
  35864. */
  35865. upperAlphaLimit: Nullable<number>;
  35866. /**
  35867. * Minimum allowed angle on the latitudinal axis.
  35868. * This can help limiting how the Camera is able to move in the scene.
  35869. */
  35870. lowerBetaLimit: number;
  35871. /**
  35872. * Maximum allowed angle on the latitudinal axis.
  35873. * This can help limiting how the Camera is able to move in the scene.
  35874. */
  35875. upperBetaLimit: number;
  35876. /**
  35877. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35878. * This can help limiting how the Camera is able to move in the scene.
  35879. */
  35880. lowerRadiusLimit: Nullable<number>;
  35881. /**
  35882. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35883. * This can help limiting how the Camera is able to move in the scene.
  35884. */
  35885. upperRadiusLimit: Nullable<number>;
  35886. /**
  35887. * Defines the current inertia value used during panning of the camera along the X axis.
  35888. */
  35889. inertialPanningX: number;
  35890. /**
  35891. * Defines the current inertia value used during panning of the camera along the Y axis.
  35892. */
  35893. inertialPanningY: number;
  35894. /**
  35895. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35896. * Basically if your fingers moves away from more than this distance you will be considered
  35897. * in pinch mode.
  35898. */
  35899. pinchToPanMaxDistance: number;
  35900. /**
  35901. * Defines the maximum distance the camera can pan.
  35902. * This could help keeping the cammera always in your scene.
  35903. */
  35904. panningDistanceLimit: Nullable<number>;
  35905. /**
  35906. * Defines the target of the camera before paning.
  35907. */
  35908. panningOriginTarget: Vector3;
  35909. /**
  35910. * Defines the value of the inertia used during panning.
  35911. * 0 would mean stop inertia and one would mean no decelleration at all.
  35912. */
  35913. panningInertia: number;
  35914. /**
  35915. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35916. */
  35917. angularSensibilityX: number;
  35918. /**
  35919. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35920. */
  35921. angularSensibilityY: number;
  35922. /**
  35923. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35924. */
  35925. pinchPrecision: number;
  35926. /**
  35927. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35928. * It will be used instead of pinchDeltaPrecision if different from 0.
  35929. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35930. */
  35931. pinchDeltaPercentage: number;
  35932. /**
  35933. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35934. */
  35935. panningSensibility: number;
  35936. /**
  35937. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35938. */
  35939. keysUp: number[];
  35940. /**
  35941. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35942. */
  35943. keysDown: number[];
  35944. /**
  35945. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35946. */
  35947. keysLeft: number[];
  35948. /**
  35949. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35950. */
  35951. keysRight: number[];
  35952. /**
  35953. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35954. */
  35955. wheelPrecision: number;
  35956. /**
  35957. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35958. * It will be used instead of pinchDeltaPrecision if different from 0.
  35959. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35960. */
  35961. wheelDeltaPercentage: number;
  35962. /**
  35963. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35964. */
  35965. zoomOnFactor: number;
  35966. /**
  35967. * Defines a screen offset for the camera position.
  35968. */
  35969. targetScreenOffset: Vector2;
  35970. /**
  35971. * Allows the camera to be completely reversed.
  35972. * If false the camera can not arrive upside down.
  35973. */
  35974. allowUpsideDown: boolean;
  35975. /**
  35976. * Define if double tap/click is used to restore the previously saved state of the camera.
  35977. */
  35978. useInputToRestoreState: boolean;
  35979. /** @hidden */
  35980. _viewMatrix: Matrix;
  35981. /** @hidden */
  35982. _useCtrlForPanning: boolean;
  35983. /** @hidden */
  35984. _panningMouseButton: number;
  35985. /**
  35986. * Defines the input associated to the camera.
  35987. */
  35988. inputs: ArcRotateCameraInputsManager;
  35989. /** @hidden */
  35990. _reset: () => void;
  35991. /**
  35992. * Defines the allowed panning axis.
  35993. */
  35994. panningAxis: Vector3;
  35995. protected _localDirection: Vector3;
  35996. protected _transformedDirection: Vector3;
  35997. private _bouncingBehavior;
  35998. /**
  35999. * Gets the bouncing behavior of the camera if it has been enabled.
  36000. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36001. */
  36002. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36003. /**
  36004. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36005. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36006. */
  36007. useBouncingBehavior: boolean;
  36008. private _framingBehavior;
  36009. /**
  36010. * Gets the framing behavior of the camera if it has been enabled.
  36011. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36012. */
  36013. readonly framingBehavior: Nullable<FramingBehavior>;
  36014. /**
  36015. * Defines if the framing behavior of the camera is enabled on the camera.
  36016. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36017. */
  36018. useFramingBehavior: boolean;
  36019. private _autoRotationBehavior;
  36020. /**
  36021. * Gets the auto rotation behavior of the camera if it has been enabled.
  36022. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36023. */
  36024. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36025. /**
  36026. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36027. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36028. */
  36029. useAutoRotationBehavior: boolean;
  36030. /**
  36031. * Observable triggered when the mesh target has been changed on the camera.
  36032. */
  36033. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36034. /**
  36035. * Event raised when the camera is colliding with a mesh.
  36036. */
  36037. onCollide: (collidedMesh: AbstractMesh) => void;
  36038. /**
  36039. * Defines whether the camera should check collision with the objects oh the scene.
  36040. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36041. */
  36042. checkCollisions: boolean;
  36043. /**
  36044. * Defines the collision radius of the camera.
  36045. * This simulates a sphere around the camera.
  36046. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36047. */
  36048. collisionRadius: Vector3;
  36049. protected _collider: Collider;
  36050. protected _previousPosition: Vector3;
  36051. protected _collisionVelocity: Vector3;
  36052. protected _newPosition: Vector3;
  36053. protected _previousAlpha: number;
  36054. protected _previousBeta: number;
  36055. protected _previousRadius: number;
  36056. protected _collisionTriggered: boolean;
  36057. protected _targetBoundingCenter: Nullable<Vector3>;
  36058. private _computationVector;
  36059. /**
  36060. * Instantiates a new ArcRotateCamera in a given scene
  36061. * @param name Defines the name of the camera
  36062. * @param alpha Defines the camera rotation along the logitudinal axis
  36063. * @param beta Defines the camera rotation along the latitudinal axis
  36064. * @param radius Defines the camera distance from its target
  36065. * @param target Defines the camera target
  36066. * @param scene Defines the scene the camera belongs to
  36067. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36068. */
  36069. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36070. /** @hidden */
  36071. _initCache(): void;
  36072. /** @hidden */
  36073. _updateCache(ignoreParentClass?: boolean): void;
  36074. protected _getTargetPosition(): Vector3;
  36075. private _storedAlpha;
  36076. private _storedBeta;
  36077. private _storedRadius;
  36078. private _storedTarget;
  36079. /**
  36080. * Stores the current state of the camera (alpha, beta, radius and target)
  36081. * @returns the camera itself
  36082. */
  36083. storeState(): Camera;
  36084. /**
  36085. * @hidden
  36086. * Restored camera state. You must call storeState() first
  36087. */
  36088. _restoreStateValues(): boolean;
  36089. /** @hidden */
  36090. _isSynchronizedViewMatrix(): boolean;
  36091. /**
  36092. * Attached controls to the current camera.
  36093. * @param element Defines the element the controls should be listened from
  36094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36095. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36096. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36097. */
  36098. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36099. /**
  36100. * Detach the current controls from the camera.
  36101. * The camera will stop reacting to inputs.
  36102. * @param element Defines the element to stop listening the inputs from
  36103. */
  36104. detachControl(element: HTMLElement): void;
  36105. /** @hidden */
  36106. _checkInputs(): void;
  36107. protected _checkLimits(): void;
  36108. /**
  36109. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36110. */
  36111. rebuildAnglesAndRadius(): void;
  36112. /**
  36113. * Use a position to define the current camera related information like aplha, beta and radius
  36114. * @param position Defines the position to set the camera at
  36115. */
  36116. setPosition(position: Vector3): void;
  36117. /**
  36118. * Defines the target the camera should look at.
  36119. * This will automatically adapt alpha beta and radius to fit within the new target.
  36120. * @param target Defines the new target as a Vector or a mesh
  36121. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36122. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36123. */
  36124. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36125. /** @hidden */
  36126. _getViewMatrix(): Matrix;
  36127. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36128. /**
  36129. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36130. * @param meshes Defines the mesh to zoom on
  36131. * @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)
  36132. */
  36133. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36134. /**
  36135. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36136. * The target will be changed but the radius
  36137. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36138. * @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)
  36139. */
  36140. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36141. min: Vector3;
  36142. max: Vector3;
  36143. distance: number;
  36144. }, doNotUpdateMaxZ?: boolean): void;
  36145. /**
  36146. * @override
  36147. * Override Camera.createRigCamera
  36148. */
  36149. createRigCamera(name: string, cameraIndex: number): Camera;
  36150. /**
  36151. * @hidden
  36152. * @override
  36153. * Override Camera._updateRigCameras
  36154. */
  36155. _updateRigCameras(): void;
  36156. /**
  36157. * Destroy the camera and release the current resources hold by it.
  36158. */
  36159. dispose(): void;
  36160. /**
  36161. * Gets the current object class name.
  36162. * @return the class name
  36163. */
  36164. getClassName(): string;
  36165. }
  36166. }
  36167. declare module BABYLON {
  36168. /**
  36169. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36170. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36171. */
  36172. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36173. /**
  36174. * Gets the name of the behavior.
  36175. */
  36176. readonly name: string;
  36177. private _zoomStopsAnimation;
  36178. private _idleRotationSpeed;
  36179. private _idleRotationWaitTime;
  36180. private _idleRotationSpinupTime;
  36181. /**
  36182. * Sets the flag that indicates if user zooming should stop animation.
  36183. */
  36184. /**
  36185. * Gets the flag that indicates if user zooming should stop animation.
  36186. */
  36187. zoomStopsAnimation: boolean;
  36188. /**
  36189. * Sets the default speed at which the camera rotates around the model.
  36190. */
  36191. /**
  36192. * Gets the default speed at which the camera rotates around the model.
  36193. */
  36194. idleRotationSpeed: number;
  36195. /**
  36196. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36197. */
  36198. /**
  36199. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36200. */
  36201. idleRotationWaitTime: number;
  36202. /**
  36203. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36204. */
  36205. /**
  36206. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36207. */
  36208. idleRotationSpinupTime: number;
  36209. /**
  36210. * Gets a value indicating if the camera is currently rotating because of this behavior
  36211. */
  36212. readonly rotationInProgress: boolean;
  36213. private _onPrePointerObservableObserver;
  36214. private _onAfterCheckInputsObserver;
  36215. private _attachedCamera;
  36216. private _isPointerDown;
  36217. private _lastFrameTime;
  36218. private _lastInteractionTime;
  36219. private _cameraRotationSpeed;
  36220. /**
  36221. * Initializes the behavior.
  36222. */
  36223. init(): void;
  36224. /**
  36225. * Attaches the behavior to its arc rotate camera.
  36226. * @param camera Defines the camera to attach the behavior to
  36227. */
  36228. attach(camera: ArcRotateCamera): void;
  36229. /**
  36230. * Detaches the behavior from its current arc rotate camera.
  36231. */
  36232. detach(): void;
  36233. /**
  36234. * Returns true if user is scrolling.
  36235. * @return true if user is scrolling.
  36236. */
  36237. private _userIsZooming;
  36238. private _lastFrameRadius;
  36239. private _shouldAnimationStopForInteraction;
  36240. /**
  36241. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36242. */
  36243. private _applyUserInteraction;
  36244. private _userIsMoving;
  36245. }
  36246. }
  36247. declare module BABYLON {
  36248. /**
  36249. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36250. */
  36251. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36252. private ui;
  36253. /**
  36254. * The name of the behavior
  36255. */
  36256. name: string;
  36257. /**
  36258. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36259. */
  36260. distanceAwayFromFace: number;
  36261. /**
  36262. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36263. */
  36264. distanceAwayFromBottomOfFace: number;
  36265. private _faceVectors;
  36266. private _target;
  36267. private _scene;
  36268. private _onRenderObserver;
  36269. private _tmpMatrix;
  36270. private _tmpVector;
  36271. /**
  36272. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36273. * @param ui The transform node that should be attched to the mesh
  36274. */
  36275. constructor(ui: TransformNode);
  36276. /**
  36277. * Initializes the behavior
  36278. */
  36279. init(): void;
  36280. private _closestFace;
  36281. private _zeroVector;
  36282. private _lookAtTmpMatrix;
  36283. private _lookAtToRef;
  36284. /**
  36285. * Attaches the AttachToBoxBehavior to the passed in mesh
  36286. * @param target The mesh that the specified node will be attached to
  36287. */
  36288. attach(target: Mesh): void;
  36289. /**
  36290. * Detaches the behavior from the mesh
  36291. */
  36292. detach(): void;
  36293. }
  36294. }
  36295. declare module BABYLON {
  36296. /**
  36297. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36298. */
  36299. export class FadeInOutBehavior implements Behavior<Mesh> {
  36300. /**
  36301. * Time in milliseconds to delay before fading in (Default: 0)
  36302. */
  36303. delay: number;
  36304. /**
  36305. * Time in milliseconds for the mesh to fade in (Default: 300)
  36306. */
  36307. fadeInTime: number;
  36308. private _millisecondsPerFrame;
  36309. private _hovered;
  36310. private _hoverValue;
  36311. private _ownerNode;
  36312. /**
  36313. * Instatiates the FadeInOutBehavior
  36314. */
  36315. constructor();
  36316. /**
  36317. * The name of the behavior
  36318. */
  36319. readonly name: string;
  36320. /**
  36321. * Initializes the behavior
  36322. */
  36323. init(): void;
  36324. /**
  36325. * Attaches the fade behavior on the passed in mesh
  36326. * @param ownerNode The mesh that will be faded in/out once attached
  36327. */
  36328. attach(ownerNode: Mesh): void;
  36329. /**
  36330. * Detaches the behavior from the mesh
  36331. */
  36332. detach(): void;
  36333. /**
  36334. * Triggers the mesh to begin fading in or out
  36335. * @param value if the object should fade in or out (true to fade in)
  36336. */
  36337. fadeIn(value: boolean): void;
  36338. private _update;
  36339. private _setAllVisibility;
  36340. }
  36341. }
  36342. declare module BABYLON {
  36343. /**
  36344. * Class containing a set of static utilities functions for managing Pivots
  36345. * @hidden
  36346. */
  36347. export class PivotTools {
  36348. private static _PivotCached;
  36349. private static _OldPivotPoint;
  36350. private static _PivotTranslation;
  36351. private static _PivotTmpVector;
  36352. /** @hidden */
  36353. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36354. /** @hidden */
  36355. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36356. }
  36357. }
  36358. declare module BABYLON {
  36359. /**
  36360. * Class containing static functions to help procedurally build meshes
  36361. */
  36362. export class PlaneBuilder {
  36363. /**
  36364. * Creates a plane mesh
  36365. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36366. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36367. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36369. * * 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
  36370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36371. * @param name defines the name of the mesh
  36372. * @param options defines the options used to create the mesh
  36373. * @param scene defines the hosting scene
  36374. * @returns the plane mesh
  36375. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36376. */
  36377. static CreatePlane(name: string, options: {
  36378. size?: number;
  36379. width?: number;
  36380. height?: number;
  36381. sideOrientation?: number;
  36382. frontUVs?: Vector4;
  36383. backUVs?: Vector4;
  36384. updatable?: boolean;
  36385. sourcePlane?: Plane;
  36386. }, scene?: Nullable<Scene>): Mesh;
  36387. }
  36388. }
  36389. declare module BABYLON {
  36390. /**
  36391. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36392. */
  36393. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36394. private static _AnyMouseID;
  36395. /**
  36396. * Abstract mesh the behavior is set on
  36397. */
  36398. attachedNode: AbstractMesh;
  36399. private _dragPlane;
  36400. private _scene;
  36401. private _pointerObserver;
  36402. private _beforeRenderObserver;
  36403. private static _planeScene;
  36404. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36405. /**
  36406. * 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)
  36407. */
  36408. maxDragAngle: number;
  36409. /**
  36410. * @hidden
  36411. */
  36412. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36413. /**
  36414. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36415. */
  36416. currentDraggingPointerID: number;
  36417. /**
  36418. * The last position where the pointer hit the drag plane in world space
  36419. */
  36420. lastDragPosition: Vector3;
  36421. /**
  36422. * If the behavior is currently in a dragging state
  36423. */
  36424. dragging: boolean;
  36425. /**
  36426. * 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)
  36427. */
  36428. dragDeltaRatio: number;
  36429. /**
  36430. * If the drag plane orientation should be updated during the dragging (Default: true)
  36431. */
  36432. updateDragPlane: boolean;
  36433. private _debugMode;
  36434. private _moving;
  36435. /**
  36436. * Fires each time the attached mesh is dragged with the pointer
  36437. * * delta between last drag position and current drag position in world space
  36438. * * dragDistance along the drag axis
  36439. * * dragPlaneNormal normal of the current drag plane used during the drag
  36440. * * dragPlanePoint in world space where the drag intersects the drag plane
  36441. */
  36442. onDragObservable: Observable<{
  36443. delta: Vector3;
  36444. dragPlanePoint: Vector3;
  36445. dragPlaneNormal: Vector3;
  36446. dragDistance: number;
  36447. pointerId: number;
  36448. }>;
  36449. /**
  36450. * Fires each time a drag begins (eg. mouse down on mesh)
  36451. */
  36452. onDragStartObservable: Observable<{
  36453. dragPlanePoint: Vector3;
  36454. pointerId: number;
  36455. }>;
  36456. /**
  36457. * Fires each time a drag ends (eg. mouse release after drag)
  36458. */
  36459. onDragEndObservable: Observable<{
  36460. dragPlanePoint: Vector3;
  36461. pointerId: number;
  36462. }>;
  36463. /**
  36464. * If the attached mesh should be moved when dragged
  36465. */
  36466. moveAttached: boolean;
  36467. /**
  36468. * If the drag behavior will react to drag events (Default: true)
  36469. */
  36470. enabled: boolean;
  36471. /**
  36472. * If pointer events should start and release the drag (Default: true)
  36473. */
  36474. startAndReleaseDragOnPointerEvents: boolean;
  36475. /**
  36476. * If camera controls should be detached during the drag
  36477. */
  36478. detachCameraControls: boolean;
  36479. /**
  36480. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36481. */
  36482. useObjectOrienationForDragging: boolean;
  36483. private _options;
  36484. /**
  36485. * Creates a pointer drag behavior that can be attached to a mesh
  36486. * @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)
  36487. */
  36488. constructor(options?: {
  36489. dragAxis?: Vector3;
  36490. dragPlaneNormal?: Vector3;
  36491. });
  36492. /**
  36493. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36494. */
  36495. validateDrag: (targetPosition: Vector3) => boolean;
  36496. /**
  36497. * The name of the behavior
  36498. */
  36499. readonly name: string;
  36500. /**
  36501. * Initializes the behavior
  36502. */
  36503. init(): void;
  36504. private _tmpVector;
  36505. private _alternatePickedPoint;
  36506. private _worldDragAxis;
  36507. private _targetPosition;
  36508. private _attachedElement;
  36509. /**
  36510. * Attaches the drag behavior the passed in mesh
  36511. * @param ownerNode The mesh that will be dragged around once attached
  36512. */
  36513. attach(ownerNode: AbstractMesh): void;
  36514. /**
  36515. * Force relase the drag action by code.
  36516. */
  36517. releaseDrag(): void;
  36518. private _startDragRay;
  36519. private _lastPointerRay;
  36520. /**
  36521. * Simulates the start of a pointer drag event on the behavior
  36522. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36523. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36524. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36525. */
  36526. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36527. private _startDrag;
  36528. private _dragDelta;
  36529. private _moveDrag;
  36530. private _pickWithRayOnDragPlane;
  36531. private _pointA;
  36532. private _pointB;
  36533. private _pointC;
  36534. private _lineA;
  36535. private _lineB;
  36536. private _localAxis;
  36537. private _lookAt;
  36538. private _updateDragPlanePosition;
  36539. /**
  36540. * Detaches the behavior from the mesh
  36541. */
  36542. detach(): void;
  36543. }
  36544. }
  36545. declare module BABYLON {
  36546. /**
  36547. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36548. */
  36549. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36550. private _dragBehaviorA;
  36551. private _dragBehaviorB;
  36552. private _startDistance;
  36553. private _initialScale;
  36554. private _targetScale;
  36555. private _ownerNode;
  36556. private _sceneRenderObserver;
  36557. /**
  36558. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36559. */
  36560. constructor();
  36561. /**
  36562. * The name of the behavior
  36563. */
  36564. readonly name: string;
  36565. /**
  36566. * Initializes the behavior
  36567. */
  36568. init(): void;
  36569. private _getCurrentDistance;
  36570. /**
  36571. * Attaches the scale behavior the passed in mesh
  36572. * @param ownerNode The mesh that will be scaled around once attached
  36573. */
  36574. attach(ownerNode: Mesh): void;
  36575. /**
  36576. * Detaches the behavior from the mesh
  36577. */
  36578. detach(): void;
  36579. }
  36580. }
  36581. declare module BABYLON {
  36582. /**
  36583. * 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
  36584. */
  36585. export class SixDofDragBehavior implements Behavior<Mesh> {
  36586. private static _virtualScene;
  36587. private _ownerNode;
  36588. private _sceneRenderObserver;
  36589. private _scene;
  36590. private _targetPosition;
  36591. private _virtualOriginMesh;
  36592. private _virtualDragMesh;
  36593. private _pointerObserver;
  36594. private _moving;
  36595. private _startingOrientation;
  36596. /**
  36597. * 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)
  36598. */
  36599. private zDragFactor;
  36600. /**
  36601. * If the object should rotate to face the drag origin
  36602. */
  36603. rotateDraggedObject: boolean;
  36604. /**
  36605. * If the behavior is currently in a dragging state
  36606. */
  36607. dragging: boolean;
  36608. /**
  36609. * 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)
  36610. */
  36611. dragDeltaRatio: number;
  36612. /**
  36613. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36614. */
  36615. currentDraggingPointerID: number;
  36616. /**
  36617. * If camera controls should be detached during the drag
  36618. */
  36619. detachCameraControls: boolean;
  36620. /**
  36621. * Fires each time a drag starts
  36622. */
  36623. onDragStartObservable: Observable<{}>;
  36624. /**
  36625. * Fires each time a drag ends (eg. mouse release after drag)
  36626. */
  36627. onDragEndObservable: Observable<{}>;
  36628. /**
  36629. * 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
  36630. */
  36631. constructor();
  36632. /**
  36633. * The name of the behavior
  36634. */
  36635. readonly name: string;
  36636. /**
  36637. * Initializes the behavior
  36638. */
  36639. init(): void;
  36640. /**
  36641. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36642. */
  36643. private readonly _pointerCamera;
  36644. /**
  36645. * Attaches the scale behavior the passed in mesh
  36646. * @param ownerNode The mesh that will be scaled around once attached
  36647. */
  36648. attach(ownerNode: Mesh): void;
  36649. /**
  36650. * Detaches the behavior from the mesh
  36651. */
  36652. detach(): void;
  36653. }
  36654. }
  36655. declare module BABYLON {
  36656. /**
  36657. * Class used to apply inverse kinematics to bones
  36658. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36659. */
  36660. export class BoneIKController {
  36661. private static _tmpVecs;
  36662. private static _tmpQuat;
  36663. private static _tmpMats;
  36664. /**
  36665. * Gets or sets the target mesh
  36666. */
  36667. targetMesh: AbstractMesh;
  36668. /** Gets or sets the mesh used as pole */
  36669. poleTargetMesh: AbstractMesh;
  36670. /**
  36671. * Gets or sets the bone used as pole
  36672. */
  36673. poleTargetBone: Nullable<Bone>;
  36674. /**
  36675. * Gets or sets the target position
  36676. */
  36677. targetPosition: Vector3;
  36678. /**
  36679. * Gets or sets the pole target position
  36680. */
  36681. poleTargetPosition: Vector3;
  36682. /**
  36683. * Gets or sets the pole target local offset
  36684. */
  36685. poleTargetLocalOffset: Vector3;
  36686. /**
  36687. * Gets or sets the pole angle
  36688. */
  36689. poleAngle: number;
  36690. /**
  36691. * Gets or sets the mesh associated with the controller
  36692. */
  36693. mesh: AbstractMesh;
  36694. /**
  36695. * 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)
  36696. */
  36697. slerpAmount: number;
  36698. private _bone1Quat;
  36699. private _bone1Mat;
  36700. private _bone2Ang;
  36701. private _bone1;
  36702. private _bone2;
  36703. private _bone1Length;
  36704. private _bone2Length;
  36705. private _maxAngle;
  36706. private _maxReach;
  36707. private _rightHandedSystem;
  36708. private _bendAxis;
  36709. private _slerping;
  36710. private _adjustRoll;
  36711. /**
  36712. * Gets or sets maximum allowed angle
  36713. */
  36714. maxAngle: number;
  36715. /**
  36716. * Creates a new BoneIKController
  36717. * @param mesh defines the mesh to control
  36718. * @param bone defines the bone to control
  36719. * @param options defines options to set up the controller
  36720. */
  36721. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36722. targetMesh?: AbstractMesh;
  36723. poleTargetMesh?: AbstractMesh;
  36724. poleTargetBone?: Bone;
  36725. poleTargetLocalOffset?: Vector3;
  36726. poleAngle?: number;
  36727. bendAxis?: Vector3;
  36728. maxAngle?: number;
  36729. slerpAmount?: number;
  36730. });
  36731. private _setMaxAngle;
  36732. /**
  36733. * Force the controller to update the bones
  36734. */
  36735. update(): void;
  36736. }
  36737. }
  36738. declare module BABYLON {
  36739. /**
  36740. * Class used to make a bone look toward a point in space
  36741. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36742. */
  36743. export class BoneLookController {
  36744. private static _tmpVecs;
  36745. private static _tmpQuat;
  36746. private static _tmpMats;
  36747. /**
  36748. * The target Vector3 that the bone will look at
  36749. */
  36750. target: Vector3;
  36751. /**
  36752. * The mesh that the bone is attached to
  36753. */
  36754. mesh: AbstractMesh;
  36755. /**
  36756. * The bone that will be looking to the target
  36757. */
  36758. bone: Bone;
  36759. /**
  36760. * The up axis of the coordinate system that is used when the bone is rotated
  36761. */
  36762. upAxis: Vector3;
  36763. /**
  36764. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36765. */
  36766. upAxisSpace: Space;
  36767. /**
  36768. * Used to make an adjustment to the yaw of the bone
  36769. */
  36770. adjustYaw: number;
  36771. /**
  36772. * Used to make an adjustment to the pitch of the bone
  36773. */
  36774. adjustPitch: number;
  36775. /**
  36776. * Used to make an adjustment to the roll of the bone
  36777. */
  36778. adjustRoll: number;
  36779. /**
  36780. * 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)
  36781. */
  36782. slerpAmount: number;
  36783. private _minYaw;
  36784. private _maxYaw;
  36785. private _minPitch;
  36786. private _maxPitch;
  36787. private _minYawSin;
  36788. private _minYawCos;
  36789. private _maxYawSin;
  36790. private _maxYawCos;
  36791. private _midYawConstraint;
  36792. private _minPitchTan;
  36793. private _maxPitchTan;
  36794. private _boneQuat;
  36795. private _slerping;
  36796. private _transformYawPitch;
  36797. private _transformYawPitchInv;
  36798. private _firstFrameSkipped;
  36799. private _yawRange;
  36800. private _fowardAxis;
  36801. /**
  36802. * Gets or sets the minimum yaw angle that the bone can look to
  36803. */
  36804. minYaw: number;
  36805. /**
  36806. * Gets or sets the maximum yaw angle that the bone can look to
  36807. */
  36808. maxYaw: number;
  36809. /**
  36810. * Gets or sets the minimum pitch angle that the bone can look to
  36811. */
  36812. minPitch: number;
  36813. /**
  36814. * Gets or sets the maximum pitch angle that the bone can look to
  36815. */
  36816. maxPitch: number;
  36817. /**
  36818. * Create a BoneLookController
  36819. * @param mesh the mesh that the bone belongs to
  36820. * @param bone the bone that will be looking to the target
  36821. * @param target the target Vector3 to look at
  36822. * @param options optional settings:
  36823. * * maxYaw: the maximum angle the bone will yaw to
  36824. * * minYaw: the minimum angle the bone will yaw to
  36825. * * maxPitch: the maximum angle the bone will pitch to
  36826. * * minPitch: the minimum angle the bone will yaw to
  36827. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36828. * * upAxis: the up axis of the coordinate system
  36829. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36830. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36831. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36832. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36833. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36834. * * adjustRoll: used to make an adjustment to the roll of the bone
  36835. **/
  36836. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36837. maxYaw?: number;
  36838. minYaw?: number;
  36839. maxPitch?: number;
  36840. minPitch?: number;
  36841. slerpAmount?: number;
  36842. upAxis?: Vector3;
  36843. upAxisSpace?: Space;
  36844. yawAxis?: Vector3;
  36845. pitchAxis?: Vector3;
  36846. adjustYaw?: number;
  36847. adjustPitch?: number;
  36848. adjustRoll?: number;
  36849. });
  36850. /**
  36851. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36852. */
  36853. update(): void;
  36854. private _getAngleDiff;
  36855. private _getAngleBetween;
  36856. private _isAngleBetween;
  36857. }
  36858. }
  36859. declare module BABYLON {
  36860. /**
  36861. * Manage the gamepad inputs to control an arc rotate camera.
  36862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36863. */
  36864. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36865. /**
  36866. * Defines the camera the input is attached to.
  36867. */
  36868. camera: ArcRotateCamera;
  36869. /**
  36870. * Defines the gamepad the input is gathering event from.
  36871. */
  36872. gamepad: Nullable<Gamepad>;
  36873. /**
  36874. * Defines the gamepad rotation sensiblity.
  36875. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36876. */
  36877. gamepadRotationSensibility: number;
  36878. /**
  36879. * Defines the gamepad move sensiblity.
  36880. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36881. */
  36882. gamepadMoveSensibility: number;
  36883. private _onGamepadConnectedObserver;
  36884. private _onGamepadDisconnectedObserver;
  36885. /**
  36886. * Attach the input controls to a specific dom element to get the input from.
  36887. * @param element Defines the element the controls should be listened from
  36888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36889. */
  36890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36891. /**
  36892. * Detach the current controls from the specified dom element.
  36893. * @param element Defines the element to stop listening the inputs from
  36894. */
  36895. detachControl(element: Nullable<HTMLElement>): void;
  36896. /**
  36897. * Update the current camera state depending on the inputs that have been used this frame.
  36898. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36899. */
  36900. checkInputs(): void;
  36901. /**
  36902. * Gets the class name of the current intput.
  36903. * @returns the class name
  36904. */
  36905. getClassName(): string;
  36906. /**
  36907. * Get the friendly name associated with the input class.
  36908. * @returns the input friendly name
  36909. */
  36910. getSimpleName(): string;
  36911. }
  36912. }
  36913. declare module BABYLON {
  36914. interface ArcRotateCameraInputsManager {
  36915. /**
  36916. * Add orientation input support to the input manager.
  36917. * @returns the current input manager
  36918. */
  36919. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36920. }
  36921. /**
  36922. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36924. */
  36925. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36926. /**
  36927. * Defines the camera the input is attached to.
  36928. */
  36929. camera: ArcRotateCamera;
  36930. /**
  36931. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36932. */
  36933. alphaCorrection: number;
  36934. /**
  36935. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36936. */
  36937. gammaCorrection: number;
  36938. private _alpha;
  36939. private _gamma;
  36940. private _dirty;
  36941. private _deviceOrientationHandler;
  36942. /**
  36943. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36944. */
  36945. constructor();
  36946. /**
  36947. * Attach the input controls to a specific dom element to get the input from.
  36948. * @param element Defines the element the controls should be listened from
  36949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36950. */
  36951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36952. /** @hidden */
  36953. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36954. /**
  36955. * Update the current camera state depending on the inputs that have been used this frame.
  36956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36957. */
  36958. checkInputs(): void;
  36959. /**
  36960. * Detach the current controls from the specified dom element.
  36961. * @param element Defines the element to stop listening the inputs from
  36962. */
  36963. detachControl(element: Nullable<HTMLElement>): void;
  36964. /**
  36965. * Gets the class name of the current intput.
  36966. * @returns the class name
  36967. */
  36968. getClassName(): string;
  36969. /**
  36970. * Get the friendly name associated with the input class.
  36971. * @returns the input friendly name
  36972. */
  36973. getSimpleName(): string;
  36974. }
  36975. }
  36976. declare module BABYLON {
  36977. /**
  36978. * Listen to mouse events to control the camera.
  36979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36980. */
  36981. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36982. /**
  36983. * Defines the camera the input is attached to.
  36984. */
  36985. camera: FlyCamera;
  36986. /**
  36987. * Defines if touch is enabled. (Default is true.)
  36988. */
  36989. touchEnabled: boolean;
  36990. /**
  36991. * Defines the buttons associated with the input to handle camera rotation.
  36992. */
  36993. buttons: number[];
  36994. /**
  36995. * Assign buttons for Yaw control.
  36996. */
  36997. buttonsYaw: number[];
  36998. /**
  36999. * Assign buttons for Pitch control.
  37000. */
  37001. buttonsPitch: number[];
  37002. /**
  37003. * Assign buttons for Roll control.
  37004. */
  37005. buttonsRoll: number[];
  37006. /**
  37007. * Detect if any button is being pressed while mouse is moved.
  37008. * -1 = Mouse locked.
  37009. * 0 = Left button.
  37010. * 1 = Middle Button.
  37011. * 2 = Right Button.
  37012. */
  37013. activeButton: number;
  37014. /**
  37015. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37016. * Higher values reduce its sensitivity.
  37017. */
  37018. angularSensibility: number;
  37019. private _mousemoveCallback;
  37020. private _observer;
  37021. private _rollObserver;
  37022. private previousPosition;
  37023. private noPreventDefault;
  37024. private element;
  37025. /**
  37026. * Listen to mouse events to control the camera.
  37027. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37028. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37029. */
  37030. constructor(touchEnabled?: boolean);
  37031. /**
  37032. * Attach the mouse control to the HTML DOM element.
  37033. * @param element Defines the element that listens to the input events.
  37034. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37035. */
  37036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37037. /**
  37038. * Detach the current controls from the specified dom element.
  37039. * @param element Defines the element to stop listening the inputs from
  37040. */
  37041. detachControl(element: Nullable<HTMLElement>): void;
  37042. /**
  37043. * Gets the class name of the current input.
  37044. * @returns the class name.
  37045. */
  37046. getClassName(): string;
  37047. /**
  37048. * Get the friendly name associated with the input class.
  37049. * @returns the input's friendly name.
  37050. */
  37051. getSimpleName(): string;
  37052. private _pointerInput;
  37053. private _onMouseMove;
  37054. /**
  37055. * Rotate camera by mouse offset.
  37056. */
  37057. private rotateCamera;
  37058. }
  37059. }
  37060. declare module BABYLON {
  37061. /**
  37062. * Default Inputs manager for the FlyCamera.
  37063. * It groups all the default supported inputs for ease of use.
  37064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37065. */
  37066. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37067. /**
  37068. * Instantiates a new FlyCameraInputsManager.
  37069. * @param camera Defines the camera the inputs belong to.
  37070. */
  37071. constructor(camera: FlyCamera);
  37072. /**
  37073. * Add keyboard input support to the input manager.
  37074. * @returns the new FlyCameraKeyboardMoveInput().
  37075. */
  37076. addKeyboard(): FlyCameraInputsManager;
  37077. /**
  37078. * Add mouse input support to the input manager.
  37079. * @param touchEnabled Enable touch screen support.
  37080. * @returns the new FlyCameraMouseInput().
  37081. */
  37082. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37083. }
  37084. }
  37085. declare module BABYLON {
  37086. /**
  37087. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37088. * such as in a 3D Space Shooter or a Flight Simulator.
  37089. */
  37090. export class FlyCamera extends TargetCamera {
  37091. /**
  37092. * Define the collision ellipsoid of the camera.
  37093. * This is helpful for simulating a camera body, like a player's body.
  37094. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37095. */
  37096. ellipsoid: Vector3;
  37097. /**
  37098. * Define an offset for the position of the ellipsoid around the camera.
  37099. * This can be helpful if the camera is attached away from the player's body center,
  37100. * such as at its head.
  37101. */
  37102. ellipsoidOffset: Vector3;
  37103. /**
  37104. * Enable or disable collisions of the camera with the rest of the scene objects.
  37105. */
  37106. checkCollisions: boolean;
  37107. /**
  37108. * Enable or disable gravity on the camera.
  37109. */
  37110. applyGravity: boolean;
  37111. /**
  37112. * Define the current direction the camera is moving to.
  37113. */
  37114. cameraDirection: Vector3;
  37115. /**
  37116. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37117. * This overrides and empties cameraRotation.
  37118. */
  37119. rotationQuaternion: Quaternion;
  37120. /**
  37121. * Track Roll to maintain the wanted Rolling when looking around.
  37122. */
  37123. _trackRoll: number;
  37124. /**
  37125. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37126. */
  37127. rollCorrect: number;
  37128. /**
  37129. * Mimic a banked turn, Rolling the camera when Yawing.
  37130. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37131. */
  37132. bankedTurn: boolean;
  37133. /**
  37134. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37135. */
  37136. bankedTurnLimit: number;
  37137. /**
  37138. * Value of 0 disables the banked Roll.
  37139. * Value of 1 is equal to the Yaw angle in radians.
  37140. */
  37141. bankedTurnMultiplier: number;
  37142. /**
  37143. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37144. */
  37145. inputs: FlyCameraInputsManager;
  37146. /**
  37147. * Gets the input sensibility for mouse input.
  37148. * Higher values reduce sensitivity.
  37149. */
  37150. /**
  37151. * Sets the input sensibility for a mouse input.
  37152. * Higher values reduce sensitivity.
  37153. */
  37154. angularSensibility: number;
  37155. /**
  37156. * Get the keys for camera movement forward.
  37157. */
  37158. /**
  37159. * Set the keys for camera movement forward.
  37160. */
  37161. keysForward: number[];
  37162. /**
  37163. * Get the keys for camera movement backward.
  37164. */
  37165. keysBackward: number[];
  37166. /**
  37167. * Get the keys for camera movement up.
  37168. */
  37169. /**
  37170. * Set the keys for camera movement up.
  37171. */
  37172. keysUp: number[];
  37173. /**
  37174. * Get the keys for camera movement down.
  37175. */
  37176. /**
  37177. * Set the keys for camera movement down.
  37178. */
  37179. keysDown: number[];
  37180. /**
  37181. * Get the keys for camera movement left.
  37182. */
  37183. /**
  37184. * Set the keys for camera movement left.
  37185. */
  37186. keysLeft: number[];
  37187. /**
  37188. * Set the keys for camera movement right.
  37189. */
  37190. /**
  37191. * Set the keys for camera movement right.
  37192. */
  37193. keysRight: number[];
  37194. /**
  37195. * Event raised when the camera collides with a mesh in the scene.
  37196. */
  37197. onCollide: (collidedMesh: AbstractMesh) => void;
  37198. private _collider;
  37199. private _needMoveForGravity;
  37200. private _oldPosition;
  37201. private _diffPosition;
  37202. private _newPosition;
  37203. /** @hidden */
  37204. _localDirection: Vector3;
  37205. /** @hidden */
  37206. _transformedDirection: Vector3;
  37207. /**
  37208. * Instantiates a FlyCamera.
  37209. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37210. * such as in a 3D Space Shooter or a Flight Simulator.
  37211. * @param name Define the name of the camera in the scene.
  37212. * @param position Define the starting position of the camera in the scene.
  37213. * @param scene Define the scene the camera belongs to.
  37214. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37215. */
  37216. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37217. /**
  37218. * Attach a control to the HTML DOM element.
  37219. * @param element Defines the element that listens to the input events.
  37220. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37221. */
  37222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37223. /**
  37224. * Detach a control from the HTML DOM element.
  37225. * The camera will stop reacting to that input.
  37226. * @param element Defines the element that listens to the input events.
  37227. */
  37228. detachControl(element: HTMLElement): void;
  37229. private _collisionMask;
  37230. /**
  37231. * Get the mask that the camera ignores in collision events.
  37232. */
  37233. /**
  37234. * Set the mask that the camera ignores in collision events.
  37235. */
  37236. collisionMask: number;
  37237. /** @hidden */
  37238. _collideWithWorld(displacement: Vector3): void;
  37239. /** @hidden */
  37240. private _onCollisionPositionChange;
  37241. /** @hidden */
  37242. _checkInputs(): void;
  37243. /** @hidden */
  37244. _decideIfNeedsToMove(): boolean;
  37245. /** @hidden */
  37246. _updatePosition(): void;
  37247. /**
  37248. * Restore the Roll to its target value at the rate specified.
  37249. * @param rate - Higher means slower restoring.
  37250. * @hidden
  37251. */
  37252. restoreRoll(rate: number): void;
  37253. /**
  37254. * Destroy the camera and release the current resources held by it.
  37255. */
  37256. dispose(): void;
  37257. /**
  37258. * Get the current object class name.
  37259. * @returns the class name.
  37260. */
  37261. getClassName(): string;
  37262. }
  37263. }
  37264. declare module BABYLON {
  37265. /**
  37266. * Listen to keyboard events to control the camera.
  37267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37268. */
  37269. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37270. /**
  37271. * Defines the camera the input is attached to.
  37272. */
  37273. camera: FlyCamera;
  37274. /**
  37275. * The list of keyboard keys used to control the forward move of the camera.
  37276. */
  37277. keysForward: number[];
  37278. /**
  37279. * The list of keyboard keys used to control the backward move of the camera.
  37280. */
  37281. keysBackward: number[];
  37282. /**
  37283. * The list of keyboard keys used to control the forward move of the camera.
  37284. */
  37285. keysUp: number[];
  37286. /**
  37287. * The list of keyboard keys used to control the backward move of the camera.
  37288. */
  37289. keysDown: number[];
  37290. /**
  37291. * The list of keyboard keys used to control the right strafe move of the camera.
  37292. */
  37293. keysRight: number[];
  37294. /**
  37295. * The list of keyboard keys used to control the left strafe move of the camera.
  37296. */
  37297. keysLeft: number[];
  37298. private _keys;
  37299. private _onCanvasBlurObserver;
  37300. private _onKeyboardObserver;
  37301. private _engine;
  37302. private _scene;
  37303. /**
  37304. * Attach the input controls to a specific dom element to get the input from.
  37305. * @param element Defines the element the controls should be listened from
  37306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37307. */
  37308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37309. /**
  37310. * Detach the current controls from the specified dom element.
  37311. * @param element Defines the element to stop listening the inputs from
  37312. */
  37313. detachControl(element: Nullable<HTMLElement>): void;
  37314. /**
  37315. * Gets the class name of the current intput.
  37316. * @returns the class name
  37317. */
  37318. getClassName(): string;
  37319. /** @hidden */
  37320. _onLostFocus(e: FocusEvent): void;
  37321. /**
  37322. * Get the friendly name associated with the input class.
  37323. * @returns the input friendly name
  37324. */
  37325. getSimpleName(): string;
  37326. /**
  37327. * Update the current camera state depending on the inputs that have been used this frame.
  37328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37329. */
  37330. checkInputs(): void;
  37331. }
  37332. }
  37333. declare module BABYLON {
  37334. /**
  37335. * Manage the mouse wheel inputs to control a follow camera.
  37336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37337. */
  37338. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37339. /**
  37340. * Defines the camera the input is attached to.
  37341. */
  37342. camera: FollowCamera;
  37343. /**
  37344. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37345. */
  37346. axisControlRadius: boolean;
  37347. /**
  37348. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37349. */
  37350. axisControlHeight: boolean;
  37351. /**
  37352. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37353. */
  37354. axisControlRotation: boolean;
  37355. /**
  37356. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37357. * relation to mouseWheel events.
  37358. */
  37359. wheelPrecision: number;
  37360. /**
  37361. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37362. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37363. */
  37364. wheelDeltaPercentage: number;
  37365. private _wheel;
  37366. private _observer;
  37367. /**
  37368. * Attach the input controls to a specific dom element to get the input from.
  37369. * @param element Defines the element the controls should be listened from
  37370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37371. */
  37372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37373. /**
  37374. * Detach the current controls from the specified dom element.
  37375. * @param element Defines the element to stop listening the inputs from
  37376. */
  37377. detachControl(element: Nullable<HTMLElement>): void;
  37378. /**
  37379. * Gets the class name of the current intput.
  37380. * @returns the class name
  37381. */
  37382. getClassName(): string;
  37383. /**
  37384. * Get the friendly name associated with the input class.
  37385. * @returns the input friendly name
  37386. */
  37387. getSimpleName(): string;
  37388. }
  37389. }
  37390. declare module BABYLON {
  37391. /**
  37392. * Manage the pointers inputs to control an follow camera.
  37393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37394. */
  37395. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37396. /**
  37397. * Defines the camera the input is attached to.
  37398. */
  37399. camera: FollowCamera;
  37400. /**
  37401. * Gets the class name of the current input.
  37402. * @returns the class name
  37403. */
  37404. getClassName(): string;
  37405. /**
  37406. * Defines the pointer angular sensibility along the X axis or how fast is
  37407. * the camera rotating.
  37408. * A negative number will reverse the axis direction.
  37409. */
  37410. angularSensibilityX: number;
  37411. /**
  37412. * Defines the pointer angular sensibility along the Y axis or how fast is
  37413. * the camera rotating.
  37414. * A negative number will reverse the axis direction.
  37415. */
  37416. angularSensibilityY: number;
  37417. /**
  37418. * Defines the pointer pinch precision or how fast is the camera zooming.
  37419. * A negative number will reverse the axis direction.
  37420. */
  37421. pinchPrecision: number;
  37422. /**
  37423. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37424. * from 0.
  37425. * It defines the percentage of current camera.radius to use as delta when
  37426. * pinch zoom is used.
  37427. */
  37428. pinchDeltaPercentage: number;
  37429. /**
  37430. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37431. */
  37432. axisXControlRadius: boolean;
  37433. /**
  37434. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37435. */
  37436. axisXControlHeight: boolean;
  37437. /**
  37438. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37439. */
  37440. axisXControlRotation: boolean;
  37441. /**
  37442. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37443. */
  37444. axisYControlRadius: boolean;
  37445. /**
  37446. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37447. */
  37448. axisYControlHeight: boolean;
  37449. /**
  37450. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37451. */
  37452. axisYControlRotation: boolean;
  37453. /**
  37454. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37455. */
  37456. axisPinchControlRadius: boolean;
  37457. /**
  37458. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37459. */
  37460. axisPinchControlHeight: boolean;
  37461. /**
  37462. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37463. */
  37464. axisPinchControlRotation: boolean;
  37465. /**
  37466. * Log error messages if basic misconfiguration has occurred.
  37467. */
  37468. warningEnable: boolean;
  37469. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37470. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37471. private _warningCounter;
  37472. private _warning;
  37473. }
  37474. }
  37475. declare module BABYLON {
  37476. /**
  37477. * Default Inputs manager for the FollowCamera.
  37478. * It groups all the default supported inputs for ease of use.
  37479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37480. */
  37481. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37482. /**
  37483. * Instantiates a new FollowCameraInputsManager.
  37484. * @param camera Defines the camera the inputs belong to
  37485. */
  37486. constructor(camera: FollowCamera);
  37487. /**
  37488. * Add keyboard input support to the input manager.
  37489. * @returns the current input manager
  37490. */
  37491. addKeyboard(): FollowCameraInputsManager;
  37492. /**
  37493. * Add mouse wheel input support to the input manager.
  37494. * @returns the current input manager
  37495. */
  37496. addMouseWheel(): FollowCameraInputsManager;
  37497. /**
  37498. * Add pointers input support to the input manager.
  37499. * @returns the current input manager
  37500. */
  37501. addPointers(): FollowCameraInputsManager;
  37502. /**
  37503. * Add orientation input support to the input manager.
  37504. * @returns the current input manager
  37505. */
  37506. addVRDeviceOrientation(): FollowCameraInputsManager;
  37507. }
  37508. }
  37509. declare module BABYLON {
  37510. /**
  37511. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37512. * an arc rotate version arcFollowCamera are available.
  37513. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37514. */
  37515. export class FollowCamera extends TargetCamera {
  37516. /**
  37517. * Distance the follow camera should follow an object at
  37518. */
  37519. radius: number;
  37520. /**
  37521. * Minimum allowed distance of the camera to the axis of rotation
  37522. * (The camera can not get closer).
  37523. * This can help limiting how the Camera is able to move in the scene.
  37524. */
  37525. lowerRadiusLimit: Nullable<number>;
  37526. /**
  37527. * Maximum allowed distance of the camera to the axis of rotation
  37528. * (The camera can not get further).
  37529. * This can help limiting how the Camera is able to move in the scene.
  37530. */
  37531. upperRadiusLimit: Nullable<number>;
  37532. /**
  37533. * Define a rotation offset between the camera and the object it follows
  37534. */
  37535. rotationOffset: number;
  37536. /**
  37537. * Minimum allowed angle to camera position relative to target object.
  37538. * This can help limiting how the Camera is able to move in the scene.
  37539. */
  37540. lowerRotationOffsetLimit: Nullable<number>;
  37541. /**
  37542. * Maximum allowed angle to camera position relative to target object.
  37543. * This can help limiting how the Camera is able to move in the scene.
  37544. */
  37545. upperRotationOffsetLimit: Nullable<number>;
  37546. /**
  37547. * Define a height offset between the camera and the object it follows.
  37548. * It can help following an object from the top (like a car chaing a plane)
  37549. */
  37550. heightOffset: number;
  37551. /**
  37552. * Minimum allowed height of camera position relative to target object.
  37553. * This can help limiting how the Camera is able to move in the scene.
  37554. */
  37555. lowerHeightOffsetLimit: Nullable<number>;
  37556. /**
  37557. * Maximum allowed height of camera position relative to target object.
  37558. * This can help limiting how the Camera is able to move in the scene.
  37559. */
  37560. upperHeightOffsetLimit: Nullable<number>;
  37561. /**
  37562. * Define how fast the camera can accelerate to follow it s target.
  37563. */
  37564. cameraAcceleration: number;
  37565. /**
  37566. * Define the speed limit of the camera following an object.
  37567. */
  37568. maxCameraSpeed: number;
  37569. /**
  37570. * Define the target of the camera.
  37571. */
  37572. lockedTarget: Nullable<AbstractMesh>;
  37573. /**
  37574. * Defines the input associated with the camera.
  37575. */
  37576. inputs: FollowCameraInputsManager;
  37577. /**
  37578. * Instantiates the follow camera.
  37579. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37580. * @param name Define the name of the camera in the scene
  37581. * @param position Define the position of the camera
  37582. * @param scene Define the scene the camera belong to
  37583. * @param lockedTarget Define the target of the camera
  37584. */
  37585. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37586. private _follow;
  37587. /**
  37588. * Attached controls to the current camera.
  37589. * @param element Defines the element the controls should be listened from
  37590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37591. */
  37592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37593. /**
  37594. * Detach the current controls from the camera.
  37595. * The camera will stop reacting to inputs.
  37596. * @param element Defines the element to stop listening the inputs from
  37597. */
  37598. detachControl(element: HTMLElement): void;
  37599. /** @hidden */
  37600. _checkInputs(): void;
  37601. private _checkLimits;
  37602. /**
  37603. * Gets the camera class name.
  37604. * @returns the class name
  37605. */
  37606. getClassName(): string;
  37607. }
  37608. /**
  37609. * Arc Rotate version of the follow camera.
  37610. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37611. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37612. */
  37613. export class ArcFollowCamera extends TargetCamera {
  37614. /** The longitudinal angle of the camera */
  37615. alpha: number;
  37616. /** The latitudinal angle of the camera */
  37617. beta: number;
  37618. /** The radius of the camera from its target */
  37619. radius: number;
  37620. /** Define the camera target (the messh it should follow) */
  37621. target: Nullable<AbstractMesh>;
  37622. private _cartesianCoordinates;
  37623. /**
  37624. * Instantiates a new ArcFollowCamera
  37625. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37626. * @param name Define the name of the camera
  37627. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37628. * @param beta Define the rotation angle of the camera around the elevation axis
  37629. * @param radius Define the radius of the camera from its target point
  37630. * @param target Define the target of the camera
  37631. * @param scene Define the scene the camera belongs to
  37632. */
  37633. constructor(name: string,
  37634. /** The longitudinal angle of the camera */
  37635. alpha: number,
  37636. /** The latitudinal angle of the camera */
  37637. beta: number,
  37638. /** The radius of the camera from its target */
  37639. radius: number,
  37640. /** Define the camera target (the messh it should follow) */
  37641. target: Nullable<AbstractMesh>, scene: Scene);
  37642. private _follow;
  37643. /** @hidden */
  37644. _checkInputs(): void;
  37645. /**
  37646. * Returns the class name of the object.
  37647. * It is mostly used internally for serialization purposes.
  37648. */
  37649. getClassName(): string;
  37650. }
  37651. }
  37652. declare module BABYLON {
  37653. /**
  37654. * Manage the keyboard inputs to control the movement of a follow camera.
  37655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37656. */
  37657. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37658. /**
  37659. * Defines the camera the input is attached to.
  37660. */
  37661. camera: FollowCamera;
  37662. /**
  37663. * Defines the list of key codes associated with the up action (increase heightOffset)
  37664. */
  37665. keysHeightOffsetIncr: number[];
  37666. /**
  37667. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37668. */
  37669. keysHeightOffsetDecr: number[];
  37670. /**
  37671. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37672. */
  37673. keysHeightOffsetModifierAlt: boolean;
  37674. /**
  37675. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37676. */
  37677. keysHeightOffsetModifierCtrl: boolean;
  37678. /**
  37679. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37680. */
  37681. keysHeightOffsetModifierShift: boolean;
  37682. /**
  37683. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37684. */
  37685. keysRotationOffsetIncr: number[];
  37686. /**
  37687. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37688. */
  37689. keysRotationOffsetDecr: number[];
  37690. /**
  37691. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37692. */
  37693. keysRotationOffsetModifierAlt: boolean;
  37694. /**
  37695. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37696. */
  37697. keysRotationOffsetModifierCtrl: boolean;
  37698. /**
  37699. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37700. */
  37701. keysRotationOffsetModifierShift: boolean;
  37702. /**
  37703. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37704. */
  37705. keysRadiusIncr: number[];
  37706. /**
  37707. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37708. */
  37709. keysRadiusDecr: number[];
  37710. /**
  37711. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37712. */
  37713. keysRadiusModifierAlt: boolean;
  37714. /**
  37715. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37716. */
  37717. keysRadiusModifierCtrl: boolean;
  37718. /**
  37719. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37720. */
  37721. keysRadiusModifierShift: boolean;
  37722. /**
  37723. * Defines the rate of change of heightOffset.
  37724. */
  37725. heightSensibility: number;
  37726. /**
  37727. * Defines the rate of change of rotationOffset.
  37728. */
  37729. rotationSensibility: number;
  37730. /**
  37731. * Defines the rate of change of radius.
  37732. */
  37733. radiusSensibility: number;
  37734. private _keys;
  37735. private _ctrlPressed;
  37736. private _altPressed;
  37737. private _shiftPressed;
  37738. private _onCanvasBlurObserver;
  37739. private _onKeyboardObserver;
  37740. private _engine;
  37741. private _scene;
  37742. /**
  37743. * Attach the input controls to a specific dom element to get the input from.
  37744. * @param element Defines the element the controls should be listened from
  37745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37746. */
  37747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37748. /**
  37749. * Detach the current controls from the specified dom element.
  37750. * @param element Defines the element to stop listening the inputs from
  37751. */
  37752. detachControl(element: Nullable<HTMLElement>): void;
  37753. /**
  37754. * Update the current camera state depending on the inputs that have been used this frame.
  37755. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37756. */
  37757. checkInputs(): void;
  37758. /**
  37759. * Gets the class name of the current input.
  37760. * @returns the class name
  37761. */
  37762. getClassName(): string;
  37763. /**
  37764. * Get the friendly name associated with the input class.
  37765. * @returns the input friendly name
  37766. */
  37767. getSimpleName(): string;
  37768. /**
  37769. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37770. * allow modification of the heightOffset value.
  37771. */
  37772. private _modifierHeightOffset;
  37773. /**
  37774. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37775. * allow modification of the rotationOffset value.
  37776. */
  37777. private _modifierRotationOffset;
  37778. /**
  37779. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37780. * allow modification of the radius value.
  37781. */
  37782. private _modifierRadius;
  37783. }
  37784. }
  37785. declare module BABYLON {
  37786. interface FreeCameraInputsManager {
  37787. /**
  37788. * @hidden
  37789. */
  37790. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37791. /**
  37792. * Add orientation input support to the input manager.
  37793. * @returns the current input manager
  37794. */
  37795. addDeviceOrientation(): FreeCameraInputsManager;
  37796. }
  37797. /**
  37798. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37799. * Screen rotation is taken into account.
  37800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37801. */
  37802. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37803. private _camera;
  37804. private _screenOrientationAngle;
  37805. private _constantTranform;
  37806. private _screenQuaternion;
  37807. private _alpha;
  37808. private _beta;
  37809. private _gamma;
  37810. /**
  37811. * Can be used to detect if a device orientation sensor is availible on a device
  37812. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37813. * @returns a promise that will resolve on orientation change
  37814. */
  37815. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37816. /**
  37817. * @hidden
  37818. */
  37819. _onDeviceOrientationChangedObservable: Observable<void>;
  37820. /**
  37821. * Instantiates a new input
  37822. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37823. */
  37824. constructor();
  37825. /**
  37826. * Define the camera controlled by the input.
  37827. */
  37828. camera: FreeCamera;
  37829. /**
  37830. * Attach the input controls to a specific dom element to get the input from.
  37831. * @param element Defines the element the controls should be listened from
  37832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37833. */
  37834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37835. private _orientationChanged;
  37836. private _deviceOrientation;
  37837. /**
  37838. * Detach the current controls from the specified dom element.
  37839. * @param element Defines the element to stop listening the inputs from
  37840. */
  37841. detachControl(element: Nullable<HTMLElement>): void;
  37842. /**
  37843. * Update the current camera state depending on the inputs that have been used this frame.
  37844. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37845. */
  37846. checkInputs(): void;
  37847. /**
  37848. * Gets the class name of the current intput.
  37849. * @returns the class name
  37850. */
  37851. getClassName(): string;
  37852. /**
  37853. * Get the friendly name associated with the input class.
  37854. * @returns the input friendly name
  37855. */
  37856. getSimpleName(): string;
  37857. }
  37858. }
  37859. declare module BABYLON {
  37860. /**
  37861. * Manage the gamepad inputs to control a free camera.
  37862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37863. */
  37864. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37865. /**
  37866. * Define the camera the input is attached to.
  37867. */
  37868. camera: FreeCamera;
  37869. /**
  37870. * Define the Gamepad controlling the input
  37871. */
  37872. gamepad: Nullable<Gamepad>;
  37873. /**
  37874. * Defines the gamepad rotation sensiblity.
  37875. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37876. */
  37877. gamepadAngularSensibility: number;
  37878. /**
  37879. * Defines the gamepad move sensiblity.
  37880. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37881. */
  37882. gamepadMoveSensibility: number;
  37883. private _onGamepadConnectedObserver;
  37884. private _onGamepadDisconnectedObserver;
  37885. private _cameraTransform;
  37886. private _deltaTransform;
  37887. private _vector3;
  37888. private _vector2;
  37889. /**
  37890. * Attach the input controls to a specific dom element to get the input from.
  37891. * @param element Defines the element the controls should be listened from
  37892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37893. */
  37894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37895. /**
  37896. * Detach the current controls from the specified dom element.
  37897. * @param element Defines the element to stop listening the inputs from
  37898. */
  37899. detachControl(element: Nullable<HTMLElement>): void;
  37900. /**
  37901. * Update the current camera state depending on the inputs that have been used this frame.
  37902. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37903. */
  37904. checkInputs(): void;
  37905. /**
  37906. * Gets the class name of the current intput.
  37907. * @returns the class name
  37908. */
  37909. getClassName(): string;
  37910. /**
  37911. * Get the friendly name associated with the input class.
  37912. * @returns the input friendly name
  37913. */
  37914. getSimpleName(): string;
  37915. }
  37916. }
  37917. declare module BABYLON {
  37918. /**
  37919. * Defines the potential axis of a Joystick
  37920. */
  37921. export enum JoystickAxis {
  37922. /** X axis */
  37923. X = 0,
  37924. /** Y axis */
  37925. Y = 1,
  37926. /** Z axis */
  37927. Z = 2
  37928. }
  37929. /**
  37930. * Class used to define virtual joystick (used in touch mode)
  37931. */
  37932. export class VirtualJoystick {
  37933. /**
  37934. * Gets or sets a boolean indicating that left and right values must be inverted
  37935. */
  37936. reverseLeftRight: boolean;
  37937. /**
  37938. * Gets or sets a boolean indicating that up and down values must be inverted
  37939. */
  37940. reverseUpDown: boolean;
  37941. /**
  37942. * Gets the offset value for the position (ie. the change of the position value)
  37943. */
  37944. deltaPosition: Vector3;
  37945. /**
  37946. * Gets a boolean indicating if the virtual joystick was pressed
  37947. */
  37948. pressed: boolean;
  37949. /**
  37950. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37951. */
  37952. static Canvas: Nullable<HTMLCanvasElement>;
  37953. private static _globalJoystickIndex;
  37954. private static vjCanvasContext;
  37955. private static vjCanvasWidth;
  37956. private static vjCanvasHeight;
  37957. private static halfWidth;
  37958. private _action;
  37959. private _axisTargetedByLeftAndRight;
  37960. private _axisTargetedByUpAndDown;
  37961. private _joystickSensibility;
  37962. private _inversedSensibility;
  37963. private _joystickPointerID;
  37964. private _joystickColor;
  37965. private _joystickPointerPos;
  37966. private _joystickPreviousPointerPos;
  37967. private _joystickPointerStartPos;
  37968. private _deltaJoystickVector;
  37969. private _leftJoystick;
  37970. private _touches;
  37971. private _onPointerDownHandlerRef;
  37972. private _onPointerMoveHandlerRef;
  37973. private _onPointerUpHandlerRef;
  37974. private _onResize;
  37975. /**
  37976. * Creates a new virtual joystick
  37977. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37978. */
  37979. constructor(leftJoystick?: boolean);
  37980. /**
  37981. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37982. * @param newJoystickSensibility defines the new sensibility
  37983. */
  37984. setJoystickSensibility(newJoystickSensibility: number): void;
  37985. private _onPointerDown;
  37986. private _onPointerMove;
  37987. private _onPointerUp;
  37988. /**
  37989. * Change the color of the virtual joystick
  37990. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37991. */
  37992. setJoystickColor(newColor: string): void;
  37993. /**
  37994. * Defines a callback to call when the joystick is touched
  37995. * @param action defines the callback
  37996. */
  37997. setActionOnTouch(action: () => any): void;
  37998. /**
  37999. * Defines which axis you'd like to control for left & right
  38000. * @param axis defines the axis to use
  38001. */
  38002. setAxisForLeftRight(axis: JoystickAxis): void;
  38003. /**
  38004. * Defines which axis you'd like to control for up & down
  38005. * @param axis defines the axis to use
  38006. */
  38007. setAxisForUpDown(axis: JoystickAxis): void;
  38008. private _drawVirtualJoystick;
  38009. /**
  38010. * Release internal HTML canvas
  38011. */
  38012. releaseCanvas(): void;
  38013. }
  38014. }
  38015. declare module BABYLON {
  38016. interface FreeCameraInputsManager {
  38017. /**
  38018. * Add virtual joystick input support to the input manager.
  38019. * @returns the current input manager
  38020. */
  38021. addVirtualJoystick(): FreeCameraInputsManager;
  38022. }
  38023. /**
  38024. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38026. */
  38027. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38028. /**
  38029. * Defines the camera the input is attached to.
  38030. */
  38031. camera: FreeCamera;
  38032. private _leftjoystick;
  38033. private _rightjoystick;
  38034. /**
  38035. * Gets the left stick of the virtual joystick.
  38036. * @returns The virtual Joystick
  38037. */
  38038. getLeftJoystick(): VirtualJoystick;
  38039. /**
  38040. * Gets the right stick of the virtual joystick.
  38041. * @returns The virtual Joystick
  38042. */
  38043. getRightJoystick(): VirtualJoystick;
  38044. /**
  38045. * Update the current camera state depending on the inputs that have been used this frame.
  38046. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38047. */
  38048. checkInputs(): void;
  38049. /**
  38050. * Attach the input controls to a specific dom element to get the input from.
  38051. * @param element Defines the element the controls should be listened from
  38052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38053. */
  38054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38055. /**
  38056. * Detach the current controls from the specified dom element.
  38057. * @param element Defines the element to stop listening the inputs from
  38058. */
  38059. detachControl(element: Nullable<HTMLElement>): void;
  38060. /**
  38061. * Gets the class name of the current intput.
  38062. * @returns the class name
  38063. */
  38064. getClassName(): string;
  38065. /**
  38066. * Get the friendly name associated with the input class.
  38067. * @returns the input friendly name
  38068. */
  38069. getSimpleName(): string;
  38070. }
  38071. }
  38072. declare module BABYLON {
  38073. /**
  38074. * This represents a FPS type of camera controlled by touch.
  38075. * This is like a universal camera minus the Gamepad controls.
  38076. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38077. */
  38078. export class TouchCamera extends FreeCamera {
  38079. /**
  38080. * Defines the touch sensibility for rotation.
  38081. * The higher the faster.
  38082. */
  38083. touchAngularSensibility: number;
  38084. /**
  38085. * Defines the touch sensibility for move.
  38086. * The higher the faster.
  38087. */
  38088. touchMoveSensibility: number;
  38089. /**
  38090. * Instantiates a new touch camera.
  38091. * This represents a FPS type of camera controlled by touch.
  38092. * This is like a universal camera minus the Gamepad controls.
  38093. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38094. * @param name Define the name of the camera in the scene
  38095. * @param position Define the start position of the camera in the scene
  38096. * @param scene Define the scene the camera belongs to
  38097. */
  38098. constructor(name: string, position: Vector3, scene: Scene);
  38099. /**
  38100. * Gets the current object class name.
  38101. * @return the class name
  38102. */
  38103. getClassName(): string;
  38104. /** @hidden */
  38105. _setupInputs(): void;
  38106. }
  38107. }
  38108. declare module BABYLON {
  38109. /**
  38110. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38111. * being tilted forward or back and left or right.
  38112. */
  38113. export class DeviceOrientationCamera extends FreeCamera {
  38114. private _initialQuaternion;
  38115. private _quaternionCache;
  38116. private _tmpDragQuaternion;
  38117. /**
  38118. * Creates a new device orientation camera
  38119. * @param name The name of the camera
  38120. * @param position The start position camera
  38121. * @param scene The scene the camera belongs to
  38122. */
  38123. constructor(name: string, position: Vector3, scene: Scene);
  38124. /**
  38125. * @hidden
  38126. * Disabled pointer input on first orientation sensor update (Default: true)
  38127. */
  38128. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38129. private _dragFactor;
  38130. /**
  38131. * Enabled turning on the y axis when the orientation sensor is active
  38132. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38133. */
  38134. enableHorizontalDragging(dragFactor?: number): void;
  38135. /**
  38136. * Gets the current instance class name ("DeviceOrientationCamera").
  38137. * This helps avoiding instanceof at run time.
  38138. * @returns the class name
  38139. */
  38140. getClassName(): string;
  38141. /**
  38142. * @hidden
  38143. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38144. */
  38145. _checkInputs(): void;
  38146. /**
  38147. * Reset the camera to its default orientation on the specified axis only.
  38148. * @param axis The axis to reset
  38149. */
  38150. resetToCurrentRotation(axis?: Axis): void;
  38151. }
  38152. }
  38153. declare module BABYLON {
  38154. /**
  38155. * Defines supported buttons for XBox360 compatible gamepads
  38156. */
  38157. export enum Xbox360Button {
  38158. /** A */
  38159. A = 0,
  38160. /** B */
  38161. B = 1,
  38162. /** X */
  38163. X = 2,
  38164. /** Y */
  38165. Y = 3,
  38166. /** Start */
  38167. Start = 4,
  38168. /** Back */
  38169. Back = 5,
  38170. /** Left button */
  38171. LB = 6,
  38172. /** Right button */
  38173. RB = 7,
  38174. /** Left stick */
  38175. LeftStick = 8,
  38176. /** Right stick */
  38177. RightStick = 9
  38178. }
  38179. /** Defines values for XBox360 DPad */
  38180. export enum Xbox360Dpad {
  38181. /** Up */
  38182. Up = 0,
  38183. /** Down */
  38184. Down = 1,
  38185. /** Left */
  38186. Left = 2,
  38187. /** Right */
  38188. Right = 3
  38189. }
  38190. /**
  38191. * Defines a XBox360 gamepad
  38192. */
  38193. export class Xbox360Pad extends Gamepad {
  38194. private _leftTrigger;
  38195. private _rightTrigger;
  38196. private _onlefttriggerchanged;
  38197. private _onrighttriggerchanged;
  38198. private _onbuttondown;
  38199. private _onbuttonup;
  38200. private _ondpaddown;
  38201. private _ondpadup;
  38202. /** Observable raised when a button is pressed */
  38203. onButtonDownObservable: Observable<Xbox360Button>;
  38204. /** Observable raised when a button is released */
  38205. onButtonUpObservable: Observable<Xbox360Button>;
  38206. /** Observable raised when a pad is pressed */
  38207. onPadDownObservable: Observable<Xbox360Dpad>;
  38208. /** Observable raised when a pad is released */
  38209. onPadUpObservable: Observable<Xbox360Dpad>;
  38210. private _buttonA;
  38211. private _buttonB;
  38212. private _buttonX;
  38213. private _buttonY;
  38214. private _buttonBack;
  38215. private _buttonStart;
  38216. private _buttonLB;
  38217. private _buttonRB;
  38218. private _buttonLeftStick;
  38219. private _buttonRightStick;
  38220. private _dPadUp;
  38221. private _dPadDown;
  38222. private _dPadLeft;
  38223. private _dPadRight;
  38224. private _isXboxOnePad;
  38225. /**
  38226. * Creates a new XBox360 gamepad object
  38227. * @param id defines the id of this gamepad
  38228. * @param index defines its index
  38229. * @param gamepad defines the internal HTML gamepad object
  38230. * @param xboxOne defines if it is a XBox One gamepad
  38231. */
  38232. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38233. /**
  38234. * Defines the callback to call when left trigger is pressed
  38235. * @param callback defines the callback to use
  38236. */
  38237. onlefttriggerchanged(callback: (value: number) => void): void;
  38238. /**
  38239. * Defines the callback to call when right trigger is pressed
  38240. * @param callback defines the callback to use
  38241. */
  38242. onrighttriggerchanged(callback: (value: number) => void): void;
  38243. /**
  38244. * Gets the left trigger value
  38245. */
  38246. /**
  38247. * Sets the left trigger value
  38248. */
  38249. leftTrigger: number;
  38250. /**
  38251. * Gets the right trigger value
  38252. */
  38253. /**
  38254. * Sets the right trigger value
  38255. */
  38256. rightTrigger: number;
  38257. /**
  38258. * Defines the callback to call when a button is pressed
  38259. * @param callback defines the callback to use
  38260. */
  38261. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38262. /**
  38263. * Defines the callback to call when a button is released
  38264. * @param callback defines the callback to use
  38265. */
  38266. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38267. /**
  38268. * Defines the callback to call when a pad is pressed
  38269. * @param callback defines the callback to use
  38270. */
  38271. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38272. /**
  38273. * Defines the callback to call when a pad is released
  38274. * @param callback defines the callback to use
  38275. */
  38276. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38277. private _setButtonValue;
  38278. private _setDPadValue;
  38279. /**
  38280. * Gets the value of the `A` button
  38281. */
  38282. /**
  38283. * Sets the value of the `A` button
  38284. */
  38285. buttonA: number;
  38286. /**
  38287. * Gets the value of the `B` button
  38288. */
  38289. /**
  38290. * Sets the value of the `B` button
  38291. */
  38292. buttonB: number;
  38293. /**
  38294. * Gets the value of the `X` button
  38295. */
  38296. /**
  38297. * Sets the value of the `X` button
  38298. */
  38299. buttonX: number;
  38300. /**
  38301. * Gets the value of the `Y` button
  38302. */
  38303. /**
  38304. * Sets the value of the `Y` button
  38305. */
  38306. buttonY: number;
  38307. /**
  38308. * Gets the value of the `Start` button
  38309. */
  38310. /**
  38311. * Sets the value of the `Start` button
  38312. */
  38313. buttonStart: number;
  38314. /**
  38315. * Gets the value of the `Back` button
  38316. */
  38317. /**
  38318. * Sets the value of the `Back` button
  38319. */
  38320. buttonBack: number;
  38321. /**
  38322. * Gets the value of the `Left` button
  38323. */
  38324. /**
  38325. * Sets the value of the `Left` button
  38326. */
  38327. buttonLB: number;
  38328. /**
  38329. * Gets the value of the `Right` button
  38330. */
  38331. /**
  38332. * Sets the value of the `Right` button
  38333. */
  38334. buttonRB: number;
  38335. /**
  38336. * Gets the value of the Left joystick
  38337. */
  38338. /**
  38339. * Sets the value of the Left joystick
  38340. */
  38341. buttonLeftStick: number;
  38342. /**
  38343. * Gets the value of the Right joystick
  38344. */
  38345. /**
  38346. * Sets the value of the Right joystick
  38347. */
  38348. buttonRightStick: number;
  38349. /**
  38350. * Gets the value of D-pad up
  38351. */
  38352. /**
  38353. * Sets the value of D-pad up
  38354. */
  38355. dPadUp: number;
  38356. /**
  38357. * Gets the value of D-pad down
  38358. */
  38359. /**
  38360. * Sets the value of D-pad down
  38361. */
  38362. dPadDown: number;
  38363. /**
  38364. * Gets the value of D-pad left
  38365. */
  38366. /**
  38367. * Sets the value of D-pad left
  38368. */
  38369. dPadLeft: number;
  38370. /**
  38371. * Gets the value of D-pad right
  38372. */
  38373. /**
  38374. * Sets the value of D-pad right
  38375. */
  38376. dPadRight: number;
  38377. /**
  38378. * Force the gamepad to synchronize with device values
  38379. */
  38380. update(): void;
  38381. /**
  38382. * Disposes the gamepad
  38383. */
  38384. dispose(): void;
  38385. }
  38386. }
  38387. declare module BABYLON {
  38388. /**
  38389. * Manager for handling gamepads
  38390. */
  38391. export class GamepadManager {
  38392. private _scene?;
  38393. private _babylonGamepads;
  38394. private _oneGamepadConnected;
  38395. /** @hidden */
  38396. _isMonitoring: boolean;
  38397. private _gamepadEventSupported;
  38398. private _gamepadSupport;
  38399. /**
  38400. * observable to be triggered when the gamepad controller has been connected
  38401. */
  38402. onGamepadConnectedObservable: Observable<Gamepad>;
  38403. /**
  38404. * observable to be triggered when the gamepad controller has been disconnected
  38405. */
  38406. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38407. private _onGamepadConnectedEvent;
  38408. private _onGamepadDisconnectedEvent;
  38409. /**
  38410. * Initializes the gamepad manager
  38411. * @param _scene BabylonJS scene
  38412. */
  38413. constructor(_scene?: Scene | undefined);
  38414. /**
  38415. * The gamepads in the game pad manager
  38416. */
  38417. readonly gamepads: Gamepad[];
  38418. /**
  38419. * Get the gamepad controllers based on type
  38420. * @param type The type of gamepad controller
  38421. * @returns Nullable gamepad
  38422. */
  38423. getGamepadByType(type?: number): Nullable<Gamepad>;
  38424. /**
  38425. * Disposes the gamepad manager
  38426. */
  38427. dispose(): void;
  38428. private _addNewGamepad;
  38429. private _startMonitoringGamepads;
  38430. private _stopMonitoringGamepads;
  38431. /** @hidden */
  38432. _checkGamepadsStatus(): void;
  38433. private _updateGamepadObjects;
  38434. }
  38435. }
  38436. declare module BABYLON {
  38437. interface Scene {
  38438. /** @hidden */
  38439. _gamepadManager: Nullable<GamepadManager>;
  38440. /**
  38441. * Gets the gamepad manager associated with the scene
  38442. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38443. */
  38444. gamepadManager: GamepadManager;
  38445. }
  38446. /**
  38447. * Interface representing a free camera inputs manager
  38448. */
  38449. interface FreeCameraInputsManager {
  38450. /**
  38451. * Adds gamepad input support to the FreeCameraInputsManager.
  38452. * @returns the FreeCameraInputsManager
  38453. */
  38454. addGamepad(): FreeCameraInputsManager;
  38455. }
  38456. /**
  38457. * Interface representing an arc rotate camera inputs manager
  38458. */
  38459. interface ArcRotateCameraInputsManager {
  38460. /**
  38461. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38462. * @returns the camera inputs manager
  38463. */
  38464. addGamepad(): ArcRotateCameraInputsManager;
  38465. }
  38466. /**
  38467. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38468. */
  38469. export class GamepadSystemSceneComponent implements ISceneComponent {
  38470. /**
  38471. * The component name helpfull to identify the component in the list of scene components.
  38472. */
  38473. readonly name: string;
  38474. /**
  38475. * The scene the component belongs to.
  38476. */
  38477. scene: Scene;
  38478. /**
  38479. * Creates a new instance of the component for the given scene
  38480. * @param scene Defines the scene to register the component in
  38481. */
  38482. constructor(scene: Scene);
  38483. /**
  38484. * Registers the component in a given scene
  38485. */
  38486. register(): void;
  38487. /**
  38488. * Rebuilds the elements related to this component in case of
  38489. * context lost for instance.
  38490. */
  38491. rebuild(): void;
  38492. /**
  38493. * Disposes the component and the associated ressources
  38494. */
  38495. dispose(): void;
  38496. private _beforeCameraUpdate;
  38497. }
  38498. }
  38499. declare module BABYLON {
  38500. /**
  38501. * 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,
  38502. * which still works and will still be found in many Playgrounds.
  38503. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38504. */
  38505. export class UniversalCamera extends TouchCamera {
  38506. /**
  38507. * Defines the gamepad rotation sensiblity.
  38508. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38509. */
  38510. gamepadAngularSensibility: number;
  38511. /**
  38512. * Defines the gamepad move sensiblity.
  38513. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38514. */
  38515. gamepadMoveSensibility: number;
  38516. /**
  38517. * 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,
  38518. * which still works and will still be found in many Playgrounds.
  38519. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38520. * @param name Define the name of the camera in the scene
  38521. * @param position Define the start position of the camera in the scene
  38522. * @param scene Define the scene the camera belongs to
  38523. */
  38524. constructor(name: string, position: Vector3, scene: Scene);
  38525. /**
  38526. * Gets the current object class name.
  38527. * @return the class name
  38528. */
  38529. getClassName(): string;
  38530. }
  38531. }
  38532. declare module BABYLON {
  38533. /**
  38534. * This represents a FPS type of camera. This is only here for back compat purpose.
  38535. * Please use the UniversalCamera instead as both are identical.
  38536. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38537. */
  38538. export class GamepadCamera extends UniversalCamera {
  38539. /**
  38540. * Instantiates a new Gamepad Camera
  38541. * This represents a FPS type of camera. This is only here for back compat purpose.
  38542. * Please use the UniversalCamera instead as both are identical.
  38543. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38544. * @param name Define the name of the camera in the scene
  38545. * @param position Define the start position of the camera in the scene
  38546. * @param scene Define the scene the camera belongs to
  38547. */
  38548. constructor(name: string, position: Vector3, scene: Scene);
  38549. /**
  38550. * Gets the current object class name.
  38551. * @return the class name
  38552. */
  38553. getClassName(): string;
  38554. }
  38555. }
  38556. declare module BABYLON {
  38557. /** @hidden */
  38558. export var passPixelShader: {
  38559. name: string;
  38560. shader: string;
  38561. };
  38562. }
  38563. declare module BABYLON {
  38564. /** @hidden */
  38565. export var passCubePixelShader: {
  38566. name: string;
  38567. shader: string;
  38568. };
  38569. }
  38570. declare module BABYLON {
  38571. /**
  38572. * PassPostProcess which produces an output the same as it's input
  38573. */
  38574. export class PassPostProcess extends PostProcess {
  38575. /**
  38576. * Creates the PassPostProcess
  38577. * @param name The name of the effect.
  38578. * @param options The required width/height ratio to downsize to before computing the render pass.
  38579. * @param camera The camera to apply the render pass to.
  38580. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38581. * @param engine The engine which the post process will be applied. (default: current engine)
  38582. * @param reusable If the post process can be reused on the same frame. (default: false)
  38583. * @param textureType The type of texture to be used when performing the post processing.
  38584. * @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)
  38585. */
  38586. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38587. }
  38588. /**
  38589. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38590. */
  38591. export class PassCubePostProcess extends PostProcess {
  38592. private _face;
  38593. /**
  38594. * Gets or sets the cube face to display.
  38595. * * 0 is +X
  38596. * * 1 is -X
  38597. * * 2 is +Y
  38598. * * 3 is -Y
  38599. * * 4 is +Z
  38600. * * 5 is -Z
  38601. */
  38602. face: number;
  38603. /**
  38604. * Creates the PassCubePostProcess
  38605. * @param name The name of the effect.
  38606. * @param options The required width/height ratio to downsize to before computing the render pass.
  38607. * @param camera The camera to apply the render pass to.
  38608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38609. * @param engine The engine which the post process will be applied. (default: current engine)
  38610. * @param reusable If the post process can be reused on the same frame. (default: false)
  38611. * @param textureType The type of texture to be used when performing the post processing.
  38612. * @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)
  38613. */
  38614. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38615. }
  38616. }
  38617. declare module BABYLON {
  38618. /** @hidden */
  38619. export var anaglyphPixelShader: {
  38620. name: string;
  38621. shader: string;
  38622. };
  38623. }
  38624. declare module BABYLON {
  38625. /**
  38626. * Postprocess used to generate anaglyphic rendering
  38627. */
  38628. export class AnaglyphPostProcess extends PostProcess {
  38629. private _passedProcess;
  38630. /**
  38631. * Creates a new AnaglyphPostProcess
  38632. * @param name defines postprocess name
  38633. * @param options defines creation options or target ratio scale
  38634. * @param rigCameras defines cameras using this postprocess
  38635. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38636. * @param engine defines hosting engine
  38637. * @param reusable defines if the postprocess will be reused multiple times per frame
  38638. */
  38639. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38640. }
  38641. }
  38642. declare module BABYLON {
  38643. /**
  38644. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38645. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38646. */
  38647. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38648. /**
  38649. * Creates a new AnaglyphArcRotateCamera
  38650. * @param name defines camera name
  38651. * @param alpha defines alpha angle (in radians)
  38652. * @param beta defines beta angle (in radians)
  38653. * @param radius defines radius
  38654. * @param target defines camera target
  38655. * @param interaxialDistance defines distance between each color axis
  38656. * @param scene defines the hosting scene
  38657. */
  38658. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38659. /**
  38660. * Gets camera class name
  38661. * @returns AnaglyphArcRotateCamera
  38662. */
  38663. getClassName(): string;
  38664. }
  38665. }
  38666. declare module BABYLON {
  38667. /**
  38668. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38669. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38670. */
  38671. export class AnaglyphFreeCamera extends FreeCamera {
  38672. /**
  38673. * Creates a new AnaglyphFreeCamera
  38674. * @param name defines camera name
  38675. * @param position defines initial position
  38676. * @param interaxialDistance defines distance between each color axis
  38677. * @param scene defines the hosting scene
  38678. */
  38679. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38680. /**
  38681. * Gets camera class name
  38682. * @returns AnaglyphFreeCamera
  38683. */
  38684. getClassName(): string;
  38685. }
  38686. }
  38687. declare module BABYLON {
  38688. /**
  38689. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38690. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38691. */
  38692. export class AnaglyphGamepadCamera extends GamepadCamera {
  38693. /**
  38694. * Creates a new AnaglyphGamepadCamera
  38695. * @param name defines camera name
  38696. * @param position defines initial position
  38697. * @param interaxialDistance defines distance between each color axis
  38698. * @param scene defines the hosting scene
  38699. */
  38700. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38701. /**
  38702. * Gets camera class name
  38703. * @returns AnaglyphGamepadCamera
  38704. */
  38705. getClassName(): string;
  38706. }
  38707. }
  38708. declare module BABYLON {
  38709. /**
  38710. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38711. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38712. */
  38713. export class AnaglyphUniversalCamera extends UniversalCamera {
  38714. /**
  38715. * Creates a new AnaglyphUniversalCamera
  38716. * @param name defines camera name
  38717. * @param position defines initial position
  38718. * @param interaxialDistance defines distance between each color axis
  38719. * @param scene defines the hosting scene
  38720. */
  38721. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38722. /**
  38723. * Gets camera class name
  38724. * @returns AnaglyphUniversalCamera
  38725. */
  38726. getClassName(): string;
  38727. }
  38728. }
  38729. declare module BABYLON {
  38730. /** @hidden */
  38731. export var stereoscopicInterlacePixelShader: {
  38732. name: string;
  38733. shader: string;
  38734. };
  38735. }
  38736. declare module BABYLON {
  38737. /**
  38738. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38739. */
  38740. export class StereoscopicInterlacePostProcess extends PostProcess {
  38741. private _stepSize;
  38742. private _passedProcess;
  38743. /**
  38744. * Initializes a StereoscopicInterlacePostProcess
  38745. * @param name The name of the effect.
  38746. * @param rigCameras The rig cameras to be appled to the post process
  38747. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38749. * @param engine The engine which the post process will be applied. (default: current engine)
  38750. * @param reusable If the post process can be reused on the same frame. (default: false)
  38751. */
  38752. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38753. }
  38754. }
  38755. declare module BABYLON {
  38756. /**
  38757. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38758. * @see http://doc.babylonjs.com/features/cameras
  38759. */
  38760. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38761. /**
  38762. * Creates a new StereoscopicArcRotateCamera
  38763. * @param name defines camera name
  38764. * @param alpha defines alpha angle (in radians)
  38765. * @param beta defines beta angle (in radians)
  38766. * @param radius defines radius
  38767. * @param target defines camera target
  38768. * @param interaxialDistance defines distance between each color axis
  38769. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38770. * @param scene defines the hosting scene
  38771. */
  38772. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38773. /**
  38774. * Gets camera class name
  38775. * @returns StereoscopicArcRotateCamera
  38776. */
  38777. getClassName(): string;
  38778. }
  38779. }
  38780. declare module BABYLON {
  38781. /**
  38782. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38783. * @see http://doc.babylonjs.com/features/cameras
  38784. */
  38785. export class StereoscopicFreeCamera extends FreeCamera {
  38786. /**
  38787. * Creates a new StereoscopicFreeCamera
  38788. * @param name defines camera name
  38789. * @param position defines initial position
  38790. * @param interaxialDistance defines distance between each color axis
  38791. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38792. * @param scene defines the hosting scene
  38793. */
  38794. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38795. /**
  38796. * Gets camera class name
  38797. * @returns StereoscopicFreeCamera
  38798. */
  38799. getClassName(): string;
  38800. }
  38801. }
  38802. declare module BABYLON {
  38803. /**
  38804. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38805. * @see http://doc.babylonjs.com/features/cameras
  38806. */
  38807. export class StereoscopicGamepadCamera extends GamepadCamera {
  38808. /**
  38809. * Creates a new StereoscopicGamepadCamera
  38810. * @param name defines camera name
  38811. * @param position defines initial position
  38812. * @param interaxialDistance defines distance between each color axis
  38813. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38814. * @param scene defines the hosting scene
  38815. */
  38816. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38817. /**
  38818. * Gets camera class name
  38819. * @returns StereoscopicGamepadCamera
  38820. */
  38821. getClassName(): string;
  38822. }
  38823. }
  38824. declare module BABYLON {
  38825. /**
  38826. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38827. * @see http://doc.babylonjs.com/features/cameras
  38828. */
  38829. export class StereoscopicUniversalCamera extends UniversalCamera {
  38830. /**
  38831. * Creates a new StereoscopicUniversalCamera
  38832. * @param name defines camera name
  38833. * @param position defines initial position
  38834. * @param interaxialDistance defines distance between each color axis
  38835. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38836. * @param scene defines the hosting scene
  38837. */
  38838. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38839. /**
  38840. * Gets camera class name
  38841. * @returns StereoscopicUniversalCamera
  38842. */
  38843. getClassName(): string;
  38844. }
  38845. }
  38846. declare module BABYLON {
  38847. /**
  38848. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38849. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38850. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38851. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38852. */
  38853. export class VirtualJoysticksCamera extends FreeCamera {
  38854. /**
  38855. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38856. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38857. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38858. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38859. * @param name Define the name of the camera in the scene
  38860. * @param position Define the start position of the camera in the scene
  38861. * @param scene Define the scene the camera belongs to
  38862. */
  38863. constructor(name: string, position: Vector3, scene: Scene);
  38864. /**
  38865. * Gets the current object class name.
  38866. * @return the class name
  38867. */
  38868. getClassName(): string;
  38869. }
  38870. }
  38871. declare module BABYLON {
  38872. /**
  38873. * This represents all the required metrics to create a VR camera.
  38874. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38875. */
  38876. export class VRCameraMetrics {
  38877. /**
  38878. * Define the horizontal resolution off the screen.
  38879. */
  38880. hResolution: number;
  38881. /**
  38882. * Define the vertical resolution off the screen.
  38883. */
  38884. vResolution: number;
  38885. /**
  38886. * Define the horizontal screen size.
  38887. */
  38888. hScreenSize: number;
  38889. /**
  38890. * Define the vertical screen size.
  38891. */
  38892. vScreenSize: number;
  38893. /**
  38894. * Define the vertical screen center position.
  38895. */
  38896. vScreenCenter: number;
  38897. /**
  38898. * Define the distance of the eyes to the screen.
  38899. */
  38900. eyeToScreenDistance: number;
  38901. /**
  38902. * Define the distance between both lenses
  38903. */
  38904. lensSeparationDistance: number;
  38905. /**
  38906. * Define the distance between both viewer's eyes.
  38907. */
  38908. interpupillaryDistance: number;
  38909. /**
  38910. * Define the distortion factor of the VR postprocess.
  38911. * Please, touch with care.
  38912. */
  38913. distortionK: number[];
  38914. /**
  38915. * Define the chromatic aberration correction factors for the VR post process.
  38916. */
  38917. chromaAbCorrection: number[];
  38918. /**
  38919. * Define the scale factor of the post process.
  38920. * The smaller the better but the slower.
  38921. */
  38922. postProcessScaleFactor: number;
  38923. /**
  38924. * Define an offset for the lens center.
  38925. */
  38926. lensCenterOffset: number;
  38927. /**
  38928. * Define if the current vr camera should compensate the distortion of the lense or not.
  38929. */
  38930. compensateDistortion: boolean;
  38931. /**
  38932. * Defines if multiview should be enabled when rendering (Default: false)
  38933. */
  38934. multiviewEnabled: boolean;
  38935. /**
  38936. * Gets the rendering aspect ratio based on the provided resolutions.
  38937. */
  38938. readonly aspectRatio: number;
  38939. /**
  38940. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38941. */
  38942. readonly aspectRatioFov: number;
  38943. /**
  38944. * @hidden
  38945. */
  38946. readonly leftHMatrix: Matrix;
  38947. /**
  38948. * @hidden
  38949. */
  38950. readonly rightHMatrix: Matrix;
  38951. /**
  38952. * @hidden
  38953. */
  38954. readonly leftPreViewMatrix: Matrix;
  38955. /**
  38956. * @hidden
  38957. */
  38958. readonly rightPreViewMatrix: Matrix;
  38959. /**
  38960. * Get the default VRMetrics based on the most generic setup.
  38961. * @returns the default vr metrics
  38962. */
  38963. static GetDefault(): VRCameraMetrics;
  38964. }
  38965. }
  38966. declare module BABYLON {
  38967. /** @hidden */
  38968. export var vrDistortionCorrectionPixelShader: {
  38969. name: string;
  38970. shader: string;
  38971. };
  38972. }
  38973. declare module BABYLON {
  38974. /**
  38975. * VRDistortionCorrectionPostProcess used for mobile VR
  38976. */
  38977. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38978. private _isRightEye;
  38979. private _distortionFactors;
  38980. private _postProcessScaleFactor;
  38981. private _lensCenterOffset;
  38982. private _scaleIn;
  38983. private _scaleFactor;
  38984. private _lensCenter;
  38985. /**
  38986. * Initializes the VRDistortionCorrectionPostProcess
  38987. * @param name The name of the effect.
  38988. * @param camera The camera to apply the render pass to.
  38989. * @param isRightEye If this is for the right eye distortion
  38990. * @param vrMetrics All the required metrics for the VR camera
  38991. */
  38992. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38993. }
  38994. }
  38995. declare module BABYLON {
  38996. /**
  38997. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38998. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38999. */
  39000. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39001. /**
  39002. * Creates a new VRDeviceOrientationArcRotateCamera
  39003. * @param name defines camera name
  39004. * @param alpha defines the camera rotation along the logitudinal axis
  39005. * @param beta defines the camera rotation along the latitudinal axis
  39006. * @param radius defines the camera distance from its target
  39007. * @param target defines the camera target
  39008. * @param scene defines the scene the camera belongs to
  39009. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39010. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39011. */
  39012. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39013. /**
  39014. * Gets camera class name
  39015. * @returns VRDeviceOrientationArcRotateCamera
  39016. */
  39017. getClassName(): string;
  39018. }
  39019. }
  39020. declare module BABYLON {
  39021. /**
  39022. * Camera used to simulate VR rendering (based on FreeCamera)
  39023. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39024. */
  39025. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39026. /**
  39027. * Creates a new VRDeviceOrientationFreeCamera
  39028. * @param name defines camera name
  39029. * @param position defines the start position of the camera
  39030. * @param scene defines the scene the camera belongs to
  39031. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39032. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39033. */
  39034. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39035. /**
  39036. * Gets camera class name
  39037. * @returns VRDeviceOrientationFreeCamera
  39038. */
  39039. getClassName(): string;
  39040. }
  39041. }
  39042. declare module BABYLON {
  39043. /**
  39044. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39045. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39046. */
  39047. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39048. /**
  39049. * Creates a new VRDeviceOrientationGamepadCamera
  39050. * @param name defines camera name
  39051. * @param position defines the start position of the camera
  39052. * @param scene defines the scene the camera belongs to
  39053. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39054. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39055. */
  39056. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39057. /**
  39058. * Gets camera class name
  39059. * @returns VRDeviceOrientationGamepadCamera
  39060. */
  39061. getClassName(): string;
  39062. }
  39063. }
  39064. declare module BABYLON {
  39065. /**
  39066. * Base class of materials working in push mode in babylon JS
  39067. * @hidden
  39068. */
  39069. export class PushMaterial extends Material {
  39070. protected _activeEffect: Effect;
  39071. protected _normalMatrix: Matrix;
  39072. /**
  39073. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39074. * This means that the material can keep using a previous shader while a new one is being compiled.
  39075. * This is mostly used when shader parallel compilation is supported (true by default)
  39076. */
  39077. allowShaderHotSwapping: boolean;
  39078. constructor(name: string, scene: Scene);
  39079. getEffect(): Effect;
  39080. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39081. /**
  39082. * Binds the given world matrix to the active effect
  39083. *
  39084. * @param world the matrix to bind
  39085. */
  39086. bindOnlyWorldMatrix(world: Matrix): void;
  39087. /**
  39088. * Binds the given normal matrix to the active effect
  39089. *
  39090. * @param normalMatrix the matrix to bind
  39091. */
  39092. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39093. bind(world: Matrix, mesh?: Mesh): void;
  39094. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39095. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39096. }
  39097. }
  39098. declare module BABYLON {
  39099. /**
  39100. * This groups all the flags used to control the materials channel.
  39101. */
  39102. export class MaterialFlags {
  39103. private static _DiffuseTextureEnabled;
  39104. /**
  39105. * Are diffuse textures enabled in the application.
  39106. */
  39107. static DiffuseTextureEnabled: boolean;
  39108. private static _AmbientTextureEnabled;
  39109. /**
  39110. * Are ambient textures enabled in the application.
  39111. */
  39112. static AmbientTextureEnabled: boolean;
  39113. private static _OpacityTextureEnabled;
  39114. /**
  39115. * Are opacity textures enabled in the application.
  39116. */
  39117. static OpacityTextureEnabled: boolean;
  39118. private static _ReflectionTextureEnabled;
  39119. /**
  39120. * Are reflection textures enabled in the application.
  39121. */
  39122. static ReflectionTextureEnabled: boolean;
  39123. private static _EmissiveTextureEnabled;
  39124. /**
  39125. * Are emissive textures enabled in the application.
  39126. */
  39127. static EmissiveTextureEnabled: boolean;
  39128. private static _SpecularTextureEnabled;
  39129. /**
  39130. * Are specular textures enabled in the application.
  39131. */
  39132. static SpecularTextureEnabled: boolean;
  39133. private static _BumpTextureEnabled;
  39134. /**
  39135. * Are bump textures enabled in the application.
  39136. */
  39137. static BumpTextureEnabled: boolean;
  39138. private static _LightmapTextureEnabled;
  39139. /**
  39140. * Are lightmap textures enabled in the application.
  39141. */
  39142. static LightmapTextureEnabled: boolean;
  39143. private static _RefractionTextureEnabled;
  39144. /**
  39145. * Are refraction textures enabled in the application.
  39146. */
  39147. static RefractionTextureEnabled: boolean;
  39148. private static _ColorGradingTextureEnabled;
  39149. /**
  39150. * Are color grading textures enabled in the application.
  39151. */
  39152. static ColorGradingTextureEnabled: boolean;
  39153. private static _FresnelEnabled;
  39154. /**
  39155. * Are fresnels enabled in the application.
  39156. */
  39157. static FresnelEnabled: boolean;
  39158. private static _ClearCoatTextureEnabled;
  39159. /**
  39160. * Are clear coat textures enabled in the application.
  39161. */
  39162. static ClearCoatTextureEnabled: boolean;
  39163. private static _ClearCoatBumpTextureEnabled;
  39164. /**
  39165. * Are clear coat bump textures enabled in the application.
  39166. */
  39167. static ClearCoatBumpTextureEnabled: boolean;
  39168. private static _ClearCoatTintTextureEnabled;
  39169. /**
  39170. * Are clear coat tint textures enabled in the application.
  39171. */
  39172. static ClearCoatTintTextureEnabled: boolean;
  39173. private static _SheenTextureEnabled;
  39174. /**
  39175. * Are sheen textures enabled in the application.
  39176. */
  39177. static SheenTextureEnabled: boolean;
  39178. private static _AnisotropicTextureEnabled;
  39179. /**
  39180. * Are anisotropic textures enabled in the application.
  39181. */
  39182. static AnisotropicTextureEnabled: boolean;
  39183. private static _ThicknessTextureEnabled;
  39184. /**
  39185. * Are thickness textures enabled in the application.
  39186. */
  39187. static ThicknessTextureEnabled: boolean;
  39188. }
  39189. }
  39190. declare module BABYLON {
  39191. /** @hidden */
  39192. export var defaultFragmentDeclaration: {
  39193. name: string;
  39194. shader: string;
  39195. };
  39196. }
  39197. declare module BABYLON {
  39198. /** @hidden */
  39199. export var defaultUboDeclaration: {
  39200. name: string;
  39201. shader: string;
  39202. };
  39203. }
  39204. declare module BABYLON {
  39205. /** @hidden */
  39206. export var lightFragmentDeclaration: {
  39207. name: string;
  39208. shader: string;
  39209. };
  39210. }
  39211. declare module BABYLON {
  39212. /** @hidden */
  39213. export var lightUboDeclaration: {
  39214. name: string;
  39215. shader: string;
  39216. };
  39217. }
  39218. declare module BABYLON {
  39219. /** @hidden */
  39220. export var lightsFragmentFunctions: {
  39221. name: string;
  39222. shader: string;
  39223. };
  39224. }
  39225. declare module BABYLON {
  39226. /** @hidden */
  39227. export var shadowsFragmentFunctions: {
  39228. name: string;
  39229. shader: string;
  39230. };
  39231. }
  39232. declare module BABYLON {
  39233. /** @hidden */
  39234. export var fresnelFunction: {
  39235. name: string;
  39236. shader: string;
  39237. };
  39238. }
  39239. declare module BABYLON {
  39240. /** @hidden */
  39241. export var reflectionFunction: {
  39242. name: string;
  39243. shader: string;
  39244. };
  39245. }
  39246. declare module BABYLON {
  39247. /** @hidden */
  39248. export var bumpFragmentFunctions: {
  39249. name: string;
  39250. shader: string;
  39251. };
  39252. }
  39253. declare module BABYLON {
  39254. /** @hidden */
  39255. export var logDepthDeclaration: {
  39256. name: string;
  39257. shader: string;
  39258. };
  39259. }
  39260. declare module BABYLON {
  39261. /** @hidden */
  39262. export var bumpFragment: {
  39263. name: string;
  39264. shader: string;
  39265. };
  39266. }
  39267. declare module BABYLON {
  39268. /** @hidden */
  39269. export var depthPrePass: {
  39270. name: string;
  39271. shader: string;
  39272. };
  39273. }
  39274. declare module BABYLON {
  39275. /** @hidden */
  39276. export var lightFragment: {
  39277. name: string;
  39278. shader: string;
  39279. };
  39280. }
  39281. declare module BABYLON {
  39282. /** @hidden */
  39283. export var logDepthFragment: {
  39284. name: string;
  39285. shader: string;
  39286. };
  39287. }
  39288. declare module BABYLON {
  39289. /** @hidden */
  39290. export var defaultPixelShader: {
  39291. name: string;
  39292. shader: string;
  39293. };
  39294. }
  39295. declare module BABYLON {
  39296. /** @hidden */
  39297. export var defaultVertexDeclaration: {
  39298. name: string;
  39299. shader: string;
  39300. };
  39301. }
  39302. declare module BABYLON {
  39303. /** @hidden */
  39304. export var bumpVertexDeclaration: {
  39305. name: string;
  39306. shader: string;
  39307. };
  39308. }
  39309. declare module BABYLON {
  39310. /** @hidden */
  39311. export var bumpVertex: {
  39312. name: string;
  39313. shader: string;
  39314. };
  39315. }
  39316. declare module BABYLON {
  39317. /** @hidden */
  39318. export var fogVertex: {
  39319. name: string;
  39320. shader: string;
  39321. };
  39322. }
  39323. declare module BABYLON {
  39324. /** @hidden */
  39325. export var shadowsVertex: {
  39326. name: string;
  39327. shader: string;
  39328. };
  39329. }
  39330. declare module BABYLON {
  39331. /** @hidden */
  39332. export var pointCloudVertex: {
  39333. name: string;
  39334. shader: string;
  39335. };
  39336. }
  39337. declare module BABYLON {
  39338. /** @hidden */
  39339. export var logDepthVertex: {
  39340. name: string;
  39341. shader: string;
  39342. };
  39343. }
  39344. declare module BABYLON {
  39345. /** @hidden */
  39346. export var defaultVertexShader: {
  39347. name: string;
  39348. shader: string;
  39349. };
  39350. }
  39351. declare module BABYLON {
  39352. /** @hidden */
  39353. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39354. MAINUV1: boolean;
  39355. MAINUV2: boolean;
  39356. DIFFUSE: boolean;
  39357. DIFFUSEDIRECTUV: number;
  39358. AMBIENT: boolean;
  39359. AMBIENTDIRECTUV: number;
  39360. OPACITY: boolean;
  39361. OPACITYDIRECTUV: number;
  39362. OPACITYRGB: boolean;
  39363. REFLECTION: boolean;
  39364. EMISSIVE: boolean;
  39365. EMISSIVEDIRECTUV: number;
  39366. SPECULAR: boolean;
  39367. SPECULARDIRECTUV: number;
  39368. BUMP: boolean;
  39369. BUMPDIRECTUV: number;
  39370. PARALLAX: boolean;
  39371. PARALLAXOCCLUSION: boolean;
  39372. SPECULAROVERALPHA: boolean;
  39373. CLIPPLANE: boolean;
  39374. CLIPPLANE2: boolean;
  39375. CLIPPLANE3: boolean;
  39376. CLIPPLANE4: boolean;
  39377. ALPHATEST: boolean;
  39378. DEPTHPREPASS: boolean;
  39379. ALPHAFROMDIFFUSE: boolean;
  39380. POINTSIZE: boolean;
  39381. FOG: boolean;
  39382. SPECULARTERM: boolean;
  39383. DIFFUSEFRESNEL: boolean;
  39384. OPACITYFRESNEL: boolean;
  39385. REFLECTIONFRESNEL: boolean;
  39386. REFRACTIONFRESNEL: boolean;
  39387. EMISSIVEFRESNEL: boolean;
  39388. FRESNEL: boolean;
  39389. NORMAL: boolean;
  39390. UV1: boolean;
  39391. UV2: boolean;
  39392. VERTEXCOLOR: boolean;
  39393. VERTEXALPHA: boolean;
  39394. NUM_BONE_INFLUENCERS: number;
  39395. BonesPerMesh: number;
  39396. BONETEXTURE: boolean;
  39397. INSTANCES: boolean;
  39398. GLOSSINESS: boolean;
  39399. ROUGHNESS: boolean;
  39400. EMISSIVEASILLUMINATION: boolean;
  39401. LINKEMISSIVEWITHDIFFUSE: boolean;
  39402. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39403. LIGHTMAP: boolean;
  39404. LIGHTMAPDIRECTUV: number;
  39405. OBJECTSPACE_NORMALMAP: boolean;
  39406. USELIGHTMAPASSHADOWMAP: boolean;
  39407. REFLECTIONMAP_3D: boolean;
  39408. REFLECTIONMAP_SPHERICAL: boolean;
  39409. REFLECTIONMAP_PLANAR: boolean;
  39410. REFLECTIONMAP_CUBIC: boolean;
  39411. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39412. REFLECTIONMAP_PROJECTION: boolean;
  39413. REFLECTIONMAP_SKYBOX: boolean;
  39414. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39415. REFLECTIONMAP_EXPLICIT: boolean;
  39416. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39417. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39418. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39419. INVERTCUBICMAP: boolean;
  39420. LOGARITHMICDEPTH: boolean;
  39421. REFRACTION: boolean;
  39422. REFRACTIONMAP_3D: boolean;
  39423. REFLECTIONOVERALPHA: boolean;
  39424. TWOSIDEDLIGHTING: boolean;
  39425. SHADOWFLOAT: boolean;
  39426. MORPHTARGETS: boolean;
  39427. MORPHTARGETS_NORMAL: boolean;
  39428. MORPHTARGETS_TANGENT: boolean;
  39429. MORPHTARGETS_UV: boolean;
  39430. NUM_MORPH_INFLUENCERS: number;
  39431. NONUNIFORMSCALING: boolean;
  39432. PREMULTIPLYALPHA: boolean;
  39433. IMAGEPROCESSING: boolean;
  39434. VIGNETTE: boolean;
  39435. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39436. VIGNETTEBLENDMODEOPAQUE: boolean;
  39437. TONEMAPPING: boolean;
  39438. TONEMAPPING_ACES: boolean;
  39439. CONTRAST: boolean;
  39440. COLORCURVES: boolean;
  39441. COLORGRADING: boolean;
  39442. COLORGRADING3D: boolean;
  39443. SAMPLER3DGREENDEPTH: boolean;
  39444. SAMPLER3DBGRMAP: boolean;
  39445. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39446. MULTIVIEW: boolean;
  39447. /**
  39448. * If the reflection texture on this material is in linear color space
  39449. * @hidden
  39450. */
  39451. IS_REFLECTION_LINEAR: boolean;
  39452. /**
  39453. * If the refraction texture on this material is in linear color space
  39454. * @hidden
  39455. */
  39456. IS_REFRACTION_LINEAR: boolean;
  39457. EXPOSURE: boolean;
  39458. constructor();
  39459. setReflectionMode(modeToEnable: string): void;
  39460. }
  39461. /**
  39462. * This is the default material used in Babylon. It is the best trade off between quality
  39463. * and performances.
  39464. * @see http://doc.babylonjs.com/babylon101/materials
  39465. */
  39466. export class StandardMaterial extends PushMaterial {
  39467. private _diffuseTexture;
  39468. /**
  39469. * The basic texture of the material as viewed under a light.
  39470. */
  39471. diffuseTexture: Nullable<BaseTexture>;
  39472. private _ambientTexture;
  39473. /**
  39474. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39475. */
  39476. ambientTexture: Nullable<BaseTexture>;
  39477. private _opacityTexture;
  39478. /**
  39479. * Define the transparency of the material from a texture.
  39480. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39481. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39482. */
  39483. opacityTexture: Nullable<BaseTexture>;
  39484. private _reflectionTexture;
  39485. /**
  39486. * Define the texture used to display the reflection.
  39487. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39488. */
  39489. reflectionTexture: Nullable<BaseTexture>;
  39490. private _emissiveTexture;
  39491. /**
  39492. * Define texture of the material as if self lit.
  39493. * This will be mixed in the final result even in the absence of light.
  39494. */
  39495. emissiveTexture: Nullable<BaseTexture>;
  39496. private _specularTexture;
  39497. /**
  39498. * Define how the color and intensity of the highlight given by the light in the material.
  39499. */
  39500. specularTexture: Nullable<BaseTexture>;
  39501. private _bumpTexture;
  39502. /**
  39503. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39504. * 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.
  39505. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39506. */
  39507. bumpTexture: Nullable<BaseTexture>;
  39508. private _lightmapTexture;
  39509. /**
  39510. * Complex lighting can be computationally expensive to compute at runtime.
  39511. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39512. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39513. */
  39514. lightmapTexture: Nullable<BaseTexture>;
  39515. private _refractionTexture;
  39516. /**
  39517. * Define the texture used to display the refraction.
  39518. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39519. */
  39520. refractionTexture: Nullable<BaseTexture>;
  39521. /**
  39522. * The color of the material lit by the environmental background lighting.
  39523. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39524. */
  39525. ambientColor: Color3;
  39526. /**
  39527. * The basic color of the material as viewed under a light.
  39528. */
  39529. diffuseColor: Color3;
  39530. /**
  39531. * Define how the color and intensity of the highlight given by the light in the material.
  39532. */
  39533. specularColor: Color3;
  39534. /**
  39535. * Define the color of the material as if self lit.
  39536. * This will be mixed in the final result even in the absence of light.
  39537. */
  39538. emissiveColor: Color3;
  39539. /**
  39540. * Defines how sharp are the highlights in the material.
  39541. * The bigger the value the sharper giving a more glossy feeling to the result.
  39542. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39543. */
  39544. specularPower: number;
  39545. private _useAlphaFromDiffuseTexture;
  39546. /**
  39547. * Does the transparency come from the diffuse texture alpha channel.
  39548. */
  39549. useAlphaFromDiffuseTexture: boolean;
  39550. private _useEmissiveAsIllumination;
  39551. /**
  39552. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39553. */
  39554. useEmissiveAsIllumination: boolean;
  39555. private _linkEmissiveWithDiffuse;
  39556. /**
  39557. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39558. * the emissive level when the final color is close to one.
  39559. */
  39560. linkEmissiveWithDiffuse: boolean;
  39561. private _useSpecularOverAlpha;
  39562. /**
  39563. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39564. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39565. */
  39566. useSpecularOverAlpha: boolean;
  39567. private _useReflectionOverAlpha;
  39568. /**
  39569. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39570. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39571. */
  39572. useReflectionOverAlpha: boolean;
  39573. private _disableLighting;
  39574. /**
  39575. * Does lights from the scene impacts this material.
  39576. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39577. */
  39578. disableLighting: boolean;
  39579. private _useObjectSpaceNormalMap;
  39580. /**
  39581. * Allows using an object space normal map (instead of tangent space).
  39582. */
  39583. useObjectSpaceNormalMap: boolean;
  39584. private _useParallax;
  39585. /**
  39586. * Is parallax enabled or not.
  39587. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39588. */
  39589. useParallax: boolean;
  39590. private _useParallaxOcclusion;
  39591. /**
  39592. * Is parallax occlusion enabled or not.
  39593. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39594. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39595. */
  39596. useParallaxOcclusion: boolean;
  39597. /**
  39598. * 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.
  39599. */
  39600. parallaxScaleBias: number;
  39601. private _roughness;
  39602. /**
  39603. * Helps to define how blurry the reflections should appears in the material.
  39604. */
  39605. roughness: number;
  39606. /**
  39607. * In case of refraction, define the value of the index of refraction.
  39608. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39609. */
  39610. indexOfRefraction: number;
  39611. /**
  39612. * Invert the refraction texture alongside the y axis.
  39613. * It can be useful with procedural textures or probe for instance.
  39614. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39615. */
  39616. invertRefractionY: boolean;
  39617. /**
  39618. * Defines the alpha limits in alpha test mode.
  39619. */
  39620. alphaCutOff: number;
  39621. private _useLightmapAsShadowmap;
  39622. /**
  39623. * In case of light mapping, define whether the map contains light or shadow informations.
  39624. */
  39625. useLightmapAsShadowmap: boolean;
  39626. private _diffuseFresnelParameters;
  39627. /**
  39628. * Define the diffuse fresnel parameters of the material.
  39629. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39630. */
  39631. diffuseFresnelParameters: FresnelParameters;
  39632. private _opacityFresnelParameters;
  39633. /**
  39634. * Define the opacity fresnel parameters of the material.
  39635. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39636. */
  39637. opacityFresnelParameters: FresnelParameters;
  39638. private _reflectionFresnelParameters;
  39639. /**
  39640. * Define the reflection fresnel parameters of the material.
  39641. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39642. */
  39643. reflectionFresnelParameters: FresnelParameters;
  39644. private _refractionFresnelParameters;
  39645. /**
  39646. * Define the refraction fresnel parameters of the material.
  39647. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39648. */
  39649. refractionFresnelParameters: FresnelParameters;
  39650. private _emissiveFresnelParameters;
  39651. /**
  39652. * Define the emissive fresnel parameters of the material.
  39653. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39654. */
  39655. emissiveFresnelParameters: FresnelParameters;
  39656. private _useReflectionFresnelFromSpecular;
  39657. /**
  39658. * If true automatically deducts the fresnels values from the material specularity.
  39659. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39660. */
  39661. useReflectionFresnelFromSpecular: boolean;
  39662. private _useGlossinessFromSpecularMapAlpha;
  39663. /**
  39664. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39665. */
  39666. useGlossinessFromSpecularMapAlpha: boolean;
  39667. private _maxSimultaneousLights;
  39668. /**
  39669. * Defines the maximum number of lights that can be used in the material
  39670. */
  39671. maxSimultaneousLights: number;
  39672. private _invertNormalMapX;
  39673. /**
  39674. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39675. */
  39676. invertNormalMapX: boolean;
  39677. private _invertNormalMapY;
  39678. /**
  39679. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39680. */
  39681. invertNormalMapY: boolean;
  39682. private _twoSidedLighting;
  39683. /**
  39684. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39685. */
  39686. twoSidedLighting: boolean;
  39687. /**
  39688. * Default configuration related to image processing available in the standard Material.
  39689. */
  39690. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39691. /**
  39692. * Gets the image processing configuration used either in this material.
  39693. */
  39694. /**
  39695. * Sets the Default image processing configuration used either in the this material.
  39696. *
  39697. * If sets to null, the scene one is in use.
  39698. */
  39699. imageProcessingConfiguration: ImageProcessingConfiguration;
  39700. /**
  39701. * Keep track of the image processing observer to allow dispose and replace.
  39702. */
  39703. private _imageProcessingObserver;
  39704. /**
  39705. * Attaches a new image processing configuration to the Standard Material.
  39706. * @param configuration
  39707. */
  39708. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39709. /**
  39710. * Gets wether the color curves effect is enabled.
  39711. */
  39712. /**
  39713. * Sets wether the color curves effect is enabled.
  39714. */
  39715. cameraColorCurvesEnabled: boolean;
  39716. /**
  39717. * Gets wether the color grading effect is enabled.
  39718. */
  39719. /**
  39720. * Gets wether the color grading effect is enabled.
  39721. */
  39722. cameraColorGradingEnabled: boolean;
  39723. /**
  39724. * Gets wether tonemapping is enabled or not.
  39725. */
  39726. /**
  39727. * Sets wether tonemapping is enabled or not
  39728. */
  39729. cameraToneMappingEnabled: boolean;
  39730. /**
  39731. * The camera exposure used on this material.
  39732. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39733. * This corresponds to a photographic exposure.
  39734. */
  39735. /**
  39736. * The camera exposure used on this material.
  39737. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39738. * This corresponds to a photographic exposure.
  39739. */
  39740. cameraExposure: number;
  39741. /**
  39742. * Gets The camera contrast used on this material.
  39743. */
  39744. /**
  39745. * Sets The camera contrast used on this material.
  39746. */
  39747. cameraContrast: number;
  39748. /**
  39749. * Gets the Color Grading 2D Lookup Texture.
  39750. */
  39751. /**
  39752. * Sets the Color Grading 2D Lookup Texture.
  39753. */
  39754. cameraColorGradingTexture: Nullable<BaseTexture>;
  39755. /**
  39756. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39757. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39758. * 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;
  39759. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39760. */
  39761. /**
  39762. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39763. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39764. * 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;
  39765. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39766. */
  39767. cameraColorCurves: Nullable<ColorCurves>;
  39768. /**
  39769. * Custom callback helping to override the default shader used in the material.
  39770. */
  39771. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39772. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39773. protected _worldViewProjectionMatrix: Matrix;
  39774. protected _globalAmbientColor: Color3;
  39775. protected _useLogarithmicDepth: boolean;
  39776. /**
  39777. * Instantiates a new standard material.
  39778. * This is the default material used in Babylon. It is the best trade off between quality
  39779. * and performances.
  39780. * @see http://doc.babylonjs.com/babylon101/materials
  39781. * @param name Define the name of the material in the scene
  39782. * @param scene Define the scene the material belong to
  39783. */
  39784. constructor(name: string, scene: Scene);
  39785. /**
  39786. * Gets a boolean indicating that current material needs to register RTT
  39787. */
  39788. readonly hasRenderTargetTextures: boolean;
  39789. /**
  39790. * Gets the current class name of the material e.g. "StandardMaterial"
  39791. * Mainly use in serialization.
  39792. * @returns the class name
  39793. */
  39794. getClassName(): string;
  39795. /**
  39796. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39797. * You can try switching to logarithmic depth.
  39798. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39799. */
  39800. useLogarithmicDepth: boolean;
  39801. /**
  39802. * Specifies if the material will require alpha blending
  39803. * @returns a boolean specifying if alpha blending is needed
  39804. */
  39805. needAlphaBlending(): boolean;
  39806. /**
  39807. * Specifies if this material should be rendered in alpha test mode
  39808. * @returns a boolean specifying if an alpha test is needed.
  39809. */
  39810. needAlphaTesting(): boolean;
  39811. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39812. /**
  39813. * Get the texture used for alpha test purpose.
  39814. * @returns the diffuse texture in case of the standard material.
  39815. */
  39816. getAlphaTestTexture(): Nullable<BaseTexture>;
  39817. /**
  39818. * Get if the submesh is ready to be used and all its information available.
  39819. * Child classes can use it to update shaders
  39820. * @param mesh defines the mesh to check
  39821. * @param subMesh defines which submesh to check
  39822. * @param useInstances specifies that instances should be used
  39823. * @returns a boolean indicating that the submesh is ready or not
  39824. */
  39825. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39826. /**
  39827. * Builds the material UBO layouts.
  39828. * Used internally during the effect preparation.
  39829. */
  39830. buildUniformLayout(): void;
  39831. /**
  39832. * Unbinds the material from the mesh
  39833. */
  39834. unbind(): void;
  39835. /**
  39836. * Binds the submesh to this material by preparing the effect and shader to draw
  39837. * @param world defines the world transformation matrix
  39838. * @param mesh defines the mesh containing the submesh
  39839. * @param subMesh defines the submesh to bind the material to
  39840. */
  39841. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39842. /**
  39843. * Get the list of animatables in the material.
  39844. * @returns the list of animatables object used in the material
  39845. */
  39846. getAnimatables(): IAnimatable[];
  39847. /**
  39848. * Gets the active textures from the material
  39849. * @returns an array of textures
  39850. */
  39851. getActiveTextures(): BaseTexture[];
  39852. /**
  39853. * Specifies if the material uses a texture
  39854. * @param texture defines the texture to check against the material
  39855. * @returns a boolean specifying if the material uses the texture
  39856. */
  39857. hasTexture(texture: BaseTexture): boolean;
  39858. /**
  39859. * Disposes the material
  39860. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39861. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39862. */
  39863. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39864. /**
  39865. * Makes a duplicate of the material, and gives it a new name
  39866. * @param name defines the new name for the duplicated material
  39867. * @returns the cloned material
  39868. */
  39869. clone(name: string): StandardMaterial;
  39870. /**
  39871. * Serializes this material in a JSON representation
  39872. * @returns the serialized material object
  39873. */
  39874. serialize(): any;
  39875. /**
  39876. * Creates a standard material from parsed material data
  39877. * @param source defines the JSON representation of the material
  39878. * @param scene defines the hosting scene
  39879. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39880. * @returns a new standard material
  39881. */
  39882. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39883. /**
  39884. * Are diffuse textures enabled in the application.
  39885. */
  39886. static DiffuseTextureEnabled: boolean;
  39887. /**
  39888. * Are ambient textures enabled in the application.
  39889. */
  39890. static AmbientTextureEnabled: boolean;
  39891. /**
  39892. * Are opacity textures enabled in the application.
  39893. */
  39894. static OpacityTextureEnabled: boolean;
  39895. /**
  39896. * Are reflection textures enabled in the application.
  39897. */
  39898. static ReflectionTextureEnabled: boolean;
  39899. /**
  39900. * Are emissive textures enabled in the application.
  39901. */
  39902. static EmissiveTextureEnabled: boolean;
  39903. /**
  39904. * Are specular textures enabled in the application.
  39905. */
  39906. static SpecularTextureEnabled: boolean;
  39907. /**
  39908. * Are bump textures enabled in the application.
  39909. */
  39910. static BumpTextureEnabled: boolean;
  39911. /**
  39912. * Are lightmap textures enabled in the application.
  39913. */
  39914. static LightmapTextureEnabled: boolean;
  39915. /**
  39916. * Are refraction textures enabled in the application.
  39917. */
  39918. static RefractionTextureEnabled: boolean;
  39919. /**
  39920. * Are color grading textures enabled in the application.
  39921. */
  39922. static ColorGradingTextureEnabled: boolean;
  39923. /**
  39924. * Are fresnels enabled in the application.
  39925. */
  39926. static FresnelEnabled: boolean;
  39927. }
  39928. }
  39929. declare module BABYLON {
  39930. /**
  39931. * A class extending Texture allowing drawing on a texture
  39932. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39933. */
  39934. export class DynamicTexture extends Texture {
  39935. private _generateMipMaps;
  39936. private _canvas;
  39937. private _context;
  39938. private _engine;
  39939. /**
  39940. * Creates a DynamicTexture
  39941. * @param name defines the name of the texture
  39942. * @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
  39943. * @param scene defines the scene where you want the texture
  39944. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39945. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39946. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39947. */
  39948. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39949. /**
  39950. * Get the current class name of the texture useful for serialization or dynamic coding.
  39951. * @returns "DynamicTexture"
  39952. */
  39953. getClassName(): string;
  39954. /**
  39955. * Gets the current state of canRescale
  39956. */
  39957. readonly canRescale: boolean;
  39958. private _recreate;
  39959. /**
  39960. * Scales the texture
  39961. * @param ratio the scale factor to apply to both width and height
  39962. */
  39963. scale(ratio: number): void;
  39964. /**
  39965. * Resizes the texture
  39966. * @param width the new width
  39967. * @param height the new height
  39968. */
  39969. scaleTo(width: number, height: number): void;
  39970. /**
  39971. * Gets the context of the canvas used by the texture
  39972. * @returns the canvas context of the dynamic texture
  39973. */
  39974. getContext(): CanvasRenderingContext2D;
  39975. /**
  39976. * Clears the texture
  39977. */
  39978. clear(): void;
  39979. /**
  39980. * Updates the texture
  39981. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39982. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39983. */
  39984. update(invertY?: boolean, premulAlpha?: boolean): void;
  39985. /**
  39986. * Draws text onto the texture
  39987. * @param text defines the text to be drawn
  39988. * @param x defines the placement of the text from the left
  39989. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39990. * @param font defines the font to be used with font-style, font-size, font-name
  39991. * @param color defines the color used for the text
  39992. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39993. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39994. * @param update defines whether texture is immediately update (default is true)
  39995. */
  39996. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39997. /**
  39998. * Clones the texture
  39999. * @returns the clone of the texture.
  40000. */
  40001. clone(): DynamicTexture;
  40002. /**
  40003. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40004. * @returns a serialized dynamic texture object
  40005. */
  40006. serialize(): any;
  40007. /** @hidden */
  40008. _rebuild(): void;
  40009. }
  40010. }
  40011. declare module BABYLON {
  40012. /** @hidden */
  40013. export var imageProcessingPixelShader: {
  40014. name: string;
  40015. shader: string;
  40016. };
  40017. }
  40018. declare module BABYLON {
  40019. /**
  40020. * ImageProcessingPostProcess
  40021. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40022. */
  40023. export class ImageProcessingPostProcess extends PostProcess {
  40024. /**
  40025. * Default configuration related to image processing available in the PBR Material.
  40026. */
  40027. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40028. /**
  40029. * Gets the image processing configuration used either in this material.
  40030. */
  40031. /**
  40032. * Sets the Default image processing configuration used either in the this material.
  40033. *
  40034. * If sets to null, the scene one is in use.
  40035. */
  40036. imageProcessingConfiguration: ImageProcessingConfiguration;
  40037. /**
  40038. * Keep track of the image processing observer to allow dispose and replace.
  40039. */
  40040. private _imageProcessingObserver;
  40041. /**
  40042. * Attaches a new image processing configuration to the PBR Material.
  40043. * @param configuration
  40044. */
  40045. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40046. /**
  40047. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40048. */
  40049. /**
  40050. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40051. */
  40052. colorCurves: Nullable<ColorCurves>;
  40053. /**
  40054. * Gets wether the color curves effect is enabled.
  40055. */
  40056. /**
  40057. * Sets wether the color curves effect is enabled.
  40058. */
  40059. colorCurvesEnabled: boolean;
  40060. /**
  40061. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40062. */
  40063. /**
  40064. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40065. */
  40066. colorGradingTexture: Nullable<BaseTexture>;
  40067. /**
  40068. * Gets wether the color grading effect is enabled.
  40069. */
  40070. /**
  40071. * Gets wether the color grading effect is enabled.
  40072. */
  40073. colorGradingEnabled: boolean;
  40074. /**
  40075. * Gets exposure used in the effect.
  40076. */
  40077. /**
  40078. * Sets exposure used in the effect.
  40079. */
  40080. exposure: number;
  40081. /**
  40082. * Gets wether tonemapping is enabled or not.
  40083. */
  40084. /**
  40085. * Sets wether tonemapping is enabled or not
  40086. */
  40087. toneMappingEnabled: boolean;
  40088. /**
  40089. * Gets the type of tone mapping effect.
  40090. */
  40091. /**
  40092. * Sets the type of tone mapping effect.
  40093. */
  40094. toneMappingType: number;
  40095. /**
  40096. * Gets contrast used in the effect.
  40097. */
  40098. /**
  40099. * Sets contrast used in the effect.
  40100. */
  40101. contrast: number;
  40102. /**
  40103. * Gets Vignette stretch size.
  40104. */
  40105. /**
  40106. * Sets Vignette stretch size.
  40107. */
  40108. vignetteStretch: number;
  40109. /**
  40110. * Gets Vignette centre X Offset.
  40111. */
  40112. /**
  40113. * Sets Vignette centre X Offset.
  40114. */
  40115. vignetteCentreX: number;
  40116. /**
  40117. * Gets Vignette centre Y Offset.
  40118. */
  40119. /**
  40120. * Sets Vignette centre Y Offset.
  40121. */
  40122. vignetteCentreY: number;
  40123. /**
  40124. * Gets Vignette weight or intensity of the vignette effect.
  40125. */
  40126. /**
  40127. * Sets Vignette weight or intensity of the vignette effect.
  40128. */
  40129. vignetteWeight: number;
  40130. /**
  40131. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40132. * if vignetteEnabled is set to true.
  40133. */
  40134. /**
  40135. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40136. * if vignetteEnabled is set to true.
  40137. */
  40138. vignetteColor: Color4;
  40139. /**
  40140. * Gets Camera field of view used by the Vignette effect.
  40141. */
  40142. /**
  40143. * Sets Camera field of view used by the Vignette effect.
  40144. */
  40145. vignetteCameraFov: number;
  40146. /**
  40147. * Gets the vignette blend mode allowing different kind of effect.
  40148. */
  40149. /**
  40150. * Sets the vignette blend mode allowing different kind of effect.
  40151. */
  40152. vignetteBlendMode: number;
  40153. /**
  40154. * Gets wether the vignette effect is enabled.
  40155. */
  40156. /**
  40157. * Sets wether the vignette effect is enabled.
  40158. */
  40159. vignetteEnabled: boolean;
  40160. private _fromLinearSpace;
  40161. /**
  40162. * Gets wether the input of the processing is in Gamma or Linear Space.
  40163. */
  40164. /**
  40165. * Sets wether the input of the processing is in Gamma or Linear Space.
  40166. */
  40167. fromLinearSpace: boolean;
  40168. /**
  40169. * Defines cache preventing GC.
  40170. */
  40171. private _defines;
  40172. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40173. /**
  40174. * "ImageProcessingPostProcess"
  40175. * @returns "ImageProcessingPostProcess"
  40176. */
  40177. getClassName(): string;
  40178. protected _updateParameters(): void;
  40179. dispose(camera?: Camera): void;
  40180. }
  40181. }
  40182. declare module BABYLON {
  40183. /**
  40184. * Class containing static functions to help procedurally build meshes
  40185. */
  40186. export class GroundBuilder {
  40187. /**
  40188. * Creates a ground mesh
  40189. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40190. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40192. * @param name defines the name of the mesh
  40193. * @param options defines the options used to create the mesh
  40194. * @param scene defines the hosting scene
  40195. * @returns the ground mesh
  40196. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40197. */
  40198. static CreateGround(name: string, options: {
  40199. width?: number;
  40200. height?: number;
  40201. subdivisions?: number;
  40202. subdivisionsX?: number;
  40203. subdivisionsY?: number;
  40204. updatable?: boolean;
  40205. }, scene: any): Mesh;
  40206. /**
  40207. * Creates a tiled ground mesh
  40208. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40209. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40210. * * 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
  40211. * * 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
  40212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40213. * @param name defines the name of the mesh
  40214. * @param options defines the options used to create the mesh
  40215. * @param scene defines the hosting scene
  40216. * @returns the tiled ground mesh
  40217. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40218. */
  40219. static CreateTiledGround(name: string, options: {
  40220. xmin: number;
  40221. zmin: number;
  40222. xmax: number;
  40223. zmax: number;
  40224. subdivisions?: {
  40225. w: number;
  40226. h: number;
  40227. };
  40228. precision?: {
  40229. w: number;
  40230. h: number;
  40231. };
  40232. updatable?: boolean;
  40233. }, scene?: Nullable<Scene>): Mesh;
  40234. /**
  40235. * Creates a ground mesh from a height map
  40236. * * The parameter `url` sets the URL of the height map image resource.
  40237. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40238. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40239. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40240. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40241. * * 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.
  40242. * * 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).
  40243. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40245. * @param name defines the name of the mesh
  40246. * @param url defines the url to the height map
  40247. * @param options defines the options used to create the mesh
  40248. * @param scene defines the hosting scene
  40249. * @returns the ground mesh
  40250. * @see https://doc.babylonjs.com/babylon101/height_map
  40251. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40252. */
  40253. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40254. width?: number;
  40255. height?: number;
  40256. subdivisions?: number;
  40257. minHeight?: number;
  40258. maxHeight?: number;
  40259. colorFilter?: Color3;
  40260. alphaFilter?: number;
  40261. updatable?: boolean;
  40262. onReady?: (mesh: GroundMesh) => void;
  40263. }, scene?: Nullable<Scene>): GroundMesh;
  40264. }
  40265. }
  40266. declare module BABYLON {
  40267. /**
  40268. * Class containing static functions to help procedurally build meshes
  40269. */
  40270. export class TorusBuilder {
  40271. /**
  40272. * Creates a torus mesh
  40273. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40274. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40275. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40277. * * 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
  40278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40279. * @param name defines the name of the mesh
  40280. * @param options defines the options used to create the mesh
  40281. * @param scene defines the hosting scene
  40282. * @returns the torus mesh
  40283. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40284. */
  40285. static CreateTorus(name: string, options: {
  40286. diameter?: number;
  40287. thickness?: number;
  40288. tessellation?: number;
  40289. updatable?: boolean;
  40290. sideOrientation?: number;
  40291. frontUVs?: Vector4;
  40292. backUVs?: Vector4;
  40293. }, scene: any): Mesh;
  40294. }
  40295. }
  40296. declare module BABYLON {
  40297. /**
  40298. * Class containing static functions to help procedurally build meshes
  40299. */
  40300. export class CylinderBuilder {
  40301. /**
  40302. * Creates a cylinder or a cone mesh
  40303. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40304. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40305. * * 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.
  40306. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40307. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40308. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40309. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40310. * * 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).
  40311. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40312. * * 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).
  40313. * * 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
  40314. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40315. * * 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
  40316. * * 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.
  40317. * * If `enclose` is false, a ring surface is one element.
  40318. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40319. * * 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
  40320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40321. * * 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
  40322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40323. * @param name defines the name of the mesh
  40324. * @param options defines the options used to create the mesh
  40325. * @param scene defines the hosting scene
  40326. * @returns the cylinder mesh
  40327. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40328. */
  40329. static CreateCylinder(name: string, options: {
  40330. height?: number;
  40331. diameterTop?: number;
  40332. diameterBottom?: number;
  40333. diameter?: number;
  40334. tessellation?: number;
  40335. subdivisions?: number;
  40336. arc?: number;
  40337. faceColors?: Color4[];
  40338. faceUV?: Vector4[];
  40339. updatable?: boolean;
  40340. hasRings?: boolean;
  40341. enclose?: boolean;
  40342. cap?: number;
  40343. sideOrientation?: number;
  40344. frontUVs?: Vector4;
  40345. backUVs?: Vector4;
  40346. }, scene: any): Mesh;
  40347. }
  40348. }
  40349. declare module BABYLON {
  40350. /**
  40351. * Options to modify the vr teleportation behavior.
  40352. */
  40353. export interface VRTeleportationOptions {
  40354. /**
  40355. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40356. */
  40357. floorMeshName?: string;
  40358. /**
  40359. * A list of meshes to be used as the teleportation floor. (default: empty)
  40360. */
  40361. floorMeshes?: Mesh[];
  40362. }
  40363. /**
  40364. * Options to modify the vr experience helper's behavior.
  40365. */
  40366. export interface VRExperienceHelperOptions extends WebVROptions {
  40367. /**
  40368. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40369. */
  40370. createDeviceOrientationCamera?: boolean;
  40371. /**
  40372. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40373. */
  40374. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40375. /**
  40376. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40377. */
  40378. laserToggle?: boolean;
  40379. /**
  40380. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40381. */
  40382. floorMeshes?: Mesh[];
  40383. /**
  40384. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40385. */
  40386. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40387. }
  40388. /**
  40389. * Event containing information after VR has been entered
  40390. */
  40391. export class OnAfterEnteringVRObservableEvent {
  40392. /**
  40393. * If entering vr was successful
  40394. */
  40395. success: boolean;
  40396. }
  40397. /**
  40398. * Helps to quickly add VR support to an existing scene.
  40399. * See http://doc.babylonjs.com/how_to/webvr_helper
  40400. */
  40401. export class VRExperienceHelper {
  40402. /** Options to modify the vr experience helper's behavior. */
  40403. webVROptions: VRExperienceHelperOptions;
  40404. private _scene;
  40405. private _position;
  40406. private _btnVR;
  40407. private _btnVRDisplayed;
  40408. private _webVRsupported;
  40409. private _webVRready;
  40410. private _webVRrequesting;
  40411. private _webVRpresenting;
  40412. private _hasEnteredVR;
  40413. private _fullscreenVRpresenting;
  40414. private _canvas;
  40415. private _webVRCamera;
  40416. private _vrDeviceOrientationCamera;
  40417. private _deviceOrientationCamera;
  40418. private _existingCamera;
  40419. private _onKeyDown;
  40420. private _onVrDisplayPresentChange;
  40421. private _onVRDisplayChanged;
  40422. private _onVRRequestPresentStart;
  40423. private _onVRRequestPresentComplete;
  40424. /**
  40425. * Observable raised right before entering VR.
  40426. */
  40427. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40428. /**
  40429. * Observable raised when entering VR has completed.
  40430. */
  40431. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40432. /**
  40433. * Observable raised when exiting VR.
  40434. */
  40435. onExitingVRObservable: Observable<VRExperienceHelper>;
  40436. /**
  40437. * Observable raised when controller mesh is loaded.
  40438. */
  40439. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40440. /** Return this.onEnteringVRObservable
  40441. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40442. */
  40443. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40444. /** Return this.onExitingVRObservable
  40445. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40446. */
  40447. readonly onExitingVR: Observable<VRExperienceHelper>;
  40448. /** Return this.onControllerMeshLoadedObservable
  40449. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40450. */
  40451. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40452. private _rayLength;
  40453. private _useCustomVRButton;
  40454. private _teleportationRequested;
  40455. private _teleportActive;
  40456. private _floorMeshName;
  40457. private _floorMeshesCollection;
  40458. private _rotationAllowed;
  40459. private _teleportBackwardsVector;
  40460. private _teleportationTarget;
  40461. private _isDefaultTeleportationTarget;
  40462. private _postProcessMove;
  40463. private _teleportationFillColor;
  40464. private _teleportationBorderColor;
  40465. private _rotationAngle;
  40466. private _haloCenter;
  40467. private _cameraGazer;
  40468. private _padSensibilityUp;
  40469. private _padSensibilityDown;
  40470. private _leftController;
  40471. private _rightController;
  40472. /**
  40473. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40474. */
  40475. onNewMeshSelected: Observable<AbstractMesh>;
  40476. /**
  40477. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40478. */
  40479. onNewMeshPicked: Observable<PickingInfo>;
  40480. private _circleEase;
  40481. /**
  40482. * Observable raised before camera teleportation
  40483. */
  40484. onBeforeCameraTeleport: Observable<Vector3>;
  40485. /**
  40486. * Observable raised after camera teleportation
  40487. */
  40488. onAfterCameraTeleport: Observable<Vector3>;
  40489. /**
  40490. * Observable raised when current selected mesh gets unselected
  40491. */
  40492. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40493. private _raySelectionPredicate;
  40494. /**
  40495. * To be optionaly changed by user to define custom ray selection
  40496. */
  40497. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40498. /**
  40499. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40500. */
  40501. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40502. /**
  40503. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40504. */
  40505. teleportationEnabled: boolean;
  40506. private _defaultHeight;
  40507. private _teleportationInitialized;
  40508. private _interactionsEnabled;
  40509. private _interactionsRequested;
  40510. private _displayGaze;
  40511. private _displayLaserPointer;
  40512. /**
  40513. * The mesh used to display where the user is going to teleport.
  40514. */
  40515. /**
  40516. * Sets the mesh to be used to display where the user is going to teleport.
  40517. */
  40518. teleportationTarget: Mesh;
  40519. /**
  40520. * 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
  40521. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40522. * See http://doc.babylonjs.com/resources/baking_transformations
  40523. */
  40524. gazeTrackerMesh: Mesh;
  40525. /**
  40526. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40527. */
  40528. updateGazeTrackerScale: boolean;
  40529. /**
  40530. * If the gaze trackers color should be updated when selecting meshes
  40531. */
  40532. updateGazeTrackerColor: boolean;
  40533. /**
  40534. * The gaze tracking mesh corresponding to the left controller
  40535. */
  40536. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40537. /**
  40538. * The gaze tracking mesh corresponding to the right controller
  40539. */
  40540. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40541. /**
  40542. * If the ray of the gaze should be displayed.
  40543. */
  40544. /**
  40545. * Sets if the ray of the gaze should be displayed.
  40546. */
  40547. displayGaze: boolean;
  40548. /**
  40549. * If the ray of the LaserPointer should be displayed.
  40550. */
  40551. /**
  40552. * Sets if the ray of the LaserPointer should be displayed.
  40553. */
  40554. displayLaserPointer: boolean;
  40555. /**
  40556. * The deviceOrientationCamera used as the camera when not in VR.
  40557. */
  40558. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40559. /**
  40560. * Based on the current WebVR support, returns the current VR camera used.
  40561. */
  40562. readonly currentVRCamera: Nullable<Camera>;
  40563. /**
  40564. * The webVRCamera which is used when in VR.
  40565. */
  40566. readonly webVRCamera: WebVRFreeCamera;
  40567. /**
  40568. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40569. */
  40570. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40571. private readonly _teleportationRequestInitiated;
  40572. /**
  40573. * Defines wether or not Pointer lock should be requested when switching to
  40574. * full screen.
  40575. */
  40576. requestPointerLockOnFullScreen: boolean;
  40577. /**
  40578. * Instantiates a VRExperienceHelper.
  40579. * Helps to quickly add VR support to an existing scene.
  40580. * @param scene The scene the VRExperienceHelper belongs to.
  40581. * @param webVROptions Options to modify the vr experience helper's behavior.
  40582. */
  40583. constructor(scene: Scene,
  40584. /** Options to modify the vr experience helper's behavior. */
  40585. webVROptions?: VRExperienceHelperOptions);
  40586. private _onDefaultMeshLoaded;
  40587. private _onResize;
  40588. private _onFullscreenChange;
  40589. /**
  40590. * Gets a value indicating if we are currently in VR mode.
  40591. */
  40592. readonly isInVRMode: boolean;
  40593. private onVrDisplayPresentChange;
  40594. private onVRDisplayChanged;
  40595. private moveButtonToBottomRight;
  40596. private displayVRButton;
  40597. private updateButtonVisibility;
  40598. private _cachedAngularSensibility;
  40599. /**
  40600. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40601. * Otherwise, will use the fullscreen API.
  40602. */
  40603. enterVR(): void;
  40604. /**
  40605. * Attempt to exit VR, or fullscreen.
  40606. */
  40607. exitVR(): void;
  40608. /**
  40609. * The position of the vr experience helper.
  40610. */
  40611. /**
  40612. * Sets the position of the vr experience helper.
  40613. */
  40614. position: Vector3;
  40615. /**
  40616. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40617. */
  40618. enableInteractions(): void;
  40619. private readonly _noControllerIsActive;
  40620. private beforeRender;
  40621. private _isTeleportationFloor;
  40622. /**
  40623. * Adds a floor mesh to be used for teleportation.
  40624. * @param floorMesh the mesh to be used for teleportation.
  40625. */
  40626. addFloorMesh(floorMesh: Mesh): void;
  40627. /**
  40628. * Removes a floor mesh from being used for teleportation.
  40629. * @param floorMesh the mesh to be removed.
  40630. */
  40631. removeFloorMesh(floorMesh: Mesh): void;
  40632. /**
  40633. * Enables interactions and teleportation using the VR controllers and gaze.
  40634. * @param vrTeleportationOptions options to modify teleportation behavior.
  40635. */
  40636. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40637. private _onNewGamepadConnected;
  40638. private _tryEnableInteractionOnController;
  40639. private _onNewGamepadDisconnected;
  40640. private _enableInteractionOnController;
  40641. private _checkTeleportWithRay;
  40642. private _checkRotate;
  40643. private _checkTeleportBackwards;
  40644. private _enableTeleportationOnController;
  40645. private _createTeleportationCircles;
  40646. private _displayTeleportationTarget;
  40647. private _hideTeleportationTarget;
  40648. private _rotateCamera;
  40649. private _moveTeleportationSelectorTo;
  40650. private _workingVector;
  40651. private _workingQuaternion;
  40652. private _workingMatrix;
  40653. /**
  40654. * Teleports the users feet to the desired location
  40655. * @param location The location where the user's feet should be placed
  40656. */
  40657. teleportCamera(location: Vector3): void;
  40658. private _convertNormalToDirectionOfRay;
  40659. private _castRayAndSelectObject;
  40660. private _notifySelectedMeshUnselected;
  40661. /**
  40662. * Sets the color of the laser ray from the vr controllers.
  40663. * @param color new color for the ray.
  40664. */
  40665. changeLaserColor(color: Color3): void;
  40666. /**
  40667. * Sets the color of the ray from the vr headsets gaze.
  40668. * @param color new color for the ray.
  40669. */
  40670. changeGazeColor(color: Color3): void;
  40671. /**
  40672. * Exits VR and disposes of the vr experience helper
  40673. */
  40674. dispose(): void;
  40675. /**
  40676. * Gets the name of the VRExperienceHelper class
  40677. * @returns "VRExperienceHelper"
  40678. */
  40679. getClassName(): string;
  40680. }
  40681. }
  40682. declare module BABYLON {
  40683. /**
  40684. * Manages an XRSession to work with Babylon's engine
  40685. * @see https://doc.babylonjs.com/how_to/webxr
  40686. */
  40687. export class WebXRSessionManager implements IDisposable {
  40688. private scene;
  40689. /**
  40690. * Fires every time a new xrFrame arrives which can be used to update the camera
  40691. */
  40692. onXRFrameObservable: Observable<any>;
  40693. /**
  40694. * Fires when the xr session is ended either by the device or manually done
  40695. */
  40696. onXRSessionEnded: Observable<any>;
  40697. /**
  40698. * Underlying xr session
  40699. */
  40700. session: XRSession;
  40701. /**
  40702. * Type of reference space used when creating the session
  40703. */
  40704. referenceSpace: XRReferenceSpace;
  40705. /** @hidden */
  40706. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40707. /**
  40708. * Current XR frame
  40709. */
  40710. currentFrame: Nullable<XRFrame>;
  40711. private _xrNavigator;
  40712. private baseLayer;
  40713. /**
  40714. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40715. * @param scene The scene which the session should be created for
  40716. */
  40717. constructor(scene: Scene);
  40718. /**
  40719. * Initializes the manager
  40720. * After initialization enterXR can be called to start an XR session
  40721. * @returns Promise which resolves after it is initialized
  40722. */
  40723. initializeAsync(): Promise<void>;
  40724. /**
  40725. * Initializes an xr session
  40726. * @param xrSessionMode mode to initialize
  40727. * @returns a promise which will resolve once the session has been initialized
  40728. */
  40729. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40730. /**
  40731. * Sets the reference space on the xr session
  40732. * @param referenceSpace space to set
  40733. * @returns a promise that will resolve once the reference space has been set
  40734. */
  40735. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40736. /**
  40737. * Updates the render state of the session
  40738. * @param state state to set
  40739. * @returns a promise that resolves once the render state has been updated
  40740. */
  40741. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40742. /**
  40743. * Starts rendering to the xr layer
  40744. * @returns a promise that will resolve once rendering has started
  40745. */
  40746. startRenderingToXRAsync(): Promise<void>;
  40747. /**
  40748. * Stops the xrSession and restores the renderloop
  40749. * @returns Promise which resolves after it exits XR
  40750. */
  40751. exitXRAsync(): Promise<unknown>;
  40752. /**
  40753. * Checks if a session would be supported for the creation options specified
  40754. * @param sessionMode session mode to check if supported eg. immersive-vr
  40755. * @returns true if supported
  40756. */
  40757. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40758. /**
  40759. * @hidden
  40760. * Converts the render layer of xrSession to a render target
  40761. * @param session session to create render target for
  40762. * @param scene scene the new render target should be created for
  40763. */
  40764. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40765. /**
  40766. * Disposes of the session manager
  40767. */
  40768. dispose(): void;
  40769. }
  40770. }
  40771. declare module BABYLON {
  40772. /**
  40773. * WebXR Camera which holds the views for the xrSession
  40774. * @see https://doc.babylonjs.com/how_to/webxr
  40775. */
  40776. export class WebXRCamera extends FreeCamera {
  40777. private static _TmpMatrix;
  40778. /**
  40779. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40780. * @param name the name of the camera
  40781. * @param scene the scene to add the camera to
  40782. */
  40783. constructor(name: string, scene: Scene);
  40784. private _updateNumberOfRigCameras;
  40785. /** @hidden */
  40786. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40787. /**
  40788. * Updates the cameras position from the current pose information of the XR session
  40789. * @param xrSessionManager the session containing pose information
  40790. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40791. */
  40792. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40793. }
  40794. }
  40795. declare module BABYLON {
  40796. /**
  40797. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40798. */
  40799. export class WebXRManagedOutputCanvas implements IDisposable {
  40800. private helper;
  40801. private _canvas;
  40802. /**
  40803. * xrpresent context of the canvas which can be used to display/mirror xr content
  40804. */
  40805. canvasContext: WebGLRenderingContext;
  40806. /**
  40807. * xr layer for the canvas
  40808. */
  40809. xrLayer: Nullable<XRWebGLLayer>;
  40810. /**
  40811. * Initializes the xr layer for the session
  40812. * @param xrSession xr session
  40813. * @returns a promise that will resolve once the XR Layer has been created
  40814. */
  40815. initializeXRLayerAsync(xrSession: any): any;
  40816. /**
  40817. * Initializes the canvas to be added/removed upon entering/exiting xr
  40818. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40819. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40820. */
  40821. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40822. /**
  40823. * Disposes of the object
  40824. */
  40825. dispose(): void;
  40826. private _setManagedOutputCanvas;
  40827. private _addCanvas;
  40828. private _removeCanvas;
  40829. }
  40830. }
  40831. declare module BABYLON {
  40832. /**
  40833. * States of the webXR experience
  40834. */
  40835. export enum WebXRState {
  40836. /**
  40837. * Transitioning to being in XR mode
  40838. */
  40839. ENTERING_XR = 0,
  40840. /**
  40841. * Transitioning to non XR mode
  40842. */
  40843. EXITING_XR = 1,
  40844. /**
  40845. * In XR mode and presenting
  40846. */
  40847. IN_XR = 2,
  40848. /**
  40849. * Not entered XR mode
  40850. */
  40851. NOT_IN_XR = 3
  40852. }
  40853. /**
  40854. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40855. * @see https://doc.babylonjs.com/how_to/webxr
  40856. */
  40857. export class WebXRExperienceHelper implements IDisposable {
  40858. private scene;
  40859. /**
  40860. * 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
  40861. */
  40862. container: AbstractMesh;
  40863. /**
  40864. * Camera used to render xr content
  40865. */
  40866. camera: WebXRCamera;
  40867. /**
  40868. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40869. */
  40870. state: WebXRState;
  40871. private _setState;
  40872. private static _TmpVector;
  40873. /**
  40874. * Fires when the state of the experience helper has changed
  40875. */
  40876. onStateChangedObservable: Observable<WebXRState>;
  40877. /** Session manager used to keep track of xr session */
  40878. sessionManager: WebXRSessionManager;
  40879. private _nonVRCamera;
  40880. private _originalSceneAutoClear;
  40881. private _supported;
  40882. /**
  40883. * Creates the experience helper
  40884. * @param scene the scene to attach the experience helper to
  40885. * @returns a promise for the experience helper
  40886. */
  40887. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40888. /**
  40889. * Creates a WebXRExperienceHelper
  40890. * @param scene The scene the helper should be created in
  40891. */
  40892. private constructor();
  40893. /**
  40894. * Exits XR mode and returns the scene to its original state
  40895. * @returns promise that resolves after xr mode has exited
  40896. */
  40897. exitXRAsync(): Promise<unknown>;
  40898. /**
  40899. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40900. * @param sessionCreationOptions options for the XR session
  40901. * @param referenceSpaceType frame of reference of the XR session
  40902. * @param outputCanvas the output canvas that will be used to enter XR mode
  40903. * @returns promise that resolves after xr mode has entered
  40904. */
  40905. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40906. /**
  40907. * Updates the global position of the camera by moving the camera's container
  40908. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40909. * @param position The desired global position of the camera
  40910. */
  40911. setPositionOfCameraUsingContainer(position: Vector3): void;
  40912. /**
  40913. * Rotates the xr camera by rotating the camera's container around the camera's position
  40914. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40915. * @param rotation the desired quaternion rotation to apply to the camera
  40916. */
  40917. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40918. /**
  40919. * Disposes of the experience helper
  40920. */
  40921. dispose(): void;
  40922. }
  40923. }
  40924. declare module BABYLON {
  40925. /**
  40926. * Button which can be used to enter a different mode of XR
  40927. */
  40928. export class WebXREnterExitUIButton {
  40929. /** button element */
  40930. element: HTMLElement;
  40931. /** XR initialization options for the button */
  40932. sessionMode: XRSessionMode;
  40933. /** Reference space type */
  40934. referenceSpaceType: XRReferenceSpaceType;
  40935. /**
  40936. * Creates a WebXREnterExitUIButton
  40937. * @param element button element
  40938. * @param sessionMode XR initialization session mode
  40939. * @param referenceSpaceType the type of reference space to be used
  40940. */
  40941. constructor(
  40942. /** button element */
  40943. element: HTMLElement,
  40944. /** XR initialization options for the button */
  40945. sessionMode: XRSessionMode,
  40946. /** Reference space type */
  40947. referenceSpaceType: XRReferenceSpaceType);
  40948. /**
  40949. * Overwritable function which can be used to update the button's visuals when the state changes
  40950. * @param activeButton the current active button in the UI
  40951. */
  40952. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40953. }
  40954. /**
  40955. * Options to create the webXR UI
  40956. */
  40957. export class WebXREnterExitUIOptions {
  40958. /**
  40959. * Context to enter xr with
  40960. */
  40961. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  40962. /**
  40963. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40964. */
  40965. customButtons?: Array<WebXREnterExitUIButton>;
  40966. }
  40967. /**
  40968. * UI to allow the user to enter/exit XR mode
  40969. */
  40970. export class WebXREnterExitUI implements IDisposable {
  40971. private scene;
  40972. private _overlay;
  40973. private _buttons;
  40974. private _activeButton;
  40975. /**
  40976. * Fired every time the active button is changed.
  40977. *
  40978. * When xr is entered via a button that launches xr that button will be the callback parameter
  40979. *
  40980. * When exiting xr the callback parameter will be null)
  40981. */
  40982. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40983. /**
  40984. * Creates UI to allow the user to enter/exit XR mode
  40985. * @param scene the scene to add the ui to
  40986. * @param helper the xr experience helper to enter/exit xr with
  40987. * @param options options to configure the UI
  40988. * @returns the created ui
  40989. */
  40990. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40991. private constructor();
  40992. private _updateButtons;
  40993. /**
  40994. * Disposes of the object
  40995. */
  40996. dispose(): void;
  40997. }
  40998. }
  40999. declare module BABYLON {
  41000. /**
  41001. * Represents an XR input
  41002. */
  41003. export class WebXRController {
  41004. private scene;
  41005. /** The underlying input source for the controller */
  41006. inputSource: XRInputSource;
  41007. private parentContainer;
  41008. /**
  41009. * 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
  41010. */
  41011. grip?: AbstractMesh;
  41012. /**
  41013. * Pointer which can be used to select objects or attach a visible laser to
  41014. */
  41015. pointer: AbstractMesh;
  41016. /**
  41017. * Event that fires when the controller is removed/disposed
  41018. */
  41019. onDisposeObservable: Observable<{}>;
  41020. private _tmpMatrix;
  41021. private _tmpQuaternion;
  41022. private _tmpVector;
  41023. /**
  41024. * Creates the controller
  41025. * @see https://doc.babylonjs.com/how_to/webxr
  41026. * @param scene the scene which the controller should be associated to
  41027. * @param inputSource the underlying input source for the controller
  41028. * @param parentContainer parent that the controller meshes should be children of
  41029. */
  41030. constructor(scene: Scene,
  41031. /** The underlying input source for the controller */
  41032. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41033. /**
  41034. * Updates the controller pose based on the given XRFrame
  41035. * @param xrFrame xr frame to update the pose with
  41036. * @param referenceSpace reference space to use
  41037. */
  41038. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41039. /**
  41040. * Gets a world space ray coming from the controller
  41041. * @param result the resulting ray
  41042. */
  41043. getWorldPointerRayToRef(result: Ray): void;
  41044. /**
  41045. * Disposes of the object
  41046. */
  41047. dispose(): void;
  41048. }
  41049. }
  41050. declare module BABYLON {
  41051. /**
  41052. * XR input used to track XR inputs such as controllers/rays
  41053. */
  41054. export class WebXRInput implements IDisposable {
  41055. /**
  41056. * Base experience the input listens to
  41057. */
  41058. baseExperience: WebXRExperienceHelper;
  41059. /**
  41060. * XR controllers being tracked
  41061. */
  41062. controllers: Array<WebXRController>;
  41063. private _frameObserver;
  41064. private _stateObserver;
  41065. /**
  41066. * Event when a controller has been connected/added
  41067. */
  41068. onControllerAddedObservable: Observable<WebXRController>;
  41069. /**
  41070. * Event when a controller has been removed/disconnected
  41071. */
  41072. onControllerRemovedObservable: Observable<WebXRController>;
  41073. /**
  41074. * Initializes the WebXRInput
  41075. * @param baseExperience experience helper which the input should be created for
  41076. */
  41077. constructor(
  41078. /**
  41079. * Base experience the input listens to
  41080. */
  41081. baseExperience: WebXRExperienceHelper);
  41082. private _onInputSourcesChange;
  41083. private _addAndRemoveControllers;
  41084. /**
  41085. * Disposes of the object
  41086. */
  41087. dispose(): void;
  41088. }
  41089. }
  41090. declare module BABYLON {
  41091. /**
  41092. * Enables teleportation
  41093. */
  41094. export class WebXRControllerTeleportation {
  41095. private _teleportationFillColor;
  41096. private _teleportationBorderColor;
  41097. private _tmpRay;
  41098. private _tmpVector;
  41099. /**
  41100. * Creates a WebXRControllerTeleportation
  41101. * @param input input manager to add teleportation to
  41102. * @param floorMeshes floormeshes which can be teleported to
  41103. */
  41104. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41105. }
  41106. }
  41107. declare module BABYLON {
  41108. /**
  41109. * Handles pointer input automatically for the pointer of XR controllers
  41110. */
  41111. export class WebXRControllerPointerSelection {
  41112. private static _idCounter;
  41113. private _tmpRay;
  41114. /**
  41115. * Creates a WebXRControllerPointerSelection
  41116. * @param input input manager to setup pointer selection
  41117. */
  41118. constructor(input: WebXRInput);
  41119. private _convertNormalToDirectionOfRay;
  41120. private _updatePointerDistance;
  41121. }
  41122. }
  41123. declare module BABYLON {
  41124. /**
  41125. * Class used to represent data loading progression
  41126. */
  41127. export class SceneLoaderProgressEvent {
  41128. /** defines if data length to load can be evaluated */
  41129. readonly lengthComputable: boolean;
  41130. /** defines the loaded data length */
  41131. readonly loaded: number;
  41132. /** defines the data length to load */
  41133. readonly total: number;
  41134. /**
  41135. * Create a new progress event
  41136. * @param lengthComputable defines if data length to load can be evaluated
  41137. * @param loaded defines the loaded data length
  41138. * @param total defines the data length to load
  41139. */
  41140. constructor(
  41141. /** defines if data length to load can be evaluated */
  41142. lengthComputable: boolean,
  41143. /** defines the loaded data length */
  41144. loaded: number,
  41145. /** defines the data length to load */
  41146. total: number);
  41147. /**
  41148. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41149. * @param event defines the source event
  41150. * @returns a new SceneLoaderProgressEvent
  41151. */
  41152. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41153. }
  41154. /**
  41155. * Interface used by SceneLoader plugins to define supported file extensions
  41156. */
  41157. export interface ISceneLoaderPluginExtensions {
  41158. /**
  41159. * Defines the list of supported extensions
  41160. */
  41161. [extension: string]: {
  41162. isBinary: boolean;
  41163. };
  41164. }
  41165. /**
  41166. * Interface used by SceneLoader plugin factory
  41167. */
  41168. export interface ISceneLoaderPluginFactory {
  41169. /**
  41170. * Defines the name of the factory
  41171. */
  41172. name: string;
  41173. /**
  41174. * Function called to create a new plugin
  41175. * @return the new plugin
  41176. */
  41177. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41178. /**
  41179. * Boolean indicating if the plugin can direct load specific data
  41180. */
  41181. canDirectLoad?: (data: string) => boolean;
  41182. }
  41183. /**
  41184. * Interface used to define a SceneLoader plugin
  41185. */
  41186. export interface ISceneLoaderPlugin {
  41187. /**
  41188. * The friendly name of this plugin.
  41189. */
  41190. name: string;
  41191. /**
  41192. * The file extensions supported by this plugin.
  41193. */
  41194. extensions: string | ISceneLoaderPluginExtensions;
  41195. /**
  41196. * Import meshes into a scene.
  41197. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41198. * @param scene The scene to import into
  41199. * @param data The data to import
  41200. * @param rootUrl The root url for scene and resources
  41201. * @param meshes The meshes array to import into
  41202. * @param particleSystems The particle systems array to import into
  41203. * @param skeletons The skeletons array to import into
  41204. * @param onError The callback when import fails
  41205. * @returns True if successful or false otherwise
  41206. */
  41207. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41208. /**
  41209. * Load into a scene.
  41210. * @param scene The scene to load into
  41211. * @param data The data to import
  41212. * @param rootUrl The root url for scene and resources
  41213. * @param onError The callback when import fails
  41214. * @returns true if successful or false otherwise
  41215. */
  41216. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41217. /**
  41218. * The callback that returns true if the data can be directly loaded.
  41219. */
  41220. canDirectLoad?: (data: string) => boolean;
  41221. /**
  41222. * The callback that allows custom handling of the root url based on the response url.
  41223. */
  41224. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41225. /**
  41226. * Load into an asset container.
  41227. * @param scene The scene to load into
  41228. * @param data The data to import
  41229. * @param rootUrl The root url for scene and resources
  41230. * @param onError The callback when import fails
  41231. * @returns The loaded asset container
  41232. */
  41233. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41234. }
  41235. /**
  41236. * Interface used to define an async SceneLoader plugin
  41237. */
  41238. export interface ISceneLoaderPluginAsync {
  41239. /**
  41240. * The friendly name of this plugin.
  41241. */
  41242. name: string;
  41243. /**
  41244. * The file extensions supported by this plugin.
  41245. */
  41246. extensions: string | ISceneLoaderPluginExtensions;
  41247. /**
  41248. * Import meshes into a scene.
  41249. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41250. * @param scene The scene to import into
  41251. * @param data The data to import
  41252. * @param rootUrl The root url for scene and resources
  41253. * @param onProgress The callback when the load progresses
  41254. * @param fileName Defines the name of the file to load
  41255. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41256. */
  41257. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41258. meshes: AbstractMesh[];
  41259. particleSystems: IParticleSystem[];
  41260. skeletons: Skeleton[];
  41261. animationGroups: AnimationGroup[];
  41262. }>;
  41263. /**
  41264. * Load into a scene.
  41265. * @param scene The scene to load into
  41266. * @param data The data to import
  41267. * @param rootUrl The root url for scene and resources
  41268. * @param onProgress The callback when the load progresses
  41269. * @param fileName Defines the name of the file to load
  41270. * @returns Nothing
  41271. */
  41272. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41273. /**
  41274. * The callback that returns true if the data can be directly loaded.
  41275. */
  41276. canDirectLoad?: (data: string) => boolean;
  41277. /**
  41278. * The callback that allows custom handling of the root url based on the response url.
  41279. */
  41280. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41281. /**
  41282. * Load into an asset container.
  41283. * @param scene The scene to load into
  41284. * @param data The data to import
  41285. * @param rootUrl The root url for scene and resources
  41286. * @param onProgress The callback when the load progresses
  41287. * @param fileName Defines the name of the file to load
  41288. * @returns The loaded asset container
  41289. */
  41290. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41291. }
  41292. /**
  41293. * Class used to load scene from various file formats using registered plugins
  41294. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41295. */
  41296. export class SceneLoader {
  41297. /**
  41298. * No logging while loading
  41299. */
  41300. static readonly NO_LOGGING: number;
  41301. /**
  41302. * Minimal logging while loading
  41303. */
  41304. static readonly MINIMAL_LOGGING: number;
  41305. /**
  41306. * Summary logging while loading
  41307. */
  41308. static readonly SUMMARY_LOGGING: number;
  41309. /**
  41310. * Detailled logging while loading
  41311. */
  41312. static readonly DETAILED_LOGGING: number;
  41313. /**
  41314. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41315. */
  41316. static ForceFullSceneLoadingForIncremental: boolean;
  41317. /**
  41318. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41319. */
  41320. static ShowLoadingScreen: boolean;
  41321. /**
  41322. * Defines the current logging level (while loading the scene)
  41323. * @ignorenaming
  41324. */
  41325. static loggingLevel: number;
  41326. /**
  41327. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41328. */
  41329. static CleanBoneMatrixWeights: boolean;
  41330. /**
  41331. * Event raised when a plugin is used to load a scene
  41332. */
  41333. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41334. private static _registeredPlugins;
  41335. private static _getDefaultPlugin;
  41336. private static _getPluginForExtension;
  41337. private static _getPluginForDirectLoad;
  41338. private static _getPluginForFilename;
  41339. private static _getDirectLoad;
  41340. private static _loadData;
  41341. private static _getFileInfo;
  41342. /**
  41343. * Gets a plugin that can load the given extension
  41344. * @param extension defines the extension to load
  41345. * @returns a plugin or null if none works
  41346. */
  41347. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41348. /**
  41349. * Gets a boolean indicating that the given extension can be loaded
  41350. * @param extension defines the extension to load
  41351. * @returns true if the extension is supported
  41352. */
  41353. static IsPluginForExtensionAvailable(extension: string): boolean;
  41354. /**
  41355. * Adds a new plugin to the list of registered plugins
  41356. * @param plugin defines the plugin to add
  41357. */
  41358. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41359. /**
  41360. * Import meshes into a scene
  41361. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41362. * @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)
  41363. * @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)
  41364. * @param scene the instance of BABYLON.Scene to append to
  41365. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41366. * @param onProgress a callback with a progress event for each file being loaded
  41367. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41368. * @param pluginExtension the extension used to determine the plugin
  41369. * @returns The loaded plugin
  41370. */
  41371. 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>;
  41372. /**
  41373. * Import meshes into a scene
  41374. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41375. * @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)
  41376. * @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)
  41377. * @param scene the instance of BABYLON.Scene to append to
  41378. * @param onProgress a callback with a progress event for each file being loaded
  41379. * @param pluginExtension the extension used to determine the plugin
  41380. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41381. */
  41382. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41383. meshes: AbstractMesh[];
  41384. particleSystems: IParticleSystem[];
  41385. skeletons: Skeleton[];
  41386. animationGroups: AnimationGroup[];
  41387. }>;
  41388. /**
  41389. * Load a scene
  41390. * @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)
  41391. * @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)
  41392. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41393. * @param onSuccess a callback with the scene when import succeeds
  41394. * @param onProgress a callback with a progress event for each file being loaded
  41395. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41396. * @param pluginExtension the extension used to determine the plugin
  41397. * @returns The loaded plugin
  41398. */
  41399. 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>;
  41400. /**
  41401. * Load a scene
  41402. * @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)
  41403. * @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)
  41404. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41405. * @param onProgress a callback with a progress event for each file being loaded
  41406. * @param pluginExtension the extension used to determine the plugin
  41407. * @returns The loaded scene
  41408. */
  41409. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41410. /**
  41411. * Append a scene
  41412. * @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)
  41413. * @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)
  41414. * @param scene is the instance of BABYLON.Scene to append to
  41415. * @param onSuccess a callback with the scene when import succeeds
  41416. * @param onProgress a callback with a progress event for each file being loaded
  41417. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41418. * @param pluginExtension the extension used to determine the plugin
  41419. * @returns The loaded plugin
  41420. */
  41421. 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>;
  41422. /**
  41423. * Append a scene
  41424. * @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)
  41425. * @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)
  41426. * @param scene is the instance of BABYLON.Scene to append to
  41427. * @param onProgress a callback with a progress event for each file being loaded
  41428. * @param pluginExtension the extension used to determine the plugin
  41429. * @returns The given scene
  41430. */
  41431. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41432. /**
  41433. * Load a scene into an asset container
  41434. * @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)
  41435. * @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)
  41436. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41437. * @param onSuccess a callback with the scene when import succeeds
  41438. * @param onProgress a callback with a progress event for each file being loaded
  41439. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41440. * @param pluginExtension the extension used to determine the plugin
  41441. * @returns The loaded plugin
  41442. */
  41443. 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>;
  41444. /**
  41445. * Load a scene into an asset container
  41446. * @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)
  41447. * @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)
  41448. * @param scene is the instance of Scene to append to
  41449. * @param onProgress a callback with a progress event for each file being loaded
  41450. * @param pluginExtension the extension used to determine the plugin
  41451. * @returns The loaded asset container
  41452. */
  41453. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41454. }
  41455. }
  41456. declare module BABYLON {
  41457. /**
  41458. * Generic Controller
  41459. */
  41460. export class GenericController extends WebVRController {
  41461. /**
  41462. * Base Url for the controller model.
  41463. */
  41464. static readonly MODEL_BASE_URL: string;
  41465. /**
  41466. * File name for the controller model.
  41467. */
  41468. static readonly MODEL_FILENAME: string;
  41469. /**
  41470. * Creates a new GenericController from a gamepad
  41471. * @param vrGamepad the gamepad that the controller should be created from
  41472. */
  41473. constructor(vrGamepad: any);
  41474. /**
  41475. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41476. * @param scene scene in which to add meshes
  41477. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41478. */
  41479. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41480. /**
  41481. * Called once for each button that changed state since the last frame
  41482. * @param buttonIdx Which button index changed
  41483. * @param state New state of the button
  41484. * @param changes Which properties on the state changed since last frame
  41485. */
  41486. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41487. }
  41488. }
  41489. declare module BABYLON {
  41490. /**
  41491. * Defines the WindowsMotionController object that the state of the windows motion controller
  41492. */
  41493. export class WindowsMotionController extends WebVRController {
  41494. /**
  41495. * The base url used to load the left and right controller models
  41496. */
  41497. static MODEL_BASE_URL: string;
  41498. /**
  41499. * The name of the left controller model file
  41500. */
  41501. static MODEL_LEFT_FILENAME: string;
  41502. /**
  41503. * The name of the right controller model file
  41504. */
  41505. static MODEL_RIGHT_FILENAME: string;
  41506. /**
  41507. * The controller name prefix for this controller type
  41508. */
  41509. static readonly GAMEPAD_ID_PREFIX: string;
  41510. /**
  41511. * The controller id pattern for this controller type
  41512. */
  41513. private static readonly GAMEPAD_ID_PATTERN;
  41514. private _loadedMeshInfo;
  41515. private readonly _mapping;
  41516. /**
  41517. * Fired when the trackpad on this controller is clicked
  41518. */
  41519. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41520. /**
  41521. * Fired when the trackpad on this controller is modified
  41522. */
  41523. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41524. /**
  41525. * The current x and y values of this controller's trackpad
  41526. */
  41527. trackpad: StickValues;
  41528. /**
  41529. * Creates a new WindowsMotionController from a gamepad
  41530. * @param vrGamepad the gamepad that the controller should be created from
  41531. */
  41532. constructor(vrGamepad: any);
  41533. /**
  41534. * Fired when the trigger on this controller is modified
  41535. */
  41536. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41537. /**
  41538. * Fired when the menu button on this controller is modified
  41539. */
  41540. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41541. /**
  41542. * Fired when the grip button on this controller is modified
  41543. */
  41544. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41545. /**
  41546. * Fired when the thumbstick button on this controller is modified
  41547. */
  41548. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41549. /**
  41550. * Fired when the touchpad button on this controller is modified
  41551. */
  41552. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41553. /**
  41554. * Fired when the touchpad values on this controller are modified
  41555. */
  41556. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41557. private _updateTrackpad;
  41558. /**
  41559. * Called once per frame by the engine.
  41560. */
  41561. update(): void;
  41562. /**
  41563. * Called once for each button that changed state since the last frame
  41564. * @param buttonIdx Which button index changed
  41565. * @param state New state of the button
  41566. * @param changes Which properties on the state changed since last frame
  41567. */
  41568. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41569. /**
  41570. * Moves the buttons on the controller mesh based on their current state
  41571. * @param buttonName the name of the button to move
  41572. * @param buttonValue the value of the button which determines the buttons new position
  41573. */
  41574. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41575. /**
  41576. * Moves the axis on the controller mesh based on its current state
  41577. * @param axis the index of the axis
  41578. * @param axisValue the value of the axis which determines the meshes new position
  41579. * @hidden
  41580. */
  41581. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41582. /**
  41583. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41584. * @param scene scene in which to add meshes
  41585. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41586. */
  41587. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41588. /**
  41589. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41590. * can be transformed by button presses and axes values, based on this._mapping.
  41591. *
  41592. * @param scene scene in which the meshes exist
  41593. * @param meshes list of meshes that make up the controller model to process
  41594. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41595. */
  41596. private processModel;
  41597. private createMeshInfo;
  41598. /**
  41599. * Gets the ray of the controller in the direction the controller is pointing
  41600. * @param length the length the resulting ray should be
  41601. * @returns a ray in the direction the controller is pointing
  41602. */
  41603. getForwardRay(length?: number): Ray;
  41604. /**
  41605. * Disposes of the controller
  41606. */
  41607. dispose(): void;
  41608. }
  41609. }
  41610. declare module BABYLON {
  41611. /**
  41612. * Oculus Touch Controller
  41613. */
  41614. export class OculusTouchController extends WebVRController {
  41615. /**
  41616. * Base Url for the controller model.
  41617. */
  41618. static MODEL_BASE_URL: string;
  41619. /**
  41620. * File name for the left controller model.
  41621. */
  41622. static MODEL_LEFT_FILENAME: string;
  41623. /**
  41624. * File name for the right controller model.
  41625. */
  41626. static MODEL_RIGHT_FILENAME: string;
  41627. /**
  41628. * Base Url for the Quest controller model.
  41629. */
  41630. static QUEST_MODEL_BASE_URL: string;
  41631. /**
  41632. * @hidden
  41633. * If the controllers are running on a device that needs the updated Quest controller models
  41634. */
  41635. static _IsQuest: boolean;
  41636. /**
  41637. * Fired when the secondary trigger on this controller is modified
  41638. */
  41639. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41640. /**
  41641. * Fired when the thumb rest on this controller is modified
  41642. */
  41643. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41644. /**
  41645. * Creates a new OculusTouchController from a gamepad
  41646. * @param vrGamepad the gamepad that the controller should be created from
  41647. */
  41648. constructor(vrGamepad: any);
  41649. /**
  41650. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41651. * @param scene scene in which to add meshes
  41652. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41653. */
  41654. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41655. /**
  41656. * Fired when the A button on this controller is modified
  41657. */
  41658. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41659. /**
  41660. * Fired when the B button on this controller is modified
  41661. */
  41662. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41663. /**
  41664. * Fired when the X button on this controller is modified
  41665. */
  41666. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41667. /**
  41668. * Fired when the Y button on this controller is modified
  41669. */
  41670. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41671. /**
  41672. * Called once for each button that changed state since the last frame
  41673. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41674. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41675. * 2) secondary trigger (same)
  41676. * 3) A (right) X (left), touch, pressed = value
  41677. * 4) B / Y
  41678. * 5) thumb rest
  41679. * @param buttonIdx Which button index changed
  41680. * @param state New state of the button
  41681. * @param changes Which properties on the state changed since last frame
  41682. */
  41683. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41684. }
  41685. }
  41686. declare module BABYLON {
  41687. /**
  41688. * Vive Controller
  41689. */
  41690. export class ViveController extends WebVRController {
  41691. /**
  41692. * Base Url for the controller model.
  41693. */
  41694. static MODEL_BASE_URL: string;
  41695. /**
  41696. * File name for the controller model.
  41697. */
  41698. static MODEL_FILENAME: string;
  41699. /**
  41700. * Creates a new ViveController from a gamepad
  41701. * @param vrGamepad the gamepad that the controller should be created from
  41702. */
  41703. constructor(vrGamepad: any);
  41704. /**
  41705. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41706. * @param scene scene in which to add meshes
  41707. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41708. */
  41709. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41710. /**
  41711. * Fired when the left button on this controller is modified
  41712. */
  41713. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41714. /**
  41715. * Fired when the right button on this controller is modified
  41716. */
  41717. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41718. /**
  41719. * Fired when the menu button on this controller is modified
  41720. */
  41721. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41722. /**
  41723. * Called once for each button that changed state since the last frame
  41724. * Vive mapping:
  41725. * 0: touchpad
  41726. * 1: trigger
  41727. * 2: left AND right buttons
  41728. * 3: menu button
  41729. * @param buttonIdx Which button index changed
  41730. * @param state New state of the button
  41731. * @param changes Which properties on the state changed since last frame
  41732. */
  41733. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41734. }
  41735. }
  41736. declare module BABYLON {
  41737. /**
  41738. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41739. */
  41740. export class WebXRControllerModelLoader {
  41741. /**
  41742. * Creates the WebXRControllerModelLoader
  41743. * @param input xr input that creates the controllers
  41744. */
  41745. constructor(input: WebXRInput);
  41746. }
  41747. }
  41748. declare module BABYLON {
  41749. /**
  41750. * Contains an array of blocks representing the octree
  41751. */
  41752. export interface IOctreeContainer<T> {
  41753. /**
  41754. * Blocks within the octree
  41755. */
  41756. blocks: Array<OctreeBlock<T>>;
  41757. }
  41758. /**
  41759. * Class used to store a cell in an octree
  41760. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41761. */
  41762. export class OctreeBlock<T> {
  41763. /**
  41764. * Gets the content of the current block
  41765. */
  41766. entries: T[];
  41767. /**
  41768. * Gets the list of block children
  41769. */
  41770. blocks: Array<OctreeBlock<T>>;
  41771. private _depth;
  41772. private _maxDepth;
  41773. private _capacity;
  41774. private _minPoint;
  41775. private _maxPoint;
  41776. private _boundingVectors;
  41777. private _creationFunc;
  41778. /**
  41779. * Creates a new block
  41780. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41781. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41782. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41783. * @param depth defines the current depth of this block in the octree
  41784. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41785. * @param creationFunc defines a callback to call when an element is added to the block
  41786. */
  41787. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41788. /**
  41789. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41790. */
  41791. readonly capacity: number;
  41792. /**
  41793. * Gets the minimum vector (in world space) of the block's bounding box
  41794. */
  41795. readonly minPoint: Vector3;
  41796. /**
  41797. * Gets the maximum vector (in world space) of the block's bounding box
  41798. */
  41799. readonly maxPoint: Vector3;
  41800. /**
  41801. * Add a new element to this block
  41802. * @param entry defines the element to add
  41803. */
  41804. addEntry(entry: T): void;
  41805. /**
  41806. * Remove an element from this block
  41807. * @param entry defines the element to remove
  41808. */
  41809. removeEntry(entry: T): void;
  41810. /**
  41811. * Add an array of elements to this block
  41812. * @param entries defines the array of elements to add
  41813. */
  41814. addEntries(entries: T[]): void;
  41815. /**
  41816. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41817. * @param frustumPlanes defines the frustum planes to test
  41818. * @param selection defines the array to store current content if selection is positive
  41819. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41820. */
  41821. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41822. /**
  41823. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41824. * @param sphereCenter defines the bounding sphere center
  41825. * @param sphereRadius defines the bounding sphere radius
  41826. * @param selection defines the array to store current content if selection is positive
  41827. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41828. */
  41829. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41830. /**
  41831. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41832. * @param ray defines the ray to test with
  41833. * @param selection defines the array to store current content if selection is positive
  41834. */
  41835. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41836. /**
  41837. * Subdivide the content into child blocks (this block will then be empty)
  41838. */
  41839. createInnerBlocks(): void;
  41840. /**
  41841. * @hidden
  41842. */
  41843. 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;
  41844. }
  41845. }
  41846. declare module BABYLON {
  41847. /**
  41848. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41849. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41850. */
  41851. export class Octree<T> {
  41852. /** 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.) */
  41853. maxDepth: number;
  41854. /**
  41855. * Blocks within the octree containing objects
  41856. */
  41857. blocks: Array<OctreeBlock<T>>;
  41858. /**
  41859. * Content stored in the octree
  41860. */
  41861. dynamicContent: T[];
  41862. private _maxBlockCapacity;
  41863. private _selectionContent;
  41864. private _creationFunc;
  41865. /**
  41866. * Creates a octree
  41867. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41868. * @param creationFunc function to be used to instatiate the octree
  41869. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41870. * @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.)
  41871. */
  41872. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41873. /** 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.) */
  41874. maxDepth?: number);
  41875. /**
  41876. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41877. * @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);
  41878. * @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);
  41879. * @param entries meshes to be added to the octree blocks
  41880. */
  41881. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41882. /**
  41883. * Adds a mesh to the octree
  41884. * @param entry Mesh to add to the octree
  41885. */
  41886. addMesh(entry: T): void;
  41887. /**
  41888. * Remove an element from the octree
  41889. * @param entry defines the element to remove
  41890. */
  41891. removeMesh(entry: T): void;
  41892. /**
  41893. * Selects an array of meshes within the frustum
  41894. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41895. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41896. * @returns array of meshes within the frustum
  41897. */
  41898. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41899. /**
  41900. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41901. * @param sphereCenter defines the bounding sphere center
  41902. * @param sphereRadius defines the bounding sphere radius
  41903. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41904. * @returns an array of objects that intersect the sphere
  41905. */
  41906. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41907. /**
  41908. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41909. * @param ray defines the ray to test with
  41910. * @returns array of intersected objects
  41911. */
  41912. intersectsRay(ray: Ray): SmartArray<T>;
  41913. /**
  41914. * Adds a mesh into the octree block if it intersects the block
  41915. */
  41916. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41917. /**
  41918. * Adds a submesh into the octree block if it intersects the block
  41919. */
  41920. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41921. }
  41922. }
  41923. declare module BABYLON {
  41924. interface Scene {
  41925. /**
  41926. * @hidden
  41927. * Backing Filed
  41928. */
  41929. _selectionOctree: Octree<AbstractMesh>;
  41930. /**
  41931. * Gets the octree used to boost mesh selection (picking)
  41932. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41933. */
  41934. selectionOctree: Octree<AbstractMesh>;
  41935. /**
  41936. * Creates or updates the octree used to boost selection (picking)
  41937. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41938. * @param maxCapacity defines the maximum capacity per leaf
  41939. * @param maxDepth defines the maximum depth of the octree
  41940. * @returns an octree of AbstractMesh
  41941. */
  41942. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41943. }
  41944. interface AbstractMesh {
  41945. /**
  41946. * @hidden
  41947. * Backing Field
  41948. */
  41949. _submeshesOctree: Octree<SubMesh>;
  41950. /**
  41951. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41952. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41953. * @param maxCapacity defines the maximum size of each block (64 by default)
  41954. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41955. * @returns the new octree
  41956. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41957. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41958. */
  41959. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41960. }
  41961. /**
  41962. * Defines the octree scene component responsible to manage any octrees
  41963. * in a given scene.
  41964. */
  41965. export class OctreeSceneComponent {
  41966. /**
  41967. * The component name help to identify the component in the list of scene components.
  41968. */
  41969. readonly name: string;
  41970. /**
  41971. * The scene the component belongs to.
  41972. */
  41973. scene: Scene;
  41974. /**
  41975. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41976. */
  41977. readonly checksIsEnabled: boolean;
  41978. /**
  41979. * Creates a new instance of the component for the given scene
  41980. * @param scene Defines the scene to register the component in
  41981. */
  41982. constructor(scene: Scene);
  41983. /**
  41984. * Registers the component in a given scene
  41985. */
  41986. register(): void;
  41987. /**
  41988. * Return the list of active meshes
  41989. * @returns the list of active meshes
  41990. */
  41991. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41992. /**
  41993. * Return the list of active sub meshes
  41994. * @param mesh The mesh to get the candidates sub meshes from
  41995. * @returns the list of active sub meshes
  41996. */
  41997. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41998. private _tempRay;
  41999. /**
  42000. * Return the list of sub meshes intersecting with a given local ray
  42001. * @param mesh defines the mesh to find the submesh for
  42002. * @param localRay defines the ray in local space
  42003. * @returns the list of intersecting sub meshes
  42004. */
  42005. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42006. /**
  42007. * Return the list of sub meshes colliding with a collider
  42008. * @param mesh defines the mesh to find the submesh for
  42009. * @param collider defines the collider to evaluate the collision against
  42010. * @returns the list of colliding sub meshes
  42011. */
  42012. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42013. /**
  42014. * Rebuilds the elements related to this component in case of
  42015. * context lost for instance.
  42016. */
  42017. rebuild(): void;
  42018. /**
  42019. * Disposes the component and the associated ressources.
  42020. */
  42021. dispose(): void;
  42022. }
  42023. }
  42024. declare module BABYLON {
  42025. /**
  42026. * Renders a layer on top of an existing scene
  42027. */
  42028. export class UtilityLayerRenderer implements IDisposable {
  42029. /** the original scene that will be rendered on top of */
  42030. originalScene: Scene;
  42031. private _pointerCaptures;
  42032. private _lastPointerEvents;
  42033. private static _DefaultUtilityLayer;
  42034. private static _DefaultKeepDepthUtilityLayer;
  42035. private _sharedGizmoLight;
  42036. private _renderCamera;
  42037. /**
  42038. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42039. * @returns the camera that is used when rendering the utility layer
  42040. */
  42041. getRenderCamera(): Nullable<Camera>;
  42042. /**
  42043. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42044. * @param cam the camera that should be used when rendering the utility layer
  42045. */
  42046. setRenderCamera(cam: Nullable<Camera>): void;
  42047. /**
  42048. * @hidden
  42049. * Light which used by gizmos to get light shading
  42050. */
  42051. _getSharedGizmoLight(): HemisphericLight;
  42052. /**
  42053. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42054. */
  42055. pickUtilitySceneFirst: boolean;
  42056. /**
  42057. * 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)
  42058. */
  42059. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42060. /**
  42061. * 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)
  42062. */
  42063. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42064. /**
  42065. * The scene that is rendered on top of the original scene
  42066. */
  42067. utilityLayerScene: Scene;
  42068. /**
  42069. * If the utility layer should automatically be rendered on top of existing scene
  42070. */
  42071. shouldRender: boolean;
  42072. /**
  42073. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42074. */
  42075. onlyCheckPointerDownEvents: boolean;
  42076. /**
  42077. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42078. */
  42079. processAllEvents: boolean;
  42080. /**
  42081. * Observable raised when the pointer move from the utility layer scene to the main scene
  42082. */
  42083. onPointerOutObservable: Observable<number>;
  42084. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42085. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42086. private _afterRenderObserver;
  42087. private _sceneDisposeObserver;
  42088. private _originalPointerObserver;
  42089. /**
  42090. * Instantiates a UtilityLayerRenderer
  42091. * @param originalScene the original scene that will be rendered on top of
  42092. * @param handleEvents boolean indicating if the utility layer should handle events
  42093. */
  42094. constructor(
  42095. /** the original scene that will be rendered on top of */
  42096. originalScene: Scene, handleEvents?: boolean);
  42097. private _notifyObservers;
  42098. /**
  42099. * Renders the utility layers scene on top of the original scene
  42100. */
  42101. render(): void;
  42102. /**
  42103. * Disposes of the renderer
  42104. */
  42105. dispose(): void;
  42106. private _updateCamera;
  42107. }
  42108. }
  42109. declare module BABYLON {
  42110. /**
  42111. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42112. */
  42113. export class Gizmo implements IDisposable {
  42114. /** The utility layer the gizmo will be added to */
  42115. gizmoLayer: UtilityLayerRenderer;
  42116. /**
  42117. * The root mesh of the gizmo
  42118. */
  42119. _rootMesh: Mesh;
  42120. private _attachedMesh;
  42121. /**
  42122. * Ratio for the scale of the gizmo (Default: 1)
  42123. */
  42124. scaleRatio: number;
  42125. /**
  42126. * If a custom mesh has been set (Default: false)
  42127. */
  42128. protected _customMeshSet: boolean;
  42129. /**
  42130. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42131. * * When set, interactions will be enabled
  42132. */
  42133. attachedMesh: Nullable<AbstractMesh>;
  42134. /**
  42135. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42136. * @param mesh The mesh to replace the default mesh of the gizmo
  42137. */
  42138. setCustomMesh(mesh: Mesh): void;
  42139. /**
  42140. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42141. */
  42142. updateGizmoRotationToMatchAttachedMesh: boolean;
  42143. /**
  42144. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42145. */
  42146. updateGizmoPositionToMatchAttachedMesh: boolean;
  42147. /**
  42148. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42149. */
  42150. updateScale: boolean;
  42151. protected _interactionsEnabled: boolean;
  42152. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42153. private _beforeRenderObserver;
  42154. private _tempVector;
  42155. /**
  42156. * Creates a gizmo
  42157. * @param gizmoLayer The utility layer the gizmo will be added to
  42158. */
  42159. constructor(
  42160. /** The utility layer the gizmo will be added to */
  42161. gizmoLayer?: UtilityLayerRenderer);
  42162. /**
  42163. * Updates the gizmo to match the attached mesh's position/rotation
  42164. */
  42165. protected _update(): void;
  42166. /**
  42167. * Disposes of the gizmo
  42168. */
  42169. dispose(): void;
  42170. }
  42171. }
  42172. declare module BABYLON {
  42173. /**
  42174. * Single plane drag gizmo
  42175. */
  42176. export class PlaneDragGizmo extends Gizmo {
  42177. /**
  42178. * Drag behavior responsible for the gizmos dragging interactions
  42179. */
  42180. dragBehavior: PointerDragBehavior;
  42181. private _pointerObserver;
  42182. /**
  42183. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42184. */
  42185. snapDistance: number;
  42186. /**
  42187. * Event that fires each time the gizmo snaps to a new location.
  42188. * * snapDistance is the the change in distance
  42189. */
  42190. onSnapObservable: Observable<{
  42191. snapDistance: number;
  42192. }>;
  42193. private _plane;
  42194. private _coloredMaterial;
  42195. private _hoverMaterial;
  42196. private _isEnabled;
  42197. private _parent;
  42198. /** @hidden */
  42199. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42200. /** @hidden */
  42201. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42202. /**
  42203. * Creates a PlaneDragGizmo
  42204. * @param gizmoLayer The utility layer the gizmo will be added to
  42205. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42206. * @param color The color of the gizmo
  42207. */
  42208. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42209. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42210. /**
  42211. * If the gizmo is enabled
  42212. */
  42213. isEnabled: boolean;
  42214. /**
  42215. * Disposes of the gizmo
  42216. */
  42217. dispose(): void;
  42218. }
  42219. }
  42220. declare module BABYLON {
  42221. /**
  42222. * Gizmo that enables dragging a mesh along 3 axis
  42223. */
  42224. export class PositionGizmo extends Gizmo {
  42225. /**
  42226. * Internal gizmo used for interactions on the x axis
  42227. */
  42228. xGizmo: AxisDragGizmo;
  42229. /**
  42230. * Internal gizmo used for interactions on the y axis
  42231. */
  42232. yGizmo: AxisDragGizmo;
  42233. /**
  42234. * Internal gizmo used for interactions on the z axis
  42235. */
  42236. zGizmo: AxisDragGizmo;
  42237. /**
  42238. * Internal gizmo used for interactions on the yz plane
  42239. */
  42240. xPlaneGizmo: PlaneDragGizmo;
  42241. /**
  42242. * Internal gizmo used for interactions on the xz plane
  42243. */
  42244. yPlaneGizmo: PlaneDragGizmo;
  42245. /**
  42246. * Internal gizmo used for interactions on the xy plane
  42247. */
  42248. zPlaneGizmo: PlaneDragGizmo;
  42249. /**
  42250. * private variables
  42251. */
  42252. private _meshAttached;
  42253. private _updateGizmoRotationToMatchAttachedMesh;
  42254. private _snapDistance;
  42255. private _scaleRatio;
  42256. /** Fires an event when any of it's sub gizmos are dragged */
  42257. onDragStartObservable: Observable<unknown>;
  42258. /** Fires an event when any of it's sub gizmos are released from dragging */
  42259. onDragEndObservable: Observable<unknown>;
  42260. /**
  42261. * If set to true, planar drag is enabled
  42262. */
  42263. private _planarGizmoEnabled;
  42264. attachedMesh: Nullable<AbstractMesh>;
  42265. /**
  42266. * Creates a PositionGizmo
  42267. * @param gizmoLayer The utility layer the gizmo will be added to
  42268. */
  42269. constructor(gizmoLayer?: UtilityLayerRenderer);
  42270. /**
  42271. * If the planar drag gizmo is enabled
  42272. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42273. */
  42274. planarGizmoEnabled: boolean;
  42275. updateGizmoRotationToMatchAttachedMesh: boolean;
  42276. /**
  42277. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42278. */
  42279. snapDistance: number;
  42280. /**
  42281. * Ratio for the scale of the gizmo (Default: 1)
  42282. */
  42283. scaleRatio: number;
  42284. /**
  42285. * Disposes of the gizmo
  42286. */
  42287. dispose(): void;
  42288. /**
  42289. * CustomMeshes are not supported by this gizmo
  42290. * @param mesh The mesh to replace the default mesh of the gizmo
  42291. */
  42292. setCustomMesh(mesh: Mesh): void;
  42293. }
  42294. }
  42295. declare module BABYLON {
  42296. /**
  42297. * Single axis drag gizmo
  42298. */
  42299. export class AxisDragGizmo extends Gizmo {
  42300. /**
  42301. * Drag behavior responsible for the gizmos dragging interactions
  42302. */
  42303. dragBehavior: PointerDragBehavior;
  42304. private _pointerObserver;
  42305. /**
  42306. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42307. */
  42308. snapDistance: number;
  42309. /**
  42310. * Event that fires each time the gizmo snaps to a new location.
  42311. * * snapDistance is the the change in distance
  42312. */
  42313. onSnapObservable: Observable<{
  42314. snapDistance: number;
  42315. }>;
  42316. private _isEnabled;
  42317. private _parent;
  42318. private _arrow;
  42319. private _coloredMaterial;
  42320. private _hoverMaterial;
  42321. /** @hidden */
  42322. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42323. /** @hidden */
  42324. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42325. /**
  42326. * Creates an AxisDragGizmo
  42327. * @param gizmoLayer The utility layer the gizmo will be added to
  42328. * @param dragAxis The axis which the gizmo will be able to drag on
  42329. * @param color The color of the gizmo
  42330. */
  42331. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42332. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42333. /**
  42334. * If the gizmo is enabled
  42335. */
  42336. isEnabled: boolean;
  42337. /**
  42338. * Disposes of the gizmo
  42339. */
  42340. dispose(): void;
  42341. }
  42342. }
  42343. declare module BABYLON.Debug {
  42344. /**
  42345. * The Axes viewer will show 3 axes in a specific point in space
  42346. */
  42347. export class AxesViewer {
  42348. private _xAxis;
  42349. private _yAxis;
  42350. private _zAxis;
  42351. private _scaleLinesFactor;
  42352. private _instanced;
  42353. /**
  42354. * Gets the hosting scene
  42355. */
  42356. scene: Scene;
  42357. /**
  42358. * Gets or sets a number used to scale line length
  42359. */
  42360. scaleLines: number;
  42361. /** Gets the node hierarchy used to render x-axis */
  42362. readonly xAxis: TransformNode;
  42363. /** Gets the node hierarchy used to render y-axis */
  42364. readonly yAxis: TransformNode;
  42365. /** Gets the node hierarchy used to render z-axis */
  42366. readonly zAxis: TransformNode;
  42367. /**
  42368. * Creates a new AxesViewer
  42369. * @param scene defines the hosting scene
  42370. * @param scaleLines defines a number used to scale line length (1 by default)
  42371. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42372. * @param xAxis defines the node hierarchy used to render the x-axis
  42373. * @param yAxis defines the node hierarchy used to render the y-axis
  42374. * @param zAxis defines the node hierarchy used to render the z-axis
  42375. */
  42376. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42377. /**
  42378. * Force the viewer to update
  42379. * @param position defines the position of the viewer
  42380. * @param xaxis defines the x axis of the viewer
  42381. * @param yaxis defines the y axis of the viewer
  42382. * @param zaxis defines the z axis of the viewer
  42383. */
  42384. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42385. /**
  42386. * Creates an instance of this axes viewer.
  42387. * @returns a new axes viewer with instanced meshes
  42388. */
  42389. createInstance(): AxesViewer;
  42390. /** Releases resources */
  42391. dispose(): void;
  42392. private static _SetRenderingGroupId;
  42393. }
  42394. }
  42395. declare module BABYLON.Debug {
  42396. /**
  42397. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42398. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42399. */
  42400. export class BoneAxesViewer extends AxesViewer {
  42401. /**
  42402. * Gets or sets the target mesh where to display the axes viewer
  42403. */
  42404. mesh: Nullable<Mesh>;
  42405. /**
  42406. * Gets or sets the target bone where to display the axes viewer
  42407. */
  42408. bone: Nullable<Bone>;
  42409. /** Gets current position */
  42410. pos: Vector3;
  42411. /** Gets direction of X axis */
  42412. xaxis: Vector3;
  42413. /** Gets direction of Y axis */
  42414. yaxis: Vector3;
  42415. /** Gets direction of Z axis */
  42416. zaxis: Vector3;
  42417. /**
  42418. * Creates a new BoneAxesViewer
  42419. * @param scene defines the hosting scene
  42420. * @param bone defines the target bone
  42421. * @param mesh defines the target mesh
  42422. * @param scaleLines defines a scaling factor for line length (1 by default)
  42423. */
  42424. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42425. /**
  42426. * Force the viewer to update
  42427. */
  42428. update(): void;
  42429. /** Releases resources */
  42430. dispose(): void;
  42431. }
  42432. }
  42433. declare module BABYLON {
  42434. /**
  42435. * Interface used to define scene explorer extensibility option
  42436. */
  42437. export interface IExplorerExtensibilityOption {
  42438. /**
  42439. * Define the option label
  42440. */
  42441. label: string;
  42442. /**
  42443. * Defines the action to execute on click
  42444. */
  42445. action: (entity: any) => void;
  42446. }
  42447. /**
  42448. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42449. */
  42450. export interface IExplorerExtensibilityGroup {
  42451. /**
  42452. * Defines a predicate to test if a given type mut be extended
  42453. */
  42454. predicate: (entity: any) => boolean;
  42455. /**
  42456. * Gets the list of options added to a type
  42457. */
  42458. entries: IExplorerExtensibilityOption[];
  42459. }
  42460. /**
  42461. * Interface used to define the options to use to create the Inspector
  42462. */
  42463. export interface IInspectorOptions {
  42464. /**
  42465. * Display in overlay mode (default: false)
  42466. */
  42467. overlay?: boolean;
  42468. /**
  42469. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42470. */
  42471. globalRoot?: HTMLElement;
  42472. /**
  42473. * Display the Scene explorer
  42474. */
  42475. showExplorer?: boolean;
  42476. /**
  42477. * Display the property inspector
  42478. */
  42479. showInspector?: boolean;
  42480. /**
  42481. * Display in embed mode (both panes on the right)
  42482. */
  42483. embedMode?: boolean;
  42484. /**
  42485. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42486. */
  42487. handleResize?: boolean;
  42488. /**
  42489. * Allow the panes to popup (default: true)
  42490. */
  42491. enablePopup?: boolean;
  42492. /**
  42493. * Allow the panes to be closed by users (default: true)
  42494. */
  42495. enableClose?: boolean;
  42496. /**
  42497. * Optional list of extensibility entries
  42498. */
  42499. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42500. /**
  42501. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42502. */
  42503. inspectorURL?: string;
  42504. }
  42505. interface Scene {
  42506. /**
  42507. * @hidden
  42508. * Backing field
  42509. */
  42510. _debugLayer: DebugLayer;
  42511. /**
  42512. * Gets the debug layer (aka Inspector) associated with the scene
  42513. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42514. */
  42515. debugLayer: DebugLayer;
  42516. }
  42517. /**
  42518. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42519. * what is happening in your scene
  42520. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42521. */
  42522. export class DebugLayer {
  42523. /**
  42524. * Define the url to get the inspector script from.
  42525. * By default it uses the babylonjs CDN.
  42526. * @ignoreNaming
  42527. */
  42528. static InspectorURL: string;
  42529. private _scene;
  42530. private BJSINSPECTOR;
  42531. private _onPropertyChangedObservable?;
  42532. /**
  42533. * Observable triggered when a property is changed through the inspector.
  42534. */
  42535. readonly onPropertyChangedObservable: any;
  42536. /**
  42537. * Instantiates a new debug layer.
  42538. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42539. * what is happening in your scene
  42540. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42541. * @param scene Defines the scene to inspect
  42542. */
  42543. constructor(scene: Scene);
  42544. /** Creates the inspector window. */
  42545. private _createInspector;
  42546. /**
  42547. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42548. * @param entity defines the entity to select
  42549. * @param lineContainerTitle defines the specific block to highlight
  42550. */
  42551. select(entity: any, lineContainerTitle?: string): void;
  42552. /** Get the inspector from bundle or global */
  42553. private _getGlobalInspector;
  42554. /**
  42555. * Get if the inspector is visible or not.
  42556. * @returns true if visible otherwise, false
  42557. */
  42558. isVisible(): boolean;
  42559. /**
  42560. * Hide the inspector and close its window.
  42561. */
  42562. hide(): void;
  42563. /**
  42564. * Launch the debugLayer.
  42565. * @param config Define the configuration of the inspector
  42566. * @return a promise fulfilled when the debug layer is visible
  42567. */
  42568. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42569. }
  42570. }
  42571. declare module BABYLON {
  42572. /**
  42573. * Class containing static functions to help procedurally build meshes
  42574. */
  42575. export class BoxBuilder {
  42576. /**
  42577. * Creates a box mesh
  42578. * * The parameter `size` sets the size (float) of each box side (default 1)
  42579. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42580. * * 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)
  42581. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42583. * * 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
  42584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42585. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42586. * @param name defines the name of the mesh
  42587. * @param options defines the options used to create the mesh
  42588. * @param scene defines the hosting scene
  42589. * @returns the box mesh
  42590. */
  42591. static CreateBox(name: string, options: {
  42592. size?: number;
  42593. width?: number;
  42594. height?: number;
  42595. depth?: number;
  42596. faceUV?: Vector4[];
  42597. faceColors?: Color4[];
  42598. sideOrientation?: number;
  42599. frontUVs?: Vector4;
  42600. backUVs?: Vector4;
  42601. wrap?: boolean;
  42602. topBaseAt?: number;
  42603. bottomBaseAt?: number;
  42604. updatable?: boolean;
  42605. }, scene?: Nullable<Scene>): Mesh;
  42606. }
  42607. }
  42608. declare module BABYLON {
  42609. /**
  42610. * Class containing static functions to help procedurally build meshes
  42611. */
  42612. export class SphereBuilder {
  42613. /**
  42614. * Creates a sphere mesh
  42615. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42616. * * 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`)
  42617. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42618. * * 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
  42619. * * 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)
  42620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42621. * * 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
  42622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42623. * @param name defines the name of the mesh
  42624. * @param options defines the options used to create the mesh
  42625. * @param scene defines the hosting scene
  42626. * @returns the sphere mesh
  42627. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42628. */
  42629. static CreateSphere(name: string, options: {
  42630. segments?: number;
  42631. diameter?: number;
  42632. diameterX?: number;
  42633. diameterY?: number;
  42634. diameterZ?: number;
  42635. arc?: number;
  42636. slice?: number;
  42637. sideOrientation?: number;
  42638. frontUVs?: Vector4;
  42639. backUVs?: Vector4;
  42640. updatable?: boolean;
  42641. }, scene: any): Mesh;
  42642. }
  42643. }
  42644. declare module BABYLON.Debug {
  42645. /**
  42646. * Used to show the physics impostor around the specific mesh
  42647. */
  42648. export class PhysicsViewer {
  42649. /** @hidden */
  42650. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42651. /** @hidden */
  42652. protected _meshes: Array<Nullable<AbstractMesh>>;
  42653. /** @hidden */
  42654. protected _scene: Nullable<Scene>;
  42655. /** @hidden */
  42656. protected _numMeshes: number;
  42657. /** @hidden */
  42658. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42659. private _renderFunction;
  42660. private _utilityLayer;
  42661. private _debugBoxMesh;
  42662. private _debugSphereMesh;
  42663. private _debugCylinderMesh;
  42664. private _debugMaterial;
  42665. private _debugMeshMeshes;
  42666. /**
  42667. * Creates a new PhysicsViewer
  42668. * @param scene defines the hosting scene
  42669. */
  42670. constructor(scene: Scene);
  42671. /** @hidden */
  42672. protected _updateDebugMeshes(): void;
  42673. /**
  42674. * Renders a specified physic impostor
  42675. * @param impostor defines the impostor to render
  42676. * @param targetMesh defines the mesh represented by the impostor
  42677. * @returns the new debug mesh used to render the impostor
  42678. */
  42679. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42680. /**
  42681. * Hides a specified physic impostor
  42682. * @param impostor defines the impostor to hide
  42683. */
  42684. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42685. private _getDebugMaterial;
  42686. private _getDebugBoxMesh;
  42687. private _getDebugSphereMesh;
  42688. private _getDebugCylinderMesh;
  42689. private _getDebugMeshMesh;
  42690. private _getDebugMesh;
  42691. /** Releases all resources */
  42692. dispose(): void;
  42693. }
  42694. }
  42695. declare module BABYLON {
  42696. /**
  42697. * Class containing static functions to help procedurally build meshes
  42698. */
  42699. export class LinesBuilder {
  42700. /**
  42701. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42702. * * 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
  42703. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42704. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42705. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42706. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42707. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42708. * * 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
  42709. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42711. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42712. * @param name defines the name of the new line system
  42713. * @param options defines the options used to create the line system
  42714. * @param scene defines the hosting scene
  42715. * @returns a new line system mesh
  42716. */
  42717. static CreateLineSystem(name: string, options: {
  42718. lines: Vector3[][];
  42719. updatable?: boolean;
  42720. instance?: Nullable<LinesMesh>;
  42721. colors?: Nullable<Color4[][]>;
  42722. useVertexAlpha?: boolean;
  42723. }, scene: Nullable<Scene>): LinesMesh;
  42724. /**
  42725. * Creates a line mesh
  42726. * 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
  42727. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42728. * * The parameter `points` is an array successive Vector3
  42729. * * 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
  42730. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42731. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42732. * * When updating an instance, remember that only point positions can change, not the number of points
  42733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42734. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42735. * @param name defines the name of the new line system
  42736. * @param options defines the options used to create the line system
  42737. * @param scene defines the hosting scene
  42738. * @returns a new line mesh
  42739. */
  42740. static CreateLines(name: string, options: {
  42741. points: Vector3[];
  42742. updatable?: boolean;
  42743. instance?: Nullable<LinesMesh>;
  42744. colors?: Color4[];
  42745. useVertexAlpha?: boolean;
  42746. }, scene?: Nullable<Scene>): LinesMesh;
  42747. /**
  42748. * Creates a dashed line mesh
  42749. * * 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
  42750. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42751. * * The parameter `points` is an array successive Vector3
  42752. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42753. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42754. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42755. * * 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
  42756. * * When updating an instance, remember that only point positions can change, not the number of points
  42757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42758. * @param name defines the name of the mesh
  42759. * @param options defines the options used to create the mesh
  42760. * @param scene defines the hosting scene
  42761. * @returns the dashed line mesh
  42762. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42763. */
  42764. static CreateDashedLines(name: string, options: {
  42765. points: Vector3[];
  42766. dashSize?: number;
  42767. gapSize?: number;
  42768. dashNb?: number;
  42769. updatable?: boolean;
  42770. instance?: LinesMesh;
  42771. }, scene?: Nullable<Scene>): LinesMesh;
  42772. }
  42773. }
  42774. declare module BABYLON {
  42775. /**
  42776. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42777. * in order to better appreciate the issue one might have.
  42778. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42779. */
  42780. export class RayHelper {
  42781. /**
  42782. * Defines the ray we are currently tryin to visualize.
  42783. */
  42784. ray: Nullable<Ray>;
  42785. private _renderPoints;
  42786. private _renderLine;
  42787. private _renderFunction;
  42788. private _scene;
  42789. private _updateToMeshFunction;
  42790. private _attachedToMesh;
  42791. private _meshSpaceDirection;
  42792. private _meshSpaceOrigin;
  42793. /**
  42794. * Helper function to create a colored helper in a scene in one line.
  42795. * @param ray Defines the ray we are currently tryin to visualize
  42796. * @param scene Defines the scene the ray is used in
  42797. * @param color Defines the color we want to see the ray in
  42798. * @returns The newly created ray helper.
  42799. */
  42800. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42801. /**
  42802. * Instantiate a new ray helper.
  42803. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42804. * in order to better appreciate the issue one might have.
  42805. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42806. * @param ray Defines the ray we are currently tryin to visualize
  42807. */
  42808. constructor(ray: Ray);
  42809. /**
  42810. * Shows the ray we are willing to debug.
  42811. * @param scene Defines the scene the ray needs to be rendered in
  42812. * @param color Defines the color the ray needs to be rendered in
  42813. */
  42814. show(scene: Scene, color?: Color3): void;
  42815. /**
  42816. * Hides the ray we are debugging.
  42817. */
  42818. hide(): void;
  42819. private _render;
  42820. /**
  42821. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42822. * @param mesh Defines the mesh we want the helper attached to
  42823. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42824. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42825. * @param length Defines the length of the ray
  42826. */
  42827. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42828. /**
  42829. * Detach the ray helper from the mesh it has previously been attached to.
  42830. */
  42831. detachFromMesh(): void;
  42832. private _updateToMesh;
  42833. /**
  42834. * Dispose the helper and release its associated resources.
  42835. */
  42836. dispose(): void;
  42837. }
  42838. }
  42839. declare module BABYLON.Debug {
  42840. /**
  42841. * Class used to render a debug view of a given skeleton
  42842. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42843. */
  42844. export class SkeletonViewer {
  42845. /** defines the skeleton to render */
  42846. skeleton: Skeleton;
  42847. /** defines the mesh attached to the skeleton */
  42848. mesh: AbstractMesh;
  42849. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42850. autoUpdateBonesMatrices: boolean;
  42851. /** defines the rendering group id to use with the viewer */
  42852. renderingGroupId: number;
  42853. /** Gets or sets the color used to render the skeleton */
  42854. color: Color3;
  42855. private _scene;
  42856. private _debugLines;
  42857. private _debugMesh;
  42858. private _isEnabled;
  42859. private _renderFunction;
  42860. private _utilityLayer;
  42861. /**
  42862. * Returns the mesh used to render the bones
  42863. */
  42864. readonly debugMesh: Nullable<LinesMesh>;
  42865. /**
  42866. * Creates a new SkeletonViewer
  42867. * @param skeleton defines the skeleton to render
  42868. * @param mesh defines the mesh attached to the skeleton
  42869. * @param scene defines the hosting scene
  42870. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42871. * @param renderingGroupId defines the rendering group id to use with the viewer
  42872. */
  42873. constructor(
  42874. /** defines the skeleton to render */
  42875. skeleton: Skeleton,
  42876. /** defines the mesh attached to the skeleton */
  42877. mesh: AbstractMesh, scene: Scene,
  42878. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42879. autoUpdateBonesMatrices?: boolean,
  42880. /** defines the rendering group id to use with the viewer */
  42881. renderingGroupId?: number);
  42882. /** Gets or sets a boolean indicating if the viewer is enabled */
  42883. isEnabled: boolean;
  42884. private _getBonePosition;
  42885. private _getLinesForBonesWithLength;
  42886. private _getLinesForBonesNoLength;
  42887. /** Update the viewer to sync with current skeleton state */
  42888. update(): void;
  42889. /** Release associated resources */
  42890. dispose(): void;
  42891. }
  42892. }
  42893. declare module BABYLON {
  42894. /**
  42895. * Options to create the null engine
  42896. */
  42897. export class NullEngineOptions {
  42898. /**
  42899. * Render width (Default: 512)
  42900. */
  42901. renderWidth: number;
  42902. /**
  42903. * Render height (Default: 256)
  42904. */
  42905. renderHeight: number;
  42906. /**
  42907. * Texture size (Default: 512)
  42908. */
  42909. textureSize: number;
  42910. /**
  42911. * If delta time between frames should be constant
  42912. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42913. */
  42914. deterministicLockstep: boolean;
  42915. /**
  42916. * Maximum about of steps between frames (Default: 4)
  42917. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42918. */
  42919. lockstepMaxSteps: number;
  42920. }
  42921. /**
  42922. * The null engine class provides support for headless version of babylon.js.
  42923. * This can be used in server side scenario or for testing purposes
  42924. */
  42925. export class NullEngine extends Engine {
  42926. private _options;
  42927. /**
  42928. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42929. */
  42930. isDeterministicLockStep(): boolean;
  42931. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42932. getLockstepMaxSteps(): number;
  42933. /**
  42934. * Sets hardware scaling, used to save performance if needed
  42935. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42936. */
  42937. getHardwareScalingLevel(): number;
  42938. constructor(options?: NullEngineOptions);
  42939. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42940. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42941. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42942. getRenderWidth(useScreen?: boolean): number;
  42943. getRenderHeight(useScreen?: boolean): number;
  42944. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  42945. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42946. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42947. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42948. bindSamplers(effect: Effect): void;
  42949. enableEffect(effect: Effect): void;
  42950. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42951. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42952. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42953. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42954. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42955. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42956. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42957. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42958. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42959. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42960. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42961. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42962. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42963. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42964. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42965. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42966. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42967. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42968. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42969. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42970. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42971. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42972. bindBuffers(vertexBuffers: {
  42973. [key: string]: VertexBuffer;
  42974. }, indexBuffer: DataBuffer, effect: Effect): void;
  42975. wipeCaches(bruteForce?: boolean): void;
  42976. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42977. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42978. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42979. /** @hidden */
  42980. _createTexture(): WebGLTexture;
  42981. /** @hidden */
  42982. _releaseTexture(texture: InternalTexture): void;
  42983. 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;
  42984. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42985. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42986. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42987. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42988. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42989. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42990. areAllEffectsReady(): boolean;
  42991. /**
  42992. * @hidden
  42993. * Get the current error code of the webGL context
  42994. * @returns the error code
  42995. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42996. */
  42997. getError(): number;
  42998. /** @hidden */
  42999. _getUnpackAlignement(): number;
  43000. /** @hidden */
  43001. _unpackFlipY(value: boolean): void;
  43002. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43003. /**
  43004. * Updates a dynamic vertex buffer.
  43005. * @param vertexBuffer the vertex buffer to update
  43006. * @param data the data used to update the vertex buffer
  43007. * @param byteOffset the byte offset of the data (optional)
  43008. * @param byteLength the byte length of the data (optional)
  43009. */
  43010. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43011. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43012. /** @hidden */
  43013. _bindTexture(channel: number, texture: InternalTexture): void;
  43014. /** @hidden */
  43015. _releaseBuffer(buffer: DataBuffer): boolean;
  43016. releaseEffects(): void;
  43017. displayLoadingUI(): void;
  43018. hideLoadingUI(): void;
  43019. /** @hidden */
  43020. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43021. /** @hidden */
  43022. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43023. /** @hidden */
  43024. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43025. /** @hidden */
  43026. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43027. }
  43028. }
  43029. declare module BABYLON {
  43030. /** @hidden */
  43031. export class _OcclusionDataStorage {
  43032. /** @hidden */
  43033. occlusionInternalRetryCounter: number;
  43034. /** @hidden */
  43035. isOcclusionQueryInProgress: boolean;
  43036. /** @hidden */
  43037. isOccluded: boolean;
  43038. /** @hidden */
  43039. occlusionRetryCount: number;
  43040. /** @hidden */
  43041. occlusionType: number;
  43042. /** @hidden */
  43043. occlusionQueryAlgorithmType: number;
  43044. }
  43045. interface Engine {
  43046. /**
  43047. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43048. * @return the new query
  43049. */
  43050. createQuery(): WebGLQuery;
  43051. /**
  43052. * Delete and release a webGL query
  43053. * @param query defines the query to delete
  43054. * @return the current engine
  43055. */
  43056. deleteQuery(query: WebGLQuery): Engine;
  43057. /**
  43058. * Check if a given query has resolved and got its value
  43059. * @param query defines the query to check
  43060. * @returns true if the query got its value
  43061. */
  43062. isQueryResultAvailable(query: WebGLQuery): boolean;
  43063. /**
  43064. * Gets the value of a given query
  43065. * @param query defines the query to check
  43066. * @returns the value of the query
  43067. */
  43068. getQueryResult(query: WebGLQuery): number;
  43069. /**
  43070. * Initiates an occlusion query
  43071. * @param algorithmType defines the algorithm to use
  43072. * @param query defines the query to use
  43073. * @returns the current engine
  43074. * @see http://doc.babylonjs.com/features/occlusionquery
  43075. */
  43076. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43077. /**
  43078. * Ends an occlusion query
  43079. * @see http://doc.babylonjs.com/features/occlusionquery
  43080. * @param algorithmType defines the algorithm to use
  43081. * @returns the current engine
  43082. */
  43083. endOcclusionQuery(algorithmType: number): Engine;
  43084. /**
  43085. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43086. * Please note that only one query can be issued at a time
  43087. * @returns a time token used to track the time span
  43088. */
  43089. startTimeQuery(): Nullable<_TimeToken>;
  43090. /**
  43091. * Ends a time query
  43092. * @param token defines the token used to measure the time span
  43093. * @returns the time spent (in ns)
  43094. */
  43095. endTimeQuery(token: _TimeToken): int;
  43096. /** @hidden */
  43097. _currentNonTimestampToken: Nullable<_TimeToken>;
  43098. /** @hidden */
  43099. _createTimeQuery(): WebGLQuery;
  43100. /** @hidden */
  43101. _deleteTimeQuery(query: WebGLQuery): void;
  43102. /** @hidden */
  43103. _getGlAlgorithmType(algorithmType: number): number;
  43104. /** @hidden */
  43105. _getTimeQueryResult(query: WebGLQuery): any;
  43106. /** @hidden */
  43107. _getTimeQueryAvailability(query: WebGLQuery): any;
  43108. }
  43109. interface AbstractMesh {
  43110. /**
  43111. * Backing filed
  43112. * @hidden
  43113. */
  43114. __occlusionDataStorage: _OcclusionDataStorage;
  43115. /**
  43116. * Access property
  43117. * @hidden
  43118. */
  43119. _occlusionDataStorage: _OcclusionDataStorage;
  43120. /**
  43121. * 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.
  43122. * The default value is -1 which means don't break the query and wait till the result
  43123. * @see http://doc.babylonjs.com/features/occlusionquery
  43124. */
  43125. occlusionRetryCount: number;
  43126. /**
  43127. * 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:
  43128. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43129. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43130. * * 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.
  43131. * @see http://doc.babylonjs.com/features/occlusionquery
  43132. */
  43133. occlusionType: number;
  43134. /**
  43135. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43136. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43137. * * 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.
  43138. * @see http://doc.babylonjs.com/features/occlusionquery
  43139. */
  43140. occlusionQueryAlgorithmType: number;
  43141. /**
  43142. * 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
  43143. * @see http://doc.babylonjs.com/features/occlusionquery
  43144. */
  43145. isOccluded: boolean;
  43146. /**
  43147. * Flag to check the progress status of the query
  43148. * @see http://doc.babylonjs.com/features/occlusionquery
  43149. */
  43150. isOcclusionQueryInProgress: boolean;
  43151. }
  43152. }
  43153. declare module BABYLON {
  43154. /** @hidden */
  43155. export var _forceTransformFeedbackToBundle: boolean;
  43156. interface Engine {
  43157. /**
  43158. * Creates a webGL transform feedback object
  43159. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43160. * @returns the webGL transform feedback object
  43161. */
  43162. createTransformFeedback(): WebGLTransformFeedback;
  43163. /**
  43164. * Delete a webGL transform feedback object
  43165. * @param value defines the webGL transform feedback object to delete
  43166. */
  43167. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43168. /**
  43169. * Bind a webGL transform feedback object to the webgl context
  43170. * @param value defines the webGL transform feedback object to bind
  43171. */
  43172. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43173. /**
  43174. * Begins a transform feedback operation
  43175. * @param usePoints defines if points or triangles must be used
  43176. */
  43177. beginTransformFeedback(usePoints: boolean): void;
  43178. /**
  43179. * Ends a transform feedback operation
  43180. */
  43181. endTransformFeedback(): void;
  43182. /**
  43183. * Specify the varyings to use with transform feedback
  43184. * @param program defines the associated webGL program
  43185. * @param value defines the list of strings representing the varying names
  43186. */
  43187. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43188. /**
  43189. * Bind a webGL buffer for a transform feedback operation
  43190. * @param value defines the webGL buffer to bind
  43191. */
  43192. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43193. }
  43194. }
  43195. declare module BABYLON {
  43196. /**
  43197. * Creation options of the multi render target texture.
  43198. */
  43199. export interface IMultiRenderTargetOptions {
  43200. /**
  43201. * Define if the texture needs to create mip maps after render.
  43202. */
  43203. generateMipMaps?: boolean;
  43204. /**
  43205. * Define the types of all the draw buffers we want to create
  43206. */
  43207. types?: number[];
  43208. /**
  43209. * Define the sampling modes of all the draw buffers we want to create
  43210. */
  43211. samplingModes?: number[];
  43212. /**
  43213. * Define if a depth buffer is required
  43214. */
  43215. generateDepthBuffer?: boolean;
  43216. /**
  43217. * Define if a stencil buffer is required
  43218. */
  43219. generateStencilBuffer?: boolean;
  43220. /**
  43221. * Define if a depth texture is required instead of a depth buffer
  43222. */
  43223. generateDepthTexture?: boolean;
  43224. /**
  43225. * Define the number of desired draw buffers
  43226. */
  43227. textureCount?: number;
  43228. /**
  43229. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43230. */
  43231. doNotChangeAspectRatio?: boolean;
  43232. /**
  43233. * Define the default type of the buffers we are creating
  43234. */
  43235. defaultType?: number;
  43236. }
  43237. /**
  43238. * A multi render target, like a render target provides the ability to render to a texture.
  43239. * Unlike the render target, it can render to several draw buffers in one draw.
  43240. * This is specially interesting in deferred rendering or for any effects requiring more than
  43241. * just one color from a single pass.
  43242. */
  43243. export class MultiRenderTarget extends RenderTargetTexture {
  43244. private _internalTextures;
  43245. private _textures;
  43246. private _multiRenderTargetOptions;
  43247. /**
  43248. * Get if draw buffers are currently supported by the used hardware and browser.
  43249. */
  43250. readonly isSupported: boolean;
  43251. /**
  43252. * Get the list of textures generated by the multi render target.
  43253. */
  43254. readonly textures: Texture[];
  43255. /**
  43256. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43257. */
  43258. readonly depthTexture: Texture;
  43259. /**
  43260. * Set the wrapping mode on U of all the textures we are rendering to.
  43261. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43262. */
  43263. wrapU: number;
  43264. /**
  43265. * Set the wrapping mode on V of all the textures we are rendering to.
  43266. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43267. */
  43268. wrapV: number;
  43269. /**
  43270. * Instantiate a new multi render target texture.
  43271. * A multi render target, like a render target provides the ability to render to a texture.
  43272. * Unlike the render target, it can render to several draw buffers in one draw.
  43273. * This is specially interesting in deferred rendering or for any effects requiring more than
  43274. * just one color from a single pass.
  43275. * @param name Define the name of the texture
  43276. * @param size Define the size of the buffers to render to
  43277. * @param count Define the number of target we are rendering into
  43278. * @param scene Define the scene the texture belongs to
  43279. * @param options Define the options used to create the multi render target
  43280. */
  43281. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43282. /** @hidden */
  43283. _rebuild(): void;
  43284. private _createInternalTextures;
  43285. private _createTextures;
  43286. /**
  43287. * Define the number of samples used if MSAA is enabled.
  43288. */
  43289. samples: number;
  43290. /**
  43291. * Resize all the textures in the multi render target.
  43292. * Be carrefull as it will recreate all the data in the new texture.
  43293. * @param size Define the new size
  43294. */
  43295. resize(size: any): void;
  43296. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43297. /**
  43298. * Dispose the render targets and their associated resources
  43299. */
  43300. dispose(): void;
  43301. /**
  43302. * Release all the underlying texture used as draw buffers.
  43303. */
  43304. releaseInternalTextures(): void;
  43305. }
  43306. }
  43307. declare module BABYLON {
  43308. interface Engine {
  43309. /**
  43310. * Unbind a list of render target textures from the webGL context
  43311. * This is used only when drawBuffer extension or webGL2 are active
  43312. * @param textures defines the render target textures to unbind
  43313. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43314. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43315. */
  43316. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43317. /**
  43318. * Create a multi render target texture
  43319. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43320. * @param size defines the size of the texture
  43321. * @param options defines the creation options
  43322. * @returns the cube texture as an InternalTexture
  43323. */
  43324. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43325. /**
  43326. * Update the sample count for a given multiple render target texture
  43327. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43328. * @param textures defines the textures to update
  43329. * @param samples defines the sample count to set
  43330. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43331. */
  43332. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43333. }
  43334. }
  43335. declare module BABYLON {
  43336. /**
  43337. * Gather the list of clipboard event types as constants.
  43338. */
  43339. export class ClipboardEventTypes {
  43340. /**
  43341. * The clipboard event is fired when a copy command is active (pressed).
  43342. */
  43343. static readonly COPY: number;
  43344. /**
  43345. * The clipboard event is fired when a cut command is active (pressed).
  43346. */
  43347. static readonly CUT: number;
  43348. /**
  43349. * The clipboard event is fired when a paste command is active (pressed).
  43350. */
  43351. static readonly PASTE: number;
  43352. }
  43353. /**
  43354. * This class is used to store clipboard related info for the onClipboardObservable event.
  43355. */
  43356. export class ClipboardInfo {
  43357. /**
  43358. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43359. */
  43360. type: number;
  43361. /**
  43362. * Defines the related dom event
  43363. */
  43364. event: ClipboardEvent;
  43365. /**
  43366. *Creates an instance of ClipboardInfo.
  43367. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43368. * @param event Defines the related dom event
  43369. */
  43370. constructor(
  43371. /**
  43372. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43373. */
  43374. type: number,
  43375. /**
  43376. * Defines the related dom event
  43377. */
  43378. event: ClipboardEvent);
  43379. /**
  43380. * Get the clipboard event's type from the keycode.
  43381. * @param keyCode Defines the keyCode for the current keyboard event.
  43382. * @return {number}
  43383. */
  43384. static GetTypeFromCharacter(keyCode: number): number;
  43385. }
  43386. }
  43387. declare module BABYLON {
  43388. /**
  43389. * Google Daydream controller
  43390. */
  43391. export class DaydreamController extends WebVRController {
  43392. /**
  43393. * Base Url for the controller model.
  43394. */
  43395. static MODEL_BASE_URL: string;
  43396. /**
  43397. * File name for the controller model.
  43398. */
  43399. static MODEL_FILENAME: string;
  43400. /**
  43401. * Gamepad Id prefix used to identify Daydream Controller.
  43402. */
  43403. static readonly GAMEPAD_ID_PREFIX: string;
  43404. /**
  43405. * Creates a new DaydreamController from a gamepad
  43406. * @param vrGamepad the gamepad that the controller should be created from
  43407. */
  43408. constructor(vrGamepad: any);
  43409. /**
  43410. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43411. * @param scene scene in which to add meshes
  43412. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43413. */
  43414. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43415. /**
  43416. * Called once for each button that changed state since the last frame
  43417. * @param buttonIdx Which button index changed
  43418. * @param state New state of the button
  43419. * @param changes Which properties on the state changed since last frame
  43420. */
  43421. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43422. }
  43423. }
  43424. declare module BABYLON {
  43425. /**
  43426. * Gear VR Controller
  43427. */
  43428. export class GearVRController extends WebVRController {
  43429. /**
  43430. * Base Url for the controller model.
  43431. */
  43432. static MODEL_BASE_URL: string;
  43433. /**
  43434. * File name for the controller model.
  43435. */
  43436. static MODEL_FILENAME: string;
  43437. /**
  43438. * Gamepad Id prefix used to identify this controller.
  43439. */
  43440. static readonly GAMEPAD_ID_PREFIX: string;
  43441. private readonly _buttonIndexToObservableNameMap;
  43442. /**
  43443. * Creates a new GearVRController from a gamepad
  43444. * @param vrGamepad the gamepad that the controller should be created from
  43445. */
  43446. constructor(vrGamepad: any);
  43447. /**
  43448. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43449. * @param scene scene in which to add meshes
  43450. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43451. */
  43452. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43453. /**
  43454. * Called once for each button that changed state since the last frame
  43455. * @param buttonIdx Which button index changed
  43456. * @param state New state of the button
  43457. * @param changes Which properties on the state changed since last frame
  43458. */
  43459. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43460. }
  43461. }
  43462. declare module BABYLON {
  43463. /**
  43464. * Class containing static functions to help procedurally build meshes
  43465. */
  43466. export class PolyhedronBuilder {
  43467. /**
  43468. * Creates a polyhedron mesh
  43469. * * 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
  43470. * * The parameter `size` (positive float, default 1) sets the polygon size
  43471. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43472. * * 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`
  43473. * * 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
  43474. * * 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)`)
  43475. * * 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
  43476. * * 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
  43477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43478. * * 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
  43479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43480. * @param name defines the name of the mesh
  43481. * @param options defines the options used to create the mesh
  43482. * @param scene defines the hosting scene
  43483. * @returns the polyhedron mesh
  43484. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43485. */
  43486. static CreatePolyhedron(name: string, options: {
  43487. type?: number;
  43488. size?: number;
  43489. sizeX?: number;
  43490. sizeY?: number;
  43491. sizeZ?: number;
  43492. custom?: any;
  43493. faceUV?: Vector4[];
  43494. faceColors?: Color4[];
  43495. flat?: boolean;
  43496. updatable?: boolean;
  43497. sideOrientation?: number;
  43498. frontUVs?: Vector4;
  43499. backUVs?: Vector4;
  43500. }, scene?: Nullable<Scene>): Mesh;
  43501. }
  43502. }
  43503. declare module BABYLON {
  43504. /**
  43505. * Gizmo that enables scaling a mesh along 3 axis
  43506. */
  43507. export class ScaleGizmo extends Gizmo {
  43508. /**
  43509. * Internal gizmo used for interactions on the x axis
  43510. */
  43511. xGizmo: AxisScaleGizmo;
  43512. /**
  43513. * Internal gizmo used for interactions on the y axis
  43514. */
  43515. yGizmo: AxisScaleGizmo;
  43516. /**
  43517. * Internal gizmo used for interactions on the z axis
  43518. */
  43519. zGizmo: AxisScaleGizmo;
  43520. /**
  43521. * Internal gizmo used to scale all axis equally
  43522. */
  43523. uniformScaleGizmo: AxisScaleGizmo;
  43524. private _meshAttached;
  43525. private _updateGizmoRotationToMatchAttachedMesh;
  43526. private _snapDistance;
  43527. private _scaleRatio;
  43528. private _uniformScalingMesh;
  43529. private _octahedron;
  43530. /** Fires an event when any of it's sub gizmos are dragged */
  43531. onDragStartObservable: Observable<unknown>;
  43532. /** Fires an event when any of it's sub gizmos are released from dragging */
  43533. onDragEndObservable: Observable<unknown>;
  43534. attachedMesh: Nullable<AbstractMesh>;
  43535. /**
  43536. * Creates a ScaleGizmo
  43537. * @param gizmoLayer The utility layer the gizmo will be added to
  43538. */
  43539. constructor(gizmoLayer?: UtilityLayerRenderer);
  43540. updateGizmoRotationToMatchAttachedMesh: boolean;
  43541. /**
  43542. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43543. */
  43544. snapDistance: number;
  43545. /**
  43546. * Ratio for the scale of the gizmo (Default: 1)
  43547. */
  43548. scaleRatio: number;
  43549. /**
  43550. * Disposes of the gizmo
  43551. */
  43552. dispose(): void;
  43553. }
  43554. }
  43555. declare module BABYLON {
  43556. /**
  43557. * Single axis scale gizmo
  43558. */
  43559. export class AxisScaleGizmo extends Gizmo {
  43560. /**
  43561. * Drag behavior responsible for the gizmos dragging interactions
  43562. */
  43563. dragBehavior: PointerDragBehavior;
  43564. private _pointerObserver;
  43565. /**
  43566. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43567. */
  43568. snapDistance: number;
  43569. /**
  43570. * Event that fires each time the gizmo snaps to a new location.
  43571. * * snapDistance is the the change in distance
  43572. */
  43573. onSnapObservable: Observable<{
  43574. snapDistance: number;
  43575. }>;
  43576. /**
  43577. * If the scaling operation should be done on all axis (default: false)
  43578. */
  43579. uniformScaling: boolean;
  43580. private _isEnabled;
  43581. private _parent;
  43582. private _arrow;
  43583. private _coloredMaterial;
  43584. private _hoverMaterial;
  43585. /**
  43586. * Creates an AxisScaleGizmo
  43587. * @param gizmoLayer The utility layer the gizmo will be added to
  43588. * @param dragAxis The axis which the gizmo will be able to scale on
  43589. * @param color The color of the gizmo
  43590. */
  43591. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43592. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43593. /**
  43594. * If the gizmo is enabled
  43595. */
  43596. isEnabled: boolean;
  43597. /**
  43598. * Disposes of the gizmo
  43599. */
  43600. dispose(): void;
  43601. /**
  43602. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43603. * @param mesh The mesh to replace the default mesh of the gizmo
  43604. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43605. */
  43606. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43607. }
  43608. }
  43609. declare module BABYLON {
  43610. /**
  43611. * Bounding box gizmo
  43612. */
  43613. export class BoundingBoxGizmo extends Gizmo {
  43614. private _lineBoundingBox;
  43615. private _rotateSpheresParent;
  43616. private _scaleBoxesParent;
  43617. private _boundingDimensions;
  43618. private _renderObserver;
  43619. private _pointerObserver;
  43620. private _scaleDragSpeed;
  43621. private _tmpQuaternion;
  43622. private _tmpVector;
  43623. private _tmpRotationMatrix;
  43624. /**
  43625. * 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)
  43626. */
  43627. ignoreChildren: boolean;
  43628. /**
  43629. * 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)
  43630. */
  43631. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43632. /**
  43633. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43634. */
  43635. rotationSphereSize: number;
  43636. /**
  43637. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43638. */
  43639. scaleBoxSize: number;
  43640. /**
  43641. * 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)
  43642. */
  43643. fixedDragMeshScreenSize: boolean;
  43644. /**
  43645. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43646. */
  43647. fixedDragMeshScreenSizeDistanceFactor: number;
  43648. /**
  43649. * Fired when a rotation sphere or scale box is dragged
  43650. */
  43651. onDragStartObservable: Observable<{}>;
  43652. /**
  43653. * Fired when a scale box is dragged
  43654. */
  43655. onScaleBoxDragObservable: Observable<{}>;
  43656. /**
  43657. * Fired when a scale box drag is ended
  43658. */
  43659. onScaleBoxDragEndObservable: Observable<{}>;
  43660. /**
  43661. * Fired when a rotation sphere is dragged
  43662. */
  43663. onRotationSphereDragObservable: Observable<{}>;
  43664. /**
  43665. * Fired when a rotation sphere drag is ended
  43666. */
  43667. onRotationSphereDragEndObservable: Observable<{}>;
  43668. /**
  43669. * 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)
  43670. */
  43671. scalePivot: Nullable<Vector3>;
  43672. /**
  43673. * Mesh used as a pivot to rotate the attached mesh
  43674. */
  43675. private _anchorMesh;
  43676. private _existingMeshScale;
  43677. private _dragMesh;
  43678. private pointerDragBehavior;
  43679. private coloredMaterial;
  43680. private hoverColoredMaterial;
  43681. /**
  43682. * Sets the color of the bounding box gizmo
  43683. * @param color the color to set
  43684. */
  43685. setColor(color: Color3): void;
  43686. /**
  43687. * Creates an BoundingBoxGizmo
  43688. * @param gizmoLayer The utility layer the gizmo will be added to
  43689. * @param color The color of the gizmo
  43690. */
  43691. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43692. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43693. private _selectNode;
  43694. /**
  43695. * Updates the bounding box information for the Gizmo
  43696. */
  43697. updateBoundingBox(): void;
  43698. private _updateRotationSpheres;
  43699. private _updateScaleBoxes;
  43700. /**
  43701. * Enables rotation on the specified axis and disables rotation on the others
  43702. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43703. */
  43704. setEnabledRotationAxis(axis: string): void;
  43705. /**
  43706. * Enables/disables scaling
  43707. * @param enable if scaling should be enabled
  43708. */
  43709. setEnabledScaling(enable: boolean): void;
  43710. private _updateDummy;
  43711. /**
  43712. * Enables a pointer drag behavior on the bounding box of the gizmo
  43713. */
  43714. enableDragBehavior(): void;
  43715. /**
  43716. * Disposes of the gizmo
  43717. */
  43718. dispose(): void;
  43719. /**
  43720. * 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)
  43721. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43722. * @returns the bounding box mesh with the passed in mesh as a child
  43723. */
  43724. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43725. /**
  43726. * CustomMeshes are not supported by this gizmo
  43727. * @param mesh The mesh to replace the default mesh of the gizmo
  43728. */
  43729. setCustomMesh(mesh: Mesh): void;
  43730. }
  43731. }
  43732. declare module BABYLON {
  43733. /**
  43734. * Single plane rotation gizmo
  43735. */
  43736. export class PlaneRotationGizmo extends Gizmo {
  43737. /**
  43738. * Drag behavior responsible for the gizmos dragging interactions
  43739. */
  43740. dragBehavior: PointerDragBehavior;
  43741. private _pointerObserver;
  43742. /**
  43743. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43744. */
  43745. snapDistance: number;
  43746. /**
  43747. * Event that fires each time the gizmo snaps to a new location.
  43748. * * snapDistance is the the change in distance
  43749. */
  43750. onSnapObservable: Observable<{
  43751. snapDistance: number;
  43752. }>;
  43753. private _isEnabled;
  43754. private _parent;
  43755. /**
  43756. * Creates a PlaneRotationGizmo
  43757. * @param gizmoLayer The utility layer the gizmo will be added to
  43758. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43759. * @param color The color of the gizmo
  43760. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43761. */
  43762. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43763. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43764. /**
  43765. * If the gizmo is enabled
  43766. */
  43767. isEnabled: boolean;
  43768. /**
  43769. * Disposes of the gizmo
  43770. */
  43771. dispose(): void;
  43772. }
  43773. }
  43774. declare module BABYLON {
  43775. /**
  43776. * Gizmo that enables rotating a mesh along 3 axis
  43777. */
  43778. export class RotationGizmo extends Gizmo {
  43779. /**
  43780. * Internal gizmo used for interactions on the x axis
  43781. */
  43782. xGizmo: PlaneRotationGizmo;
  43783. /**
  43784. * Internal gizmo used for interactions on the y axis
  43785. */
  43786. yGizmo: PlaneRotationGizmo;
  43787. /**
  43788. * Internal gizmo used for interactions on the z axis
  43789. */
  43790. zGizmo: PlaneRotationGizmo;
  43791. /** Fires an event when any of it's sub gizmos are dragged */
  43792. onDragStartObservable: Observable<unknown>;
  43793. /** Fires an event when any of it's sub gizmos are released from dragging */
  43794. onDragEndObservable: Observable<unknown>;
  43795. private _meshAttached;
  43796. attachedMesh: Nullable<AbstractMesh>;
  43797. /**
  43798. * Creates a RotationGizmo
  43799. * @param gizmoLayer The utility layer the gizmo will be added to
  43800. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43801. */
  43802. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43803. updateGizmoRotationToMatchAttachedMesh: boolean;
  43804. /**
  43805. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43806. */
  43807. snapDistance: number;
  43808. /**
  43809. * Ratio for the scale of the gizmo (Default: 1)
  43810. */
  43811. scaleRatio: number;
  43812. /**
  43813. * Disposes of the gizmo
  43814. */
  43815. dispose(): void;
  43816. /**
  43817. * CustomMeshes are not supported by this gizmo
  43818. * @param mesh The mesh to replace the default mesh of the gizmo
  43819. */
  43820. setCustomMesh(mesh: Mesh): void;
  43821. }
  43822. }
  43823. declare module BABYLON {
  43824. /**
  43825. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43826. */
  43827. export class GizmoManager implements IDisposable {
  43828. private scene;
  43829. /**
  43830. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43831. */
  43832. gizmos: {
  43833. positionGizmo: Nullable<PositionGizmo>;
  43834. rotationGizmo: Nullable<RotationGizmo>;
  43835. scaleGizmo: Nullable<ScaleGizmo>;
  43836. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43837. };
  43838. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43839. clearGizmoOnEmptyPointerEvent: boolean;
  43840. /** Fires an event when the manager is attached to a mesh */
  43841. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43842. private _gizmosEnabled;
  43843. private _pointerObserver;
  43844. private _attachedMesh;
  43845. private _boundingBoxColor;
  43846. private _defaultUtilityLayer;
  43847. private _defaultKeepDepthUtilityLayer;
  43848. /**
  43849. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43850. */
  43851. boundingBoxDragBehavior: SixDofDragBehavior;
  43852. /**
  43853. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43854. */
  43855. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43856. /**
  43857. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43858. */
  43859. usePointerToAttachGizmos: boolean;
  43860. /**
  43861. * Utility layer that the bounding box gizmo belongs to
  43862. */
  43863. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43864. /**
  43865. * Utility layer that all gizmos besides bounding box belong to
  43866. */
  43867. readonly utilityLayer: UtilityLayerRenderer;
  43868. /**
  43869. * Instatiates a gizmo manager
  43870. * @param scene the scene to overlay the gizmos on top of
  43871. */
  43872. constructor(scene: Scene);
  43873. /**
  43874. * Attaches a set of gizmos to the specified mesh
  43875. * @param mesh The mesh the gizmo's should be attached to
  43876. */
  43877. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43878. /**
  43879. * If the position gizmo is enabled
  43880. */
  43881. positionGizmoEnabled: boolean;
  43882. /**
  43883. * If the rotation gizmo is enabled
  43884. */
  43885. rotationGizmoEnabled: boolean;
  43886. /**
  43887. * If the scale gizmo is enabled
  43888. */
  43889. scaleGizmoEnabled: boolean;
  43890. /**
  43891. * If the boundingBox gizmo is enabled
  43892. */
  43893. boundingBoxGizmoEnabled: boolean;
  43894. /**
  43895. * Disposes of the gizmo manager
  43896. */
  43897. dispose(): void;
  43898. }
  43899. }
  43900. declare module BABYLON {
  43901. /**
  43902. * A directional light is defined by a direction (what a surprise!).
  43903. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43904. * 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.
  43905. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43906. */
  43907. export class DirectionalLight extends ShadowLight {
  43908. private _shadowFrustumSize;
  43909. /**
  43910. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43911. */
  43912. /**
  43913. * Specifies a fix frustum size for the shadow generation.
  43914. */
  43915. shadowFrustumSize: number;
  43916. private _shadowOrthoScale;
  43917. /**
  43918. * Gets the shadow projection scale against the optimal computed one.
  43919. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43920. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43921. */
  43922. /**
  43923. * Sets the shadow projection scale against the optimal computed one.
  43924. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43925. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43926. */
  43927. shadowOrthoScale: number;
  43928. /**
  43929. * Automatically compute the projection matrix to best fit (including all the casters)
  43930. * on each frame.
  43931. */
  43932. autoUpdateExtends: boolean;
  43933. private _orthoLeft;
  43934. private _orthoRight;
  43935. private _orthoTop;
  43936. private _orthoBottom;
  43937. /**
  43938. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43939. * The directional light is emitted from everywhere in the given direction.
  43940. * It can cast shadows.
  43941. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43942. * @param name The friendly name of the light
  43943. * @param direction The direction of the light
  43944. * @param scene The scene the light belongs to
  43945. */
  43946. constructor(name: string, direction: Vector3, scene: Scene);
  43947. /**
  43948. * Returns the string "DirectionalLight".
  43949. * @return The class name
  43950. */
  43951. getClassName(): string;
  43952. /**
  43953. * Returns the integer 1.
  43954. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43955. */
  43956. getTypeID(): number;
  43957. /**
  43958. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43959. * Returns the DirectionalLight Shadow projection matrix.
  43960. */
  43961. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43962. /**
  43963. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43964. * Returns the DirectionalLight Shadow projection matrix.
  43965. */
  43966. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43967. /**
  43968. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43969. * Returns the DirectionalLight Shadow projection matrix.
  43970. */
  43971. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43972. protected _buildUniformLayout(): void;
  43973. /**
  43974. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43975. * @param effect The effect to update
  43976. * @param lightIndex The index of the light in the effect to update
  43977. * @returns The directional light
  43978. */
  43979. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43980. /**
  43981. * Gets the minZ used for shadow according to both the scene and the light.
  43982. *
  43983. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43984. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43985. * @param activeCamera The camera we are returning the min for
  43986. * @returns the depth min z
  43987. */
  43988. getDepthMinZ(activeCamera: Camera): number;
  43989. /**
  43990. * Gets the maxZ used for shadow according to both the scene and the light.
  43991. *
  43992. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43993. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43994. * @param activeCamera The camera we are returning the max for
  43995. * @returns the depth max z
  43996. */
  43997. getDepthMaxZ(activeCamera: Camera): number;
  43998. /**
  43999. * Prepares the list of defines specific to the light type.
  44000. * @param defines the list of defines
  44001. * @param lightIndex defines the index of the light for the effect
  44002. */
  44003. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44004. }
  44005. }
  44006. declare module BABYLON {
  44007. /**
  44008. * Class containing static functions to help procedurally build meshes
  44009. */
  44010. export class HemisphereBuilder {
  44011. /**
  44012. * Creates a hemisphere mesh
  44013. * @param name defines the name of the mesh
  44014. * @param options defines the options used to create the mesh
  44015. * @param scene defines the hosting scene
  44016. * @returns the hemisphere mesh
  44017. */
  44018. static CreateHemisphere(name: string, options: {
  44019. segments?: number;
  44020. diameter?: number;
  44021. sideOrientation?: number;
  44022. }, scene: any): Mesh;
  44023. }
  44024. }
  44025. declare module BABYLON {
  44026. /**
  44027. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44028. * These values define a cone of light starting from the position, emitting toward the direction.
  44029. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44030. * and the exponent defines the speed of the decay of the light with distance (reach).
  44031. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44032. */
  44033. export class SpotLight extends ShadowLight {
  44034. private _angle;
  44035. private _innerAngle;
  44036. private _cosHalfAngle;
  44037. private _lightAngleScale;
  44038. private _lightAngleOffset;
  44039. /**
  44040. * Gets the cone angle of the spot light in Radians.
  44041. */
  44042. /**
  44043. * Sets the cone angle of the spot light in Radians.
  44044. */
  44045. angle: number;
  44046. /**
  44047. * Only used in gltf falloff mode, this defines the angle where
  44048. * the directional falloff will start before cutting at angle which could be seen
  44049. * as outer angle.
  44050. */
  44051. /**
  44052. * Only used in gltf falloff mode, this defines the angle where
  44053. * the directional falloff will start before cutting at angle which could be seen
  44054. * as outer angle.
  44055. */
  44056. innerAngle: number;
  44057. private _shadowAngleScale;
  44058. /**
  44059. * Allows scaling the angle of the light for shadow generation only.
  44060. */
  44061. /**
  44062. * Allows scaling the angle of the light for shadow generation only.
  44063. */
  44064. shadowAngleScale: number;
  44065. /**
  44066. * The light decay speed with the distance from the emission spot.
  44067. */
  44068. exponent: number;
  44069. private _projectionTextureMatrix;
  44070. /**
  44071. * Allows reading the projecton texture
  44072. */
  44073. readonly projectionTextureMatrix: Matrix;
  44074. protected _projectionTextureLightNear: number;
  44075. /**
  44076. * Gets the near clip of the Spotlight for texture projection.
  44077. */
  44078. /**
  44079. * Sets the near clip of the Spotlight for texture projection.
  44080. */
  44081. projectionTextureLightNear: number;
  44082. protected _projectionTextureLightFar: number;
  44083. /**
  44084. * Gets the far clip of the Spotlight for texture projection.
  44085. */
  44086. /**
  44087. * Sets the far clip of the Spotlight for texture projection.
  44088. */
  44089. projectionTextureLightFar: number;
  44090. protected _projectionTextureUpDirection: Vector3;
  44091. /**
  44092. * Gets the Up vector of the Spotlight for texture projection.
  44093. */
  44094. /**
  44095. * Sets the Up vector of the Spotlight for texture projection.
  44096. */
  44097. projectionTextureUpDirection: Vector3;
  44098. private _projectionTexture;
  44099. /**
  44100. * Gets the projection texture of the light.
  44101. */
  44102. /**
  44103. * Sets the projection texture of the light.
  44104. */
  44105. projectionTexture: Nullable<BaseTexture>;
  44106. private _projectionTextureViewLightDirty;
  44107. private _projectionTextureProjectionLightDirty;
  44108. private _projectionTextureDirty;
  44109. private _projectionTextureViewTargetVector;
  44110. private _projectionTextureViewLightMatrix;
  44111. private _projectionTextureProjectionLightMatrix;
  44112. private _projectionTextureScalingMatrix;
  44113. /**
  44114. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44115. * It can cast shadows.
  44116. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44117. * @param name The light friendly name
  44118. * @param position The position of the spot light in the scene
  44119. * @param direction The direction of the light in the scene
  44120. * @param angle The cone angle of the light in Radians
  44121. * @param exponent The light decay speed with the distance from the emission spot
  44122. * @param scene The scene the lights belongs to
  44123. */
  44124. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44125. /**
  44126. * Returns the string "SpotLight".
  44127. * @returns the class name
  44128. */
  44129. getClassName(): string;
  44130. /**
  44131. * Returns the integer 2.
  44132. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44133. */
  44134. getTypeID(): number;
  44135. /**
  44136. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44137. */
  44138. protected _setDirection(value: Vector3): void;
  44139. /**
  44140. * Overrides the position setter to recompute the projection texture view light Matrix.
  44141. */
  44142. protected _setPosition(value: Vector3): void;
  44143. /**
  44144. * 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.
  44145. * Returns the SpotLight.
  44146. */
  44147. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44148. protected _computeProjectionTextureViewLightMatrix(): void;
  44149. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44150. /**
  44151. * Main function for light texture projection matrix computing.
  44152. */
  44153. protected _computeProjectionTextureMatrix(): void;
  44154. protected _buildUniformLayout(): void;
  44155. private _computeAngleValues;
  44156. /**
  44157. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44158. * @param effect The effect to update
  44159. * @param lightIndex The index of the light in the effect to update
  44160. * @returns The spot light
  44161. */
  44162. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44163. /**
  44164. * Disposes the light and the associated resources.
  44165. */
  44166. dispose(): void;
  44167. /**
  44168. * Prepares the list of defines specific to the light type.
  44169. * @param defines the list of defines
  44170. * @param lightIndex defines the index of the light for the effect
  44171. */
  44172. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44173. }
  44174. }
  44175. declare module BABYLON {
  44176. /**
  44177. * Gizmo that enables viewing a light
  44178. */
  44179. export class LightGizmo extends Gizmo {
  44180. private _lightMesh;
  44181. private _material;
  44182. private cachedPosition;
  44183. private cachedForward;
  44184. /**
  44185. * Creates a LightGizmo
  44186. * @param gizmoLayer The utility layer the gizmo will be added to
  44187. */
  44188. constructor(gizmoLayer?: UtilityLayerRenderer);
  44189. private _light;
  44190. /**
  44191. * The light that the gizmo is attached to
  44192. */
  44193. light: Nullable<Light>;
  44194. /**
  44195. * @hidden
  44196. * Updates the gizmo to match the attached mesh's position/rotation
  44197. */
  44198. protected _update(): void;
  44199. private static _Scale;
  44200. /**
  44201. * Creates the lines for a light mesh
  44202. */
  44203. private static _createLightLines;
  44204. /**
  44205. * Disposes of the light gizmo
  44206. */
  44207. dispose(): void;
  44208. private static _CreateHemisphericLightMesh;
  44209. private static _CreatePointLightMesh;
  44210. private static _CreateSpotLightMesh;
  44211. private static _CreateDirectionalLightMesh;
  44212. }
  44213. }
  44214. declare module BABYLON {
  44215. /** @hidden */
  44216. export var backgroundFragmentDeclaration: {
  44217. name: string;
  44218. shader: string;
  44219. };
  44220. }
  44221. declare module BABYLON {
  44222. /** @hidden */
  44223. export var backgroundUboDeclaration: {
  44224. name: string;
  44225. shader: string;
  44226. };
  44227. }
  44228. declare module BABYLON {
  44229. /** @hidden */
  44230. export var backgroundPixelShader: {
  44231. name: string;
  44232. shader: string;
  44233. };
  44234. }
  44235. declare module BABYLON {
  44236. /** @hidden */
  44237. export var backgroundVertexDeclaration: {
  44238. name: string;
  44239. shader: string;
  44240. };
  44241. }
  44242. declare module BABYLON {
  44243. /** @hidden */
  44244. export var backgroundVertexShader: {
  44245. name: string;
  44246. shader: string;
  44247. };
  44248. }
  44249. declare module BABYLON {
  44250. /**
  44251. * Background material used to create an efficient environement around your scene.
  44252. */
  44253. export class BackgroundMaterial extends PushMaterial {
  44254. /**
  44255. * Standard reflectance value at parallel view angle.
  44256. */
  44257. static StandardReflectance0: number;
  44258. /**
  44259. * Standard reflectance value at grazing angle.
  44260. */
  44261. static StandardReflectance90: number;
  44262. protected _primaryColor: Color3;
  44263. /**
  44264. * Key light Color (multiply against the environement texture)
  44265. */
  44266. primaryColor: Color3;
  44267. protected __perceptualColor: Nullable<Color3>;
  44268. /**
  44269. * Experimental Internal Use Only.
  44270. *
  44271. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44272. * This acts as a helper to set the primary color to a more "human friendly" value.
  44273. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44274. * output color as close as possible from the chosen value.
  44275. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44276. * part of lighting setup.)
  44277. */
  44278. _perceptualColor: Nullable<Color3>;
  44279. protected _primaryColorShadowLevel: float;
  44280. /**
  44281. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44282. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44283. */
  44284. primaryColorShadowLevel: float;
  44285. protected _primaryColorHighlightLevel: float;
  44286. /**
  44287. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44288. * The primary color is used at the level chosen to define what the white area would look.
  44289. */
  44290. primaryColorHighlightLevel: float;
  44291. protected _reflectionTexture: Nullable<BaseTexture>;
  44292. /**
  44293. * Reflection Texture used in the material.
  44294. * Should be author in a specific way for the best result (refer to the documentation).
  44295. */
  44296. reflectionTexture: Nullable<BaseTexture>;
  44297. protected _reflectionBlur: float;
  44298. /**
  44299. * Reflection Texture level of blur.
  44300. *
  44301. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44302. * texture twice.
  44303. */
  44304. reflectionBlur: float;
  44305. protected _diffuseTexture: Nullable<BaseTexture>;
  44306. /**
  44307. * Diffuse Texture used in the material.
  44308. * Should be author in a specific way for the best result (refer to the documentation).
  44309. */
  44310. diffuseTexture: Nullable<BaseTexture>;
  44311. protected _shadowLights: Nullable<IShadowLight[]>;
  44312. /**
  44313. * Specify the list of lights casting shadow on the material.
  44314. * All scene shadow lights will be included if null.
  44315. */
  44316. shadowLights: Nullable<IShadowLight[]>;
  44317. protected _shadowLevel: float;
  44318. /**
  44319. * Helps adjusting the shadow to a softer level if required.
  44320. * 0 means black shadows and 1 means no shadows.
  44321. */
  44322. shadowLevel: float;
  44323. protected _sceneCenter: Vector3;
  44324. /**
  44325. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44326. * It is usually zero but might be interesting to modify according to your setup.
  44327. */
  44328. sceneCenter: Vector3;
  44329. protected _opacityFresnel: boolean;
  44330. /**
  44331. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44332. * This helps ensuring a nice transition when the camera goes under the ground.
  44333. */
  44334. opacityFresnel: boolean;
  44335. protected _reflectionFresnel: boolean;
  44336. /**
  44337. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44338. * This helps adding a mirror texture on the ground.
  44339. */
  44340. reflectionFresnel: boolean;
  44341. protected _reflectionFalloffDistance: number;
  44342. /**
  44343. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44344. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44345. */
  44346. reflectionFalloffDistance: number;
  44347. protected _reflectionAmount: number;
  44348. /**
  44349. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44350. */
  44351. reflectionAmount: number;
  44352. protected _reflectionReflectance0: number;
  44353. /**
  44354. * This specifies the weight of the reflection at grazing angle.
  44355. */
  44356. reflectionReflectance0: number;
  44357. protected _reflectionReflectance90: number;
  44358. /**
  44359. * This specifies the weight of the reflection at a perpendicular point of view.
  44360. */
  44361. reflectionReflectance90: number;
  44362. /**
  44363. * Sets the reflection reflectance fresnel values according to the default standard
  44364. * empirically know to work well :-)
  44365. */
  44366. reflectionStandardFresnelWeight: number;
  44367. protected _useRGBColor: boolean;
  44368. /**
  44369. * Helps to directly use the maps channels instead of their level.
  44370. */
  44371. useRGBColor: boolean;
  44372. protected _enableNoise: boolean;
  44373. /**
  44374. * This helps reducing the banding effect that could occur on the background.
  44375. */
  44376. enableNoise: boolean;
  44377. /**
  44378. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44379. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44380. * Recommended to be keep at 1.0 except for special cases.
  44381. */
  44382. fovMultiplier: number;
  44383. private _fovMultiplier;
  44384. /**
  44385. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44386. */
  44387. useEquirectangularFOV: boolean;
  44388. private _maxSimultaneousLights;
  44389. /**
  44390. * Number of Simultaneous lights allowed on the material.
  44391. */
  44392. maxSimultaneousLights: int;
  44393. /**
  44394. * Default configuration related to image processing available in the Background Material.
  44395. */
  44396. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44397. /**
  44398. * Keep track of the image processing observer to allow dispose and replace.
  44399. */
  44400. private _imageProcessingObserver;
  44401. /**
  44402. * Attaches a new image processing configuration to the PBR Material.
  44403. * @param configuration (if null the scene configuration will be use)
  44404. */
  44405. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44406. /**
  44407. * Gets the image processing configuration used either in this material.
  44408. */
  44409. /**
  44410. * Sets the Default image processing configuration used either in the this material.
  44411. *
  44412. * If sets to null, the scene one is in use.
  44413. */
  44414. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44415. /**
  44416. * Gets wether the color curves effect is enabled.
  44417. */
  44418. /**
  44419. * Sets wether the color curves effect is enabled.
  44420. */
  44421. cameraColorCurvesEnabled: boolean;
  44422. /**
  44423. * Gets wether the color grading effect is enabled.
  44424. */
  44425. /**
  44426. * Gets wether the color grading effect is enabled.
  44427. */
  44428. cameraColorGradingEnabled: boolean;
  44429. /**
  44430. * Gets wether tonemapping is enabled or not.
  44431. */
  44432. /**
  44433. * Sets wether tonemapping is enabled or not
  44434. */
  44435. cameraToneMappingEnabled: boolean;
  44436. /**
  44437. * The camera exposure used on this material.
  44438. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44439. * This corresponds to a photographic exposure.
  44440. */
  44441. /**
  44442. * The camera exposure used on this material.
  44443. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44444. * This corresponds to a photographic exposure.
  44445. */
  44446. cameraExposure: float;
  44447. /**
  44448. * Gets The camera contrast used on this material.
  44449. */
  44450. /**
  44451. * Sets The camera contrast used on this material.
  44452. */
  44453. cameraContrast: float;
  44454. /**
  44455. * Gets the Color Grading 2D Lookup Texture.
  44456. */
  44457. /**
  44458. * Sets the Color Grading 2D Lookup Texture.
  44459. */
  44460. cameraColorGradingTexture: Nullable<BaseTexture>;
  44461. /**
  44462. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44463. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44464. * 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;
  44465. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44466. */
  44467. /**
  44468. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44469. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44470. * 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;
  44471. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44472. */
  44473. cameraColorCurves: Nullable<ColorCurves>;
  44474. /**
  44475. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44476. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44477. */
  44478. switchToBGR: boolean;
  44479. private _renderTargets;
  44480. private _reflectionControls;
  44481. private _white;
  44482. private _primaryShadowColor;
  44483. private _primaryHighlightColor;
  44484. /**
  44485. * Instantiates a Background Material in the given scene
  44486. * @param name The friendly name of the material
  44487. * @param scene The scene to add the material to
  44488. */
  44489. constructor(name: string, scene: Scene);
  44490. /**
  44491. * Gets a boolean indicating that current material needs to register RTT
  44492. */
  44493. readonly hasRenderTargetTextures: boolean;
  44494. /**
  44495. * The entire material has been created in order to prevent overdraw.
  44496. * @returns false
  44497. */
  44498. needAlphaTesting(): boolean;
  44499. /**
  44500. * The entire material has been created in order to prevent overdraw.
  44501. * @returns true if blending is enable
  44502. */
  44503. needAlphaBlending(): boolean;
  44504. /**
  44505. * Checks wether the material is ready to be rendered for a given mesh.
  44506. * @param mesh The mesh to render
  44507. * @param subMesh The submesh to check against
  44508. * @param useInstances Specify wether or not the material is used with instances
  44509. * @returns true if all the dependencies are ready (Textures, Effects...)
  44510. */
  44511. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44512. /**
  44513. * Compute the primary color according to the chosen perceptual color.
  44514. */
  44515. private _computePrimaryColorFromPerceptualColor;
  44516. /**
  44517. * Compute the highlights and shadow colors according to their chosen levels.
  44518. */
  44519. private _computePrimaryColors;
  44520. /**
  44521. * Build the uniform buffer used in the material.
  44522. */
  44523. buildUniformLayout(): void;
  44524. /**
  44525. * Unbind the material.
  44526. */
  44527. unbind(): void;
  44528. /**
  44529. * Bind only the world matrix to the material.
  44530. * @param world The world matrix to bind.
  44531. */
  44532. bindOnlyWorldMatrix(world: Matrix): void;
  44533. /**
  44534. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44535. * @param world The world matrix to bind.
  44536. * @param subMesh The submesh to bind for.
  44537. */
  44538. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44539. /**
  44540. * Dispose the material.
  44541. * @param forceDisposeEffect Force disposal of the associated effect.
  44542. * @param forceDisposeTextures Force disposal of the associated textures.
  44543. */
  44544. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44545. /**
  44546. * Clones the material.
  44547. * @param name The cloned name.
  44548. * @returns The cloned material.
  44549. */
  44550. clone(name: string): BackgroundMaterial;
  44551. /**
  44552. * Serializes the current material to its JSON representation.
  44553. * @returns The JSON representation.
  44554. */
  44555. serialize(): any;
  44556. /**
  44557. * Gets the class name of the material
  44558. * @returns "BackgroundMaterial"
  44559. */
  44560. getClassName(): string;
  44561. /**
  44562. * Parse a JSON input to create back a background material.
  44563. * @param source The JSON data to parse
  44564. * @param scene The scene to create the parsed material in
  44565. * @param rootUrl The root url of the assets the material depends upon
  44566. * @returns the instantiated BackgroundMaterial.
  44567. */
  44568. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44569. }
  44570. }
  44571. declare module BABYLON {
  44572. /**
  44573. * Represents the different options available during the creation of
  44574. * a Environment helper.
  44575. *
  44576. * This can control the default ground, skybox and image processing setup of your scene.
  44577. */
  44578. export interface IEnvironmentHelperOptions {
  44579. /**
  44580. * Specifies wether or not to create a ground.
  44581. * True by default.
  44582. */
  44583. createGround: boolean;
  44584. /**
  44585. * Specifies the ground size.
  44586. * 15 by default.
  44587. */
  44588. groundSize: number;
  44589. /**
  44590. * The texture used on the ground for the main color.
  44591. * Comes from the BabylonJS CDN by default.
  44592. *
  44593. * Remarks: Can be either a texture or a url.
  44594. */
  44595. groundTexture: string | BaseTexture;
  44596. /**
  44597. * The color mixed in the ground texture by default.
  44598. * BabylonJS clearColor by default.
  44599. */
  44600. groundColor: Color3;
  44601. /**
  44602. * Specifies the ground opacity.
  44603. * 1 by default.
  44604. */
  44605. groundOpacity: number;
  44606. /**
  44607. * Enables the ground to receive shadows.
  44608. * True by default.
  44609. */
  44610. enableGroundShadow: boolean;
  44611. /**
  44612. * Helps preventing the shadow to be fully black on the ground.
  44613. * 0.5 by default.
  44614. */
  44615. groundShadowLevel: number;
  44616. /**
  44617. * Creates a mirror texture attach to the ground.
  44618. * false by default.
  44619. */
  44620. enableGroundMirror: boolean;
  44621. /**
  44622. * Specifies the ground mirror size ratio.
  44623. * 0.3 by default as the default kernel is 64.
  44624. */
  44625. groundMirrorSizeRatio: number;
  44626. /**
  44627. * Specifies the ground mirror blur kernel size.
  44628. * 64 by default.
  44629. */
  44630. groundMirrorBlurKernel: number;
  44631. /**
  44632. * Specifies the ground mirror visibility amount.
  44633. * 1 by default
  44634. */
  44635. groundMirrorAmount: number;
  44636. /**
  44637. * Specifies the ground mirror reflectance weight.
  44638. * This uses the standard weight of the background material to setup the fresnel effect
  44639. * of the mirror.
  44640. * 1 by default.
  44641. */
  44642. groundMirrorFresnelWeight: number;
  44643. /**
  44644. * Specifies the ground mirror Falloff distance.
  44645. * This can helps reducing the size of the reflection.
  44646. * 0 by Default.
  44647. */
  44648. groundMirrorFallOffDistance: number;
  44649. /**
  44650. * Specifies the ground mirror texture type.
  44651. * Unsigned Int by Default.
  44652. */
  44653. groundMirrorTextureType: number;
  44654. /**
  44655. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44656. * the shown objects.
  44657. */
  44658. groundYBias: number;
  44659. /**
  44660. * Specifies wether or not to create a skybox.
  44661. * True by default.
  44662. */
  44663. createSkybox: boolean;
  44664. /**
  44665. * Specifies the skybox size.
  44666. * 20 by default.
  44667. */
  44668. skyboxSize: number;
  44669. /**
  44670. * The texture used on the skybox for the main color.
  44671. * Comes from the BabylonJS CDN by default.
  44672. *
  44673. * Remarks: Can be either a texture or a url.
  44674. */
  44675. skyboxTexture: string | BaseTexture;
  44676. /**
  44677. * The color mixed in the skybox texture by default.
  44678. * BabylonJS clearColor by default.
  44679. */
  44680. skyboxColor: Color3;
  44681. /**
  44682. * The background rotation around the Y axis of the scene.
  44683. * This helps aligning the key lights of your scene with the background.
  44684. * 0 by default.
  44685. */
  44686. backgroundYRotation: number;
  44687. /**
  44688. * Compute automatically the size of the elements to best fit with the scene.
  44689. */
  44690. sizeAuto: boolean;
  44691. /**
  44692. * Default position of the rootMesh if autoSize is not true.
  44693. */
  44694. rootPosition: Vector3;
  44695. /**
  44696. * Sets up the image processing in the scene.
  44697. * true by default.
  44698. */
  44699. setupImageProcessing: boolean;
  44700. /**
  44701. * The texture used as your environment texture in the scene.
  44702. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44703. *
  44704. * Remarks: Can be either a texture or a url.
  44705. */
  44706. environmentTexture: string | BaseTexture;
  44707. /**
  44708. * The value of the exposure to apply to the scene.
  44709. * 0.6 by default if setupImageProcessing is true.
  44710. */
  44711. cameraExposure: number;
  44712. /**
  44713. * The value of the contrast to apply to the scene.
  44714. * 1.6 by default if setupImageProcessing is true.
  44715. */
  44716. cameraContrast: number;
  44717. /**
  44718. * Specifies wether or not tonemapping should be enabled in the scene.
  44719. * true by default if setupImageProcessing is true.
  44720. */
  44721. toneMappingEnabled: boolean;
  44722. }
  44723. /**
  44724. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44725. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44726. * It also helps with the default setup of your imageProcessing configuration.
  44727. */
  44728. export class EnvironmentHelper {
  44729. /**
  44730. * Default ground texture URL.
  44731. */
  44732. private static _groundTextureCDNUrl;
  44733. /**
  44734. * Default skybox texture URL.
  44735. */
  44736. private static _skyboxTextureCDNUrl;
  44737. /**
  44738. * Default environment texture URL.
  44739. */
  44740. private static _environmentTextureCDNUrl;
  44741. /**
  44742. * Creates the default options for the helper.
  44743. */
  44744. private static _getDefaultOptions;
  44745. private _rootMesh;
  44746. /**
  44747. * Gets the root mesh created by the helper.
  44748. */
  44749. readonly rootMesh: Mesh;
  44750. private _skybox;
  44751. /**
  44752. * Gets the skybox created by the helper.
  44753. */
  44754. readonly skybox: Nullable<Mesh>;
  44755. private _skyboxTexture;
  44756. /**
  44757. * Gets the skybox texture created by the helper.
  44758. */
  44759. readonly skyboxTexture: Nullable<BaseTexture>;
  44760. private _skyboxMaterial;
  44761. /**
  44762. * Gets the skybox material created by the helper.
  44763. */
  44764. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44765. private _ground;
  44766. /**
  44767. * Gets the ground mesh created by the helper.
  44768. */
  44769. readonly ground: Nullable<Mesh>;
  44770. private _groundTexture;
  44771. /**
  44772. * Gets the ground texture created by the helper.
  44773. */
  44774. readonly groundTexture: Nullable<BaseTexture>;
  44775. private _groundMirror;
  44776. /**
  44777. * Gets the ground mirror created by the helper.
  44778. */
  44779. readonly groundMirror: Nullable<MirrorTexture>;
  44780. /**
  44781. * Gets the ground mirror render list to helps pushing the meshes
  44782. * you wish in the ground reflection.
  44783. */
  44784. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44785. private _groundMaterial;
  44786. /**
  44787. * Gets the ground material created by the helper.
  44788. */
  44789. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44790. /**
  44791. * Stores the creation options.
  44792. */
  44793. private readonly _scene;
  44794. private _options;
  44795. /**
  44796. * This observable will be notified with any error during the creation of the environment,
  44797. * mainly texture creation errors.
  44798. */
  44799. onErrorObservable: Observable<{
  44800. message?: string;
  44801. exception?: any;
  44802. }>;
  44803. /**
  44804. * constructor
  44805. * @param options Defines the options we want to customize the helper
  44806. * @param scene The scene to add the material to
  44807. */
  44808. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44809. /**
  44810. * Updates the background according to the new options
  44811. * @param options
  44812. */
  44813. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44814. /**
  44815. * Sets the primary color of all the available elements.
  44816. * @param color the main color to affect to the ground and the background
  44817. */
  44818. setMainColor(color: Color3): void;
  44819. /**
  44820. * Setup the image processing according to the specified options.
  44821. */
  44822. private _setupImageProcessing;
  44823. /**
  44824. * Setup the environment texture according to the specified options.
  44825. */
  44826. private _setupEnvironmentTexture;
  44827. /**
  44828. * Setup the background according to the specified options.
  44829. */
  44830. private _setupBackground;
  44831. /**
  44832. * Get the scene sizes according to the setup.
  44833. */
  44834. private _getSceneSize;
  44835. /**
  44836. * Setup the ground according to the specified options.
  44837. */
  44838. private _setupGround;
  44839. /**
  44840. * Setup the ground material according to the specified options.
  44841. */
  44842. private _setupGroundMaterial;
  44843. /**
  44844. * Setup the ground diffuse texture according to the specified options.
  44845. */
  44846. private _setupGroundDiffuseTexture;
  44847. /**
  44848. * Setup the ground mirror texture according to the specified options.
  44849. */
  44850. private _setupGroundMirrorTexture;
  44851. /**
  44852. * Setup the ground to receive the mirror texture.
  44853. */
  44854. private _setupMirrorInGroundMaterial;
  44855. /**
  44856. * Setup the skybox according to the specified options.
  44857. */
  44858. private _setupSkybox;
  44859. /**
  44860. * Setup the skybox material according to the specified options.
  44861. */
  44862. private _setupSkyboxMaterial;
  44863. /**
  44864. * Setup the skybox reflection texture according to the specified options.
  44865. */
  44866. private _setupSkyboxReflectionTexture;
  44867. private _errorHandler;
  44868. /**
  44869. * Dispose all the elements created by the Helper.
  44870. */
  44871. dispose(): void;
  44872. }
  44873. }
  44874. declare module BABYLON {
  44875. /**
  44876. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44877. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44878. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44879. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44880. */
  44881. export class PhotoDome extends TransformNode {
  44882. /**
  44883. * Define the image as a Monoscopic panoramic 360 image.
  44884. */
  44885. static readonly MODE_MONOSCOPIC: number;
  44886. /**
  44887. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44888. */
  44889. static readonly MODE_TOPBOTTOM: number;
  44890. /**
  44891. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44892. */
  44893. static readonly MODE_SIDEBYSIDE: number;
  44894. private _useDirectMapping;
  44895. /**
  44896. * The texture being displayed on the sphere
  44897. */
  44898. protected _photoTexture: Texture;
  44899. /**
  44900. * Gets or sets the texture being displayed on the sphere
  44901. */
  44902. photoTexture: Texture;
  44903. /**
  44904. * Observable raised when an error occured while loading the 360 image
  44905. */
  44906. onLoadErrorObservable: Observable<string>;
  44907. /**
  44908. * The skybox material
  44909. */
  44910. protected _material: BackgroundMaterial;
  44911. /**
  44912. * The surface used for the skybox
  44913. */
  44914. protected _mesh: Mesh;
  44915. /**
  44916. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44917. * Also see the options.resolution property.
  44918. */
  44919. fovMultiplier: number;
  44920. private _imageMode;
  44921. /**
  44922. * Gets or set the current video mode for the video. It can be:
  44923. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44924. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44925. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44926. */
  44927. imageMode: number;
  44928. /**
  44929. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44930. * @param name Element's name, child elements will append suffixes for their own names.
  44931. * @param urlsOfPhoto defines the url of the photo to display
  44932. * @param options defines an object containing optional or exposed sub element properties
  44933. * @param onError defines a callback called when an error occured while loading the texture
  44934. */
  44935. constructor(name: string, urlOfPhoto: string, options: {
  44936. resolution?: number;
  44937. size?: number;
  44938. useDirectMapping?: boolean;
  44939. faceForward?: boolean;
  44940. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44941. private _onBeforeCameraRenderObserver;
  44942. private _changeImageMode;
  44943. /**
  44944. * Releases resources associated with this node.
  44945. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44946. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44947. */
  44948. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44949. }
  44950. }
  44951. declare module BABYLON {
  44952. /** @hidden */
  44953. export var rgbdDecodePixelShader: {
  44954. name: string;
  44955. shader: string;
  44956. };
  44957. }
  44958. declare module BABYLON {
  44959. /**
  44960. * Class used to host texture specific utilities
  44961. */
  44962. export class BRDFTextureTools {
  44963. /**
  44964. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44965. * @param texture the texture to expand.
  44966. */
  44967. private static _ExpandDefaultBRDFTexture;
  44968. /**
  44969. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44970. * @param scene defines the hosting scene
  44971. * @returns the environment BRDF texture
  44972. */
  44973. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44974. private static _environmentBRDFBase64Texture;
  44975. }
  44976. }
  44977. declare module BABYLON {
  44978. /**
  44979. * @hidden
  44980. */
  44981. export interface IMaterialClearCoatDefines {
  44982. CLEARCOAT: boolean;
  44983. CLEARCOAT_DEFAULTIOR: boolean;
  44984. CLEARCOAT_TEXTURE: boolean;
  44985. CLEARCOAT_TEXTUREDIRECTUV: number;
  44986. CLEARCOAT_BUMP: boolean;
  44987. CLEARCOAT_BUMPDIRECTUV: number;
  44988. CLEARCOAT_TINT: boolean;
  44989. CLEARCOAT_TINT_TEXTURE: boolean;
  44990. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44991. /** @hidden */
  44992. _areTexturesDirty: boolean;
  44993. }
  44994. /**
  44995. * Define the code related to the clear coat parameters of the pbr material.
  44996. */
  44997. export class PBRClearCoatConfiguration {
  44998. /**
  44999. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45000. * The default fits with a polyurethane material.
  45001. */
  45002. private static readonly _DefaultIndexOfRefraction;
  45003. private _isEnabled;
  45004. /**
  45005. * Defines if the clear coat is enabled in the material.
  45006. */
  45007. isEnabled: boolean;
  45008. /**
  45009. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45010. */
  45011. intensity: number;
  45012. /**
  45013. * Defines the clear coat layer roughness.
  45014. */
  45015. roughness: number;
  45016. private _indexOfRefraction;
  45017. /**
  45018. * Defines the index of refraction of the clear coat.
  45019. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45020. * The default fits with a polyurethane material.
  45021. * Changing the default value is more performance intensive.
  45022. */
  45023. indexOfRefraction: number;
  45024. private _texture;
  45025. /**
  45026. * Stores the clear coat values in a texture.
  45027. */
  45028. texture: Nullable<BaseTexture>;
  45029. private _bumpTexture;
  45030. /**
  45031. * Define the clear coat specific bump texture.
  45032. */
  45033. bumpTexture: Nullable<BaseTexture>;
  45034. private _isTintEnabled;
  45035. /**
  45036. * Defines if the clear coat tint is enabled in the material.
  45037. */
  45038. isTintEnabled: boolean;
  45039. /**
  45040. * Defines the clear coat tint of the material.
  45041. * This is only use if tint is enabled
  45042. */
  45043. tintColor: Color3;
  45044. /**
  45045. * Defines the distance at which the tint color should be found in the
  45046. * clear coat media.
  45047. * This is only use if tint is enabled
  45048. */
  45049. tintColorAtDistance: number;
  45050. /**
  45051. * Defines the clear coat layer thickness.
  45052. * This is only use if tint is enabled
  45053. */
  45054. tintThickness: number;
  45055. private _tintTexture;
  45056. /**
  45057. * Stores the clear tint values in a texture.
  45058. * rgb is tint
  45059. * a is a thickness factor
  45060. */
  45061. tintTexture: Nullable<BaseTexture>;
  45062. /** @hidden */
  45063. private _internalMarkAllSubMeshesAsTexturesDirty;
  45064. /** @hidden */
  45065. _markAllSubMeshesAsTexturesDirty(): void;
  45066. /**
  45067. * Instantiate a new istance of clear coat configuration.
  45068. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45069. */
  45070. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45071. /**
  45072. * Gets wehter the submesh is ready to be used or not.
  45073. * @param defines the list of "defines" to update.
  45074. * @param scene defines the scene the material belongs to.
  45075. * @param engine defines the engine the material belongs to.
  45076. * @param disableBumpMap defines wether the material disables bump or not.
  45077. * @returns - boolean indicating that the submesh is ready or not.
  45078. */
  45079. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45080. /**
  45081. * Checks to see if a texture is used in the material.
  45082. * @param defines the list of "defines" to update.
  45083. * @param scene defines the scene to the material belongs to.
  45084. */
  45085. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45086. /**
  45087. * Binds the material data.
  45088. * @param uniformBuffer defines the Uniform buffer to fill in.
  45089. * @param scene defines the scene the material belongs to.
  45090. * @param engine defines the engine the material belongs to.
  45091. * @param disableBumpMap defines wether the material disables bump or not.
  45092. * @param isFrozen defines wether the material is frozen or not.
  45093. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45094. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45095. */
  45096. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45097. /**
  45098. * Checks to see if a texture is used in the material.
  45099. * @param texture - Base texture to use.
  45100. * @returns - Boolean specifying if a texture is used in the material.
  45101. */
  45102. hasTexture(texture: BaseTexture): boolean;
  45103. /**
  45104. * Returns an array of the actively used textures.
  45105. * @param activeTextures Array of BaseTextures
  45106. */
  45107. getActiveTextures(activeTextures: BaseTexture[]): void;
  45108. /**
  45109. * Returns the animatable textures.
  45110. * @param animatables Array of animatable textures.
  45111. */
  45112. getAnimatables(animatables: IAnimatable[]): void;
  45113. /**
  45114. * Disposes the resources of the material.
  45115. * @param forceDisposeTextures - Forces the disposal of all textures.
  45116. */
  45117. dispose(forceDisposeTextures?: boolean): void;
  45118. /**
  45119. * Get the current class name of the texture useful for serialization or dynamic coding.
  45120. * @returns "PBRClearCoatConfiguration"
  45121. */
  45122. getClassName(): string;
  45123. /**
  45124. * Add fallbacks to the effect fallbacks list.
  45125. * @param defines defines the Base texture to use.
  45126. * @param fallbacks defines the current fallback list.
  45127. * @param currentRank defines the current fallback rank.
  45128. * @returns the new fallback rank.
  45129. */
  45130. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45131. /**
  45132. * Add the required uniforms to the current list.
  45133. * @param uniforms defines the current uniform list.
  45134. */
  45135. static AddUniforms(uniforms: string[]): void;
  45136. /**
  45137. * Add the required samplers to the current list.
  45138. * @param samplers defines the current sampler list.
  45139. */
  45140. static AddSamplers(samplers: string[]): void;
  45141. /**
  45142. * Add the required uniforms to the current buffer.
  45143. * @param uniformBuffer defines the current uniform buffer.
  45144. */
  45145. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45146. /**
  45147. * Makes a duplicate of the current configuration into another one.
  45148. * @param clearCoatConfiguration define the config where to copy the info
  45149. */
  45150. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45151. /**
  45152. * Serializes this clear coat configuration.
  45153. * @returns - An object with the serialized config.
  45154. */
  45155. serialize(): any;
  45156. /**
  45157. * Parses a anisotropy Configuration from a serialized object.
  45158. * @param source - Serialized object.
  45159. * @param scene Defines the scene we are parsing for
  45160. * @param rootUrl Defines the rootUrl to load from
  45161. */
  45162. parse(source: any, scene: Scene, rootUrl: string): void;
  45163. }
  45164. }
  45165. declare module BABYLON {
  45166. /**
  45167. * @hidden
  45168. */
  45169. export interface IMaterialAnisotropicDefines {
  45170. ANISOTROPIC: boolean;
  45171. ANISOTROPIC_TEXTURE: boolean;
  45172. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45173. MAINUV1: boolean;
  45174. _areTexturesDirty: boolean;
  45175. _needUVs: boolean;
  45176. }
  45177. /**
  45178. * Define the code related to the anisotropic parameters of the pbr material.
  45179. */
  45180. export class PBRAnisotropicConfiguration {
  45181. private _isEnabled;
  45182. /**
  45183. * Defines if the anisotropy is enabled in the material.
  45184. */
  45185. isEnabled: boolean;
  45186. /**
  45187. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45188. */
  45189. intensity: number;
  45190. /**
  45191. * Defines if the effect is along the tangents, bitangents or in between.
  45192. * By default, the effect is "strectching" the highlights along the tangents.
  45193. */
  45194. direction: Vector2;
  45195. private _texture;
  45196. /**
  45197. * Stores the anisotropy values in a texture.
  45198. * rg is direction (like normal from -1 to 1)
  45199. * b is a intensity
  45200. */
  45201. texture: Nullable<BaseTexture>;
  45202. /** @hidden */
  45203. private _internalMarkAllSubMeshesAsTexturesDirty;
  45204. /** @hidden */
  45205. _markAllSubMeshesAsTexturesDirty(): void;
  45206. /**
  45207. * Instantiate a new istance of anisotropy configuration.
  45208. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45209. */
  45210. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45211. /**
  45212. * Specifies that the submesh is ready to be used.
  45213. * @param defines the list of "defines" to update.
  45214. * @param scene defines the scene the material belongs to.
  45215. * @returns - boolean indicating that the submesh is ready or not.
  45216. */
  45217. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45218. /**
  45219. * Checks to see if a texture is used in the material.
  45220. * @param defines the list of "defines" to update.
  45221. * @param mesh the mesh we are preparing the defines for.
  45222. * @param scene defines the scene the material belongs to.
  45223. */
  45224. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45225. /**
  45226. * Binds the material data.
  45227. * @param uniformBuffer defines the Uniform buffer to fill in.
  45228. * @param scene defines the scene the material belongs to.
  45229. * @param isFrozen defines wether the material is frozen or not.
  45230. */
  45231. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45232. /**
  45233. * Checks to see if a texture is used in the material.
  45234. * @param texture - Base texture to use.
  45235. * @returns - Boolean specifying if a texture is used in the material.
  45236. */
  45237. hasTexture(texture: BaseTexture): boolean;
  45238. /**
  45239. * Returns an array of the actively used textures.
  45240. * @param activeTextures Array of BaseTextures
  45241. */
  45242. getActiveTextures(activeTextures: BaseTexture[]): void;
  45243. /**
  45244. * Returns the animatable textures.
  45245. * @param animatables Array of animatable textures.
  45246. */
  45247. getAnimatables(animatables: IAnimatable[]): void;
  45248. /**
  45249. * Disposes the resources of the material.
  45250. * @param forceDisposeTextures - Forces the disposal of all textures.
  45251. */
  45252. dispose(forceDisposeTextures?: boolean): void;
  45253. /**
  45254. * Get the current class name of the texture useful for serialization or dynamic coding.
  45255. * @returns "PBRAnisotropicConfiguration"
  45256. */
  45257. getClassName(): string;
  45258. /**
  45259. * Add fallbacks to the effect fallbacks list.
  45260. * @param defines defines the Base texture to use.
  45261. * @param fallbacks defines the current fallback list.
  45262. * @param currentRank defines the current fallback rank.
  45263. * @returns the new fallback rank.
  45264. */
  45265. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45266. /**
  45267. * Add the required uniforms to the current list.
  45268. * @param uniforms defines the current uniform list.
  45269. */
  45270. static AddUniforms(uniforms: string[]): void;
  45271. /**
  45272. * Add the required uniforms to the current buffer.
  45273. * @param uniformBuffer defines the current uniform buffer.
  45274. */
  45275. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45276. /**
  45277. * Add the required samplers to the current list.
  45278. * @param samplers defines the current sampler list.
  45279. */
  45280. static AddSamplers(samplers: string[]): void;
  45281. /**
  45282. * Makes a duplicate of the current configuration into another one.
  45283. * @param anisotropicConfiguration define the config where to copy the info
  45284. */
  45285. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45286. /**
  45287. * Serializes this anisotropy configuration.
  45288. * @returns - An object with the serialized config.
  45289. */
  45290. serialize(): any;
  45291. /**
  45292. * Parses a anisotropy Configuration from a serialized object.
  45293. * @param source - Serialized object.
  45294. * @param scene Defines the scene we are parsing for
  45295. * @param rootUrl Defines the rootUrl to load from
  45296. */
  45297. parse(source: any, scene: Scene, rootUrl: string): void;
  45298. }
  45299. }
  45300. declare module BABYLON {
  45301. /**
  45302. * @hidden
  45303. */
  45304. export interface IMaterialBRDFDefines {
  45305. BRDF_V_HEIGHT_CORRELATED: boolean;
  45306. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45307. SPHERICAL_HARMONICS: boolean;
  45308. /** @hidden */
  45309. _areMiscDirty: boolean;
  45310. }
  45311. /**
  45312. * Define the code related to the BRDF parameters of the pbr material.
  45313. */
  45314. export class PBRBRDFConfiguration {
  45315. /**
  45316. * Default value used for the energy conservation.
  45317. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45318. */
  45319. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45320. /**
  45321. * Default value used for the Smith Visibility Height Correlated mode.
  45322. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45323. */
  45324. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45325. /**
  45326. * Default value used for the IBL diffuse part.
  45327. * This can help switching back to the polynomials mode globally which is a tiny bit
  45328. * less GPU intensive at the drawback of a lower quality.
  45329. */
  45330. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45331. private _useEnergyConservation;
  45332. /**
  45333. * Defines if the material uses energy conservation.
  45334. */
  45335. useEnergyConservation: boolean;
  45336. private _useSmithVisibilityHeightCorrelated;
  45337. /**
  45338. * LEGACY Mode set to false
  45339. * Defines if the material uses height smith correlated visibility term.
  45340. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45341. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45342. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45343. * Not relying on height correlated will also disable energy conservation.
  45344. */
  45345. useSmithVisibilityHeightCorrelated: boolean;
  45346. private _useSphericalHarmonics;
  45347. /**
  45348. * LEGACY Mode set to false
  45349. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45350. * diffuse part of the IBL.
  45351. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45352. * to the ground truth.
  45353. */
  45354. useSphericalHarmonics: boolean;
  45355. /** @hidden */
  45356. private _internalMarkAllSubMeshesAsMiscDirty;
  45357. /** @hidden */
  45358. _markAllSubMeshesAsMiscDirty(): void;
  45359. /**
  45360. * Instantiate a new istance of clear coat configuration.
  45361. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45362. */
  45363. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45364. /**
  45365. * Checks to see if a texture is used in the material.
  45366. * @param defines the list of "defines" to update.
  45367. */
  45368. prepareDefines(defines: IMaterialBRDFDefines): void;
  45369. /**
  45370. * Get the current class name of the texture useful for serialization or dynamic coding.
  45371. * @returns "PBRClearCoatConfiguration"
  45372. */
  45373. getClassName(): string;
  45374. /**
  45375. * Makes a duplicate of the current configuration into another one.
  45376. * @param brdfConfiguration define the config where to copy the info
  45377. */
  45378. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45379. /**
  45380. * Serializes this BRDF configuration.
  45381. * @returns - An object with the serialized config.
  45382. */
  45383. serialize(): any;
  45384. /**
  45385. * Parses a anisotropy Configuration from a serialized object.
  45386. * @param source - Serialized object.
  45387. * @param scene Defines the scene we are parsing for
  45388. * @param rootUrl Defines the rootUrl to load from
  45389. */
  45390. parse(source: any, scene: Scene, rootUrl: string): void;
  45391. }
  45392. }
  45393. declare module BABYLON {
  45394. /**
  45395. * @hidden
  45396. */
  45397. export interface IMaterialSheenDefines {
  45398. SHEEN: boolean;
  45399. SHEEN_TEXTURE: boolean;
  45400. SHEEN_TEXTUREDIRECTUV: number;
  45401. SHEEN_LINKWITHALBEDO: boolean;
  45402. /** @hidden */
  45403. _areTexturesDirty: boolean;
  45404. }
  45405. /**
  45406. * Define the code related to the Sheen parameters of the pbr material.
  45407. */
  45408. export class PBRSheenConfiguration {
  45409. private _isEnabled;
  45410. /**
  45411. * Defines if the material uses sheen.
  45412. */
  45413. isEnabled: boolean;
  45414. private _linkSheenWithAlbedo;
  45415. /**
  45416. * Defines if the sheen is linked to the sheen color.
  45417. */
  45418. linkSheenWithAlbedo: boolean;
  45419. /**
  45420. * Defines the sheen intensity.
  45421. */
  45422. intensity: number;
  45423. /**
  45424. * Defines the sheen color.
  45425. */
  45426. color: Color3;
  45427. private _texture;
  45428. /**
  45429. * Stores the sheen tint values in a texture.
  45430. * rgb is tint
  45431. * a is a intensity
  45432. */
  45433. texture: Nullable<BaseTexture>;
  45434. /** @hidden */
  45435. private _internalMarkAllSubMeshesAsTexturesDirty;
  45436. /** @hidden */
  45437. _markAllSubMeshesAsTexturesDirty(): void;
  45438. /**
  45439. * Instantiate a new istance of clear coat configuration.
  45440. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45441. */
  45442. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45443. /**
  45444. * Specifies that the submesh is ready to be used.
  45445. * @param defines the list of "defines" to update.
  45446. * @param scene defines the scene the material belongs to.
  45447. * @returns - boolean indicating that the submesh is ready or not.
  45448. */
  45449. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45450. /**
  45451. * Checks to see if a texture is used in the material.
  45452. * @param defines the list of "defines" to update.
  45453. * @param scene defines the scene the material belongs to.
  45454. */
  45455. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45456. /**
  45457. * Binds the material data.
  45458. * @param uniformBuffer defines the Uniform buffer to fill in.
  45459. * @param scene defines the scene the material belongs to.
  45460. * @param isFrozen defines wether the material is frozen or not.
  45461. */
  45462. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45463. /**
  45464. * Checks to see if a texture is used in the material.
  45465. * @param texture - Base texture to use.
  45466. * @returns - Boolean specifying if a texture is used in the material.
  45467. */
  45468. hasTexture(texture: BaseTexture): boolean;
  45469. /**
  45470. * Returns an array of the actively used textures.
  45471. * @param activeTextures Array of BaseTextures
  45472. */
  45473. getActiveTextures(activeTextures: BaseTexture[]): void;
  45474. /**
  45475. * Returns the animatable textures.
  45476. * @param animatables Array of animatable textures.
  45477. */
  45478. getAnimatables(animatables: IAnimatable[]): void;
  45479. /**
  45480. * Disposes the resources of the material.
  45481. * @param forceDisposeTextures - Forces the disposal of all textures.
  45482. */
  45483. dispose(forceDisposeTextures?: boolean): void;
  45484. /**
  45485. * Get the current class name of the texture useful for serialization or dynamic coding.
  45486. * @returns "PBRSheenConfiguration"
  45487. */
  45488. getClassName(): string;
  45489. /**
  45490. * Add fallbacks to the effect fallbacks list.
  45491. * @param defines defines the Base texture to use.
  45492. * @param fallbacks defines the current fallback list.
  45493. * @param currentRank defines the current fallback rank.
  45494. * @returns the new fallback rank.
  45495. */
  45496. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45497. /**
  45498. * Add the required uniforms to the current list.
  45499. * @param uniforms defines the current uniform list.
  45500. */
  45501. static AddUniforms(uniforms: string[]): void;
  45502. /**
  45503. * Add the required uniforms to the current buffer.
  45504. * @param uniformBuffer defines the current uniform buffer.
  45505. */
  45506. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45507. /**
  45508. * Add the required samplers to the current list.
  45509. * @param samplers defines the current sampler list.
  45510. */
  45511. static AddSamplers(samplers: string[]): void;
  45512. /**
  45513. * Makes a duplicate of the current configuration into another one.
  45514. * @param sheenConfiguration define the config where to copy the info
  45515. */
  45516. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45517. /**
  45518. * Serializes this BRDF configuration.
  45519. * @returns - An object with the serialized config.
  45520. */
  45521. serialize(): any;
  45522. /**
  45523. * Parses a anisotropy Configuration from a serialized object.
  45524. * @param source - Serialized object.
  45525. * @param scene Defines the scene we are parsing for
  45526. * @param rootUrl Defines the rootUrl to load from
  45527. */
  45528. parse(source: any, scene: Scene, rootUrl: string): void;
  45529. }
  45530. }
  45531. declare module BABYLON {
  45532. /**
  45533. * @hidden
  45534. */
  45535. export interface IMaterialSubSurfaceDefines {
  45536. SUBSURFACE: boolean;
  45537. SS_REFRACTION: boolean;
  45538. SS_TRANSLUCENCY: boolean;
  45539. SS_SCATERRING: boolean;
  45540. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45541. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45542. SS_REFRACTIONMAP_3D: boolean;
  45543. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45544. SS_LODINREFRACTIONALPHA: boolean;
  45545. SS_GAMMAREFRACTION: boolean;
  45546. SS_RGBDREFRACTION: boolean;
  45547. SS_LINEARSPECULARREFRACTION: boolean;
  45548. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45549. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45550. /** @hidden */
  45551. _areTexturesDirty: boolean;
  45552. }
  45553. /**
  45554. * Define the code related to the sub surface parameters of the pbr material.
  45555. */
  45556. export class PBRSubSurfaceConfiguration {
  45557. private _isRefractionEnabled;
  45558. /**
  45559. * Defines if the refraction is enabled in the material.
  45560. */
  45561. isRefractionEnabled: boolean;
  45562. private _isTranslucencyEnabled;
  45563. /**
  45564. * Defines if the translucency is enabled in the material.
  45565. */
  45566. isTranslucencyEnabled: boolean;
  45567. private _isScatteringEnabled;
  45568. /**
  45569. * Defines the refraction intensity of the material.
  45570. * The refraction when enabled replaces the Diffuse part of the material.
  45571. * The intensity helps transitionning between diffuse and refraction.
  45572. */
  45573. refractionIntensity: number;
  45574. /**
  45575. * Defines the translucency intensity of the material.
  45576. * When translucency has been enabled, this defines how much of the "translucency"
  45577. * is addded to the diffuse part of the material.
  45578. */
  45579. translucencyIntensity: number;
  45580. /**
  45581. * Defines the scattering intensity of the material.
  45582. * When scattering has been enabled, this defines how much of the "scattered light"
  45583. * is addded to the diffuse part of the material.
  45584. */
  45585. scatteringIntensity: number;
  45586. private _thicknessTexture;
  45587. /**
  45588. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45589. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45590. * 0 would mean minimumThickness
  45591. * 1 would mean maximumThickness
  45592. * The other channels might be use as a mask to vary the different effects intensity.
  45593. */
  45594. thicknessTexture: Nullable<BaseTexture>;
  45595. private _refractionTexture;
  45596. /**
  45597. * Defines the texture to use for refraction.
  45598. */
  45599. refractionTexture: Nullable<BaseTexture>;
  45600. private _indexOfRefraction;
  45601. /**
  45602. * Defines the index of refraction used in the material.
  45603. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45604. */
  45605. indexOfRefraction: number;
  45606. private _invertRefractionY;
  45607. /**
  45608. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45609. */
  45610. invertRefractionY: boolean;
  45611. private _linkRefractionWithTransparency;
  45612. /**
  45613. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45614. * Materials half opaque for instance using refraction could benefit from this control.
  45615. */
  45616. linkRefractionWithTransparency: boolean;
  45617. /**
  45618. * Defines the minimum thickness stored in the thickness map.
  45619. * If no thickness map is defined, this value will be used to simulate thickness.
  45620. */
  45621. minimumThickness: number;
  45622. /**
  45623. * Defines the maximum thickness stored in the thickness map.
  45624. */
  45625. maximumThickness: number;
  45626. /**
  45627. * Defines the volume tint of the material.
  45628. * This is used for both translucency and scattering.
  45629. */
  45630. tintColor: Color3;
  45631. /**
  45632. * Defines the distance at which the tint color should be found in the media.
  45633. * This is used for refraction only.
  45634. */
  45635. tintColorAtDistance: number;
  45636. /**
  45637. * Defines how far each channel transmit through the media.
  45638. * It is defined as a color to simplify it selection.
  45639. */
  45640. diffusionDistance: Color3;
  45641. private _useMaskFromThicknessTexture;
  45642. /**
  45643. * Stores the intensity of the different subsurface effects in the thickness texture.
  45644. * * the green channel is the translucency intensity.
  45645. * * the blue channel is the scattering intensity.
  45646. * * the alpha channel is the refraction intensity.
  45647. */
  45648. useMaskFromThicknessTexture: boolean;
  45649. /** @hidden */
  45650. private _internalMarkAllSubMeshesAsTexturesDirty;
  45651. /** @hidden */
  45652. _markAllSubMeshesAsTexturesDirty(): void;
  45653. /**
  45654. * Instantiate a new istance of sub surface configuration.
  45655. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45656. */
  45657. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45658. /**
  45659. * Gets wehter the submesh is ready to be used or not.
  45660. * @param defines the list of "defines" to update.
  45661. * @param scene defines the scene the material belongs to.
  45662. * @returns - boolean indicating that the submesh is ready or not.
  45663. */
  45664. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45665. /**
  45666. * Checks to see if a texture is used in the material.
  45667. * @param defines the list of "defines" to update.
  45668. * @param scene defines the scene to the material belongs to.
  45669. */
  45670. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45671. /**
  45672. * Binds the material data.
  45673. * @param uniformBuffer defines the Uniform buffer to fill in.
  45674. * @param scene defines the scene the material belongs to.
  45675. * @param engine defines the engine the material belongs to.
  45676. * @param isFrozen defines wether the material is frozen or not.
  45677. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45678. */
  45679. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45680. /**
  45681. * Unbinds the material from the mesh.
  45682. * @param activeEffect defines the effect that should be unbound from.
  45683. * @returns true if unbound, otherwise false
  45684. */
  45685. unbind(activeEffect: Effect): boolean;
  45686. /**
  45687. * Returns the texture used for refraction or null if none is used.
  45688. * @param scene defines the scene the material belongs to.
  45689. * @returns - Refraction texture if present. If no refraction texture and refraction
  45690. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45691. */
  45692. private _getRefractionTexture;
  45693. /**
  45694. * Returns true if alpha blending should be disabled.
  45695. */
  45696. readonly disableAlphaBlending: boolean;
  45697. /**
  45698. * Fills the list of render target textures.
  45699. * @param renderTargets the list of render targets to update
  45700. */
  45701. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45702. /**
  45703. * Checks to see if a texture is used in the material.
  45704. * @param texture - Base texture to use.
  45705. * @returns - Boolean specifying if a texture is used in the material.
  45706. */
  45707. hasTexture(texture: BaseTexture): boolean;
  45708. /**
  45709. * Gets a boolean indicating that current material needs to register RTT
  45710. * @returns true if this uses a render target otherwise false.
  45711. */
  45712. hasRenderTargetTextures(): boolean;
  45713. /**
  45714. * Returns an array of the actively used textures.
  45715. * @param activeTextures Array of BaseTextures
  45716. */
  45717. getActiveTextures(activeTextures: BaseTexture[]): void;
  45718. /**
  45719. * Returns the animatable textures.
  45720. * @param animatables Array of animatable textures.
  45721. */
  45722. getAnimatables(animatables: IAnimatable[]): void;
  45723. /**
  45724. * Disposes the resources of the material.
  45725. * @param forceDisposeTextures - Forces the disposal of all textures.
  45726. */
  45727. dispose(forceDisposeTextures?: boolean): void;
  45728. /**
  45729. * Get the current class name of the texture useful for serialization or dynamic coding.
  45730. * @returns "PBRSubSurfaceConfiguration"
  45731. */
  45732. getClassName(): string;
  45733. /**
  45734. * Add fallbacks to the effect fallbacks list.
  45735. * @param defines defines the Base texture to use.
  45736. * @param fallbacks defines the current fallback list.
  45737. * @param currentRank defines the current fallback rank.
  45738. * @returns the new fallback rank.
  45739. */
  45740. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45741. /**
  45742. * Add the required uniforms to the current list.
  45743. * @param uniforms defines the current uniform list.
  45744. */
  45745. static AddUniforms(uniforms: string[]): void;
  45746. /**
  45747. * Add the required samplers to the current list.
  45748. * @param samplers defines the current sampler list.
  45749. */
  45750. static AddSamplers(samplers: string[]): void;
  45751. /**
  45752. * Add the required uniforms to the current buffer.
  45753. * @param uniformBuffer defines the current uniform buffer.
  45754. */
  45755. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45756. /**
  45757. * Makes a duplicate of the current configuration into another one.
  45758. * @param configuration define the config where to copy the info
  45759. */
  45760. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45761. /**
  45762. * Serializes this Sub Surface configuration.
  45763. * @returns - An object with the serialized config.
  45764. */
  45765. serialize(): any;
  45766. /**
  45767. * Parses a anisotropy Configuration from a serialized object.
  45768. * @param source - Serialized object.
  45769. * @param scene Defines the scene we are parsing for
  45770. * @param rootUrl Defines the rootUrl to load from
  45771. */
  45772. parse(source: any, scene: Scene, rootUrl: string): void;
  45773. }
  45774. }
  45775. declare module BABYLON {
  45776. /** @hidden */
  45777. export var pbrFragmentDeclaration: {
  45778. name: string;
  45779. shader: string;
  45780. };
  45781. }
  45782. declare module BABYLON {
  45783. /** @hidden */
  45784. export var pbrUboDeclaration: {
  45785. name: string;
  45786. shader: string;
  45787. };
  45788. }
  45789. declare module BABYLON {
  45790. /** @hidden */
  45791. export var pbrFragmentExtraDeclaration: {
  45792. name: string;
  45793. shader: string;
  45794. };
  45795. }
  45796. declare module BABYLON {
  45797. /** @hidden */
  45798. export var pbrFragmentSamplersDeclaration: {
  45799. name: string;
  45800. shader: string;
  45801. };
  45802. }
  45803. declare module BABYLON {
  45804. /** @hidden */
  45805. export var pbrHelperFunctions: {
  45806. name: string;
  45807. shader: string;
  45808. };
  45809. }
  45810. declare module BABYLON {
  45811. /** @hidden */
  45812. export var harmonicsFunctions: {
  45813. name: string;
  45814. shader: string;
  45815. };
  45816. }
  45817. declare module BABYLON {
  45818. /** @hidden */
  45819. export var pbrDirectLightingSetupFunctions: {
  45820. name: string;
  45821. shader: string;
  45822. };
  45823. }
  45824. declare module BABYLON {
  45825. /** @hidden */
  45826. export var pbrDirectLightingFalloffFunctions: {
  45827. name: string;
  45828. shader: string;
  45829. };
  45830. }
  45831. declare module BABYLON {
  45832. /** @hidden */
  45833. export var pbrBRDFFunctions: {
  45834. name: string;
  45835. shader: string;
  45836. };
  45837. }
  45838. declare module BABYLON {
  45839. /** @hidden */
  45840. export var pbrDirectLightingFunctions: {
  45841. name: string;
  45842. shader: string;
  45843. };
  45844. }
  45845. declare module BABYLON {
  45846. /** @hidden */
  45847. export var pbrIBLFunctions: {
  45848. name: string;
  45849. shader: string;
  45850. };
  45851. }
  45852. declare module BABYLON {
  45853. /** @hidden */
  45854. export var pbrDebug: {
  45855. name: string;
  45856. shader: string;
  45857. };
  45858. }
  45859. declare module BABYLON {
  45860. /** @hidden */
  45861. export var pbrPixelShader: {
  45862. name: string;
  45863. shader: string;
  45864. };
  45865. }
  45866. declare module BABYLON {
  45867. /** @hidden */
  45868. export var pbrVertexDeclaration: {
  45869. name: string;
  45870. shader: string;
  45871. };
  45872. }
  45873. declare module BABYLON {
  45874. /** @hidden */
  45875. export var pbrVertexShader: {
  45876. name: string;
  45877. shader: string;
  45878. };
  45879. }
  45880. declare module BABYLON {
  45881. /**
  45882. * Manages the defines for the PBR Material.
  45883. * @hidden
  45884. */
  45885. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45886. PBR: boolean;
  45887. MAINUV1: boolean;
  45888. MAINUV2: boolean;
  45889. UV1: boolean;
  45890. UV2: boolean;
  45891. ALBEDO: boolean;
  45892. ALBEDODIRECTUV: number;
  45893. VERTEXCOLOR: boolean;
  45894. AMBIENT: boolean;
  45895. AMBIENTDIRECTUV: number;
  45896. AMBIENTINGRAYSCALE: boolean;
  45897. OPACITY: boolean;
  45898. VERTEXALPHA: boolean;
  45899. OPACITYDIRECTUV: number;
  45900. OPACITYRGB: boolean;
  45901. ALPHATEST: boolean;
  45902. DEPTHPREPASS: boolean;
  45903. ALPHABLEND: boolean;
  45904. ALPHAFROMALBEDO: boolean;
  45905. ALPHATESTVALUE: string;
  45906. SPECULAROVERALPHA: boolean;
  45907. RADIANCEOVERALPHA: boolean;
  45908. ALPHAFRESNEL: boolean;
  45909. LINEARALPHAFRESNEL: boolean;
  45910. PREMULTIPLYALPHA: boolean;
  45911. EMISSIVE: boolean;
  45912. EMISSIVEDIRECTUV: number;
  45913. REFLECTIVITY: boolean;
  45914. REFLECTIVITYDIRECTUV: number;
  45915. SPECULARTERM: boolean;
  45916. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45917. MICROSURFACEAUTOMATIC: boolean;
  45918. LODBASEDMICROSFURACE: boolean;
  45919. MICROSURFACEMAP: boolean;
  45920. MICROSURFACEMAPDIRECTUV: number;
  45921. METALLICWORKFLOW: boolean;
  45922. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45923. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45924. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45925. AOSTOREINMETALMAPRED: boolean;
  45926. ENVIRONMENTBRDF: boolean;
  45927. ENVIRONMENTBRDF_RGBD: boolean;
  45928. NORMAL: boolean;
  45929. TANGENT: boolean;
  45930. BUMP: boolean;
  45931. BUMPDIRECTUV: number;
  45932. OBJECTSPACE_NORMALMAP: boolean;
  45933. PARALLAX: boolean;
  45934. PARALLAXOCCLUSION: boolean;
  45935. NORMALXYSCALE: boolean;
  45936. LIGHTMAP: boolean;
  45937. LIGHTMAPDIRECTUV: number;
  45938. USELIGHTMAPASSHADOWMAP: boolean;
  45939. GAMMALIGHTMAP: boolean;
  45940. REFLECTION: boolean;
  45941. REFLECTIONMAP_3D: boolean;
  45942. REFLECTIONMAP_SPHERICAL: boolean;
  45943. REFLECTIONMAP_PLANAR: boolean;
  45944. REFLECTIONMAP_CUBIC: boolean;
  45945. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45946. REFLECTIONMAP_PROJECTION: boolean;
  45947. REFLECTIONMAP_SKYBOX: boolean;
  45948. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45949. REFLECTIONMAP_EXPLICIT: boolean;
  45950. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45951. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45952. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45953. INVERTCUBICMAP: boolean;
  45954. USESPHERICALFROMREFLECTIONMAP: boolean;
  45955. USEIRRADIANCEMAP: boolean;
  45956. SPHERICAL_HARMONICS: boolean;
  45957. USESPHERICALINVERTEX: boolean;
  45958. REFLECTIONMAP_OPPOSITEZ: boolean;
  45959. LODINREFLECTIONALPHA: boolean;
  45960. GAMMAREFLECTION: boolean;
  45961. RGBDREFLECTION: boolean;
  45962. LINEARSPECULARREFLECTION: boolean;
  45963. RADIANCEOCCLUSION: boolean;
  45964. HORIZONOCCLUSION: boolean;
  45965. INSTANCES: boolean;
  45966. NUM_BONE_INFLUENCERS: number;
  45967. BonesPerMesh: number;
  45968. BONETEXTURE: boolean;
  45969. NONUNIFORMSCALING: boolean;
  45970. MORPHTARGETS: boolean;
  45971. MORPHTARGETS_NORMAL: boolean;
  45972. MORPHTARGETS_TANGENT: boolean;
  45973. MORPHTARGETS_UV: boolean;
  45974. NUM_MORPH_INFLUENCERS: number;
  45975. IMAGEPROCESSING: boolean;
  45976. VIGNETTE: boolean;
  45977. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45978. VIGNETTEBLENDMODEOPAQUE: boolean;
  45979. TONEMAPPING: boolean;
  45980. TONEMAPPING_ACES: boolean;
  45981. CONTRAST: boolean;
  45982. COLORCURVES: boolean;
  45983. COLORGRADING: boolean;
  45984. COLORGRADING3D: boolean;
  45985. SAMPLER3DGREENDEPTH: boolean;
  45986. SAMPLER3DBGRMAP: boolean;
  45987. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45988. EXPOSURE: boolean;
  45989. MULTIVIEW: boolean;
  45990. USEPHYSICALLIGHTFALLOFF: boolean;
  45991. USEGLTFLIGHTFALLOFF: boolean;
  45992. TWOSIDEDLIGHTING: boolean;
  45993. SHADOWFLOAT: boolean;
  45994. CLIPPLANE: boolean;
  45995. CLIPPLANE2: boolean;
  45996. CLIPPLANE3: boolean;
  45997. CLIPPLANE4: boolean;
  45998. POINTSIZE: boolean;
  45999. FOG: boolean;
  46000. LOGARITHMICDEPTH: boolean;
  46001. FORCENORMALFORWARD: boolean;
  46002. SPECULARAA: boolean;
  46003. CLEARCOAT: boolean;
  46004. CLEARCOAT_DEFAULTIOR: boolean;
  46005. CLEARCOAT_TEXTURE: boolean;
  46006. CLEARCOAT_TEXTUREDIRECTUV: number;
  46007. CLEARCOAT_BUMP: boolean;
  46008. CLEARCOAT_BUMPDIRECTUV: number;
  46009. CLEARCOAT_TINT: boolean;
  46010. CLEARCOAT_TINT_TEXTURE: boolean;
  46011. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46012. ANISOTROPIC: boolean;
  46013. ANISOTROPIC_TEXTURE: boolean;
  46014. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46015. BRDF_V_HEIGHT_CORRELATED: boolean;
  46016. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46017. SHEEN: boolean;
  46018. SHEEN_TEXTURE: boolean;
  46019. SHEEN_TEXTUREDIRECTUV: number;
  46020. SHEEN_LINKWITHALBEDO: boolean;
  46021. SUBSURFACE: boolean;
  46022. SS_REFRACTION: boolean;
  46023. SS_TRANSLUCENCY: boolean;
  46024. SS_SCATERRING: boolean;
  46025. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46026. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46027. SS_REFRACTIONMAP_3D: boolean;
  46028. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46029. SS_LODINREFRACTIONALPHA: boolean;
  46030. SS_GAMMAREFRACTION: boolean;
  46031. SS_RGBDREFRACTION: boolean;
  46032. SS_LINEARSPECULARREFRACTION: boolean;
  46033. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46034. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46035. UNLIT: boolean;
  46036. DEBUGMODE: number;
  46037. /**
  46038. * Initializes the PBR Material defines.
  46039. */
  46040. constructor();
  46041. /**
  46042. * Resets the PBR Material defines.
  46043. */
  46044. reset(): void;
  46045. }
  46046. /**
  46047. * The Physically based material base class of BJS.
  46048. *
  46049. * This offers the main features of a standard PBR material.
  46050. * For more information, please refer to the documentation :
  46051. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46052. */
  46053. export abstract class PBRBaseMaterial extends PushMaterial {
  46054. /**
  46055. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46056. */
  46057. static readonly PBRMATERIAL_OPAQUE: number;
  46058. /**
  46059. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46060. */
  46061. static readonly PBRMATERIAL_ALPHATEST: number;
  46062. /**
  46063. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46064. */
  46065. static readonly PBRMATERIAL_ALPHABLEND: number;
  46066. /**
  46067. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46068. * They are also discarded below the alpha cutoff threshold to improve performances.
  46069. */
  46070. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46071. /**
  46072. * Defines the default value of how much AO map is occluding the analytical lights
  46073. * (point spot...).
  46074. */
  46075. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46076. /**
  46077. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46078. */
  46079. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46080. /**
  46081. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46082. * to enhance interoperability with other engines.
  46083. */
  46084. static readonly LIGHTFALLOFF_GLTF: number;
  46085. /**
  46086. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46087. * to enhance interoperability with other materials.
  46088. */
  46089. static readonly LIGHTFALLOFF_STANDARD: number;
  46090. /**
  46091. * Intensity of the direct lights e.g. the four lights available in your scene.
  46092. * This impacts both the direct diffuse and specular highlights.
  46093. */
  46094. protected _directIntensity: number;
  46095. /**
  46096. * Intensity of the emissive part of the material.
  46097. * This helps controlling the emissive effect without modifying the emissive color.
  46098. */
  46099. protected _emissiveIntensity: number;
  46100. /**
  46101. * Intensity of the environment e.g. how much the environment will light the object
  46102. * either through harmonics for rough material or through the refelction for shiny ones.
  46103. */
  46104. protected _environmentIntensity: number;
  46105. /**
  46106. * This is a special control allowing the reduction of the specular highlights coming from the
  46107. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46108. */
  46109. protected _specularIntensity: number;
  46110. /**
  46111. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46112. */
  46113. private _lightingInfos;
  46114. /**
  46115. * Debug Control allowing disabling the bump map on this material.
  46116. */
  46117. protected _disableBumpMap: boolean;
  46118. /**
  46119. * AKA Diffuse Texture in standard nomenclature.
  46120. */
  46121. protected _albedoTexture: Nullable<BaseTexture>;
  46122. /**
  46123. * AKA Occlusion Texture in other nomenclature.
  46124. */
  46125. protected _ambientTexture: Nullable<BaseTexture>;
  46126. /**
  46127. * AKA Occlusion Texture Intensity in other nomenclature.
  46128. */
  46129. protected _ambientTextureStrength: number;
  46130. /**
  46131. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46132. * 1 means it completely occludes it
  46133. * 0 mean it has no impact
  46134. */
  46135. protected _ambientTextureImpactOnAnalyticalLights: number;
  46136. /**
  46137. * Stores the alpha values in a texture.
  46138. */
  46139. protected _opacityTexture: Nullable<BaseTexture>;
  46140. /**
  46141. * Stores the reflection values in a texture.
  46142. */
  46143. protected _reflectionTexture: Nullable<BaseTexture>;
  46144. /**
  46145. * Stores the emissive values in a texture.
  46146. */
  46147. protected _emissiveTexture: Nullable<BaseTexture>;
  46148. /**
  46149. * AKA Specular texture in other nomenclature.
  46150. */
  46151. protected _reflectivityTexture: Nullable<BaseTexture>;
  46152. /**
  46153. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46154. */
  46155. protected _metallicTexture: Nullable<BaseTexture>;
  46156. /**
  46157. * Specifies the metallic scalar of the metallic/roughness workflow.
  46158. * Can also be used to scale the metalness values of the metallic texture.
  46159. */
  46160. protected _metallic: Nullable<number>;
  46161. /**
  46162. * Specifies the roughness scalar of the metallic/roughness workflow.
  46163. * Can also be used to scale the roughness values of the metallic texture.
  46164. */
  46165. protected _roughness: Nullable<number>;
  46166. /**
  46167. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46168. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46169. */
  46170. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46171. /**
  46172. * Stores surface normal data used to displace a mesh in a texture.
  46173. */
  46174. protected _bumpTexture: Nullable<BaseTexture>;
  46175. /**
  46176. * Stores the pre-calculated light information of a mesh in a texture.
  46177. */
  46178. protected _lightmapTexture: Nullable<BaseTexture>;
  46179. /**
  46180. * The color of a material in ambient lighting.
  46181. */
  46182. protected _ambientColor: Color3;
  46183. /**
  46184. * AKA Diffuse Color in other nomenclature.
  46185. */
  46186. protected _albedoColor: Color3;
  46187. /**
  46188. * AKA Specular Color in other nomenclature.
  46189. */
  46190. protected _reflectivityColor: Color3;
  46191. /**
  46192. * The color applied when light is reflected from a material.
  46193. */
  46194. protected _reflectionColor: Color3;
  46195. /**
  46196. * The color applied when light is emitted from a material.
  46197. */
  46198. protected _emissiveColor: Color3;
  46199. /**
  46200. * AKA Glossiness in other nomenclature.
  46201. */
  46202. protected _microSurface: number;
  46203. /**
  46204. * Specifies that the material will use the light map as a show map.
  46205. */
  46206. protected _useLightmapAsShadowmap: boolean;
  46207. /**
  46208. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46209. * makes the reflect vector face the model (under horizon).
  46210. */
  46211. protected _useHorizonOcclusion: boolean;
  46212. /**
  46213. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46214. * too much the area relying on ambient texture to define their ambient occlusion.
  46215. */
  46216. protected _useRadianceOcclusion: boolean;
  46217. /**
  46218. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46219. */
  46220. protected _useAlphaFromAlbedoTexture: boolean;
  46221. /**
  46222. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46223. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46224. */
  46225. protected _useSpecularOverAlpha: boolean;
  46226. /**
  46227. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46228. */
  46229. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46230. /**
  46231. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46232. */
  46233. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46234. /**
  46235. * Specifies if the metallic texture contains the roughness information in its green channel.
  46236. */
  46237. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46238. /**
  46239. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46240. */
  46241. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46242. /**
  46243. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46244. */
  46245. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46246. /**
  46247. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46248. */
  46249. protected _useAmbientInGrayScale: boolean;
  46250. /**
  46251. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46252. * The material will try to infer what glossiness each pixel should be.
  46253. */
  46254. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46255. /**
  46256. * Defines the falloff type used in this material.
  46257. * It by default is Physical.
  46258. */
  46259. protected _lightFalloff: number;
  46260. /**
  46261. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46262. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46263. */
  46264. protected _useRadianceOverAlpha: boolean;
  46265. /**
  46266. * Allows using an object space normal map (instead of tangent space).
  46267. */
  46268. protected _useObjectSpaceNormalMap: boolean;
  46269. /**
  46270. * Allows using the bump map in parallax mode.
  46271. */
  46272. protected _useParallax: boolean;
  46273. /**
  46274. * Allows using the bump map in parallax occlusion mode.
  46275. */
  46276. protected _useParallaxOcclusion: boolean;
  46277. /**
  46278. * Controls the scale bias of the parallax mode.
  46279. */
  46280. protected _parallaxScaleBias: number;
  46281. /**
  46282. * If sets to true, disables all the lights affecting the material.
  46283. */
  46284. protected _disableLighting: boolean;
  46285. /**
  46286. * Number of Simultaneous lights allowed on the material.
  46287. */
  46288. protected _maxSimultaneousLights: number;
  46289. /**
  46290. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46291. */
  46292. protected _invertNormalMapX: boolean;
  46293. /**
  46294. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46295. */
  46296. protected _invertNormalMapY: boolean;
  46297. /**
  46298. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46299. */
  46300. protected _twoSidedLighting: boolean;
  46301. /**
  46302. * Defines the alpha limits in alpha test mode.
  46303. */
  46304. protected _alphaCutOff: number;
  46305. /**
  46306. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46307. */
  46308. protected _forceAlphaTest: boolean;
  46309. /**
  46310. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46311. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46312. */
  46313. protected _useAlphaFresnel: boolean;
  46314. /**
  46315. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46316. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46317. */
  46318. protected _useLinearAlphaFresnel: boolean;
  46319. /**
  46320. * The transparency mode of the material.
  46321. */
  46322. protected _transparencyMode: Nullable<number>;
  46323. /**
  46324. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46325. * from cos thetav and roughness:
  46326. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46327. */
  46328. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46329. /**
  46330. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46331. */
  46332. protected _forceIrradianceInFragment: boolean;
  46333. /**
  46334. * Force normal to face away from face.
  46335. */
  46336. protected _forceNormalForward: boolean;
  46337. /**
  46338. * Enables specular anti aliasing in the PBR shader.
  46339. * It will both interacts on the Geometry for analytical and IBL lighting.
  46340. * It also prefilter the roughness map based on the bump values.
  46341. */
  46342. protected _enableSpecularAntiAliasing: boolean;
  46343. /**
  46344. * Default configuration related to image processing available in the PBR Material.
  46345. */
  46346. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46347. /**
  46348. * Keep track of the image processing observer to allow dispose and replace.
  46349. */
  46350. private _imageProcessingObserver;
  46351. /**
  46352. * Attaches a new image processing configuration to the PBR Material.
  46353. * @param configuration
  46354. */
  46355. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46356. /**
  46357. * Stores the available render targets.
  46358. */
  46359. private _renderTargets;
  46360. /**
  46361. * Sets the global ambient color for the material used in lighting calculations.
  46362. */
  46363. private _globalAmbientColor;
  46364. /**
  46365. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46366. */
  46367. private _useLogarithmicDepth;
  46368. /**
  46369. * If set to true, no lighting calculations will be applied.
  46370. */
  46371. private _unlit;
  46372. private _debugMode;
  46373. /**
  46374. * @hidden
  46375. * This is reserved for the inspector.
  46376. * Defines the material debug mode.
  46377. * It helps seeing only some components of the material while troubleshooting.
  46378. */
  46379. debugMode: number;
  46380. /**
  46381. * @hidden
  46382. * This is reserved for the inspector.
  46383. * Specify from where on screen the debug mode should start.
  46384. * The value goes from -1 (full screen) to 1 (not visible)
  46385. * It helps with side by side comparison against the final render
  46386. * This defaults to -1
  46387. */
  46388. private debugLimit;
  46389. /**
  46390. * @hidden
  46391. * This is reserved for the inspector.
  46392. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46393. * You can use the factor to better multiply the final value.
  46394. */
  46395. private debugFactor;
  46396. /**
  46397. * Defines the clear coat layer parameters for the material.
  46398. */
  46399. readonly clearCoat: PBRClearCoatConfiguration;
  46400. /**
  46401. * Defines the anisotropic parameters for the material.
  46402. */
  46403. readonly anisotropy: PBRAnisotropicConfiguration;
  46404. /**
  46405. * Defines the BRDF parameters for the material.
  46406. */
  46407. readonly brdf: PBRBRDFConfiguration;
  46408. /**
  46409. * Defines the Sheen parameters for the material.
  46410. */
  46411. readonly sheen: PBRSheenConfiguration;
  46412. /**
  46413. * Defines the SubSurface parameters for the material.
  46414. */
  46415. readonly subSurface: PBRSubSurfaceConfiguration;
  46416. /**
  46417. * Custom callback helping to override the default shader used in the material.
  46418. */
  46419. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46420. /**
  46421. * Instantiates a new PBRMaterial instance.
  46422. *
  46423. * @param name The material name
  46424. * @param scene The scene the material will be use in.
  46425. */
  46426. constructor(name: string, scene: Scene);
  46427. /**
  46428. * Gets a boolean indicating that current material needs to register RTT
  46429. */
  46430. readonly hasRenderTargetTextures: boolean;
  46431. /**
  46432. * Gets the name of the material class.
  46433. */
  46434. getClassName(): string;
  46435. /**
  46436. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46437. */
  46438. /**
  46439. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46440. */
  46441. useLogarithmicDepth: boolean;
  46442. /**
  46443. * Gets the current transparency mode.
  46444. */
  46445. /**
  46446. * Sets the transparency mode of the material.
  46447. *
  46448. * | Value | Type | Description |
  46449. * | ----- | ----------------------------------- | ----------- |
  46450. * | 0 | OPAQUE | |
  46451. * | 1 | ALPHATEST | |
  46452. * | 2 | ALPHABLEND | |
  46453. * | 3 | ALPHATESTANDBLEND | |
  46454. *
  46455. */
  46456. transparencyMode: Nullable<number>;
  46457. /**
  46458. * Returns true if alpha blending should be disabled.
  46459. */
  46460. private readonly _disableAlphaBlending;
  46461. /**
  46462. * Specifies whether or not this material should be rendered in alpha blend mode.
  46463. */
  46464. needAlphaBlending(): boolean;
  46465. /**
  46466. * Specifies if the mesh will require alpha blending.
  46467. * @param mesh - BJS mesh.
  46468. */
  46469. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46470. /**
  46471. * Specifies whether or not this material should be rendered in alpha test mode.
  46472. */
  46473. needAlphaTesting(): boolean;
  46474. /**
  46475. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46476. */
  46477. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46478. /**
  46479. * Gets the texture used for the alpha test.
  46480. */
  46481. getAlphaTestTexture(): Nullable<BaseTexture>;
  46482. /**
  46483. * Specifies that the submesh is ready to be used.
  46484. * @param mesh - BJS mesh.
  46485. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46486. * @param useInstances - Specifies that instances should be used.
  46487. * @returns - boolean indicating that the submesh is ready or not.
  46488. */
  46489. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46490. /**
  46491. * Specifies if the material uses metallic roughness workflow.
  46492. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46493. */
  46494. isMetallicWorkflow(): boolean;
  46495. private _prepareEffect;
  46496. private _prepareDefines;
  46497. /**
  46498. * Force shader compilation
  46499. */
  46500. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46501. clipPlane: boolean;
  46502. }>): void;
  46503. /**
  46504. * Initializes the uniform buffer layout for the shader.
  46505. */
  46506. buildUniformLayout(): void;
  46507. /**
  46508. * Unbinds the material from the mesh
  46509. */
  46510. unbind(): void;
  46511. /**
  46512. * Binds the submesh data.
  46513. * @param world - The world matrix.
  46514. * @param mesh - The BJS mesh.
  46515. * @param subMesh - A submesh of the BJS mesh.
  46516. */
  46517. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46518. /**
  46519. * Returns the animatable textures.
  46520. * @returns - Array of animatable textures.
  46521. */
  46522. getAnimatables(): IAnimatable[];
  46523. /**
  46524. * Returns the texture used for reflections.
  46525. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46526. */
  46527. private _getReflectionTexture;
  46528. /**
  46529. * Returns an array of the actively used textures.
  46530. * @returns - Array of BaseTextures
  46531. */
  46532. getActiveTextures(): BaseTexture[];
  46533. /**
  46534. * Checks to see if a texture is used in the material.
  46535. * @param texture - Base texture to use.
  46536. * @returns - Boolean specifying if a texture is used in the material.
  46537. */
  46538. hasTexture(texture: BaseTexture): boolean;
  46539. /**
  46540. * Disposes the resources of the material.
  46541. * @param forceDisposeEffect - Forces the disposal of effects.
  46542. * @param forceDisposeTextures - Forces the disposal of all textures.
  46543. */
  46544. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46545. }
  46546. }
  46547. declare module BABYLON {
  46548. /**
  46549. * The Physically based material of BJS.
  46550. *
  46551. * This offers the main features of a standard PBR material.
  46552. * For more information, please refer to the documentation :
  46553. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46554. */
  46555. export class PBRMaterial extends PBRBaseMaterial {
  46556. /**
  46557. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46558. */
  46559. static readonly PBRMATERIAL_OPAQUE: number;
  46560. /**
  46561. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46562. */
  46563. static readonly PBRMATERIAL_ALPHATEST: number;
  46564. /**
  46565. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46566. */
  46567. static readonly PBRMATERIAL_ALPHABLEND: number;
  46568. /**
  46569. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46570. * They are also discarded below the alpha cutoff threshold to improve performances.
  46571. */
  46572. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46573. /**
  46574. * Defines the default value of how much AO map is occluding the analytical lights
  46575. * (point spot...).
  46576. */
  46577. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46578. /**
  46579. * Intensity of the direct lights e.g. the four lights available in your scene.
  46580. * This impacts both the direct diffuse and specular highlights.
  46581. */
  46582. directIntensity: number;
  46583. /**
  46584. * Intensity of the emissive part of the material.
  46585. * This helps controlling the emissive effect without modifying the emissive color.
  46586. */
  46587. emissiveIntensity: number;
  46588. /**
  46589. * Intensity of the environment e.g. how much the environment will light the object
  46590. * either through harmonics for rough material or through the refelction for shiny ones.
  46591. */
  46592. environmentIntensity: number;
  46593. /**
  46594. * This is a special control allowing the reduction of the specular highlights coming from the
  46595. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46596. */
  46597. specularIntensity: number;
  46598. /**
  46599. * Debug Control allowing disabling the bump map on this material.
  46600. */
  46601. disableBumpMap: boolean;
  46602. /**
  46603. * AKA Diffuse Texture in standard nomenclature.
  46604. */
  46605. albedoTexture: BaseTexture;
  46606. /**
  46607. * AKA Occlusion Texture in other nomenclature.
  46608. */
  46609. ambientTexture: BaseTexture;
  46610. /**
  46611. * AKA Occlusion Texture Intensity in other nomenclature.
  46612. */
  46613. ambientTextureStrength: number;
  46614. /**
  46615. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46616. * 1 means it completely occludes it
  46617. * 0 mean it has no impact
  46618. */
  46619. ambientTextureImpactOnAnalyticalLights: number;
  46620. /**
  46621. * Stores the alpha values in a texture.
  46622. */
  46623. opacityTexture: BaseTexture;
  46624. /**
  46625. * Stores the reflection values in a texture.
  46626. */
  46627. reflectionTexture: Nullable<BaseTexture>;
  46628. /**
  46629. * Stores the emissive values in a texture.
  46630. */
  46631. emissiveTexture: BaseTexture;
  46632. /**
  46633. * AKA Specular texture in other nomenclature.
  46634. */
  46635. reflectivityTexture: BaseTexture;
  46636. /**
  46637. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46638. */
  46639. metallicTexture: BaseTexture;
  46640. /**
  46641. * Specifies the metallic scalar of the metallic/roughness workflow.
  46642. * Can also be used to scale the metalness values of the metallic texture.
  46643. */
  46644. metallic: Nullable<number>;
  46645. /**
  46646. * Specifies the roughness scalar of the metallic/roughness workflow.
  46647. * Can also be used to scale the roughness values of the metallic texture.
  46648. */
  46649. roughness: Nullable<number>;
  46650. /**
  46651. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46652. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46653. */
  46654. microSurfaceTexture: BaseTexture;
  46655. /**
  46656. * Stores surface normal data used to displace a mesh in a texture.
  46657. */
  46658. bumpTexture: BaseTexture;
  46659. /**
  46660. * Stores the pre-calculated light information of a mesh in a texture.
  46661. */
  46662. lightmapTexture: BaseTexture;
  46663. /**
  46664. * Stores the refracted light information in a texture.
  46665. */
  46666. refractionTexture: Nullable<BaseTexture>;
  46667. /**
  46668. * The color of a material in ambient lighting.
  46669. */
  46670. ambientColor: Color3;
  46671. /**
  46672. * AKA Diffuse Color in other nomenclature.
  46673. */
  46674. albedoColor: Color3;
  46675. /**
  46676. * AKA Specular Color in other nomenclature.
  46677. */
  46678. reflectivityColor: Color3;
  46679. /**
  46680. * The color reflected from the material.
  46681. */
  46682. reflectionColor: Color3;
  46683. /**
  46684. * The color emitted from the material.
  46685. */
  46686. emissiveColor: Color3;
  46687. /**
  46688. * AKA Glossiness in other nomenclature.
  46689. */
  46690. microSurface: number;
  46691. /**
  46692. * source material index of refraction (IOR)' / 'destination material IOR.
  46693. */
  46694. indexOfRefraction: number;
  46695. /**
  46696. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46697. */
  46698. invertRefractionY: boolean;
  46699. /**
  46700. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46701. * Materials half opaque for instance using refraction could benefit from this control.
  46702. */
  46703. linkRefractionWithTransparency: boolean;
  46704. /**
  46705. * If true, the light map contains occlusion information instead of lighting info.
  46706. */
  46707. useLightmapAsShadowmap: boolean;
  46708. /**
  46709. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46710. */
  46711. useAlphaFromAlbedoTexture: boolean;
  46712. /**
  46713. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46714. */
  46715. forceAlphaTest: boolean;
  46716. /**
  46717. * Defines the alpha limits in alpha test mode.
  46718. */
  46719. alphaCutOff: number;
  46720. /**
  46721. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46722. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46723. */
  46724. useSpecularOverAlpha: boolean;
  46725. /**
  46726. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46727. */
  46728. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46729. /**
  46730. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46731. */
  46732. useRoughnessFromMetallicTextureAlpha: boolean;
  46733. /**
  46734. * Specifies if the metallic texture contains the roughness information in its green channel.
  46735. */
  46736. useRoughnessFromMetallicTextureGreen: boolean;
  46737. /**
  46738. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46739. */
  46740. useMetallnessFromMetallicTextureBlue: boolean;
  46741. /**
  46742. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46743. */
  46744. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46745. /**
  46746. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46747. */
  46748. useAmbientInGrayScale: boolean;
  46749. /**
  46750. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46751. * The material will try to infer what glossiness each pixel should be.
  46752. */
  46753. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46754. /**
  46755. * BJS is using an harcoded light falloff based on a manually sets up range.
  46756. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46757. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46758. */
  46759. /**
  46760. * BJS is using an harcoded light falloff based on a manually sets up range.
  46761. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46762. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46763. */
  46764. usePhysicalLightFalloff: boolean;
  46765. /**
  46766. * In order to support the falloff compatibility with gltf, a special mode has been added
  46767. * to reproduce the gltf light falloff.
  46768. */
  46769. /**
  46770. * In order to support the falloff compatibility with gltf, a special mode has been added
  46771. * to reproduce the gltf light falloff.
  46772. */
  46773. useGLTFLightFalloff: boolean;
  46774. /**
  46775. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46776. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46777. */
  46778. useRadianceOverAlpha: boolean;
  46779. /**
  46780. * Allows using an object space normal map (instead of tangent space).
  46781. */
  46782. useObjectSpaceNormalMap: boolean;
  46783. /**
  46784. * Allows using the bump map in parallax mode.
  46785. */
  46786. useParallax: boolean;
  46787. /**
  46788. * Allows using the bump map in parallax occlusion mode.
  46789. */
  46790. useParallaxOcclusion: boolean;
  46791. /**
  46792. * Controls the scale bias of the parallax mode.
  46793. */
  46794. parallaxScaleBias: number;
  46795. /**
  46796. * If sets to true, disables all the lights affecting the material.
  46797. */
  46798. disableLighting: boolean;
  46799. /**
  46800. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46801. */
  46802. forceIrradianceInFragment: boolean;
  46803. /**
  46804. * Number of Simultaneous lights allowed on the material.
  46805. */
  46806. maxSimultaneousLights: number;
  46807. /**
  46808. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46809. */
  46810. invertNormalMapX: boolean;
  46811. /**
  46812. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46813. */
  46814. invertNormalMapY: boolean;
  46815. /**
  46816. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46817. */
  46818. twoSidedLighting: boolean;
  46819. /**
  46820. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46821. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46822. */
  46823. useAlphaFresnel: boolean;
  46824. /**
  46825. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46826. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46827. */
  46828. useLinearAlphaFresnel: boolean;
  46829. /**
  46830. * Let user defines the brdf lookup texture used for IBL.
  46831. * A default 8bit version is embedded but you could point at :
  46832. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  46833. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46834. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  46835. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46836. */
  46837. environmentBRDFTexture: Nullable<BaseTexture>;
  46838. /**
  46839. * Force normal to face away from face.
  46840. */
  46841. forceNormalForward: boolean;
  46842. /**
  46843. * Enables specular anti aliasing in the PBR shader.
  46844. * It will both interacts on the Geometry for analytical and IBL lighting.
  46845. * It also prefilter the roughness map based on the bump values.
  46846. */
  46847. enableSpecularAntiAliasing: boolean;
  46848. /**
  46849. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46850. * makes the reflect vector face the model (under horizon).
  46851. */
  46852. useHorizonOcclusion: boolean;
  46853. /**
  46854. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46855. * too much the area relying on ambient texture to define their ambient occlusion.
  46856. */
  46857. useRadianceOcclusion: boolean;
  46858. /**
  46859. * If set to true, no lighting calculations will be applied.
  46860. */
  46861. unlit: boolean;
  46862. /**
  46863. * Gets the image processing configuration used either in this material.
  46864. */
  46865. /**
  46866. * Sets the Default image processing configuration used either in the this material.
  46867. *
  46868. * If sets to null, the scene one is in use.
  46869. */
  46870. imageProcessingConfiguration: ImageProcessingConfiguration;
  46871. /**
  46872. * Gets wether the color curves effect is enabled.
  46873. */
  46874. /**
  46875. * Sets wether the color curves effect is enabled.
  46876. */
  46877. cameraColorCurvesEnabled: boolean;
  46878. /**
  46879. * Gets wether the color grading effect is enabled.
  46880. */
  46881. /**
  46882. * Gets wether the color grading effect is enabled.
  46883. */
  46884. cameraColorGradingEnabled: boolean;
  46885. /**
  46886. * Gets wether tonemapping is enabled or not.
  46887. */
  46888. /**
  46889. * Sets wether tonemapping is enabled or not
  46890. */
  46891. cameraToneMappingEnabled: boolean;
  46892. /**
  46893. * The camera exposure used on this material.
  46894. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46895. * This corresponds to a photographic exposure.
  46896. */
  46897. /**
  46898. * The camera exposure used on this material.
  46899. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46900. * This corresponds to a photographic exposure.
  46901. */
  46902. cameraExposure: number;
  46903. /**
  46904. * Gets The camera contrast used on this material.
  46905. */
  46906. /**
  46907. * Sets The camera contrast used on this material.
  46908. */
  46909. cameraContrast: number;
  46910. /**
  46911. * Gets the Color Grading 2D Lookup Texture.
  46912. */
  46913. /**
  46914. * Sets the Color Grading 2D Lookup Texture.
  46915. */
  46916. cameraColorGradingTexture: Nullable<BaseTexture>;
  46917. /**
  46918. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46919. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46920. * 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;
  46921. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46922. */
  46923. /**
  46924. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46925. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46926. * 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;
  46927. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46928. */
  46929. cameraColorCurves: Nullable<ColorCurves>;
  46930. /**
  46931. * Instantiates a new PBRMaterial instance.
  46932. *
  46933. * @param name The material name
  46934. * @param scene The scene the material will be use in.
  46935. */
  46936. constructor(name: string, scene: Scene);
  46937. /**
  46938. * Returns the name of this material class.
  46939. */
  46940. getClassName(): string;
  46941. /**
  46942. * Makes a duplicate of the current material.
  46943. * @param name - name to use for the new material.
  46944. */
  46945. clone(name: string): PBRMaterial;
  46946. /**
  46947. * Serializes this PBR Material.
  46948. * @returns - An object with the serialized material.
  46949. */
  46950. serialize(): any;
  46951. /**
  46952. * Parses a PBR Material from a serialized object.
  46953. * @param source - Serialized object.
  46954. * @param scene - BJS scene instance.
  46955. * @param rootUrl - url for the scene object
  46956. * @returns - PBRMaterial
  46957. */
  46958. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46959. }
  46960. }
  46961. declare module BABYLON {
  46962. /**
  46963. * Direct draw surface info
  46964. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46965. */
  46966. export interface DDSInfo {
  46967. /**
  46968. * Width of the texture
  46969. */
  46970. width: number;
  46971. /**
  46972. * Width of the texture
  46973. */
  46974. height: number;
  46975. /**
  46976. * Number of Mipmaps for the texture
  46977. * @see https://en.wikipedia.org/wiki/Mipmap
  46978. */
  46979. mipmapCount: number;
  46980. /**
  46981. * If the textures format is a known fourCC format
  46982. * @see https://www.fourcc.org/
  46983. */
  46984. isFourCC: boolean;
  46985. /**
  46986. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46987. */
  46988. isRGB: boolean;
  46989. /**
  46990. * If the texture is a lumincance format
  46991. */
  46992. isLuminance: boolean;
  46993. /**
  46994. * If this is a cube texture
  46995. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46996. */
  46997. isCube: boolean;
  46998. /**
  46999. * If the texture is a compressed format eg. FOURCC_DXT1
  47000. */
  47001. isCompressed: boolean;
  47002. /**
  47003. * The dxgiFormat of the texture
  47004. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47005. */
  47006. dxgiFormat: number;
  47007. /**
  47008. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47009. */
  47010. textureType: number;
  47011. /**
  47012. * Sphericle polynomial created for the dds texture
  47013. */
  47014. sphericalPolynomial?: SphericalPolynomial;
  47015. }
  47016. /**
  47017. * Class used to provide DDS decompression tools
  47018. */
  47019. export class DDSTools {
  47020. /**
  47021. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47022. */
  47023. static StoreLODInAlphaChannel: boolean;
  47024. /**
  47025. * Gets DDS information from an array buffer
  47026. * @param arrayBuffer defines the array buffer to read data from
  47027. * @returns the DDS information
  47028. */
  47029. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47030. private static _FloatView;
  47031. private static _Int32View;
  47032. private static _ToHalfFloat;
  47033. private static _FromHalfFloat;
  47034. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47035. private static _GetHalfFloatRGBAArrayBuffer;
  47036. private static _GetFloatRGBAArrayBuffer;
  47037. private static _GetFloatAsUIntRGBAArrayBuffer;
  47038. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47039. private static _GetRGBAArrayBuffer;
  47040. private static _ExtractLongWordOrder;
  47041. private static _GetRGBArrayBuffer;
  47042. private static _GetLuminanceArrayBuffer;
  47043. /**
  47044. * Uploads DDS Levels to a Babylon Texture
  47045. * @hidden
  47046. */
  47047. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47048. }
  47049. interface Engine {
  47050. /**
  47051. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47052. * @param rootUrl defines the url where the file to load is located
  47053. * @param scene defines the current scene
  47054. * @param lodScale defines scale to apply to the mip map selection
  47055. * @param lodOffset defines offset to apply to the mip map selection
  47056. * @param onLoad defines an optional callback raised when the texture is loaded
  47057. * @param onError defines an optional callback raised if there is an issue to load the texture
  47058. * @param format defines the format of the data
  47059. * @param forcedExtension defines the extension to use to pick the right loader
  47060. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47061. * @returns the cube texture as an InternalTexture
  47062. */
  47063. 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;
  47064. }
  47065. }
  47066. declare module BABYLON {
  47067. /**
  47068. * Implementation of the DDS Texture Loader.
  47069. * @hidden
  47070. */
  47071. export class _DDSTextureLoader implements IInternalTextureLoader {
  47072. /**
  47073. * Defines wether the loader supports cascade loading the different faces.
  47074. */
  47075. readonly supportCascades: boolean;
  47076. /**
  47077. * This returns if the loader support the current file information.
  47078. * @param extension defines the file extension of the file being loaded
  47079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47080. * @param fallback defines the fallback internal texture if any
  47081. * @param isBase64 defines whether the texture is encoded as a base64
  47082. * @param isBuffer defines whether the texture data are stored as a buffer
  47083. * @returns true if the loader can load the specified file
  47084. */
  47085. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47086. /**
  47087. * Transform the url before loading if required.
  47088. * @param rootUrl the url of the texture
  47089. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47090. * @returns the transformed texture
  47091. */
  47092. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47093. /**
  47094. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47095. * @param rootUrl the url of the texture
  47096. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47097. * @returns the fallback texture
  47098. */
  47099. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47100. /**
  47101. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47102. * @param data contains the texture data
  47103. * @param texture defines the BabylonJS internal texture
  47104. * @param createPolynomials will be true if polynomials have been requested
  47105. * @param onLoad defines the callback to trigger once the texture is ready
  47106. * @param onError defines the callback to trigger in case of error
  47107. */
  47108. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47109. /**
  47110. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47111. * @param data contains the texture data
  47112. * @param texture defines the BabylonJS internal texture
  47113. * @param callback defines the method to call once ready to upload
  47114. */
  47115. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47116. }
  47117. }
  47118. declare module BABYLON {
  47119. /** @hidden */
  47120. export var rgbdEncodePixelShader: {
  47121. name: string;
  47122. shader: string;
  47123. };
  47124. }
  47125. declare module BABYLON {
  47126. /**
  47127. * Raw texture data and descriptor sufficient for WebGL texture upload
  47128. */
  47129. export interface EnvironmentTextureInfo {
  47130. /**
  47131. * Version of the environment map
  47132. */
  47133. version: number;
  47134. /**
  47135. * Width of image
  47136. */
  47137. width: number;
  47138. /**
  47139. * Irradiance information stored in the file.
  47140. */
  47141. irradiance: any;
  47142. /**
  47143. * Specular information stored in the file.
  47144. */
  47145. specular: any;
  47146. }
  47147. /**
  47148. * Sets of helpers addressing the serialization and deserialization of environment texture
  47149. * stored in a BabylonJS env file.
  47150. * Those files are usually stored as .env files.
  47151. */
  47152. export class EnvironmentTextureTools {
  47153. /**
  47154. * Magic number identifying the env file.
  47155. */
  47156. private static _MagicBytes;
  47157. /**
  47158. * Gets the environment info from an env file.
  47159. * @param data The array buffer containing the .env bytes.
  47160. * @returns the environment file info (the json header) if successfully parsed.
  47161. */
  47162. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47163. /**
  47164. * Creates an environment texture from a loaded cube texture.
  47165. * @param texture defines the cube texture to convert in env file
  47166. * @return a promise containing the environment data if succesfull.
  47167. */
  47168. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47169. /**
  47170. * Creates a JSON representation of the spherical data.
  47171. * @param texture defines the texture containing the polynomials
  47172. * @return the JSON representation of the spherical info
  47173. */
  47174. private static _CreateEnvTextureIrradiance;
  47175. /**
  47176. * Uploads the texture info contained in the env file to the GPU.
  47177. * @param texture defines the internal texture to upload to
  47178. * @param arrayBuffer defines the buffer cotaining the data to load
  47179. * @param info defines the texture info retrieved through the GetEnvInfo method
  47180. * @returns a promise
  47181. */
  47182. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47183. /**
  47184. * Uploads the levels of image data to the GPU.
  47185. * @param texture defines the internal texture to upload to
  47186. * @param imageData defines the array buffer views of image data [mipmap][face]
  47187. * @returns a promise
  47188. */
  47189. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47190. /**
  47191. * Uploads spherical polynomials information to the texture.
  47192. * @param texture defines the texture we are trying to upload the information to
  47193. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47194. */
  47195. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47196. /** @hidden */
  47197. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47198. }
  47199. }
  47200. declare module BABYLON {
  47201. /**
  47202. * Implementation of the ENV Texture Loader.
  47203. * @hidden
  47204. */
  47205. export class _ENVTextureLoader implements IInternalTextureLoader {
  47206. /**
  47207. * Defines wether the loader supports cascade loading the different faces.
  47208. */
  47209. readonly supportCascades: boolean;
  47210. /**
  47211. * This returns if the loader support the current file information.
  47212. * @param extension defines the file extension of the file being loaded
  47213. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47214. * @param fallback defines the fallback internal texture if any
  47215. * @param isBase64 defines whether the texture is encoded as a base64
  47216. * @param isBuffer defines whether the texture data are stored as a buffer
  47217. * @returns true if the loader can load the specified file
  47218. */
  47219. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47220. /**
  47221. * Transform the url before loading if required.
  47222. * @param rootUrl the url of the texture
  47223. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47224. * @returns the transformed texture
  47225. */
  47226. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47227. /**
  47228. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47229. * @param rootUrl the url of the texture
  47230. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47231. * @returns the fallback texture
  47232. */
  47233. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47234. /**
  47235. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47236. * @param data contains the texture data
  47237. * @param texture defines the BabylonJS internal texture
  47238. * @param createPolynomials will be true if polynomials have been requested
  47239. * @param onLoad defines the callback to trigger once the texture is ready
  47240. * @param onError defines the callback to trigger in case of error
  47241. */
  47242. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47243. /**
  47244. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47245. * @param data contains the texture data
  47246. * @param texture defines the BabylonJS internal texture
  47247. * @param callback defines the method to call once ready to upload
  47248. */
  47249. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47250. }
  47251. }
  47252. declare module BABYLON {
  47253. /**
  47254. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47255. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47256. */
  47257. export class KhronosTextureContainer {
  47258. /** contents of the KTX container file */
  47259. arrayBuffer: any;
  47260. private static HEADER_LEN;
  47261. private static COMPRESSED_2D;
  47262. private static COMPRESSED_3D;
  47263. private static TEX_2D;
  47264. private static TEX_3D;
  47265. /**
  47266. * Gets the openGL type
  47267. */
  47268. glType: number;
  47269. /**
  47270. * Gets the openGL type size
  47271. */
  47272. glTypeSize: number;
  47273. /**
  47274. * Gets the openGL format
  47275. */
  47276. glFormat: number;
  47277. /**
  47278. * Gets the openGL internal format
  47279. */
  47280. glInternalFormat: number;
  47281. /**
  47282. * Gets the base internal format
  47283. */
  47284. glBaseInternalFormat: number;
  47285. /**
  47286. * Gets image width in pixel
  47287. */
  47288. pixelWidth: number;
  47289. /**
  47290. * Gets image height in pixel
  47291. */
  47292. pixelHeight: number;
  47293. /**
  47294. * Gets image depth in pixels
  47295. */
  47296. pixelDepth: number;
  47297. /**
  47298. * Gets the number of array elements
  47299. */
  47300. numberOfArrayElements: number;
  47301. /**
  47302. * Gets the number of faces
  47303. */
  47304. numberOfFaces: number;
  47305. /**
  47306. * Gets the number of mipmap levels
  47307. */
  47308. numberOfMipmapLevels: number;
  47309. /**
  47310. * Gets the bytes of key value data
  47311. */
  47312. bytesOfKeyValueData: number;
  47313. /**
  47314. * Gets the load type
  47315. */
  47316. loadType: number;
  47317. /**
  47318. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47319. */
  47320. isInvalid: boolean;
  47321. /**
  47322. * Creates a new KhronosTextureContainer
  47323. * @param arrayBuffer contents of the KTX container file
  47324. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47325. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47326. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47327. */
  47328. constructor(
  47329. /** contents of the KTX container file */
  47330. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47331. /**
  47332. * Uploads KTX content to a Babylon Texture.
  47333. * It is assumed that the texture has already been created & is currently bound
  47334. * @hidden
  47335. */
  47336. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47337. private _upload2DCompressedLevels;
  47338. }
  47339. }
  47340. declare module BABYLON {
  47341. /**
  47342. * Implementation of the KTX Texture Loader.
  47343. * @hidden
  47344. */
  47345. export class _KTXTextureLoader implements IInternalTextureLoader {
  47346. /**
  47347. * Defines wether the loader supports cascade loading the different faces.
  47348. */
  47349. readonly supportCascades: boolean;
  47350. /**
  47351. * This returns if the loader support the current file information.
  47352. * @param extension defines the file extension of the file being loaded
  47353. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47354. * @param fallback defines the fallback internal texture if any
  47355. * @param isBase64 defines whether the texture is encoded as a base64
  47356. * @param isBuffer defines whether the texture data are stored as a buffer
  47357. * @returns true if the loader can load the specified file
  47358. */
  47359. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47360. /**
  47361. * Transform the url before loading if required.
  47362. * @param rootUrl the url of the texture
  47363. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47364. * @returns the transformed texture
  47365. */
  47366. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47367. /**
  47368. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47369. * @param rootUrl the url of the texture
  47370. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47371. * @returns the fallback texture
  47372. */
  47373. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47374. /**
  47375. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47376. * @param data contains the texture data
  47377. * @param texture defines the BabylonJS internal texture
  47378. * @param createPolynomials will be true if polynomials have been requested
  47379. * @param onLoad defines the callback to trigger once the texture is ready
  47380. * @param onError defines the callback to trigger in case of error
  47381. */
  47382. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47383. /**
  47384. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47385. * @param data contains the texture data
  47386. * @param texture defines the BabylonJS internal texture
  47387. * @param callback defines the method to call once ready to upload
  47388. */
  47389. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47390. }
  47391. }
  47392. declare module BABYLON {
  47393. /**
  47394. * Options for the default xr helper
  47395. */
  47396. export class WebXRDefaultExperienceOptions {
  47397. /**
  47398. * Floor meshes that should be used for teleporting
  47399. */
  47400. floorMeshes: Array<AbstractMesh>;
  47401. }
  47402. /**
  47403. * Default experience which provides a similar setup to the previous webVRExperience
  47404. */
  47405. export class WebXRDefaultExperience {
  47406. /**
  47407. * Base experience
  47408. */
  47409. baseExperience: WebXRExperienceHelper;
  47410. /**
  47411. * Input experience extension
  47412. */
  47413. input: WebXRInput;
  47414. /**
  47415. * Loads the controller models
  47416. */
  47417. controllerModelLoader: WebXRControllerModelLoader;
  47418. /**
  47419. * Enables laser pointer and selection
  47420. */
  47421. pointerSelection: WebXRControllerPointerSelection;
  47422. /**
  47423. * Enables teleportation
  47424. */
  47425. teleportation: WebXRControllerTeleportation;
  47426. /**
  47427. * Enables ui for enetering/exiting xr
  47428. */
  47429. enterExitUI: WebXREnterExitUI;
  47430. /**
  47431. * Default output canvas xr should render to
  47432. */
  47433. outputCanvas: WebXRManagedOutputCanvas;
  47434. /**
  47435. * Creates the default xr experience
  47436. * @param scene scene
  47437. * @param options options for basic configuration
  47438. * @returns resulting WebXRDefaultExperience
  47439. */
  47440. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47441. private constructor();
  47442. /**
  47443. * DIsposes of the experience helper
  47444. */
  47445. dispose(): void;
  47446. }
  47447. }
  47448. declare module BABYLON {
  47449. /** @hidden */
  47450. export var _forceSceneHelpersToBundle: boolean;
  47451. interface Scene {
  47452. /**
  47453. * Creates a default light for the scene.
  47454. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47455. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47456. */
  47457. createDefaultLight(replace?: boolean): void;
  47458. /**
  47459. * Creates a default camera for the scene.
  47460. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47461. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47462. * @param replace has default false, when true replaces the active camera in the scene
  47463. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47464. */
  47465. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47466. /**
  47467. * Creates a default camera and a default light.
  47468. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47469. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47470. * @param replace has the default false, when true replaces the active camera/light in the scene
  47471. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47472. */
  47473. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47474. /**
  47475. * Creates a new sky box
  47476. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47477. * @param environmentTexture defines the texture to use as environment texture
  47478. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47479. * @param scale defines the overall scale of the skybox
  47480. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47481. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47482. * @returns a new mesh holding the sky box
  47483. */
  47484. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47485. /**
  47486. * Creates a new environment
  47487. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47488. * @param options defines the options you can use to configure the environment
  47489. * @returns the new EnvironmentHelper
  47490. */
  47491. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47492. /**
  47493. * Creates a new VREXperienceHelper
  47494. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47495. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47496. * @returns a new VREXperienceHelper
  47497. */
  47498. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47499. /**
  47500. * Creates a new WebXRDefaultExperience
  47501. * @see http://doc.babylonjs.com/how_to/webxr
  47502. * @param options experience options
  47503. * @returns a promise for a new WebXRDefaultExperience
  47504. */
  47505. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47506. }
  47507. }
  47508. declare module BABYLON {
  47509. /**
  47510. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47511. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47512. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47513. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47514. */
  47515. export class VideoDome extends TransformNode {
  47516. /**
  47517. * Define the video source as a Monoscopic panoramic 360 video.
  47518. */
  47519. static readonly MODE_MONOSCOPIC: number;
  47520. /**
  47521. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47522. */
  47523. static readonly MODE_TOPBOTTOM: number;
  47524. /**
  47525. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47526. */
  47527. static readonly MODE_SIDEBYSIDE: number;
  47528. private _useDirectMapping;
  47529. /**
  47530. * The video texture being displayed on the sphere
  47531. */
  47532. protected _videoTexture: VideoTexture;
  47533. /**
  47534. * Gets the video texture being displayed on the sphere
  47535. */
  47536. readonly videoTexture: VideoTexture;
  47537. /**
  47538. * The skybox material
  47539. */
  47540. protected _material: BackgroundMaterial;
  47541. /**
  47542. * The surface used for the skybox
  47543. */
  47544. protected _mesh: Mesh;
  47545. /**
  47546. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47547. * Also see the options.resolution property.
  47548. */
  47549. fovMultiplier: number;
  47550. private _videoMode;
  47551. /**
  47552. * Gets or set the current video mode for the video. It can be:
  47553. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47554. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47555. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47556. */
  47557. videoMode: number;
  47558. /**
  47559. * Oberserver used in Stereoscopic VR Mode.
  47560. */
  47561. private _onBeforeCameraRenderObserver;
  47562. /**
  47563. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47564. * @param name Element's name, child elements will append suffixes for their own names.
  47565. * @param urlsOrVideo defines the url(s) or the video element to use
  47566. * @param options An object containing optional or exposed sub element properties
  47567. */
  47568. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47569. resolution?: number;
  47570. clickToPlay?: boolean;
  47571. autoPlay?: boolean;
  47572. loop?: boolean;
  47573. size?: number;
  47574. poster?: string;
  47575. faceForward?: boolean;
  47576. useDirectMapping?: boolean;
  47577. }, scene: Scene);
  47578. private _changeVideoMode;
  47579. /**
  47580. * Releases resources associated with this node.
  47581. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47582. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47583. */
  47584. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47585. }
  47586. }
  47587. declare module BABYLON {
  47588. /**
  47589. * This class can be used to get instrumentation data from a Babylon engine
  47590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47591. */
  47592. export class EngineInstrumentation implements IDisposable {
  47593. /**
  47594. * Define the instrumented engine.
  47595. */
  47596. engine: Engine;
  47597. private _captureGPUFrameTime;
  47598. private _gpuFrameTimeToken;
  47599. private _gpuFrameTime;
  47600. private _captureShaderCompilationTime;
  47601. private _shaderCompilationTime;
  47602. private _onBeginFrameObserver;
  47603. private _onEndFrameObserver;
  47604. private _onBeforeShaderCompilationObserver;
  47605. private _onAfterShaderCompilationObserver;
  47606. /**
  47607. * Gets the perf counter used for GPU frame time
  47608. */
  47609. readonly gpuFrameTimeCounter: PerfCounter;
  47610. /**
  47611. * Gets the GPU frame time capture status
  47612. */
  47613. /**
  47614. * Enable or disable the GPU frame time capture
  47615. */
  47616. captureGPUFrameTime: boolean;
  47617. /**
  47618. * Gets the perf counter used for shader compilation time
  47619. */
  47620. readonly shaderCompilationTimeCounter: PerfCounter;
  47621. /**
  47622. * Gets the shader compilation time capture status
  47623. */
  47624. /**
  47625. * Enable or disable the shader compilation time capture
  47626. */
  47627. captureShaderCompilationTime: boolean;
  47628. /**
  47629. * Instantiates a new engine instrumentation.
  47630. * This class can be used to get instrumentation data from a Babylon engine
  47631. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47632. * @param engine Defines the engine to instrument
  47633. */
  47634. constructor(
  47635. /**
  47636. * Define the instrumented engine.
  47637. */
  47638. engine: Engine);
  47639. /**
  47640. * Dispose and release associated resources.
  47641. */
  47642. dispose(): void;
  47643. }
  47644. }
  47645. declare module BABYLON {
  47646. /**
  47647. * This class can be used to get instrumentation data from a Babylon engine
  47648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47649. */
  47650. export class SceneInstrumentation implements IDisposable {
  47651. /**
  47652. * Defines the scene to instrument
  47653. */
  47654. scene: Scene;
  47655. private _captureActiveMeshesEvaluationTime;
  47656. private _activeMeshesEvaluationTime;
  47657. private _captureRenderTargetsRenderTime;
  47658. private _renderTargetsRenderTime;
  47659. private _captureFrameTime;
  47660. private _frameTime;
  47661. private _captureRenderTime;
  47662. private _renderTime;
  47663. private _captureInterFrameTime;
  47664. private _interFrameTime;
  47665. private _captureParticlesRenderTime;
  47666. private _particlesRenderTime;
  47667. private _captureSpritesRenderTime;
  47668. private _spritesRenderTime;
  47669. private _capturePhysicsTime;
  47670. private _physicsTime;
  47671. private _captureAnimationsTime;
  47672. private _animationsTime;
  47673. private _captureCameraRenderTime;
  47674. private _cameraRenderTime;
  47675. private _onBeforeActiveMeshesEvaluationObserver;
  47676. private _onAfterActiveMeshesEvaluationObserver;
  47677. private _onBeforeRenderTargetsRenderObserver;
  47678. private _onAfterRenderTargetsRenderObserver;
  47679. private _onAfterRenderObserver;
  47680. private _onBeforeDrawPhaseObserver;
  47681. private _onAfterDrawPhaseObserver;
  47682. private _onBeforeAnimationsObserver;
  47683. private _onBeforeParticlesRenderingObserver;
  47684. private _onAfterParticlesRenderingObserver;
  47685. private _onBeforeSpritesRenderingObserver;
  47686. private _onAfterSpritesRenderingObserver;
  47687. private _onBeforePhysicsObserver;
  47688. private _onAfterPhysicsObserver;
  47689. private _onAfterAnimationsObserver;
  47690. private _onBeforeCameraRenderObserver;
  47691. private _onAfterCameraRenderObserver;
  47692. /**
  47693. * Gets the perf counter used for active meshes evaluation time
  47694. */
  47695. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47696. /**
  47697. * Gets the active meshes evaluation time capture status
  47698. */
  47699. /**
  47700. * Enable or disable the active meshes evaluation time capture
  47701. */
  47702. captureActiveMeshesEvaluationTime: boolean;
  47703. /**
  47704. * Gets the perf counter used for render targets render time
  47705. */
  47706. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47707. /**
  47708. * Gets the render targets render time capture status
  47709. */
  47710. /**
  47711. * Enable or disable the render targets render time capture
  47712. */
  47713. captureRenderTargetsRenderTime: boolean;
  47714. /**
  47715. * Gets the perf counter used for particles render time
  47716. */
  47717. readonly particlesRenderTimeCounter: PerfCounter;
  47718. /**
  47719. * Gets the particles render time capture status
  47720. */
  47721. /**
  47722. * Enable or disable the particles render time capture
  47723. */
  47724. captureParticlesRenderTime: boolean;
  47725. /**
  47726. * Gets the perf counter used for sprites render time
  47727. */
  47728. readonly spritesRenderTimeCounter: PerfCounter;
  47729. /**
  47730. * Gets the sprites render time capture status
  47731. */
  47732. /**
  47733. * Enable or disable the sprites render time capture
  47734. */
  47735. captureSpritesRenderTime: boolean;
  47736. /**
  47737. * Gets the perf counter used for physics time
  47738. */
  47739. readonly physicsTimeCounter: PerfCounter;
  47740. /**
  47741. * Gets the physics time capture status
  47742. */
  47743. /**
  47744. * Enable or disable the physics time capture
  47745. */
  47746. capturePhysicsTime: boolean;
  47747. /**
  47748. * Gets the perf counter used for animations time
  47749. */
  47750. readonly animationsTimeCounter: PerfCounter;
  47751. /**
  47752. * Gets the animations time capture status
  47753. */
  47754. /**
  47755. * Enable or disable the animations time capture
  47756. */
  47757. captureAnimationsTime: boolean;
  47758. /**
  47759. * Gets the perf counter used for frame time capture
  47760. */
  47761. readonly frameTimeCounter: PerfCounter;
  47762. /**
  47763. * Gets the frame time capture status
  47764. */
  47765. /**
  47766. * Enable or disable the frame time capture
  47767. */
  47768. captureFrameTime: boolean;
  47769. /**
  47770. * Gets the perf counter used for inter-frames time capture
  47771. */
  47772. readonly interFrameTimeCounter: PerfCounter;
  47773. /**
  47774. * Gets the inter-frames time capture status
  47775. */
  47776. /**
  47777. * Enable or disable the inter-frames time capture
  47778. */
  47779. captureInterFrameTime: boolean;
  47780. /**
  47781. * Gets the perf counter used for render time capture
  47782. */
  47783. readonly renderTimeCounter: PerfCounter;
  47784. /**
  47785. * Gets the render time capture status
  47786. */
  47787. /**
  47788. * Enable or disable the render time capture
  47789. */
  47790. captureRenderTime: boolean;
  47791. /**
  47792. * Gets the perf counter used for camera render time capture
  47793. */
  47794. readonly cameraRenderTimeCounter: PerfCounter;
  47795. /**
  47796. * Gets the camera render time capture status
  47797. */
  47798. /**
  47799. * Enable or disable the camera render time capture
  47800. */
  47801. captureCameraRenderTime: boolean;
  47802. /**
  47803. * Gets the perf counter used for draw calls
  47804. */
  47805. readonly drawCallsCounter: PerfCounter;
  47806. /**
  47807. * Instantiates a new scene instrumentation.
  47808. * This class can be used to get instrumentation data from a Babylon engine
  47809. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47810. * @param scene Defines the scene to instrument
  47811. */
  47812. constructor(
  47813. /**
  47814. * Defines the scene to instrument
  47815. */
  47816. scene: Scene);
  47817. /**
  47818. * Dispose and release associated resources.
  47819. */
  47820. dispose(): void;
  47821. }
  47822. }
  47823. declare module BABYLON {
  47824. /** @hidden */
  47825. export var glowMapGenerationPixelShader: {
  47826. name: string;
  47827. shader: string;
  47828. };
  47829. }
  47830. declare module BABYLON {
  47831. /** @hidden */
  47832. export var glowMapGenerationVertexShader: {
  47833. name: string;
  47834. shader: string;
  47835. };
  47836. }
  47837. declare module BABYLON {
  47838. /**
  47839. * Effect layer options. This helps customizing the behaviour
  47840. * of the effect layer.
  47841. */
  47842. export interface IEffectLayerOptions {
  47843. /**
  47844. * Multiplication factor apply to the canvas size to compute the render target size
  47845. * used to generated the objects (the smaller the faster).
  47846. */
  47847. mainTextureRatio: number;
  47848. /**
  47849. * Enforces a fixed size texture to ensure effect stability across devices.
  47850. */
  47851. mainTextureFixedSize?: number;
  47852. /**
  47853. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47854. */
  47855. alphaBlendingMode: number;
  47856. /**
  47857. * The camera attached to the layer.
  47858. */
  47859. camera: Nullable<Camera>;
  47860. /**
  47861. * The rendering group to draw the layer in.
  47862. */
  47863. renderingGroupId: number;
  47864. }
  47865. /**
  47866. * The effect layer Helps adding post process effect blended with the main pass.
  47867. *
  47868. * This can be for instance use to generate glow or higlight effects on the scene.
  47869. *
  47870. * The effect layer class can not be used directly and is intented to inherited from to be
  47871. * customized per effects.
  47872. */
  47873. export abstract class EffectLayer {
  47874. private _vertexBuffers;
  47875. private _indexBuffer;
  47876. private _cachedDefines;
  47877. private _effectLayerMapGenerationEffect;
  47878. private _effectLayerOptions;
  47879. private _mergeEffect;
  47880. protected _scene: Scene;
  47881. protected _engine: Engine;
  47882. protected _maxSize: number;
  47883. protected _mainTextureDesiredSize: ISize;
  47884. protected _mainTexture: RenderTargetTexture;
  47885. protected _shouldRender: boolean;
  47886. protected _postProcesses: PostProcess[];
  47887. protected _textures: BaseTexture[];
  47888. protected _emissiveTextureAndColor: {
  47889. texture: Nullable<BaseTexture>;
  47890. color: Color4;
  47891. };
  47892. /**
  47893. * The name of the layer
  47894. */
  47895. name: string;
  47896. /**
  47897. * The clear color of the texture used to generate the glow map.
  47898. */
  47899. neutralColor: Color4;
  47900. /**
  47901. * Specifies wether the highlight layer is enabled or not.
  47902. */
  47903. isEnabled: boolean;
  47904. /**
  47905. * Gets the camera attached to the layer.
  47906. */
  47907. readonly camera: Nullable<Camera>;
  47908. /**
  47909. * Gets the rendering group id the layer should render in.
  47910. */
  47911. renderingGroupId: number;
  47912. /**
  47913. * An event triggered when the effect layer has been disposed.
  47914. */
  47915. onDisposeObservable: Observable<EffectLayer>;
  47916. /**
  47917. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47918. */
  47919. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47920. /**
  47921. * An event triggered when the generated texture is being merged in the scene.
  47922. */
  47923. onBeforeComposeObservable: Observable<EffectLayer>;
  47924. /**
  47925. * An event triggered when the generated texture has been merged in the scene.
  47926. */
  47927. onAfterComposeObservable: Observable<EffectLayer>;
  47928. /**
  47929. * An event triggered when the efffect layer changes its size.
  47930. */
  47931. onSizeChangedObservable: Observable<EffectLayer>;
  47932. /** @hidden */
  47933. static _SceneComponentInitialization: (scene: Scene) => void;
  47934. /**
  47935. * Instantiates a new effect Layer and references it in the scene.
  47936. * @param name The name of the layer
  47937. * @param scene The scene to use the layer in
  47938. */
  47939. constructor(
  47940. /** The Friendly of the effect in the scene */
  47941. name: string, scene: Scene);
  47942. /**
  47943. * Get the effect name of the layer.
  47944. * @return The effect name
  47945. */
  47946. abstract getEffectName(): string;
  47947. /**
  47948. * Checks for the readiness of the element composing the layer.
  47949. * @param subMesh the mesh to check for
  47950. * @param useInstances specify wether or not to use instances to render the mesh
  47951. * @return true if ready otherwise, false
  47952. */
  47953. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47954. /**
  47955. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47956. * @returns true if the effect requires stencil during the main canvas render pass.
  47957. */
  47958. abstract needStencil(): boolean;
  47959. /**
  47960. * Create the merge effect. This is the shader use to blit the information back
  47961. * to the main canvas at the end of the scene rendering.
  47962. * @returns The effect containing the shader used to merge the effect on the main canvas
  47963. */
  47964. protected abstract _createMergeEffect(): Effect;
  47965. /**
  47966. * Creates the render target textures and post processes used in the effect layer.
  47967. */
  47968. protected abstract _createTextureAndPostProcesses(): void;
  47969. /**
  47970. * Implementation specific of rendering the generating effect on the main canvas.
  47971. * @param effect The effect used to render through
  47972. */
  47973. protected abstract _internalRender(effect: Effect): void;
  47974. /**
  47975. * Sets the required values for both the emissive texture and and the main color.
  47976. */
  47977. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47978. /**
  47979. * Free any resources and references associated to a mesh.
  47980. * Internal use
  47981. * @param mesh The mesh to free.
  47982. */
  47983. abstract _disposeMesh(mesh: Mesh): void;
  47984. /**
  47985. * Serializes this layer (Glow or Highlight for example)
  47986. * @returns a serialized layer object
  47987. */
  47988. abstract serialize?(): any;
  47989. /**
  47990. * Initializes the effect layer with the required options.
  47991. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47992. */
  47993. protected _init(options: Partial<IEffectLayerOptions>): void;
  47994. /**
  47995. * Generates the index buffer of the full screen quad blending to the main canvas.
  47996. */
  47997. private _generateIndexBuffer;
  47998. /**
  47999. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48000. */
  48001. private _generateVertexBuffer;
  48002. /**
  48003. * Sets the main texture desired size which is the closest power of two
  48004. * of the engine canvas size.
  48005. */
  48006. private _setMainTextureSize;
  48007. /**
  48008. * Creates the main texture for the effect layer.
  48009. */
  48010. protected _createMainTexture(): void;
  48011. /**
  48012. * Adds specific effects defines.
  48013. * @param defines The defines to add specifics to.
  48014. */
  48015. protected _addCustomEffectDefines(defines: string[]): void;
  48016. /**
  48017. * Checks for the readiness of the element composing the layer.
  48018. * @param subMesh the mesh to check for
  48019. * @param useInstances specify wether or not to use instances to render the mesh
  48020. * @param emissiveTexture the associated emissive texture used to generate the glow
  48021. * @return true if ready otherwise, false
  48022. */
  48023. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48024. /**
  48025. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48026. */
  48027. render(): void;
  48028. /**
  48029. * Determine if a given mesh will be used in the current effect.
  48030. * @param mesh mesh to test
  48031. * @returns true if the mesh will be used
  48032. */
  48033. hasMesh(mesh: AbstractMesh): boolean;
  48034. /**
  48035. * Returns true if the layer contains information to display, otherwise false.
  48036. * @returns true if the glow layer should be rendered
  48037. */
  48038. shouldRender(): boolean;
  48039. /**
  48040. * Returns true if the mesh should render, otherwise false.
  48041. * @param mesh The mesh to render
  48042. * @returns true if it should render otherwise false
  48043. */
  48044. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48045. /**
  48046. * Returns true if the mesh can be rendered, otherwise false.
  48047. * @param mesh The mesh to render
  48048. * @param material The material used on the mesh
  48049. * @returns true if it can be rendered otherwise false
  48050. */
  48051. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48052. /**
  48053. * Returns true if the mesh should render, otherwise false.
  48054. * @param mesh The mesh to render
  48055. * @returns true if it should render otherwise false
  48056. */
  48057. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48058. /**
  48059. * Renders the submesh passed in parameter to the generation map.
  48060. */
  48061. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48062. /**
  48063. * Rebuild the required buffers.
  48064. * @hidden Internal use only.
  48065. */
  48066. _rebuild(): void;
  48067. /**
  48068. * Dispose only the render target textures and post process.
  48069. */
  48070. private _disposeTextureAndPostProcesses;
  48071. /**
  48072. * Dispose the highlight layer and free resources.
  48073. */
  48074. dispose(): void;
  48075. /**
  48076. * Gets the class name of the effect layer
  48077. * @returns the string with the class name of the effect layer
  48078. */
  48079. getClassName(): string;
  48080. /**
  48081. * Creates an effect layer from parsed effect layer data
  48082. * @param parsedEffectLayer defines effect layer data
  48083. * @param scene defines the current scene
  48084. * @param rootUrl defines the root URL containing the effect layer information
  48085. * @returns a parsed effect Layer
  48086. */
  48087. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48088. }
  48089. }
  48090. declare module BABYLON {
  48091. interface AbstractScene {
  48092. /**
  48093. * The list of effect layers (highlights/glow) added to the scene
  48094. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48095. * @see http://doc.babylonjs.com/how_to/glow_layer
  48096. */
  48097. effectLayers: Array<EffectLayer>;
  48098. /**
  48099. * Removes the given effect layer from this scene.
  48100. * @param toRemove defines the effect layer to remove
  48101. * @returns the index of the removed effect layer
  48102. */
  48103. removeEffectLayer(toRemove: EffectLayer): number;
  48104. /**
  48105. * Adds the given effect layer to this scene
  48106. * @param newEffectLayer defines the effect layer to add
  48107. */
  48108. addEffectLayer(newEffectLayer: EffectLayer): void;
  48109. }
  48110. /**
  48111. * Defines the layer scene component responsible to manage any effect layers
  48112. * in a given scene.
  48113. */
  48114. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48115. /**
  48116. * The component name helpfull to identify the component in the list of scene components.
  48117. */
  48118. readonly name: string;
  48119. /**
  48120. * The scene the component belongs to.
  48121. */
  48122. scene: Scene;
  48123. private _engine;
  48124. private _renderEffects;
  48125. private _needStencil;
  48126. private _previousStencilState;
  48127. /**
  48128. * Creates a new instance of the component for the given scene
  48129. * @param scene Defines the scene to register the component in
  48130. */
  48131. constructor(scene: Scene);
  48132. /**
  48133. * Registers the component in a given scene
  48134. */
  48135. register(): void;
  48136. /**
  48137. * Rebuilds the elements related to this component in case of
  48138. * context lost for instance.
  48139. */
  48140. rebuild(): void;
  48141. /**
  48142. * Serializes the component data to the specified json object
  48143. * @param serializationObject The object to serialize to
  48144. */
  48145. serialize(serializationObject: any): void;
  48146. /**
  48147. * Adds all the elements from the container to the scene
  48148. * @param container the container holding the elements
  48149. */
  48150. addFromContainer(container: AbstractScene): void;
  48151. /**
  48152. * Removes all the elements in the container from the scene
  48153. * @param container contains the elements to remove
  48154. * @param dispose if the removed element should be disposed (default: false)
  48155. */
  48156. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48157. /**
  48158. * Disposes the component and the associated ressources.
  48159. */
  48160. dispose(): void;
  48161. private _isReadyForMesh;
  48162. private _renderMainTexture;
  48163. private _setStencil;
  48164. private _setStencilBack;
  48165. private _draw;
  48166. private _drawCamera;
  48167. private _drawRenderingGroup;
  48168. }
  48169. }
  48170. declare module BABYLON {
  48171. /** @hidden */
  48172. export var glowMapMergePixelShader: {
  48173. name: string;
  48174. shader: string;
  48175. };
  48176. }
  48177. declare module BABYLON {
  48178. /** @hidden */
  48179. export var glowMapMergeVertexShader: {
  48180. name: string;
  48181. shader: string;
  48182. };
  48183. }
  48184. declare module BABYLON {
  48185. interface AbstractScene {
  48186. /**
  48187. * Return a the first highlight layer of the scene with a given name.
  48188. * @param name The name of the highlight layer to look for.
  48189. * @return The highlight layer if found otherwise null.
  48190. */
  48191. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48192. }
  48193. /**
  48194. * Glow layer options. This helps customizing the behaviour
  48195. * of the glow layer.
  48196. */
  48197. export interface IGlowLayerOptions {
  48198. /**
  48199. * Multiplication factor apply to the canvas size to compute the render target size
  48200. * used to generated the glowing objects (the smaller the faster).
  48201. */
  48202. mainTextureRatio: number;
  48203. /**
  48204. * Enforces a fixed size texture to ensure resize independant blur.
  48205. */
  48206. mainTextureFixedSize?: number;
  48207. /**
  48208. * How big is the kernel of the blur texture.
  48209. */
  48210. blurKernelSize: number;
  48211. /**
  48212. * The camera attached to the layer.
  48213. */
  48214. camera: Nullable<Camera>;
  48215. /**
  48216. * Enable MSAA by chosing the number of samples.
  48217. */
  48218. mainTextureSamples?: number;
  48219. /**
  48220. * The rendering group to draw the layer in.
  48221. */
  48222. renderingGroupId: number;
  48223. }
  48224. /**
  48225. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48226. *
  48227. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48228. * glowy meshes to your scene.
  48229. *
  48230. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48231. */
  48232. export class GlowLayer extends EffectLayer {
  48233. /**
  48234. * Effect Name of the layer.
  48235. */
  48236. static readonly EffectName: string;
  48237. /**
  48238. * The default blur kernel size used for the glow.
  48239. */
  48240. static DefaultBlurKernelSize: number;
  48241. /**
  48242. * The default texture size ratio used for the glow.
  48243. */
  48244. static DefaultTextureRatio: number;
  48245. /**
  48246. * Sets the kernel size of the blur.
  48247. */
  48248. /**
  48249. * Gets the kernel size of the blur.
  48250. */
  48251. blurKernelSize: number;
  48252. /**
  48253. * Sets the glow intensity.
  48254. */
  48255. /**
  48256. * Gets the glow intensity.
  48257. */
  48258. intensity: number;
  48259. private _options;
  48260. private _intensity;
  48261. private _horizontalBlurPostprocess1;
  48262. private _verticalBlurPostprocess1;
  48263. private _horizontalBlurPostprocess2;
  48264. private _verticalBlurPostprocess2;
  48265. private _blurTexture1;
  48266. private _blurTexture2;
  48267. private _postProcesses1;
  48268. private _postProcesses2;
  48269. private _includedOnlyMeshes;
  48270. private _excludedMeshes;
  48271. /**
  48272. * Callback used to let the user override the color selection on a per mesh basis
  48273. */
  48274. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48275. /**
  48276. * Callback used to let the user override the texture selection on a per mesh basis
  48277. */
  48278. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48279. /**
  48280. * Instantiates a new glow Layer and references it to the scene.
  48281. * @param name The name of the layer
  48282. * @param scene The scene to use the layer in
  48283. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48284. */
  48285. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48286. /**
  48287. * Get the effect name of the layer.
  48288. * @return The effect name
  48289. */
  48290. getEffectName(): string;
  48291. /**
  48292. * Create the merge effect. This is the shader use to blit the information back
  48293. * to the main canvas at the end of the scene rendering.
  48294. */
  48295. protected _createMergeEffect(): Effect;
  48296. /**
  48297. * Creates the render target textures and post processes used in the glow layer.
  48298. */
  48299. protected _createTextureAndPostProcesses(): void;
  48300. /**
  48301. * Checks for the readiness of the element composing the layer.
  48302. * @param subMesh the mesh to check for
  48303. * @param useInstances specify wether or not to use instances to render the mesh
  48304. * @param emissiveTexture the associated emissive texture used to generate the glow
  48305. * @return true if ready otherwise, false
  48306. */
  48307. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48308. /**
  48309. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48310. */
  48311. needStencil(): boolean;
  48312. /**
  48313. * Returns true if the mesh can be rendered, otherwise false.
  48314. * @param mesh The mesh to render
  48315. * @param material The material used on the mesh
  48316. * @returns true if it can be rendered otherwise false
  48317. */
  48318. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48319. /**
  48320. * Implementation specific of rendering the generating effect on the main canvas.
  48321. * @param effect The effect used to render through
  48322. */
  48323. protected _internalRender(effect: Effect): void;
  48324. /**
  48325. * Sets the required values for both the emissive texture and and the main color.
  48326. */
  48327. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48328. /**
  48329. * Returns true if the mesh should render, otherwise false.
  48330. * @param mesh The mesh to render
  48331. * @returns true if it should render otherwise false
  48332. */
  48333. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48334. /**
  48335. * Adds specific effects defines.
  48336. * @param defines The defines to add specifics to.
  48337. */
  48338. protected _addCustomEffectDefines(defines: string[]): void;
  48339. /**
  48340. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48341. * @param mesh The mesh to exclude from the glow layer
  48342. */
  48343. addExcludedMesh(mesh: Mesh): void;
  48344. /**
  48345. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48346. * @param mesh The mesh to remove
  48347. */
  48348. removeExcludedMesh(mesh: Mesh): void;
  48349. /**
  48350. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48351. * @param mesh The mesh to include in the glow layer
  48352. */
  48353. addIncludedOnlyMesh(mesh: Mesh): void;
  48354. /**
  48355. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48356. * @param mesh The mesh to remove
  48357. */
  48358. removeIncludedOnlyMesh(mesh: Mesh): void;
  48359. /**
  48360. * Determine if a given mesh will be used in the glow layer
  48361. * @param mesh The mesh to test
  48362. * @returns true if the mesh will be highlighted by the current glow layer
  48363. */
  48364. hasMesh(mesh: AbstractMesh): boolean;
  48365. /**
  48366. * Free any resources and references associated to a mesh.
  48367. * Internal use
  48368. * @param mesh The mesh to free.
  48369. * @hidden
  48370. */
  48371. _disposeMesh(mesh: Mesh): void;
  48372. /**
  48373. * Gets the class name of the effect layer
  48374. * @returns the string with the class name of the effect layer
  48375. */
  48376. getClassName(): string;
  48377. /**
  48378. * Serializes this glow layer
  48379. * @returns a serialized glow layer object
  48380. */
  48381. serialize(): any;
  48382. /**
  48383. * Creates a Glow Layer from parsed glow layer data
  48384. * @param parsedGlowLayer defines glow layer data
  48385. * @param scene defines the current scene
  48386. * @param rootUrl defines the root URL containing the glow layer information
  48387. * @returns a parsed Glow Layer
  48388. */
  48389. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48390. }
  48391. }
  48392. declare module BABYLON {
  48393. /** @hidden */
  48394. export var glowBlurPostProcessPixelShader: {
  48395. name: string;
  48396. shader: string;
  48397. };
  48398. }
  48399. declare module BABYLON {
  48400. interface AbstractScene {
  48401. /**
  48402. * Return a the first highlight layer of the scene with a given name.
  48403. * @param name The name of the highlight layer to look for.
  48404. * @return The highlight layer if found otherwise null.
  48405. */
  48406. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48407. }
  48408. /**
  48409. * Highlight layer options. This helps customizing the behaviour
  48410. * of the highlight layer.
  48411. */
  48412. export interface IHighlightLayerOptions {
  48413. /**
  48414. * Multiplication factor apply to the canvas size to compute the render target size
  48415. * used to generated the glowing objects (the smaller the faster).
  48416. */
  48417. mainTextureRatio: number;
  48418. /**
  48419. * Enforces a fixed size texture to ensure resize independant blur.
  48420. */
  48421. mainTextureFixedSize?: number;
  48422. /**
  48423. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48424. * of the picture to blur (the smaller the faster).
  48425. */
  48426. blurTextureSizeRatio: number;
  48427. /**
  48428. * How big in texel of the blur texture is the vertical blur.
  48429. */
  48430. blurVerticalSize: number;
  48431. /**
  48432. * How big in texel of the blur texture is the horizontal blur.
  48433. */
  48434. blurHorizontalSize: number;
  48435. /**
  48436. * Alpha blending mode used to apply the blur. Default is combine.
  48437. */
  48438. alphaBlendingMode: number;
  48439. /**
  48440. * The camera attached to the layer.
  48441. */
  48442. camera: Nullable<Camera>;
  48443. /**
  48444. * Should we display highlight as a solid stroke?
  48445. */
  48446. isStroke?: boolean;
  48447. /**
  48448. * The rendering group to draw the layer in.
  48449. */
  48450. renderingGroupId: number;
  48451. }
  48452. /**
  48453. * The highlight layer Helps adding a glow effect around a mesh.
  48454. *
  48455. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48456. * glowy meshes to your scene.
  48457. *
  48458. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48459. */
  48460. export class HighlightLayer extends EffectLayer {
  48461. name: string;
  48462. /**
  48463. * Effect Name of the highlight layer.
  48464. */
  48465. static readonly EffectName: string;
  48466. /**
  48467. * The neutral color used during the preparation of the glow effect.
  48468. * This is black by default as the blend operation is a blend operation.
  48469. */
  48470. static NeutralColor: Color4;
  48471. /**
  48472. * Stencil value used for glowing meshes.
  48473. */
  48474. static GlowingMeshStencilReference: number;
  48475. /**
  48476. * Stencil value used for the other meshes in the scene.
  48477. */
  48478. static NormalMeshStencilReference: number;
  48479. /**
  48480. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48481. */
  48482. innerGlow: boolean;
  48483. /**
  48484. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48485. */
  48486. outerGlow: boolean;
  48487. /**
  48488. * Specifies the horizontal size of the blur.
  48489. */
  48490. /**
  48491. * Gets the horizontal size of the blur.
  48492. */
  48493. blurHorizontalSize: number;
  48494. /**
  48495. * Specifies the vertical size of the blur.
  48496. */
  48497. /**
  48498. * Gets the vertical size of the blur.
  48499. */
  48500. blurVerticalSize: number;
  48501. /**
  48502. * An event triggered when the highlight layer is being blurred.
  48503. */
  48504. onBeforeBlurObservable: Observable<HighlightLayer>;
  48505. /**
  48506. * An event triggered when the highlight layer has been blurred.
  48507. */
  48508. onAfterBlurObservable: Observable<HighlightLayer>;
  48509. private _instanceGlowingMeshStencilReference;
  48510. private _options;
  48511. private _downSamplePostprocess;
  48512. private _horizontalBlurPostprocess;
  48513. private _verticalBlurPostprocess;
  48514. private _blurTexture;
  48515. private _meshes;
  48516. private _excludedMeshes;
  48517. /**
  48518. * Instantiates a new highlight Layer and references it to the scene..
  48519. * @param name The name of the layer
  48520. * @param scene The scene to use the layer in
  48521. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48522. */
  48523. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48524. /**
  48525. * Get the effect name of the layer.
  48526. * @return The effect name
  48527. */
  48528. getEffectName(): string;
  48529. /**
  48530. * Create the merge effect. This is the shader use to blit the information back
  48531. * to the main canvas at the end of the scene rendering.
  48532. */
  48533. protected _createMergeEffect(): Effect;
  48534. /**
  48535. * Creates the render target textures and post processes used in the highlight layer.
  48536. */
  48537. protected _createTextureAndPostProcesses(): void;
  48538. /**
  48539. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48540. */
  48541. needStencil(): boolean;
  48542. /**
  48543. * Checks for the readiness of the element composing the layer.
  48544. * @param subMesh the mesh to check for
  48545. * @param useInstances specify wether or not to use instances to render the mesh
  48546. * @param emissiveTexture the associated emissive texture used to generate the glow
  48547. * @return true if ready otherwise, false
  48548. */
  48549. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48550. /**
  48551. * Implementation specific of rendering the generating effect on the main canvas.
  48552. * @param effect The effect used to render through
  48553. */
  48554. protected _internalRender(effect: Effect): void;
  48555. /**
  48556. * Returns true if the layer contains information to display, otherwise false.
  48557. */
  48558. shouldRender(): boolean;
  48559. /**
  48560. * Returns true if the mesh should render, otherwise false.
  48561. * @param mesh The mesh to render
  48562. * @returns true if it should render otherwise false
  48563. */
  48564. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48565. /**
  48566. * Sets the required values for both the emissive texture and and the main color.
  48567. */
  48568. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48569. /**
  48570. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48571. * @param mesh The mesh to exclude from the highlight layer
  48572. */
  48573. addExcludedMesh(mesh: Mesh): void;
  48574. /**
  48575. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48576. * @param mesh The mesh to highlight
  48577. */
  48578. removeExcludedMesh(mesh: Mesh): void;
  48579. /**
  48580. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48581. * @param mesh mesh to test
  48582. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48583. */
  48584. hasMesh(mesh: AbstractMesh): boolean;
  48585. /**
  48586. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48587. * @param mesh The mesh to highlight
  48588. * @param color The color of the highlight
  48589. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48590. */
  48591. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48592. /**
  48593. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48594. * @param mesh The mesh to highlight
  48595. */
  48596. removeMesh(mesh: Mesh): void;
  48597. /**
  48598. * Force the stencil to the normal expected value for none glowing parts
  48599. */
  48600. private _defaultStencilReference;
  48601. /**
  48602. * Free any resources and references associated to a mesh.
  48603. * Internal use
  48604. * @param mesh The mesh to free.
  48605. * @hidden
  48606. */
  48607. _disposeMesh(mesh: Mesh): void;
  48608. /**
  48609. * Dispose the highlight layer and free resources.
  48610. */
  48611. dispose(): void;
  48612. /**
  48613. * Gets the class name of the effect layer
  48614. * @returns the string with the class name of the effect layer
  48615. */
  48616. getClassName(): string;
  48617. /**
  48618. * Serializes this Highlight layer
  48619. * @returns a serialized Highlight layer object
  48620. */
  48621. serialize(): any;
  48622. /**
  48623. * Creates a Highlight layer from parsed Highlight layer data
  48624. * @param parsedHightlightLayer defines the Highlight layer data
  48625. * @param scene defines the current scene
  48626. * @param rootUrl defines the root URL containing the Highlight layer information
  48627. * @returns a parsed Highlight layer
  48628. */
  48629. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48630. }
  48631. }
  48632. declare module BABYLON {
  48633. interface AbstractScene {
  48634. /**
  48635. * The list of layers (background and foreground) of the scene
  48636. */
  48637. layers: Array<Layer>;
  48638. }
  48639. /**
  48640. * Defines the layer scene component responsible to manage any layers
  48641. * in a given scene.
  48642. */
  48643. export class LayerSceneComponent implements ISceneComponent {
  48644. /**
  48645. * The component name helpfull to identify the component in the list of scene components.
  48646. */
  48647. readonly name: string;
  48648. /**
  48649. * The scene the component belongs to.
  48650. */
  48651. scene: Scene;
  48652. private _engine;
  48653. /**
  48654. * Creates a new instance of the component for the given scene
  48655. * @param scene Defines the scene to register the component in
  48656. */
  48657. constructor(scene: Scene);
  48658. /**
  48659. * Registers the component in a given scene
  48660. */
  48661. register(): void;
  48662. /**
  48663. * Rebuilds the elements related to this component in case of
  48664. * context lost for instance.
  48665. */
  48666. rebuild(): void;
  48667. /**
  48668. * Disposes the component and the associated ressources.
  48669. */
  48670. dispose(): void;
  48671. private _draw;
  48672. private _drawCameraPredicate;
  48673. private _drawCameraBackground;
  48674. private _drawCameraForeground;
  48675. private _drawRenderTargetPredicate;
  48676. private _drawRenderTargetBackground;
  48677. private _drawRenderTargetForeground;
  48678. /**
  48679. * Adds all the elements from the container to the scene
  48680. * @param container the container holding the elements
  48681. */
  48682. addFromContainer(container: AbstractScene): void;
  48683. /**
  48684. * Removes all the elements in the container from the scene
  48685. * @param container contains the elements to remove
  48686. * @param dispose if the removed element should be disposed (default: false)
  48687. */
  48688. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48689. }
  48690. }
  48691. declare module BABYLON {
  48692. /** @hidden */
  48693. export var layerPixelShader: {
  48694. name: string;
  48695. shader: string;
  48696. };
  48697. }
  48698. declare module BABYLON {
  48699. /** @hidden */
  48700. export var layerVertexShader: {
  48701. name: string;
  48702. shader: string;
  48703. };
  48704. }
  48705. declare module BABYLON {
  48706. /**
  48707. * This represents a full screen 2d layer.
  48708. * This can be useful to display a picture in the background of your scene for instance.
  48709. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48710. */
  48711. export class Layer {
  48712. /**
  48713. * Define the name of the layer.
  48714. */
  48715. name: string;
  48716. /**
  48717. * Define the texture the layer should display.
  48718. */
  48719. texture: Nullable<Texture>;
  48720. /**
  48721. * Is the layer in background or foreground.
  48722. */
  48723. isBackground: boolean;
  48724. /**
  48725. * Define the color of the layer (instead of texture).
  48726. */
  48727. color: Color4;
  48728. /**
  48729. * Define the scale of the layer in order to zoom in out of the texture.
  48730. */
  48731. scale: Vector2;
  48732. /**
  48733. * Define an offset for the layer in order to shift the texture.
  48734. */
  48735. offset: Vector2;
  48736. /**
  48737. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48738. */
  48739. alphaBlendingMode: number;
  48740. /**
  48741. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48742. * Alpha test will not mix with the background color in case of transparency.
  48743. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48744. */
  48745. alphaTest: boolean;
  48746. /**
  48747. * Define a mask to restrict the layer to only some of the scene cameras.
  48748. */
  48749. layerMask: number;
  48750. /**
  48751. * Define the list of render target the layer is visible into.
  48752. */
  48753. renderTargetTextures: RenderTargetTexture[];
  48754. /**
  48755. * Define if the layer is only used in renderTarget or if it also
  48756. * renders in the main frame buffer of the canvas.
  48757. */
  48758. renderOnlyInRenderTargetTextures: boolean;
  48759. private _scene;
  48760. private _vertexBuffers;
  48761. private _indexBuffer;
  48762. private _effect;
  48763. private _alphaTestEffect;
  48764. /**
  48765. * An event triggered when the layer is disposed.
  48766. */
  48767. onDisposeObservable: Observable<Layer>;
  48768. private _onDisposeObserver;
  48769. /**
  48770. * Back compatibility with callback before the onDisposeObservable existed.
  48771. * The set callback will be triggered when the layer has been disposed.
  48772. */
  48773. onDispose: () => void;
  48774. /**
  48775. * An event triggered before rendering the scene
  48776. */
  48777. onBeforeRenderObservable: Observable<Layer>;
  48778. private _onBeforeRenderObserver;
  48779. /**
  48780. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48781. * The set callback will be triggered just before rendering the layer.
  48782. */
  48783. onBeforeRender: () => void;
  48784. /**
  48785. * An event triggered after rendering the scene
  48786. */
  48787. onAfterRenderObservable: Observable<Layer>;
  48788. private _onAfterRenderObserver;
  48789. /**
  48790. * Back compatibility with callback before the onAfterRenderObservable existed.
  48791. * The set callback will be triggered just after rendering the layer.
  48792. */
  48793. onAfterRender: () => void;
  48794. /**
  48795. * Instantiates a new layer.
  48796. * This represents a full screen 2d layer.
  48797. * This can be useful to display a picture in the background of your scene for instance.
  48798. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48799. * @param name Define the name of the layer in the scene
  48800. * @param imgUrl Define the url of the texture to display in the layer
  48801. * @param scene Define the scene the layer belongs to
  48802. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48803. * @param color Defines a color for the layer
  48804. */
  48805. constructor(
  48806. /**
  48807. * Define the name of the layer.
  48808. */
  48809. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48810. private _createIndexBuffer;
  48811. /** @hidden */
  48812. _rebuild(): void;
  48813. /**
  48814. * Renders the layer in the scene.
  48815. */
  48816. render(): void;
  48817. /**
  48818. * Disposes and releases the associated ressources.
  48819. */
  48820. dispose(): void;
  48821. }
  48822. }
  48823. declare module BABYLON {
  48824. /** @hidden */
  48825. export var lensFlarePixelShader: {
  48826. name: string;
  48827. shader: string;
  48828. };
  48829. }
  48830. declare module BABYLON {
  48831. /** @hidden */
  48832. export var lensFlareVertexShader: {
  48833. name: string;
  48834. shader: string;
  48835. };
  48836. }
  48837. declare module BABYLON {
  48838. /**
  48839. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48840. * It is usually composed of several `lensFlare`.
  48841. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48842. */
  48843. export class LensFlareSystem {
  48844. /**
  48845. * Define the name of the lens flare system
  48846. */
  48847. name: string;
  48848. /**
  48849. * List of lens flares used in this system.
  48850. */
  48851. lensFlares: LensFlare[];
  48852. /**
  48853. * Define a limit from the border the lens flare can be visible.
  48854. */
  48855. borderLimit: number;
  48856. /**
  48857. * Define a viewport border we do not want to see the lens flare in.
  48858. */
  48859. viewportBorder: number;
  48860. /**
  48861. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48862. */
  48863. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48864. /**
  48865. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48866. */
  48867. layerMask: number;
  48868. /**
  48869. * Define the id of the lens flare system in the scene.
  48870. * (equal to name by default)
  48871. */
  48872. id: string;
  48873. private _scene;
  48874. private _emitter;
  48875. private _vertexBuffers;
  48876. private _indexBuffer;
  48877. private _effect;
  48878. private _positionX;
  48879. private _positionY;
  48880. private _isEnabled;
  48881. /** @hidden */
  48882. static _SceneComponentInitialization: (scene: Scene) => void;
  48883. /**
  48884. * Instantiates a lens flare system.
  48885. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48886. * It is usually composed of several `lensFlare`.
  48887. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48888. * @param name Define the name of the lens flare system in the scene
  48889. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48890. * @param scene Define the scene the lens flare system belongs to
  48891. */
  48892. constructor(
  48893. /**
  48894. * Define the name of the lens flare system
  48895. */
  48896. name: string, emitter: any, scene: Scene);
  48897. /**
  48898. * Define if the lens flare system is enabled.
  48899. */
  48900. isEnabled: boolean;
  48901. /**
  48902. * Get the scene the effects belongs to.
  48903. * @returns the scene holding the lens flare system
  48904. */
  48905. getScene(): Scene;
  48906. /**
  48907. * Get the emitter of the lens flare system.
  48908. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48909. * @returns the emitter of the lens flare system
  48910. */
  48911. getEmitter(): any;
  48912. /**
  48913. * Set the emitter of the lens flare system.
  48914. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48915. * @param newEmitter Define the new emitter of the system
  48916. */
  48917. setEmitter(newEmitter: any): void;
  48918. /**
  48919. * Get the lens flare system emitter position.
  48920. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48921. * @returns the position
  48922. */
  48923. getEmitterPosition(): Vector3;
  48924. /**
  48925. * @hidden
  48926. */
  48927. computeEffectivePosition(globalViewport: Viewport): boolean;
  48928. /** @hidden */
  48929. _isVisible(): boolean;
  48930. /**
  48931. * @hidden
  48932. */
  48933. render(): boolean;
  48934. /**
  48935. * Dispose and release the lens flare with its associated resources.
  48936. */
  48937. dispose(): void;
  48938. /**
  48939. * Parse a lens flare system from a JSON repressentation
  48940. * @param parsedLensFlareSystem Define the JSON to parse
  48941. * @param scene Define the scene the parsed system should be instantiated in
  48942. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48943. * @returns the parsed system
  48944. */
  48945. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48946. /**
  48947. * Serialize the current Lens Flare System into a JSON representation.
  48948. * @returns the serialized JSON
  48949. */
  48950. serialize(): any;
  48951. }
  48952. }
  48953. declare module BABYLON {
  48954. /**
  48955. * This represents one of the lens effect in a `lensFlareSystem`.
  48956. * It controls one of the indiviual texture used in the effect.
  48957. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48958. */
  48959. export class LensFlare {
  48960. /**
  48961. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48962. */
  48963. size: number;
  48964. /**
  48965. * 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.
  48966. */
  48967. position: number;
  48968. /**
  48969. * Define the lens color.
  48970. */
  48971. color: Color3;
  48972. /**
  48973. * Define the lens texture.
  48974. */
  48975. texture: Nullable<Texture>;
  48976. /**
  48977. * Define the alpha mode to render this particular lens.
  48978. */
  48979. alphaMode: number;
  48980. private _system;
  48981. /**
  48982. * Creates a new Lens Flare.
  48983. * This represents one of the lens effect in a `lensFlareSystem`.
  48984. * It controls one of the indiviual texture used in the effect.
  48985. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48986. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48987. * @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.
  48988. * @param color Define the lens color
  48989. * @param imgUrl Define the lens texture url
  48990. * @param system Define the `lensFlareSystem` this flare is part of
  48991. * @returns The newly created Lens Flare
  48992. */
  48993. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48994. /**
  48995. * Instantiates a new Lens Flare.
  48996. * This represents one of the lens effect in a `lensFlareSystem`.
  48997. * It controls one of the indiviual texture used in the effect.
  48998. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48999. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49000. * @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.
  49001. * @param color Define the lens color
  49002. * @param imgUrl Define the lens texture url
  49003. * @param system Define the `lensFlareSystem` this flare is part of
  49004. */
  49005. constructor(
  49006. /**
  49007. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49008. */
  49009. size: number,
  49010. /**
  49011. * 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.
  49012. */
  49013. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49014. /**
  49015. * Dispose and release the lens flare with its associated resources.
  49016. */
  49017. dispose(): void;
  49018. }
  49019. }
  49020. declare module BABYLON {
  49021. interface AbstractScene {
  49022. /**
  49023. * The list of lens flare system added to the scene
  49024. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49025. */
  49026. lensFlareSystems: Array<LensFlareSystem>;
  49027. /**
  49028. * Removes the given lens flare system from this scene.
  49029. * @param toRemove The lens flare system to remove
  49030. * @returns The index of the removed lens flare system
  49031. */
  49032. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49033. /**
  49034. * Adds the given lens flare system to this scene
  49035. * @param newLensFlareSystem The lens flare system to add
  49036. */
  49037. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49038. /**
  49039. * Gets a lens flare system using its name
  49040. * @param name defines the name to look for
  49041. * @returns the lens flare system or null if not found
  49042. */
  49043. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49044. /**
  49045. * Gets a lens flare system using its id
  49046. * @param id defines the id to look for
  49047. * @returns the lens flare system or null if not found
  49048. */
  49049. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49050. }
  49051. /**
  49052. * Defines the lens flare scene component responsible to manage any lens flares
  49053. * in a given scene.
  49054. */
  49055. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49056. /**
  49057. * The component name helpfull to identify the component in the list of scene components.
  49058. */
  49059. readonly name: string;
  49060. /**
  49061. * The scene the component belongs to.
  49062. */
  49063. scene: Scene;
  49064. /**
  49065. * Creates a new instance of the component for the given scene
  49066. * @param scene Defines the scene to register the component in
  49067. */
  49068. constructor(scene: Scene);
  49069. /**
  49070. * Registers the component in a given scene
  49071. */
  49072. register(): void;
  49073. /**
  49074. * Rebuilds the elements related to this component in case of
  49075. * context lost for instance.
  49076. */
  49077. rebuild(): void;
  49078. /**
  49079. * Adds all the elements from the container to the scene
  49080. * @param container the container holding the elements
  49081. */
  49082. addFromContainer(container: AbstractScene): void;
  49083. /**
  49084. * Removes all the elements in the container from the scene
  49085. * @param container contains the elements to remove
  49086. * @param dispose if the removed element should be disposed (default: false)
  49087. */
  49088. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49089. /**
  49090. * Serializes the component data to the specified json object
  49091. * @param serializationObject The object to serialize to
  49092. */
  49093. serialize(serializationObject: any): void;
  49094. /**
  49095. * Disposes the component and the associated ressources.
  49096. */
  49097. dispose(): void;
  49098. private _draw;
  49099. }
  49100. }
  49101. declare module BABYLON {
  49102. /**
  49103. * Defines the shadow generator component responsible to manage any shadow generators
  49104. * in a given scene.
  49105. */
  49106. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49107. /**
  49108. * The component name helpfull to identify the component in the list of scene components.
  49109. */
  49110. readonly name: string;
  49111. /**
  49112. * The scene the component belongs to.
  49113. */
  49114. scene: Scene;
  49115. /**
  49116. * Creates a new instance of the component for the given scene
  49117. * @param scene Defines the scene to register the component in
  49118. */
  49119. constructor(scene: Scene);
  49120. /**
  49121. * Registers the component in a given scene
  49122. */
  49123. register(): void;
  49124. /**
  49125. * Rebuilds the elements related to this component in case of
  49126. * context lost for instance.
  49127. */
  49128. rebuild(): void;
  49129. /**
  49130. * Serializes the component data to the specified json object
  49131. * @param serializationObject The object to serialize to
  49132. */
  49133. serialize(serializationObject: any): void;
  49134. /**
  49135. * Adds all the elements from the container to the scene
  49136. * @param container the container holding the elements
  49137. */
  49138. addFromContainer(container: AbstractScene): void;
  49139. /**
  49140. * Removes all the elements in the container from the scene
  49141. * @param container contains the elements to remove
  49142. * @param dispose if the removed element should be disposed (default: false)
  49143. */
  49144. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49145. /**
  49146. * Rebuilds the elements related to this component in case of
  49147. * context lost for instance.
  49148. */
  49149. dispose(): void;
  49150. private _gatherRenderTargets;
  49151. }
  49152. }
  49153. declare module BABYLON {
  49154. /**
  49155. * A point light is a light defined by an unique point in world space.
  49156. * The light is emitted in every direction from this point.
  49157. * A good example of a point light is a standard light bulb.
  49158. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49159. */
  49160. export class PointLight extends ShadowLight {
  49161. private _shadowAngle;
  49162. /**
  49163. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49164. * This specifies what angle the shadow will use to be created.
  49165. *
  49166. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49167. */
  49168. /**
  49169. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49170. * This specifies what angle the shadow will use to be created.
  49171. *
  49172. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49173. */
  49174. shadowAngle: number;
  49175. /**
  49176. * Gets the direction if it has been set.
  49177. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49178. */
  49179. /**
  49180. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49181. */
  49182. direction: Vector3;
  49183. /**
  49184. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49185. * A PointLight emits the light in every direction.
  49186. * It can cast shadows.
  49187. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49188. * ```javascript
  49189. * var pointLight = new PointLight("pl", camera.position, scene);
  49190. * ```
  49191. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49192. * @param name The light friendly name
  49193. * @param position The position of the point light in the scene
  49194. * @param scene The scene the lights belongs to
  49195. */
  49196. constructor(name: string, position: Vector3, scene: Scene);
  49197. /**
  49198. * Returns the string "PointLight"
  49199. * @returns the class name
  49200. */
  49201. getClassName(): string;
  49202. /**
  49203. * Returns the integer 0.
  49204. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49205. */
  49206. getTypeID(): number;
  49207. /**
  49208. * Specifies wether or not the shadowmap should be a cube texture.
  49209. * @returns true if the shadowmap needs to be a cube texture.
  49210. */
  49211. needCube(): boolean;
  49212. /**
  49213. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49214. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49215. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49216. */
  49217. getShadowDirection(faceIndex?: number): Vector3;
  49218. /**
  49219. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49220. * - fov = PI / 2
  49221. * - aspect ratio : 1.0
  49222. * - z-near and far equal to the active camera minZ and maxZ.
  49223. * Returns the PointLight.
  49224. */
  49225. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49226. protected _buildUniformLayout(): void;
  49227. /**
  49228. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49229. * @param effect The effect to update
  49230. * @param lightIndex The index of the light in the effect to update
  49231. * @returns The point light
  49232. */
  49233. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49234. /**
  49235. * Prepares the list of defines specific to the light type.
  49236. * @param defines the list of defines
  49237. * @param lightIndex defines the index of the light for the effect
  49238. */
  49239. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49240. }
  49241. }
  49242. declare module BABYLON {
  49243. /**
  49244. * Header information of HDR texture files.
  49245. */
  49246. export interface HDRInfo {
  49247. /**
  49248. * The height of the texture in pixels.
  49249. */
  49250. height: number;
  49251. /**
  49252. * The width of the texture in pixels.
  49253. */
  49254. width: number;
  49255. /**
  49256. * The index of the beginning of the data in the binary file.
  49257. */
  49258. dataPosition: number;
  49259. }
  49260. /**
  49261. * This groups tools to convert HDR texture to native colors array.
  49262. */
  49263. export class HDRTools {
  49264. private static Ldexp;
  49265. private static Rgbe2float;
  49266. private static readStringLine;
  49267. /**
  49268. * Reads header information from an RGBE texture stored in a native array.
  49269. * More information on this format are available here:
  49270. * https://en.wikipedia.org/wiki/RGBE_image_format
  49271. *
  49272. * @param uint8array The binary file stored in native array.
  49273. * @return The header information.
  49274. */
  49275. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49276. /**
  49277. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49278. * This RGBE texture needs to store the information as a panorama.
  49279. *
  49280. * More information on this format are available here:
  49281. * https://en.wikipedia.org/wiki/RGBE_image_format
  49282. *
  49283. * @param buffer The binary file stored in an array buffer.
  49284. * @param size The expected size of the extracted cubemap.
  49285. * @return The Cube Map information.
  49286. */
  49287. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49288. /**
  49289. * Returns the pixels data extracted from an RGBE texture.
  49290. * This pixels will be stored left to right up to down in the R G B order in one array.
  49291. *
  49292. * More information on this format are available here:
  49293. * https://en.wikipedia.org/wiki/RGBE_image_format
  49294. *
  49295. * @param uint8array The binary file stored in an array buffer.
  49296. * @param hdrInfo The header information of the file.
  49297. * @return The pixels data in RGB right to left up to down order.
  49298. */
  49299. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49300. private static RGBE_ReadPixels_RLE;
  49301. }
  49302. }
  49303. declare module BABYLON {
  49304. /**
  49305. * This represents a texture coming from an HDR input.
  49306. *
  49307. * The only supported format is currently panorama picture stored in RGBE format.
  49308. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49309. */
  49310. export class HDRCubeTexture extends BaseTexture {
  49311. private static _facesMapping;
  49312. private _generateHarmonics;
  49313. private _noMipmap;
  49314. private _textureMatrix;
  49315. private _size;
  49316. private _onLoad;
  49317. private _onError;
  49318. /**
  49319. * The texture URL.
  49320. */
  49321. url: string;
  49322. /**
  49323. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49324. */
  49325. coordinatesMode: number;
  49326. protected _isBlocking: boolean;
  49327. /**
  49328. * Sets wether or not the texture is blocking during loading.
  49329. */
  49330. /**
  49331. * Gets wether or not the texture is blocking during loading.
  49332. */
  49333. isBlocking: boolean;
  49334. protected _rotationY: number;
  49335. /**
  49336. * Sets texture matrix rotation angle around Y axis in radians.
  49337. */
  49338. /**
  49339. * Gets texture matrix rotation angle around Y axis radians.
  49340. */
  49341. rotationY: number;
  49342. /**
  49343. * Gets or sets the center of the bounding box associated with the cube texture
  49344. * It must define where the camera used to render the texture was set
  49345. */
  49346. boundingBoxPosition: Vector3;
  49347. private _boundingBoxSize;
  49348. /**
  49349. * Gets or sets the size of the bounding box associated with the cube texture
  49350. * When defined, the cubemap will switch to local mode
  49351. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49352. * @example https://www.babylonjs-playground.com/#RNASML
  49353. */
  49354. boundingBoxSize: Vector3;
  49355. /**
  49356. * Instantiates an HDRTexture from the following parameters.
  49357. *
  49358. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49359. * @param scene The scene the texture will be used in
  49360. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49361. * @param noMipmap Forces to not generate the mipmap if true
  49362. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49363. * @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)
  49364. * @param reserved Reserved flag for internal use.
  49365. */
  49366. 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>);
  49367. /**
  49368. * Get the current class name of the texture useful for serialization or dynamic coding.
  49369. * @returns "HDRCubeTexture"
  49370. */
  49371. getClassName(): string;
  49372. /**
  49373. * Occurs when the file is raw .hdr file.
  49374. */
  49375. private loadTexture;
  49376. clone(): HDRCubeTexture;
  49377. delayLoad(): void;
  49378. /**
  49379. * Get the texture reflection matrix used to rotate/transform the reflection.
  49380. * @returns the reflection matrix
  49381. */
  49382. getReflectionTextureMatrix(): Matrix;
  49383. /**
  49384. * Set the texture reflection matrix used to rotate/transform the reflection.
  49385. * @param value Define the reflection matrix to set
  49386. */
  49387. setReflectionTextureMatrix(value: Matrix): void;
  49388. /**
  49389. * Parses a JSON representation of an HDR Texture in order to create the texture
  49390. * @param parsedTexture Define the JSON representation
  49391. * @param scene Define the scene the texture should be created in
  49392. * @param rootUrl Define the root url in case we need to load relative dependencies
  49393. * @returns the newly created texture after parsing
  49394. */
  49395. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49396. serialize(): any;
  49397. }
  49398. }
  49399. declare module BABYLON {
  49400. /**
  49401. * Class used to control physics engine
  49402. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49403. */
  49404. export class PhysicsEngine implements IPhysicsEngine {
  49405. private _physicsPlugin;
  49406. /**
  49407. * Global value used to control the smallest number supported by the simulation
  49408. */
  49409. static Epsilon: number;
  49410. private _impostors;
  49411. private _joints;
  49412. /**
  49413. * Gets the gravity vector used by the simulation
  49414. */
  49415. gravity: Vector3;
  49416. /**
  49417. * Factory used to create the default physics plugin.
  49418. * @returns The default physics plugin
  49419. */
  49420. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49421. /**
  49422. * Creates a new Physics Engine
  49423. * @param gravity defines the gravity vector used by the simulation
  49424. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49425. */
  49426. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49427. /**
  49428. * Sets the gravity vector used by the simulation
  49429. * @param gravity defines the gravity vector to use
  49430. */
  49431. setGravity(gravity: Vector3): void;
  49432. /**
  49433. * Set the time step of the physics engine.
  49434. * Default is 1/60.
  49435. * To slow it down, enter 1/600 for example.
  49436. * To speed it up, 1/30
  49437. * @param newTimeStep defines the new timestep to apply to this world.
  49438. */
  49439. setTimeStep(newTimeStep?: number): void;
  49440. /**
  49441. * Get the time step of the physics engine.
  49442. * @returns the current time step
  49443. */
  49444. getTimeStep(): number;
  49445. /**
  49446. * Release all resources
  49447. */
  49448. dispose(): void;
  49449. /**
  49450. * Gets the name of the current physics plugin
  49451. * @returns the name of the plugin
  49452. */
  49453. getPhysicsPluginName(): string;
  49454. /**
  49455. * Adding a new impostor for the impostor tracking.
  49456. * This will be done by the impostor itself.
  49457. * @param impostor the impostor to add
  49458. */
  49459. addImpostor(impostor: PhysicsImpostor): void;
  49460. /**
  49461. * Remove an impostor from the engine.
  49462. * This impostor and its mesh will not longer be updated by the physics engine.
  49463. * @param impostor the impostor to remove
  49464. */
  49465. removeImpostor(impostor: PhysicsImpostor): void;
  49466. /**
  49467. * Add a joint to the physics engine
  49468. * @param mainImpostor defines the main impostor to which the joint is added.
  49469. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49470. * @param joint defines the joint that will connect both impostors.
  49471. */
  49472. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49473. /**
  49474. * Removes a joint from the simulation
  49475. * @param mainImpostor defines the impostor used with the joint
  49476. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49477. * @param joint defines the joint to remove
  49478. */
  49479. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49480. /**
  49481. * Called by the scene. No need to call it.
  49482. * @param delta defines the timespam between frames
  49483. */
  49484. _step(delta: number): void;
  49485. /**
  49486. * Gets the current plugin used to run the simulation
  49487. * @returns current plugin
  49488. */
  49489. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49490. /**
  49491. * Gets the list of physic impostors
  49492. * @returns an array of PhysicsImpostor
  49493. */
  49494. getImpostors(): Array<PhysicsImpostor>;
  49495. /**
  49496. * Gets the impostor for a physics enabled object
  49497. * @param object defines the object impersonated by the impostor
  49498. * @returns the PhysicsImpostor or null if not found
  49499. */
  49500. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49501. /**
  49502. * Gets the impostor for a physics body object
  49503. * @param body defines physics body used by the impostor
  49504. * @returns the PhysicsImpostor or null if not found
  49505. */
  49506. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49507. /**
  49508. * Does a raycast in the physics world
  49509. * @param from when should the ray start?
  49510. * @param to when should the ray end?
  49511. * @returns PhysicsRaycastResult
  49512. */
  49513. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49514. }
  49515. }
  49516. declare module BABYLON {
  49517. /** @hidden */
  49518. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49519. private _useDeltaForWorldStep;
  49520. world: any;
  49521. name: string;
  49522. private _physicsMaterials;
  49523. private _fixedTimeStep;
  49524. private _cannonRaycastResult;
  49525. private _raycastResult;
  49526. private _physicsBodysToRemoveAfterStep;
  49527. BJSCANNON: any;
  49528. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49529. setGravity(gravity: Vector3): void;
  49530. setTimeStep(timeStep: number): void;
  49531. getTimeStep(): number;
  49532. executeStep(delta: number): void;
  49533. private _removeMarkedPhysicsBodiesFromWorld;
  49534. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49535. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49536. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49537. private _processChildMeshes;
  49538. removePhysicsBody(impostor: PhysicsImpostor): void;
  49539. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49540. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49541. private _addMaterial;
  49542. private _checkWithEpsilon;
  49543. private _createShape;
  49544. private _createHeightmap;
  49545. private _minus90X;
  49546. private _plus90X;
  49547. private _tmpPosition;
  49548. private _tmpDeltaPosition;
  49549. private _tmpUnityRotation;
  49550. private _updatePhysicsBodyTransformation;
  49551. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49552. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49553. isSupported(): boolean;
  49554. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49555. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49556. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49557. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49558. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49559. getBodyMass(impostor: PhysicsImpostor): number;
  49560. getBodyFriction(impostor: PhysicsImpostor): number;
  49561. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49562. getBodyRestitution(impostor: PhysicsImpostor): number;
  49563. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49564. sleepBody(impostor: PhysicsImpostor): void;
  49565. wakeUpBody(impostor: PhysicsImpostor): void;
  49566. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49567. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49568. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49569. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49570. getRadius(impostor: PhysicsImpostor): number;
  49571. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49572. dispose(): void;
  49573. private _extendNamespace;
  49574. /**
  49575. * Does a raycast in the physics world
  49576. * @param from when should the ray start?
  49577. * @param to when should the ray end?
  49578. * @returns PhysicsRaycastResult
  49579. */
  49580. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49581. }
  49582. }
  49583. declare module BABYLON {
  49584. /** @hidden */
  49585. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49586. world: any;
  49587. name: string;
  49588. BJSOIMO: any;
  49589. private _raycastResult;
  49590. constructor(iterations?: number, oimoInjection?: any);
  49591. setGravity(gravity: Vector3): void;
  49592. setTimeStep(timeStep: number): void;
  49593. getTimeStep(): number;
  49594. private _tmpImpostorsArray;
  49595. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49596. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49597. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49598. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49599. private _tmpPositionVector;
  49600. removePhysicsBody(impostor: PhysicsImpostor): void;
  49601. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49602. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49603. isSupported(): boolean;
  49604. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49605. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49606. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49607. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49608. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49609. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49610. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49611. getBodyMass(impostor: PhysicsImpostor): number;
  49612. getBodyFriction(impostor: PhysicsImpostor): number;
  49613. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49614. getBodyRestitution(impostor: PhysicsImpostor): number;
  49615. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49616. sleepBody(impostor: PhysicsImpostor): void;
  49617. wakeUpBody(impostor: PhysicsImpostor): void;
  49618. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49619. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49620. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49621. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49622. getRadius(impostor: PhysicsImpostor): number;
  49623. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49624. dispose(): void;
  49625. /**
  49626. * Does a raycast in the physics world
  49627. * @param from when should the ray start?
  49628. * @param to when should the ray end?
  49629. * @returns PhysicsRaycastResult
  49630. */
  49631. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49632. }
  49633. }
  49634. declare module BABYLON {
  49635. /**
  49636. * Class containing static functions to help procedurally build meshes
  49637. */
  49638. export class RibbonBuilder {
  49639. /**
  49640. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49641. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49642. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49643. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49644. * * 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
  49645. * * 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
  49646. * * 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
  49647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49648. * * 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
  49649. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49650. * * 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
  49651. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49652. * * 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
  49653. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49655. * @param name defines the name of the mesh
  49656. * @param options defines the options used to create the mesh
  49657. * @param scene defines the hosting scene
  49658. * @returns the ribbon mesh
  49659. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49660. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49661. */
  49662. static CreateRibbon(name: string, options: {
  49663. pathArray: Vector3[][];
  49664. closeArray?: boolean;
  49665. closePath?: boolean;
  49666. offset?: number;
  49667. updatable?: boolean;
  49668. sideOrientation?: number;
  49669. frontUVs?: Vector4;
  49670. backUVs?: Vector4;
  49671. instance?: Mesh;
  49672. invertUV?: boolean;
  49673. uvs?: Vector2[];
  49674. colors?: Color4[];
  49675. }, scene?: Nullable<Scene>): Mesh;
  49676. }
  49677. }
  49678. declare module BABYLON {
  49679. /**
  49680. * Class containing static functions to help procedurally build meshes
  49681. */
  49682. export class ShapeBuilder {
  49683. /**
  49684. * 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.
  49685. * * 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.
  49686. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49687. * * 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.
  49688. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49689. * * 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
  49690. * * 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
  49691. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49693. * * 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
  49694. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49696. * @param name defines the name of the mesh
  49697. * @param options defines the options used to create the mesh
  49698. * @param scene defines the hosting scene
  49699. * @returns the extruded shape mesh
  49700. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49702. */
  49703. static ExtrudeShape(name: string, options: {
  49704. shape: Vector3[];
  49705. path: Vector3[];
  49706. scale?: number;
  49707. rotation?: number;
  49708. cap?: number;
  49709. updatable?: boolean;
  49710. sideOrientation?: number;
  49711. frontUVs?: Vector4;
  49712. backUVs?: Vector4;
  49713. instance?: Mesh;
  49714. invertUV?: boolean;
  49715. }, scene?: Nullable<Scene>): Mesh;
  49716. /**
  49717. * Creates an custom extruded shape mesh.
  49718. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49719. * * 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.
  49720. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49721. * * 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
  49722. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49723. * * 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
  49724. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49725. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49726. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49727. * * 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
  49728. * * 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
  49729. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49731. * * 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
  49732. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49734. * @param name defines the name of the mesh
  49735. * @param options defines the options used to create the mesh
  49736. * @param scene defines the hosting scene
  49737. * @returns the custom extruded shape mesh
  49738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49739. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49741. */
  49742. static ExtrudeShapeCustom(name: string, options: {
  49743. shape: Vector3[];
  49744. path: Vector3[];
  49745. scaleFunction?: any;
  49746. rotationFunction?: any;
  49747. ribbonCloseArray?: boolean;
  49748. ribbonClosePath?: boolean;
  49749. cap?: number;
  49750. updatable?: boolean;
  49751. sideOrientation?: number;
  49752. frontUVs?: Vector4;
  49753. backUVs?: Vector4;
  49754. instance?: Mesh;
  49755. invertUV?: boolean;
  49756. }, scene?: Nullable<Scene>): Mesh;
  49757. private static _ExtrudeShapeGeneric;
  49758. }
  49759. }
  49760. declare module BABYLON {
  49761. /**
  49762. * AmmoJS Physics plugin
  49763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49764. * @see https://github.com/kripken/ammo.js/
  49765. */
  49766. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49767. private _useDeltaForWorldStep;
  49768. /**
  49769. * Reference to the Ammo library
  49770. */
  49771. bjsAMMO: any;
  49772. /**
  49773. * Created ammoJS world which physics bodies are added to
  49774. */
  49775. world: any;
  49776. /**
  49777. * Name of the plugin
  49778. */
  49779. name: string;
  49780. private _timeStep;
  49781. private _fixedTimeStep;
  49782. private _maxSteps;
  49783. private _tmpQuaternion;
  49784. private _tmpAmmoTransform;
  49785. private _tmpAmmoQuaternion;
  49786. private _tmpAmmoConcreteContactResultCallback;
  49787. private _collisionConfiguration;
  49788. private _dispatcher;
  49789. private _overlappingPairCache;
  49790. private _solver;
  49791. private _softBodySolver;
  49792. private _tmpAmmoVectorA;
  49793. private _tmpAmmoVectorB;
  49794. private _tmpAmmoVectorC;
  49795. private _tmpAmmoVectorD;
  49796. private _tmpContactCallbackResult;
  49797. private _tmpAmmoVectorRCA;
  49798. private _tmpAmmoVectorRCB;
  49799. private _raycastResult;
  49800. private static readonly DISABLE_COLLISION_FLAG;
  49801. private static readonly KINEMATIC_FLAG;
  49802. private static readonly DISABLE_DEACTIVATION_FLAG;
  49803. /**
  49804. * Initializes the ammoJS plugin
  49805. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49806. * @param ammoInjection can be used to inject your own ammo reference
  49807. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49808. */
  49809. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49810. /**
  49811. * Sets the gravity of the physics world (m/(s^2))
  49812. * @param gravity Gravity to set
  49813. */
  49814. setGravity(gravity: Vector3): void;
  49815. /**
  49816. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49817. * @param timeStep timestep to use in seconds
  49818. */
  49819. setTimeStep(timeStep: number): void;
  49820. /**
  49821. * 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)
  49822. * @param fixedTimeStep fixedTimeStep to use in seconds
  49823. */
  49824. setFixedTimeStep(fixedTimeStep: number): void;
  49825. /**
  49826. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49827. * @param maxSteps the maximum number of steps by the physics engine per frame
  49828. */
  49829. setMaxSteps(maxSteps: number): void;
  49830. /**
  49831. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49832. * @returns the current timestep in seconds
  49833. */
  49834. getTimeStep(): number;
  49835. private _isImpostorInContact;
  49836. private _isImpostorPairInContact;
  49837. private _stepSimulation;
  49838. /**
  49839. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49840. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49841. * After the step the babylon meshes are set to the position of the physics imposters
  49842. * @param delta amount of time to step forward
  49843. * @param impostors array of imposters to update before/after the step
  49844. */
  49845. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49846. /**
  49847. * Update babylon mesh to match physics world object
  49848. * @param impostor imposter to match
  49849. */
  49850. private _afterSoftStep;
  49851. /**
  49852. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49853. * @param impostor imposter to match
  49854. */
  49855. private _ropeStep;
  49856. /**
  49857. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49858. * @param impostor imposter to match
  49859. */
  49860. private _softbodyOrClothStep;
  49861. private _tmpVector;
  49862. private _tmpMatrix;
  49863. /**
  49864. * Applies an impulse on the imposter
  49865. * @param impostor imposter to apply impulse to
  49866. * @param force amount of force to be applied to the imposter
  49867. * @param contactPoint the location to apply the impulse on the imposter
  49868. */
  49869. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49870. /**
  49871. * Applies a force on the imposter
  49872. * @param impostor imposter to apply force
  49873. * @param force amount of force to be applied to the imposter
  49874. * @param contactPoint the location to apply the force on the imposter
  49875. */
  49876. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49877. /**
  49878. * Creates a physics body using the plugin
  49879. * @param impostor the imposter to create the physics body on
  49880. */
  49881. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49882. /**
  49883. * Removes the physics body from the imposter and disposes of the body's memory
  49884. * @param impostor imposter to remove the physics body from
  49885. */
  49886. removePhysicsBody(impostor: PhysicsImpostor): void;
  49887. /**
  49888. * Generates a joint
  49889. * @param impostorJoint the imposter joint to create the joint with
  49890. */
  49891. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49892. /**
  49893. * Removes a joint
  49894. * @param impostorJoint the imposter joint to remove the joint from
  49895. */
  49896. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49897. private _addMeshVerts;
  49898. /**
  49899. * Initialise the soft body vertices to match its object's (mesh) vertices
  49900. * Softbody vertices (nodes) are in world space and to match this
  49901. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49902. * @param impostor to create the softbody for
  49903. */
  49904. private _softVertexData;
  49905. /**
  49906. * Create an impostor's soft body
  49907. * @param impostor to create the softbody for
  49908. */
  49909. private _createSoftbody;
  49910. /**
  49911. * Create cloth for an impostor
  49912. * @param impostor to create the softbody for
  49913. */
  49914. private _createCloth;
  49915. /**
  49916. * Create rope for an impostor
  49917. * @param impostor to create the softbody for
  49918. */
  49919. private _createRope;
  49920. private _addHullVerts;
  49921. private _createShape;
  49922. /**
  49923. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49924. * @param impostor imposter containing the physics body and babylon object
  49925. */
  49926. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49927. /**
  49928. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49929. * @param impostor imposter containing the physics body and babylon object
  49930. * @param newPosition new position
  49931. * @param newRotation new rotation
  49932. */
  49933. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49934. /**
  49935. * If this plugin is supported
  49936. * @returns true if its supported
  49937. */
  49938. isSupported(): boolean;
  49939. /**
  49940. * Sets the linear velocity of the physics body
  49941. * @param impostor imposter to set the velocity on
  49942. * @param velocity velocity to set
  49943. */
  49944. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49945. /**
  49946. * Sets the angular velocity of the physics body
  49947. * @param impostor imposter to set the velocity on
  49948. * @param velocity velocity to set
  49949. */
  49950. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49951. /**
  49952. * gets the linear velocity
  49953. * @param impostor imposter to get linear velocity from
  49954. * @returns linear velocity
  49955. */
  49956. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49957. /**
  49958. * gets the angular velocity
  49959. * @param impostor imposter to get angular velocity from
  49960. * @returns angular velocity
  49961. */
  49962. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49963. /**
  49964. * Sets the mass of physics body
  49965. * @param impostor imposter to set the mass on
  49966. * @param mass mass to set
  49967. */
  49968. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49969. /**
  49970. * Gets the mass of the physics body
  49971. * @param impostor imposter to get the mass from
  49972. * @returns mass
  49973. */
  49974. getBodyMass(impostor: PhysicsImpostor): number;
  49975. /**
  49976. * Gets friction of the impostor
  49977. * @param impostor impostor to get friction from
  49978. * @returns friction value
  49979. */
  49980. getBodyFriction(impostor: PhysicsImpostor): number;
  49981. /**
  49982. * Sets friction of the impostor
  49983. * @param impostor impostor to set friction on
  49984. * @param friction friction value
  49985. */
  49986. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49987. /**
  49988. * Gets restitution of the impostor
  49989. * @param impostor impostor to get restitution from
  49990. * @returns restitution value
  49991. */
  49992. getBodyRestitution(impostor: PhysicsImpostor): number;
  49993. /**
  49994. * Sets resitution of the impostor
  49995. * @param impostor impostor to set resitution on
  49996. * @param restitution resitution value
  49997. */
  49998. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49999. /**
  50000. * Gets pressure inside the impostor
  50001. * @param impostor impostor to get pressure from
  50002. * @returns pressure value
  50003. */
  50004. getBodyPressure(impostor: PhysicsImpostor): number;
  50005. /**
  50006. * Sets pressure inside a soft body impostor
  50007. * Cloth and rope must remain 0 pressure
  50008. * @param impostor impostor to set pressure on
  50009. * @param pressure pressure value
  50010. */
  50011. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50012. /**
  50013. * Gets stiffness of the impostor
  50014. * @param impostor impostor to get stiffness from
  50015. * @returns pressure value
  50016. */
  50017. getBodyStiffness(impostor: PhysicsImpostor): number;
  50018. /**
  50019. * Sets stiffness of the impostor
  50020. * @param impostor impostor to set stiffness on
  50021. * @param stiffness stiffness value from 0 to 1
  50022. */
  50023. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50024. /**
  50025. * Gets velocityIterations of the impostor
  50026. * @param impostor impostor to get velocity iterations from
  50027. * @returns velocityIterations value
  50028. */
  50029. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50030. /**
  50031. * Sets velocityIterations of the impostor
  50032. * @param impostor impostor to set velocity iterations on
  50033. * @param velocityIterations velocityIterations value
  50034. */
  50035. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50036. /**
  50037. * Gets positionIterations of the impostor
  50038. * @param impostor impostor to get position iterations from
  50039. * @returns positionIterations value
  50040. */
  50041. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50042. /**
  50043. * Sets positionIterations of the impostor
  50044. * @param impostor impostor to set position on
  50045. * @param positionIterations positionIterations value
  50046. */
  50047. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50048. /**
  50049. * Append an anchor to a cloth object
  50050. * @param impostor is the cloth impostor to add anchor to
  50051. * @param otherImpostor is the rigid impostor to anchor to
  50052. * @param width ratio across width from 0 to 1
  50053. * @param height ratio up height from 0 to 1
  50054. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50055. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50056. */
  50057. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50058. /**
  50059. * Append an hook to a rope object
  50060. * @param impostor is the rope impostor to add hook to
  50061. * @param otherImpostor is the rigid impostor to hook to
  50062. * @param length ratio along the rope from 0 to 1
  50063. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50064. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50065. */
  50066. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50067. /**
  50068. * Sleeps the physics body and stops it from being active
  50069. * @param impostor impostor to sleep
  50070. */
  50071. sleepBody(impostor: PhysicsImpostor): void;
  50072. /**
  50073. * Activates the physics body
  50074. * @param impostor impostor to activate
  50075. */
  50076. wakeUpBody(impostor: PhysicsImpostor): void;
  50077. /**
  50078. * Updates the distance parameters of the joint
  50079. * @param joint joint to update
  50080. * @param maxDistance maximum distance of the joint
  50081. * @param minDistance minimum distance of the joint
  50082. */
  50083. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50084. /**
  50085. * Sets a motor on the joint
  50086. * @param joint joint to set motor on
  50087. * @param speed speed of the motor
  50088. * @param maxForce maximum force of the motor
  50089. * @param motorIndex index of the motor
  50090. */
  50091. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50092. /**
  50093. * Sets the motors limit
  50094. * @param joint joint to set limit on
  50095. * @param upperLimit upper limit
  50096. * @param lowerLimit lower limit
  50097. */
  50098. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50099. /**
  50100. * Syncs the position and rotation of a mesh with the impostor
  50101. * @param mesh mesh to sync
  50102. * @param impostor impostor to update the mesh with
  50103. */
  50104. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50105. /**
  50106. * Gets the radius of the impostor
  50107. * @param impostor impostor to get radius from
  50108. * @returns the radius
  50109. */
  50110. getRadius(impostor: PhysicsImpostor): number;
  50111. /**
  50112. * Gets the box size of the impostor
  50113. * @param impostor impostor to get box size from
  50114. * @param result the resulting box size
  50115. */
  50116. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50117. /**
  50118. * Disposes of the impostor
  50119. */
  50120. dispose(): void;
  50121. /**
  50122. * Does a raycast in the physics world
  50123. * @param from when should the ray start?
  50124. * @param to when should the ray end?
  50125. * @returns PhysicsRaycastResult
  50126. */
  50127. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50128. }
  50129. }
  50130. declare module BABYLON {
  50131. interface AbstractScene {
  50132. /**
  50133. * The list of reflection probes added to the scene
  50134. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50135. */
  50136. reflectionProbes: Array<ReflectionProbe>;
  50137. /**
  50138. * Removes the given reflection probe from this scene.
  50139. * @param toRemove The reflection probe to remove
  50140. * @returns The index of the removed reflection probe
  50141. */
  50142. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50143. /**
  50144. * Adds the given reflection probe to this scene.
  50145. * @param newReflectionProbe The reflection probe to add
  50146. */
  50147. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50148. }
  50149. /**
  50150. * Class used to generate realtime reflection / refraction cube textures
  50151. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50152. */
  50153. export class ReflectionProbe {
  50154. /** defines the name of the probe */
  50155. name: string;
  50156. private _scene;
  50157. private _renderTargetTexture;
  50158. private _projectionMatrix;
  50159. private _viewMatrix;
  50160. private _target;
  50161. private _add;
  50162. private _attachedMesh;
  50163. private _invertYAxis;
  50164. /** Gets or sets probe position (center of the cube map) */
  50165. position: Vector3;
  50166. /**
  50167. * Creates a new reflection probe
  50168. * @param name defines the name of the probe
  50169. * @param size defines the texture resolution (for each face)
  50170. * @param scene defines the hosting scene
  50171. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50172. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50173. */
  50174. constructor(
  50175. /** defines the name of the probe */
  50176. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50177. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50178. samples: number;
  50179. /** Gets or sets the refresh rate to use (on every frame by default) */
  50180. refreshRate: number;
  50181. /**
  50182. * Gets the hosting scene
  50183. * @returns a Scene
  50184. */
  50185. getScene(): Scene;
  50186. /** Gets the internal CubeTexture used to render to */
  50187. readonly cubeTexture: RenderTargetTexture;
  50188. /** Gets the list of meshes to render */
  50189. readonly renderList: Nullable<AbstractMesh[]>;
  50190. /**
  50191. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50192. * @param mesh defines the mesh to attach to
  50193. */
  50194. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50195. /**
  50196. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50197. * @param renderingGroupId The rendering group id corresponding to its index
  50198. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50199. */
  50200. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50201. /**
  50202. * Clean all associated resources
  50203. */
  50204. dispose(): void;
  50205. /**
  50206. * Converts the reflection probe information to a readable string for debug purpose.
  50207. * @param fullDetails Supports for multiple levels of logging within scene loading
  50208. * @returns the human readable reflection probe info
  50209. */
  50210. toString(fullDetails?: boolean): string;
  50211. /**
  50212. * Get the class name of the relfection probe.
  50213. * @returns "ReflectionProbe"
  50214. */
  50215. getClassName(): string;
  50216. /**
  50217. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50218. * @returns The JSON representation of the texture
  50219. */
  50220. serialize(): any;
  50221. /**
  50222. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50223. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50224. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50225. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50226. * @returns The parsed reflection probe if successful
  50227. */
  50228. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50229. }
  50230. }
  50231. declare module BABYLON {
  50232. /** @hidden */
  50233. export var _BabylonLoaderRegistered: boolean;
  50234. }
  50235. declare module BABYLON {
  50236. /**
  50237. * The Physically based simple base material of BJS.
  50238. *
  50239. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50240. * It is used as the base class for both the specGloss and metalRough conventions.
  50241. */
  50242. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50243. /**
  50244. * Number of Simultaneous lights allowed on the material.
  50245. */
  50246. maxSimultaneousLights: number;
  50247. /**
  50248. * If sets to true, disables all the lights affecting the material.
  50249. */
  50250. disableLighting: boolean;
  50251. /**
  50252. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50253. */
  50254. environmentTexture: BaseTexture;
  50255. /**
  50256. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50257. */
  50258. invertNormalMapX: boolean;
  50259. /**
  50260. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50261. */
  50262. invertNormalMapY: boolean;
  50263. /**
  50264. * Normal map used in the model.
  50265. */
  50266. normalTexture: BaseTexture;
  50267. /**
  50268. * Emissivie color used to self-illuminate the model.
  50269. */
  50270. emissiveColor: Color3;
  50271. /**
  50272. * Emissivie texture used to self-illuminate the model.
  50273. */
  50274. emissiveTexture: BaseTexture;
  50275. /**
  50276. * Occlusion Channel Strenght.
  50277. */
  50278. occlusionStrength: number;
  50279. /**
  50280. * Occlusion Texture of the material (adding extra occlusion effects).
  50281. */
  50282. occlusionTexture: BaseTexture;
  50283. /**
  50284. * Defines the alpha limits in alpha test mode.
  50285. */
  50286. alphaCutOff: number;
  50287. /**
  50288. * Gets the current double sided mode.
  50289. */
  50290. /**
  50291. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50292. */
  50293. doubleSided: boolean;
  50294. /**
  50295. * Stores the pre-calculated light information of a mesh in a texture.
  50296. */
  50297. lightmapTexture: BaseTexture;
  50298. /**
  50299. * If true, the light map contains occlusion information instead of lighting info.
  50300. */
  50301. useLightmapAsShadowmap: boolean;
  50302. /**
  50303. * Instantiates a new PBRMaterial instance.
  50304. *
  50305. * @param name The material name
  50306. * @param scene The scene the material will be use in.
  50307. */
  50308. constructor(name: string, scene: Scene);
  50309. getClassName(): string;
  50310. }
  50311. }
  50312. declare module BABYLON {
  50313. /**
  50314. * The PBR material of BJS following the metal roughness convention.
  50315. *
  50316. * This fits to the PBR convention in the GLTF definition:
  50317. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50318. */
  50319. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50320. /**
  50321. * The base color has two different interpretations depending on the value of metalness.
  50322. * When the material is a metal, the base color is the specific measured reflectance value
  50323. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50324. * of the material.
  50325. */
  50326. baseColor: Color3;
  50327. /**
  50328. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50329. * well as opacity information in the alpha channel.
  50330. */
  50331. baseTexture: BaseTexture;
  50332. /**
  50333. * Specifies the metallic scalar value of the material.
  50334. * Can also be used to scale the metalness values of the metallic texture.
  50335. */
  50336. metallic: number;
  50337. /**
  50338. * Specifies the roughness scalar value of the material.
  50339. * Can also be used to scale the roughness values of the metallic texture.
  50340. */
  50341. roughness: number;
  50342. /**
  50343. * Texture containing both the metallic value in the B channel and the
  50344. * roughness value in the G channel to keep better precision.
  50345. */
  50346. metallicRoughnessTexture: BaseTexture;
  50347. /**
  50348. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50349. *
  50350. * @param name The material name
  50351. * @param scene The scene the material will be use in.
  50352. */
  50353. constructor(name: string, scene: Scene);
  50354. /**
  50355. * Return the currrent class name of the material.
  50356. */
  50357. getClassName(): string;
  50358. /**
  50359. * Makes a duplicate of the current material.
  50360. * @param name - name to use for the new material.
  50361. */
  50362. clone(name: string): PBRMetallicRoughnessMaterial;
  50363. /**
  50364. * Serialize the material to a parsable JSON object.
  50365. */
  50366. serialize(): any;
  50367. /**
  50368. * Parses a JSON object correponding to the serialize function.
  50369. */
  50370. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50371. }
  50372. }
  50373. declare module BABYLON {
  50374. /**
  50375. * The PBR material of BJS following the specular glossiness convention.
  50376. *
  50377. * This fits to the PBR convention in the GLTF definition:
  50378. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50379. */
  50380. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50381. /**
  50382. * Specifies the diffuse color of the material.
  50383. */
  50384. diffuseColor: Color3;
  50385. /**
  50386. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50387. * channel.
  50388. */
  50389. diffuseTexture: BaseTexture;
  50390. /**
  50391. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50392. */
  50393. specularColor: Color3;
  50394. /**
  50395. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50396. */
  50397. glossiness: number;
  50398. /**
  50399. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50400. */
  50401. specularGlossinessTexture: BaseTexture;
  50402. /**
  50403. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50404. *
  50405. * @param name The material name
  50406. * @param scene The scene the material will be use in.
  50407. */
  50408. constructor(name: string, scene: Scene);
  50409. /**
  50410. * Return the currrent class name of the material.
  50411. */
  50412. getClassName(): string;
  50413. /**
  50414. * Makes a duplicate of the current material.
  50415. * @param name - name to use for the new material.
  50416. */
  50417. clone(name: string): PBRSpecularGlossinessMaterial;
  50418. /**
  50419. * Serialize the material to a parsable JSON object.
  50420. */
  50421. serialize(): any;
  50422. /**
  50423. * Parses a JSON object correponding to the serialize function.
  50424. */
  50425. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50426. }
  50427. }
  50428. declare module BABYLON {
  50429. /**
  50430. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50431. * It can help converting any input color in a desired output one. This can then be used to create effects
  50432. * from sepia, black and white to sixties or futuristic rendering...
  50433. *
  50434. * The only supported format is currently 3dl.
  50435. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50436. */
  50437. export class ColorGradingTexture extends BaseTexture {
  50438. /**
  50439. * The current texture matrix. (will always be identity in color grading texture)
  50440. */
  50441. private _textureMatrix;
  50442. /**
  50443. * The texture URL.
  50444. */
  50445. url: string;
  50446. /**
  50447. * Empty line regex stored for GC.
  50448. */
  50449. private static _noneEmptyLineRegex;
  50450. private _engine;
  50451. /**
  50452. * Instantiates a ColorGradingTexture from the following parameters.
  50453. *
  50454. * @param url The location of the color gradind data (currently only supporting 3dl)
  50455. * @param scene The scene the texture will be used in
  50456. */
  50457. constructor(url: string, scene: Scene);
  50458. /**
  50459. * Returns the texture matrix used in most of the material.
  50460. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50461. */
  50462. getTextureMatrix(): Matrix;
  50463. /**
  50464. * Occurs when the file being loaded is a .3dl LUT file.
  50465. */
  50466. private load3dlTexture;
  50467. /**
  50468. * Starts the loading process of the texture.
  50469. */
  50470. private loadTexture;
  50471. /**
  50472. * Clones the color gradind texture.
  50473. */
  50474. clone(): ColorGradingTexture;
  50475. /**
  50476. * Called during delayed load for textures.
  50477. */
  50478. delayLoad(): void;
  50479. /**
  50480. * Parses a color grading texture serialized by Babylon.
  50481. * @param parsedTexture The texture information being parsedTexture
  50482. * @param scene The scene to load the texture in
  50483. * @param rootUrl The root url of the data assets to load
  50484. * @return A color gradind texture
  50485. */
  50486. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50487. /**
  50488. * Serializes the LUT texture to json format.
  50489. */
  50490. serialize(): any;
  50491. }
  50492. }
  50493. declare module BABYLON {
  50494. /**
  50495. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50496. */
  50497. export class EquiRectangularCubeTexture extends BaseTexture {
  50498. /** The six faces of the cube. */
  50499. private static _FacesMapping;
  50500. private _noMipmap;
  50501. private _onLoad;
  50502. private _onError;
  50503. /** The size of the cubemap. */
  50504. private _size;
  50505. /** The buffer of the image. */
  50506. private _buffer;
  50507. /** The width of the input image. */
  50508. private _width;
  50509. /** The height of the input image. */
  50510. private _height;
  50511. /** The URL to the image. */
  50512. url: string;
  50513. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50514. coordinatesMode: number;
  50515. /**
  50516. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50517. * @param url The location of the image
  50518. * @param scene The scene the texture will be used in
  50519. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50520. * @param noMipmap Forces to not generate the mipmap if true
  50521. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50522. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50523. * @param onLoad — defines a callback called when texture is loaded
  50524. * @param onError — defines a callback called if there is an error
  50525. */
  50526. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50527. /**
  50528. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50529. */
  50530. private loadImage;
  50531. /**
  50532. * Convert the image buffer into a cubemap and create a CubeTexture.
  50533. */
  50534. private loadTexture;
  50535. /**
  50536. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50537. * @param buffer The ArrayBuffer that should be converted.
  50538. * @returns The buffer as Float32Array.
  50539. */
  50540. private getFloat32ArrayFromArrayBuffer;
  50541. /**
  50542. * Get the current class name of the texture useful for serialization or dynamic coding.
  50543. * @returns "EquiRectangularCubeTexture"
  50544. */
  50545. getClassName(): string;
  50546. /**
  50547. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50548. * @returns A clone of the current EquiRectangularCubeTexture.
  50549. */
  50550. clone(): EquiRectangularCubeTexture;
  50551. }
  50552. }
  50553. declare module BABYLON {
  50554. /**
  50555. * Based on jsTGALoader - Javascript loader for TGA file
  50556. * By Vincent Thibault
  50557. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50558. */
  50559. export class TGATools {
  50560. private static _TYPE_INDEXED;
  50561. private static _TYPE_RGB;
  50562. private static _TYPE_GREY;
  50563. private static _TYPE_RLE_INDEXED;
  50564. private static _TYPE_RLE_RGB;
  50565. private static _TYPE_RLE_GREY;
  50566. private static _ORIGIN_MASK;
  50567. private static _ORIGIN_SHIFT;
  50568. private static _ORIGIN_BL;
  50569. private static _ORIGIN_BR;
  50570. private static _ORIGIN_UL;
  50571. private static _ORIGIN_UR;
  50572. /**
  50573. * Gets the header of a TGA file
  50574. * @param data defines the TGA data
  50575. * @returns the header
  50576. */
  50577. static GetTGAHeader(data: Uint8Array): any;
  50578. /**
  50579. * Uploads TGA content to a Babylon Texture
  50580. * @hidden
  50581. */
  50582. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50583. /** @hidden */
  50584. 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;
  50585. /** @hidden */
  50586. 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;
  50587. /** @hidden */
  50588. 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;
  50589. /** @hidden */
  50590. 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;
  50591. /** @hidden */
  50592. 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;
  50593. /** @hidden */
  50594. 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;
  50595. }
  50596. }
  50597. declare module BABYLON {
  50598. /**
  50599. * Implementation of the TGA Texture Loader.
  50600. * @hidden
  50601. */
  50602. export class _TGATextureLoader implements IInternalTextureLoader {
  50603. /**
  50604. * Defines wether the loader supports cascade loading the different faces.
  50605. */
  50606. readonly supportCascades: boolean;
  50607. /**
  50608. * This returns if the loader support the current file information.
  50609. * @param extension defines the file extension of the file being loaded
  50610. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50611. * @param fallback defines the fallback internal texture if any
  50612. * @param isBase64 defines whether the texture is encoded as a base64
  50613. * @param isBuffer defines whether the texture data are stored as a buffer
  50614. * @returns true if the loader can load the specified file
  50615. */
  50616. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50617. /**
  50618. * Transform the url before loading if required.
  50619. * @param rootUrl the url of the texture
  50620. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50621. * @returns the transformed texture
  50622. */
  50623. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50624. /**
  50625. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50626. * @param rootUrl the url of the texture
  50627. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50628. * @returns the fallback texture
  50629. */
  50630. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50631. /**
  50632. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50633. * @param data contains the texture data
  50634. * @param texture defines the BabylonJS internal texture
  50635. * @param createPolynomials will be true if polynomials have been requested
  50636. * @param onLoad defines the callback to trigger once the texture is ready
  50637. * @param onError defines the callback to trigger in case of error
  50638. */
  50639. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50640. /**
  50641. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50642. * @param data contains the texture data
  50643. * @param texture defines the BabylonJS internal texture
  50644. * @param callback defines the method to call once ready to upload
  50645. */
  50646. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50647. }
  50648. }
  50649. declare module BABYLON {
  50650. /**
  50651. * Info about the .basis files
  50652. */
  50653. class BasisFileInfo {
  50654. /**
  50655. * If the file has alpha
  50656. */
  50657. hasAlpha: boolean;
  50658. /**
  50659. * Info about each image of the basis file
  50660. */
  50661. images: Array<{
  50662. levels: Array<{
  50663. width: number;
  50664. height: number;
  50665. transcodedPixels: ArrayBufferView;
  50666. }>;
  50667. }>;
  50668. }
  50669. /**
  50670. * Result of transcoding a basis file
  50671. */
  50672. class TranscodeResult {
  50673. /**
  50674. * Info about the .basis file
  50675. */
  50676. fileInfo: BasisFileInfo;
  50677. /**
  50678. * Format to use when loading the file
  50679. */
  50680. format: number;
  50681. }
  50682. /**
  50683. * Configuration options for the Basis transcoder
  50684. */
  50685. export class BasisTranscodeConfiguration {
  50686. /**
  50687. * Supported compression formats used to determine the supported output format of the transcoder
  50688. */
  50689. supportedCompressionFormats?: {
  50690. /**
  50691. * etc1 compression format
  50692. */
  50693. etc1?: boolean;
  50694. /**
  50695. * s3tc compression format
  50696. */
  50697. s3tc?: boolean;
  50698. /**
  50699. * pvrtc compression format
  50700. */
  50701. pvrtc?: boolean;
  50702. /**
  50703. * etc2 compression format
  50704. */
  50705. etc2?: boolean;
  50706. };
  50707. /**
  50708. * If mipmap levels should be loaded for transcoded images (Default: true)
  50709. */
  50710. loadMipmapLevels?: boolean;
  50711. /**
  50712. * Index of a single image to load (Default: all images)
  50713. */
  50714. loadSingleImage?: number;
  50715. }
  50716. /**
  50717. * Used to load .Basis files
  50718. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50719. */
  50720. export class BasisTools {
  50721. private static _IgnoreSupportedFormats;
  50722. /**
  50723. * URL to use when loading the basis transcoder
  50724. */
  50725. static JSModuleURL: string;
  50726. /**
  50727. * URL to use when loading the wasm module for the transcoder
  50728. */
  50729. static WasmModuleURL: string;
  50730. /**
  50731. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50732. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50733. * @returns internal format corresponding to the Basis format
  50734. */
  50735. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50736. private static _WorkerPromise;
  50737. private static _Worker;
  50738. private static _actionId;
  50739. private static _CreateWorkerAsync;
  50740. /**
  50741. * Transcodes a loaded image file to compressed pixel data
  50742. * @param imageData image data to transcode
  50743. * @param config configuration options for the transcoding
  50744. * @returns a promise resulting in the transcoded image
  50745. */
  50746. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50747. /**
  50748. * Loads a texture from the transcode result
  50749. * @param texture texture load to
  50750. * @param transcodeResult the result of transcoding the basis file to load from
  50751. */
  50752. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50753. }
  50754. }
  50755. declare module BABYLON {
  50756. /**
  50757. * Loader for .basis file format
  50758. */
  50759. export class _BasisTextureLoader implements IInternalTextureLoader {
  50760. /**
  50761. * Defines whether the loader supports cascade loading the different faces.
  50762. */
  50763. readonly supportCascades: boolean;
  50764. /**
  50765. * This returns if the loader support the current file information.
  50766. * @param extension defines the file extension of the file being loaded
  50767. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50768. * @param fallback defines the fallback internal texture if any
  50769. * @param isBase64 defines whether the texture is encoded as a base64
  50770. * @param isBuffer defines whether the texture data are stored as a buffer
  50771. * @returns true if the loader can load the specified file
  50772. */
  50773. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50774. /**
  50775. * Transform the url before loading if required.
  50776. * @param rootUrl the url of the texture
  50777. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50778. * @returns the transformed texture
  50779. */
  50780. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50781. /**
  50782. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50783. * @param rootUrl the url of the texture
  50784. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50785. * @returns the fallback texture
  50786. */
  50787. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50788. /**
  50789. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50790. * @param data contains the texture data
  50791. * @param texture defines the BabylonJS internal texture
  50792. * @param createPolynomials will be true if polynomials have been requested
  50793. * @param onLoad defines the callback to trigger once the texture is ready
  50794. * @param onError defines the callback to trigger in case of error
  50795. */
  50796. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50797. /**
  50798. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50799. * @param data contains the texture data
  50800. * @param texture defines the BabylonJS internal texture
  50801. * @param callback defines the method to call once ready to upload
  50802. */
  50803. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50804. }
  50805. }
  50806. declare module BABYLON {
  50807. /**
  50808. * 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.
  50809. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50810. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50811. */
  50812. export class CustomProceduralTexture extends ProceduralTexture {
  50813. private _animate;
  50814. private _time;
  50815. private _config;
  50816. private _texturePath;
  50817. /**
  50818. * Instantiates a new Custom Procedural Texture.
  50819. * 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.
  50820. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50821. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50822. * @param name Define the name of the texture
  50823. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50824. * @param size Define the size of the texture to create
  50825. * @param scene Define the scene the texture belongs to
  50826. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50827. * @param generateMipMaps Define if the texture should creates mip maps or not
  50828. */
  50829. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50830. private _loadJson;
  50831. /**
  50832. * Is the texture ready to be used ? (rendered at least once)
  50833. * @returns true if ready, otherwise, false.
  50834. */
  50835. isReady(): boolean;
  50836. /**
  50837. * Render the texture to its associated render target.
  50838. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50839. */
  50840. render(useCameraPostProcess?: boolean): void;
  50841. /**
  50842. * Update the list of dependant textures samplers in the shader.
  50843. */
  50844. updateTextures(): void;
  50845. /**
  50846. * Update the uniform values of the procedural texture in the shader.
  50847. */
  50848. updateShaderUniforms(): void;
  50849. /**
  50850. * Define if the texture animates or not.
  50851. */
  50852. animate: boolean;
  50853. }
  50854. }
  50855. declare module BABYLON {
  50856. /** @hidden */
  50857. export var noisePixelShader: {
  50858. name: string;
  50859. shader: string;
  50860. };
  50861. }
  50862. declare module BABYLON {
  50863. /**
  50864. * Class used to generate noise procedural textures
  50865. */
  50866. export class NoiseProceduralTexture extends ProceduralTexture {
  50867. private _time;
  50868. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50869. brightness: number;
  50870. /** Defines the number of octaves to process */
  50871. octaves: number;
  50872. /** Defines the level of persistence (0.8 by default) */
  50873. persistence: number;
  50874. /** Gets or sets animation speed factor (default is 1) */
  50875. animationSpeedFactor: number;
  50876. /**
  50877. * Creates a new NoiseProceduralTexture
  50878. * @param name defines the name fo the texture
  50879. * @param size defines the size of the texture (default is 256)
  50880. * @param scene defines the hosting scene
  50881. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50882. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50883. */
  50884. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50885. private _updateShaderUniforms;
  50886. protected _getDefines(): string;
  50887. /** Generate the current state of the procedural texture */
  50888. render(useCameraPostProcess?: boolean): void;
  50889. /**
  50890. * Serializes this noise procedural texture
  50891. * @returns a serialized noise procedural texture object
  50892. */
  50893. serialize(): any;
  50894. /**
  50895. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50896. * @param parsedTexture defines parsed texture data
  50897. * @param scene defines the current scene
  50898. * @param rootUrl defines the root URL containing noise procedural texture information
  50899. * @returns a parsed NoiseProceduralTexture
  50900. */
  50901. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50902. }
  50903. }
  50904. declare module BABYLON {
  50905. /**
  50906. * Raw cube texture where the raw buffers are passed in
  50907. */
  50908. export class RawCubeTexture extends CubeTexture {
  50909. /**
  50910. * Creates a cube texture where the raw buffers are passed in.
  50911. * @param scene defines the scene the texture is attached to
  50912. * @param data defines the array of data to use to create each face
  50913. * @param size defines the size of the textures
  50914. * @param format defines the format of the data
  50915. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50916. * @param generateMipMaps defines if the engine should generate the mip levels
  50917. * @param invertY defines if data must be stored with Y axis inverted
  50918. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50919. * @param compression defines the compression used (null by default)
  50920. */
  50921. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50922. /**
  50923. * Updates the raw cube texture.
  50924. * @param data defines the data to store
  50925. * @param format defines the data format
  50926. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50927. * @param invertY defines if data must be stored with Y axis inverted
  50928. * @param compression defines the compression used (null by default)
  50929. * @param level defines which level of the texture to update
  50930. */
  50931. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50932. /**
  50933. * Updates a raw cube texture with RGBD encoded data.
  50934. * @param data defines the array of data [mipmap][face] to use to create each face
  50935. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50936. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50937. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50938. * @returns a promsie that resolves when the operation is complete
  50939. */
  50940. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50941. /**
  50942. * Clones the raw cube texture.
  50943. * @return a new cube texture
  50944. */
  50945. clone(): CubeTexture;
  50946. /** @hidden */
  50947. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50948. }
  50949. }
  50950. declare module BABYLON {
  50951. /**
  50952. * Class used to store 3D textures containing user data
  50953. */
  50954. export class RawTexture3D extends Texture {
  50955. /** Gets or sets the texture format to use */
  50956. format: number;
  50957. private _engine;
  50958. /**
  50959. * Create a new RawTexture3D
  50960. * @param data defines the data of the texture
  50961. * @param width defines the width of the texture
  50962. * @param height defines the height of the texture
  50963. * @param depth defines the depth of the texture
  50964. * @param format defines the texture format to use
  50965. * @param scene defines the hosting scene
  50966. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50967. * @param invertY defines if texture must be stored with Y axis inverted
  50968. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50969. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50970. */
  50971. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50972. /** Gets or sets the texture format to use */
  50973. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50974. /**
  50975. * Update the texture with new data
  50976. * @param data defines the data to store in the texture
  50977. */
  50978. update(data: ArrayBufferView): void;
  50979. }
  50980. }
  50981. declare module BABYLON {
  50982. /**
  50983. * Creates a refraction texture used by refraction channel of the standard material.
  50984. * It is like a mirror but to see through a material.
  50985. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50986. */
  50987. export class RefractionTexture extends RenderTargetTexture {
  50988. /**
  50989. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50990. * 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.
  50991. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50992. */
  50993. refractionPlane: Plane;
  50994. /**
  50995. * Define how deep under the surface we should see.
  50996. */
  50997. depth: number;
  50998. /**
  50999. * Creates a refraction texture used by refraction channel of the standard material.
  51000. * It is like a mirror but to see through a material.
  51001. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51002. * @param name Define the texture name
  51003. * @param size Define the size of the underlying texture
  51004. * @param scene Define the scene the refraction belongs to
  51005. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51006. */
  51007. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51008. /**
  51009. * Clone the refraction texture.
  51010. * @returns the cloned texture
  51011. */
  51012. clone(): RefractionTexture;
  51013. /**
  51014. * Serialize the texture to a JSON representation you could use in Parse later on
  51015. * @returns the serialized JSON representation
  51016. */
  51017. serialize(): any;
  51018. }
  51019. }
  51020. declare module BABYLON {
  51021. /**
  51022. * Defines the options related to the creation of an HtmlElementTexture
  51023. */
  51024. export interface IHtmlElementTextureOptions {
  51025. /**
  51026. * Defines wether mip maps should be created or not.
  51027. */
  51028. generateMipMaps?: boolean;
  51029. /**
  51030. * Defines the sampling mode of the texture.
  51031. */
  51032. samplingMode?: number;
  51033. /**
  51034. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51035. */
  51036. engine: Nullable<Engine>;
  51037. /**
  51038. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51039. */
  51040. scene: Nullable<Scene>;
  51041. }
  51042. /**
  51043. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51044. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51045. * is automatically managed.
  51046. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51047. * in your application.
  51048. *
  51049. * As the update is not automatic, you need to call them manually.
  51050. */
  51051. export class HtmlElementTexture extends BaseTexture {
  51052. /**
  51053. * The texture URL.
  51054. */
  51055. element: HTMLVideoElement | HTMLCanvasElement;
  51056. private static readonly DefaultOptions;
  51057. private _textureMatrix;
  51058. private _engine;
  51059. private _isVideo;
  51060. private _generateMipMaps;
  51061. private _samplingMode;
  51062. /**
  51063. * Instantiates a HtmlElementTexture from the following parameters.
  51064. *
  51065. * @param name Defines the name of the texture
  51066. * @param element Defines the video or canvas the texture is filled with
  51067. * @param options Defines the other none mandatory texture creation options
  51068. */
  51069. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51070. private _createInternalTexture;
  51071. /**
  51072. * Returns the texture matrix used in most of the material.
  51073. */
  51074. getTextureMatrix(): Matrix;
  51075. /**
  51076. * Updates the content of the texture.
  51077. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51078. */
  51079. update(invertY?: Nullable<boolean>): void;
  51080. }
  51081. }
  51082. declare module BABYLON {
  51083. /**
  51084. * Enum used to define the target of a block
  51085. */
  51086. export enum NodeMaterialBlockTargets {
  51087. /** Vertex shader */
  51088. Vertex = 1,
  51089. /** Fragment shader */
  51090. Fragment = 2,
  51091. /** Neutral */
  51092. Neutral = 4,
  51093. /** Vertex and Fragment */
  51094. VertexAndFragment = 3
  51095. }
  51096. }
  51097. declare module BABYLON {
  51098. /**
  51099. * Defines the kind of connection point for node based material
  51100. */
  51101. export enum NodeMaterialBlockConnectionPointTypes {
  51102. /** Float */
  51103. Float = 1,
  51104. /** Int */
  51105. Int = 2,
  51106. /** Vector2 */
  51107. Vector2 = 4,
  51108. /** Vector3 */
  51109. Vector3 = 8,
  51110. /** Vector4 */
  51111. Vector4 = 16,
  51112. /** Color3 */
  51113. Color3 = 32,
  51114. /** Color4 */
  51115. Color4 = 64,
  51116. /** Matrix */
  51117. Matrix = 128,
  51118. /** Vector3 or Color3 */
  51119. Vector3OrColor3 = 40,
  51120. /** Vector3 or Vector4 */
  51121. Vector3OrVector4 = 24,
  51122. /** Vector4 or Color4 */
  51123. Vector4OrColor4 = 80,
  51124. /** Color3 or Color4 */
  51125. Color3OrColor4 = 96,
  51126. /** Vector2 or Color3 or Color4 */
  51127. Vector2OrColor3OrColor4 = 100,
  51128. /** Vector3 or Color3 or Color4 or Vector4 */
  51129. Vector3OrColor3OrVector4OrColor4 = 120,
  51130. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  51131. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  51132. /** Detect type based on connection */
  51133. AutoDetect = 1024,
  51134. /** Output type that will be defined by input type */
  51135. BasedOnInput = 2048
  51136. }
  51137. }
  51138. declare module BABYLON {
  51139. /**
  51140. * Root class for all node material optimizers
  51141. */
  51142. export class NodeMaterialOptimizer {
  51143. /**
  51144. * Function used to optimize a NodeMaterial graph
  51145. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51146. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51147. */
  51148. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51149. }
  51150. }
  51151. declare module BABYLON {
  51152. /**
  51153. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51154. */
  51155. export class VectorTransformBlock extends NodeMaterialBlock {
  51156. /**
  51157. * Defines the value to use to complement W value to transform it to a Vector4
  51158. */
  51159. complementW: number;
  51160. /**
  51161. * Defines the value to use to complement z value to transform it to a Vector4
  51162. */
  51163. complementZ: number;
  51164. /**
  51165. * Creates a new VectorTransformBlock
  51166. * @param name defines the block name
  51167. */
  51168. constructor(name: string);
  51169. /**
  51170. * Gets the current class name
  51171. * @returns the class name
  51172. */
  51173. getClassName(): string;
  51174. /**
  51175. * Gets the vector input
  51176. */
  51177. readonly vector: NodeMaterialConnectionPoint;
  51178. /**
  51179. * Gets the output component
  51180. */
  51181. readonly output: NodeMaterialConnectionPoint;
  51182. /**
  51183. * Gets the matrix transform input
  51184. */
  51185. readonly transform: NodeMaterialConnectionPoint;
  51186. protected _buildBlock(state: NodeMaterialBuildState): this;
  51187. }
  51188. }
  51189. declare module BABYLON {
  51190. /**
  51191. * Block used to output the vertex position
  51192. */
  51193. export class VertexOutputBlock extends NodeMaterialBlock {
  51194. /**
  51195. * Creates a new VertexOutputBlock
  51196. * @param name defines the block name
  51197. */
  51198. constructor(name: string);
  51199. /**
  51200. * Gets the current class name
  51201. * @returns the class name
  51202. */
  51203. getClassName(): string;
  51204. /**
  51205. * Gets the vector input component
  51206. */
  51207. readonly vector: NodeMaterialConnectionPoint;
  51208. protected _buildBlock(state: NodeMaterialBuildState): this;
  51209. }
  51210. }
  51211. declare module BABYLON {
  51212. /**
  51213. * Block used to output the final color
  51214. */
  51215. export class FragmentOutputBlock extends NodeMaterialBlock {
  51216. /**
  51217. * Gets or sets a boolean indicating if this block will output an alpha value
  51218. */
  51219. alphaBlendingEnabled: boolean;
  51220. /**
  51221. * Create a new FragmentOutputBlock
  51222. * @param name defines the block name
  51223. */
  51224. constructor(name: string);
  51225. /**
  51226. * Gets the current class name
  51227. * @returns the class name
  51228. */
  51229. getClassName(): string;
  51230. /**
  51231. * Gets the color input component
  51232. */
  51233. readonly color: NodeMaterialConnectionPoint;
  51234. protected _buildBlock(state: NodeMaterialBuildState): this;
  51235. }
  51236. }
  51237. declare module BABYLON {
  51238. /**
  51239. * Interface used to configure the node material editor
  51240. */
  51241. export interface INodeMaterialEditorOptions {
  51242. /** Define the URl to load node editor script */
  51243. editorURL?: string;
  51244. }
  51245. /** @hidden */
  51246. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51247. /** BONES */
  51248. NUM_BONE_INFLUENCERS: number;
  51249. BonesPerMesh: number;
  51250. BONETEXTURE: boolean;
  51251. /** MORPH TARGETS */
  51252. MORPHTARGETS: boolean;
  51253. MORPHTARGETS_NORMAL: boolean;
  51254. MORPHTARGETS_TANGENT: boolean;
  51255. MORPHTARGETS_UV: boolean;
  51256. NUM_MORPH_INFLUENCERS: number;
  51257. /** IMAGE PROCESSING */
  51258. IMAGEPROCESSING: boolean;
  51259. VIGNETTE: boolean;
  51260. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51261. VIGNETTEBLENDMODEOPAQUE: boolean;
  51262. TONEMAPPING: boolean;
  51263. TONEMAPPING_ACES: boolean;
  51264. CONTRAST: boolean;
  51265. EXPOSURE: boolean;
  51266. COLORCURVES: boolean;
  51267. COLORGRADING: boolean;
  51268. COLORGRADING3D: boolean;
  51269. SAMPLER3DGREENDEPTH: boolean;
  51270. SAMPLER3DBGRMAP: boolean;
  51271. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51272. constructor();
  51273. setValue(name: string, value: boolean): void;
  51274. }
  51275. /**
  51276. * Class used to configure NodeMaterial
  51277. */
  51278. export interface INodeMaterialOptions {
  51279. /**
  51280. * Defines if blocks should emit comments
  51281. */
  51282. emitComments: boolean;
  51283. }
  51284. /**
  51285. * Class used to create a node based material built by assembling shader blocks
  51286. */
  51287. export class NodeMaterial extends PushMaterial {
  51288. private _options;
  51289. private _vertexCompilationState;
  51290. private _fragmentCompilationState;
  51291. private _sharedData;
  51292. private _buildId;
  51293. private _buildWasSuccessful;
  51294. private _cachedWorldViewMatrix;
  51295. private _cachedWorldViewProjectionMatrix;
  51296. private _optimizers;
  51297. /** Define the URl to load node editor script */
  51298. static EditorURL: string;
  51299. private BJSNODEMATERIALEDITOR;
  51300. /** Get the inspector from bundle or global */
  51301. private _getGlobalNodeMaterialEditor;
  51302. /**
  51303. * Defines the maximum number of lights that can be used in the material
  51304. */
  51305. maxSimultaneousLights: number;
  51306. /**
  51307. * Observable raised when the material is built
  51308. */
  51309. onBuildObservable: Observable<NodeMaterial>;
  51310. /**
  51311. * Gets or sets the root nodes of the material vertex shader
  51312. */
  51313. _vertexOutputNodes: NodeMaterialBlock[];
  51314. /**
  51315. * Gets or sets the root nodes of the material fragment (pixel) shader
  51316. */
  51317. _fragmentOutputNodes: NodeMaterialBlock[];
  51318. /** Gets or sets options to control the node material overall behavior */
  51319. options: INodeMaterialOptions;
  51320. /**
  51321. * Default configuration related to image processing available in the standard Material.
  51322. */
  51323. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51324. /**
  51325. * Gets the image processing configuration used either in this material.
  51326. */
  51327. /**
  51328. * Sets the Default image processing configuration used either in the this material.
  51329. *
  51330. * If sets to null, the scene one is in use.
  51331. */
  51332. imageProcessingConfiguration: ImageProcessingConfiguration;
  51333. /**
  51334. * Create a new node based material
  51335. * @param name defines the material name
  51336. * @param scene defines the hosting scene
  51337. * @param options defines creation option
  51338. */
  51339. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51340. /**
  51341. * Gets the current class name of the material e.g. "NodeMaterial"
  51342. * @returns the class name
  51343. */
  51344. getClassName(): string;
  51345. /**
  51346. * Keep track of the image processing observer to allow dispose and replace.
  51347. */
  51348. private _imageProcessingObserver;
  51349. /**
  51350. * Attaches a new image processing configuration to the Standard Material.
  51351. * @param configuration
  51352. */
  51353. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51354. /**
  51355. * Adds a new optimizer to the list of optimizers
  51356. * @param optimizer defines the optimizers to add
  51357. * @returns the current material
  51358. */
  51359. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51360. /**
  51361. * Remove an optimizer from the list of optimizers
  51362. * @param optimizer defines the optimizers to remove
  51363. * @returns the current material
  51364. */
  51365. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51366. /**
  51367. * Add a new block to the list of output nodes
  51368. * @param node defines the node to add
  51369. * @returns the current material
  51370. */
  51371. addOutputNode(node: NodeMaterialBlock): this;
  51372. /**
  51373. * Remove a block from the list of root nodes
  51374. * @param node defines the node to remove
  51375. * @returns the current material
  51376. */
  51377. removeOutputNode(node: NodeMaterialBlock): this;
  51378. private _addVertexOutputNode;
  51379. private _removeVertexOutputNode;
  51380. private _addFragmentOutputNode;
  51381. private _removeFragmentOutputNode;
  51382. /**
  51383. * Specifies if the material will require alpha blending
  51384. * @returns a boolean specifying if alpha blending is needed
  51385. */
  51386. needAlphaBlending(): boolean;
  51387. /**
  51388. * Specifies if this material should be rendered in alpha test mode
  51389. * @returns a boolean specifying if an alpha test is needed.
  51390. */
  51391. needAlphaTesting(): boolean;
  51392. private _initializeBlock;
  51393. private _resetDualBlocks;
  51394. /**
  51395. * Build the material and generates the inner effect
  51396. * @param verbose defines if the build should log activity
  51397. */
  51398. build(verbose?: boolean): void;
  51399. /**
  51400. * Runs an otpimization phase to try to improve the shader code
  51401. */
  51402. optimize(): void;
  51403. private _prepareDefinesForAttributes;
  51404. /**
  51405. * Get if the submesh is ready to be used and all its information available.
  51406. * Child classes can use it to update shaders
  51407. * @param mesh defines the mesh to check
  51408. * @param subMesh defines which submesh to check
  51409. * @param useInstances specifies that instances should be used
  51410. * @returns a boolean indicating that the submesh is ready or not
  51411. */
  51412. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51413. /**
  51414. * Get a string representing the shaders built by the current node graph
  51415. */
  51416. readonly compiledShaders: string;
  51417. /**
  51418. * Binds the world matrix to the material
  51419. * @param world defines the world transformation matrix
  51420. */
  51421. bindOnlyWorldMatrix(world: Matrix): void;
  51422. /**
  51423. * Binds the submesh to this material by preparing the effect and shader to draw
  51424. * @param world defines the world transformation matrix
  51425. * @param mesh defines the mesh containing the submesh
  51426. * @param subMesh defines the submesh to bind the material to
  51427. */
  51428. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51429. /**
  51430. * Gets the active textures from the material
  51431. * @returns an array of textures
  51432. */
  51433. getActiveTextures(): BaseTexture[];
  51434. /**
  51435. * Specifies if the material uses a texture
  51436. * @param texture defines the texture to check against the material
  51437. * @returns a boolean specifying if the material uses the texture
  51438. */
  51439. hasTexture(texture: BaseTexture): boolean;
  51440. /**
  51441. * Disposes the material
  51442. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51443. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51444. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51445. */
  51446. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51447. /** Creates the node editor window. */
  51448. private _createNodeEditor;
  51449. /**
  51450. * Launch the node material editor
  51451. * @param config Define the configuration of the editor
  51452. * @return a promise fulfilled when the node editor is visible
  51453. */
  51454. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51455. /**
  51456. * Clear the current material
  51457. */
  51458. clear(): void;
  51459. /**
  51460. * Clear the current material and set it to a default state
  51461. */
  51462. setToDefault(): void;
  51463. }
  51464. }
  51465. declare module BABYLON {
  51466. /**
  51467. * Block used to read a texture from a sampler
  51468. */
  51469. export class TextureBlock extends NodeMaterialBlock {
  51470. private _defineName;
  51471. private _samplerName;
  51472. private _transformedUVName;
  51473. private _textureTransformName;
  51474. private _textureInfoName;
  51475. private _mainUVName;
  51476. private _mainUVDefineName;
  51477. /**
  51478. * Gets or sets the texture associated with the node
  51479. */
  51480. texture: Nullable<BaseTexture>;
  51481. /**
  51482. * Create a new TextureBlock
  51483. * @param name defines the block name
  51484. */
  51485. constructor(name: string);
  51486. /**
  51487. * Gets the current class name
  51488. * @returns the class name
  51489. */
  51490. getClassName(): string;
  51491. /**
  51492. * Gets the uv input component
  51493. */
  51494. readonly uv: NodeMaterialConnectionPoint;
  51495. /**
  51496. * Gets the output component
  51497. */
  51498. readonly output: NodeMaterialConnectionPoint;
  51499. autoConfigure(): void;
  51500. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51501. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51502. isReady(): boolean;
  51503. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51504. private _injectVertexCode;
  51505. private _writeOutput;
  51506. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51507. }
  51508. }
  51509. declare module BABYLON {
  51510. /**
  51511. * Class used to store shared data between 2 NodeMaterialBuildState
  51512. */
  51513. export class NodeMaterialBuildStateSharedData {
  51514. /**
  51515. * Gets the list of emitted varyings
  51516. */
  51517. varyings: string[];
  51518. /**
  51519. * Gets the varying declaration string
  51520. */
  51521. varyingDeclaration: string;
  51522. /**
  51523. * Input blocks
  51524. */
  51525. inputBlocks: InputBlock[];
  51526. /**
  51527. * Input blocks
  51528. */
  51529. textureBlocks: TextureBlock[];
  51530. /**
  51531. * Bindable blocks (Blocks that need to set data to the effect)
  51532. */
  51533. bindableBlocks: NodeMaterialBlock[];
  51534. /**
  51535. * List of blocks that can provide a compilation fallback
  51536. */
  51537. blocksWithFallbacks: NodeMaterialBlock[];
  51538. /**
  51539. * List of blocks that can provide a define update
  51540. */
  51541. blocksWithDefines: NodeMaterialBlock[];
  51542. /**
  51543. * List of blocks that can provide a repeatable content
  51544. */
  51545. repeatableContentBlocks: NodeMaterialBlock[];
  51546. /**
  51547. * List of blocks that can provide a dynamic list of uniforms
  51548. */
  51549. dynamicUniformBlocks: NodeMaterialBlock[];
  51550. /**
  51551. * List of blocks that can block the isReady function for the material
  51552. */
  51553. blockingBlocks: NodeMaterialBlock[];
  51554. /**
  51555. * Build Id used to avoid multiple recompilations
  51556. */
  51557. buildId: number;
  51558. /** List of emitted variables */
  51559. variableNames: {
  51560. [key: string]: number;
  51561. };
  51562. /** List of emitted defines */
  51563. defineNames: {
  51564. [key: string]: number;
  51565. };
  51566. /** Should emit comments? */
  51567. emitComments: boolean;
  51568. /** Emit build activity */
  51569. verbose: boolean;
  51570. /**
  51571. * Gets the compilation hints emitted at compilation time
  51572. */
  51573. hints: {
  51574. needWorldViewMatrix: boolean;
  51575. needWorldViewProjectionMatrix: boolean;
  51576. needAlphaBlending: boolean;
  51577. needAlphaTesting: boolean;
  51578. };
  51579. /**
  51580. * List of compilation checks
  51581. */
  51582. checks: {
  51583. emitVertex: boolean;
  51584. emitFragment: boolean;
  51585. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  51586. };
  51587. /** Creates a new shared data */
  51588. constructor();
  51589. /**
  51590. * Emits console errors and exceptions if there is a failing check
  51591. */
  51592. emitErrors(): void;
  51593. }
  51594. }
  51595. declare module BABYLON {
  51596. /**
  51597. * Class used to store node based material build state
  51598. */
  51599. export class NodeMaterialBuildState {
  51600. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  51601. supportUniformBuffers: boolean;
  51602. /**
  51603. * Gets the list of emitted attributes
  51604. */
  51605. attributes: string[];
  51606. /**
  51607. * Gets the list of emitted uniforms
  51608. */
  51609. uniforms: string[];
  51610. /**
  51611. * Gets the list of emitted uniform buffers
  51612. */
  51613. uniformBuffers: string[];
  51614. /**
  51615. * Gets the list of emitted samplers
  51616. */
  51617. samplers: string[];
  51618. /**
  51619. * Gets the list of emitted functions
  51620. */
  51621. functions: {
  51622. [key: string]: string;
  51623. };
  51624. /**
  51625. * Gets the target of the compilation state
  51626. */
  51627. target: NodeMaterialBlockTargets;
  51628. /**
  51629. * Gets the list of emitted counters
  51630. */
  51631. counters: {
  51632. [key: string]: number;
  51633. };
  51634. /**
  51635. * Shared data between multiple NodeMaterialBuildState instances
  51636. */
  51637. sharedData: NodeMaterialBuildStateSharedData;
  51638. /** @hidden */
  51639. _vertexState: NodeMaterialBuildState;
  51640. /** @hidden */
  51641. _attributeDeclaration: string;
  51642. /** @hidden */
  51643. _uniformDeclaration: string;
  51644. /** @hidden */
  51645. _samplerDeclaration: string;
  51646. /** @hidden */
  51647. _varyingTransfer: string;
  51648. private _repeatableContentAnchorIndex;
  51649. /** @hidden */
  51650. _builtCompilationString: string;
  51651. /**
  51652. * Gets the emitted compilation strings
  51653. */
  51654. compilationString: string;
  51655. /**
  51656. * Finalize the compilation strings
  51657. * @param state defines the current compilation state
  51658. */
  51659. finalize(state: NodeMaterialBuildState): void;
  51660. /** @hidden */
  51661. readonly _repeatableContentAnchor: string;
  51662. /** @hidden */
  51663. _getFreeVariableName(prefix: string): string;
  51664. /** @hidden */
  51665. _getFreeDefineName(prefix: string): string;
  51666. /** @hidden */
  51667. _excludeVariableName(name: string): void;
  51668. /** @hidden */
  51669. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  51670. /** @hidden */
  51671. _emitFunction(name: string, code: string, comments: string): void;
  51672. /** @hidden */
  51673. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  51674. replaceStrings?: {
  51675. search: RegExp;
  51676. replace: string;
  51677. }[];
  51678. repeatKey?: string;
  51679. }): string;
  51680. /** @hidden */
  51681. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  51682. repeatKey?: string;
  51683. removeAttributes?: boolean;
  51684. removeUniforms?: boolean;
  51685. removeVaryings?: boolean;
  51686. removeIfDef?: boolean;
  51687. replaceStrings?: {
  51688. search: RegExp;
  51689. replace: string;
  51690. }[];
  51691. }, storeKey?: string): void;
  51692. /** @hidden */
  51693. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51694. /** @hidden */
  51695. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51696. }
  51697. }
  51698. declare module BABYLON {
  51699. /**
  51700. * Defines a block that can be used inside a node based material
  51701. */
  51702. export class NodeMaterialBlock {
  51703. private _buildId;
  51704. private _buildTarget;
  51705. private _target;
  51706. private _isFinalMerger;
  51707. private _isInput;
  51708. /** @hidden */
  51709. _inputs: NodeMaterialConnectionPoint[];
  51710. /** @hidden */
  51711. _outputs: NodeMaterialConnectionPoint[];
  51712. /**
  51713. * Gets or sets the name of the block
  51714. */
  51715. name: string;
  51716. /**
  51717. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51718. */
  51719. readonly isFinalMerger: boolean;
  51720. /**
  51721. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  51722. */
  51723. readonly isInput: boolean;
  51724. /**
  51725. * Gets or sets the build Id
  51726. */
  51727. buildId: number;
  51728. /**
  51729. * Gets or sets the target of the block
  51730. */
  51731. target: NodeMaterialBlockTargets;
  51732. /**
  51733. * Gets the list of input points
  51734. */
  51735. readonly inputs: NodeMaterialConnectionPoint[];
  51736. /** Gets the list of output points */
  51737. readonly outputs: NodeMaterialConnectionPoint[];
  51738. /**
  51739. * Find an input by its name
  51740. * @param name defines the name of the input to look for
  51741. * @returns the input or null if not found
  51742. */
  51743. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51744. /**
  51745. * Find an output by its name
  51746. * @param name defines the name of the outputto look for
  51747. * @returns the output or null if not found
  51748. */
  51749. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51750. /**
  51751. * Creates a new NodeMaterialBlock
  51752. * @param name defines the block name
  51753. * @param target defines the target of that block (Vertex by default)
  51754. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51755. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  51756. */
  51757. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  51758. /**
  51759. * Initialize the block and prepare the context for build
  51760. * @param state defines the state that will be used for the build
  51761. */
  51762. initialize(state: NodeMaterialBuildState): void;
  51763. /**
  51764. * Bind data to effect. Will only be called for blocks with isBindable === true
  51765. * @param effect defines the effect to bind data to
  51766. * @param nodeMaterial defines the hosting NodeMaterial
  51767. * @param mesh defines the mesh that will be rendered
  51768. */
  51769. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51770. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51771. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51772. protected _writeFloat(value: number): string;
  51773. /**
  51774. * Gets the current class name e.g. "NodeMaterialBlock"
  51775. * @returns the class name
  51776. */
  51777. getClassName(): string;
  51778. /**
  51779. * Register a new input. Must be called inside a block constructor
  51780. * @param name defines the connection point name
  51781. * @param type defines the connection point type
  51782. * @param isOptional defines a boolean indicating that this input can be omitted
  51783. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51784. * @returns the current block
  51785. */
  51786. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51787. /**
  51788. * Register a new output. Must be called inside a block constructor
  51789. * @param name defines the connection point name
  51790. * @param type defines the connection point type
  51791. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51792. * @returns the current block
  51793. */
  51794. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51795. /**
  51796. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51797. * @param forOutput defines an optional connection point to check compatibility with
  51798. * @returns the first available input or null
  51799. */
  51800. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51801. /**
  51802. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51803. * @param forBlock defines an optional block to check compatibility with
  51804. * @returns the first available input or null
  51805. */
  51806. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51807. /**
  51808. * Connect current block with another block
  51809. * @param other defines the block to connect with
  51810. * @param options define the various options to help pick the right connections
  51811. * @returns the current block
  51812. */
  51813. connectTo(other: NodeMaterialBlock, options?: {
  51814. input?: string;
  51815. output?: string;
  51816. outputSwizzle?: string;
  51817. }): this | undefined;
  51818. protected _buildBlock(state: NodeMaterialBuildState): void;
  51819. /**
  51820. * Add uniforms, samplers and uniform buffers at compilation time
  51821. * @param state defines the state to update
  51822. * @param nodeMaterial defines the node material requesting the update
  51823. * @param defines defines the material defines to update
  51824. */
  51825. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51826. /**
  51827. * Add potential fallbacks if shader compilation fails
  51828. * @param mesh defines the mesh to be rendered
  51829. * @param fallbacks defines the current prioritized list of fallbacks
  51830. */
  51831. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51832. /**
  51833. * Update defines for shader compilation
  51834. * @param mesh defines the mesh to be rendered
  51835. * @param nodeMaterial defines the node material requesting the update
  51836. * @param defines defines the material defines to update
  51837. * @param useInstances specifies that instances should be used
  51838. */
  51839. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51840. /**
  51841. * Initialize defines for shader compilation
  51842. * @param mesh defines the mesh to be rendered
  51843. * @param nodeMaterial defines the node material requesting the update
  51844. * @param defines defines the material defines to be prepared
  51845. * @param useInstances specifies that instances should be used
  51846. */
  51847. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51848. /**
  51849. * Lets the block try to connect some inputs automatically
  51850. */
  51851. autoConfigure(): void;
  51852. /**
  51853. * Function called when a block is declared as repeatable content generator
  51854. * @param vertexShaderState defines the current compilation state for the vertex shader
  51855. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51856. * @param mesh defines the mesh to be rendered
  51857. * @param defines defines the material defines to update
  51858. */
  51859. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51860. /**
  51861. * Checks if the block is ready
  51862. * @param mesh defines the mesh to be rendered
  51863. * @param nodeMaterial defines the node material requesting the update
  51864. * @param defines defines the material defines to update
  51865. * @param useInstances specifies that instances should be used
  51866. * @returns true if the block is ready
  51867. */
  51868. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  51869. private _processBuild;
  51870. /**
  51871. * Compile the current node and generate the shader code
  51872. * @param state defines the current compilation state (uniforms, samplers, current string)
  51873. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  51874. * @returns true if already built
  51875. */
  51876. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  51877. }
  51878. }
  51879. declare module BABYLON {
  51880. /**
  51881. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  51882. */
  51883. export enum NodeMaterialBlockConnectionPointMode {
  51884. /** Value is an uniform */
  51885. Uniform = 0,
  51886. /** Value is a mesh attribute */
  51887. Attribute = 1,
  51888. /** Value is a varying between vertex and fragment shaders */
  51889. Varying = 2,
  51890. /** Mode is undefined */
  51891. Undefined = 3
  51892. }
  51893. }
  51894. declare module BABYLON {
  51895. /**
  51896. * Enum used to define well known values e.g. values automatically provided by the system
  51897. */
  51898. export enum NodeMaterialWellKnownValues {
  51899. /** World */
  51900. World = 1,
  51901. /** View */
  51902. View = 2,
  51903. /** Projection */
  51904. Projection = 3,
  51905. /** ViewProjection */
  51906. ViewProjection = 4,
  51907. /** WorldView */
  51908. WorldView = 5,
  51909. /** WorldViewProjection */
  51910. WorldViewProjection = 6,
  51911. /** CameraPosition */
  51912. CameraPosition = 7,
  51913. /** Fog Color */
  51914. FogColor = 8
  51915. }
  51916. }
  51917. declare module BABYLON {
  51918. /**
  51919. * Block used to expose an input value
  51920. */
  51921. export class InputBlock extends NodeMaterialBlock {
  51922. private _mode;
  51923. private _associatedVariableName;
  51924. private _storedValue;
  51925. private _valueCallback;
  51926. private _type;
  51927. /** @hidden */
  51928. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51929. /**
  51930. * Gets or sets the connection point type (default is float)
  51931. */
  51932. readonly type: NodeMaterialBlockConnectionPointTypes;
  51933. /**
  51934. * Creates a new InputBlock
  51935. * @param name defines the block name
  51936. * @param target defines the target of that block (Vertex by default)
  51937. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  51938. */
  51939. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  51940. /**
  51941. * Gets the output component
  51942. */
  51943. readonly output: NodeMaterialConnectionPoint;
  51944. /**
  51945. * Set the source of this connection point to a vertex attribute
  51946. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  51947. * @returns the current connection point
  51948. */
  51949. setAsAttribute(attributeName?: string): InputBlock;
  51950. /**
  51951. * Set the source of this connection point to a well known value
  51952. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  51953. * @returns the current connection point
  51954. */
  51955. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  51956. /**
  51957. * Gets or sets the value of that point.
  51958. * Please note that this value will be ignored if valueCallback is defined
  51959. */
  51960. value: any;
  51961. /**
  51962. * Gets or sets a callback used to get the value of that point.
  51963. * Please note that setting this value will force the connection point to ignore the value property
  51964. */
  51965. valueCallback: () => any;
  51966. /**
  51967. * Gets or sets the associated variable name in the shader
  51968. */
  51969. associatedVariableName: string;
  51970. /**
  51971. * Gets a boolean indicating that this connection point not defined yet
  51972. */
  51973. readonly isUndefined: boolean;
  51974. /**
  51975. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  51976. * In this case the connection point name must be the name of the uniform to use.
  51977. * Can only be set on inputs
  51978. */
  51979. isUniform: boolean;
  51980. /**
  51981. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  51982. * In this case the connection point name must be the name of the attribute to use
  51983. * Can only be set on inputs
  51984. */
  51985. isAttribute: boolean;
  51986. /**
  51987. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  51988. * Can only be set on exit points
  51989. */
  51990. isVarying: boolean;
  51991. /**
  51992. * Gets a boolean indicating that the current connection point is a well known value
  51993. */
  51994. readonly isWellKnownValue: boolean;
  51995. /**
  51996. * Gets or sets the current well known value or null if not defined as well know value
  51997. */
  51998. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51999. /**
  52000. * Gets the current class name
  52001. * @returns the class name
  52002. */
  52003. getClassName(): string;
  52004. private _emitDefine;
  52005. /**
  52006. * Set the input block to its default value (based on its type)
  52007. */
  52008. setDefaultValue(): void;
  52009. private _emit;
  52010. /** @hidden */
  52011. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52012. /** @hidden */
  52013. _transmit(effect: Effect, scene: Scene): void;
  52014. protected _buildBlock(state: NodeMaterialBuildState): void;
  52015. }
  52016. }
  52017. declare module BABYLON {
  52018. /**
  52019. * Defines a connection point for a block
  52020. */
  52021. export class NodeMaterialConnectionPoint {
  52022. /** @hidden */
  52023. _ownerBlock: NodeMaterialBlock;
  52024. /** @hidden */
  52025. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52026. private _endpoints;
  52027. private _associatedVariableName;
  52028. /** @hidden */
  52029. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52030. private _type;
  52031. /** @hidden */
  52032. _enforceAssociatedVariableName: boolean;
  52033. /**
  52034. * Gets or sets the associated variable name in the shader
  52035. */
  52036. associatedVariableName: string;
  52037. /**
  52038. * Gets or sets the connection point type (default is float)
  52039. */
  52040. type: NodeMaterialBlockConnectionPointTypes;
  52041. /**
  52042. * Gets or sets the connection point name
  52043. */
  52044. name: string;
  52045. /**
  52046. * Gets or sets the swizzle to apply to this connection point when reading or writing
  52047. */
  52048. swizzle: string;
  52049. /**
  52050. * Gets or sets a boolean indicating that this connection point can be omitted
  52051. */
  52052. isOptional: boolean;
  52053. /**
  52054. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52055. */
  52056. define: string;
  52057. /** Gets or sets the target of that connection point */
  52058. target: NodeMaterialBlockTargets;
  52059. /**
  52060. * Gets a boolean indicating that the current point is connected
  52061. */
  52062. readonly isConnected: boolean;
  52063. /**
  52064. * Gets a boolean indicating that the current point is connected to an input block
  52065. */
  52066. readonly isConnectedToInput: boolean;
  52067. /**
  52068. * Gets a the connected input block (if any)
  52069. */
  52070. readonly connectInputBlock: Nullable<InputBlock>;
  52071. /** Get the other side of the connection (if any) */
  52072. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52073. /** Get the block that owns this connection point */
  52074. readonly ownerBlock: NodeMaterialBlock;
  52075. /** Get the block connected on the other side of this connection (if any) */
  52076. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52077. /** Get the block connected on the endpoints of this connection (if any) */
  52078. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52079. /** Gets the list of connected endpoints */
  52080. readonly endpoints: NodeMaterialConnectionPoint[];
  52081. /**
  52082. * Creates a new connection point
  52083. * @param name defines the connection point name
  52084. * @param ownerBlock defines the block hosting this connection point
  52085. */
  52086. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52087. /**
  52088. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52089. * @returns the class name
  52090. */
  52091. getClassName(): string;
  52092. private _getTypeLength;
  52093. /**
  52094. * Gets an boolean indicating if the current point can be connected to another point
  52095. * @param connectionPoint defines the other connection point
  52096. * @returns true if the connection is possible
  52097. */
  52098. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52099. /**
  52100. * Connect this point to another connection point
  52101. * @param connectionPoint defines the other connection point
  52102. * @returns the current connection point
  52103. */
  52104. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52105. /**
  52106. * Disconnect this point from one of his endpoint
  52107. * @param endpoint defines the other connection point
  52108. * @returns the current connection point
  52109. */
  52110. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52111. }
  52112. }
  52113. declare module BABYLON {
  52114. /**
  52115. * Block used to add support for vertex skinning (bones)
  52116. */
  52117. export class BonesBlock extends NodeMaterialBlock {
  52118. /**
  52119. * Creates a new BonesBlock
  52120. * @param name defines the block name
  52121. */
  52122. constructor(name: string);
  52123. /**
  52124. * Initialize the block and prepare the context for build
  52125. * @param state defines the state that will be used for the build
  52126. */
  52127. initialize(state: NodeMaterialBuildState): void;
  52128. /**
  52129. * Gets the current class name
  52130. * @returns the class name
  52131. */
  52132. getClassName(): string;
  52133. /**
  52134. * Gets the matrix indices input component
  52135. */
  52136. readonly matricesIndices: NodeMaterialConnectionPoint;
  52137. /**
  52138. * Gets the matrix weights input component
  52139. */
  52140. readonly matricesWeights: NodeMaterialConnectionPoint;
  52141. /**
  52142. * Gets the extra matrix indices input component
  52143. */
  52144. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52145. /**
  52146. * Gets the extra matrix weights input component
  52147. */
  52148. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52149. /**
  52150. * Gets the world input component
  52151. */
  52152. readonly world: NodeMaterialConnectionPoint;
  52153. /**
  52154. * Gets the output component
  52155. */
  52156. readonly output: NodeMaterialConnectionPoint;
  52157. autoConfigure(): void;
  52158. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52159. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52160. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52161. protected _buildBlock(state: NodeMaterialBuildState): this;
  52162. }
  52163. }
  52164. declare module BABYLON {
  52165. /**
  52166. * Block used to add support for instances
  52167. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52168. */
  52169. export class InstancesBlock extends NodeMaterialBlock {
  52170. /**
  52171. * Creates a new InstancesBlock
  52172. * @param name defines the block name
  52173. */
  52174. constructor(name: string);
  52175. /**
  52176. * Gets the current class name
  52177. * @returns the class name
  52178. */
  52179. getClassName(): string;
  52180. /**
  52181. * Gets the first world row input component
  52182. */
  52183. readonly world0: NodeMaterialConnectionPoint;
  52184. /**
  52185. * Gets the second world row input component
  52186. */
  52187. readonly world1: NodeMaterialConnectionPoint;
  52188. /**
  52189. * Gets the third world row input component
  52190. */
  52191. readonly world2: NodeMaterialConnectionPoint;
  52192. /**
  52193. * Gets the forth world row input component
  52194. */
  52195. readonly world3: NodeMaterialConnectionPoint;
  52196. /**
  52197. * Gets the world input component
  52198. */
  52199. readonly world: NodeMaterialConnectionPoint;
  52200. /**
  52201. * Gets the output component
  52202. */
  52203. readonly output: NodeMaterialConnectionPoint;
  52204. autoConfigure(): void;
  52205. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52206. protected _buildBlock(state: NodeMaterialBuildState): this;
  52207. }
  52208. }
  52209. declare module BABYLON {
  52210. /**
  52211. * Block used to add morph targets support to vertex shader
  52212. */
  52213. export class MorphTargetsBlock extends NodeMaterialBlock {
  52214. private _repeatableContentAnchor;
  52215. private _repeatebleContentGenerated;
  52216. /**
  52217. * Create a new MorphTargetsBlock
  52218. * @param name defines the block name
  52219. */
  52220. constructor(name: string);
  52221. /**
  52222. * Gets the current class name
  52223. * @returns the class name
  52224. */
  52225. getClassName(): string;
  52226. /**
  52227. * Gets the position input component
  52228. */
  52229. readonly position: NodeMaterialConnectionPoint;
  52230. /**
  52231. * Gets the normal input component
  52232. */
  52233. readonly normal: NodeMaterialConnectionPoint;
  52234. /**
  52235. * Gets the tangent input component
  52236. */
  52237. readonly tangent: NodeMaterialConnectionPoint;
  52238. /**
  52239. * Gets the tangent input component
  52240. */
  52241. readonly uv: NodeMaterialConnectionPoint;
  52242. /**
  52243. * Gets the position output component
  52244. */
  52245. readonly positionOutput: NodeMaterialConnectionPoint;
  52246. /**
  52247. * Gets the normal output component
  52248. */
  52249. readonly normalOutput: NodeMaterialConnectionPoint;
  52250. /**
  52251. * Gets the tangent output component
  52252. */
  52253. readonly tangentOutput: NodeMaterialConnectionPoint;
  52254. /**
  52255. * Gets the tangent output component
  52256. */
  52257. readonly uvOutput: NodeMaterialConnectionPoint;
  52258. initialize(state: NodeMaterialBuildState): void;
  52259. autoConfigure(): void;
  52260. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52261. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52262. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52263. protected _buildBlock(state: NodeMaterialBuildState): this;
  52264. }
  52265. }
  52266. declare module BABYLON {
  52267. /**
  52268. * Block used to add an alpha test in the fragment shader
  52269. */
  52270. export class AlphaTestBlock extends NodeMaterialBlock {
  52271. /**
  52272. * Gets or sets the alpha value where alpha testing happens
  52273. */
  52274. alphaCutOff: number;
  52275. /**
  52276. * Create a new AlphaTestBlock
  52277. * @param name defines the block name
  52278. */
  52279. constructor(name: string);
  52280. /**
  52281. * Gets the current class name
  52282. * @returns the class name
  52283. */
  52284. getClassName(): string;
  52285. /**
  52286. * Gets the color input component
  52287. */
  52288. readonly color: NodeMaterialConnectionPoint;
  52289. protected _buildBlock(state: NodeMaterialBuildState): this;
  52290. }
  52291. }
  52292. declare module BABYLON {
  52293. /**
  52294. * Block used to create a Color4 out of 4 inputs (one for each component)
  52295. */
  52296. export class RGBAMergerBlock extends NodeMaterialBlock {
  52297. /**
  52298. * Create a new RGBAMergerBlock
  52299. * @param name defines the block name
  52300. */
  52301. constructor(name: string);
  52302. /**
  52303. * Gets the current class name
  52304. * @returns the class name
  52305. */
  52306. getClassName(): string;
  52307. /**
  52308. * Gets the R input component
  52309. */
  52310. readonly r: NodeMaterialConnectionPoint;
  52311. /**
  52312. * Gets the G input component
  52313. */
  52314. readonly g: NodeMaterialConnectionPoint;
  52315. /**
  52316. * Gets the B input component
  52317. */
  52318. readonly b: NodeMaterialConnectionPoint;
  52319. /**
  52320. * Gets the RGB input component
  52321. */
  52322. readonly rgb: NodeMaterialConnectionPoint;
  52323. /**
  52324. * Gets the R input component
  52325. */
  52326. readonly a: NodeMaterialConnectionPoint;
  52327. /**
  52328. * Gets the output component
  52329. */
  52330. readonly output: NodeMaterialConnectionPoint;
  52331. protected _buildBlock(state: NodeMaterialBuildState): this;
  52332. }
  52333. }
  52334. declare module BABYLON {
  52335. /**
  52336. * Block used to create a Color3 out of 3 inputs (one for each component)
  52337. */
  52338. export class RGBMergerBlock extends NodeMaterialBlock {
  52339. /**
  52340. * Create a new RGBMergerBlock
  52341. * @param name defines the block name
  52342. */
  52343. constructor(name: string);
  52344. /**
  52345. * Gets the current class name
  52346. * @returns the class name
  52347. */
  52348. getClassName(): string;
  52349. /**
  52350. * Gets the R component input
  52351. */
  52352. readonly r: NodeMaterialConnectionPoint;
  52353. /**
  52354. * Gets the G component input
  52355. */
  52356. readonly g: NodeMaterialConnectionPoint;
  52357. /**
  52358. * Gets the B component input
  52359. */
  52360. readonly b: NodeMaterialConnectionPoint;
  52361. /**
  52362. * Gets the output component
  52363. */
  52364. readonly output: NodeMaterialConnectionPoint;
  52365. protected _buildBlock(state: NodeMaterialBuildState): this;
  52366. }
  52367. }
  52368. declare module BABYLON {
  52369. /**
  52370. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  52371. */
  52372. export class RGBASplitterBlock extends NodeMaterialBlock {
  52373. /**
  52374. * Create a new RGBASplitterBlock
  52375. * @param name defines the block name
  52376. */
  52377. constructor(name: string);
  52378. /**
  52379. * Gets the current class name
  52380. * @returns the class name
  52381. */
  52382. getClassName(): string;
  52383. /**
  52384. * Gets the input component
  52385. */
  52386. readonly input: NodeMaterialConnectionPoint;
  52387. protected _buildBlock(state: NodeMaterialBuildState): this;
  52388. }
  52389. }
  52390. declare module BABYLON {
  52391. /**
  52392. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  52393. */
  52394. export class RGBSplitterBlock extends NodeMaterialBlock {
  52395. /**
  52396. * Create a new RGBSplitterBlock
  52397. * @param name defines the block name
  52398. */
  52399. constructor(name: string);
  52400. /**
  52401. * Gets the current class name
  52402. * @returns the class name
  52403. */
  52404. getClassName(): string;
  52405. /**
  52406. * Gets the input component
  52407. */
  52408. readonly input: NodeMaterialConnectionPoint;
  52409. protected _buildBlock(state: NodeMaterialBuildState): this;
  52410. }
  52411. }
  52412. declare module BABYLON {
  52413. /**
  52414. * Block used to add image processing support to fragment shader
  52415. */
  52416. export class ImageProcessingBlock extends NodeMaterialBlock {
  52417. /**
  52418. * Create a new ImageProcessingBlock
  52419. * @param name defines the block name
  52420. */
  52421. constructor(name: string);
  52422. /**
  52423. * Gets the current class name
  52424. * @returns the class name
  52425. */
  52426. getClassName(): string;
  52427. /**
  52428. * Gets the color input component
  52429. */
  52430. readonly color: NodeMaterialConnectionPoint;
  52431. /**
  52432. * Gets the output component
  52433. */
  52434. readonly output: NodeMaterialConnectionPoint;
  52435. /**
  52436. * Initialize the block and prepare the context for build
  52437. * @param state defines the state that will be used for the build
  52438. */
  52439. initialize(state: NodeMaterialBuildState): void;
  52440. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  52441. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52442. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52443. protected _buildBlock(state: NodeMaterialBuildState): this;
  52444. }
  52445. }
  52446. declare module BABYLON {
  52447. /**
  52448. * Block used to add support for scene fog
  52449. */
  52450. export class FogBlock extends NodeMaterialBlock {
  52451. private _fogDistanceName;
  52452. private _fogParameters;
  52453. /**
  52454. * Create a new FogBlock
  52455. * @param name defines the block name
  52456. */
  52457. constructor(name: string);
  52458. /**
  52459. * Gets the current class name
  52460. * @returns the class name
  52461. */
  52462. getClassName(): string;
  52463. /**
  52464. * Gets the world position input component
  52465. */
  52466. readonly worldPosition: NodeMaterialConnectionPoint;
  52467. /**
  52468. * Gets the view input component
  52469. */
  52470. readonly view: NodeMaterialConnectionPoint;
  52471. /**
  52472. * Gets the color input component
  52473. */
  52474. readonly color: NodeMaterialConnectionPoint;
  52475. /**
  52476. * Gets the fog color input component
  52477. */
  52478. readonly fogColor: NodeMaterialConnectionPoint;
  52479. /**
  52480. * Gets the output component
  52481. */
  52482. readonly output: NodeMaterialConnectionPoint;
  52483. autoConfigure(): void;
  52484. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52485. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52486. protected _buildBlock(state: NodeMaterialBuildState): this;
  52487. }
  52488. }
  52489. declare module BABYLON {
  52490. /**
  52491. * Block used to add light in the fragment shader
  52492. */
  52493. export class LightBlock extends NodeMaterialBlock {
  52494. private _lightId;
  52495. /**
  52496. * Gets or sets the light associated with this block
  52497. */
  52498. light: Nullable<Light>;
  52499. /**
  52500. * Create a new LightBlock
  52501. * @param name defines the block name
  52502. */
  52503. constructor(name: string);
  52504. /**
  52505. * Gets the current class name
  52506. * @returns the class name
  52507. */
  52508. getClassName(): string;
  52509. /**
  52510. * Gets the world position input component
  52511. */
  52512. readonly worldPosition: NodeMaterialConnectionPoint;
  52513. /**
  52514. * Gets the world normal input component
  52515. */
  52516. readonly worldNormal: NodeMaterialConnectionPoint;
  52517. /**
  52518. * Gets the camera (or eye) position component
  52519. */
  52520. readonly cameraPosition: NodeMaterialConnectionPoint;
  52521. /**
  52522. * Gets the diffuse output component
  52523. */
  52524. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52525. /**
  52526. * Gets the specular output component
  52527. */
  52528. readonly specularOutput: NodeMaterialConnectionPoint;
  52529. autoConfigure(): void;
  52530. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52531. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52532. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52533. private _injectVertexCode;
  52534. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52535. }
  52536. }
  52537. declare module BABYLON {
  52538. /**
  52539. * Block used to multiply 2 values
  52540. */
  52541. export class MultiplyBlock extends NodeMaterialBlock {
  52542. /**
  52543. * Creates a new MultiplyBlock
  52544. * @param name defines the block name
  52545. */
  52546. constructor(name: string);
  52547. /**
  52548. * Gets the current class name
  52549. * @returns the class name
  52550. */
  52551. getClassName(): string;
  52552. /**
  52553. * Gets the left operand input component
  52554. */
  52555. readonly left: NodeMaterialConnectionPoint;
  52556. /**
  52557. * Gets the right operand input component
  52558. */
  52559. readonly right: NodeMaterialConnectionPoint;
  52560. /**
  52561. * Gets the output component
  52562. */
  52563. readonly output: NodeMaterialConnectionPoint;
  52564. protected _buildBlock(state: NodeMaterialBuildState): this;
  52565. }
  52566. }
  52567. declare module BABYLON {
  52568. /**
  52569. * Block used to add 2 vector4
  52570. */
  52571. export class AddBlock extends NodeMaterialBlock {
  52572. /**
  52573. * Creates a new AddBlock
  52574. * @param name defines the block name
  52575. */
  52576. constructor(name: string);
  52577. /**
  52578. * Gets the current class name
  52579. * @returns the class name
  52580. */
  52581. getClassName(): string;
  52582. /**
  52583. * Gets the left operand input component
  52584. */
  52585. readonly left: NodeMaterialConnectionPoint;
  52586. /**
  52587. * Gets the right operand input component
  52588. */
  52589. readonly right: NodeMaterialConnectionPoint;
  52590. /**
  52591. * Gets the output component
  52592. */
  52593. readonly output: NodeMaterialConnectionPoint;
  52594. protected _buildBlock(state: NodeMaterialBuildState): this;
  52595. }
  52596. }
  52597. declare module BABYLON {
  52598. /**
  52599. * Block used to clamp a float
  52600. */
  52601. export class ClampBlock extends NodeMaterialBlock {
  52602. /** Gets or sets the minimum range */
  52603. minimum: number;
  52604. /** Gets or sets the maximum range */
  52605. maximum: number;
  52606. /**
  52607. * Creates a new ClampBlock
  52608. * @param name defines the block name
  52609. */
  52610. constructor(name: string);
  52611. /**
  52612. * Gets the current class name
  52613. * @returns the class name
  52614. */
  52615. getClassName(): string;
  52616. /**
  52617. * Gets the value input component
  52618. */
  52619. readonly value: NodeMaterialConnectionPoint;
  52620. /**
  52621. * Gets the output component
  52622. */
  52623. readonly output: NodeMaterialConnectionPoint;
  52624. protected _buildBlock(state: NodeMaterialBuildState): this;
  52625. }
  52626. }
  52627. declare module BABYLON {
  52628. /**
  52629. * Effect Render Options
  52630. */
  52631. export interface IEffectRendererOptions {
  52632. /**
  52633. * Defines the vertices positions.
  52634. */
  52635. positions?: number[];
  52636. /**
  52637. * Defines the indices.
  52638. */
  52639. indices?: number[];
  52640. }
  52641. /**
  52642. * Helper class to render one or more effects
  52643. */
  52644. export class EffectRenderer {
  52645. private engine;
  52646. private static _DefaultOptions;
  52647. private _vertexBuffers;
  52648. private _indexBuffer;
  52649. private _ringBufferIndex;
  52650. private _ringScreenBuffer;
  52651. private _fullscreenViewport;
  52652. private _getNextFrameBuffer;
  52653. /**
  52654. * Creates an effect renderer
  52655. * @param engine the engine to use for rendering
  52656. * @param options defines the options of the effect renderer
  52657. */
  52658. constructor(engine: Engine, options?: IEffectRendererOptions);
  52659. /**
  52660. * Sets the current viewport in normalized coordinates 0-1
  52661. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  52662. */
  52663. setViewport(viewport?: Viewport): void;
  52664. /**
  52665. * Sets the current effect wrapper to use during draw.
  52666. * The effect needs to be ready before calling this api.
  52667. * This also sets the default full screen position attribute.
  52668. * @param effectWrapper Defines the effect to draw with
  52669. */
  52670. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  52671. /**
  52672. * Draws a full screen quad.
  52673. */
  52674. draw(): void;
  52675. /**
  52676. * renders one or more effects to a specified texture
  52677. * @param effectWrappers list of effects to renderer
  52678. * @param outputTexture texture to draw to, if null it will render to the screen
  52679. */
  52680. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  52681. /**
  52682. * Disposes of the effect renderer
  52683. */
  52684. dispose(): void;
  52685. }
  52686. /**
  52687. * Options to create an EffectWrapper
  52688. */
  52689. interface EffectWrapperCreationOptions {
  52690. /**
  52691. * Engine to use to create the effect
  52692. */
  52693. engine: Engine;
  52694. /**
  52695. * Fragment shader for the effect
  52696. */
  52697. fragmentShader: string;
  52698. /**
  52699. * Vertex shader for the effect
  52700. */
  52701. vertexShader: string;
  52702. /**
  52703. * Attributes to use in the shader
  52704. */
  52705. attributeNames?: Array<string>;
  52706. /**
  52707. * Uniforms to use in the shader
  52708. */
  52709. uniformNames?: Array<string>;
  52710. /**
  52711. * Texture sampler names to use in the shader
  52712. */
  52713. samplerNames?: Array<string>;
  52714. /**
  52715. * The friendly name of the effect displayed in Spector.
  52716. */
  52717. name?: string;
  52718. }
  52719. /**
  52720. * Wraps an effect to be used for rendering
  52721. */
  52722. export class EffectWrapper {
  52723. /**
  52724. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  52725. */
  52726. onApplyObservable: Observable<{}>;
  52727. /**
  52728. * The underlying effect
  52729. */
  52730. effect: Effect;
  52731. /**
  52732. * Creates an effect to be renderer
  52733. * @param creationOptions options to create the effect
  52734. */
  52735. constructor(creationOptions: EffectWrapperCreationOptions);
  52736. /**
  52737. * Disposes of the effect wrapper
  52738. */
  52739. dispose(): void;
  52740. }
  52741. }
  52742. declare module BABYLON {
  52743. /**
  52744. * Contains position and normal vectors for a vertex
  52745. */
  52746. export class PositionNormalVertex {
  52747. /** the position of the vertex (defaut: 0,0,0) */
  52748. position: Vector3;
  52749. /** the normal of the vertex (defaut: 0,1,0) */
  52750. normal: Vector3;
  52751. /**
  52752. * Creates a PositionNormalVertex
  52753. * @param position the position of the vertex (defaut: 0,0,0)
  52754. * @param normal the normal of the vertex (defaut: 0,1,0)
  52755. */
  52756. constructor(
  52757. /** the position of the vertex (defaut: 0,0,0) */
  52758. position?: Vector3,
  52759. /** the normal of the vertex (defaut: 0,1,0) */
  52760. normal?: Vector3);
  52761. /**
  52762. * Clones the PositionNormalVertex
  52763. * @returns the cloned PositionNormalVertex
  52764. */
  52765. clone(): PositionNormalVertex;
  52766. }
  52767. /**
  52768. * Contains position, normal and uv vectors for a vertex
  52769. */
  52770. export class PositionNormalTextureVertex {
  52771. /** the position of the vertex (defaut: 0,0,0) */
  52772. position: Vector3;
  52773. /** the normal of the vertex (defaut: 0,1,0) */
  52774. normal: Vector3;
  52775. /** the uv of the vertex (default: 0,0) */
  52776. uv: Vector2;
  52777. /**
  52778. * Creates a PositionNormalTextureVertex
  52779. * @param position the position of the vertex (defaut: 0,0,0)
  52780. * @param normal the normal of the vertex (defaut: 0,1,0)
  52781. * @param uv the uv of the vertex (default: 0,0)
  52782. */
  52783. constructor(
  52784. /** the position of the vertex (defaut: 0,0,0) */
  52785. position?: Vector3,
  52786. /** the normal of the vertex (defaut: 0,1,0) */
  52787. normal?: Vector3,
  52788. /** the uv of the vertex (default: 0,0) */
  52789. uv?: Vector2);
  52790. /**
  52791. * Clones the PositionNormalTextureVertex
  52792. * @returns the cloned PositionNormalTextureVertex
  52793. */
  52794. clone(): PositionNormalTextureVertex;
  52795. }
  52796. }
  52797. declare module BABYLON {
  52798. /**
  52799. * Helper class to push actions to a pool of workers.
  52800. */
  52801. export class WorkerPool implements IDisposable {
  52802. private _workerInfos;
  52803. private _pendingActions;
  52804. /**
  52805. * Constructor
  52806. * @param workers Array of workers to use for actions
  52807. */
  52808. constructor(workers: Array<Worker>);
  52809. /**
  52810. * Terminates all workers and clears any pending actions.
  52811. */
  52812. dispose(): void;
  52813. /**
  52814. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52815. * pended until a worker has completed its action.
  52816. * @param action The action to perform. Call onComplete when the action is complete.
  52817. */
  52818. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52819. private _execute;
  52820. }
  52821. }
  52822. declare module BABYLON {
  52823. /**
  52824. * Configuration for Draco compression
  52825. */
  52826. export interface IDracoCompressionConfiguration {
  52827. /**
  52828. * Configuration for the decoder.
  52829. */
  52830. decoder: {
  52831. /**
  52832. * The url to the WebAssembly module.
  52833. */
  52834. wasmUrl?: string;
  52835. /**
  52836. * The url to the WebAssembly binary.
  52837. */
  52838. wasmBinaryUrl?: string;
  52839. /**
  52840. * The url to the fallback JavaScript module.
  52841. */
  52842. fallbackUrl?: string;
  52843. };
  52844. }
  52845. /**
  52846. * Draco compression (https://google.github.io/draco/)
  52847. *
  52848. * This class wraps the Draco module.
  52849. *
  52850. * **Encoder**
  52851. *
  52852. * The encoder is not currently implemented.
  52853. *
  52854. * **Decoder**
  52855. *
  52856. * 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.
  52857. *
  52858. * To update the configuration, use the following code:
  52859. * ```javascript
  52860. * DracoCompression.Configuration = {
  52861. * decoder: {
  52862. * wasmUrl: "<url to the WebAssembly library>",
  52863. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  52864. * fallbackUrl: "<url to the fallback JavaScript library>",
  52865. * }
  52866. * };
  52867. * ```
  52868. *
  52869. * 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.
  52870. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52871. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52872. *
  52873. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52874. * ```javascript
  52875. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52876. * ```
  52877. *
  52878. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52879. */
  52880. export class DracoCompression implements IDisposable {
  52881. private _workerPoolPromise?;
  52882. private _decoderModulePromise?;
  52883. /**
  52884. * The configuration. Defaults to the following urls:
  52885. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52886. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52887. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52888. */
  52889. static Configuration: IDracoCompressionConfiguration;
  52890. /**
  52891. * Returns true if the decoder configuration is available.
  52892. */
  52893. static readonly DecoderAvailable: boolean;
  52894. /**
  52895. * Default number of workers to create when creating the draco compression object.
  52896. */
  52897. static DefaultNumWorkers: number;
  52898. private static GetDefaultNumWorkers;
  52899. private static _Default;
  52900. /**
  52901. * Default instance for the draco compression object.
  52902. */
  52903. static readonly Default: DracoCompression;
  52904. /**
  52905. * Constructor
  52906. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52907. */
  52908. constructor(numWorkers?: number);
  52909. /**
  52910. * Stop all async operations and release resources.
  52911. */
  52912. dispose(): void;
  52913. /**
  52914. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52915. * @returns a promise that resolves when ready
  52916. */
  52917. whenReadyAsync(): Promise<void>;
  52918. /**
  52919. * Decode Draco compressed mesh data to vertex data.
  52920. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52921. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52922. * @returns A promise that resolves with the decoded vertex data
  52923. */
  52924. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52925. [kind: string]: number;
  52926. }): Promise<VertexData>;
  52927. }
  52928. }
  52929. declare module BABYLON {
  52930. /**
  52931. * Class for building Constructive Solid Geometry
  52932. */
  52933. export class CSG {
  52934. private polygons;
  52935. /**
  52936. * The world matrix
  52937. */
  52938. matrix: Matrix;
  52939. /**
  52940. * Stores the position
  52941. */
  52942. position: Vector3;
  52943. /**
  52944. * Stores the rotation
  52945. */
  52946. rotation: Vector3;
  52947. /**
  52948. * Stores the rotation quaternion
  52949. */
  52950. rotationQuaternion: Nullable<Quaternion>;
  52951. /**
  52952. * Stores the scaling vector
  52953. */
  52954. scaling: Vector3;
  52955. /**
  52956. * Convert the Mesh to CSG
  52957. * @param mesh The Mesh to convert to CSG
  52958. * @returns A new CSG from the Mesh
  52959. */
  52960. static FromMesh(mesh: Mesh): CSG;
  52961. /**
  52962. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52963. * @param polygons Polygons used to construct a CSG solid
  52964. */
  52965. private static FromPolygons;
  52966. /**
  52967. * Clones, or makes a deep copy, of the CSG
  52968. * @returns A new CSG
  52969. */
  52970. clone(): CSG;
  52971. /**
  52972. * Unions this CSG with another CSG
  52973. * @param csg The CSG to union against this CSG
  52974. * @returns The unioned CSG
  52975. */
  52976. union(csg: CSG): CSG;
  52977. /**
  52978. * Unions this CSG with another CSG in place
  52979. * @param csg The CSG to union against this CSG
  52980. */
  52981. unionInPlace(csg: CSG): void;
  52982. /**
  52983. * Subtracts this CSG with another CSG
  52984. * @param csg The CSG to subtract against this CSG
  52985. * @returns A new CSG
  52986. */
  52987. subtract(csg: CSG): CSG;
  52988. /**
  52989. * Subtracts this CSG with another CSG in place
  52990. * @param csg The CSG to subtact against this CSG
  52991. */
  52992. subtractInPlace(csg: CSG): void;
  52993. /**
  52994. * Intersect this CSG with another CSG
  52995. * @param csg The CSG to intersect against this CSG
  52996. * @returns A new CSG
  52997. */
  52998. intersect(csg: CSG): CSG;
  52999. /**
  53000. * Intersects this CSG with another CSG in place
  53001. * @param csg The CSG to intersect against this CSG
  53002. */
  53003. intersectInPlace(csg: CSG): void;
  53004. /**
  53005. * Return a new CSG solid with solid and empty space switched. This solid is
  53006. * not modified.
  53007. * @returns A new CSG solid with solid and empty space switched
  53008. */
  53009. inverse(): CSG;
  53010. /**
  53011. * Inverses the CSG in place
  53012. */
  53013. inverseInPlace(): void;
  53014. /**
  53015. * This is used to keep meshes transformations so they can be restored
  53016. * when we build back a Babylon Mesh
  53017. * NB : All CSG operations are performed in world coordinates
  53018. * @param csg The CSG to copy the transform attributes from
  53019. * @returns This CSG
  53020. */
  53021. copyTransformAttributes(csg: CSG): CSG;
  53022. /**
  53023. * Build Raw mesh from CSG
  53024. * Coordinates here are in world space
  53025. * @param name The name of the mesh geometry
  53026. * @param scene The Scene
  53027. * @param keepSubMeshes Specifies if the submeshes should be kept
  53028. * @returns A new Mesh
  53029. */
  53030. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  53031. /**
  53032. * Build Mesh from CSG taking material and transforms into account
  53033. * @param name The name of the Mesh
  53034. * @param material The material of the Mesh
  53035. * @param scene The Scene
  53036. * @param keepSubMeshes Specifies if submeshes should be kept
  53037. * @returns The new Mesh
  53038. */
  53039. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  53040. }
  53041. }
  53042. declare module BABYLON {
  53043. /**
  53044. * Class used to create a trail following a mesh
  53045. */
  53046. export class TrailMesh extends Mesh {
  53047. private _generator;
  53048. private _autoStart;
  53049. private _running;
  53050. private _diameter;
  53051. private _length;
  53052. private _sectionPolygonPointsCount;
  53053. private _sectionVectors;
  53054. private _sectionNormalVectors;
  53055. private _beforeRenderObserver;
  53056. /**
  53057. * @constructor
  53058. * @param name The value used by scene.getMeshByName() to do a lookup.
  53059. * @param generator The mesh to generate a trail.
  53060. * @param scene The scene to add this mesh to.
  53061. * @param diameter Diameter of trailing mesh. Default is 1.
  53062. * @param length Length of trailing mesh. Default is 60.
  53063. * @param autoStart Automatically start trailing mesh. Default true.
  53064. */
  53065. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  53066. /**
  53067. * "TrailMesh"
  53068. * @returns "TrailMesh"
  53069. */
  53070. getClassName(): string;
  53071. private _createMesh;
  53072. /**
  53073. * Start trailing mesh.
  53074. */
  53075. start(): void;
  53076. /**
  53077. * Stop trailing mesh.
  53078. */
  53079. stop(): void;
  53080. /**
  53081. * Update trailing mesh geometry.
  53082. */
  53083. update(): void;
  53084. /**
  53085. * Returns a new TrailMesh object.
  53086. * @param name is a string, the name given to the new mesh
  53087. * @param newGenerator use new generator object for cloned trail mesh
  53088. * @returns a new mesh
  53089. */
  53090. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  53091. /**
  53092. * Serializes this trail mesh
  53093. * @param serializationObject object to write serialization to
  53094. */
  53095. serialize(serializationObject: any): void;
  53096. /**
  53097. * Parses a serialized trail mesh
  53098. * @param parsedMesh the serialized mesh
  53099. * @param scene the scene to create the trail mesh in
  53100. * @returns the created trail mesh
  53101. */
  53102. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  53103. }
  53104. }
  53105. declare module BABYLON {
  53106. /**
  53107. * Class containing static functions to help procedurally build meshes
  53108. */
  53109. export class TiledBoxBuilder {
  53110. /**
  53111. * Creates a box mesh
  53112. * 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)
  53113. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53115. * * 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
  53116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53117. * @param name defines the name of the mesh
  53118. * @param options defines the options used to create the mesh
  53119. * @param scene defines the hosting scene
  53120. * @returns the box mesh
  53121. */
  53122. static CreateTiledBox(name: string, options: {
  53123. pattern?: number;
  53124. width?: number;
  53125. height?: number;
  53126. depth?: number;
  53127. tileSize?: number;
  53128. tileWidth?: number;
  53129. tileHeight?: number;
  53130. alignHorizontal?: number;
  53131. alignVertical?: number;
  53132. faceUV?: Vector4[];
  53133. faceColors?: Color4[];
  53134. sideOrientation?: number;
  53135. updatable?: boolean;
  53136. }, scene?: Nullable<Scene>): Mesh;
  53137. }
  53138. }
  53139. declare module BABYLON {
  53140. /**
  53141. * Class containing static functions to help procedurally build meshes
  53142. */
  53143. export class TorusKnotBuilder {
  53144. /**
  53145. * Creates a torus knot mesh
  53146. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53147. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53148. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53149. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53151. * * 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
  53152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53153. * @param name defines the name of the mesh
  53154. * @param options defines the options used to create the mesh
  53155. * @param scene defines the hosting scene
  53156. * @returns the torus knot mesh
  53157. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53158. */
  53159. static CreateTorusKnot(name: string, options: {
  53160. radius?: number;
  53161. tube?: number;
  53162. radialSegments?: number;
  53163. tubularSegments?: number;
  53164. p?: number;
  53165. q?: number;
  53166. updatable?: boolean;
  53167. sideOrientation?: number;
  53168. frontUVs?: Vector4;
  53169. backUVs?: Vector4;
  53170. }, scene: any): Mesh;
  53171. }
  53172. }
  53173. declare module BABYLON {
  53174. /**
  53175. * Polygon
  53176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  53177. */
  53178. export class Polygon {
  53179. /**
  53180. * Creates a rectangle
  53181. * @param xmin bottom X coord
  53182. * @param ymin bottom Y coord
  53183. * @param xmax top X coord
  53184. * @param ymax top Y coord
  53185. * @returns points that make the resulting rectation
  53186. */
  53187. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  53188. /**
  53189. * Creates a circle
  53190. * @param radius radius of circle
  53191. * @param cx scale in x
  53192. * @param cy scale in y
  53193. * @param numberOfSides number of sides that make up the circle
  53194. * @returns points that make the resulting circle
  53195. */
  53196. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  53197. /**
  53198. * Creates a polygon from input string
  53199. * @param input Input polygon data
  53200. * @returns the parsed points
  53201. */
  53202. static Parse(input: string): Vector2[];
  53203. /**
  53204. * Starts building a polygon from x and y coordinates
  53205. * @param x x coordinate
  53206. * @param y y coordinate
  53207. * @returns the started path2
  53208. */
  53209. static StartingAt(x: number, y: number): Path2;
  53210. }
  53211. /**
  53212. * Builds a polygon
  53213. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  53214. */
  53215. export class PolygonMeshBuilder {
  53216. private _points;
  53217. private _outlinepoints;
  53218. private _holes;
  53219. private _name;
  53220. private _scene;
  53221. private _epoints;
  53222. private _eholes;
  53223. private _addToepoint;
  53224. /**
  53225. * Babylon reference to the earcut plugin.
  53226. */
  53227. bjsEarcut: any;
  53228. /**
  53229. * Creates a PolygonMeshBuilder
  53230. * @param name name of the builder
  53231. * @param contours Path of the polygon
  53232. * @param scene scene to add to when creating the mesh
  53233. * @param earcutInjection can be used to inject your own earcut reference
  53234. */
  53235. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  53236. /**
  53237. * Adds a whole within the polygon
  53238. * @param hole Array of points defining the hole
  53239. * @returns this
  53240. */
  53241. addHole(hole: Vector2[]): PolygonMeshBuilder;
  53242. /**
  53243. * Creates the polygon
  53244. * @param updatable If the mesh should be updatable
  53245. * @param depth The depth of the mesh created
  53246. * @returns the created mesh
  53247. */
  53248. build(updatable?: boolean, depth?: number): Mesh;
  53249. /**
  53250. * Creates the polygon
  53251. * @param depth The depth of the mesh created
  53252. * @returns the created VertexData
  53253. */
  53254. buildVertexData(depth?: number): VertexData;
  53255. /**
  53256. * Adds a side to the polygon
  53257. * @param positions points that make the polygon
  53258. * @param normals normals of the polygon
  53259. * @param uvs uvs of the polygon
  53260. * @param indices indices of the polygon
  53261. * @param bounds bounds of the polygon
  53262. * @param points points of the polygon
  53263. * @param depth depth of the polygon
  53264. * @param flip flip of the polygon
  53265. */
  53266. private addSide;
  53267. }
  53268. }
  53269. declare module BABYLON {
  53270. /**
  53271. * Class containing static functions to help procedurally build meshes
  53272. */
  53273. export class PolygonBuilder {
  53274. /**
  53275. * Creates a polygon mesh
  53276. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53277. * * 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
  53278. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53280. * * 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)
  53281. * * Remember you can only change the shape positions, not their number when updating a polygon
  53282. * @param name defines the name of the mesh
  53283. * @param options defines the options used to create the mesh
  53284. * @param scene defines the hosting scene
  53285. * @param earcutInjection can be used to inject your own earcut reference
  53286. * @returns the polygon mesh
  53287. */
  53288. static CreatePolygon(name: string, options: {
  53289. shape: Vector3[];
  53290. holes?: Vector3[][];
  53291. depth?: number;
  53292. faceUV?: Vector4[];
  53293. faceColors?: Color4[];
  53294. updatable?: boolean;
  53295. sideOrientation?: number;
  53296. frontUVs?: Vector4;
  53297. backUVs?: Vector4;
  53298. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53299. /**
  53300. * Creates an extruded polygon mesh, with depth in the Y direction.
  53301. * * 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)
  53302. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53303. * @param name defines the name of the mesh
  53304. * @param options defines the options used to create the mesh
  53305. * @param scene defines the hosting scene
  53306. * @param earcutInjection can be used to inject your own earcut reference
  53307. * @returns the polygon mesh
  53308. */
  53309. static ExtrudePolygon(name: string, options: {
  53310. shape: Vector3[];
  53311. holes?: Vector3[][];
  53312. depth?: number;
  53313. faceUV?: Vector4[];
  53314. faceColors?: Color4[];
  53315. updatable?: boolean;
  53316. sideOrientation?: number;
  53317. frontUVs?: Vector4;
  53318. backUVs?: Vector4;
  53319. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53320. }
  53321. }
  53322. declare module BABYLON {
  53323. /**
  53324. * Class containing static functions to help procedurally build meshes
  53325. */
  53326. export class LatheBuilder {
  53327. /**
  53328. * Creates lathe mesh.
  53329. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53330. * * 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
  53331. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53332. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53333. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53334. * * 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
  53335. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53336. * * 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
  53337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53338. * * 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
  53339. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53341. * @param name defines the name of the mesh
  53342. * @param options defines the options used to create the mesh
  53343. * @param scene defines the hosting scene
  53344. * @returns the lathe mesh
  53345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53346. */
  53347. static CreateLathe(name: string, options: {
  53348. shape: Vector3[];
  53349. radius?: number;
  53350. tessellation?: number;
  53351. clip?: number;
  53352. arc?: number;
  53353. closed?: boolean;
  53354. updatable?: boolean;
  53355. sideOrientation?: number;
  53356. frontUVs?: Vector4;
  53357. backUVs?: Vector4;
  53358. cap?: number;
  53359. invertUV?: boolean;
  53360. }, scene?: Nullable<Scene>): Mesh;
  53361. }
  53362. }
  53363. declare module BABYLON {
  53364. /**
  53365. * Class containing static functions to help procedurally build meshes
  53366. */
  53367. export class TiledPlaneBuilder {
  53368. /**
  53369. * Creates a tiled plane mesh
  53370. * * The parameter `pattern` will, depending on value, do nothing or
  53371. * * * flip (reflect about central vertical) alternate tiles across and up
  53372. * * * flip every tile on alternate rows
  53373. * * * rotate (180 degs) alternate tiles across and up
  53374. * * * rotate every tile on alternate rows
  53375. * * * flip and rotate alternate tiles across and up
  53376. * * * flip and rotate every tile on alternate rows
  53377. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  53378. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  53379. * * 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
  53380. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53381. * * 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)
  53382. * * 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)
  53383. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53384. * @param name defines the name of the mesh
  53385. * @param options defines the options used to create the mesh
  53386. * @param scene defines the hosting scene
  53387. * @returns the box mesh
  53388. */
  53389. static CreateTiledPlane(name: string, options: {
  53390. pattern?: number;
  53391. tileSize?: number;
  53392. tileWidth?: number;
  53393. tileHeight?: number;
  53394. size?: number;
  53395. width?: number;
  53396. height?: number;
  53397. alignHorizontal?: number;
  53398. alignVertical?: number;
  53399. sideOrientation?: number;
  53400. frontUVs?: Vector4;
  53401. backUVs?: Vector4;
  53402. updatable?: boolean;
  53403. }, scene?: Nullable<Scene>): Mesh;
  53404. }
  53405. }
  53406. declare module BABYLON {
  53407. /**
  53408. * Class containing static functions to help procedurally build meshes
  53409. */
  53410. export class TubeBuilder {
  53411. /**
  53412. * Creates a tube mesh.
  53413. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53414. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53415. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53416. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53417. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53418. * * 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)
  53419. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53420. * * 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
  53421. * * 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
  53422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53423. * * 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
  53424. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53426. * @param name defines the name of the mesh
  53427. * @param options defines the options used to create the mesh
  53428. * @param scene defines the hosting scene
  53429. * @returns the tube mesh
  53430. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53431. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53432. */
  53433. static CreateTube(name: string, options: {
  53434. path: Vector3[];
  53435. radius?: number;
  53436. tessellation?: number;
  53437. radiusFunction?: {
  53438. (i: number, distance: number): number;
  53439. };
  53440. cap?: number;
  53441. arc?: number;
  53442. updatable?: boolean;
  53443. sideOrientation?: number;
  53444. frontUVs?: Vector4;
  53445. backUVs?: Vector4;
  53446. instance?: Mesh;
  53447. invertUV?: boolean;
  53448. }, scene?: Nullable<Scene>): Mesh;
  53449. }
  53450. }
  53451. declare module BABYLON {
  53452. /**
  53453. * Class containing static functions to help procedurally build meshes
  53454. */
  53455. export class IcoSphereBuilder {
  53456. /**
  53457. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53458. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53459. * * 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`)
  53460. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53461. * * 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
  53462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53463. * * 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
  53464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53465. * @param name defines the name of the mesh
  53466. * @param options defines the options used to create the mesh
  53467. * @param scene defines the hosting scene
  53468. * @returns the icosahedron mesh
  53469. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53470. */
  53471. static CreateIcoSphere(name: string, options: {
  53472. radius?: number;
  53473. radiusX?: number;
  53474. radiusY?: number;
  53475. radiusZ?: number;
  53476. flat?: boolean;
  53477. subdivisions?: number;
  53478. sideOrientation?: number;
  53479. frontUVs?: Vector4;
  53480. backUVs?: Vector4;
  53481. updatable?: boolean;
  53482. }, scene?: Nullable<Scene>): Mesh;
  53483. }
  53484. }
  53485. declare module BABYLON {
  53486. /**
  53487. * Class containing static functions to help procedurally build meshes
  53488. */
  53489. export class DecalBuilder {
  53490. /**
  53491. * Creates a decal mesh.
  53492. * 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
  53493. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53494. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53495. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53496. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53497. * @param name defines the name of the mesh
  53498. * @param sourceMesh defines the mesh where the decal must be applied
  53499. * @param options defines the options used to create the mesh
  53500. * @param scene defines the hosting scene
  53501. * @returns the decal mesh
  53502. * @see https://doc.babylonjs.com/how_to/decals
  53503. */
  53504. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53505. position?: Vector3;
  53506. normal?: Vector3;
  53507. size?: Vector3;
  53508. angle?: number;
  53509. }): Mesh;
  53510. }
  53511. }
  53512. declare module BABYLON {
  53513. /**
  53514. * Class containing static functions to help procedurally build meshes
  53515. */
  53516. export class MeshBuilder {
  53517. /**
  53518. * Creates a box mesh
  53519. * * The parameter `size` sets the size (float) of each box side (default 1)
  53520. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53521. * * 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)
  53522. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53524. * * 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
  53525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53526. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53527. * @param name defines the name of the mesh
  53528. * @param options defines the options used to create the mesh
  53529. * @param scene defines the hosting scene
  53530. * @returns the box mesh
  53531. */
  53532. static CreateBox(name: string, options: {
  53533. size?: number;
  53534. width?: number;
  53535. height?: number;
  53536. depth?: number;
  53537. faceUV?: Vector4[];
  53538. faceColors?: Color4[];
  53539. sideOrientation?: number;
  53540. frontUVs?: Vector4;
  53541. backUVs?: Vector4;
  53542. updatable?: boolean;
  53543. }, scene?: Nullable<Scene>): Mesh;
  53544. /**
  53545. * Creates a tiled box mesh
  53546. * * faceTiles sets the pattern, tile size and number of tiles for a face
  53547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53548. * @param name defines the name of the mesh
  53549. * @param options defines the options used to create the mesh
  53550. * @param scene defines the hosting scene
  53551. * @returns the tiled box mesh
  53552. */
  53553. static CreateTiledBox(name: string, options: {
  53554. pattern?: number;
  53555. size?: number;
  53556. width?: number;
  53557. height?: number;
  53558. depth: number;
  53559. tileSize?: number;
  53560. tileWidth?: number;
  53561. tileHeight?: number;
  53562. faceUV?: Vector4[];
  53563. faceColors?: Color4[];
  53564. alignHorizontal?: number;
  53565. alignVertical?: number;
  53566. sideOrientation?: number;
  53567. updatable?: boolean;
  53568. }, scene?: Nullable<Scene>): Mesh;
  53569. /**
  53570. * Creates a sphere mesh
  53571. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53572. * * 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`)
  53573. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53574. * * 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
  53575. * * 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)
  53576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53577. * * 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
  53578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53579. * @param name defines the name of the mesh
  53580. * @param options defines the options used to create the mesh
  53581. * @param scene defines the hosting scene
  53582. * @returns the sphere mesh
  53583. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53584. */
  53585. static CreateSphere(name: string, options: {
  53586. segments?: number;
  53587. diameter?: number;
  53588. diameterX?: number;
  53589. diameterY?: number;
  53590. diameterZ?: number;
  53591. arc?: number;
  53592. slice?: number;
  53593. sideOrientation?: number;
  53594. frontUVs?: Vector4;
  53595. backUVs?: Vector4;
  53596. updatable?: boolean;
  53597. }, scene?: Nullable<Scene>): Mesh;
  53598. /**
  53599. * Creates a plane polygonal mesh. By default, this is a disc
  53600. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  53601. * * 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
  53602. * * 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
  53603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53604. * * 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
  53605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53606. * @param name defines the name of the mesh
  53607. * @param options defines the options used to create the mesh
  53608. * @param scene defines the hosting scene
  53609. * @returns the plane polygonal mesh
  53610. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  53611. */
  53612. static CreateDisc(name: string, options: {
  53613. radius?: number;
  53614. tessellation?: number;
  53615. arc?: number;
  53616. updatable?: boolean;
  53617. sideOrientation?: number;
  53618. frontUVs?: Vector4;
  53619. backUVs?: Vector4;
  53620. }, scene?: Nullable<Scene>): Mesh;
  53621. /**
  53622. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53623. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53624. * * 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`)
  53625. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53626. * * 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
  53627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53628. * * 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
  53629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53630. * @param name defines the name of the mesh
  53631. * @param options defines the options used to create the mesh
  53632. * @param scene defines the hosting scene
  53633. * @returns the icosahedron mesh
  53634. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53635. */
  53636. static CreateIcoSphere(name: string, options: {
  53637. radius?: number;
  53638. radiusX?: number;
  53639. radiusY?: number;
  53640. radiusZ?: number;
  53641. flat?: boolean;
  53642. subdivisions?: number;
  53643. sideOrientation?: number;
  53644. frontUVs?: Vector4;
  53645. backUVs?: Vector4;
  53646. updatable?: boolean;
  53647. }, scene?: Nullable<Scene>): Mesh;
  53648. /**
  53649. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53650. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53651. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53652. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53653. * * 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
  53654. * * 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
  53655. * * 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
  53656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53657. * * 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
  53658. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53659. * * 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
  53660. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53661. * * 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
  53662. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53664. * @param name defines the name of the mesh
  53665. * @param options defines the options used to create the mesh
  53666. * @param scene defines the hosting scene
  53667. * @returns the ribbon mesh
  53668. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53669. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53670. */
  53671. static CreateRibbon(name: string, options: {
  53672. pathArray: Vector3[][];
  53673. closeArray?: boolean;
  53674. closePath?: boolean;
  53675. offset?: number;
  53676. updatable?: boolean;
  53677. sideOrientation?: number;
  53678. frontUVs?: Vector4;
  53679. backUVs?: Vector4;
  53680. instance?: Mesh;
  53681. invertUV?: boolean;
  53682. uvs?: Vector2[];
  53683. colors?: Color4[];
  53684. }, scene?: Nullable<Scene>): Mesh;
  53685. /**
  53686. * Creates a cylinder or a cone mesh
  53687. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53688. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53689. * * 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.
  53690. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53691. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53692. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53693. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53694. * * 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).
  53695. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53696. * * 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).
  53697. * * 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
  53698. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53699. * * 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
  53700. * * 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.
  53701. * * If `enclose` is false, a ring surface is one element.
  53702. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53703. * * 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
  53704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53705. * * 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
  53706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53707. * @param name defines the name of the mesh
  53708. * @param options defines the options used to create the mesh
  53709. * @param scene defines the hosting scene
  53710. * @returns the cylinder mesh
  53711. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53712. */
  53713. static CreateCylinder(name: string, options: {
  53714. height?: number;
  53715. diameterTop?: number;
  53716. diameterBottom?: number;
  53717. diameter?: number;
  53718. tessellation?: number;
  53719. subdivisions?: number;
  53720. arc?: number;
  53721. faceColors?: Color4[];
  53722. faceUV?: Vector4[];
  53723. updatable?: boolean;
  53724. hasRings?: boolean;
  53725. enclose?: boolean;
  53726. cap?: number;
  53727. sideOrientation?: number;
  53728. frontUVs?: Vector4;
  53729. backUVs?: Vector4;
  53730. }, scene?: Nullable<Scene>): Mesh;
  53731. /**
  53732. * Creates a torus mesh
  53733. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53734. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53735. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53737. * * 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
  53738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53739. * @param name defines the name of the mesh
  53740. * @param options defines the options used to create the mesh
  53741. * @param scene defines the hosting scene
  53742. * @returns the torus mesh
  53743. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53744. */
  53745. static CreateTorus(name: string, options: {
  53746. diameter?: number;
  53747. thickness?: number;
  53748. tessellation?: number;
  53749. updatable?: boolean;
  53750. sideOrientation?: number;
  53751. frontUVs?: Vector4;
  53752. backUVs?: Vector4;
  53753. }, scene?: Nullable<Scene>): Mesh;
  53754. /**
  53755. * Creates a torus knot mesh
  53756. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53757. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53758. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53759. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53761. * * 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
  53762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53763. * @param name defines the name of the mesh
  53764. * @param options defines the options used to create the mesh
  53765. * @param scene defines the hosting scene
  53766. * @returns the torus knot mesh
  53767. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53768. */
  53769. static CreateTorusKnot(name: string, options: {
  53770. radius?: number;
  53771. tube?: number;
  53772. radialSegments?: number;
  53773. tubularSegments?: number;
  53774. p?: number;
  53775. q?: number;
  53776. updatable?: boolean;
  53777. sideOrientation?: number;
  53778. frontUVs?: Vector4;
  53779. backUVs?: Vector4;
  53780. }, scene?: Nullable<Scene>): Mesh;
  53781. /**
  53782. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  53783. * * 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
  53784. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  53785. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  53786. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  53787. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  53788. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  53789. * * 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
  53790. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  53791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53792. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  53793. * @param name defines the name of the new line system
  53794. * @param options defines the options used to create the line system
  53795. * @param scene defines the hosting scene
  53796. * @returns a new line system mesh
  53797. */
  53798. static CreateLineSystem(name: string, options: {
  53799. lines: Vector3[][];
  53800. updatable?: boolean;
  53801. instance?: Nullable<LinesMesh>;
  53802. colors?: Nullable<Color4[][]>;
  53803. useVertexAlpha?: boolean;
  53804. }, scene: Nullable<Scene>): LinesMesh;
  53805. /**
  53806. * Creates a line mesh
  53807. * 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
  53808. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53809. * * The parameter `points` is an array successive Vector3
  53810. * * 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
  53811. * * The optional parameter `colors` is an array of successive Color4, one per line point
  53812. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  53813. * * When updating an instance, remember that only point positions can change, not the number of points
  53814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53815. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  53816. * @param name defines the name of the new line system
  53817. * @param options defines the options used to create the line system
  53818. * @param scene defines the hosting scene
  53819. * @returns a new line mesh
  53820. */
  53821. static CreateLines(name: string, options: {
  53822. points: Vector3[];
  53823. updatable?: boolean;
  53824. instance?: Nullable<LinesMesh>;
  53825. colors?: Color4[];
  53826. useVertexAlpha?: boolean;
  53827. }, scene?: Nullable<Scene>): LinesMesh;
  53828. /**
  53829. * Creates a dashed line mesh
  53830. * * 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
  53831. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53832. * * The parameter `points` is an array successive Vector3
  53833. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  53834. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  53835. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  53836. * * 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
  53837. * * When updating an instance, remember that only point positions can change, not the number of points
  53838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53839. * @param name defines the name of the mesh
  53840. * @param options defines the options used to create the mesh
  53841. * @param scene defines the hosting scene
  53842. * @returns the dashed line mesh
  53843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  53844. */
  53845. static CreateDashedLines(name: string, options: {
  53846. points: Vector3[];
  53847. dashSize?: number;
  53848. gapSize?: number;
  53849. dashNb?: number;
  53850. updatable?: boolean;
  53851. instance?: LinesMesh;
  53852. }, scene?: Nullable<Scene>): LinesMesh;
  53853. /**
  53854. * 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.
  53855. * * 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.
  53856. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53857. * * 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.
  53858. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53859. * * 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
  53860. * * 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
  53861. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53863. * * 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
  53864. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53866. * @param name defines the name of the mesh
  53867. * @param options defines the options used to create the mesh
  53868. * @param scene defines the hosting scene
  53869. * @returns the extruded shape mesh
  53870. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53872. */
  53873. static ExtrudeShape(name: string, options: {
  53874. shape: Vector3[];
  53875. path: Vector3[];
  53876. scale?: number;
  53877. rotation?: number;
  53878. cap?: number;
  53879. updatable?: boolean;
  53880. sideOrientation?: number;
  53881. frontUVs?: Vector4;
  53882. backUVs?: Vector4;
  53883. instance?: Mesh;
  53884. invertUV?: boolean;
  53885. }, scene?: Nullable<Scene>): Mesh;
  53886. /**
  53887. * Creates an custom extruded shape mesh.
  53888. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53889. * * 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.
  53890. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53891. * * 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
  53892. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53893. * * 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
  53894. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53895. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53896. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53897. * * 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
  53898. * * 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
  53899. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53901. * * 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
  53902. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53904. * @param name defines the name of the mesh
  53905. * @param options defines the options used to create the mesh
  53906. * @param scene defines the hosting scene
  53907. * @returns the custom extruded shape mesh
  53908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53909. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53911. */
  53912. static ExtrudeShapeCustom(name: string, options: {
  53913. shape: Vector3[];
  53914. path: Vector3[];
  53915. scaleFunction?: any;
  53916. rotationFunction?: any;
  53917. ribbonCloseArray?: boolean;
  53918. ribbonClosePath?: boolean;
  53919. cap?: number;
  53920. updatable?: boolean;
  53921. sideOrientation?: number;
  53922. frontUVs?: Vector4;
  53923. backUVs?: Vector4;
  53924. instance?: Mesh;
  53925. invertUV?: boolean;
  53926. }, scene?: Nullable<Scene>): Mesh;
  53927. /**
  53928. * Creates lathe mesh.
  53929. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53930. * * 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
  53931. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53932. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53933. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53934. * * 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
  53935. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53936. * * 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
  53937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53938. * * 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
  53939. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53941. * @param name defines the name of the mesh
  53942. * @param options defines the options used to create the mesh
  53943. * @param scene defines the hosting scene
  53944. * @returns the lathe mesh
  53945. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53946. */
  53947. static CreateLathe(name: string, options: {
  53948. shape: Vector3[];
  53949. radius?: number;
  53950. tessellation?: number;
  53951. clip?: number;
  53952. arc?: number;
  53953. closed?: boolean;
  53954. updatable?: boolean;
  53955. sideOrientation?: number;
  53956. frontUVs?: Vector4;
  53957. backUVs?: Vector4;
  53958. cap?: number;
  53959. invertUV?: boolean;
  53960. }, scene?: Nullable<Scene>): Mesh;
  53961. /**
  53962. * Creates a tiled plane mesh
  53963. * * You can set a limited pattern arrangement with the tiles
  53964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53965. * * 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
  53966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53967. * @param name defines the name of the mesh
  53968. * @param options defines the options used to create the mesh
  53969. * @param scene defines the hosting scene
  53970. * @returns the plane mesh
  53971. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53972. */
  53973. static CreateTiledPlane(name: string, options: {
  53974. pattern?: number;
  53975. tileSize?: number;
  53976. tileWidth?: number;
  53977. tileHeight?: number;
  53978. size?: number;
  53979. width?: number;
  53980. height?: number;
  53981. alignHorizontal?: number;
  53982. alignVertical?: number;
  53983. sideOrientation?: number;
  53984. frontUVs?: Vector4;
  53985. backUVs?: Vector4;
  53986. updatable?: boolean;
  53987. }, scene?: Nullable<Scene>): Mesh;
  53988. /**
  53989. * Creates a plane mesh
  53990. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53991. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53992. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53994. * * 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
  53995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53996. * @param name defines the name of the mesh
  53997. * @param options defines the options used to create the mesh
  53998. * @param scene defines the hosting scene
  53999. * @returns the plane mesh
  54000. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54001. */
  54002. static CreatePlane(name: string, options: {
  54003. size?: number;
  54004. width?: number;
  54005. height?: number;
  54006. sideOrientation?: number;
  54007. frontUVs?: Vector4;
  54008. backUVs?: Vector4;
  54009. updatable?: boolean;
  54010. sourcePlane?: Plane;
  54011. }, scene?: Nullable<Scene>): Mesh;
  54012. /**
  54013. * Creates a ground mesh
  54014. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  54015. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  54016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54017. * @param name defines the name of the mesh
  54018. * @param options defines the options used to create the mesh
  54019. * @param scene defines the hosting scene
  54020. * @returns the ground mesh
  54021. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  54022. */
  54023. static CreateGround(name: string, options: {
  54024. width?: number;
  54025. height?: number;
  54026. subdivisions?: number;
  54027. subdivisionsX?: number;
  54028. subdivisionsY?: number;
  54029. updatable?: boolean;
  54030. }, scene?: Nullable<Scene>): Mesh;
  54031. /**
  54032. * Creates a tiled ground mesh
  54033. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  54034. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  54035. * * 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
  54036. * * 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
  54037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54038. * @param name defines the name of the mesh
  54039. * @param options defines the options used to create the mesh
  54040. * @param scene defines the hosting scene
  54041. * @returns the tiled ground mesh
  54042. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  54043. */
  54044. static CreateTiledGround(name: string, options: {
  54045. xmin: number;
  54046. zmin: number;
  54047. xmax: number;
  54048. zmax: number;
  54049. subdivisions?: {
  54050. w: number;
  54051. h: number;
  54052. };
  54053. precision?: {
  54054. w: number;
  54055. h: number;
  54056. };
  54057. updatable?: boolean;
  54058. }, scene?: Nullable<Scene>): Mesh;
  54059. /**
  54060. * Creates a ground mesh from a height map
  54061. * * The parameter `url` sets the URL of the height map image resource.
  54062. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  54063. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  54064. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  54065. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  54066. * * 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.
  54067. * * 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).
  54068. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  54069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54070. * @param name defines the name of the mesh
  54071. * @param url defines the url to the height map
  54072. * @param options defines the options used to create the mesh
  54073. * @param scene defines the hosting scene
  54074. * @returns the ground mesh
  54075. * @see https://doc.babylonjs.com/babylon101/height_map
  54076. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  54077. */
  54078. static CreateGroundFromHeightMap(name: string, url: string, options: {
  54079. width?: number;
  54080. height?: number;
  54081. subdivisions?: number;
  54082. minHeight?: number;
  54083. maxHeight?: number;
  54084. colorFilter?: Color3;
  54085. alphaFilter?: number;
  54086. updatable?: boolean;
  54087. onReady?: (mesh: GroundMesh) => void;
  54088. }, scene?: Nullable<Scene>): GroundMesh;
  54089. /**
  54090. * Creates a polygon mesh
  54091. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54092. * * 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
  54093. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54095. * * 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)
  54096. * * Remember you can only change the shape positions, not their number when updating a polygon
  54097. * @param name defines the name of the mesh
  54098. * @param options defines the options used to create the mesh
  54099. * @param scene defines the hosting scene
  54100. * @param earcutInjection can be used to inject your own earcut reference
  54101. * @returns the polygon mesh
  54102. */
  54103. static CreatePolygon(name: string, options: {
  54104. shape: Vector3[];
  54105. holes?: Vector3[][];
  54106. depth?: number;
  54107. faceUV?: Vector4[];
  54108. faceColors?: Color4[];
  54109. updatable?: boolean;
  54110. sideOrientation?: number;
  54111. frontUVs?: Vector4;
  54112. backUVs?: Vector4;
  54113. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54114. /**
  54115. * Creates an extruded polygon mesh, with depth in the Y direction.
  54116. * * 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)
  54117. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54118. * @param name defines the name of the mesh
  54119. * @param options defines the options used to create the mesh
  54120. * @param scene defines the hosting scene
  54121. * @param earcutInjection can be used to inject your own earcut reference
  54122. * @returns the polygon mesh
  54123. */
  54124. static ExtrudePolygon(name: string, options: {
  54125. shape: Vector3[];
  54126. holes?: Vector3[][];
  54127. depth?: number;
  54128. faceUV?: Vector4[];
  54129. faceColors?: Color4[];
  54130. updatable?: boolean;
  54131. sideOrientation?: number;
  54132. frontUVs?: Vector4;
  54133. backUVs?: Vector4;
  54134. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54135. /**
  54136. * Creates a tube mesh.
  54137. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54138. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54139. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54140. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54141. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54142. * * 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)
  54143. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54144. * * 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
  54145. * * 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
  54146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54147. * * 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
  54148. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54150. * @param name defines the name of the mesh
  54151. * @param options defines the options used to create the mesh
  54152. * @param scene defines the hosting scene
  54153. * @returns the tube mesh
  54154. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54155. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54156. */
  54157. static CreateTube(name: string, options: {
  54158. path: Vector3[];
  54159. radius?: number;
  54160. tessellation?: number;
  54161. radiusFunction?: {
  54162. (i: number, distance: number): number;
  54163. };
  54164. cap?: number;
  54165. arc?: number;
  54166. updatable?: boolean;
  54167. sideOrientation?: number;
  54168. frontUVs?: Vector4;
  54169. backUVs?: Vector4;
  54170. instance?: Mesh;
  54171. invertUV?: boolean;
  54172. }, scene?: Nullable<Scene>): Mesh;
  54173. /**
  54174. * Creates a polyhedron mesh
  54175. * * 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
  54176. * * The parameter `size` (positive float, default 1) sets the polygon size
  54177. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54178. * * 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`
  54179. * * 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
  54180. * * 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)`)
  54181. * * 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
  54182. * * 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
  54183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54184. * * 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
  54185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54186. * @param name defines the name of the mesh
  54187. * @param options defines the options used to create the mesh
  54188. * @param scene defines the hosting scene
  54189. * @returns the polyhedron mesh
  54190. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54191. */
  54192. static CreatePolyhedron(name: string, options: {
  54193. type?: number;
  54194. size?: number;
  54195. sizeX?: number;
  54196. sizeY?: number;
  54197. sizeZ?: number;
  54198. custom?: any;
  54199. faceUV?: Vector4[];
  54200. faceColors?: Color4[];
  54201. flat?: boolean;
  54202. updatable?: boolean;
  54203. sideOrientation?: number;
  54204. frontUVs?: Vector4;
  54205. backUVs?: Vector4;
  54206. }, scene?: Nullable<Scene>): Mesh;
  54207. /**
  54208. * Creates a decal mesh.
  54209. * 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
  54210. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54211. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54212. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54213. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54214. * @param name defines the name of the mesh
  54215. * @param sourceMesh defines the mesh where the decal must be applied
  54216. * @param options defines the options used to create the mesh
  54217. * @param scene defines the hosting scene
  54218. * @returns the decal mesh
  54219. * @see https://doc.babylonjs.com/how_to/decals
  54220. */
  54221. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54222. position?: Vector3;
  54223. normal?: Vector3;
  54224. size?: Vector3;
  54225. angle?: number;
  54226. }): Mesh;
  54227. }
  54228. }
  54229. declare module BABYLON {
  54230. /**
  54231. * A simplifier interface for future simplification implementations
  54232. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54233. */
  54234. export interface ISimplifier {
  54235. /**
  54236. * Simplification of a given mesh according to the given settings.
  54237. * Since this requires computation, it is assumed that the function runs async.
  54238. * @param settings The settings of the simplification, including quality and distance
  54239. * @param successCallback A callback that will be called after the mesh was simplified.
  54240. * @param errorCallback in case of an error, this callback will be called. optional.
  54241. */
  54242. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  54243. }
  54244. /**
  54245. * Expected simplification settings.
  54246. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  54247. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54248. */
  54249. export interface ISimplificationSettings {
  54250. /**
  54251. * Gets or sets the expected quality
  54252. */
  54253. quality: number;
  54254. /**
  54255. * Gets or sets the distance when this optimized version should be used
  54256. */
  54257. distance: number;
  54258. /**
  54259. * Gets an already optimized mesh
  54260. */
  54261. optimizeMesh?: boolean;
  54262. }
  54263. /**
  54264. * Class used to specify simplification options
  54265. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54266. */
  54267. export class SimplificationSettings implements ISimplificationSettings {
  54268. /** expected quality */
  54269. quality: number;
  54270. /** distance when this optimized version should be used */
  54271. distance: number;
  54272. /** already optimized mesh */
  54273. optimizeMesh?: boolean | undefined;
  54274. /**
  54275. * Creates a SimplificationSettings
  54276. * @param quality expected quality
  54277. * @param distance distance when this optimized version should be used
  54278. * @param optimizeMesh already optimized mesh
  54279. */
  54280. constructor(
  54281. /** expected quality */
  54282. quality: number,
  54283. /** distance when this optimized version should be used */
  54284. distance: number,
  54285. /** already optimized mesh */
  54286. optimizeMesh?: boolean | undefined);
  54287. }
  54288. /**
  54289. * Interface used to define a simplification task
  54290. */
  54291. export interface ISimplificationTask {
  54292. /**
  54293. * Array of settings
  54294. */
  54295. settings: Array<ISimplificationSettings>;
  54296. /**
  54297. * Simplification type
  54298. */
  54299. simplificationType: SimplificationType;
  54300. /**
  54301. * Mesh to simplify
  54302. */
  54303. mesh: Mesh;
  54304. /**
  54305. * Callback called on success
  54306. */
  54307. successCallback?: () => void;
  54308. /**
  54309. * Defines if parallel processing can be used
  54310. */
  54311. parallelProcessing: boolean;
  54312. }
  54313. /**
  54314. * Queue used to order the simplification tasks
  54315. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54316. */
  54317. export class SimplificationQueue {
  54318. private _simplificationArray;
  54319. /**
  54320. * Gets a boolean indicating that the process is still running
  54321. */
  54322. running: boolean;
  54323. /**
  54324. * Creates a new queue
  54325. */
  54326. constructor();
  54327. /**
  54328. * Adds a new simplification task
  54329. * @param task defines a task to add
  54330. */
  54331. addTask(task: ISimplificationTask): void;
  54332. /**
  54333. * Execute next task
  54334. */
  54335. executeNext(): void;
  54336. /**
  54337. * Execute a simplification task
  54338. * @param task defines the task to run
  54339. */
  54340. runSimplification(task: ISimplificationTask): void;
  54341. private getSimplifier;
  54342. }
  54343. /**
  54344. * The implemented types of simplification
  54345. * At the moment only Quadratic Error Decimation is implemented
  54346. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54347. */
  54348. export enum SimplificationType {
  54349. /** Quadratic error decimation */
  54350. QUADRATIC = 0
  54351. }
  54352. }
  54353. declare module BABYLON {
  54354. interface Scene {
  54355. /** @hidden (Backing field) */
  54356. _simplificationQueue: SimplificationQueue;
  54357. /**
  54358. * Gets or sets the simplification queue attached to the scene
  54359. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54360. */
  54361. simplificationQueue: SimplificationQueue;
  54362. }
  54363. interface Mesh {
  54364. /**
  54365. * Simplify the mesh according to the given array of settings.
  54366. * Function will return immediately and will simplify async
  54367. * @param settings a collection of simplification settings
  54368. * @param parallelProcessing should all levels calculate parallel or one after the other
  54369. * @param simplificationType the type of simplification to run
  54370. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  54371. * @returns the current mesh
  54372. */
  54373. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  54374. }
  54375. /**
  54376. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  54377. * created in a scene
  54378. */
  54379. export class SimplicationQueueSceneComponent implements ISceneComponent {
  54380. /**
  54381. * The component name helpfull to identify the component in the list of scene components.
  54382. */
  54383. readonly name: string;
  54384. /**
  54385. * The scene the component belongs to.
  54386. */
  54387. scene: Scene;
  54388. /**
  54389. * Creates a new instance of the component for the given scene
  54390. * @param scene Defines the scene to register the component in
  54391. */
  54392. constructor(scene: Scene);
  54393. /**
  54394. * Registers the component in a given scene
  54395. */
  54396. register(): void;
  54397. /**
  54398. * Rebuilds the elements related to this component in case of
  54399. * context lost for instance.
  54400. */
  54401. rebuild(): void;
  54402. /**
  54403. * Disposes the component and the associated ressources
  54404. */
  54405. dispose(): void;
  54406. private _beforeCameraUpdate;
  54407. }
  54408. }
  54409. declare module BABYLON {
  54410. /**
  54411. * Class used to enable access to IndexedDB
  54412. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  54413. */
  54414. export class Database implements IOfflineProvider {
  54415. private _callbackManifestChecked;
  54416. private _currentSceneUrl;
  54417. private _db;
  54418. private _enableSceneOffline;
  54419. private _enableTexturesOffline;
  54420. private _manifestVersionFound;
  54421. private _mustUpdateRessources;
  54422. private _hasReachedQuota;
  54423. private _isSupported;
  54424. private _idbFactory;
  54425. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  54426. private static IsUASupportingBlobStorage;
  54427. /**
  54428. * Gets a boolean indicating if Database storate is enabled (off by default)
  54429. */
  54430. static IDBStorageEnabled: boolean;
  54431. /**
  54432. * Gets a boolean indicating if scene must be saved in the database
  54433. */
  54434. readonly enableSceneOffline: boolean;
  54435. /**
  54436. * Gets a boolean indicating if textures must be saved in the database
  54437. */
  54438. readonly enableTexturesOffline: boolean;
  54439. /**
  54440. * Creates a new Database
  54441. * @param urlToScene defines the url to load the scene
  54442. * @param callbackManifestChecked defines the callback to use when manifest is checked
  54443. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  54444. */
  54445. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  54446. private static _ParseURL;
  54447. private static _ReturnFullUrlLocation;
  54448. private _checkManifestFile;
  54449. /**
  54450. * Open the database and make it available
  54451. * @param successCallback defines the callback to call on success
  54452. * @param errorCallback defines the callback to call on error
  54453. */
  54454. open(successCallback: () => void, errorCallback: () => void): void;
  54455. /**
  54456. * Loads an image from the database
  54457. * @param url defines the url to load from
  54458. * @param image defines the target DOM image
  54459. */
  54460. loadImage(url: string, image: HTMLImageElement): void;
  54461. private _loadImageFromDBAsync;
  54462. private _saveImageIntoDBAsync;
  54463. private _checkVersionFromDB;
  54464. private _loadVersionFromDBAsync;
  54465. private _saveVersionIntoDBAsync;
  54466. /**
  54467. * Loads a file from database
  54468. * @param url defines the URL to load from
  54469. * @param sceneLoaded defines a callback to call on success
  54470. * @param progressCallBack defines a callback to call when progress changed
  54471. * @param errorCallback defines a callback to call on error
  54472. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  54473. */
  54474. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  54475. private _loadFileAsync;
  54476. private _saveFileAsync;
  54477. /**
  54478. * Validates if xhr data is correct
  54479. * @param xhr defines the request to validate
  54480. * @param dataType defines the expected data type
  54481. * @returns true if data is correct
  54482. */
  54483. private static _ValidateXHRData;
  54484. }
  54485. }
  54486. declare module BABYLON {
  54487. /** @hidden */
  54488. export var gpuUpdateParticlesPixelShader: {
  54489. name: string;
  54490. shader: string;
  54491. };
  54492. }
  54493. declare module BABYLON {
  54494. /** @hidden */
  54495. export var gpuUpdateParticlesVertexShader: {
  54496. name: string;
  54497. shader: string;
  54498. };
  54499. }
  54500. declare module BABYLON {
  54501. /** @hidden */
  54502. export var clipPlaneFragmentDeclaration2: {
  54503. name: string;
  54504. shader: string;
  54505. };
  54506. }
  54507. declare module BABYLON {
  54508. /** @hidden */
  54509. export var gpuRenderParticlesPixelShader: {
  54510. name: string;
  54511. shader: string;
  54512. };
  54513. }
  54514. declare module BABYLON {
  54515. /** @hidden */
  54516. export var clipPlaneVertexDeclaration2: {
  54517. name: string;
  54518. shader: string;
  54519. };
  54520. }
  54521. declare module BABYLON {
  54522. /** @hidden */
  54523. export var gpuRenderParticlesVertexShader: {
  54524. name: string;
  54525. shader: string;
  54526. };
  54527. }
  54528. declare module BABYLON {
  54529. /**
  54530. * This represents a GPU particle system in Babylon
  54531. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  54532. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  54533. */
  54534. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  54535. /**
  54536. * The layer mask we are rendering the particles through.
  54537. */
  54538. layerMask: number;
  54539. private _capacity;
  54540. private _activeCount;
  54541. private _currentActiveCount;
  54542. private _accumulatedCount;
  54543. private _renderEffect;
  54544. private _updateEffect;
  54545. private _buffer0;
  54546. private _buffer1;
  54547. private _spriteBuffer;
  54548. private _updateVAO;
  54549. private _renderVAO;
  54550. private _targetIndex;
  54551. private _sourceBuffer;
  54552. private _targetBuffer;
  54553. private _engine;
  54554. private _currentRenderId;
  54555. private _started;
  54556. private _stopped;
  54557. private _timeDelta;
  54558. private _randomTexture;
  54559. private _randomTexture2;
  54560. private _attributesStrideSize;
  54561. private _updateEffectOptions;
  54562. private _randomTextureSize;
  54563. private _actualFrame;
  54564. private readonly _rawTextureWidth;
  54565. /**
  54566. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  54567. */
  54568. static readonly IsSupported: boolean;
  54569. /**
  54570. * An event triggered when the system is disposed.
  54571. */
  54572. onDisposeObservable: Observable<GPUParticleSystem>;
  54573. /**
  54574. * Gets the maximum number of particles active at the same time.
  54575. * @returns The max number of active particles.
  54576. */
  54577. getCapacity(): number;
  54578. /**
  54579. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  54580. * to override the particles.
  54581. */
  54582. forceDepthWrite: boolean;
  54583. /**
  54584. * Gets or set the number of active particles
  54585. */
  54586. activeParticleCount: number;
  54587. private _preWarmDone;
  54588. /**
  54589. * Is this system ready to be used/rendered
  54590. * @return true if the system is ready
  54591. */
  54592. isReady(): boolean;
  54593. /**
  54594. * Gets if the system has been started. (Note: this will still be true after stop is called)
  54595. * @returns True if it has been started, otherwise false.
  54596. */
  54597. isStarted(): boolean;
  54598. /**
  54599. * Starts the particle system and begins to emit
  54600. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  54601. */
  54602. start(delay?: number): void;
  54603. /**
  54604. * Stops the particle system.
  54605. */
  54606. stop(): void;
  54607. /**
  54608. * Remove all active particles
  54609. */
  54610. reset(): void;
  54611. /**
  54612. * Returns the string "GPUParticleSystem"
  54613. * @returns a string containing the class name
  54614. */
  54615. getClassName(): string;
  54616. private _colorGradientsTexture;
  54617. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  54618. /**
  54619. * Adds a new color gradient
  54620. * @param gradient defines the gradient to use (between 0 and 1)
  54621. * @param color1 defines the color to affect to the specified gradient
  54622. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  54623. * @returns the current particle system
  54624. */
  54625. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  54626. /**
  54627. * Remove a specific color gradient
  54628. * @param gradient defines the gradient to remove
  54629. * @returns the current particle system
  54630. */
  54631. removeColorGradient(gradient: number): GPUParticleSystem;
  54632. private _angularSpeedGradientsTexture;
  54633. private _sizeGradientsTexture;
  54634. private _velocityGradientsTexture;
  54635. private _limitVelocityGradientsTexture;
  54636. private _dragGradientsTexture;
  54637. private _addFactorGradient;
  54638. /**
  54639. * Adds a new size gradient
  54640. * @param gradient defines the gradient to use (between 0 and 1)
  54641. * @param factor defines the size factor to affect to the specified gradient
  54642. * @returns the current particle system
  54643. */
  54644. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  54645. /**
  54646. * Remove a specific size gradient
  54647. * @param gradient defines the gradient to remove
  54648. * @returns the current particle system
  54649. */
  54650. removeSizeGradient(gradient: number): GPUParticleSystem;
  54651. /**
  54652. * Adds a new angular speed gradient
  54653. * @param gradient defines the gradient to use (between 0 and 1)
  54654. * @param factor defines the angular speed to affect to the specified gradient
  54655. * @returns the current particle system
  54656. */
  54657. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  54658. /**
  54659. * Remove a specific angular speed gradient
  54660. * @param gradient defines the gradient to remove
  54661. * @returns the current particle system
  54662. */
  54663. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  54664. /**
  54665. * Adds a new velocity gradient
  54666. * @param gradient defines the gradient to use (between 0 and 1)
  54667. * @param factor defines the velocity to affect to the specified gradient
  54668. * @returns the current particle system
  54669. */
  54670. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54671. /**
  54672. * Remove a specific velocity gradient
  54673. * @param gradient defines the gradient to remove
  54674. * @returns the current particle system
  54675. */
  54676. removeVelocityGradient(gradient: number): GPUParticleSystem;
  54677. /**
  54678. * Adds a new limit velocity gradient
  54679. * @param gradient defines the gradient to use (between 0 and 1)
  54680. * @param factor defines the limit velocity value to affect to the specified gradient
  54681. * @returns the current particle system
  54682. */
  54683. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54684. /**
  54685. * Remove a specific limit velocity gradient
  54686. * @param gradient defines the gradient to remove
  54687. * @returns the current particle system
  54688. */
  54689. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  54690. /**
  54691. * Adds a new drag gradient
  54692. * @param gradient defines the gradient to use (between 0 and 1)
  54693. * @param factor defines the drag value to affect to the specified gradient
  54694. * @returns the current particle system
  54695. */
  54696. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  54697. /**
  54698. * Remove a specific drag gradient
  54699. * @param gradient defines the gradient to remove
  54700. * @returns the current particle system
  54701. */
  54702. removeDragGradient(gradient: number): GPUParticleSystem;
  54703. /**
  54704. * Not supported by GPUParticleSystem
  54705. * @param gradient defines the gradient to use (between 0 and 1)
  54706. * @param factor defines the emit rate value to affect to the specified gradient
  54707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54708. * @returns the current particle system
  54709. */
  54710. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54711. /**
  54712. * Not supported by GPUParticleSystem
  54713. * @param gradient defines the gradient to remove
  54714. * @returns the current particle system
  54715. */
  54716. removeEmitRateGradient(gradient: number): IParticleSystem;
  54717. /**
  54718. * Not supported by GPUParticleSystem
  54719. * @param gradient defines the gradient to use (between 0 and 1)
  54720. * @param factor defines the start size value to affect to the specified gradient
  54721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54722. * @returns the current particle system
  54723. */
  54724. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54725. /**
  54726. * Not supported by GPUParticleSystem
  54727. * @param gradient defines the gradient to remove
  54728. * @returns the current particle system
  54729. */
  54730. removeStartSizeGradient(gradient: number): IParticleSystem;
  54731. /**
  54732. * Not supported by GPUParticleSystem
  54733. * @param gradient defines the gradient to use (between 0 and 1)
  54734. * @param min defines the color remap minimal range
  54735. * @param max defines the color remap maximal range
  54736. * @returns the current particle system
  54737. */
  54738. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54739. /**
  54740. * Not supported by GPUParticleSystem
  54741. * @param gradient defines the gradient to remove
  54742. * @returns the current particle system
  54743. */
  54744. removeColorRemapGradient(): IParticleSystem;
  54745. /**
  54746. * Not supported by GPUParticleSystem
  54747. * @param gradient defines the gradient to use (between 0 and 1)
  54748. * @param min defines the alpha remap minimal range
  54749. * @param max defines the alpha remap maximal range
  54750. * @returns the current particle system
  54751. */
  54752. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54753. /**
  54754. * Not supported by GPUParticleSystem
  54755. * @param gradient defines the gradient to remove
  54756. * @returns the current particle system
  54757. */
  54758. removeAlphaRemapGradient(): IParticleSystem;
  54759. /**
  54760. * Not supported by GPUParticleSystem
  54761. * @param gradient defines the gradient to use (between 0 and 1)
  54762. * @param color defines the color to affect to the specified gradient
  54763. * @returns the current particle system
  54764. */
  54765. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  54766. /**
  54767. * Not supported by GPUParticleSystem
  54768. * @param gradient defines the gradient to remove
  54769. * @returns the current particle system
  54770. */
  54771. removeRampGradient(): IParticleSystem;
  54772. /**
  54773. * Not supported by GPUParticleSystem
  54774. * @returns the list of ramp gradients
  54775. */
  54776. getRampGradients(): Nullable<Array<Color3Gradient>>;
  54777. /**
  54778. * Not supported by GPUParticleSystem
  54779. * Gets or sets a boolean indicating that ramp gradients must be used
  54780. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  54781. */
  54782. useRampGradients: boolean;
  54783. /**
  54784. * Not supported by GPUParticleSystem
  54785. * @param gradient defines the gradient to use (between 0 and 1)
  54786. * @param factor defines the life time factor to affect to the specified gradient
  54787. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54788. * @returns the current particle system
  54789. */
  54790. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54791. /**
  54792. * Not supported by GPUParticleSystem
  54793. * @param gradient defines the gradient to remove
  54794. * @returns the current particle system
  54795. */
  54796. removeLifeTimeGradient(gradient: number): IParticleSystem;
  54797. /**
  54798. * Instantiates a GPU particle system.
  54799. * 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.
  54800. * @param name The name of the particle system
  54801. * @param options The options used to create the system
  54802. * @param scene The scene the particle system belongs to
  54803. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  54804. */
  54805. constructor(name: string, options: Partial<{
  54806. capacity: number;
  54807. randomTextureSize: number;
  54808. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  54809. protected _reset(): void;
  54810. private _createUpdateVAO;
  54811. private _createRenderVAO;
  54812. private _initialize;
  54813. /** @hidden */
  54814. _recreateUpdateEffect(): void;
  54815. /** @hidden */
  54816. _recreateRenderEffect(): void;
  54817. /**
  54818. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  54819. * @param preWarm defines if we are in the pre-warmimg phase
  54820. */
  54821. animate(preWarm?: boolean): void;
  54822. private _createFactorGradientTexture;
  54823. private _createSizeGradientTexture;
  54824. private _createAngularSpeedGradientTexture;
  54825. private _createVelocityGradientTexture;
  54826. private _createLimitVelocityGradientTexture;
  54827. private _createDragGradientTexture;
  54828. private _createColorGradientTexture;
  54829. /**
  54830. * Renders the particle system in its current state
  54831. * @param preWarm defines if the system should only update the particles but not render them
  54832. * @returns the current number of particles
  54833. */
  54834. render(preWarm?: boolean): number;
  54835. /**
  54836. * Rebuilds the particle system
  54837. */
  54838. rebuild(): void;
  54839. private _releaseBuffers;
  54840. private _releaseVAOs;
  54841. /**
  54842. * Disposes the particle system and free the associated resources
  54843. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  54844. */
  54845. dispose(disposeTexture?: boolean): void;
  54846. /**
  54847. * Clones the particle system.
  54848. * @param name The name of the cloned object
  54849. * @param newEmitter The new emitter to use
  54850. * @returns the cloned particle system
  54851. */
  54852. clone(name: string, newEmitter: any): GPUParticleSystem;
  54853. /**
  54854. * Serializes the particle system to a JSON object.
  54855. * @returns the JSON object
  54856. */
  54857. serialize(): any;
  54858. /**
  54859. * Parses a JSON object to create a GPU particle system.
  54860. * @param parsedParticleSystem The JSON object to parse
  54861. * @param scene The scene to create the particle system in
  54862. * @param rootUrl The root url to use to load external dependencies like texture
  54863. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  54864. * @returns the parsed GPU particle system
  54865. */
  54866. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  54867. }
  54868. }
  54869. declare module BABYLON {
  54870. /**
  54871. * Represents a set of particle systems working together to create a specific effect
  54872. */
  54873. export class ParticleSystemSet implements IDisposable {
  54874. private _emitterCreationOptions;
  54875. private _emitterNode;
  54876. /**
  54877. * Gets the particle system list
  54878. */
  54879. systems: IParticleSystem[];
  54880. /**
  54881. * Gets the emitter node used with this set
  54882. */
  54883. readonly emitterNode: Nullable<TransformNode>;
  54884. /**
  54885. * Creates a new emitter mesh as a sphere
  54886. * @param options defines the options used to create the sphere
  54887. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54888. * @param scene defines the hosting scene
  54889. */
  54890. setEmitterAsSphere(options: {
  54891. diameter: number;
  54892. segments: number;
  54893. color: Color3;
  54894. }, renderingGroupId: number, scene: Scene): void;
  54895. /**
  54896. * Starts all particle systems of the set
  54897. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54898. */
  54899. start(emitter?: AbstractMesh): void;
  54900. /**
  54901. * Release all associated resources
  54902. */
  54903. dispose(): void;
  54904. /**
  54905. * Serialize the set into a JSON compatible object
  54906. * @returns a JSON compatible representation of the set
  54907. */
  54908. serialize(): any;
  54909. /**
  54910. * Parse a new ParticleSystemSet from a serialized source
  54911. * @param data defines a JSON compatible representation of the set
  54912. * @param scene defines the hosting scene
  54913. * @param gpu defines if we want GPU particles or CPU particles
  54914. * @returns a new ParticleSystemSet
  54915. */
  54916. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54917. }
  54918. }
  54919. declare module BABYLON {
  54920. /**
  54921. * This class is made for on one-liner static method to help creating particle system set.
  54922. */
  54923. export class ParticleHelper {
  54924. /**
  54925. * Gets or sets base Assets URL
  54926. */
  54927. static BaseAssetsUrl: string;
  54928. /**
  54929. * Create a default particle system that you can tweak
  54930. * @param emitter defines the emitter to use
  54931. * @param capacity defines the system capacity (default is 500 particles)
  54932. * @param scene defines the hosting scene
  54933. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54934. * @returns the new Particle system
  54935. */
  54936. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54937. /**
  54938. * This is the main static method (one-liner) of this helper to create different particle systems
  54939. * @param type This string represents the type to the particle system to create
  54940. * @param scene The scene where the particle system should live
  54941. * @param gpu If the system will use gpu
  54942. * @returns the ParticleSystemSet created
  54943. */
  54944. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54945. /**
  54946. * Static function used to export a particle system to a ParticleSystemSet variable.
  54947. * Please note that the emitter shape is not exported
  54948. * @param systems defines the particle systems to export
  54949. * @returns the created particle system set
  54950. */
  54951. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54952. }
  54953. }
  54954. declare module BABYLON {
  54955. interface Engine {
  54956. /**
  54957. * Create an effect to use with particle systems.
  54958. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54959. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54960. * @param uniformsNames defines a list of attribute names
  54961. * @param samplers defines an array of string used to represent textures
  54962. * @param defines defines the string containing the defines to use to compile the shaders
  54963. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54964. * @param onCompiled defines a function to call when the effect creation is successful
  54965. * @param onError defines a function to call when the effect creation has failed
  54966. * @returns the new Effect
  54967. */
  54968. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54969. }
  54970. interface Mesh {
  54971. /**
  54972. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54973. * @returns an array of IParticleSystem
  54974. */
  54975. getEmittedParticleSystems(): IParticleSystem[];
  54976. /**
  54977. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54978. * @returns an array of IParticleSystem
  54979. */
  54980. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54981. }
  54982. /**
  54983. * @hidden
  54984. */
  54985. export var _IDoNeedToBeInTheBuild: number;
  54986. }
  54987. declare module BABYLON {
  54988. interface Scene {
  54989. /** @hidden (Backing field) */
  54990. _physicsEngine: Nullable<IPhysicsEngine>;
  54991. /**
  54992. * Gets the current physics engine
  54993. * @returns a IPhysicsEngine or null if none attached
  54994. */
  54995. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54996. /**
  54997. * Enables physics to the current scene
  54998. * @param gravity defines the scene's gravity for the physics engine
  54999. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  55000. * @return a boolean indicating if the physics engine was initialized
  55001. */
  55002. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  55003. /**
  55004. * Disables and disposes the physics engine associated with the scene
  55005. */
  55006. disablePhysicsEngine(): void;
  55007. /**
  55008. * Gets a boolean indicating if there is an active physics engine
  55009. * @returns a boolean indicating if there is an active physics engine
  55010. */
  55011. isPhysicsEnabled(): boolean;
  55012. /**
  55013. * Deletes a physics compound impostor
  55014. * @param compound defines the compound to delete
  55015. */
  55016. deleteCompoundImpostor(compound: any): void;
  55017. /**
  55018. * An event triggered when physic simulation is about to be run
  55019. */
  55020. onBeforePhysicsObservable: Observable<Scene>;
  55021. /**
  55022. * An event triggered when physic simulation has been done
  55023. */
  55024. onAfterPhysicsObservable: Observable<Scene>;
  55025. }
  55026. interface AbstractMesh {
  55027. /** @hidden */
  55028. _physicsImpostor: Nullable<PhysicsImpostor>;
  55029. /**
  55030. * Gets or sets impostor used for physic simulation
  55031. * @see http://doc.babylonjs.com/features/physics_engine
  55032. */
  55033. physicsImpostor: Nullable<PhysicsImpostor>;
  55034. /**
  55035. * Gets the current physics impostor
  55036. * @see http://doc.babylonjs.com/features/physics_engine
  55037. * @returns a physics impostor or null
  55038. */
  55039. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  55040. /** Apply a physic impulse to the mesh
  55041. * @param force defines the force to apply
  55042. * @param contactPoint defines where to apply the force
  55043. * @returns the current mesh
  55044. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55045. */
  55046. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  55047. /**
  55048. * Creates a physic joint between two meshes
  55049. * @param otherMesh defines the other mesh to use
  55050. * @param pivot1 defines the pivot to use on this mesh
  55051. * @param pivot2 defines the pivot to use on the other mesh
  55052. * @param options defines additional options (can be plugin dependent)
  55053. * @returns the current mesh
  55054. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  55055. */
  55056. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  55057. /** @hidden */
  55058. _disposePhysicsObserver: Nullable<Observer<Node>>;
  55059. }
  55060. /**
  55061. * Defines the physics engine scene component responsible to manage a physics engine
  55062. */
  55063. export class PhysicsEngineSceneComponent implements ISceneComponent {
  55064. /**
  55065. * The component name helpful to identify the component in the list of scene components.
  55066. */
  55067. readonly name: string;
  55068. /**
  55069. * The scene the component belongs to.
  55070. */
  55071. scene: Scene;
  55072. /**
  55073. * Creates a new instance of the component for the given scene
  55074. * @param scene Defines the scene to register the component in
  55075. */
  55076. constructor(scene: Scene);
  55077. /**
  55078. * Registers the component in a given scene
  55079. */
  55080. register(): void;
  55081. /**
  55082. * Rebuilds the elements related to this component in case of
  55083. * context lost for instance.
  55084. */
  55085. rebuild(): void;
  55086. /**
  55087. * Disposes the component and the associated ressources
  55088. */
  55089. dispose(): void;
  55090. }
  55091. }
  55092. declare module BABYLON {
  55093. /**
  55094. * A helper for physics simulations
  55095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55096. */
  55097. export class PhysicsHelper {
  55098. private _scene;
  55099. private _physicsEngine;
  55100. /**
  55101. * Initializes the Physics helper
  55102. * @param scene Babylon.js scene
  55103. */
  55104. constructor(scene: Scene);
  55105. /**
  55106. * Applies a radial explosion impulse
  55107. * @param origin the origin of the explosion
  55108. * @param radiusOrEventOptions the radius or the options of radial explosion
  55109. * @param strength the explosion strength
  55110. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55111. * @returns A physics radial explosion event, or null
  55112. */
  55113. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  55114. /**
  55115. * Applies a radial explosion force
  55116. * @param origin the origin of the explosion
  55117. * @param radiusOrEventOptions the radius or the options of radial explosion
  55118. * @param strength the explosion strength
  55119. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55120. * @returns A physics radial explosion event, or null
  55121. */
  55122. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  55123. /**
  55124. * Creates a gravitational field
  55125. * @param origin the origin of the explosion
  55126. * @param radiusOrEventOptions the radius or the options of radial explosion
  55127. * @param strength the explosion strength
  55128. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55129. * @returns A physics gravitational field event, or null
  55130. */
  55131. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  55132. /**
  55133. * Creates a physics updraft event
  55134. * @param origin the origin of the updraft
  55135. * @param radiusOrEventOptions the radius or the options of the updraft
  55136. * @param strength the strength of the updraft
  55137. * @param height the height of the updraft
  55138. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  55139. * @returns A physics updraft event, or null
  55140. */
  55141. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  55142. /**
  55143. * Creates a physics vortex event
  55144. * @param origin the of the vortex
  55145. * @param radiusOrEventOptions the radius or the options of the vortex
  55146. * @param strength the strength of the vortex
  55147. * @param height the height of the vortex
  55148. * @returns a Physics vortex event, or null
  55149. * A physics vortex event or null
  55150. */
  55151. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  55152. }
  55153. /**
  55154. * Represents a physics radial explosion event
  55155. */
  55156. class PhysicsRadialExplosionEvent {
  55157. private _scene;
  55158. private _options;
  55159. private _sphere;
  55160. private _dataFetched;
  55161. /**
  55162. * Initializes a radial explosioin event
  55163. * @param _scene BabylonJS scene
  55164. * @param _options The options for the vortex event
  55165. */
  55166. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  55167. /**
  55168. * Returns the data related to the radial explosion event (sphere).
  55169. * @returns The radial explosion event data
  55170. */
  55171. getData(): PhysicsRadialExplosionEventData;
  55172. /**
  55173. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  55174. * @param impostor A physics imposter
  55175. * @param origin the origin of the explosion
  55176. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  55177. */
  55178. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  55179. /**
  55180. * Triggers affecterd impostors callbacks
  55181. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  55182. */
  55183. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  55184. /**
  55185. * Disposes the sphere.
  55186. * @param force Specifies if the sphere should be disposed by force
  55187. */
  55188. dispose(force?: boolean): void;
  55189. /*** Helpers ***/
  55190. private _prepareSphere;
  55191. private _intersectsWithSphere;
  55192. }
  55193. /**
  55194. * Represents a gravitational field event
  55195. */
  55196. class PhysicsGravitationalFieldEvent {
  55197. private _physicsHelper;
  55198. private _scene;
  55199. private _origin;
  55200. private _options;
  55201. private _tickCallback;
  55202. private _sphere;
  55203. private _dataFetched;
  55204. /**
  55205. * Initializes the physics gravitational field event
  55206. * @param _physicsHelper A physics helper
  55207. * @param _scene BabylonJS scene
  55208. * @param _origin The origin position of the gravitational field event
  55209. * @param _options The options for the vortex event
  55210. */
  55211. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  55212. /**
  55213. * Returns the data related to the gravitational field event (sphere).
  55214. * @returns A gravitational field event
  55215. */
  55216. getData(): PhysicsGravitationalFieldEventData;
  55217. /**
  55218. * Enables the gravitational field.
  55219. */
  55220. enable(): void;
  55221. /**
  55222. * Disables the gravitational field.
  55223. */
  55224. disable(): void;
  55225. /**
  55226. * Disposes the sphere.
  55227. * @param force The force to dispose from the gravitational field event
  55228. */
  55229. dispose(force?: boolean): void;
  55230. private _tick;
  55231. }
  55232. /**
  55233. * Represents a physics updraft event
  55234. */
  55235. class PhysicsUpdraftEvent {
  55236. private _scene;
  55237. private _origin;
  55238. private _options;
  55239. private _physicsEngine;
  55240. private _originTop;
  55241. private _originDirection;
  55242. private _tickCallback;
  55243. private _cylinder;
  55244. private _cylinderPosition;
  55245. private _dataFetched;
  55246. /**
  55247. * Initializes the physics updraft event
  55248. * @param _scene BabylonJS scene
  55249. * @param _origin The origin position of the updraft
  55250. * @param _options The options for the updraft event
  55251. */
  55252. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  55253. /**
  55254. * Returns the data related to the updraft event (cylinder).
  55255. * @returns A physics updraft event
  55256. */
  55257. getData(): PhysicsUpdraftEventData;
  55258. /**
  55259. * Enables the updraft.
  55260. */
  55261. enable(): void;
  55262. /**
  55263. * Disables the updraft.
  55264. */
  55265. disable(): void;
  55266. /**
  55267. * Disposes the cylinder.
  55268. * @param force Specifies if the updraft should be disposed by force
  55269. */
  55270. dispose(force?: boolean): void;
  55271. private getImpostorHitData;
  55272. private _tick;
  55273. /*** Helpers ***/
  55274. private _prepareCylinder;
  55275. private _intersectsWithCylinder;
  55276. }
  55277. /**
  55278. * Represents a physics vortex event
  55279. */
  55280. class PhysicsVortexEvent {
  55281. private _scene;
  55282. private _origin;
  55283. private _options;
  55284. private _physicsEngine;
  55285. private _originTop;
  55286. private _tickCallback;
  55287. private _cylinder;
  55288. private _cylinderPosition;
  55289. private _dataFetched;
  55290. /**
  55291. * Initializes the physics vortex event
  55292. * @param _scene The BabylonJS scene
  55293. * @param _origin The origin position of the vortex
  55294. * @param _options The options for the vortex event
  55295. */
  55296. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  55297. /**
  55298. * Returns the data related to the vortex event (cylinder).
  55299. * @returns The physics vortex event data
  55300. */
  55301. getData(): PhysicsVortexEventData;
  55302. /**
  55303. * Enables the vortex.
  55304. */
  55305. enable(): void;
  55306. /**
  55307. * Disables the cortex.
  55308. */
  55309. disable(): void;
  55310. /**
  55311. * Disposes the sphere.
  55312. * @param force
  55313. */
  55314. dispose(force?: boolean): void;
  55315. private getImpostorHitData;
  55316. private _tick;
  55317. /*** Helpers ***/
  55318. private _prepareCylinder;
  55319. private _intersectsWithCylinder;
  55320. }
  55321. /**
  55322. * Options fot the radial explosion event
  55323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55324. */
  55325. export class PhysicsRadialExplosionEventOptions {
  55326. /**
  55327. * The radius of the sphere for the radial explosion.
  55328. */
  55329. radius: number;
  55330. /**
  55331. * The strenth of the explosion.
  55332. */
  55333. strength: number;
  55334. /**
  55335. * The strenght of the force in correspondence to the distance of the affected object
  55336. */
  55337. falloff: PhysicsRadialImpulseFalloff;
  55338. /**
  55339. * Sphere options for the radial explosion.
  55340. */
  55341. sphere: {
  55342. segments: number;
  55343. diameter: number;
  55344. };
  55345. /**
  55346. * Sphere options for the radial explosion.
  55347. */
  55348. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  55349. }
  55350. /**
  55351. * Options fot the updraft event
  55352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55353. */
  55354. export class PhysicsUpdraftEventOptions {
  55355. /**
  55356. * The radius of the cylinder for the vortex
  55357. */
  55358. radius: number;
  55359. /**
  55360. * The strenth of the updraft.
  55361. */
  55362. strength: number;
  55363. /**
  55364. * The height of the cylinder for the updraft.
  55365. */
  55366. height: number;
  55367. /**
  55368. * The mode for the the updraft.
  55369. */
  55370. updraftMode: PhysicsUpdraftMode;
  55371. }
  55372. /**
  55373. * Options fot the vortex event
  55374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55375. */
  55376. export class PhysicsVortexEventOptions {
  55377. /**
  55378. * The radius of the cylinder for the vortex
  55379. */
  55380. radius: number;
  55381. /**
  55382. * The strenth of the vortex.
  55383. */
  55384. strength: number;
  55385. /**
  55386. * The height of the cylinder for the vortex.
  55387. */
  55388. height: number;
  55389. /**
  55390. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  55391. */
  55392. centripetalForceThreshold: number;
  55393. /**
  55394. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  55395. */
  55396. centripetalForceMultiplier: number;
  55397. /**
  55398. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  55399. */
  55400. centrifugalForceMultiplier: number;
  55401. /**
  55402. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  55403. */
  55404. updraftForceMultiplier: number;
  55405. }
  55406. /**
  55407. * The strenght of the force in correspondence to the distance of the affected object
  55408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55409. */
  55410. export enum PhysicsRadialImpulseFalloff {
  55411. /** Defines that impulse is constant in strength across it's whole radius */
  55412. Constant = 0,
  55413. /** Defines that impulse gets weaker if it's further from the origin */
  55414. Linear = 1
  55415. }
  55416. /**
  55417. * The strength of the force in correspondence to the distance of the affected object
  55418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55419. */
  55420. export enum PhysicsUpdraftMode {
  55421. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  55422. Center = 0,
  55423. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  55424. Perpendicular = 1
  55425. }
  55426. /**
  55427. * Interface for a physics hit data
  55428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55429. */
  55430. export interface PhysicsHitData {
  55431. /**
  55432. * The force applied at the contact point
  55433. */
  55434. force: Vector3;
  55435. /**
  55436. * The contact point
  55437. */
  55438. contactPoint: Vector3;
  55439. /**
  55440. * The distance from the origin to the contact point
  55441. */
  55442. distanceFromOrigin: number;
  55443. }
  55444. /**
  55445. * Interface for radial explosion event data
  55446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55447. */
  55448. export interface PhysicsRadialExplosionEventData {
  55449. /**
  55450. * A sphere used for the radial explosion event
  55451. */
  55452. sphere: Mesh;
  55453. }
  55454. /**
  55455. * Interface for gravitational field event data
  55456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55457. */
  55458. export interface PhysicsGravitationalFieldEventData {
  55459. /**
  55460. * A sphere mesh used for the gravitational field event
  55461. */
  55462. sphere: Mesh;
  55463. }
  55464. /**
  55465. * Interface for updraft event data
  55466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55467. */
  55468. export interface PhysicsUpdraftEventData {
  55469. /**
  55470. * A cylinder used for the updraft event
  55471. */
  55472. cylinder: Mesh;
  55473. }
  55474. /**
  55475. * Interface for vortex event data
  55476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55477. */
  55478. export interface PhysicsVortexEventData {
  55479. /**
  55480. * A cylinder used for the vortex event
  55481. */
  55482. cylinder: Mesh;
  55483. }
  55484. /**
  55485. * Interface for an affected physics impostor
  55486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55487. */
  55488. export interface PhysicsAffectedImpostorWithData {
  55489. /**
  55490. * The impostor affected by the effect
  55491. */
  55492. impostor: PhysicsImpostor;
  55493. /**
  55494. * The data about the hit/horce from the explosion
  55495. */
  55496. hitData: PhysicsHitData;
  55497. }
  55498. }
  55499. declare module BABYLON {
  55500. /** @hidden */
  55501. export var blackAndWhitePixelShader: {
  55502. name: string;
  55503. shader: string;
  55504. };
  55505. }
  55506. declare module BABYLON {
  55507. /**
  55508. * Post process used to render in black and white
  55509. */
  55510. export class BlackAndWhitePostProcess extends PostProcess {
  55511. /**
  55512. * Linear about to convert he result to black and white (default: 1)
  55513. */
  55514. degree: number;
  55515. /**
  55516. * Creates a black and white post process
  55517. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  55518. * @param name The name of the effect.
  55519. * @param options The required width/height ratio to downsize to before computing the render pass.
  55520. * @param camera The camera to apply the render pass to.
  55521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55522. * @param engine The engine which the post process will be applied. (default: current engine)
  55523. * @param reusable If the post process can be reused on the same frame. (default: false)
  55524. */
  55525. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55526. }
  55527. }
  55528. declare module BABYLON {
  55529. /**
  55530. * This represents a set of one or more post processes in Babylon.
  55531. * A post process can be used to apply a shader to a texture after it is rendered.
  55532. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55533. */
  55534. export class PostProcessRenderEffect {
  55535. private _postProcesses;
  55536. private _getPostProcesses;
  55537. private _singleInstance;
  55538. private _cameras;
  55539. private _indicesForCamera;
  55540. /**
  55541. * Name of the effect
  55542. * @hidden
  55543. */
  55544. _name: string;
  55545. /**
  55546. * Instantiates a post process render effect.
  55547. * A post process can be used to apply a shader to a texture after it is rendered.
  55548. * @param engine The engine the effect is tied to
  55549. * @param name The name of the effect
  55550. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  55551. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  55552. */
  55553. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  55554. /**
  55555. * Checks if all the post processes in the effect are supported.
  55556. */
  55557. readonly isSupported: boolean;
  55558. /**
  55559. * Updates the current state of the effect
  55560. * @hidden
  55561. */
  55562. _update(): void;
  55563. /**
  55564. * Attaches the effect on cameras
  55565. * @param cameras The camera to attach to.
  55566. * @hidden
  55567. */
  55568. _attachCameras(cameras: Camera): void;
  55569. /**
  55570. * Attaches the effect on cameras
  55571. * @param cameras The camera to attach to.
  55572. * @hidden
  55573. */
  55574. _attachCameras(cameras: Camera[]): void;
  55575. /**
  55576. * Detaches the effect on cameras
  55577. * @param cameras The camera to detatch from.
  55578. * @hidden
  55579. */
  55580. _detachCameras(cameras: Camera): void;
  55581. /**
  55582. * Detatches the effect on cameras
  55583. * @param cameras The camera to detatch from.
  55584. * @hidden
  55585. */
  55586. _detachCameras(cameras: Camera[]): void;
  55587. /**
  55588. * Enables the effect on given cameras
  55589. * @param cameras The camera to enable.
  55590. * @hidden
  55591. */
  55592. _enable(cameras: Camera): void;
  55593. /**
  55594. * Enables the effect on given cameras
  55595. * @param cameras The camera to enable.
  55596. * @hidden
  55597. */
  55598. _enable(cameras: Nullable<Camera[]>): void;
  55599. /**
  55600. * Disables the effect on the given cameras
  55601. * @param cameras The camera to disable.
  55602. * @hidden
  55603. */
  55604. _disable(cameras: Camera): void;
  55605. /**
  55606. * Disables the effect on the given cameras
  55607. * @param cameras The camera to disable.
  55608. * @hidden
  55609. */
  55610. _disable(cameras: Nullable<Camera[]>): void;
  55611. /**
  55612. * Gets a list of the post processes contained in the effect.
  55613. * @param camera The camera to get the post processes on.
  55614. * @returns The list of the post processes in the effect.
  55615. */
  55616. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  55617. }
  55618. }
  55619. declare module BABYLON {
  55620. /** @hidden */
  55621. export var extractHighlightsPixelShader: {
  55622. name: string;
  55623. shader: string;
  55624. };
  55625. }
  55626. declare module BABYLON {
  55627. /**
  55628. * 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.
  55629. */
  55630. export class ExtractHighlightsPostProcess extends PostProcess {
  55631. /**
  55632. * The luminance threshold, pixels below this value will be set to black.
  55633. */
  55634. threshold: number;
  55635. /** @hidden */
  55636. _exposure: number;
  55637. /**
  55638. * Post process which has the input texture to be used when performing highlight extraction
  55639. * @hidden
  55640. */
  55641. _inputPostProcess: Nullable<PostProcess>;
  55642. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55643. }
  55644. }
  55645. declare module BABYLON {
  55646. /** @hidden */
  55647. export var bloomMergePixelShader: {
  55648. name: string;
  55649. shader: string;
  55650. };
  55651. }
  55652. declare module BABYLON {
  55653. /**
  55654. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55655. */
  55656. export class BloomMergePostProcess extends PostProcess {
  55657. /** Weight of the bloom to be added to the original input. */
  55658. weight: number;
  55659. /**
  55660. * Creates a new instance of @see BloomMergePostProcess
  55661. * @param name The name of the effect.
  55662. * @param originalFromInput Post process which's input will be used for the merge.
  55663. * @param blurred Blurred highlights post process which's output will be used.
  55664. * @param weight Weight of the bloom to be added to the original input.
  55665. * @param options The required width/height ratio to downsize to before computing the render pass.
  55666. * @param camera The camera to apply the render pass to.
  55667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55668. * @param engine The engine which the post process will be applied. (default: current engine)
  55669. * @param reusable If the post process can be reused on the same frame. (default: false)
  55670. * @param textureType Type of textures used when performing the post process. (default: 0)
  55671. * @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)
  55672. */
  55673. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  55674. /** Weight of the bloom to be added to the original input. */
  55675. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55676. }
  55677. }
  55678. declare module BABYLON {
  55679. /**
  55680. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  55681. */
  55682. export class BloomEffect extends PostProcessRenderEffect {
  55683. private bloomScale;
  55684. /**
  55685. * @hidden Internal
  55686. */
  55687. _effects: Array<PostProcess>;
  55688. /**
  55689. * @hidden Internal
  55690. */
  55691. _downscale: ExtractHighlightsPostProcess;
  55692. private _blurX;
  55693. private _blurY;
  55694. private _merge;
  55695. /**
  55696. * The luminance threshold to find bright areas of the image to bloom.
  55697. */
  55698. threshold: number;
  55699. /**
  55700. * The strength of the bloom.
  55701. */
  55702. weight: number;
  55703. /**
  55704. * Specifies the size of the bloom blur kernel, relative to the final output size
  55705. */
  55706. kernel: number;
  55707. /**
  55708. * Creates a new instance of @see BloomEffect
  55709. * @param scene The scene the effect belongs to.
  55710. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  55711. * @param bloomKernel The size of the kernel to be used when applying the blur.
  55712. * @param bloomWeight The the strength of bloom.
  55713. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55714. * @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)
  55715. */
  55716. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  55717. /**
  55718. * Disposes each of the internal effects for a given camera.
  55719. * @param camera The camera to dispose the effect on.
  55720. */
  55721. disposeEffects(camera: Camera): void;
  55722. /**
  55723. * @hidden Internal
  55724. */
  55725. _updateEffects(): void;
  55726. /**
  55727. * Internal
  55728. * @returns if all the contained post processes are ready.
  55729. * @hidden
  55730. */
  55731. _isReady(): boolean;
  55732. }
  55733. }
  55734. declare module BABYLON {
  55735. /** @hidden */
  55736. export var chromaticAberrationPixelShader: {
  55737. name: string;
  55738. shader: string;
  55739. };
  55740. }
  55741. declare module BABYLON {
  55742. /**
  55743. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  55744. */
  55745. export class ChromaticAberrationPostProcess extends PostProcess {
  55746. /**
  55747. * The amount of seperation of rgb channels (default: 30)
  55748. */
  55749. aberrationAmount: number;
  55750. /**
  55751. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  55752. */
  55753. radialIntensity: number;
  55754. /**
  55755. * 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))
  55756. */
  55757. direction: Vector2;
  55758. /**
  55759. * 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))
  55760. */
  55761. centerPosition: Vector2;
  55762. /**
  55763. * Creates a new instance ChromaticAberrationPostProcess
  55764. * @param name The name of the effect.
  55765. * @param screenWidth The width of the screen to apply the effect on.
  55766. * @param screenHeight The height of the screen to apply the effect on.
  55767. * @param options The required width/height ratio to downsize to before computing the render pass.
  55768. * @param camera The camera to apply the render pass to.
  55769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55770. * @param engine The engine which the post process will be applied. (default: current engine)
  55771. * @param reusable If the post process can be reused on the same frame. (default: false)
  55772. * @param textureType Type of textures used when performing the post process. (default: 0)
  55773. * @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)
  55774. */
  55775. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55776. }
  55777. }
  55778. declare module BABYLON {
  55779. /** @hidden */
  55780. export var circleOfConfusionPixelShader: {
  55781. name: string;
  55782. shader: string;
  55783. };
  55784. }
  55785. declare module BABYLON {
  55786. /**
  55787. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55788. */
  55789. export class CircleOfConfusionPostProcess extends PostProcess {
  55790. /**
  55791. * 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.
  55792. */
  55793. lensSize: number;
  55794. /**
  55795. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55796. */
  55797. fStop: number;
  55798. /**
  55799. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55800. */
  55801. focusDistance: number;
  55802. /**
  55803. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55804. */
  55805. focalLength: number;
  55806. private _depthTexture;
  55807. /**
  55808. * Creates a new instance CircleOfConfusionPostProcess
  55809. * @param name The name of the effect.
  55810. * @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.
  55811. * @param options The required width/height ratio to downsize to before computing the render pass.
  55812. * @param camera The camera to apply the render pass to.
  55813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55814. * @param engine The engine which the post process will be applied. (default: current engine)
  55815. * @param reusable If the post process can be reused on the same frame. (default: false)
  55816. * @param textureType Type of textures used when performing the post process. (default: 0)
  55817. * @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)
  55818. */
  55819. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55820. /**
  55821. * 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.
  55822. */
  55823. depthTexture: RenderTargetTexture;
  55824. }
  55825. }
  55826. declare module BABYLON {
  55827. /** @hidden */
  55828. export var colorCorrectionPixelShader: {
  55829. name: string;
  55830. shader: string;
  55831. };
  55832. }
  55833. declare module BABYLON {
  55834. /**
  55835. *
  55836. * This post-process allows the modification of rendered colors by using
  55837. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55838. *
  55839. * The object needs to be provided an url to a texture containing the color
  55840. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55841. * Use an image editing software to tweak the LUT to match your needs.
  55842. *
  55843. * For an example of a color LUT, see here:
  55844. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55845. * For explanations on color grading, see here:
  55846. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55847. *
  55848. */
  55849. export class ColorCorrectionPostProcess extends PostProcess {
  55850. private _colorTableTexture;
  55851. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55852. }
  55853. }
  55854. declare module BABYLON {
  55855. /** @hidden */
  55856. export var convolutionPixelShader: {
  55857. name: string;
  55858. shader: string;
  55859. };
  55860. }
  55861. declare module BABYLON {
  55862. /**
  55863. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55864. * input texture to perform effects such as edge detection or sharpening
  55865. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55866. */
  55867. export class ConvolutionPostProcess extends PostProcess {
  55868. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55869. kernel: number[];
  55870. /**
  55871. * Creates a new instance ConvolutionPostProcess
  55872. * @param name The name of the effect.
  55873. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  55874. * @param options The required width/height ratio to downsize to before computing the render pass.
  55875. * @param camera The camera to apply the render pass to.
  55876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55877. * @param engine The engine which the post process will be applied. (default: current engine)
  55878. * @param reusable If the post process can be reused on the same frame. (default: false)
  55879. * @param textureType Type of textures used when performing the post process. (default: 0)
  55880. */
  55881. constructor(name: string,
  55882. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55883. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55884. /**
  55885. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55886. */
  55887. static EdgeDetect0Kernel: number[];
  55888. /**
  55889. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55890. */
  55891. static EdgeDetect1Kernel: number[];
  55892. /**
  55893. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55894. */
  55895. static EdgeDetect2Kernel: number[];
  55896. /**
  55897. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55898. */
  55899. static SharpenKernel: number[];
  55900. /**
  55901. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55902. */
  55903. static EmbossKernel: number[];
  55904. /**
  55905. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55906. */
  55907. static GaussianKernel: number[];
  55908. }
  55909. }
  55910. declare module BABYLON {
  55911. /**
  55912. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55913. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55914. * based on samples that have a large difference in distance than the center pixel.
  55915. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55916. */
  55917. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55918. direction: Vector2;
  55919. /**
  55920. * Creates a new instance CircleOfConfusionPostProcess
  55921. * @param name The name of the effect.
  55922. * @param scene The scene the effect belongs to.
  55923. * @param direction The direction the blur should be applied.
  55924. * @param kernel The size of the kernel used to blur.
  55925. * @param options The required width/height ratio to downsize to before computing the render pass.
  55926. * @param camera The camera to apply the render pass to.
  55927. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55928. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55930. * @param engine The engine which the post process will be applied. (default: current engine)
  55931. * @param reusable If the post process can be reused on the same frame. (default: false)
  55932. * @param textureType Type of textures used when performing the post process. (default: 0)
  55933. * @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)
  55934. */
  55935. 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);
  55936. }
  55937. }
  55938. declare module BABYLON {
  55939. /** @hidden */
  55940. export var depthOfFieldMergePixelShader: {
  55941. name: string;
  55942. shader: string;
  55943. };
  55944. }
  55945. declare module BABYLON {
  55946. /**
  55947. * Options to be set when merging outputs from the default pipeline.
  55948. */
  55949. export class DepthOfFieldMergePostProcessOptions {
  55950. /**
  55951. * The original image to merge on top of
  55952. */
  55953. originalFromInput: PostProcess;
  55954. /**
  55955. * Parameters to perform the merge of the depth of field effect
  55956. */
  55957. depthOfField?: {
  55958. circleOfConfusion: PostProcess;
  55959. blurSteps: Array<PostProcess>;
  55960. };
  55961. /**
  55962. * Parameters to perform the merge of bloom effect
  55963. */
  55964. bloom?: {
  55965. blurred: PostProcess;
  55966. weight: number;
  55967. };
  55968. }
  55969. /**
  55970. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55971. */
  55972. export class DepthOfFieldMergePostProcess extends PostProcess {
  55973. private blurSteps;
  55974. /**
  55975. * Creates a new instance of DepthOfFieldMergePostProcess
  55976. * @param name The name of the effect.
  55977. * @param originalFromInput Post process which's input will be used for the merge.
  55978. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55979. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55980. * @param options The required width/height ratio to downsize to before computing the render pass.
  55981. * @param camera The camera to apply the render pass to.
  55982. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55983. * @param engine The engine which the post process will be applied. (default: current engine)
  55984. * @param reusable If the post process can be reused on the same frame. (default: false)
  55985. * @param textureType Type of textures used when performing the post process. (default: 0)
  55986. * @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)
  55987. */
  55988. 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);
  55989. /**
  55990. * Updates the effect with the current post process compile time values and recompiles the shader.
  55991. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55992. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55993. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55994. * @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
  55995. * @param onCompiled Called when the shader has been compiled.
  55996. * @param onError Called if there is an error when compiling a shader.
  55997. */
  55998. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55999. }
  56000. }
  56001. declare module BABYLON {
  56002. /**
  56003. * Specifies the level of max blur that should be applied when using the depth of field effect
  56004. */
  56005. export enum DepthOfFieldEffectBlurLevel {
  56006. /**
  56007. * Subtle blur
  56008. */
  56009. Low = 0,
  56010. /**
  56011. * Medium blur
  56012. */
  56013. Medium = 1,
  56014. /**
  56015. * Large blur
  56016. */
  56017. High = 2
  56018. }
  56019. /**
  56020. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  56021. */
  56022. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  56023. private _circleOfConfusion;
  56024. /**
  56025. * @hidden Internal, blurs from high to low
  56026. */
  56027. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  56028. private _depthOfFieldBlurY;
  56029. private _dofMerge;
  56030. /**
  56031. * @hidden Internal post processes in depth of field effect
  56032. */
  56033. _effects: Array<PostProcess>;
  56034. /**
  56035. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  56036. */
  56037. focalLength: number;
  56038. /**
  56039. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  56040. */
  56041. fStop: number;
  56042. /**
  56043. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  56044. */
  56045. focusDistance: number;
  56046. /**
  56047. * 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.
  56048. */
  56049. lensSize: number;
  56050. /**
  56051. * Creates a new instance DepthOfFieldEffect
  56052. * @param scene The scene the effect belongs to.
  56053. * @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.
  56054. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56055. * @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)
  56056. */
  56057. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  56058. /**
  56059. * Get the current class name of the current effet
  56060. * @returns "DepthOfFieldEffect"
  56061. */
  56062. getClassName(): string;
  56063. /**
  56064. * 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.
  56065. */
  56066. depthTexture: RenderTargetTexture;
  56067. /**
  56068. * Disposes each of the internal effects for a given camera.
  56069. * @param camera The camera to dispose the effect on.
  56070. */
  56071. disposeEffects(camera: Camera): void;
  56072. /**
  56073. * @hidden Internal
  56074. */
  56075. _updateEffects(): void;
  56076. /**
  56077. * Internal
  56078. * @returns if all the contained post processes are ready.
  56079. * @hidden
  56080. */
  56081. _isReady(): boolean;
  56082. }
  56083. }
  56084. declare module BABYLON {
  56085. /** @hidden */
  56086. export var displayPassPixelShader: {
  56087. name: string;
  56088. shader: string;
  56089. };
  56090. }
  56091. declare module BABYLON {
  56092. /**
  56093. * DisplayPassPostProcess which produces an output the same as it's input
  56094. */
  56095. export class DisplayPassPostProcess extends PostProcess {
  56096. /**
  56097. * Creates the DisplayPassPostProcess
  56098. * @param name The name of the effect.
  56099. * @param options The required width/height ratio to downsize to before computing the render pass.
  56100. * @param camera The camera to apply the render pass to.
  56101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56102. * @param engine The engine which the post process will be applied. (default: current engine)
  56103. * @param reusable If the post process can be reused on the same frame. (default: false)
  56104. */
  56105. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56106. }
  56107. }
  56108. declare module BABYLON {
  56109. /** @hidden */
  56110. export var filterPixelShader: {
  56111. name: string;
  56112. shader: string;
  56113. };
  56114. }
  56115. declare module BABYLON {
  56116. /**
  56117. * Applies a kernel filter to the image
  56118. */
  56119. export class FilterPostProcess extends PostProcess {
  56120. /** The matrix to be applied to the image */
  56121. kernelMatrix: Matrix;
  56122. /**
  56123. *
  56124. * @param name The name of the effect.
  56125. * @param kernelMatrix The matrix to be applied to the image
  56126. * @param options The required width/height ratio to downsize to before computing the render pass.
  56127. * @param camera The camera to apply the render pass to.
  56128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56129. * @param engine The engine which the post process will be applied. (default: current engine)
  56130. * @param reusable If the post process can be reused on the same frame. (default: false)
  56131. */
  56132. constructor(name: string,
  56133. /** The matrix to be applied to the image */
  56134. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56135. }
  56136. }
  56137. declare module BABYLON {
  56138. /** @hidden */
  56139. export var fxaaPixelShader: {
  56140. name: string;
  56141. shader: string;
  56142. };
  56143. }
  56144. declare module BABYLON {
  56145. /** @hidden */
  56146. export var fxaaVertexShader: {
  56147. name: string;
  56148. shader: string;
  56149. };
  56150. }
  56151. declare module BABYLON {
  56152. /**
  56153. * Fxaa post process
  56154. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  56155. */
  56156. export class FxaaPostProcess extends PostProcess {
  56157. /** @hidden */
  56158. texelWidth: number;
  56159. /** @hidden */
  56160. texelHeight: number;
  56161. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56162. private _getDefines;
  56163. }
  56164. }
  56165. declare module BABYLON {
  56166. /** @hidden */
  56167. export var grainPixelShader: {
  56168. name: string;
  56169. shader: string;
  56170. };
  56171. }
  56172. declare module BABYLON {
  56173. /**
  56174. * The GrainPostProcess adds noise to the image at mid luminance levels
  56175. */
  56176. export class GrainPostProcess extends PostProcess {
  56177. /**
  56178. * The intensity of the grain added (default: 30)
  56179. */
  56180. intensity: number;
  56181. /**
  56182. * If the grain should be randomized on every frame
  56183. */
  56184. animated: boolean;
  56185. /**
  56186. * Creates a new instance of @see GrainPostProcess
  56187. * @param name The name of the effect.
  56188. * @param options The required width/height ratio to downsize to before computing the render pass.
  56189. * @param camera The camera to apply the render pass to.
  56190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56191. * @param engine The engine which the post process will be applied. (default: current engine)
  56192. * @param reusable If the post process can be reused on the same frame. (default: false)
  56193. * @param textureType Type of textures used when performing the post process. (default: 0)
  56194. * @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)
  56195. */
  56196. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56197. }
  56198. }
  56199. declare module BABYLON {
  56200. /** @hidden */
  56201. export var highlightsPixelShader: {
  56202. name: string;
  56203. shader: string;
  56204. };
  56205. }
  56206. declare module BABYLON {
  56207. /**
  56208. * Extracts highlights from the image
  56209. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56210. */
  56211. export class HighlightsPostProcess extends PostProcess {
  56212. /**
  56213. * Extracts highlights from the image
  56214. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56215. * @param name The name of the effect.
  56216. * @param options The required width/height ratio to downsize to before computing the render pass.
  56217. * @param camera The camera to apply the render pass to.
  56218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56219. * @param engine The engine which the post process will be applied. (default: current engine)
  56220. * @param reusable If the post process can be reused on the same frame. (default: false)
  56221. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  56222. */
  56223. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56224. }
  56225. }
  56226. declare module BABYLON {
  56227. /** @hidden */
  56228. export var mrtFragmentDeclaration: {
  56229. name: string;
  56230. shader: string;
  56231. };
  56232. }
  56233. declare module BABYLON {
  56234. /** @hidden */
  56235. export var geometryPixelShader: {
  56236. name: string;
  56237. shader: string;
  56238. };
  56239. }
  56240. declare module BABYLON {
  56241. /** @hidden */
  56242. export var geometryVertexShader: {
  56243. name: string;
  56244. shader: string;
  56245. };
  56246. }
  56247. declare module BABYLON {
  56248. /** @hidden */
  56249. interface ISavedTransformationMatrix {
  56250. world: Matrix;
  56251. viewProjection: Matrix;
  56252. }
  56253. /**
  56254. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  56255. */
  56256. export class GeometryBufferRenderer {
  56257. /**
  56258. * Constant used to retrieve the position texture index in the G-Buffer textures array
  56259. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  56260. */
  56261. static readonly POSITION_TEXTURE_TYPE: number;
  56262. /**
  56263. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  56264. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  56265. */
  56266. static readonly VELOCITY_TEXTURE_TYPE: number;
  56267. /**
  56268. * Dictionary used to store the previous transformation matrices of each rendered mesh
  56269. * in order to compute objects velocities when enableVelocity is set to "true"
  56270. * @hidden
  56271. */
  56272. _previousTransformationMatrices: {
  56273. [index: number]: ISavedTransformationMatrix;
  56274. };
  56275. /**
  56276. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  56277. * in order to compute objects velocities when enableVelocity is set to "true"
  56278. * @hidden
  56279. */
  56280. _previousBonesTransformationMatrices: {
  56281. [index: number]: Float32Array;
  56282. };
  56283. /**
  56284. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  56285. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  56286. */
  56287. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  56288. private _scene;
  56289. private _multiRenderTarget;
  56290. private _ratio;
  56291. private _enablePosition;
  56292. private _enableVelocity;
  56293. private _positionIndex;
  56294. private _velocityIndex;
  56295. protected _effect: Effect;
  56296. protected _cachedDefines: string;
  56297. /**
  56298. * Set the render list (meshes to be rendered) used in the G buffer.
  56299. */
  56300. renderList: Mesh[];
  56301. /**
  56302. * Gets wether or not G buffer are supported by the running hardware.
  56303. * This requires draw buffer supports
  56304. */
  56305. readonly isSupported: boolean;
  56306. /**
  56307. * Returns the index of the given texture type in the G-Buffer textures array
  56308. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  56309. * @returns the index of the given texture type in the G-Buffer textures array
  56310. */
  56311. getTextureIndex(textureType: number): number;
  56312. /**
  56313. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  56314. */
  56315. /**
  56316. * Sets whether or not objects positions are enabled for the G buffer.
  56317. */
  56318. enablePosition: boolean;
  56319. /**
  56320. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  56321. */
  56322. /**
  56323. * Sets wether or not objects velocities are enabled for the G buffer.
  56324. */
  56325. enableVelocity: boolean;
  56326. /**
  56327. * Gets the scene associated with the buffer.
  56328. */
  56329. readonly scene: Scene;
  56330. /**
  56331. * Gets the ratio used by the buffer during its creation.
  56332. * How big is the buffer related to the main canvas.
  56333. */
  56334. readonly ratio: number;
  56335. /** @hidden */
  56336. static _SceneComponentInitialization: (scene: Scene) => void;
  56337. /**
  56338. * Creates a new G Buffer for the scene
  56339. * @param scene The scene the buffer belongs to
  56340. * @param ratio How big is the buffer related to the main canvas.
  56341. */
  56342. constructor(scene: Scene, ratio?: number);
  56343. /**
  56344. * Checks wether everything is ready to render a submesh to the G buffer.
  56345. * @param subMesh the submesh to check readiness for
  56346. * @param useInstances is the mesh drawn using instance or not
  56347. * @returns true if ready otherwise false
  56348. */
  56349. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56350. /**
  56351. * Gets the current underlying G Buffer.
  56352. * @returns the buffer
  56353. */
  56354. getGBuffer(): MultiRenderTarget;
  56355. /**
  56356. * Gets the number of samples used to render the buffer (anti aliasing).
  56357. */
  56358. /**
  56359. * Sets the number of samples used to render the buffer (anti aliasing).
  56360. */
  56361. samples: number;
  56362. /**
  56363. * Disposes the renderer and frees up associated resources.
  56364. */
  56365. dispose(): void;
  56366. protected _createRenderTargets(): void;
  56367. private _copyBonesTransformationMatrices;
  56368. }
  56369. }
  56370. declare module BABYLON {
  56371. interface Scene {
  56372. /** @hidden (Backing field) */
  56373. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56374. /**
  56375. * Gets or Sets the current geometry buffer associated to the scene.
  56376. */
  56377. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56378. /**
  56379. * Enables a GeometryBufferRender and associates it with the scene
  56380. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  56381. * @returns the GeometryBufferRenderer
  56382. */
  56383. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  56384. /**
  56385. * Disables the GeometryBufferRender associated with the scene
  56386. */
  56387. disableGeometryBufferRenderer(): void;
  56388. }
  56389. /**
  56390. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  56391. * in several rendering techniques.
  56392. */
  56393. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  56394. /**
  56395. * The component name helpful to identify the component in the list of scene components.
  56396. */
  56397. readonly name: string;
  56398. /**
  56399. * The scene the component belongs to.
  56400. */
  56401. scene: Scene;
  56402. /**
  56403. * Creates a new instance of the component for the given scene
  56404. * @param scene Defines the scene to register the component in
  56405. */
  56406. constructor(scene: Scene);
  56407. /**
  56408. * Registers the component in a given scene
  56409. */
  56410. register(): void;
  56411. /**
  56412. * Rebuilds the elements related to this component in case of
  56413. * context lost for instance.
  56414. */
  56415. rebuild(): void;
  56416. /**
  56417. * Disposes the component and the associated ressources
  56418. */
  56419. dispose(): void;
  56420. private _gatherRenderTargets;
  56421. }
  56422. }
  56423. declare module BABYLON {
  56424. /** @hidden */
  56425. export var motionBlurPixelShader: {
  56426. name: string;
  56427. shader: string;
  56428. };
  56429. }
  56430. declare module BABYLON {
  56431. /**
  56432. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  56433. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  56434. * As an example, all you have to do is to create the post-process:
  56435. * var mb = new BABYLON.MotionBlurPostProcess(
  56436. * 'mb', // The name of the effect.
  56437. * scene, // The scene containing the objects to blur according to their velocity.
  56438. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  56439. * camera // The camera to apply the render pass to.
  56440. * );
  56441. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  56442. */
  56443. export class MotionBlurPostProcess extends PostProcess {
  56444. /**
  56445. * Defines how much the image is blurred by the movement. Default value is equal to 1
  56446. */
  56447. motionStrength: number;
  56448. /**
  56449. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  56450. */
  56451. /**
  56452. * Sets the number of iterations to be used for motion blur quality
  56453. */
  56454. motionBlurSamples: number;
  56455. private _motionBlurSamples;
  56456. private _geometryBufferRenderer;
  56457. /**
  56458. * Creates a new instance MotionBlurPostProcess
  56459. * @param name The name of the effect.
  56460. * @param scene The scene containing the objects to blur according to their velocity.
  56461. * @param options The required width/height ratio to downsize to before computing the render pass.
  56462. * @param camera The camera to apply the render pass to.
  56463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56464. * @param engine The engine which the post process will be applied. (default: current engine)
  56465. * @param reusable If the post process can be reused on the same frame. (default: false)
  56466. * @param textureType Type of textures used when performing the post process. (default: 0)
  56467. * @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)
  56468. */
  56469. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56470. /**
  56471. * Excludes the given skinned mesh from computing bones velocities.
  56472. * 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.
  56473. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  56474. */
  56475. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56476. /**
  56477. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  56478. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  56479. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  56480. */
  56481. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56482. /**
  56483. * Disposes the post process.
  56484. * @param camera The camera to dispose the post process on.
  56485. */
  56486. dispose(camera?: Camera): void;
  56487. }
  56488. }
  56489. declare module BABYLON {
  56490. /** @hidden */
  56491. export var refractionPixelShader: {
  56492. name: string;
  56493. shader: string;
  56494. };
  56495. }
  56496. declare module BABYLON {
  56497. /**
  56498. * Post process which applies a refractin texture
  56499. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56500. */
  56501. export class RefractionPostProcess extends PostProcess {
  56502. /** the base color of the refraction (used to taint the rendering) */
  56503. color: Color3;
  56504. /** simulated refraction depth */
  56505. depth: number;
  56506. /** the coefficient of the base color (0 to remove base color tainting) */
  56507. colorLevel: number;
  56508. private _refTexture;
  56509. private _ownRefractionTexture;
  56510. /**
  56511. * Gets or sets the refraction texture
  56512. * Please note that you are responsible for disposing the texture if you set it manually
  56513. */
  56514. refractionTexture: Texture;
  56515. /**
  56516. * Initializes the RefractionPostProcess
  56517. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56518. * @param name The name of the effect.
  56519. * @param refractionTextureUrl Url of the refraction texture to use
  56520. * @param color the base color of the refraction (used to taint the rendering)
  56521. * @param depth simulated refraction depth
  56522. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  56523. * @param camera The camera to apply the render pass to.
  56524. * @param options The required width/height ratio to downsize to before computing the render pass.
  56525. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56526. * @param engine The engine which the post process will be applied. (default: current engine)
  56527. * @param reusable If the post process can be reused on the same frame. (default: false)
  56528. */
  56529. constructor(name: string, refractionTextureUrl: string,
  56530. /** the base color of the refraction (used to taint the rendering) */
  56531. color: Color3,
  56532. /** simulated refraction depth */
  56533. depth: number,
  56534. /** the coefficient of the base color (0 to remove base color tainting) */
  56535. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56536. /**
  56537. * Disposes of the post process
  56538. * @param camera Camera to dispose post process on
  56539. */
  56540. dispose(camera: Camera): void;
  56541. }
  56542. }
  56543. declare module BABYLON {
  56544. /** @hidden */
  56545. export var sharpenPixelShader: {
  56546. name: string;
  56547. shader: string;
  56548. };
  56549. }
  56550. declare module BABYLON {
  56551. /**
  56552. * The SharpenPostProcess applies a sharpen kernel to every pixel
  56553. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56554. */
  56555. export class SharpenPostProcess extends PostProcess {
  56556. /**
  56557. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  56558. */
  56559. colorAmount: number;
  56560. /**
  56561. * How much sharpness should be applied (default: 0.3)
  56562. */
  56563. edgeAmount: number;
  56564. /**
  56565. * Creates a new instance ConvolutionPostProcess
  56566. * @param name The name of the effect.
  56567. * @param options The required width/height ratio to downsize to before computing the render pass.
  56568. * @param camera The camera to apply the render pass to.
  56569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56570. * @param engine The engine which the post process will be applied. (default: current engine)
  56571. * @param reusable If the post process can be reused on the same frame. (default: false)
  56572. * @param textureType Type of textures used when performing the post process. (default: 0)
  56573. * @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)
  56574. */
  56575. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56576. }
  56577. }
  56578. declare module BABYLON {
  56579. /**
  56580. * PostProcessRenderPipeline
  56581. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56582. */
  56583. export class PostProcessRenderPipeline {
  56584. private engine;
  56585. private _renderEffects;
  56586. private _renderEffectsForIsolatedPass;
  56587. /**
  56588. * List of inspectable custom properties (used by the Inspector)
  56589. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  56590. */
  56591. inspectableCustomProperties: IInspectable[];
  56592. /**
  56593. * @hidden
  56594. */
  56595. protected _cameras: Camera[];
  56596. /** @hidden */
  56597. _name: string;
  56598. /**
  56599. * Gets pipeline name
  56600. */
  56601. readonly name: string;
  56602. /**
  56603. * Initializes a PostProcessRenderPipeline
  56604. * @param engine engine to add the pipeline to
  56605. * @param name name of the pipeline
  56606. */
  56607. constructor(engine: Engine, name: string);
  56608. /**
  56609. * Gets the class name
  56610. * @returns "PostProcessRenderPipeline"
  56611. */
  56612. getClassName(): string;
  56613. /**
  56614. * If all the render effects in the pipeline are supported
  56615. */
  56616. readonly isSupported: boolean;
  56617. /**
  56618. * Adds an effect to the pipeline
  56619. * @param renderEffect the effect to add
  56620. */
  56621. addEffect(renderEffect: PostProcessRenderEffect): void;
  56622. /** @hidden */
  56623. _rebuild(): void;
  56624. /** @hidden */
  56625. _enableEffect(renderEffectName: string, cameras: Camera): void;
  56626. /** @hidden */
  56627. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  56628. /** @hidden */
  56629. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56630. /** @hidden */
  56631. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56632. /** @hidden */
  56633. _attachCameras(cameras: Camera, unique: boolean): void;
  56634. /** @hidden */
  56635. _attachCameras(cameras: Camera[], unique: boolean): void;
  56636. /** @hidden */
  56637. _detachCameras(cameras: Camera): void;
  56638. /** @hidden */
  56639. _detachCameras(cameras: Nullable<Camera[]>): void;
  56640. /** @hidden */
  56641. _update(): void;
  56642. /** @hidden */
  56643. _reset(): void;
  56644. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  56645. /**
  56646. * Disposes of the pipeline
  56647. */
  56648. dispose(): void;
  56649. }
  56650. }
  56651. declare module BABYLON {
  56652. /**
  56653. * PostProcessRenderPipelineManager class
  56654. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56655. */
  56656. export class PostProcessRenderPipelineManager {
  56657. private _renderPipelines;
  56658. /**
  56659. * Initializes a PostProcessRenderPipelineManager
  56660. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56661. */
  56662. constructor();
  56663. /**
  56664. * Gets the list of supported render pipelines
  56665. */
  56666. readonly supportedPipelines: PostProcessRenderPipeline[];
  56667. /**
  56668. * Adds a pipeline to the manager
  56669. * @param renderPipeline The pipeline to add
  56670. */
  56671. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  56672. /**
  56673. * Attaches a camera to the pipeline
  56674. * @param renderPipelineName The name of the pipeline to attach to
  56675. * @param cameras the camera to attach
  56676. * @param unique if the camera can be attached multiple times to the pipeline
  56677. */
  56678. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  56679. /**
  56680. * Detaches a camera from the pipeline
  56681. * @param renderPipelineName The name of the pipeline to detach from
  56682. * @param cameras the camera to detach
  56683. */
  56684. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  56685. /**
  56686. * Enables an effect by name on a pipeline
  56687. * @param renderPipelineName the name of the pipeline to enable the effect in
  56688. * @param renderEffectName the name of the effect to enable
  56689. * @param cameras the cameras that the effect should be enabled on
  56690. */
  56691. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56692. /**
  56693. * Disables an effect by name on a pipeline
  56694. * @param renderPipelineName the name of the pipeline to disable the effect in
  56695. * @param renderEffectName the name of the effect to disable
  56696. * @param cameras the cameras that the effect should be disabled on
  56697. */
  56698. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56699. /**
  56700. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  56701. */
  56702. update(): void;
  56703. /** @hidden */
  56704. _rebuild(): void;
  56705. /**
  56706. * Disposes of the manager and pipelines
  56707. */
  56708. dispose(): void;
  56709. }
  56710. }
  56711. declare module BABYLON {
  56712. interface Scene {
  56713. /** @hidden (Backing field) */
  56714. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56715. /**
  56716. * Gets the postprocess render pipeline manager
  56717. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56718. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56719. */
  56720. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56721. }
  56722. /**
  56723. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56724. */
  56725. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56726. /**
  56727. * The component name helpfull to identify the component in the list of scene components.
  56728. */
  56729. readonly name: string;
  56730. /**
  56731. * The scene the component belongs to.
  56732. */
  56733. scene: Scene;
  56734. /**
  56735. * Creates a new instance of the component for the given scene
  56736. * @param scene Defines the scene to register the component in
  56737. */
  56738. constructor(scene: Scene);
  56739. /**
  56740. * Registers the component in a given scene
  56741. */
  56742. register(): void;
  56743. /**
  56744. * Rebuilds the elements related to this component in case of
  56745. * context lost for instance.
  56746. */
  56747. rebuild(): void;
  56748. /**
  56749. * Disposes the component and the associated ressources
  56750. */
  56751. dispose(): void;
  56752. private _gatherRenderTargets;
  56753. }
  56754. }
  56755. declare module BABYLON {
  56756. /**
  56757. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56758. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56759. */
  56760. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56761. private _scene;
  56762. private _camerasToBeAttached;
  56763. /**
  56764. * ID of the sharpen post process,
  56765. */
  56766. private readonly SharpenPostProcessId;
  56767. /**
  56768. * @ignore
  56769. * ID of the image processing post process;
  56770. */
  56771. readonly ImageProcessingPostProcessId: string;
  56772. /**
  56773. * @ignore
  56774. * ID of the Fast Approximate Anti-Aliasing post process;
  56775. */
  56776. readonly FxaaPostProcessId: string;
  56777. /**
  56778. * ID of the chromatic aberration post process,
  56779. */
  56780. private readonly ChromaticAberrationPostProcessId;
  56781. /**
  56782. * ID of the grain post process
  56783. */
  56784. private readonly GrainPostProcessId;
  56785. /**
  56786. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56787. */
  56788. sharpen: SharpenPostProcess;
  56789. private _sharpenEffect;
  56790. private bloom;
  56791. /**
  56792. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56793. */
  56794. depthOfField: DepthOfFieldEffect;
  56795. /**
  56796. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56797. */
  56798. fxaa: FxaaPostProcess;
  56799. /**
  56800. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56801. */
  56802. imageProcessing: ImageProcessingPostProcess;
  56803. /**
  56804. * Chromatic aberration post process which will shift rgb colors in the image
  56805. */
  56806. chromaticAberration: ChromaticAberrationPostProcess;
  56807. private _chromaticAberrationEffect;
  56808. /**
  56809. * Grain post process which add noise to the image
  56810. */
  56811. grain: GrainPostProcess;
  56812. private _grainEffect;
  56813. /**
  56814. * Glow post process which adds a glow to emissive areas of the image
  56815. */
  56816. private _glowLayer;
  56817. /**
  56818. * Animations which can be used to tweak settings over a period of time
  56819. */
  56820. animations: Animation[];
  56821. private _imageProcessingConfigurationObserver;
  56822. private _sharpenEnabled;
  56823. private _bloomEnabled;
  56824. private _depthOfFieldEnabled;
  56825. private _depthOfFieldBlurLevel;
  56826. private _fxaaEnabled;
  56827. private _imageProcessingEnabled;
  56828. private _defaultPipelineTextureType;
  56829. private _bloomScale;
  56830. private _chromaticAberrationEnabled;
  56831. private _grainEnabled;
  56832. private _buildAllowed;
  56833. /**
  56834. * Gets active scene
  56835. */
  56836. readonly scene: Scene;
  56837. /**
  56838. * Enable or disable the sharpen process from the pipeline
  56839. */
  56840. sharpenEnabled: boolean;
  56841. private _resizeObserver;
  56842. private _hardwareScaleLevel;
  56843. private _bloomKernel;
  56844. /**
  56845. * Specifies the size of the bloom blur kernel, relative to the final output size
  56846. */
  56847. bloomKernel: number;
  56848. /**
  56849. * Specifies the weight of the bloom in the final rendering
  56850. */
  56851. private _bloomWeight;
  56852. /**
  56853. * Specifies the luma threshold for the area that will be blurred by the bloom
  56854. */
  56855. private _bloomThreshold;
  56856. private _hdr;
  56857. /**
  56858. * The strength of the bloom.
  56859. */
  56860. bloomWeight: number;
  56861. /**
  56862. * The strength of the bloom.
  56863. */
  56864. bloomThreshold: number;
  56865. /**
  56866. * The scale of the bloom, lower value will provide better performance.
  56867. */
  56868. bloomScale: number;
  56869. /**
  56870. * Enable or disable the bloom from the pipeline
  56871. */
  56872. bloomEnabled: boolean;
  56873. private _rebuildBloom;
  56874. /**
  56875. * If the depth of field is enabled.
  56876. */
  56877. depthOfFieldEnabled: boolean;
  56878. /**
  56879. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56880. */
  56881. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56882. /**
  56883. * If the anti aliasing is enabled.
  56884. */
  56885. fxaaEnabled: boolean;
  56886. private _samples;
  56887. /**
  56888. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56889. */
  56890. samples: number;
  56891. /**
  56892. * If image processing is enabled.
  56893. */
  56894. imageProcessingEnabled: boolean;
  56895. /**
  56896. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56897. */
  56898. glowLayerEnabled: boolean;
  56899. /**
  56900. * Gets the glow layer (or null if not defined)
  56901. */
  56902. readonly glowLayer: Nullable<GlowLayer>;
  56903. /**
  56904. * Enable or disable the chromaticAberration process from the pipeline
  56905. */
  56906. chromaticAberrationEnabled: boolean;
  56907. /**
  56908. * Enable or disable the grain process from the pipeline
  56909. */
  56910. grainEnabled: boolean;
  56911. /**
  56912. * @constructor
  56913. * @param name - The rendering pipeline name (default: "")
  56914. * @param hdr - If high dynamic range textures should be used (default: true)
  56915. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56916. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56917. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56918. */
  56919. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56920. /**
  56921. * Get the class name
  56922. * @returns "DefaultRenderingPipeline"
  56923. */
  56924. getClassName(): string;
  56925. /**
  56926. * Force the compilation of the entire pipeline.
  56927. */
  56928. prepare(): void;
  56929. private _hasCleared;
  56930. private _prevPostProcess;
  56931. private _prevPrevPostProcess;
  56932. private _setAutoClearAndTextureSharing;
  56933. private _depthOfFieldSceneObserver;
  56934. private _buildPipeline;
  56935. private _disposePostProcesses;
  56936. /**
  56937. * Adds a camera to the pipeline
  56938. * @param camera the camera to be added
  56939. */
  56940. addCamera(camera: Camera): void;
  56941. /**
  56942. * Removes a camera from the pipeline
  56943. * @param camera the camera to remove
  56944. */
  56945. removeCamera(camera: Camera): void;
  56946. /**
  56947. * Dispose of the pipeline and stop all post processes
  56948. */
  56949. dispose(): void;
  56950. /**
  56951. * Serialize the rendering pipeline (Used when exporting)
  56952. * @returns the serialized object
  56953. */
  56954. serialize(): any;
  56955. /**
  56956. * Parse the serialized pipeline
  56957. * @param source Source pipeline.
  56958. * @param scene The scene to load the pipeline to.
  56959. * @param rootUrl The URL of the serialized pipeline.
  56960. * @returns An instantiated pipeline from the serialized object.
  56961. */
  56962. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56963. }
  56964. }
  56965. declare module BABYLON {
  56966. /** @hidden */
  56967. export var lensHighlightsPixelShader: {
  56968. name: string;
  56969. shader: string;
  56970. };
  56971. }
  56972. declare module BABYLON {
  56973. /** @hidden */
  56974. export var depthOfFieldPixelShader: {
  56975. name: string;
  56976. shader: string;
  56977. };
  56978. }
  56979. declare module BABYLON {
  56980. /**
  56981. * BABYLON.JS Chromatic Aberration GLSL Shader
  56982. * Author: Olivier Guyot
  56983. * Separates very slightly R, G and B colors on the edges of the screen
  56984. * Inspired by Francois Tarlier & Martins Upitis
  56985. */
  56986. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56987. /**
  56988. * @ignore
  56989. * The chromatic aberration PostProcess id in the pipeline
  56990. */
  56991. LensChromaticAberrationEffect: string;
  56992. /**
  56993. * @ignore
  56994. * The highlights enhancing PostProcess id in the pipeline
  56995. */
  56996. HighlightsEnhancingEffect: string;
  56997. /**
  56998. * @ignore
  56999. * The depth-of-field PostProcess id in the pipeline
  57000. */
  57001. LensDepthOfFieldEffect: string;
  57002. private _scene;
  57003. private _depthTexture;
  57004. private _grainTexture;
  57005. private _chromaticAberrationPostProcess;
  57006. private _highlightsPostProcess;
  57007. private _depthOfFieldPostProcess;
  57008. private _edgeBlur;
  57009. private _grainAmount;
  57010. private _chromaticAberration;
  57011. private _distortion;
  57012. private _highlightsGain;
  57013. private _highlightsThreshold;
  57014. private _dofDistance;
  57015. private _dofAperture;
  57016. private _dofDarken;
  57017. private _dofPentagon;
  57018. private _blurNoise;
  57019. /**
  57020. * @constructor
  57021. *
  57022. * Effect parameters are as follow:
  57023. * {
  57024. * chromatic_aberration: number; // from 0 to x (1 for realism)
  57025. * edge_blur: number; // from 0 to x (1 for realism)
  57026. * distortion: number; // from 0 to x (1 for realism)
  57027. * grain_amount: number; // from 0 to 1
  57028. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  57029. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  57030. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  57031. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  57032. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  57033. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  57034. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  57035. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  57036. * }
  57037. * Note: if an effect parameter is unset, effect is disabled
  57038. *
  57039. * @param name The rendering pipeline name
  57040. * @param parameters - An object containing all parameters (see above)
  57041. * @param scene The scene linked to this pipeline
  57042. * @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)
  57043. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57044. */
  57045. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  57046. /**
  57047. * Get the class name
  57048. * @returns "LensRenderingPipeline"
  57049. */
  57050. getClassName(): string;
  57051. /**
  57052. * Gets associated scene
  57053. */
  57054. readonly scene: Scene;
  57055. /**
  57056. * Gets or sets the edge blur
  57057. */
  57058. edgeBlur: number;
  57059. /**
  57060. * Gets or sets the grain amount
  57061. */
  57062. grainAmount: number;
  57063. /**
  57064. * Gets or sets the chromatic aberration amount
  57065. */
  57066. chromaticAberration: number;
  57067. /**
  57068. * Gets or sets the depth of field aperture
  57069. */
  57070. dofAperture: number;
  57071. /**
  57072. * Gets or sets the edge distortion
  57073. */
  57074. edgeDistortion: number;
  57075. /**
  57076. * Gets or sets the depth of field distortion
  57077. */
  57078. dofDistortion: number;
  57079. /**
  57080. * Gets or sets the darken out of focus amount
  57081. */
  57082. darkenOutOfFocus: number;
  57083. /**
  57084. * Gets or sets a boolean indicating if blur noise is enabled
  57085. */
  57086. blurNoise: boolean;
  57087. /**
  57088. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  57089. */
  57090. pentagonBokeh: boolean;
  57091. /**
  57092. * Gets or sets the highlight grain amount
  57093. */
  57094. highlightsGain: number;
  57095. /**
  57096. * Gets or sets the highlight threshold
  57097. */
  57098. highlightsThreshold: number;
  57099. /**
  57100. * Sets the amount of blur at the edges
  57101. * @param amount blur amount
  57102. */
  57103. setEdgeBlur(amount: number): void;
  57104. /**
  57105. * Sets edge blur to 0
  57106. */
  57107. disableEdgeBlur(): void;
  57108. /**
  57109. * Sets the amout of grain
  57110. * @param amount Amount of grain
  57111. */
  57112. setGrainAmount(amount: number): void;
  57113. /**
  57114. * Set grain amount to 0
  57115. */
  57116. disableGrain(): void;
  57117. /**
  57118. * Sets the chromatic aberration amount
  57119. * @param amount amount of chromatic aberration
  57120. */
  57121. setChromaticAberration(amount: number): void;
  57122. /**
  57123. * Sets chromatic aberration amount to 0
  57124. */
  57125. disableChromaticAberration(): void;
  57126. /**
  57127. * Sets the EdgeDistortion amount
  57128. * @param amount amount of EdgeDistortion
  57129. */
  57130. setEdgeDistortion(amount: number): void;
  57131. /**
  57132. * Sets edge distortion to 0
  57133. */
  57134. disableEdgeDistortion(): void;
  57135. /**
  57136. * Sets the FocusDistance amount
  57137. * @param amount amount of FocusDistance
  57138. */
  57139. setFocusDistance(amount: number): void;
  57140. /**
  57141. * Disables depth of field
  57142. */
  57143. disableDepthOfField(): void;
  57144. /**
  57145. * Sets the Aperture amount
  57146. * @param amount amount of Aperture
  57147. */
  57148. setAperture(amount: number): void;
  57149. /**
  57150. * Sets the DarkenOutOfFocus amount
  57151. * @param amount amount of DarkenOutOfFocus
  57152. */
  57153. setDarkenOutOfFocus(amount: number): void;
  57154. private _pentagonBokehIsEnabled;
  57155. /**
  57156. * Creates a pentagon bokeh effect
  57157. */
  57158. enablePentagonBokeh(): void;
  57159. /**
  57160. * Disables the pentagon bokeh effect
  57161. */
  57162. disablePentagonBokeh(): void;
  57163. /**
  57164. * Enables noise blur
  57165. */
  57166. enableNoiseBlur(): void;
  57167. /**
  57168. * Disables noise blur
  57169. */
  57170. disableNoiseBlur(): void;
  57171. /**
  57172. * Sets the HighlightsGain amount
  57173. * @param amount amount of HighlightsGain
  57174. */
  57175. setHighlightsGain(amount: number): void;
  57176. /**
  57177. * Sets the HighlightsThreshold amount
  57178. * @param amount amount of HighlightsThreshold
  57179. */
  57180. setHighlightsThreshold(amount: number): void;
  57181. /**
  57182. * Disables highlights
  57183. */
  57184. disableHighlights(): void;
  57185. /**
  57186. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  57187. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  57188. */
  57189. dispose(disableDepthRender?: boolean): void;
  57190. private _createChromaticAberrationPostProcess;
  57191. private _createHighlightsPostProcess;
  57192. private _createDepthOfFieldPostProcess;
  57193. private _createGrainTexture;
  57194. }
  57195. }
  57196. declare module BABYLON {
  57197. /** @hidden */
  57198. export var ssao2PixelShader: {
  57199. name: string;
  57200. shader: string;
  57201. };
  57202. }
  57203. declare module BABYLON {
  57204. /** @hidden */
  57205. export var ssaoCombinePixelShader: {
  57206. name: string;
  57207. shader: string;
  57208. };
  57209. }
  57210. declare module BABYLON {
  57211. /**
  57212. * Render pipeline to produce ssao effect
  57213. */
  57214. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  57215. /**
  57216. * @ignore
  57217. * The PassPostProcess id in the pipeline that contains the original scene color
  57218. */
  57219. SSAOOriginalSceneColorEffect: string;
  57220. /**
  57221. * @ignore
  57222. * The SSAO PostProcess id in the pipeline
  57223. */
  57224. SSAORenderEffect: string;
  57225. /**
  57226. * @ignore
  57227. * The horizontal blur PostProcess id in the pipeline
  57228. */
  57229. SSAOBlurHRenderEffect: string;
  57230. /**
  57231. * @ignore
  57232. * The vertical blur PostProcess id in the pipeline
  57233. */
  57234. SSAOBlurVRenderEffect: string;
  57235. /**
  57236. * @ignore
  57237. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57238. */
  57239. SSAOCombineRenderEffect: string;
  57240. /**
  57241. * The output strength of the SSAO post-process. Default value is 1.0.
  57242. */
  57243. totalStrength: number;
  57244. /**
  57245. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  57246. */
  57247. maxZ: number;
  57248. /**
  57249. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  57250. */
  57251. minZAspect: number;
  57252. private _samples;
  57253. /**
  57254. * Number of samples used for the SSAO calculations. Default value is 8
  57255. */
  57256. samples: number;
  57257. private _textureSamples;
  57258. /**
  57259. * Number of samples to use for antialiasing
  57260. */
  57261. textureSamples: number;
  57262. /**
  57263. * Ratio object used for SSAO ratio and blur ratio
  57264. */
  57265. private _ratio;
  57266. /**
  57267. * Dynamically generated sphere sampler.
  57268. */
  57269. private _sampleSphere;
  57270. /**
  57271. * Blur filter offsets
  57272. */
  57273. private _samplerOffsets;
  57274. private _expensiveBlur;
  57275. /**
  57276. * If bilateral blur should be used
  57277. */
  57278. expensiveBlur: boolean;
  57279. /**
  57280. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  57281. */
  57282. radius: number;
  57283. /**
  57284. * The base color of the SSAO post-process
  57285. * The final result is "base + ssao" between [0, 1]
  57286. */
  57287. base: number;
  57288. /**
  57289. * Support test.
  57290. */
  57291. static readonly IsSupported: boolean;
  57292. private _scene;
  57293. private _depthTexture;
  57294. private _normalTexture;
  57295. private _randomTexture;
  57296. private _originalColorPostProcess;
  57297. private _ssaoPostProcess;
  57298. private _blurHPostProcess;
  57299. private _blurVPostProcess;
  57300. private _ssaoCombinePostProcess;
  57301. private _firstUpdate;
  57302. /**
  57303. * Gets active scene
  57304. */
  57305. readonly scene: Scene;
  57306. /**
  57307. * @constructor
  57308. * @param name The rendering pipeline name
  57309. * @param scene The scene linked to this pipeline
  57310. * @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 }
  57311. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57312. */
  57313. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57314. /**
  57315. * Get the class name
  57316. * @returns "SSAO2RenderingPipeline"
  57317. */
  57318. getClassName(): string;
  57319. /**
  57320. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57321. */
  57322. dispose(disableGeometryBufferRenderer?: boolean): void;
  57323. private _createBlurPostProcess;
  57324. /** @hidden */
  57325. _rebuild(): void;
  57326. private _bits;
  57327. private _radicalInverse_VdC;
  57328. private _hammersley;
  57329. private _hemisphereSample_uniform;
  57330. private _generateHemisphere;
  57331. private _createSSAOPostProcess;
  57332. private _createSSAOCombinePostProcess;
  57333. private _createRandomTexture;
  57334. /**
  57335. * Serialize the rendering pipeline (Used when exporting)
  57336. * @returns the serialized object
  57337. */
  57338. serialize(): any;
  57339. /**
  57340. * Parse the serialized pipeline
  57341. * @param source Source pipeline.
  57342. * @param scene The scene to load the pipeline to.
  57343. * @param rootUrl The URL of the serialized pipeline.
  57344. * @returns An instantiated pipeline from the serialized object.
  57345. */
  57346. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  57347. }
  57348. }
  57349. declare module BABYLON {
  57350. /** @hidden */
  57351. export var ssaoPixelShader: {
  57352. name: string;
  57353. shader: string;
  57354. };
  57355. }
  57356. declare module BABYLON {
  57357. /**
  57358. * Render pipeline to produce ssao effect
  57359. */
  57360. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  57361. /**
  57362. * @ignore
  57363. * The PassPostProcess id in the pipeline that contains the original scene color
  57364. */
  57365. SSAOOriginalSceneColorEffect: string;
  57366. /**
  57367. * @ignore
  57368. * The SSAO PostProcess id in the pipeline
  57369. */
  57370. SSAORenderEffect: string;
  57371. /**
  57372. * @ignore
  57373. * The horizontal blur PostProcess id in the pipeline
  57374. */
  57375. SSAOBlurHRenderEffect: string;
  57376. /**
  57377. * @ignore
  57378. * The vertical blur PostProcess id in the pipeline
  57379. */
  57380. SSAOBlurVRenderEffect: string;
  57381. /**
  57382. * @ignore
  57383. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57384. */
  57385. SSAOCombineRenderEffect: string;
  57386. /**
  57387. * The output strength of the SSAO post-process. Default value is 1.0.
  57388. */
  57389. totalStrength: number;
  57390. /**
  57391. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  57392. */
  57393. radius: number;
  57394. /**
  57395. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  57396. * Must not be equal to fallOff and superior to fallOff.
  57397. * Default value is 0.0075
  57398. */
  57399. area: number;
  57400. /**
  57401. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  57402. * Must not be equal to area and inferior to area.
  57403. * Default value is 0.000001
  57404. */
  57405. fallOff: number;
  57406. /**
  57407. * The base color of the SSAO post-process
  57408. * The final result is "base + ssao" between [0, 1]
  57409. */
  57410. base: number;
  57411. private _scene;
  57412. private _depthTexture;
  57413. private _randomTexture;
  57414. private _originalColorPostProcess;
  57415. private _ssaoPostProcess;
  57416. private _blurHPostProcess;
  57417. private _blurVPostProcess;
  57418. private _ssaoCombinePostProcess;
  57419. private _firstUpdate;
  57420. /**
  57421. * Gets active scene
  57422. */
  57423. readonly scene: Scene;
  57424. /**
  57425. * @constructor
  57426. * @param name - The rendering pipeline name
  57427. * @param scene - The scene linked to this pipeline
  57428. * @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 }
  57429. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  57430. */
  57431. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57432. /**
  57433. * Get the class name
  57434. * @returns "SSAORenderingPipeline"
  57435. */
  57436. getClassName(): string;
  57437. /**
  57438. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57439. */
  57440. dispose(disableDepthRender?: boolean): void;
  57441. private _createBlurPostProcess;
  57442. /** @hidden */
  57443. _rebuild(): void;
  57444. private _createSSAOPostProcess;
  57445. private _createSSAOCombinePostProcess;
  57446. private _createRandomTexture;
  57447. }
  57448. }
  57449. declare module BABYLON {
  57450. /** @hidden */
  57451. export var standardPixelShader: {
  57452. name: string;
  57453. shader: string;
  57454. };
  57455. }
  57456. declare module BABYLON {
  57457. /**
  57458. * Standard rendering pipeline
  57459. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57460. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  57461. */
  57462. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57463. /**
  57464. * Public members
  57465. */
  57466. /**
  57467. * Post-process which contains the original scene color before the pipeline applies all the effects
  57468. */
  57469. originalPostProcess: Nullable<PostProcess>;
  57470. /**
  57471. * Post-process used to down scale an image x4
  57472. */
  57473. downSampleX4PostProcess: Nullable<PostProcess>;
  57474. /**
  57475. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  57476. */
  57477. brightPassPostProcess: Nullable<PostProcess>;
  57478. /**
  57479. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  57480. */
  57481. blurHPostProcesses: PostProcess[];
  57482. /**
  57483. * Post-process array storing all the vertical blur post-processes used by the pipeline
  57484. */
  57485. blurVPostProcesses: PostProcess[];
  57486. /**
  57487. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  57488. */
  57489. textureAdderPostProcess: Nullable<PostProcess>;
  57490. /**
  57491. * Post-process used to create volumetric lighting effect
  57492. */
  57493. volumetricLightPostProcess: Nullable<PostProcess>;
  57494. /**
  57495. * Post-process used to smooth the previous volumetric light post-process on the X axis
  57496. */
  57497. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  57498. /**
  57499. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  57500. */
  57501. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  57502. /**
  57503. * Post-process used to merge the volumetric light effect and the real scene color
  57504. */
  57505. volumetricLightMergePostProces: Nullable<PostProcess>;
  57506. /**
  57507. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  57508. */
  57509. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  57510. /**
  57511. * Base post-process used to calculate the average luminance of the final image for HDR
  57512. */
  57513. luminancePostProcess: Nullable<PostProcess>;
  57514. /**
  57515. * Post-processes used to create down sample post-processes in order to get
  57516. * the average luminance of the final image for HDR
  57517. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  57518. */
  57519. luminanceDownSamplePostProcesses: PostProcess[];
  57520. /**
  57521. * Post-process used to create a HDR effect (light adaptation)
  57522. */
  57523. hdrPostProcess: Nullable<PostProcess>;
  57524. /**
  57525. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  57526. */
  57527. textureAdderFinalPostProcess: Nullable<PostProcess>;
  57528. /**
  57529. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  57530. */
  57531. lensFlareFinalPostProcess: Nullable<PostProcess>;
  57532. /**
  57533. * Post-process used to merge the final HDR post-process and the real scene color
  57534. */
  57535. hdrFinalPostProcess: Nullable<PostProcess>;
  57536. /**
  57537. * Post-process used to create a lens flare effect
  57538. */
  57539. lensFlarePostProcess: Nullable<PostProcess>;
  57540. /**
  57541. * Post-process that merges the result of the lens flare post-process and the real scene color
  57542. */
  57543. lensFlareComposePostProcess: Nullable<PostProcess>;
  57544. /**
  57545. * Post-process used to create a motion blur effect
  57546. */
  57547. motionBlurPostProcess: Nullable<PostProcess>;
  57548. /**
  57549. * Post-process used to create a depth of field effect
  57550. */
  57551. depthOfFieldPostProcess: Nullable<PostProcess>;
  57552. /**
  57553. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57554. */
  57555. fxaaPostProcess: Nullable<FxaaPostProcess>;
  57556. /**
  57557. * Represents the brightness threshold in order to configure the illuminated surfaces
  57558. */
  57559. brightThreshold: number;
  57560. /**
  57561. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  57562. */
  57563. blurWidth: number;
  57564. /**
  57565. * Sets if the blur for highlighted surfaces must be only horizontal
  57566. */
  57567. horizontalBlur: boolean;
  57568. /**
  57569. * Gets the overall exposure used by the pipeline
  57570. */
  57571. /**
  57572. * Sets the overall exposure used by the pipeline
  57573. */
  57574. exposure: number;
  57575. /**
  57576. * Texture used typically to simulate "dirty" on camera lens
  57577. */
  57578. lensTexture: Nullable<Texture>;
  57579. /**
  57580. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  57581. */
  57582. volumetricLightCoefficient: number;
  57583. /**
  57584. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  57585. */
  57586. volumetricLightPower: number;
  57587. /**
  57588. * Used the set the blur intensity to smooth the volumetric lights
  57589. */
  57590. volumetricLightBlurScale: number;
  57591. /**
  57592. * Light (spot or directional) used to generate the volumetric lights rays
  57593. * The source light must have a shadow generate so the pipeline can get its
  57594. * depth map
  57595. */
  57596. sourceLight: Nullable<SpotLight | DirectionalLight>;
  57597. /**
  57598. * For eye adaptation, represents the minimum luminance the eye can see
  57599. */
  57600. hdrMinimumLuminance: number;
  57601. /**
  57602. * For eye adaptation, represents the decrease luminance speed
  57603. */
  57604. hdrDecreaseRate: number;
  57605. /**
  57606. * For eye adaptation, represents the increase luminance speed
  57607. */
  57608. hdrIncreaseRate: number;
  57609. /**
  57610. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57611. */
  57612. /**
  57613. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57614. */
  57615. hdrAutoExposure: boolean;
  57616. /**
  57617. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  57618. */
  57619. lensColorTexture: Nullable<Texture>;
  57620. /**
  57621. * The overall strengh for the lens flare effect
  57622. */
  57623. lensFlareStrength: number;
  57624. /**
  57625. * Dispersion coefficient for lens flare ghosts
  57626. */
  57627. lensFlareGhostDispersal: number;
  57628. /**
  57629. * Main lens flare halo width
  57630. */
  57631. lensFlareHaloWidth: number;
  57632. /**
  57633. * Based on the lens distortion effect, defines how much the lens flare result
  57634. * is distorted
  57635. */
  57636. lensFlareDistortionStrength: number;
  57637. /**
  57638. * Lens star texture must be used to simulate rays on the flares and is available
  57639. * in the documentation
  57640. */
  57641. lensStarTexture: Nullable<Texture>;
  57642. /**
  57643. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  57644. * flare effect by taking account of the dirt texture
  57645. */
  57646. lensFlareDirtTexture: Nullable<Texture>;
  57647. /**
  57648. * Represents the focal length for the depth of field effect
  57649. */
  57650. depthOfFieldDistance: number;
  57651. /**
  57652. * Represents the blur intensity for the blurred part of the depth of field effect
  57653. */
  57654. depthOfFieldBlurWidth: number;
  57655. /**
  57656. * Gets how much the image is blurred by the movement while using the motion blur post-process
  57657. */
  57658. /**
  57659. * Sets how much the image is blurred by the movement while using the motion blur post-process
  57660. */
  57661. motionStrength: number;
  57662. /**
  57663. * Gets wether or not the motion blur post-process is object based or screen based.
  57664. */
  57665. /**
  57666. * Sets wether or not the motion blur post-process should be object based or screen based
  57667. */
  57668. objectBasedMotionBlur: boolean;
  57669. /**
  57670. * List of animations for the pipeline (IAnimatable implementation)
  57671. */
  57672. animations: Animation[];
  57673. /**
  57674. * Private members
  57675. */
  57676. private _scene;
  57677. private _currentDepthOfFieldSource;
  57678. private _basePostProcess;
  57679. private _fixedExposure;
  57680. private _currentExposure;
  57681. private _hdrAutoExposure;
  57682. private _hdrCurrentLuminance;
  57683. private _motionStrength;
  57684. private _isObjectBasedMotionBlur;
  57685. private _floatTextureType;
  57686. private _ratio;
  57687. private _bloomEnabled;
  57688. private _depthOfFieldEnabled;
  57689. private _vlsEnabled;
  57690. private _lensFlareEnabled;
  57691. private _hdrEnabled;
  57692. private _motionBlurEnabled;
  57693. private _fxaaEnabled;
  57694. private _motionBlurSamples;
  57695. private _volumetricLightStepsCount;
  57696. private _samples;
  57697. /**
  57698. * @ignore
  57699. * Specifies if the bloom pipeline is enabled
  57700. */
  57701. BloomEnabled: boolean;
  57702. /**
  57703. * @ignore
  57704. * Specifies if the depth of field pipeline is enabed
  57705. */
  57706. DepthOfFieldEnabled: boolean;
  57707. /**
  57708. * @ignore
  57709. * Specifies if the lens flare pipeline is enabed
  57710. */
  57711. LensFlareEnabled: boolean;
  57712. /**
  57713. * @ignore
  57714. * Specifies if the HDR pipeline is enabled
  57715. */
  57716. HDREnabled: boolean;
  57717. /**
  57718. * @ignore
  57719. * Specifies if the volumetric lights scattering effect is enabled
  57720. */
  57721. VLSEnabled: boolean;
  57722. /**
  57723. * @ignore
  57724. * Specifies if the motion blur effect is enabled
  57725. */
  57726. MotionBlurEnabled: boolean;
  57727. /**
  57728. * Specifies if anti-aliasing is enabled
  57729. */
  57730. fxaaEnabled: boolean;
  57731. /**
  57732. * Specifies the number of steps used to calculate the volumetric lights
  57733. * Typically in interval [50, 200]
  57734. */
  57735. volumetricLightStepsCount: number;
  57736. /**
  57737. * Specifies the number of samples used for the motion blur effect
  57738. * Typically in interval [16, 64]
  57739. */
  57740. motionBlurSamples: number;
  57741. /**
  57742. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57743. */
  57744. samples: number;
  57745. /**
  57746. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57747. * @constructor
  57748. * @param name The rendering pipeline name
  57749. * @param scene The scene linked to this pipeline
  57750. * @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)
  57751. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57752. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57753. */
  57754. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57755. private _buildPipeline;
  57756. private _createDownSampleX4PostProcess;
  57757. private _createBrightPassPostProcess;
  57758. private _createBlurPostProcesses;
  57759. private _createTextureAdderPostProcess;
  57760. private _createVolumetricLightPostProcess;
  57761. private _createLuminancePostProcesses;
  57762. private _createHdrPostProcess;
  57763. private _createLensFlarePostProcess;
  57764. private _createDepthOfFieldPostProcess;
  57765. private _createMotionBlurPostProcess;
  57766. private _getDepthTexture;
  57767. private _disposePostProcesses;
  57768. /**
  57769. * Dispose of the pipeline and stop all post processes
  57770. */
  57771. dispose(): void;
  57772. /**
  57773. * Serialize the rendering pipeline (Used when exporting)
  57774. * @returns the serialized object
  57775. */
  57776. serialize(): any;
  57777. /**
  57778. * Parse the serialized pipeline
  57779. * @param source Source pipeline.
  57780. * @param scene The scene to load the pipeline to.
  57781. * @param rootUrl The URL of the serialized pipeline.
  57782. * @returns An instantiated pipeline from the serialized object.
  57783. */
  57784. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57785. /**
  57786. * Luminance steps
  57787. */
  57788. static LuminanceSteps: number;
  57789. }
  57790. }
  57791. declare module BABYLON {
  57792. /** @hidden */
  57793. export var tonemapPixelShader: {
  57794. name: string;
  57795. shader: string;
  57796. };
  57797. }
  57798. declare module BABYLON {
  57799. /** Defines operator used for tonemapping */
  57800. export enum TonemappingOperator {
  57801. /** Hable */
  57802. Hable = 0,
  57803. /** Reinhard */
  57804. Reinhard = 1,
  57805. /** HejiDawson */
  57806. HejiDawson = 2,
  57807. /** Photographic */
  57808. Photographic = 3
  57809. }
  57810. /**
  57811. * Defines a post process to apply tone mapping
  57812. */
  57813. export class TonemapPostProcess extends PostProcess {
  57814. private _operator;
  57815. /** Defines the required exposure adjustement */
  57816. exposureAdjustment: number;
  57817. /**
  57818. * Creates a new TonemapPostProcess
  57819. * @param name defines the name of the postprocess
  57820. * @param _operator defines the operator to use
  57821. * @param exposureAdjustment defines the required exposure adjustement
  57822. * @param camera defines the camera to use (can be null)
  57823. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57824. * @param engine defines the hosting engine (can be ignore if camera is set)
  57825. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57826. */
  57827. constructor(name: string, _operator: TonemappingOperator,
  57828. /** Defines the required exposure adjustement */
  57829. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57830. }
  57831. }
  57832. declare module BABYLON {
  57833. /** @hidden */
  57834. export var depthVertexShader: {
  57835. name: string;
  57836. shader: string;
  57837. };
  57838. }
  57839. declare module BABYLON {
  57840. /** @hidden */
  57841. export var volumetricLightScatteringPixelShader: {
  57842. name: string;
  57843. shader: string;
  57844. };
  57845. }
  57846. declare module BABYLON {
  57847. /** @hidden */
  57848. export var volumetricLightScatteringPassPixelShader: {
  57849. name: string;
  57850. shader: string;
  57851. };
  57852. }
  57853. declare module BABYLON {
  57854. /**
  57855. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57856. */
  57857. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57858. private _volumetricLightScatteringPass;
  57859. private _volumetricLightScatteringRTT;
  57860. private _viewPort;
  57861. private _screenCoordinates;
  57862. private _cachedDefines;
  57863. /**
  57864. * If not undefined, the mesh position is computed from the attached node position
  57865. */
  57866. attachedNode: {
  57867. position: Vector3;
  57868. };
  57869. /**
  57870. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57871. */
  57872. customMeshPosition: Vector3;
  57873. /**
  57874. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57875. */
  57876. useCustomMeshPosition: boolean;
  57877. /**
  57878. * If the post-process should inverse the light scattering direction
  57879. */
  57880. invert: boolean;
  57881. /**
  57882. * The internal mesh used by the post-process
  57883. */
  57884. mesh: Mesh;
  57885. /**
  57886. * @hidden
  57887. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57888. */
  57889. useDiffuseColor: boolean;
  57890. /**
  57891. * Array containing the excluded meshes not rendered in the internal pass
  57892. */
  57893. excludedMeshes: AbstractMesh[];
  57894. /**
  57895. * Controls the overall intensity of the post-process
  57896. */
  57897. exposure: number;
  57898. /**
  57899. * Dissipates each sample's contribution in range [0, 1]
  57900. */
  57901. decay: number;
  57902. /**
  57903. * Controls the overall intensity of each sample
  57904. */
  57905. weight: number;
  57906. /**
  57907. * Controls the density of each sample
  57908. */
  57909. density: number;
  57910. /**
  57911. * @constructor
  57912. * @param name The post-process name
  57913. * @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)
  57914. * @param camera The camera that the post-process will be attached to
  57915. * @param mesh The mesh used to create the light scattering
  57916. * @param samples The post-process quality, default 100
  57917. * @param samplingModeThe post-process filtering mode
  57918. * @param engine The babylon engine
  57919. * @param reusable If the post-process is reusable
  57920. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57921. */
  57922. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57923. /**
  57924. * Returns the string "VolumetricLightScatteringPostProcess"
  57925. * @returns "VolumetricLightScatteringPostProcess"
  57926. */
  57927. getClassName(): string;
  57928. private _isReady;
  57929. /**
  57930. * Sets the new light position for light scattering effect
  57931. * @param position The new custom light position
  57932. */
  57933. setCustomMeshPosition(position: Vector3): void;
  57934. /**
  57935. * Returns the light position for light scattering effect
  57936. * @return Vector3 The custom light position
  57937. */
  57938. getCustomMeshPosition(): Vector3;
  57939. /**
  57940. * Disposes the internal assets and detaches the post-process from the camera
  57941. */
  57942. dispose(camera: Camera): void;
  57943. /**
  57944. * Returns the render target texture used by the post-process
  57945. * @return the render target texture used by the post-process
  57946. */
  57947. getPass(): RenderTargetTexture;
  57948. private _meshExcluded;
  57949. private _createPass;
  57950. private _updateMeshScreenCoordinates;
  57951. /**
  57952. * Creates a default mesh for the Volumeric Light Scattering post-process
  57953. * @param name The mesh name
  57954. * @param scene The scene where to create the mesh
  57955. * @return the default mesh
  57956. */
  57957. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57958. }
  57959. }
  57960. declare module BABYLON {
  57961. interface Scene {
  57962. /** @hidden (Backing field) */
  57963. _boundingBoxRenderer: BoundingBoxRenderer;
  57964. /** @hidden (Backing field) */
  57965. _forceShowBoundingBoxes: boolean;
  57966. /**
  57967. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57968. */
  57969. forceShowBoundingBoxes: boolean;
  57970. /**
  57971. * Gets the bounding box renderer associated with the scene
  57972. * @returns a BoundingBoxRenderer
  57973. */
  57974. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57975. }
  57976. interface AbstractMesh {
  57977. /** @hidden (Backing field) */
  57978. _showBoundingBox: boolean;
  57979. /**
  57980. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57981. */
  57982. showBoundingBox: boolean;
  57983. }
  57984. /**
  57985. * Component responsible of rendering the bounding box of the meshes in a scene.
  57986. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57987. */
  57988. export class BoundingBoxRenderer implements ISceneComponent {
  57989. /**
  57990. * The component name helpfull to identify the component in the list of scene components.
  57991. */
  57992. readonly name: string;
  57993. /**
  57994. * The scene the component belongs to.
  57995. */
  57996. scene: Scene;
  57997. /**
  57998. * Color of the bounding box lines placed in front of an object
  57999. */
  58000. frontColor: Color3;
  58001. /**
  58002. * Color of the bounding box lines placed behind an object
  58003. */
  58004. backColor: Color3;
  58005. /**
  58006. * Defines if the renderer should show the back lines or not
  58007. */
  58008. showBackLines: boolean;
  58009. /**
  58010. * @hidden
  58011. */
  58012. renderList: SmartArray<BoundingBox>;
  58013. private _colorShader;
  58014. private _vertexBuffers;
  58015. private _indexBuffer;
  58016. private _fillIndexBuffer;
  58017. private _fillIndexData;
  58018. /**
  58019. * Instantiates a new bounding box renderer in a scene.
  58020. * @param scene the scene the renderer renders in
  58021. */
  58022. constructor(scene: Scene);
  58023. /**
  58024. * Registers the component in a given scene
  58025. */
  58026. register(): void;
  58027. private _evaluateSubMesh;
  58028. private _activeMesh;
  58029. private _prepareRessources;
  58030. private _createIndexBuffer;
  58031. /**
  58032. * Rebuilds the elements related to this component in case of
  58033. * context lost for instance.
  58034. */
  58035. rebuild(): void;
  58036. /**
  58037. * @hidden
  58038. */
  58039. reset(): void;
  58040. /**
  58041. * Render the bounding boxes of a specific rendering group
  58042. * @param renderingGroupId defines the rendering group to render
  58043. */
  58044. render(renderingGroupId: number): void;
  58045. /**
  58046. * In case of occlusion queries, we can render the occlusion bounding box through this method
  58047. * @param mesh Define the mesh to render the occlusion bounding box for
  58048. */
  58049. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  58050. /**
  58051. * Dispose and release the resources attached to this renderer.
  58052. */
  58053. dispose(): void;
  58054. }
  58055. }
  58056. declare module BABYLON {
  58057. /** @hidden */
  58058. export var depthPixelShader: {
  58059. name: string;
  58060. shader: string;
  58061. };
  58062. }
  58063. declare module BABYLON {
  58064. /**
  58065. * This represents a depth renderer in Babylon.
  58066. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58067. */
  58068. export class DepthRenderer {
  58069. private _scene;
  58070. private _depthMap;
  58071. private _effect;
  58072. private readonly _storeNonLinearDepth;
  58073. private readonly _clearColor;
  58074. /** Get if the depth renderer is using packed depth or not */
  58075. readonly isPacked: boolean;
  58076. private _cachedDefines;
  58077. private _camera;
  58078. /**
  58079. * Specifiess that the depth renderer will only be used within
  58080. * the camera it is created for.
  58081. * This can help forcing its rendering during the camera processing.
  58082. */
  58083. useOnlyInActiveCamera: boolean;
  58084. /** @hidden */
  58085. static _SceneComponentInitialization: (scene: Scene) => void;
  58086. /**
  58087. * Instantiates a depth renderer
  58088. * @param scene The scene the renderer belongs to
  58089. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58090. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58091. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58092. */
  58093. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58094. /**
  58095. * Creates the depth rendering effect and checks if the effect is ready.
  58096. * @param subMesh The submesh to be used to render the depth map of
  58097. * @param useInstances If multiple world instances should be used
  58098. * @returns if the depth renderer is ready to render the depth map
  58099. */
  58100. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58101. /**
  58102. * Gets the texture which the depth map will be written to.
  58103. * @returns The depth map texture
  58104. */
  58105. getDepthMap(): RenderTargetTexture;
  58106. /**
  58107. * Disposes of the depth renderer.
  58108. */
  58109. dispose(): void;
  58110. }
  58111. }
  58112. declare module BABYLON {
  58113. interface Scene {
  58114. /** @hidden (Backing field) */
  58115. _depthRenderer: {
  58116. [id: string]: DepthRenderer;
  58117. };
  58118. /**
  58119. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  58120. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  58121. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58122. * @returns the created depth renderer
  58123. */
  58124. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  58125. /**
  58126. * Disables a depth renderer for a given camera
  58127. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  58128. */
  58129. disableDepthRenderer(camera?: Nullable<Camera>): void;
  58130. }
  58131. /**
  58132. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  58133. * in several rendering techniques.
  58134. */
  58135. export class DepthRendererSceneComponent implements ISceneComponent {
  58136. /**
  58137. * The component name helpfull to identify the component in the list of scene components.
  58138. */
  58139. readonly name: string;
  58140. /**
  58141. * The scene the component belongs to.
  58142. */
  58143. scene: Scene;
  58144. /**
  58145. * Creates a new instance of the component for the given scene
  58146. * @param scene Defines the scene to register the component in
  58147. */
  58148. constructor(scene: Scene);
  58149. /**
  58150. * Registers the component in a given scene
  58151. */
  58152. register(): void;
  58153. /**
  58154. * Rebuilds the elements related to this component in case of
  58155. * context lost for instance.
  58156. */
  58157. rebuild(): void;
  58158. /**
  58159. * Disposes the component and the associated ressources
  58160. */
  58161. dispose(): void;
  58162. private _gatherRenderTargets;
  58163. private _gatherActiveCameraRenderTargets;
  58164. }
  58165. }
  58166. declare module BABYLON {
  58167. /** @hidden */
  58168. export var outlinePixelShader: {
  58169. name: string;
  58170. shader: string;
  58171. };
  58172. }
  58173. declare module BABYLON {
  58174. /** @hidden */
  58175. export var outlineVertexShader: {
  58176. name: string;
  58177. shader: string;
  58178. };
  58179. }
  58180. declare module BABYLON {
  58181. interface Scene {
  58182. /** @hidden */
  58183. _outlineRenderer: OutlineRenderer;
  58184. /**
  58185. * Gets the outline renderer associated with the scene
  58186. * @returns a OutlineRenderer
  58187. */
  58188. getOutlineRenderer(): OutlineRenderer;
  58189. }
  58190. interface AbstractMesh {
  58191. /** @hidden (Backing field) */
  58192. _renderOutline: boolean;
  58193. /**
  58194. * Gets or sets a boolean indicating if the outline must be rendered as well
  58195. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  58196. */
  58197. renderOutline: boolean;
  58198. /** @hidden (Backing field) */
  58199. _renderOverlay: boolean;
  58200. /**
  58201. * Gets or sets a boolean indicating if the overlay must be rendered as well
  58202. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  58203. */
  58204. renderOverlay: boolean;
  58205. }
  58206. /**
  58207. * This class is responsible to draw bothe outline/overlay of meshes.
  58208. * It should not be used directly but through the available method on mesh.
  58209. */
  58210. export class OutlineRenderer implements ISceneComponent {
  58211. /**
  58212. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  58213. */
  58214. private static _StencilReference;
  58215. /**
  58216. * The name of the component. Each component must have a unique name.
  58217. */
  58218. name: string;
  58219. /**
  58220. * The scene the component belongs to.
  58221. */
  58222. scene: Scene;
  58223. /**
  58224. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  58225. */
  58226. zOffset: number;
  58227. private _engine;
  58228. private _effect;
  58229. private _cachedDefines;
  58230. private _savedDepthWrite;
  58231. /**
  58232. * Instantiates a new outline renderer. (There could be only one per scene).
  58233. * @param scene Defines the scene it belongs to
  58234. */
  58235. constructor(scene: Scene);
  58236. /**
  58237. * Register the component to one instance of a scene.
  58238. */
  58239. register(): void;
  58240. /**
  58241. * Rebuilds the elements related to this component in case of
  58242. * context lost for instance.
  58243. */
  58244. rebuild(): void;
  58245. /**
  58246. * Disposes the component and the associated ressources.
  58247. */
  58248. dispose(): void;
  58249. /**
  58250. * Renders the outline in the canvas.
  58251. * @param subMesh Defines the sumesh to render
  58252. * @param batch Defines the batch of meshes in case of instances
  58253. * @param useOverlay Defines if the rendering is for the overlay or the outline
  58254. */
  58255. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  58256. /**
  58257. * Returns whether or not the outline renderer is ready for a given submesh.
  58258. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  58259. * @param subMesh Defines the submesh to check readyness for
  58260. * @param useInstances Defines wheter wee are trying to render instances or not
  58261. * @returns true if ready otherwise false
  58262. */
  58263. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58264. private _beforeRenderingMesh;
  58265. private _afterRenderingMesh;
  58266. }
  58267. }
  58268. declare module BABYLON {
  58269. /**
  58270. * Defines the list of states available for a task inside a AssetsManager
  58271. */
  58272. export enum AssetTaskState {
  58273. /**
  58274. * Initialization
  58275. */
  58276. INIT = 0,
  58277. /**
  58278. * Running
  58279. */
  58280. RUNNING = 1,
  58281. /**
  58282. * Done
  58283. */
  58284. DONE = 2,
  58285. /**
  58286. * Error
  58287. */
  58288. ERROR = 3
  58289. }
  58290. /**
  58291. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  58292. */
  58293. export abstract class AbstractAssetTask {
  58294. /**
  58295. * Task name
  58296. */ name: string;
  58297. /**
  58298. * Callback called when the task is successful
  58299. */
  58300. onSuccess: (task: any) => void;
  58301. /**
  58302. * Callback called when the task is not successful
  58303. */
  58304. onError: (task: any, message?: string, exception?: any) => void;
  58305. /**
  58306. * Creates a new AssetsManager
  58307. * @param name defines the name of the task
  58308. */
  58309. constructor(
  58310. /**
  58311. * Task name
  58312. */ name: string);
  58313. private _isCompleted;
  58314. private _taskState;
  58315. private _errorObject;
  58316. /**
  58317. * Get if the task is completed
  58318. */
  58319. readonly isCompleted: boolean;
  58320. /**
  58321. * Gets the current state of the task
  58322. */
  58323. readonly taskState: AssetTaskState;
  58324. /**
  58325. * Gets the current error object (if task is in error)
  58326. */
  58327. readonly errorObject: {
  58328. message?: string;
  58329. exception?: any;
  58330. };
  58331. /**
  58332. * Internal only
  58333. * @hidden
  58334. */
  58335. _setErrorObject(message?: string, exception?: any): void;
  58336. /**
  58337. * Execute the current task
  58338. * @param scene defines the scene where you want your assets to be loaded
  58339. * @param onSuccess is a callback called when the task is successfully executed
  58340. * @param onError is a callback called if an error occurs
  58341. */
  58342. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58343. /**
  58344. * Execute the current task
  58345. * @param scene defines the scene where you want your assets to be loaded
  58346. * @param onSuccess is a callback called when the task is successfully executed
  58347. * @param onError is a callback called if an error occurs
  58348. */
  58349. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58350. /**
  58351. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  58352. * This can be used with failed tasks that have the reason for failure fixed.
  58353. */
  58354. reset(): void;
  58355. private onErrorCallback;
  58356. private onDoneCallback;
  58357. }
  58358. /**
  58359. * Define the interface used by progress events raised during assets loading
  58360. */
  58361. export interface IAssetsProgressEvent {
  58362. /**
  58363. * Defines the number of remaining tasks to process
  58364. */
  58365. remainingCount: number;
  58366. /**
  58367. * Defines the total number of tasks
  58368. */
  58369. totalCount: number;
  58370. /**
  58371. * Defines the task that was just processed
  58372. */
  58373. task: AbstractAssetTask;
  58374. }
  58375. /**
  58376. * Class used to share progress information about assets loading
  58377. */
  58378. export class AssetsProgressEvent implements IAssetsProgressEvent {
  58379. /**
  58380. * Defines the number of remaining tasks to process
  58381. */
  58382. remainingCount: number;
  58383. /**
  58384. * Defines the total number of tasks
  58385. */
  58386. totalCount: number;
  58387. /**
  58388. * Defines the task that was just processed
  58389. */
  58390. task: AbstractAssetTask;
  58391. /**
  58392. * Creates a AssetsProgressEvent
  58393. * @param remainingCount defines the number of remaining tasks to process
  58394. * @param totalCount defines the total number of tasks
  58395. * @param task defines the task that was just processed
  58396. */
  58397. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  58398. }
  58399. /**
  58400. * Define a task used by AssetsManager to load meshes
  58401. */
  58402. export class MeshAssetTask extends AbstractAssetTask {
  58403. /**
  58404. * Defines the name of the task
  58405. */
  58406. name: string;
  58407. /**
  58408. * Defines the list of mesh's names you want to load
  58409. */
  58410. meshesNames: any;
  58411. /**
  58412. * Defines the root url to use as a base to load your meshes and associated resources
  58413. */
  58414. rootUrl: string;
  58415. /**
  58416. * Defines the filename of the scene to load from
  58417. */
  58418. sceneFilename: string;
  58419. /**
  58420. * Gets the list of loaded meshes
  58421. */
  58422. loadedMeshes: Array<AbstractMesh>;
  58423. /**
  58424. * Gets the list of loaded particle systems
  58425. */
  58426. loadedParticleSystems: Array<IParticleSystem>;
  58427. /**
  58428. * Gets the list of loaded skeletons
  58429. */
  58430. loadedSkeletons: Array<Skeleton>;
  58431. /**
  58432. * Gets the list of loaded animation groups
  58433. */
  58434. loadedAnimationGroups: Array<AnimationGroup>;
  58435. /**
  58436. * Callback called when the task is successful
  58437. */
  58438. onSuccess: (task: MeshAssetTask) => void;
  58439. /**
  58440. * Callback called when the task is successful
  58441. */
  58442. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  58443. /**
  58444. * Creates a new MeshAssetTask
  58445. * @param name defines the name of the task
  58446. * @param meshesNames defines the list of mesh's names you want to load
  58447. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  58448. * @param sceneFilename defines the filename of the scene to load from
  58449. */
  58450. constructor(
  58451. /**
  58452. * Defines the name of the task
  58453. */
  58454. name: string,
  58455. /**
  58456. * Defines the list of mesh's names you want to load
  58457. */
  58458. meshesNames: any,
  58459. /**
  58460. * Defines the root url to use as a base to load your meshes and associated resources
  58461. */
  58462. rootUrl: string,
  58463. /**
  58464. * Defines the filename of the scene to load from
  58465. */
  58466. sceneFilename: string);
  58467. /**
  58468. * Execute the current task
  58469. * @param scene defines the scene where you want your assets to be loaded
  58470. * @param onSuccess is a callback called when the task is successfully executed
  58471. * @param onError is a callback called if an error occurs
  58472. */
  58473. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58474. }
  58475. /**
  58476. * Define a task used by AssetsManager to load text content
  58477. */
  58478. export class TextFileAssetTask extends AbstractAssetTask {
  58479. /**
  58480. * Defines the name of the task
  58481. */
  58482. name: string;
  58483. /**
  58484. * Defines the location of the file to load
  58485. */
  58486. url: string;
  58487. /**
  58488. * Gets the loaded text string
  58489. */
  58490. text: string;
  58491. /**
  58492. * Callback called when the task is successful
  58493. */
  58494. onSuccess: (task: TextFileAssetTask) => void;
  58495. /**
  58496. * Callback called when the task is successful
  58497. */
  58498. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  58499. /**
  58500. * Creates a new TextFileAssetTask object
  58501. * @param name defines the name of the task
  58502. * @param url defines the location of the file to load
  58503. */
  58504. constructor(
  58505. /**
  58506. * Defines the name of the task
  58507. */
  58508. name: string,
  58509. /**
  58510. * Defines the location of the file to load
  58511. */
  58512. url: string);
  58513. /**
  58514. * Execute the current task
  58515. * @param scene defines the scene where you want your assets to be loaded
  58516. * @param onSuccess is a callback called when the task is successfully executed
  58517. * @param onError is a callback called if an error occurs
  58518. */
  58519. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58520. }
  58521. /**
  58522. * Define a task used by AssetsManager to load binary data
  58523. */
  58524. export class BinaryFileAssetTask extends AbstractAssetTask {
  58525. /**
  58526. * Defines the name of the task
  58527. */
  58528. name: string;
  58529. /**
  58530. * Defines the location of the file to load
  58531. */
  58532. url: string;
  58533. /**
  58534. * Gets the lodaded data (as an array buffer)
  58535. */
  58536. data: ArrayBuffer;
  58537. /**
  58538. * Callback called when the task is successful
  58539. */
  58540. onSuccess: (task: BinaryFileAssetTask) => void;
  58541. /**
  58542. * Callback called when the task is successful
  58543. */
  58544. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58545. /**
  58546. * Creates a new BinaryFileAssetTask object
  58547. * @param name defines the name of the new task
  58548. * @param url defines the location of the file to load
  58549. */
  58550. constructor(
  58551. /**
  58552. * Defines the name of the task
  58553. */
  58554. name: string,
  58555. /**
  58556. * Defines the location of the file to load
  58557. */
  58558. url: string);
  58559. /**
  58560. * Execute the current task
  58561. * @param scene defines the scene where you want your assets to be loaded
  58562. * @param onSuccess is a callback called when the task is successfully executed
  58563. * @param onError is a callback called if an error occurs
  58564. */
  58565. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58566. }
  58567. /**
  58568. * Define a task used by AssetsManager to load images
  58569. */
  58570. export class ImageAssetTask extends AbstractAssetTask {
  58571. /**
  58572. * Defines the name of the task
  58573. */
  58574. name: string;
  58575. /**
  58576. * Defines the location of the image to load
  58577. */
  58578. url: string;
  58579. /**
  58580. * Gets the loaded images
  58581. */
  58582. image: HTMLImageElement;
  58583. /**
  58584. * Callback called when the task is successful
  58585. */
  58586. onSuccess: (task: ImageAssetTask) => void;
  58587. /**
  58588. * Callback called when the task is successful
  58589. */
  58590. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58591. /**
  58592. * Creates a new ImageAssetTask
  58593. * @param name defines the name of the task
  58594. * @param url defines the location of the image to load
  58595. */
  58596. constructor(
  58597. /**
  58598. * Defines the name of the task
  58599. */
  58600. name: string,
  58601. /**
  58602. * Defines the location of the image to load
  58603. */
  58604. url: string);
  58605. /**
  58606. * Execute the current task
  58607. * @param scene defines the scene where you want your assets to be loaded
  58608. * @param onSuccess is a callback called when the task is successfully executed
  58609. * @param onError is a callback called if an error occurs
  58610. */
  58611. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58612. }
  58613. /**
  58614. * Defines the interface used by texture loading tasks
  58615. */
  58616. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58617. /**
  58618. * Gets the loaded texture
  58619. */
  58620. texture: TEX;
  58621. }
  58622. /**
  58623. * Define a task used by AssetsManager to load 2D textures
  58624. */
  58625. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58626. /**
  58627. * Defines the name of the task
  58628. */
  58629. name: string;
  58630. /**
  58631. * Defines the location of the file to load
  58632. */
  58633. url: string;
  58634. /**
  58635. * Defines if mipmap should not be generated (default is false)
  58636. */
  58637. noMipmap?: boolean | undefined;
  58638. /**
  58639. * Defines if texture must be inverted on Y axis (default is false)
  58640. */
  58641. invertY?: boolean | undefined;
  58642. /**
  58643. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58644. */
  58645. samplingMode: number;
  58646. /**
  58647. * Gets the loaded texture
  58648. */
  58649. texture: Texture;
  58650. /**
  58651. * Callback called when the task is successful
  58652. */
  58653. onSuccess: (task: TextureAssetTask) => void;
  58654. /**
  58655. * Callback called when the task is successful
  58656. */
  58657. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58658. /**
  58659. * Creates a new TextureAssetTask object
  58660. * @param name defines the name of the task
  58661. * @param url defines the location of the file to load
  58662. * @param noMipmap defines if mipmap should not be generated (default is false)
  58663. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58664. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58665. */
  58666. constructor(
  58667. /**
  58668. * Defines the name of the task
  58669. */
  58670. name: string,
  58671. /**
  58672. * Defines the location of the file to load
  58673. */
  58674. url: string,
  58675. /**
  58676. * Defines if mipmap should not be generated (default is false)
  58677. */
  58678. noMipmap?: boolean | undefined,
  58679. /**
  58680. * Defines if texture must be inverted on Y axis (default is false)
  58681. */
  58682. invertY?: boolean | undefined,
  58683. /**
  58684. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58685. */
  58686. samplingMode?: number);
  58687. /**
  58688. * Execute the current task
  58689. * @param scene defines the scene where you want your assets to be loaded
  58690. * @param onSuccess is a callback called when the task is successfully executed
  58691. * @param onError is a callback called if an error occurs
  58692. */
  58693. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58694. }
  58695. /**
  58696. * Define a task used by AssetsManager to load cube textures
  58697. */
  58698. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58699. /**
  58700. * Defines the name of the task
  58701. */
  58702. name: string;
  58703. /**
  58704. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58705. */
  58706. url: string;
  58707. /**
  58708. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58709. */
  58710. extensions?: string[] | undefined;
  58711. /**
  58712. * Defines if mipmaps should not be generated (default is false)
  58713. */
  58714. noMipmap?: boolean | undefined;
  58715. /**
  58716. * Defines the explicit list of files (undefined by default)
  58717. */
  58718. files?: string[] | undefined;
  58719. /**
  58720. * Gets the loaded texture
  58721. */
  58722. texture: CubeTexture;
  58723. /**
  58724. * Callback called when the task is successful
  58725. */
  58726. onSuccess: (task: CubeTextureAssetTask) => void;
  58727. /**
  58728. * Callback called when the task is successful
  58729. */
  58730. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58731. /**
  58732. * Creates a new CubeTextureAssetTask
  58733. * @param name defines the name of the task
  58734. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58735. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58736. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58737. * @param files defines the explicit list of files (undefined by default)
  58738. */
  58739. constructor(
  58740. /**
  58741. * Defines the name of the task
  58742. */
  58743. name: string,
  58744. /**
  58745. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58746. */
  58747. url: string,
  58748. /**
  58749. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58750. */
  58751. extensions?: string[] | undefined,
  58752. /**
  58753. * Defines if mipmaps should not be generated (default is false)
  58754. */
  58755. noMipmap?: boolean | undefined,
  58756. /**
  58757. * Defines the explicit list of files (undefined by default)
  58758. */
  58759. files?: string[] | undefined);
  58760. /**
  58761. * Execute the current task
  58762. * @param scene defines the scene where you want your assets to be loaded
  58763. * @param onSuccess is a callback called when the task is successfully executed
  58764. * @param onError is a callback called if an error occurs
  58765. */
  58766. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58767. }
  58768. /**
  58769. * Define a task used by AssetsManager to load HDR cube textures
  58770. */
  58771. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58772. /**
  58773. * Defines the name of the task
  58774. */
  58775. name: string;
  58776. /**
  58777. * Defines the location of the file to load
  58778. */
  58779. url: string;
  58780. /**
  58781. * Defines the desired size (the more it increases the longer the generation will be)
  58782. */
  58783. size: number;
  58784. /**
  58785. * Defines if mipmaps should not be generated (default is false)
  58786. */
  58787. noMipmap: boolean;
  58788. /**
  58789. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58790. */
  58791. generateHarmonics: boolean;
  58792. /**
  58793. * 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)
  58794. */
  58795. gammaSpace: boolean;
  58796. /**
  58797. * Internal Use Only
  58798. */
  58799. reserved: boolean;
  58800. /**
  58801. * Gets the loaded texture
  58802. */
  58803. texture: HDRCubeTexture;
  58804. /**
  58805. * Callback called when the task is successful
  58806. */
  58807. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58808. /**
  58809. * Callback called when the task is successful
  58810. */
  58811. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58812. /**
  58813. * Creates a new HDRCubeTextureAssetTask object
  58814. * @param name defines the name of the task
  58815. * @param url defines the location of the file to load
  58816. * @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.
  58817. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58818. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58819. * @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)
  58820. * @param reserved Internal use only
  58821. */
  58822. constructor(
  58823. /**
  58824. * Defines the name of the task
  58825. */
  58826. name: string,
  58827. /**
  58828. * Defines the location of the file to load
  58829. */
  58830. url: string,
  58831. /**
  58832. * Defines the desired size (the more it increases the longer the generation will be)
  58833. */
  58834. size: number,
  58835. /**
  58836. * Defines if mipmaps should not be generated (default is false)
  58837. */
  58838. noMipmap?: boolean,
  58839. /**
  58840. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58841. */
  58842. generateHarmonics?: boolean,
  58843. /**
  58844. * 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)
  58845. */
  58846. gammaSpace?: boolean,
  58847. /**
  58848. * Internal Use Only
  58849. */
  58850. reserved?: boolean);
  58851. /**
  58852. * Execute the current task
  58853. * @param scene defines the scene where you want your assets to be loaded
  58854. * @param onSuccess is a callback called when the task is successfully executed
  58855. * @param onError is a callback called if an error occurs
  58856. */
  58857. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58858. }
  58859. /**
  58860. * Define a task used by AssetsManager to load Equirectangular cube textures
  58861. */
  58862. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58863. /**
  58864. * Defines the name of the task
  58865. */
  58866. name: string;
  58867. /**
  58868. * Defines the location of the file to load
  58869. */
  58870. url: string;
  58871. /**
  58872. * Defines the desired size (the more it increases the longer the generation will be)
  58873. */
  58874. size: number;
  58875. /**
  58876. * Defines if mipmaps should not be generated (default is false)
  58877. */
  58878. noMipmap: boolean;
  58879. /**
  58880. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58881. * but the standard material would require them in Gamma space) (default is true)
  58882. */
  58883. gammaSpace: boolean;
  58884. /**
  58885. * Gets the loaded texture
  58886. */
  58887. texture: EquiRectangularCubeTexture;
  58888. /**
  58889. * Callback called when the task is successful
  58890. */
  58891. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58892. /**
  58893. * Callback called when the task is successful
  58894. */
  58895. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58896. /**
  58897. * Creates a new EquiRectangularCubeTextureAssetTask object
  58898. * @param name defines the name of the task
  58899. * @param url defines the location of the file to load
  58900. * @param size defines the desired size (the more it increases the longer the generation will be)
  58901. * If the size is omitted this implies you are using a preprocessed cubemap.
  58902. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58903. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58904. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58905. * (default is true)
  58906. */
  58907. constructor(
  58908. /**
  58909. * Defines the name of the task
  58910. */
  58911. name: string,
  58912. /**
  58913. * Defines the location of the file to load
  58914. */
  58915. url: string,
  58916. /**
  58917. * Defines the desired size (the more it increases the longer the generation will be)
  58918. */
  58919. size: number,
  58920. /**
  58921. * Defines if mipmaps should not be generated (default is false)
  58922. */
  58923. noMipmap?: boolean,
  58924. /**
  58925. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58926. * but the standard material would require them in Gamma space) (default is true)
  58927. */
  58928. gammaSpace?: boolean);
  58929. /**
  58930. * Execute the current task
  58931. * @param scene defines the scene where you want your assets to be loaded
  58932. * @param onSuccess is a callback called when the task is successfully executed
  58933. * @param onError is a callback called if an error occurs
  58934. */
  58935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58936. }
  58937. /**
  58938. * This class can be used to easily import assets into a scene
  58939. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58940. */
  58941. export class AssetsManager {
  58942. private _scene;
  58943. private _isLoading;
  58944. protected _tasks: AbstractAssetTask[];
  58945. protected _waitingTasksCount: number;
  58946. protected _totalTasksCount: number;
  58947. /**
  58948. * Callback called when all tasks are processed
  58949. */
  58950. onFinish: (tasks: AbstractAssetTask[]) => void;
  58951. /**
  58952. * Callback called when a task is successful
  58953. */
  58954. onTaskSuccess: (task: AbstractAssetTask) => void;
  58955. /**
  58956. * Callback called when a task had an error
  58957. */
  58958. onTaskError: (task: AbstractAssetTask) => void;
  58959. /**
  58960. * Callback called when a task is done (whatever the result is)
  58961. */
  58962. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58963. /**
  58964. * Observable called when all tasks are processed
  58965. */
  58966. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58967. /**
  58968. * Observable called when a task had an error
  58969. */
  58970. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58971. /**
  58972. * Observable called when all tasks were executed
  58973. */
  58974. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58975. /**
  58976. * Observable called when a task is done (whatever the result is)
  58977. */
  58978. onProgressObservable: Observable<IAssetsProgressEvent>;
  58979. /**
  58980. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58981. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58982. */
  58983. useDefaultLoadingScreen: boolean;
  58984. /**
  58985. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  58986. * when all assets have been downloaded.
  58987. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  58988. */
  58989. autoHideLoadingUI: boolean;
  58990. /**
  58991. * Creates a new AssetsManager
  58992. * @param scene defines the scene to work on
  58993. */
  58994. constructor(scene: Scene);
  58995. /**
  58996. * Add a MeshAssetTask to the list of active tasks
  58997. * @param taskName defines the name of the new task
  58998. * @param meshesNames defines the name of meshes to load
  58999. * @param rootUrl defines the root url to use to locate files
  59000. * @param sceneFilename defines the filename of the scene file
  59001. * @returns a new MeshAssetTask object
  59002. */
  59003. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  59004. /**
  59005. * Add a TextFileAssetTask to the list of active tasks
  59006. * @param taskName defines the name of the new task
  59007. * @param url defines the url of the file to load
  59008. * @returns a new TextFileAssetTask object
  59009. */
  59010. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  59011. /**
  59012. * Add a BinaryFileAssetTask to the list of active tasks
  59013. * @param taskName defines the name of the new task
  59014. * @param url defines the url of the file to load
  59015. * @returns a new BinaryFileAssetTask object
  59016. */
  59017. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  59018. /**
  59019. * Add a ImageAssetTask to the list of active tasks
  59020. * @param taskName defines the name of the new task
  59021. * @param url defines the url of the file to load
  59022. * @returns a new ImageAssetTask object
  59023. */
  59024. addImageTask(taskName: string, url: string): ImageAssetTask;
  59025. /**
  59026. * Add a TextureAssetTask to the list of active tasks
  59027. * @param taskName defines the name of the new task
  59028. * @param url defines the url of the file to load
  59029. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59030. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  59031. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59032. * @returns a new TextureAssetTask object
  59033. */
  59034. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  59035. /**
  59036. * Add a CubeTextureAssetTask to the list of active tasks
  59037. * @param taskName defines the name of the new task
  59038. * @param url defines the url of the file to load
  59039. * @param extensions defines the extension to use to load the cube map (can be null)
  59040. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59041. * @param files defines the list of files to load (can be null)
  59042. * @returns a new CubeTextureAssetTask object
  59043. */
  59044. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  59045. /**
  59046. *
  59047. * Add a HDRCubeTextureAssetTask to the list of active tasks
  59048. * @param taskName defines the name of the new task
  59049. * @param url defines the url of the file to load
  59050. * @param size defines the size you want for the cubemap (can be null)
  59051. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59052. * @param generateHarmonics defines if you want to automatically generate (true by default)
  59053. * @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)
  59054. * @param reserved Internal use only
  59055. * @returns a new HDRCubeTextureAssetTask object
  59056. */
  59057. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  59058. /**
  59059. *
  59060. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  59061. * @param taskName defines the name of the new task
  59062. * @param url defines the url of the file to load
  59063. * @param size defines the size you want for the cubemap (can be null)
  59064. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59065. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59066. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59067. * @returns a new EquiRectangularCubeTextureAssetTask object
  59068. */
  59069. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  59070. /**
  59071. * Remove a task from the assets manager.
  59072. * @param task the task to remove
  59073. */
  59074. removeTask(task: AbstractAssetTask): void;
  59075. private _decreaseWaitingTasksCount;
  59076. private _runTask;
  59077. /**
  59078. * Reset the AssetsManager and remove all tasks
  59079. * @return the current instance of the AssetsManager
  59080. */
  59081. reset(): AssetsManager;
  59082. /**
  59083. * Start the loading process
  59084. * @return the current instance of the AssetsManager
  59085. */
  59086. load(): AssetsManager;
  59087. /**
  59088. * Start the loading process as an async operation
  59089. * @return a promise returning the list of failed tasks
  59090. */
  59091. loadAsync(): Promise<void>;
  59092. }
  59093. }
  59094. declare module BABYLON {
  59095. /**
  59096. * Wrapper class for promise with external resolve and reject.
  59097. */
  59098. export class Deferred<T> {
  59099. /**
  59100. * The promise associated with this deferred object.
  59101. */
  59102. readonly promise: Promise<T>;
  59103. private _resolve;
  59104. private _reject;
  59105. /**
  59106. * The resolve method of the promise associated with this deferred object.
  59107. */
  59108. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  59109. /**
  59110. * The reject method of the promise associated with this deferred object.
  59111. */
  59112. readonly reject: (reason?: any) => void;
  59113. /**
  59114. * Constructor for this deferred object.
  59115. */
  59116. constructor();
  59117. }
  59118. }
  59119. declare module BABYLON {
  59120. /**
  59121. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  59122. */
  59123. export class MeshExploder {
  59124. private _centerMesh;
  59125. private _meshes;
  59126. private _meshesOrigins;
  59127. private _toCenterVectors;
  59128. private _scaledDirection;
  59129. private _newPosition;
  59130. private _centerPosition;
  59131. /**
  59132. * Explodes meshes from a center mesh.
  59133. * @param meshes The meshes to explode.
  59134. * @param centerMesh The mesh to be center of explosion.
  59135. */
  59136. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  59137. private _setCenterMesh;
  59138. /**
  59139. * Get class name
  59140. * @returns "MeshExploder"
  59141. */
  59142. getClassName(): string;
  59143. /**
  59144. * "Exploded meshes"
  59145. * @returns Array of meshes with the centerMesh at index 0.
  59146. */
  59147. getMeshes(): Array<Mesh>;
  59148. /**
  59149. * Explodes meshes giving a specific direction
  59150. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  59151. */
  59152. explode(direction?: number): void;
  59153. }
  59154. }
  59155. declare module BABYLON {
  59156. /**
  59157. * Class used to help managing file picking and drag'n'drop
  59158. */
  59159. export class FilesInput {
  59160. /**
  59161. * List of files ready to be loaded
  59162. */
  59163. static readonly FilesToLoad: {
  59164. [key: string]: File;
  59165. };
  59166. /**
  59167. * Callback called when a file is processed
  59168. */
  59169. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  59170. private _engine;
  59171. private _currentScene;
  59172. private _sceneLoadedCallback;
  59173. private _progressCallback;
  59174. private _additionalRenderLoopLogicCallback;
  59175. private _textureLoadingCallback;
  59176. private _startingProcessingFilesCallback;
  59177. private _onReloadCallback;
  59178. private _errorCallback;
  59179. private _elementToMonitor;
  59180. private _sceneFileToLoad;
  59181. private _filesToLoad;
  59182. /**
  59183. * Creates a new FilesInput
  59184. * @param engine defines the rendering engine
  59185. * @param scene defines the hosting scene
  59186. * @param sceneLoadedCallback callback called when scene is loaded
  59187. * @param progressCallback callback called to track progress
  59188. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  59189. * @param textureLoadingCallback callback called when a texture is loading
  59190. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  59191. * @param onReloadCallback callback called when a reload is requested
  59192. * @param errorCallback callback call if an error occurs
  59193. */
  59194. 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);
  59195. private _dragEnterHandler;
  59196. private _dragOverHandler;
  59197. private _dropHandler;
  59198. /**
  59199. * Calls this function to listen to drag'n'drop events on a specific DOM element
  59200. * @param elementToMonitor defines the DOM element to track
  59201. */
  59202. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  59203. /**
  59204. * Release all associated resources
  59205. */
  59206. dispose(): void;
  59207. private renderFunction;
  59208. private drag;
  59209. private drop;
  59210. private _traverseFolder;
  59211. private _processFiles;
  59212. /**
  59213. * Load files from a drop event
  59214. * @param event defines the drop event to use as source
  59215. */
  59216. loadFiles(event: any): void;
  59217. private _processReload;
  59218. /**
  59219. * Reload the current scene from the loaded files
  59220. */
  59221. reload(): void;
  59222. }
  59223. }
  59224. declare module BABYLON {
  59225. /**
  59226. * Defines the root class used to create scene optimization to use with SceneOptimizer
  59227. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59228. */
  59229. export class SceneOptimization {
  59230. /**
  59231. * Defines the priority of this optimization (0 by default which means first in the list)
  59232. */
  59233. priority: number;
  59234. /**
  59235. * Gets a string describing the action executed by the current optimization
  59236. * @returns description string
  59237. */
  59238. getDescription(): string;
  59239. /**
  59240. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59241. * @param scene defines the current scene where to apply this optimization
  59242. * @param optimizer defines the current optimizer
  59243. * @returns true if everything that can be done was applied
  59244. */
  59245. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59246. /**
  59247. * Creates the SceneOptimization object
  59248. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59249. * @param desc defines the description associated with the optimization
  59250. */
  59251. constructor(
  59252. /**
  59253. * Defines the priority of this optimization (0 by default which means first in the list)
  59254. */
  59255. priority?: number);
  59256. }
  59257. /**
  59258. * Defines an optimization used to reduce the size of render target textures
  59259. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59260. */
  59261. export class TextureOptimization extends SceneOptimization {
  59262. /**
  59263. * Defines the priority of this optimization (0 by default which means first in the list)
  59264. */
  59265. priority: number;
  59266. /**
  59267. * 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
  59268. */
  59269. maximumSize: number;
  59270. /**
  59271. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59272. */
  59273. step: number;
  59274. /**
  59275. * Gets a string describing the action executed by the current optimization
  59276. * @returns description string
  59277. */
  59278. getDescription(): string;
  59279. /**
  59280. * Creates the TextureOptimization object
  59281. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59282. * @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
  59283. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59284. */
  59285. constructor(
  59286. /**
  59287. * Defines the priority of this optimization (0 by default which means first in the list)
  59288. */
  59289. priority?: number,
  59290. /**
  59291. * 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
  59292. */
  59293. maximumSize?: number,
  59294. /**
  59295. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59296. */
  59297. step?: number);
  59298. /**
  59299. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59300. * @param scene defines the current scene where to apply this optimization
  59301. * @param optimizer defines the current optimizer
  59302. * @returns true if everything that can be done was applied
  59303. */
  59304. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59305. }
  59306. /**
  59307. * Defines an optimization used to increase or decrease the rendering resolution
  59308. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59309. */
  59310. export class HardwareScalingOptimization extends SceneOptimization {
  59311. /**
  59312. * Defines the priority of this optimization (0 by default which means first in the list)
  59313. */
  59314. priority: number;
  59315. /**
  59316. * Defines the maximum scale to use (2 by default)
  59317. */
  59318. maximumScale: number;
  59319. /**
  59320. * Defines the step to use between two passes (0.5 by default)
  59321. */
  59322. step: number;
  59323. private _currentScale;
  59324. private _directionOffset;
  59325. /**
  59326. * Gets a string describing the action executed by the current optimization
  59327. * @return description string
  59328. */
  59329. getDescription(): string;
  59330. /**
  59331. * Creates the HardwareScalingOptimization object
  59332. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59333. * @param maximumScale defines the maximum scale to use (2 by default)
  59334. * @param step defines the step to use between two passes (0.5 by default)
  59335. */
  59336. constructor(
  59337. /**
  59338. * Defines the priority of this optimization (0 by default which means first in the list)
  59339. */
  59340. priority?: number,
  59341. /**
  59342. * Defines the maximum scale to use (2 by default)
  59343. */
  59344. maximumScale?: number,
  59345. /**
  59346. * Defines the step to use between two passes (0.5 by default)
  59347. */
  59348. step?: number);
  59349. /**
  59350. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59351. * @param scene defines the current scene where to apply this optimization
  59352. * @param optimizer defines the current optimizer
  59353. * @returns true if everything that can be done was applied
  59354. */
  59355. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59356. }
  59357. /**
  59358. * Defines an optimization used to remove shadows
  59359. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59360. */
  59361. export class ShadowsOptimization extends SceneOptimization {
  59362. /**
  59363. * Gets a string describing the action executed by the current optimization
  59364. * @return description string
  59365. */
  59366. getDescription(): string;
  59367. /**
  59368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59369. * @param scene defines the current scene where to apply this optimization
  59370. * @param optimizer defines the current optimizer
  59371. * @returns true if everything that can be done was applied
  59372. */
  59373. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59374. }
  59375. /**
  59376. * Defines an optimization used to turn post-processes off
  59377. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59378. */
  59379. export class PostProcessesOptimization extends SceneOptimization {
  59380. /**
  59381. * Gets a string describing the action executed by the current optimization
  59382. * @return description string
  59383. */
  59384. getDescription(): string;
  59385. /**
  59386. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59387. * @param scene defines the current scene where to apply this optimization
  59388. * @param optimizer defines the current optimizer
  59389. * @returns true if everything that can be done was applied
  59390. */
  59391. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59392. }
  59393. /**
  59394. * Defines an optimization used to turn lens flares off
  59395. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59396. */
  59397. export class LensFlaresOptimization extends SceneOptimization {
  59398. /**
  59399. * Gets a string describing the action executed by the current optimization
  59400. * @return description string
  59401. */
  59402. getDescription(): string;
  59403. /**
  59404. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59405. * @param scene defines the current scene where to apply this optimization
  59406. * @param optimizer defines the current optimizer
  59407. * @returns true if everything that can be done was applied
  59408. */
  59409. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59410. }
  59411. /**
  59412. * Defines an optimization based on user defined callback.
  59413. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59414. */
  59415. export class CustomOptimization extends SceneOptimization {
  59416. /**
  59417. * Callback called to apply the custom optimization.
  59418. */
  59419. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  59420. /**
  59421. * Callback called to get custom description
  59422. */
  59423. onGetDescription: () => string;
  59424. /**
  59425. * Gets a string describing the action executed by the current optimization
  59426. * @returns description string
  59427. */
  59428. getDescription(): string;
  59429. /**
  59430. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59431. * @param scene defines the current scene where to apply this optimization
  59432. * @param optimizer defines the current optimizer
  59433. * @returns true if everything that can be done was applied
  59434. */
  59435. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59436. }
  59437. /**
  59438. * Defines an optimization used to turn particles off
  59439. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59440. */
  59441. export class ParticlesOptimization extends SceneOptimization {
  59442. /**
  59443. * Gets a string describing the action executed by the current optimization
  59444. * @return description string
  59445. */
  59446. getDescription(): string;
  59447. /**
  59448. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59449. * @param scene defines the current scene where to apply this optimization
  59450. * @param optimizer defines the current optimizer
  59451. * @returns true if everything that can be done was applied
  59452. */
  59453. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59454. }
  59455. /**
  59456. * Defines an optimization used to turn render targets off
  59457. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59458. */
  59459. export class RenderTargetsOptimization extends SceneOptimization {
  59460. /**
  59461. * Gets a string describing the action executed by the current optimization
  59462. * @return description string
  59463. */
  59464. getDescription(): string;
  59465. /**
  59466. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59467. * @param scene defines the current scene where to apply this optimization
  59468. * @param optimizer defines the current optimizer
  59469. * @returns true if everything that can be done was applied
  59470. */
  59471. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59472. }
  59473. /**
  59474. * Defines an optimization used to merge meshes with compatible materials
  59475. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59476. */
  59477. export class MergeMeshesOptimization extends SceneOptimization {
  59478. private static _UpdateSelectionTree;
  59479. /**
  59480. * Gets or sets a boolean which defines if optimization octree has to be updated
  59481. */
  59482. /**
  59483. * Gets or sets a boolean which defines if optimization octree has to be updated
  59484. */
  59485. static UpdateSelectionTree: boolean;
  59486. /**
  59487. * Gets a string describing the action executed by the current optimization
  59488. * @return description string
  59489. */
  59490. getDescription(): string;
  59491. private _canBeMerged;
  59492. /**
  59493. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59494. * @param scene defines the current scene where to apply this optimization
  59495. * @param optimizer defines the current optimizer
  59496. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  59497. * @returns true if everything that can be done was applied
  59498. */
  59499. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  59500. }
  59501. /**
  59502. * Defines a list of options used by SceneOptimizer
  59503. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59504. */
  59505. export class SceneOptimizerOptions {
  59506. /**
  59507. * Defines the target frame rate to reach (60 by default)
  59508. */
  59509. targetFrameRate: number;
  59510. /**
  59511. * Defines the interval between two checkes (2000ms by default)
  59512. */
  59513. trackerDuration: number;
  59514. /**
  59515. * Gets the list of optimizations to apply
  59516. */
  59517. optimizations: SceneOptimization[];
  59518. /**
  59519. * Creates a new list of options used by SceneOptimizer
  59520. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  59521. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  59522. */
  59523. constructor(
  59524. /**
  59525. * Defines the target frame rate to reach (60 by default)
  59526. */
  59527. targetFrameRate?: number,
  59528. /**
  59529. * Defines the interval between two checkes (2000ms by default)
  59530. */
  59531. trackerDuration?: number);
  59532. /**
  59533. * Add a new optimization
  59534. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59535. * @returns the current SceneOptimizerOptions
  59536. */
  59537. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59538. /**
  59539. * Add a new custom optimization
  59540. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59541. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59542. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59543. * @returns the current SceneOptimizerOptions
  59544. */
  59545. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59546. /**
  59547. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59548. * @param targetFrameRate defines the target frame rate (60 by default)
  59549. * @returns a SceneOptimizerOptions object
  59550. */
  59551. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59552. /**
  59553. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59554. * @param targetFrameRate defines the target frame rate (60 by default)
  59555. * @returns a SceneOptimizerOptions object
  59556. */
  59557. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59558. /**
  59559. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59560. * @param targetFrameRate defines the target frame rate (60 by default)
  59561. * @returns a SceneOptimizerOptions object
  59562. */
  59563. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59564. }
  59565. /**
  59566. * Class used to run optimizations in order to reach a target frame rate
  59567. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59568. */
  59569. export class SceneOptimizer implements IDisposable {
  59570. private _isRunning;
  59571. private _options;
  59572. private _scene;
  59573. private _currentPriorityLevel;
  59574. private _targetFrameRate;
  59575. private _trackerDuration;
  59576. private _currentFrameRate;
  59577. private _sceneDisposeObserver;
  59578. private _improvementMode;
  59579. /**
  59580. * Defines an observable called when the optimizer reaches the target frame rate
  59581. */
  59582. onSuccessObservable: Observable<SceneOptimizer>;
  59583. /**
  59584. * Defines an observable called when the optimizer enables an optimization
  59585. */
  59586. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59587. /**
  59588. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59589. */
  59590. onFailureObservable: Observable<SceneOptimizer>;
  59591. /**
  59592. * Gets a boolean indicating if the optimizer is in improvement mode
  59593. */
  59594. readonly isInImprovementMode: boolean;
  59595. /**
  59596. * Gets the current priority level (0 at start)
  59597. */
  59598. readonly currentPriorityLevel: number;
  59599. /**
  59600. * Gets the current frame rate checked by the SceneOptimizer
  59601. */
  59602. readonly currentFrameRate: number;
  59603. /**
  59604. * Gets or sets the current target frame rate (60 by default)
  59605. */
  59606. /**
  59607. * Gets or sets the current target frame rate (60 by default)
  59608. */
  59609. targetFrameRate: number;
  59610. /**
  59611. * Gets or sets the current interval between two checks (every 2000ms by default)
  59612. */
  59613. /**
  59614. * Gets or sets the current interval between two checks (every 2000ms by default)
  59615. */
  59616. trackerDuration: number;
  59617. /**
  59618. * Gets the list of active optimizations
  59619. */
  59620. readonly optimizations: SceneOptimization[];
  59621. /**
  59622. * Creates a new SceneOptimizer
  59623. * @param scene defines the scene to work on
  59624. * @param options defines the options to use with the SceneOptimizer
  59625. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59626. * @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)
  59627. */
  59628. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59629. /**
  59630. * Stops the current optimizer
  59631. */
  59632. stop(): void;
  59633. /**
  59634. * Reset the optimizer to initial step (current priority level = 0)
  59635. */
  59636. reset(): void;
  59637. /**
  59638. * Start the optimizer. By default it will try to reach a specific framerate
  59639. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59640. */
  59641. start(): void;
  59642. private _checkCurrentState;
  59643. /**
  59644. * Release all resources
  59645. */
  59646. dispose(): void;
  59647. /**
  59648. * Helper function to create a SceneOptimizer with one single line of code
  59649. * @param scene defines the scene to work on
  59650. * @param options defines the options to use with the SceneOptimizer
  59651. * @param onSuccess defines a callback to call on success
  59652. * @param onFailure defines a callback to call on failure
  59653. * @returns the new SceneOptimizer object
  59654. */
  59655. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59656. }
  59657. }
  59658. declare module BABYLON {
  59659. /**
  59660. * Class used to serialize a scene into a string
  59661. */
  59662. export class SceneSerializer {
  59663. /**
  59664. * Clear cache used by a previous serialization
  59665. */
  59666. static ClearCache(): void;
  59667. /**
  59668. * Serialize a scene into a JSON compatible object
  59669. * @param scene defines the scene to serialize
  59670. * @returns a JSON compatible object
  59671. */
  59672. static Serialize(scene: Scene): any;
  59673. /**
  59674. * Serialize a mesh into a JSON compatible object
  59675. * @param toSerialize defines the mesh to serialize
  59676. * @param withParents defines if parents must be serialized as well
  59677. * @param withChildren defines if children must be serialized as well
  59678. * @returns a JSON compatible object
  59679. */
  59680. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59681. }
  59682. }
  59683. declare module BABYLON {
  59684. /**
  59685. * Class used to host texture specific utilities
  59686. */
  59687. export class TextureTools {
  59688. /**
  59689. * Uses the GPU to create a copy texture rescaled at a given size
  59690. * @param texture Texture to copy from
  59691. * @param width defines the desired width
  59692. * @param height defines the desired height
  59693. * @param useBilinearMode defines if bilinear mode has to be used
  59694. * @return the generated texture
  59695. */
  59696. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59697. }
  59698. }
  59699. declare module BABYLON {
  59700. /**
  59701. * This represents the different options available for the video capture.
  59702. */
  59703. export interface VideoRecorderOptions {
  59704. /** Defines the mime type of the video. */
  59705. mimeType: string;
  59706. /** Defines the FPS the video should be recorded at. */
  59707. fps: number;
  59708. /** Defines the chunk size for the recording data. */
  59709. recordChunckSize: number;
  59710. /** The audio tracks to attach to the recording. */
  59711. audioTracks?: MediaStreamTrack[];
  59712. }
  59713. /**
  59714. * This can help with recording videos from BabylonJS.
  59715. * This is based on the available WebRTC functionalities of the browser.
  59716. *
  59717. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59718. */
  59719. export class VideoRecorder {
  59720. private static readonly _defaultOptions;
  59721. /**
  59722. * Returns whether or not the VideoRecorder is available in your browser.
  59723. * @param engine Defines the Babylon Engine.
  59724. * @returns true if supported otherwise false.
  59725. */
  59726. static IsSupported(engine: Engine): boolean;
  59727. private readonly _options;
  59728. private _canvas;
  59729. private _mediaRecorder;
  59730. private _recordedChunks;
  59731. private _fileName;
  59732. private _resolve;
  59733. private _reject;
  59734. /**
  59735. * True when a recording is already in progress.
  59736. */
  59737. readonly isRecording: boolean;
  59738. /**
  59739. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  59740. * @param engine Defines the BabylonJS Engine you wish to record.
  59741. * @param options Defines options that can be used to customize the capture.
  59742. */
  59743. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59744. /**
  59745. * Stops the current recording before the default capture timeout passed in the startRecording function.
  59746. */
  59747. stopRecording(): void;
  59748. /**
  59749. * Starts recording the canvas for a max duration specified in parameters.
  59750. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  59751. * If null no automatic download will start and you can rely on the promise to get the data back.
  59752. * @param maxDuration Defines the maximum recording time in seconds.
  59753. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59754. * @return A promise callback at the end of the recording with the video data in Blob.
  59755. */
  59756. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59757. /**
  59758. * Releases internal resources used during the recording.
  59759. */
  59760. dispose(): void;
  59761. private _handleDataAvailable;
  59762. private _handleError;
  59763. private _handleStop;
  59764. }
  59765. }
  59766. declare module BABYLON {
  59767. /**
  59768. * Class containing a set of static utilities functions for screenshots
  59769. */
  59770. export class ScreenshotTools {
  59771. /**
  59772. * Captures a screenshot of the current rendering
  59773. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59774. * @param engine defines the rendering engine
  59775. * @param camera defines the source camera
  59776. * @param size This parameter can be set to a single number or to an object with the
  59777. * following (optional) properties: precision, width, height. If a single number is passed,
  59778. * it will be used for both width and height. If an object is passed, the screenshot size
  59779. * will be derived from the parameters. The precision property is a multiplier allowing
  59780. * rendering at a higher or lower resolution
  59781. * @param successCallback defines the callback receives a single parameter which contains the
  59782. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59783. * src parameter of an <img> to display it
  59784. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59785. * Check your browser for supported MIME types
  59786. */
  59787. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59788. /**
  59789. * Generates an image screenshot from the specified camera.
  59790. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59791. * @param engine The engine to use for rendering
  59792. * @param camera The camera to use for rendering
  59793. * @param size This parameter can be set to a single number or to an object with the
  59794. * following (optional) properties: precision, width, height. If a single number is passed,
  59795. * it will be used for both width and height. If an object is passed, the screenshot size
  59796. * will be derived from the parameters. The precision property is a multiplier allowing
  59797. * rendering at a higher or lower resolution
  59798. * @param successCallback The callback receives a single parameter which contains the
  59799. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59800. * src parameter of an <img> to display it
  59801. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59802. * Check your browser for supported MIME types
  59803. * @param samples Texture samples (default: 1)
  59804. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59805. * @param fileName A name for for the downloaded file.
  59806. */
  59807. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59808. }
  59809. }
  59810. declare module BABYLON {
  59811. /**
  59812. * A cursor which tracks a point on a path
  59813. */
  59814. export class PathCursor {
  59815. private path;
  59816. /**
  59817. * Stores path cursor callbacks for when an onchange event is triggered
  59818. */
  59819. private _onchange;
  59820. /**
  59821. * The value of the path cursor
  59822. */
  59823. value: number;
  59824. /**
  59825. * The animation array of the path cursor
  59826. */
  59827. animations: Animation[];
  59828. /**
  59829. * Initializes the path cursor
  59830. * @param path The path to track
  59831. */
  59832. constructor(path: Path2);
  59833. /**
  59834. * Gets the cursor point on the path
  59835. * @returns A point on the path cursor at the cursor location
  59836. */
  59837. getPoint(): Vector3;
  59838. /**
  59839. * Moves the cursor ahead by the step amount
  59840. * @param step The amount to move the cursor forward
  59841. * @returns This path cursor
  59842. */
  59843. moveAhead(step?: number): PathCursor;
  59844. /**
  59845. * Moves the cursor behind by the step amount
  59846. * @param step The amount to move the cursor back
  59847. * @returns This path cursor
  59848. */
  59849. moveBack(step?: number): PathCursor;
  59850. /**
  59851. * Moves the cursor by the step amount
  59852. * If the step amount is greater than one, an exception is thrown
  59853. * @param step The amount to move the cursor
  59854. * @returns This path cursor
  59855. */
  59856. move(step: number): PathCursor;
  59857. /**
  59858. * Ensures that the value is limited between zero and one
  59859. * @returns This path cursor
  59860. */
  59861. private ensureLimits;
  59862. /**
  59863. * Runs onchange callbacks on change (used by the animation engine)
  59864. * @returns This path cursor
  59865. */
  59866. private raiseOnChange;
  59867. /**
  59868. * Executes a function on change
  59869. * @param f A path cursor onchange callback
  59870. * @returns This path cursor
  59871. */
  59872. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59873. }
  59874. }
  59875. declare module BABYLON {
  59876. /** @hidden */
  59877. export var blurPixelShader: {
  59878. name: string;
  59879. shader: string;
  59880. };
  59881. }
  59882. declare module BABYLON {
  59883. /** @hidden */
  59884. export var pointCloudVertexDeclaration: {
  59885. name: string;
  59886. shader: string;
  59887. };
  59888. }
  59889. // Mixins
  59890. interface Window {
  59891. mozIndexedDB: IDBFactory;
  59892. webkitIndexedDB: IDBFactory;
  59893. msIndexedDB: IDBFactory;
  59894. webkitURL: typeof URL;
  59895. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59896. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59897. WebGLRenderingContext: WebGLRenderingContext;
  59898. MSGesture: MSGesture;
  59899. CANNON: any;
  59900. AudioContext: AudioContext;
  59901. webkitAudioContext: AudioContext;
  59902. PointerEvent: any;
  59903. Math: Math;
  59904. Uint8Array: Uint8ArrayConstructor;
  59905. Float32Array: Float32ArrayConstructor;
  59906. mozURL: typeof URL;
  59907. msURL: typeof URL;
  59908. VRFrameData: any; // WebVR, from specs 1.1
  59909. DracoDecoderModule: any;
  59910. setImmediate(handler: (...args: any[]) => void): number;
  59911. }
  59912. interface HTMLCanvasElement {
  59913. requestPointerLock(): void;
  59914. msRequestPointerLock?(): void;
  59915. mozRequestPointerLock?(): void;
  59916. webkitRequestPointerLock?(): void;
  59917. /** Track wether a record is in progress */
  59918. isRecording: boolean;
  59919. /** Capture Stream method defined by some browsers */
  59920. captureStream(fps?: number): MediaStream;
  59921. }
  59922. interface CanvasRenderingContext2D {
  59923. msImageSmoothingEnabled: boolean;
  59924. }
  59925. interface MouseEvent {
  59926. mozMovementX: number;
  59927. mozMovementY: number;
  59928. webkitMovementX: number;
  59929. webkitMovementY: number;
  59930. msMovementX: number;
  59931. msMovementY: number;
  59932. }
  59933. interface Navigator {
  59934. mozGetVRDevices: (any: any) => any;
  59935. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59936. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59937. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59938. webkitGetGamepads(): Gamepad[];
  59939. msGetGamepads(): Gamepad[];
  59940. webkitGamepads(): Gamepad[];
  59941. }
  59942. interface HTMLVideoElement {
  59943. mozSrcObject: any;
  59944. }
  59945. interface Math {
  59946. fround(x: number): number;
  59947. imul(a: number, b: number): number;
  59948. }
  59949. interface WebGLRenderingContext {
  59950. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59951. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59952. vertexAttribDivisor(index: number, divisor: number): void;
  59953. createVertexArray(): any;
  59954. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59955. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59956. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59957. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59958. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59959. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59960. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59961. // Queries
  59962. createQuery(): WebGLQuery;
  59963. deleteQuery(query: WebGLQuery): void;
  59964. beginQuery(target: number, query: WebGLQuery): void;
  59965. endQuery(target: number): void;
  59966. getQueryParameter(query: WebGLQuery, pname: number): any;
  59967. getQuery(target: number, pname: number): any;
  59968. MAX_SAMPLES: number;
  59969. RGBA8: number;
  59970. READ_FRAMEBUFFER: number;
  59971. DRAW_FRAMEBUFFER: number;
  59972. UNIFORM_BUFFER: number;
  59973. HALF_FLOAT_OES: number;
  59974. RGBA16F: number;
  59975. RGBA32F: number;
  59976. R32F: number;
  59977. RG32F: number;
  59978. RGB32F: number;
  59979. R16F: number;
  59980. RG16F: number;
  59981. RGB16F: number;
  59982. RED: number;
  59983. RG: number;
  59984. R8: number;
  59985. RG8: number;
  59986. UNSIGNED_INT_24_8: number;
  59987. DEPTH24_STENCIL8: number;
  59988. /* Multiple Render Targets */
  59989. drawBuffers(buffers: number[]): void;
  59990. readBuffer(src: number): void;
  59991. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59992. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59993. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59994. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59995. // Occlusion Query
  59996. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59997. ANY_SAMPLES_PASSED: number;
  59998. QUERY_RESULT_AVAILABLE: number;
  59999. QUERY_RESULT: number;
  60000. }
  60001. interface WebGLProgram {
  60002. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  60003. }
  60004. interface EXT_disjoint_timer_query {
  60005. QUERY_COUNTER_BITS_EXT: number;
  60006. TIME_ELAPSED_EXT: number;
  60007. TIMESTAMP_EXT: number;
  60008. GPU_DISJOINT_EXT: number;
  60009. QUERY_RESULT_EXT: number;
  60010. QUERY_RESULT_AVAILABLE_EXT: number;
  60011. queryCounterEXT(query: WebGLQuery, target: number): void;
  60012. createQueryEXT(): WebGLQuery;
  60013. beginQueryEXT(target: number, query: WebGLQuery): void;
  60014. endQueryEXT(target: number): void;
  60015. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  60016. deleteQueryEXT(query: WebGLQuery): void;
  60017. }
  60018. interface WebGLUniformLocation {
  60019. _currentState: any;
  60020. }
  60021. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  60022. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  60023. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  60024. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  60025. interface WebGLRenderingContext {
  60026. readonly RASTERIZER_DISCARD: number;
  60027. readonly DEPTH_COMPONENT24: number;
  60028. readonly TEXTURE_3D: number;
  60029. readonly TEXTURE_2D_ARRAY: number;
  60030. readonly TEXTURE_COMPARE_FUNC: number;
  60031. readonly TEXTURE_COMPARE_MODE: number;
  60032. readonly COMPARE_REF_TO_TEXTURE: number;
  60033. readonly TEXTURE_WRAP_R: number;
  60034. readonly HALF_FLOAT: number;
  60035. readonly RGB8: number;
  60036. readonly RED_INTEGER: number;
  60037. readonly RG_INTEGER: number;
  60038. readonly RGB_INTEGER: number;
  60039. readonly RGBA_INTEGER: number;
  60040. readonly R8_SNORM: number;
  60041. readonly RG8_SNORM: number;
  60042. readonly RGB8_SNORM: number;
  60043. readonly RGBA8_SNORM: number;
  60044. readonly R8I: number;
  60045. readonly RG8I: number;
  60046. readonly RGB8I: number;
  60047. readonly RGBA8I: number;
  60048. readonly R8UI: number;
  60049. readonly RG8UI: number;
  60050. readonly RGB8UI: number;
  60051. readonly RGBA8UI: number;
  60052. readonly R16I: number;
  60053. readonly RG16I: number;
  60054. readonly RGB16I: number;
  60055. readonly RGBA16I: number;
  60056. readonly R16UI: number;
  60057. readonly RG16UI: number;
  60058. readonly RGB16UI: number;
  60059. readonly RGBA16UI: number;
  60060. readonly R32I: number;
  60061. readonly RG32I: number;
  60062. readonly RGB32I: number;
  60063. readonly RGBA32I: number;
  60064. readonly R32UI: number;
  60065. readonly RG32UI: number;
  60066. readonly RGB32UI: number;
  60067. readonly RGBA32UI: number;
  60068. readonly RGB10_A2UI: number;
  60069. readonly R11F_G11F_B10F: number;
  60070. readonly RGB9_E5: number;
  60071. readonly RGB10_A2: number;
  60072. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  60073. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  60074. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  60075. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  60076. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  60077. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  60078. 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;
  60079. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  60080. readonly TRANSFORM_FEEDBACK: number;
  60081. readonly INTERLEAVED_ATTRIBS: number;
  60082. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  60083. createTransformFeedback(): WebGLTransformFeedback;
  60084. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  60085. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  60086. beginTransformFeedback(primitiveMode: number): void;
  60087. endTransformFeedback(): void;
  60088. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  60089. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60090. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60091. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60092. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  60093. }
  60094. interface ImageBitmap {
  60095. readonly width: number;
  60096. readonly height: number;
  60097. close(): void;
  60098. }
  60099. interface WebGLQuery extends WebGLObject {
  60100. }
  60101. declare var WebGLQuery: {
  60102. prototype: WebGLQuery;
  60103. new(): WebGLQuery;
  60104. };
  60105. interface WebGLSampler extends WebGLObject {
  60106. }
  60107. declare var WebGLSampler: {
  60108. prototype: WebGLSampler;
  60109. new(): WebGLSampler;
  60110. };
  60111. interface WebGLSync extends WebGLObject {
  60112. }
  60113. declare var WebGLSync: {
  60114. prototype: WebGLSync;
  60115. new(): WebGLSync;
  60116. };
  60117. interface WebGLTransformFeedback extends WebGLObject {
  60118. }
  60119. declare var WebGLTransformFeedback: {
  60120. prototype: WebGLTransformFeedback;
  60121. new(): WebGLTransformFeedback;
  60122. };
  60123. interface WebGLVertexArrayObject extends WebGLObject {
  60124. }
  60125. declare var WebGLVertexArrayObject: {
  60126. prototype: WebGLVertexArrayObject;
  60127. new(): WebGLVertexArrayObject;
  60128. };
  60129. // Type definitions for WebVR API
  60130. // Project: https://w3c.github.io/webvr/
  60131. // Definitions by: six a <https://github.com/lostfictions>
  60132. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  60133. interface VRDisplay extends EventTarget {
  60134. /**
  60135. * Dictionary of capabilities describing the VRDisplay.
  60136. */
  60137. readonly capabilities: VRDisplayCapabilities;
  60138. /**
  60139. * z-depth defining the far plane of the eye view frustum
  60140. * enables mapping of values in the render target depth
  60141. * attachment to scene coordinates. Initially set to 10000.0.
  60142. */
  60143. depthFar: number;
  60144. /**
  60145. * z-depth defining the near plane of the eye view frustum
  60146. * enables mapping of values in the render target depth
  60147. * attachment to scene coordinates. Initially set to 0.01.
  60148. */
  60149. depthNear: number;
  60150. /**
  60151. * An identifier for this distinct VRDisplay. Used as an
  60152. * association point in the Gamepad API.
  60153. */
  60154. readonly displayId: number;
  60155. /**
  60156. * A display name, a user-readable name identifying it.
  60157. */
  60158. readonly displayName: string;
  60159. readonly isConnected: boolean;
  60160. readonly isPresenting: boolean;
  60161. /**
  60162. * If this VRDisplay supports room-scale experiences, the optional
  60163. * stage attribute contains details on the room-scale parameters.
  60164. */
  60165. readonly stageParameters: VRStageParameters | null;
  60166. /**
  60167. * Passing the value returned by `requestAnimationFrame` to
  60168. * `cancelAnimationFrame` will unregister the callback.
  60169. * @param handle Define the hanle of the request to cancel
  60170. */
  60171. cancelAnimationFrame(handle: number): void;
  60172. /**
  60173. * Stops presenting to the VRDisplay.
  60174. * @returns a promise to know when it stopped
  60175. */
  60176. exitPresent(): Promise<void>;
  60177. /**
  60178. * Return the current VREyeParameters for the given eye.
  60179. * @param whichEye Define the eye we want the parameter for
  60180. * @returns the eye parameters
  60181. */
  60182. getEyeParameters(whichEye: string): VREyeParameters;
  60183. /**
  60184. * Populates the passed VRFrameData with the information required to render
  60185. * the current frame.
  60186. * @param frameData Define the data structure to populate
  60187. * @returns true if ok otherwise false
  60188. */
  60189. getFrameData(frameData: VRFrameData): boolean;
  60190. /**
  60191. * Get the layers currently being presented.
  60192. * @returns the list of VR layers
  60193. */
  60194. getLayers(): VRLayer[];
  60195. /**
  60196. * Return a VRPose containing the future predicted pose of the VRDisplay
  60197. * when the current frame will be presented. The value returned will not
  60198. * change until JavaScript has returned control to the browser.
  60199. *
  60200. * The VRPose will contain the position, orientation, velocity,
  60201. * and acceleration of each of these properties.
  60202. * @returns the pose object
  60203. */
  60204. getPose(): VRPose;
  60205. /**
  60206. * Return the current instantaneous pose of the VRDisplay, with no
  60207. * prediction applied.
  60208. * @returns the current instantaneous pose
  60209. */
  60210. getImmediatePose(): VRPose;
  60211. /**
  60212. * The callback passed to `requestAnimationFrame` will be called
  60213. * any time a new frame should be rendered. When the VRDisplay is
  60214. * presenting the callback will be called at the native refresh
  60215. * rate of the HMD. When not presenting this function acts
  60216. * identically to how window.requestAnimationFrame acts. Content should
  60217. * make no assumptions of frame rate or vsync behavior as the HMD runs
  60218. * asynchronously from other displays and at differing refresh rates.
  60219. * @param callback Define the eaction to run next frame
  60220. * @returns the request handle it
  60221. */
  60222. requestAnimationFrame(callback: FrameRequestCallback): number;
  60223. /**
  60224. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  60225. * Repeat calls while already presenting will update the VRLayers being displayed.
  60226. * @param layers Define the list of layer to present
  60227. * @returns a promise to know when the request has been fulfilled
  60228. */
  60229. requestPresent(layers: VRLayer[]): Promise<void>;
  60230. /**
  60231. * Reset the pose for this display, treating its current position and
  60232. * orientation as the "origin/zero" values. VRPose.position,
  60233. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  60234. * updated when calling resetPose(). This should be called in only
  60235. * sitting-space experiences.
  60236. */
  60237. resetPose(): void;
  60238. /**
  60239. * The VRLayer provided to the VRDisplay will be captured and presented
  60240. * in the HMD. Calling this function has the same effect on the source
  60241. * canvas as any other operation that uses its source image, and canvases
  60242. * created without preserveDrawingBuffer set to true will be cleared.
  60243. * @param pose Define the pose to submit
  60244. */
  60245. submitFrame(pose?: VRPose): void;
  60246. }
  60247. declare var VRDisplay: {
  60248. prototype: VRDisplay;
  60249. new(): VRDisplay;
  60250. };
  60251. interface VRLayer {
  60252. leftBounds?: number[] | Float32Array | null;
  60253. rightBounds?: number[] | Float32Array | null;
  60254. source?: HTMLCanvasElement | null;
  60255. }
  60256. interface VRDisplayCapabilities {
  60257. readonly canPresent: boolean;
  60258. readonly hasExternalDisplay: boolean;
  60259. readonly hasOrientation: boolean;
  60260. readonly hasPosition: boolean;
  60261. readonly maxLayers: number;
  60262. }
  60263. interface VREyeParameters {
  60264. /** @deprecated */
  60265. readonly fieldOfView: VRFieldOfView;
  60266. readonly offset: Float32Array;
  60267. readonly renderHeight: number;
  60268. readonly renderWidth: number;
  60269. }
  60270. interface VRFieldOfView {
  60271. readonly downDegrees: number;
  60272. readonly leftDegrees: number;
  60273. readonly rightDegrees: number;
  60274. readonly upDegrees: number;
  60275. }
  60276. interface VRFrameData {
  60277. readonly leftProjectionMatrix: Float32Array;
  60278. readonly leftViewMatrix: Float32Array;
  60279. readonly pose: VRPose;
  60280. readonly rightProjectionMatrix: Float32Array;
  60281. readonly rightViewMatrix: Float32Array;
  60282. readonly timestamp: number;
  60283. }
  60284. interface VRPose {
  60285. readonly angularAcceleration: Float32Array | null;
  60286. readonly angularVelocity: Float32Array | null;
  60287. readonly linearAcceleration: Float32Array | null;
  60288. readonly linearVelocity: Float32Array | null;
  60289. readonly orientation: Float32Array | null;
  60290. readonly position: Float32Array | null;
  60291. readonly timestamp: number;
  60292. }
  60293. interface VRStageParameters {
  60294. sittingToStandingTransform?: Float32Array;
  60295. sizeX?: number;
  60296. sizeY?: number;
  60297. }
  60298. interface Navigator {
  60299. getVRDisplays(): Promise<VRDisplay[]>;
  60300. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  60301. }
  60302. interface Window {
  60303. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  60304. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  60305. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  60306. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  60307. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  60308. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  60309. }
  60310. interface Gamepad {
  60311. readonly displayId: number;
  60312. }
  60313. type XRSessionMode =
  60314. | "inline"
  60315. | "immersive-vr"
  60316. | "immersive-ar";
  60317. type XRReferenceSpaceType =
  60318. | "viewer"
  60319. | "local"
  60320. | "local-floor"
  60321. | "bounded-floor"
  60322. | "unbounded";
  60323. type XREnvironmentBlendMode =
  60324. | "opaque"
  60325. | "additive"
  60326. | "alpha-blend";
  60327. type XRVisibilityState =
  60328. | "visible"
  60329. | "visible-blurred"
  60330. | "hidden";
  60331. type XRHandedness =
  60332. | "none"
  60333. | "left"
  60334. | "right";
  60335. type XRTargetRayMode =
  60336. | "gaze"
  60337. | "tracked-pointer"
  60338. | "screen";
  60339. type XREye =
  60340. | "none"
  60341. | "left"
  60342. | "right";
  60343. interface XRSpace extends EventTarget {
  60344. }
  60345. interface XRRenderState {
  60346. depthNear?: number;
  60347. depthFar?: number;
  60348. inlineVerticalFieldOfView?: number;
  60349. baseLayer?: XRWebGLLayer;
  60350. }
  60351. interface XRInputSource {
  60352. handedness: XRHandedness;
  60353. targetRayMode: XRTargetRayMode;
  60354. targetRaySpace: XRSpace;
  60355. gripSpace: XRSpace | undefined;
  60356. gamepad: Gamepad | undefined;
  60357. profiles: Array<string>;
  60358. }
  60359. interface XRSession {
  60360. addEventListener: Function;
  60361. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  60362. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  60363. requestAnimationFrame: Function;
  60364. end(): Promise<void>;
  60365. renderState: XRRenderState;
  60366. inputSources: Array<XRInputSource>;
  60367. }
  60368. interface XRReferenceSpace extends XRSpace {
  60369. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  60370. onreset: any;
  60371. }
  60372. interface XRFrame {
  60373. session: XRSession;
  60374. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  60375. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  60376. }
  60377. interface XRViewerPose extends XRPose {
  60378. views: Array<XRView>;
  60379. }
  60380. interface XRPose {
  60381. transform: XRRigidTransform;
  60382. emulatedPosition: boolean;
  60383. }
  60384. declare var XRWebGLLayer: {
  60385. prototype: XRWebGLLayer;
  60386. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  60387. };
  60388. interface XRWebGLLayer {
  60389. framebuffer: WebGLFramebuffer;
  60390. framebufferWidth: number;
  60391. framebufferHeight: number;
  60392. getViewport: Function;
  60393. }
  60394. interface XRRigidTransform {
  60395. position: DOMPointReadOnly;
  60396. orientation: DOMPointReadOnly;
  60397. matrix: Float32Array;
  60398. inverse: XRRigidTransform;
  60399. }
  60400. interface XRView {
  60401. eye: XREye;
  60402. projectionMatrix: Float32Array;
  60403. transform: XRRigidTransform;
  60404. }
  60405. interface XRInputSourceChangeEvent {
  60406. session: XRSession;
  60407. removed: Array<XRInputSource>;
  60408. added: Array<XRInputSource>;
  60409. }
  60410. declare module BABYLON.GUI {
  60411. /**
  60412. * Class used to specific a value and its associated unit
  60413. */
  60414. export class ValueAndUnit {
  60415. /** defines the unit to store */
  60416. unit: number;
  60417. /** defines a boolean indicating if the value can be negative */
  60418. negativeValueAllowed: boolean;
  60419. private _value;
  60420. private _originalUnit;
  60421. /**
  60422. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  60423. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60424. */
  60425. ignoreAdaptiveScaling: boolean;
  60426. /**
  60427. * Creates a new ValueAndUnit
  60428. * @param value defines the value to store
  60429. * @param unit defines the unit to store
  60430. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  60431. */
  60432. constructor(value: number,
  60433. /** defines the unit to store */
  60434. unit?: number,
  60435. /** defines a boolean indicating if the value can be negative */
  60436. negativeValueAllowed?: boolean);
  60437. /** Gets a boolean indicating if the value is a percentage */
  60438. readonly isPercentage: boolean;
  60439. /** Gets a boolean indicating if the value is store as pixel */
  60440. readonly isPixel: boolean;
  60441. /** Gets direct internal value */
  60442. readonly internalValue: number;
  60443. /**
  60444. * Gets value as pixel
  60445. * @param host defines the root host
  60446. * @param refValue defines the reference value for percentages
  60447. * @returns the value as pixel
  60448. */
  60449. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  60450. /**
  60451. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  60452. * @param value defines the value to store
  60453. * @param unit defines the unit to store
  60454. * @returns the current ValueAndUnit
  60455. */
  60456. updateInPlace(value: number, unit?: number): ValueAndUnit;
  60457. /**
  60458. * Gets the value accordingly to its unit
  60459. * @param host defines the root host
  60460. * @returns the value
  60461. */
  60462. getValue(host: AdvancedDynamicTexture): number;
  60463. /**
  60464. * Gets a string representation of the value
  60465. * @param host defines the root host
  60466. * @param decimals defines an optional number of decimals to display
  60467. * @returns a string
  60468. */
  60469. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  60470. /**
  60471. * Store a value parsed from a string
  60472. * @param source defines the source string
  60473. * @returns true if the value was successfully parsed
  60474. */
  60475. fromString(source: string | number): boolean;
  60476. private static _Regex;
  60477. private static _UNITMODE_PERCENTAGE;
  60478. private static _UNITMODE_PIXEL;
  60479. /** UNITMODE_PERCENTAGE */
  60480. static readonly UNITMODE_PERCENTAGE: number;
  60481. /** UNITMODE_PIXEL */
  60482. static readonly UNITMODE_PIXEL: number;
  60483. }
  60484. }
  60485. declare module BABYLON.GUI {
  60486. /**
  60487. * Define a style used by control to automatically setup properties based on a template.
  60488. * Only support font related properties so far
  60489. */
  60490. export class Style implements BABYLON.IDisposable {
  60491. private _fontFamily;
  60492. private _fontStyle;
  60493. private _fontWeight;
  60494. /** @hidden */
  60495. _host: AdvancedDynamicTexture;
  60496. /** @hidden */
  60497. _fontSize: ValueAndUnit;
  60498. /**
  60499. * BABYLON.Observable raised when the style values are changed
  60500. */
  60501. onChangedObservable: BABYLON.Observable<Style>;
  60502. /**
  60503. * Creates a new style object
  60504. * @param host defines the AdvancedDynamicTexture which hosts this style
  60505. */
  60506. constructor(host: AdvancedDynamicTexture);
  60507. /**
  60508. * Gets or sets the font size
  60509. */
  60510. fontSize: string | number;
  60511. /**
  60512. * Gets or sets the font family
  60513. */
  60514. fontFamily: string;
  60515. /**
  60516. * Gets or sets the font style
  60517. */
  60518. fontStyle: string;
  60519. /** Gets or sets font weight */
  60520. fontWeight: string;
  60521. /** Dispose all associated resources */
  60522. dispose(): void;
  60523. }
  60524. }
  60525. declare module BABYLON.GUI {
  60526. /**
  60527. * Class used to transport BABYLON.Vector2 information for pointer events
  60528. */
  60529. export class Vector2WithInfo extends BABYLON.Vector2 {
  60530. /** defines the current mouse button index */
  60531. buttonIndex: number;
  60532. /**
  60533. * Creates a new Vector2WithInfo
  60534. * @param source defines the vector2 data to transport
  60535. * @param buttonIndex defines the current mouse button index
  60536. */
  60537. constructor(source: BABYLON.Vector2,
  60538. /** defines the current mouse button index */
  60539. buttonIndex?: number);
  60540. }
  60541. /** Class used to provide 2D matrix features */
  60542. export class Matrix2D {
  60543. /** Gets the internal array of 6 floats used to store matrix data */
  60544. m: Float32Array;
  60545. /**
  60546. * Creates a new matrix
  60547. * @param m00 defines value for (0, 0)
  60548. * @param m01 defines value for (0, 1)
  60549. * @param m10 defines value for (1, 0)
  60550. * @param m11 defines value for (1, 1)
  60551. * @param m20 defines value for (2, 0)
  60552. * @param m21 defines value for (2, 1)
  60553. */
  60554. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  60555. /**
  60556. * Fills the matrix from direct values
  60557. * @param m00 defines value for (0, 0)
  60558. * @param m01 defines value for (0, 1)
  60559. * @param m10 defines value for (1, 0)
  60560. * @param m11 defines value for (1, 1)
  60561. * @param m20 defines value for (2, 0)
  60562. * @param m21 defines value for (2, 1)
  60563. * @returns the current modified matrix
  60564. */
  60565. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  60566. /**
  60567. * Gets matrix determinant
  60568. * @returns the determinant
  60569. */
  60570. determinant(): number;
  60571. /**
  60572. * Inverses the matrix and stores it in a target matrix
  60573. * @param result defines the target matrix
  60574. * @returns the current matrix
  60575. */
  60576. invertToRef(result: Matrix2D): Matrix2D;
  60577. /**
  60578. * Multiplies the current matrix with another one
  60579. * @param other defines the second operand
  60580. * @param result defines the target matrix
  60581. * @returns the current matrix
  60582. */
  60583. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  60584. /**
  60585. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  60586. * @param x defines the x coordinate to transform
  60587. * @param y defines the x coordinate to transform
  60588. * @param result defines the target vector2
  60589. * @returns the current matrix
  60590. */
  60591. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  60592. /**
  60593. * Creates an identity matrix
  60594. * @returns a new matrix
  60595. */
  60596. static Identity(): Matrix2D;
  60597. /**
  60598. * Creates a translation matrix and stores it in a target matrix
  60599. * @param x defines the x coordinate of the translation
  60600. * @param y defines the y coordinate of the translation
  60601. * @param result defines the target matrix
  60602. */
  60603. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  60604. /**
  60605. * Creates a scaling matrix and stores it in a target matrix
  60606. * @param x defines the x coordinate of the scaling
  60607. * @param y defines the y coordinate of the scaling
  60608. * @param result defines the target matrix
  60609. */
  60610. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  60611. /**
  60612. * Creates a rotation matrix and stores it in a target matrix
  60613. * @param angle defines the rotation angle
  60614. * @param result defines the target matrix
  60615. */
  60616. static RotationToRef(angle: number, result: Matrix2D): void;
  60617. private static _TempPreTranslationMatrix;
  60618. private static _TempPostTranslationMatrix;
  60619. private static _TempRotationMatrix;
  60620. private static _TempScalingMatrix;
  60621. private static _TempCompose0;
  60622. private static _TempCompose1;
  60623. private static _TempCompose2;
  60624. /**
  60625. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  60626. * @param tx defines the x coordinate of the translation
  60627. * @param ty defines the y coordinate of the translation
  60628. * @param angle defines the rotation angle
  60629. * @param scaleX defines the x coordinate of the scaling
  60630. * @param scaleY defines the y coordinate of the scaling
  60631. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  60632. * @param result defines the target matrix
  60633. */
  60634. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  60635. }
  60636. }
  60637. declare module BABYLON.GUI {
  60638. /**
  60639. * Class used to store 2D control sizes
  60640. */
  60641. export class Measure {
  60642. /** defines left coordinate */
  60643. left: number;
  60644. /** defines top coordinate */
  60645. top: number;
  60646. /** defines width dimension */
  60647. width: number;
  60648. /** defines height dimension */
  60649. height: number;
  60650. /**
  60651. * Creates a new measure
  60652. * @param left defines left coordinate
  60653. * @param top defines top coordinate
  60654. * @param width defines width dimension
  60655. * @param height defines height dimension
  60656. */
  60657. constructor(
  60658. /** defines left coordinate */
  60659. left: number,
  60660. /** defines top coordinate */
  60661. top: number,
  60662. /** defines width dimension */
  60663. width: number,
  60664. /** defines height dimension */
  60665. height: number);
  60666. /**
  60667. * Copy from another measure
  60668. * @param other defines the other measure to copy from
  60669. */
  60670. copyFrom(other: Measure): void;
  60671. /**
  60672. * Copy from a group of 4 floats
  60673. * @param left defines left coordinate
  60674. * @param top defines top coordinate
  60675. * @param width defines width dimension
  60676. * @param height defines height dimension
  60677. */
  60678. copyFromFloats(left: number, top: number, width: number, height: number): void;
  60679. /**
  60680. * Computes the axis aligned bounding box measure for two given measures
  60681. * @param a Input measure
  60682. * @param b Input measure
  60683. * @param result the resulting bounding measure
  60684. */
  60685. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  60686. /**
  60687. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  60688. * @param transform the matrix to transform the measure before computing the AABB
  60689. * @param result the resulting AABB
  60690. */
  60691. transformToRef(transform: Matrix2D, result: Measure): void;
  60692. /**
  60693. * Check equality between this measure and another one
  60694. * @param other defines the other measures
  60695. * @returns true if both measures are equals
  60696. */
  60697. isEqualsTo(other: Measure): boolean;
  60698. /**
  60699. * Creates an empty measure
  60700. * @returns a new measure
  60701. */
  60702. static Empty(): Measure;
  60703. }
  60704. }
  60705. declare module BABYLON.GUI {
  60706. /**
  60707. * Interface used to define a control that can receive focus
  60708. */
  60709. export interface IFocusableControl {
  60710. /**
  60711. * Function called when the control receives the focus
  60712. */
  60713. onFocus(): void;
  60714. /**
  60715. * Function called when the control loses the focus
  60716. */
  60717. onBlur(): void;
  60718. /**
  60719. * Function called to let the control handle keyboard events
  60720. * @param evt defines the current keyboard event
  60721. */
  60722. processKeyboard(evt: KeyboardEvent): void;
  60723. /**
  60724. * Function called to get the list of controls that should not steal the focus from this control
  60725. * @returns an array of controls
  60726. */
  60727. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  60728. }
  60729. /**
  60730. * Class used to create texture to support 2D GUI elements
  60731. * @see http://doc.babylonjs.com/how_to/gui
  60732. */
  60733. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  60734. private _isDirty;
  60735. private _renderObserver;
  60736. private _resizeObserver;
  60737. private _preKeyboardObserver;
  60738. private _pointerMoveObserver;
  60739. private _pointerObserver;
  60740. private _canvasPointerOutObserver;
  60741. private _background;
  60742. /** @hidden */
  60743. _rootContainer: Container;
  60744. /** @hidden */
  60745. _lastPickedControl: Control;
  60746. /** @hidden */
  60747. _lastControlOver: {
  60748. [pointerId: number]: Control;
  60749. };
  60750. /** @hidden */
  60751. _lastControlDown: {
  60752. [pointerId: number]: Control;
  60753. };
  60754. /** @hidden */
  60755. _capturingControl: {
  60756. [pointerId: number]: Control;
  60757. };
  60758. /** @hidden */
  60759. _shouldBlockPointer: boolean;
  60760. /** @hidden */
  60761. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  60762. /** @hidden */
  60763. _linkedControls: Control[];
  60764. private _isFullscreen;
  60765. private _fullscreenViewport;
  60766. private _idealWidth;
  60767. private _idealHeight;
  60768. private _useSmallestIdeal;
  60769. private _renderAtIdealSize;
  60770. private _focusedControl;
  60771. private _blockNextFocusCheck;
  60772. private _renderScale;
  60773. private _rootCanvas;
  60774. private _cursorChanged;
  60775. /**
  60776. * Define type to string to ensure compatibility across browsers
  60777. * Safari doesn't support DataTransfer constructor
  60778. */
  60779. private _clipboardData;
  60780. /**
  60781. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  60782. */
  60783. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  60784. /**
  60785. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  60786. */
  60787. onControlPickedObservable: BABYLON.Observable<Control>;
  60788. /**
  60789. * BABYLON.Observable event triggered before layout is evaluated
  60790. */
  60791. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60792. /**
  60793. * BABYLON.Observable event triggered after the layout was evaluated
  60794. */
  60795. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60796. /**
  60797. * BABYLON.Observable event triggered before the texture is rendered
  60798. */
  60799. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60800. /**
  60801. * BABYLON.Observable event triggered after the texture was rendered
  60802. */
  60803. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60804. /**
  60805. * Gets or sets a boolean defining if alpha is stored as premultiplied
  60806. */
  60807. premulAlpha: boolean;
  60808. /**
  60809. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  60810. * Useful when you want more antialiasing
  60811. */
  60812. renderScale: number;
  60813. /** Gets or sets the background color */
  60814. background: string;
  60815. /**
  60816. * Gets or sets the ideal width used to design controls.
  60817. * The GUI will then rescale everything accordingly
  60818. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60819. */
  60820. idealWidth: number;
  60821. /**
  60822. * Gets or sets the ideal height used to design controls.
  60823. * The GUI will then rescale everything accordingly
  60824. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60825. */
  60826. idealHeight: number;
  60827. /**
  60828. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  60829. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60830. */
  60831. useSmallestIdeal: boolean;
  60832. /**
  60833. * Gets or sets a boolean indicating if adaptive scaling must be used
  60834. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60835. */
  60836. renderAtIdealSize: boolean;
  60837. /**
  60838. * Gets the underlying layer used to render the texture when in fullscreen mode
  60839. */
  60840. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  60841. /**
  60842. * Gets the root container control
  60843. */
  60844. readonly rootContainer: Container;
  60845. /**
  60846. * Returns an array containing the root container.
  60847. * This is mostly used to let the Inspector introspects the ADT
  60848. * @returns an array containing the rootContainer
  60849. */
  60850. getChildren(): Array<Container>;
  60851. /**
  60852. * Will return all controls that are inside this texture
  60853. * @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
  60854. * @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
  60855. * @return all child controls
  60856. */
  60857. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60858. /**
  60859. * Gets or sets the current focused control
  60860. */
  60861. focusedControl: BABYLON.Nullable<IFocusableControl>;
  60862. /**
  60863. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  60864. */
  60865. isForeground: boolean;
  60866. /**
  60867. * Gets or set information about clipboardData
  60868. */
  60869. clipboardData: string;
  60870. /**
  60871. * Creates a new AdvancedDynamicTexture
  60872. * @param name defines the name of the texture
  60873. * @param width defines the width of the texture
  60874. * @param height defines the height of the texture
  60875. * @param scene defines the hosting scene
  60876. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  60877. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  60878. */
  60879. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  60880. /**
  60881. * Get the current class name of the texture useful for serialization or dynamic coding.
  60882. * @returns "AdvancedDynamicTexture"
  60883. */
  60884. getClassName(): string;
  60885. /**
  60886. * Function used to execute a function on all controls
  60887. * @param func defines the function to execute
  60888. * @param container defines the container where controls belong. If null the root container will be used
  60889. */
  60890. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  60891. private _useInvalidateRectOptimization;
  60892. /**
  60893. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  60894. */
  60895. useInvalidateRectOptimization: boolean;
  60896. private _invalidatedRectangle;
  60897. /**
  60898. * Invalidates a rectangle area on the gui texture
  60899. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  60900. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  60901. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  60902. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  60903. */
  60904. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  60905. /**
  60906. * Marks the texture as dirty forcing a complete update
  60907. */
  60908. markAsDirty(): void;
  60909. /**
  60910. * Helper function used to create a new style
  60911. * @returns a new style
  60912. * @see http://doc.babylonjs.com/how_to/gui#styles
  60913. */
  60914. createStyle(): Style;
  60915. /**
  60916. * Adds a new control to the root container
  60917. * @param control defines the control to add
  60918. * @returns the current texture
  60919. */
  60920. addControl(control: Control): AdvancedDynamicTexture;
  60921. /**
  60922. * Removes a control from the root container
  60923. * @param control defines the control to remove
  60924. * @returns the current texture
  60925. */
  60926. removeControl(control: Control): AdvancedDynamicTexture;
  60927. /**
  60928. * Release all resources
  60929. */
  60930. dispose(): void;
  60931. private _onResize;
  60932. /** @hidden */
  60933. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  60934. /**
  60935. * Get screen coordinates for a vector3
  60936. * @param position defines the position to project
  60937. * @param worldMatrix defines the world matrix to use
  60938. * @returns the projected position
  60939. */
  60940. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  60941. private _checkUpdate;
  60942. private _clearMeasure;
  60943. private _render;
  60944. /** @hidden */
  60945. _changeCursor(cursor: string): void;
  60946. /** @hidden */
  60947. _registerLastControlDown(control: Control, pointerId: number): void;
  60948. private _doPicking;
  60949. /** @hidden */
  60950. _cleanControlAfterRemovalFromList(list: {
  60951. [pointerId: number]: Control;
  60952. }, control: Control): void;
  60953. /** @hidden */
  60954. _cleanControlAfterRemoval(control: Control): void;
  60955. /** Attach to all scene events required to support pointer events */
  60956. attach(): void;
  60957. /** @hidden */
  60958. private onClipboardCopy;
  60959. /** @hidden */
  60960. private onClipboardCut;
  60961. /** @hidden */
  60962. private onClipboardPaste;
  60963. /**
  60964. * Register the clipboard Events onto the canvas
  60965. */
  60966. registerClipboardEvents(): void;
  60967. /**
  60968. * Unregister the clipboard Events from the canvas
  60969. */
  60970. unRegisterClipboardEvents(): void;
  60971. /**
  60972. * Connect the texture to a hosting mesh to enable interactions
  60973. * @param mesh defines the mesh to attach to
  60974. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  60975. */
  60976. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  60977. /**
  60978. * Move the focus to a specific control
  60979. * @param control defines the control which will receive the focus
  60980. */
  60981. moveFocusToControl(control: IFocusableControl): void;
  60982. private _manageFocus;
  60983. private _attachToOnPointerOut;
  60984. /**
  60985. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  60986. * @param mesh defines the mesh which will receive the texture
  60987. * @param width defines the texture width (1024 by default)
  60988. * @param height defines the texture height (1024 by default)
  60989. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  60990. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  60991. * @returns a new AdvancedDynamicTexture
  60992. */
  60993. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  60994. /**
  60995. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  60996. * In this mode the texture will rely on a layer for its rendering.
  60997. * This allows it to be treated like any other layer.
  60998. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  60999. * LayerMask is set through advancedTexture.layer.layerMask
  61000. * @param name defines name for the texture
  61001. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  61002. * @param scene defines the hsoting scene
  61003. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  61004. * @returns a new AdvancedDynamicTexture
  61005. */
  61006. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  61007. }
  61008. }
  61009. declare module BABYLON.GUI {
  61010. /**
  61011. * Root class used for all 2D controls
  61012. * @see http://doc.babylonjs.com/how_to/gui#controls
  61013. */
  61014. export class Control {
  61015. /** defines the name of the control */
  61016. name?: string | undefined;
  61017. /**
  61018. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  61019. */
  61020. static AllowAlphaInheritance: boolean;
  61021. private _alpha;
  61022. private _alphaSet;
  61023. private _zIndex;
  61024. /** @hidden */
  61025. _host: AdvancedDynamicTexture;
  61026. /** Gets or sets the control parent */
  61027. parent: BABYLON.Nullable<Container>;
  61028. /** @hidden */
  61029. _currentMeasure: Measure;
  61030. private _fontFamily;
  61031. private _fontStyle;
  61032. private _fontWeight;
  61033. private _fontSize;
  61034. private _font;
  61035. /** @hidden */
  61036. _width: ValueAndUnit;
  61037. /** @hidden */
  61038. _height: ValueAndUnit;
  61039. /** @hidden */
  61040. protected _fontOffset: {
  61041. ascent: number;
  61042. height: number;
  61043. descent: number;
  61044. };
  61045. private _color;
  61046. private _style;
  61047. private _styleObserver;
  61048. /** @hidden */
  61049. protected _horizontalAlignment: number;
  61050. /** @hidden */
  61051. protected _verticalAlignment: number;
  61052. /** @hidden */
  61053. protected _isDirty: boolean;
  61054. /** @hidden */
  61055. protected _wasDirty: boolean;
  61056. /** @hidden */
  61057. _tempParentMeasure: Measure;
  61058. /** @hidden */
  61059. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  61060. /** @hidden */
  61061. protected _cachedParentMeasure: Measure;
  61062. private _paddingLeft;
  61063. private _paddingRight;
  61064. private _paddingTop;
  61065. private _paddingBottom;
  61066. /** @hidden */
  61067. _left: ValueAndUnit;
  61068. /** @hidden */
  61069. _top: ValueAndUnit;
  61070. private _scaleX;
  61071. private _scaleY;
  61072. private _rotation;
  61073. private _transformCenterX;
  61074. private _transformCenterY;
  61075. /** @hidden */
  61076. _transformMatrix: Matrix2D;
  61077. /** @hidden */
  61078. protected _invertTransformMatrix: Matrix2D;
  61079. /** @hidden */
  61080. protected _transformedPosition: BABYLON.Vector2;
  61081. private _isMatrixDirty;
  61082. private _cachedOffsetX;
  61083. private _cachedOffsetY;
  61084. private _isVisible;
  61085. private _isHighlighted;
  61086. /** @hidden */
  61087. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61088. private _fontSet;
  61089. private _dummyVector2;
  61090. private _downCount;
  61091. private _enterCount;
  61092. private _doNotRender;
  61093. private _downPointerIds;
  61094. protected _isEnabled: boolean;
  61095. protected _disabledColor: string;
  61096. /** @hidden */
  61097. protected _rebuildLayout: boolean;
  61098. /** @hidden */
  61099. _isClipped: boolean;
  61100. /** @hidden */
  61101. _tag: any;
  61102. /**
  61103. * 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
  61104. */
  61105. uniqueId: number;
  61106. /**
  61107. * Gets or sets an object used to store user defined information for the node
  61108. */
  61109. metadata: any;
  61110. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  61111. isHitTestVisible: boolean;
  61112. /** Gets or sets a boolean indicating if the control can block pointer events */
  61113. isPointerBlocker: boolean;
  61114. /** Gets or sets a boolean indicating if the control can be focusable */
  61115. isFocusInvisible: boolean;
  61116. /**
  61117. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  61118. * 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
  61119. */
  61120. clipChildren: boolean;
  61121. /**
  61122. * Gets or sets a boolean indicating that control content must be clipped
  61123. * 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
  61124. */
  61125. clipContent: boolean;
  61126. /**
  61127. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  61128. */
  61129. useBitmapCache: boolean;
  61130. private _cacheData;
  61131. private _shadowOffsetX;
  61132. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  61133. shadowOffsetX: number;
  61134. private _shadowOffsetY;
  61135. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  61136. shadowOffsetY: number;
  61137. private _shadowBlur;
  61138. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  61139. shadowBlur: number;
  61140. private _shadowColor;
  61141. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  61142. shadowColor: string;
  61143. /** Gets or sets the cursor to use when the control is hovered */
  61144. hoverCursor: string;
  61145. /** @hidden */
  61146. protected _linkOffsetX: ValueAndUnit;
  61147. /** @hidden */
  61148. protected _linkOffsetY: ValueAndUnit;
  61149. /** Gets the control type name */
  61150. readonly typeName: string;
  61151. /**
  61152. * Get the current class name of the control.
  61153. * @returns current class name
  61154. */
  61155. getClassName(): string;
  61156. /**
  61157. * An event triggered when the pointer move over the control.
  61158. */
  61159. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  61160. /**
  61161. * An event triggered when the pointer move out of the control.
  61162. */
  61163. onPointerOutObservable: BABYLON.Observable<Control>;
  61164. /**
  61165. * An event triggered when the pointer taps the control
  61166. */
  61167. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  61168. /**
  61169. * An event triggered when pointer up
  61170. */
  61171. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  61172. /**
  61173. * An event triggered when a control is clicked on
  61174. */
  61175. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  61176. /**
  61177. * An event triggered when pointer enters the control
  61178. */
  61179. onPointerEnterObservable: BABYLON.Observable<Control>;
  61180. /**
  61181. * An event triggered when the control is marked as dirty
  61182. */
  61183. onDirtyObservable: BABYLON.Observable<Control>;
  61184. /**
  61185. * An event triggered before drawing the control
  61186. */
  61187. onBeforeDrawObservable: BABYLON.Observable<Control>;
  61188. /**
  61189. * An event triggered after the control was drawn
  61190. */
  61191. onAfterDrawObservable: BABYLON.Observable<Control>;
  61192. /**
  61193. * Get the hosting AdvancedDynamicTexture
  61194. */
  61195. readonly host: AdvancedDynamicTexture;
  61196. /** Gets or set information about font offsets (used to render and align text) */
  61197. fontOffset: {
  61198. ascent: number;
  61199. height: number;
  61200. descent: number;
  61201. };
  61202. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  61203. alpha: number;
  61204. /**
  61205. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  61206. */
  61207. isHighlighted: boolean;
  61208. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  61209. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61210. */
  61211. scaleX: number;
  61212. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  61213. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61214. */
  61215. scaleY: number;
  61216. /** Gets or sets the rotation angle (0 by default)
  61217. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61218. */
  61219. rotation: number;
  61220. /** Gets or sets the transformation center on Y axis (0 by default)
  61221. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61222. */
  61223. transformCenterY: number;
  61224. /** Gets or sets the transformation center on X axis (0 by default)
  61225. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61226. */
  61227. transformCenterX: number;
  61228. /**
  61229. * Gets or sets the horizontal alignment
  61230. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61231. */
  61232. horizontalAlignment: number;
  61233. /**
  61234. * Gets or sets the vertical alignment
  61235. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61236. */
  61237. verticalAlignment: number;
  61238. /**
  61239. * Gets or sets control width
  61240. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61241. */
  61242. width: string | number;
  61243. /**
  61244. * Gets or sets the control width in pixel
  61245. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61246. */
  61247. widthInPixels: number;
  61248. /**
  61249. * Gets or sets control height
  61250. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61251. */
  61252. height: string | number;
  61253. /**
  61254. * Gets or sets control height in pixel
  61255. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61256. */
  61257. heightInPixels: number;
  61258. /** Gets or set font family */
  61259. fontFamily: string;
  61260. /** Gets or sets font style */
  61261. fontStyle: string;
  61262. /** Gets or sets font weight */
  61263. fontWeight: string;
  61264. /**
  61265. * Gets or sets style
  61266. * @see http://doc.babylonjs.com/how_to/gui#styles
  61267. */
  61268. style: BABYLON.Nullable<Style>;
  61269. /** @hidden */
  61270. readonly _isFontSizeInPercentage: boolean;
  61271. /** Gets or sets font size in pixels */
  61272. fontSizeInPixels: number;
  61273. /** Gets or sets font size */
  61274. fontSize: string | number;
  61275. /** Gets or sets foreground color */
  61276. color: string;
  61277. /** Gets or sets z index which is used to reorder controls on the z axis */
  61278. zIndex: number;
  61279. /** Gets or sets a boolean indicating if the control can be rendered */
  61280. notRenderable: boolean;
  61281. /** Gets or sets a boolean indicating if the control is visible */
  61282. isVisible: boolean;
  61283. /** Gets a boolean indicating that the control needs to update its rendering */
  61284. readonly isDirty: boolean;
  61285. /**
  61286. * Gets the current linked mesh (or null if none)
  61287. */
  61288. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61289. /**
  61290. * Gets or sets a value indicating the padding to use on the left of the control
  61291. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61292. */
  61293. paddingLeft: string | number;
  61294. /**
  61295. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  61296. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61297. */
  61298. paddingLeftInPixels: number;
  61299. /**
  61300. * Gets or sets a value indicating the padding to use on the right of the control
  61301. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61302. */
  61303. paddingRight: string | number;
  61304. /**
  61305. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  61306. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61307. */
  61308. paddingRightInPixels: number;
  61309. /**
  61310. * Gets or sets a value indicating the padding to use on the top of the control
  61311. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61312. */
  61313. paddingTop: string | number;
  61314. /**
  61315. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  61316. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61317. */
  61318. paddingTopInPixels: number;
  61319. /**
  61320. * Gets or sets a value indicating the padding to use on the bottom of the control
  61321. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61322. */
  61323. paddingBottom: string | number;
  61324. /**
  61325. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  61326. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61327. */
  61328. paddingBottomInPixels: number;
  61329. /**
  61330. * Gets or sets a value indicating the left coordinate of the control
  61331. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61332. */
  61333. left: string | number;
  61334. /**
  61335. * Gets or sets a value indicating the left coordinate in pixels of the control
  61336. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61337. */
  61338. leftInPixels: number;
  61339. /**
  61340. * Gets or sets a value indicating the top coordinate of the control
  61341. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61342. */
  61343. top: string | number;
  61344. /**
  61345. * Gets or sets a value indicating the top coordinate in pixels of the control
  61346. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61347. */
  61348. topInPixels: number;
  61349. /**
  61350. * Gets or sets a value indicating the offset on X axis to the linked mesh
  61351. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61352. */
  61353. linkOffsetX: string | number;
  61354. /**
  61355. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  61356. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61357. */
  61358. linkOffsetXInPixels: number;
  61359. /**
  61360. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  61361. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61362. */
  61363. linkOffsetY: string | number;
  61364. /**
  61365. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  61366. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61367. */
  61368. linkOffsetYInPixels: number;
  61369. /** Gets the center coordinate on X axis */
  61370. readonly centerX: number;
  61371. /** Gets the center coordinate on Y axis */
  61372. readonly centerY: number;
  61373. /** Gets or sets if control is Enabled*/
  61374. isEnabled: boolean;
  61375. /** Gets or sets background color of control if it's disabled*/
  61376. disabledColor: string;
  61377. /**
  61378. * Creates a new control
  61379. * @param name defines the name of the control
  61380. */
  61381. constructor(
  61382. /** defines the name of the control */
  61383. name?: string | undefined);
  61384. /** @hidden */
  61385. protected _getTypeName(): string;
  61386. /**
  61387. * Gets the first ascendant in the hierarchy of the given type
  61388. * @param className defines the required type
  61389. * @returns the ascendant or null if not found
  61390. */
  61391. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  61392. /** @hidden */
  61393. _resetFontCache(): void;
  61394. /**
  61395. * Determines if a container is an ascendant of the current control
  61396. * @param container defines the container to look for
  61397. * @returns true if the container is one of the ascendant of the control
  61398. */
  61399. isAscendant(container: Control): boolean;
  61400. /**
  61401. * Gets coordinates in local control space
  61402. * @param globalCoordinates defines the coordinates to transform
  61403. * @returns the new coordinates in local space
  61404. */
  61405. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61406. /**
  61407. * Gets coordinates in local control space
  61408. * @param globalCoordinates defines the coordinates to transform
  61409. * @param result defines the target vector2 where to store the result
  61410. * @returns the current control
  61411. */
  61412. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  61413. /**
  61414. * Gets coordinates in parent local control space
  61415. * @param globalCoordinates defines the coordinates to transform
  61416. * @returns the new coordinates in parent local space
  61417. */
  61418. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61419. /**
  61420. * Move the current control to a vector3 position projected onto the screen.
  61421. * @param position defines the target position
  61422. * @param scene defines the hosting scene
  61423. */
  61424. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  61425. /** @hidden */
  61426. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61427. /**
  61428. * Will return all controls that have this control as ascendant
  61429. * @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
  61430. * @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
  61431. * @return all child controls
  61432. */
  61433. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  61434. /**
  61435. * Link current control with a target mesh
  61436. * @param mesh defines the mesh to link with
  61437. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61438. */
  61439. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  61440. /** @hidden */
  61441. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  61442. /** @hidden */
  61443. _offsetLeft(offset: number): void;
  61444. /** @hidden */
  61445. _offsetTop(offset: number): void;
  61446. /** @hidden */
  61447. _markMatrixAsDirty(): void;
  61448. /** @hidden */
  61449. _flagDescendantsAsMatrixDirty(): void;
  61450. /** @hidden */
  61451. _intersectsRect(rect: Measure): boolean;
  61452. /** @hidden */
  61453. protected invalidateRect(): void;
  61454. /** @hidden */
  61455. _markAsDirty(force?: boolean): void;
  61456. /** @hidden */
  61457. _markAllAsDirty(): void;
  61458. /** @hidden */
  61459. _link(host: AdvancedDynamicTexture): void;
  61460. /** @hidden */
  61461. protected _transform(context?: CanvasRenderingContext2D): void;
  61462. /** @hidden */
  61463. _renderHighlight(context: CanvasRenderingContext2D): void;
  61464. /** @hidden */
  61465. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61466. /** @hidden */
  61467. protected _applyStates(context: CanvasRenderingContext2D): void;
  61468. /** @hidden */
  61469. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61470. /** @hidden */
  61471. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61472. protected _evaluateClippingState(parentMeasure: Measure): void;
  61473. /** @hidden */
  61474. _measure(): void;
  61475. /** @hidden */
  61476. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61477. /** @hidden */
  61478. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61479. /** @hidden */
  61480. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61481. /** @hidden */
  61482. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61483. private static _ClipMeasure;
  61484. private _tmpMeasureA;
  61485. private _clip;
  61486. /** @hidden */
  61487. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  61488. /** @hidden */
  61489. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  61490. /**
  61491. * Tests if a given coordinates belong to the current control
  61492. * @param x defines x coordinate to test
  61493. * @param y defines y coordinate to test
  61494. * @returns true if the coordinates are inside the control
  61495. */
  61496. contains(x: number, y: number): boolean;
  61497. /** @hidden */
  61498. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61499. /** @hidden */
  61500. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61501. /** @hidden */
  61502. _onPointerEnter(target: Control): boolean;
  61503. /** @hidden */
  61504. _onPointerOut(target: Control, force?: boolean): void;
  61505. /** @hidden */
  61506. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61507. /** @hidden */
  61508. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61509. /** @hidden */
  61510. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  61511. /** @hidden */
  61512. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  61513. private _prepareFont;
  61514. /** Releases associated resources */
  61515. dispose(): void;
  61516. private static _HORIZONTAL_ALIGNMENT_LEFT;
  61517. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  61518. private static _HORIZONTAL_ALIGNMENT_CENTER;
  61519. private static _VERTICAL_ALIGNMENT_TOP;
  61520. private static _VERTICAL_ALIGNMENT_BOTTOM;
  61521. private static _VERTICAL_ALIGNMENT_CENTER;
  61522. /** HORIZONTAL_ALIGNMENT_LEFT */
  61523. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  61524. /** HORIZONTAL_ALIGNMENT_RIGHT */
  61525. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  61526. /** HORIZONTAL_ALIGNMENT_CENTER */
  61527. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  61528. /** VERTICAL_ALIGNMENT_TOP */
  61529. static readonly VERTICAL_ALIGNMENT_TOP: number;
  61530. /** VERTICAL_ALIGNMENT_BOTTOM */
  61531. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  61532. /** VERTICAL_ALIGNMENT_CENTER */
  61533. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  61534. private static _FontHeightSizes;
  61535. /** @hidden */
  61536. static _GetFontOffset(font: string): {
  61537. ascent: number;
  61538. height: number;
  61539. descent: number;
  61540. };
  61541. /**
  61542. * Creates a stack panel that can be used to render headers
  61543. * @param control defines the control to associate with the header
  61544. * @param text defines the text of the header
  61545. * @param size defines the size of the header
  61546. * @param options defines options used to configure the header
  61547. * @returns a new StackPanel
  61548. * @ignore
  61549. * @hidden
  61550. */
  61551. static AddHeader: (control: Control, text: string, size: string | number, options: {
  61552. isHorizontal: boolean;
  61553. controlFirst: boolean;
  61554. }) => any;
  61555. /** @hidden */
  61556. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  61557. }
  61558. }
  61559. declare module BABYLON.GUI {
  61560. /**
  61561. * Root class for 2D containers
  61562. * @see http://doc.babylonjs.com/how_to/gui#containers
  61563. */
  61564. export class Container extends Control {
  61565. name?: string | undefined;
  61566. /** @hidden */
  61567. protected _children: Control[];
  61568. /** @hidden */
  61569. protected _measureForChildren: Measure;
  61570. /** @hidden */
  61571. protected _background: string;
  61572. /** @hidden */
  61573. protected _adaptWidthToChildren: boolean;
  61574. /** @hidden */
  61575. protected _adaptHeightToChildren: boolean;
  61576. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  61577. adaptHeightToChildren: boolean;
  61578. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  61579. adaptWidthToChildren: boolean;
  61580. /** Gets or sets background color */
  61581. background: string;
  61582. /** Gets the list of children */
  61583. readonly children: Control[];
  61584. /**
  61585. * Creates a new Container
  61586. * @param name defines the name of the container
  61587. */
  61588. constructor(name?: string | undefined);
  61589. protected _getTypeName(): string;
  61590. _flagDescendantsAsMatrixDirty(): void;
  61591. /**
  61592. * Gets a child using its name
  61593. * @param name defines the child name to look for
  61594. * @returns the child control if found
  61595. */
  61596. getChildByName(name: string): BABYLON.Nullable<Control>;
  61597. /**
  61598. * Gets a child using its type and its name
  61599. * @param name defines the child name to look for
  61600. * @param type defines the child type to look for
  61601. * @returns the child control if found
  61602. */
  61603. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  61604. /**
  61605. * Search for a specific control in children
  61606. * @param control defines the control to look for
  61607. * @returns true if the control is in child list
  61608. */
  61609. containsControl(control: Control): boolean;
  61610. /**
  61611. * Adds a new control to the current container
  61612. * @param control defines the control to add
  61613. * @returns the current container
  61614. */
  61615. addControl(control: BABYLON.Nullable<Control>): Container;
  61616. /**
  61617. * Removes all controls from the current container
  61618. * @returns the current container
  61619. */
  61620. clearControls(): Container;
  61621. /**
  61622. * Removes a control from the current container
  61623. * @param control defines the control to remove
  61624. * @returns the current container
  61625. */
  61626. removeControl(control: Control): Container;
  61627. /** @hidden */
  61628. _reOrderControl(control: Control): void;
  61629. /** @hidden */
  61630. _offsetLeft(offset: number): void;
  61631. /** @hidden */
  61632. _offsetTop(offset: number): void;
  61633. /** @hidden */
  61634. _markAllAsDirty(): void;
  61635. /** @hidden */
  61636. protected _localDraw(context: CanvasRenderingContext2D): void;
  61637. /** @hidden */
  61638. _link(host: AdvancedDynamicTexture): void;
  61639. /** @hidden */
  61640. protected _beforeLayout(): void;
  61641. /** @hidden */
  61642. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61643. /** @hidden */
  61644. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61645. protected _postMeasure(): void;
  61646. /** @hidden */
  61647. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  61648. /** @hidden */
  61649. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61650. /** @hidden */
  61651. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61652. /** @hidden */
  61653. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61654. /** Releases associated resources */
  61655. dispose(): void;
  61656. }
  61657. }
  61658. declare module BABYLON.GUI {
  61659. /** Class used to create rectangle container */
  61660. export class Rectangle extends Container {
  61661. name?: string | undefined;
  61662. private _thickness;
  61663. private _cornerRadius;
  61664. /** Gets or sets border thickness */
  61665. thickness: number;
  61666. /** Gets or sets the corner radius angle */
  61667. cornerRadius: number;
  61668. /**
  61669. * Creates a new Rectangle
  61670. * @param name defines the control name
  61671. */
  61672. constructor(name?: string | undefined);
  61673. protected _getTypeName(): string;
  61674. protected _localDraw(context: CanvasRenderingContext2D): void;
  61675. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61676. private _drawRoundedRect;
  61677. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61678. }
  61679. }
  61680. declare module BABYLON.GUI {
  61681. /**
  61682. * Enum that determines the text-wrapping mode to use.
  61683. */
  61684. export enum TextWrapping {
  61685. /**
  61686. * Clip the text when it's larger than Control.width; this is the default mode.
  61687. */
  61688. Clip = 0,
  61689. /**
  61690. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  61691. */
  61692. WordWrap = 1,
  61693. /**
  61694. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  61695. */
  61696. Ellipsis = 2
  61697. }
  61698. /**
  61699. * Class used to create text block control
  61700. */
  61701. export class TextBlock extends Control {
  61702. /**
  61703. * Defines the name of the control
  61704. */
  61705. name?: string | undefined;
  61706. private _text;
  61707. private _textWrapping;
  61708. private _textHorizontalAlignment;
  61709. private _textVerticalAlignment;
  61710. private _lines;
  61711. private _resizeToFit;
  61712. private _lineSpacing;
  61713. private _outlineWidth;
  61714. private _outlineColor;
  61715. /**
  61716. * An event triggered after the text is changed
  61717. */
  61718. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  61719. /**
  61720. * An event triggered after the text was broken up into lines
  61721. */
  61722. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  61723. /**
  61724. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  61725. */
  61726. readonly lines: any[];
  61727. /**
  61728. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61729. */
  61730. /**
  61731. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61732. */
  61733. resizeToFit: boolean;
  61734. /**
  61735. * Gets or sets a boolean indicating if text must be wrapped
  61736. */
  61737. /**
  61738. * Gets or sets a boolean indicating if text must be wrapped
  61739. */
  61740. textWrapping: TextWrapping | boolean;
  61741. /**
  61742. * Gets or sets text to display
  61743. */
  61744. /**
  61745. * Gets or sets text to display
  61746. */
  61747. text: string;
  61748. /**
  61749. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61750. */
  61751. /**
  61752. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61753. */
  61754. textHorizontalAlignment: number;
  61755. /**
  61756. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61757. */
  61758. /**
  61759. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61760. */
  61761. textVerticalAlignment: number;
  61762. /**
  61763. * Gets or sets line spacing value
  61764. */
  61765. /**
  61766. * Gets or sets line spacing value
  61767. */
  61768. lineSpacing: string | number;
  61769. /**
  61770. * Gets or sets outlineWidth of the text to display
  61771. */
  61772. /**
  61773. * Gets or sets outlineWidth of the text to display
  61774. */
  61775. outlineWidth: number;
  61776. /**
  61777. * Gets or sets outlineColor of the text to display
  61778. */
  61779. /**
  61780. * Gets or sets outlineColor of the text to display
  61781. */
  61782. outlineColor: string;
  61783. /**
  61784. * Creates a new TextBlock object
  61785. * @param name defines the name of the control
  61786. * @param text defines the text to display (emptry string by default)
  61787. */
  61788. constructor(
  61789. /**
  61790. * Defines the name of the control
  61791. */
  61792. name?: string | undefined, text?: string);
  61793. protected _getTypeName(): string;
  61794. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61795. private _drawText;
  61796. /** @hidden */
  61797. _draw(context: CanvasRenderingContext2D): void;
  61798. protected _applyStates(context: CanvasRenderingContext2D): void;
  61799. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  61800. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  61801. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  61802. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  61803. protected _renderLines(context: CanvasRenderingContext2D): void;
  61804. /**
  61805. * Given a width constraint applied on the text block, find the expected height
  61806. * @returns expected height
  61807. */
  61808. computeExpectedHeight(): number;
  61809. dispose(): void;
  61810. }
  61811. }
  61812. declare module BABYLON.GUI {
  61813. /**
  61814. * Class used to create 2D images
  61815. */
  61816. export class Image extends Control {
  61817. name?: string | undefined;
  61818. private static _WorkingCanvas;
  61819. private _domImage;
  61820. private _imageWidth;
  61821. private _imageHeight;
  61822. private _loaded;
  61823. private _stretch;
  61824. private _source;
  61825. private _autoScale;
  61826. private _sourceLeft;
  61827. private _sourceTop;
  61828. private _sourceWidth;
  61829. private _sourceHeight;
  61830. private _cellWidth;
  61831. private _cellHeight;
  61832. private _cellId;
  61833. private _populateNinePatchSlicesFromImage;
  61834. private _sliceLeft;
  61835. private _sliceRight;
  61836. private _sliceTop;
  61837. private _sliceBottom;
  61838. private _detectPointerOnOpaqueOnly;
  61839. /**
  61840. * BABYLON.Observable notified when the content is loaded
  61841. */
  61842. onImageLoadedObservable: BABYLON.Observable<Image>;
  61843. /**
  61844. * Gets a boolean indicating that the content is loaded
  61845. */
  61846. readonly isLoaded: boolean;
  61847. /**
  61848. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  61849. */
  61850. populateNinePatchSlicesFromImage: boolean;
  61851. /**
  61852. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  61853. * Beware using this as this will comsume more memory as the image has to be stored twice
  61854. */
  61855. detectPointerOnOpaqueOnly: boolean;
  61856. /**
  61857. * Gets or sets the left value for slicing (9-patch)
  61858. */
  61859. sliceLeft: number;
  61860. /**
  61861. * Gets or sets the right value for slicing (9-patch)
  61862. */
  61863. sliceRight: number;
  61864. /**
  61865. * Gets or sets the top value for slicing (9-patch)
  61866. */
  61867. sliceTop: number;
  61868. /**
  61869. * Gets or sets the bottom value for slicing (9-patch)
  61870. */
  61871. sliceBottom: number;
  61872. /**
  61873. * Gets or sets the left coordinate in the source image
  61874. */
  61875. sourceLeft: number;
  61876. /**
  61877. * Gets or sets the top coordinate in the source image
  61878. */
  61879. sourceTop: number;
  61880. /**
  61881. * Gets or sets the width to capture in the source image
  61882. */
  61883. sourceWidth: number;
  61884. /**
  61885. * Gets or sets the height to capture in the source image
  61886. */
  61887. sourceHeight: number;
  61888. /**
  61889. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  61890. * @see http://doc.babylonjs.com/how_to/gui#image
  61891. */
  61892. autoScale: boolean;
  61893. /** Gets or sets the streching mode used by the image */
  61894. stretch: number;
  61895. /**
  61896. * Gets or sets the internal DOM image used to render the control
  61897. */
  61898. domImage: HTMLImageElement;
  61899. private _onImageLoaded;
  61900. private _extractNinePatchSliceDataFromImage;
  61901. /**
  61902. * Gets or sets image source url
  61903. */
  61904. source: BABYLON.Nullable<string>;
  61905. /**
  61906. * Gets or sets the cell width to use when animation sheet is enabled
  61907. * @see http://doc.babylonjs.com/how_to/gui#image
  61908. */
  61909. cellWidth: number;
  61910. /**
  61911. * Gets or sets the cell height to use when animation sheet is enabled
  61912. * @see http://doc.babylonjs.com/how_to/gui#image
  61913. */
  61914. cellHeight: number;
  61915. /**
  61916. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  61917. * @see http://doc.babylonjs.com/how_to/gui#image
  61918. */
  61919. cellId: number;
  61920. /**
  61921. * Creates a new Image
  61922. * @param name defines the control name
  61923. * @param url defines the image url
  61924. */
  61925. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  61926. /**
  61927. * Tests if a given coordinates belong to the current control
  61928. * @param x defines x coordinate to test
  61929. * @param y defines y coordinate to test
  61930. * @returns true if the coordinates are inside the control
  61931. */
  61932. contains(x: number, y: number): boolean;
  61933. protected _getTypeName(): string;
  61934. /** Force the control to synchronize with its content */
  61935. synchronizeSizeWithContent(): void;
  61936. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61937. private _prepareWorkingCanvasForOpaqueDetection;
  61938. private _drawImage;
  61939. _draw(context: CanvasRenderingContext2D): void;
  61940. private _renderCornerPatch;
  61941. private _renderNinePatch;
  61942. dispose(): void;
  61943. /** STRETCH_NONE */
  61944. static readonly STRETCH_NONE: number;
  61945. /** STRETCH_FILL */
  61946. static readonly STRETCH_FILL: number;
  61947. /** STRETCH_UNIFORM */
  61948. static readonly STRETCH_UNIFORM: number;
  61949. /** STRETCH_EXTEND */
  61950. static readonly STRETCH_EXTEND: number;
  61951. /** NINE_PATCH */
  61952. static readonly STRETCH_NINE_PATCH: number;
  61953. }
  61954. }
  61955. declare module BABYLON.GUI {
  61956. /**
  61957. * Class used to create 2D buttons
  61958. */
  61959. export class Button extends Rectangle {
  61960. name?: string | undefined;
  61961. /**
  61962. * Function called to generate a pointer enter animation
  61963. */
  61964. pointerEnterAnimation: () => void;
  61965. /**
  61966. * Function called to generate a pointer out animation
  61967. */
  61968. pointerOutAnimation: () => void;
  61969. /**
  61970. * Function called to generate a pointer down animation
  61971. */
  61972. pointerDownAnimation: () => void;
  61973. /**
  61974. * Function called to generate a pointer up animation
  61975. */
  61976. pointerUpAnimation: () => void;
  61977. private _image;
  61978. /**
  61979. * Returns the image part of the button (if any)
  61980. */
  61981. readonly image: BABYLON.Nullable<Image>;
  61982. private _textBlock;
  61983. /**
  61984. * Returns the image part of the button (if any)
  61985. */
  61986. readonly textBlock: BABYLON.Nullable<TextBlock>;
  61987. /**
  61988. * Creates a new Button
  61989. * @param name defines the name of the button
  61990. */
  61991. constructor(name?: string | undefined);
  61992. protected _getTypeName(): string;
  61993. /** @hidden */
  61994. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61995. /** @hidden */
  61996. _onPointerEnter(target: Control): boolean;
  61997. /** @hidden */
  61998. _onPointerOut(target: Control, force?: boolean): void;
  61999. /** @hidden */
  62000. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62001. /** @hidden */
  62002. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62003. /**
  62004. * Creates a new button made with an image and a text
  62005. * @param name defines the name of the button
  62006. * @param text defines the text of the button
  62007. * @param imageUrl defines the url of the image
  62008. * @returns a new Button
  62009. */
  62010. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  62011. /**
  62012. * Creates a new button made with an image
  62013. * @param name defines the name of the button
  62014. * @param imageUrl defines the url of the image
  62015. * @returns a new Button
  62016. */
  62017. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  62018. /**
  62019. * Creates a new button made with a text
  62020. * @param name defines the name of the button
  62021. * @param text defines the text of the button
  62022. * @returns a new Button
  62023. */
  62024. static CreateSimpleButton(name: string, text: string): Button;
  62025. /**
  62026. * Creates a new button made with an image and a centered text
  62027. * @param name defines the name of the button
  62028. * @param text defines the text of the button
  62029. * @param imageUrl defines the url of the image
  62030. * @returns a new Button
  62031. */
  62032. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  62033. }
  62034. }
  62035. declare module BABYLON.GUI {
  62036. /**
  62037. * Class used to create a 2D stack panel container
  62038. */
  62039. export class StackPanel extends Container {
  62040. name?: string | undefined;
  62041. private _isVertical;
  62042. private _manualWidth;
  62043. private _manualHeight;
  62044. private _doNotTrackManualChanges;
  62045. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  62046. isVertical: boolean;
  62047. /**
  62048. * Gets or sets panel width.
  62049. * This value should not be set when in horizontal mode as it will be computed automatically
  62050. */
  62051. width: string | number;
  62052. /**
  62053. * Gets or sets panel height.
  62054. * This value should not be set when in vertical mode as it will be computed automatically
  62055. */
  62056. height: string | number;
  62057. /**
  62058. * Creates a new StackPanel
  62059. * @param name defines control name
  62060. */
  62061. constructor(name?: string | undefined);
  62062. protected _getTypeName(): string;
  62063. /** @hidden */
  62064. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62065. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62066. protected _postMeasure(): void;
  62067. }
  62068. }
  62069. declare module BABYLON.GUI {
  62070. /**
  62071. * Class used to represent a 2D checkbox
  62072. */
  62073. export class Checkbox extends Control {
  62074. name?: string | undefined;
  62075. private _isChecked;
  62076. private _background;
  62077. private _checkSizeRatio;
  62078. private _thickness;
  62079. /** Gets or sets border thickness */
  62080. thickness: number;
  62081. /**
  62082. * BABYLON.Observable raised when isChecked property changes
  62083. */
  62084. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62085. /** Gets or sets a value indicating the ratio between overall size and check size */
  62086. checkSizeRatio: number;
  62087. /** Gets or sets background color */
  62088. background: string;
  62089. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62090. isChecked: boolean;
  62091. /**
  62092. * Creates a new CheckBox
  62093. * @param name defines the control name
  62094. */
  62095. constructor(name?: string | undefined);
  62096. protected _getTypeName(): string;
  62097. /** @hidden */
  62098. _draw(context: CanvasRenderingContext2D): void;
  62099. /** @hidden */
  62100. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62101. /**
  62102. * Utility function to easily create a checkbox with a header
  62103. * @param title defines the label to use for the header
  62104. * @param onValueChanged defines the callback to call when value changes
  62105. * @returns a StackPanel containing the checkbox and a textBlock
  62106. */
  62107. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  62108. }
  62109. }
  62110. declare module BABYLON.GUI {
  62111. /**
  62112. * Class used to store key control properties
  62113. */
  62114. export class KeyPropertySet {
  62115. /** Width */
  62116. width?: string;
  62117. /** Height */
  62118. height?: string;
  62119. /** Left padding */
  62120. paddingLeft?: string;
  62121. /** Right padding */
  62122. paddingRight?: string;
  62123. /** Top padding */
  62124. paddingTop?: string;
  62125. /** Bottom padding */
  62126. paddingBottom?: string;
  62127. /** Foreground color */
  62128. color?: string;
  62129. /** Background color */
  62130. background?: string;
  62131. }
  62132. /**
  62133. * Class used to create virtual keyboard
  62134. */
  62135. export class VirtualKeyboard extends StackPanel {
  62136. /** BABYLON.Observable raised when a key is pressed */
  62137. onKeyPressObservable: BABYLON.Observable<string>;
  62138. /** Gets or sets default key button width */
  62139. defaultButtonWidth: string;
  62140. /** Gets or sets default key button height */
  62141. defaultButtonHeight: string;
  62142. /** Gets or sets default key button left padding */
  62143. defaultButtonPaddingLeft: string;
  62144. /** Gets or sets default key button right padding */
  62145. defaultButtonPaddingRight: string;
  62146. /** Gets or sets default key button top padding */
  62147. defaultButtonPaddingTop: string;
  62148. /** Gets or sets default key button bottom padding */
  62149. defaultButtonPaddingBottom: string;
  62150. /** Gets or sets default key button foreground color */
  62151. defaultButtonColor: string;
  62152. /** Gets or sets default key button background color */
  62153. defaultButtonBackground: string;
  62154. /** Gets or sets shift button foreground color */
  62155. shiftButtonColor: string;
  62156. /** Gets or sets shift button thickness*/
  62157. selectedShiftThickness: number;
  62158. /** Gets shift key state */
  62159. shiftState: number;
  62160. protected _getTypeName(): string;
  62161. private _createKey;
  62162. /**
  62163. * Adds a new row of keys
  62164. * @param keys defines the list of keys to add
  62165. * @param propertySets defines the associated property sets
  62166. */
  62167. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  62168. /**
  62169. * Set the shift key to a specific state
  62170. * @param shiftState defines the new shift state
  62171. */
  62172. applyShiftState(shiftState: number): void;
  62173. private _currentlyConnectedInputText;
  62174. private _connectedInputTexts;
  62175. private _onKeyPressObserver;
  62176. /** Gets the input text control currently attached to the keyboard */
  62177. readonly connectedInputText: BABYLON.Nullable<InputText>;
  62178. /**
  62179. * Connects the keyboard with an input text control
  62180. *
  62181. * @param input defines the target control
  62182. */
  62183. connect(input: InputText): void;
  62184. /**
  62185. * Disconnects the keyboard from connected InputText controls
  62186. *
  62187. * @param input optionally defines a target control, otherwise all are disconnected
  62188. */
  62189. disconnect(input?: InputText): void;
  62190. private _removeConnectedInputObservables;
  62191. /**
  62192. * Release all resources
  62193. */
  62194. dispose(): void;
  62195. /**
  62196. * Creates a new keyboard using a default layout
  62197. *
  62198. * @param name defines control name
  62199. * @returns a new VirtualKeyboard
  62200. */
  62201. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  62202. }
  62203. }
  62204. declare module BABYLON.GUI {
  62205. /**
  62206. * Class used to create input text control
  62207. */
  62208. export class InputText extends Control implements IFocusableControl {
  62209. name?: string | undefined;
  62210. private _text;
  62211. private _placeholderText;
  62212. private _background;
  62213. private _focusedBackground;
  62214. private _focusedColor;
  62215. private _placeholderColor;
  62216. private _thickness;
  62217. private _margin;
  62218. private _autoStretchWidth;
  62219. private _maxWidth;
  62220. private _isFocused;
  62221. private _blinkTimeout;
  62222. private _blinkIsEven;
  62223. private _cursorOffset;
  62224. private _scrollLeft;
  62225. private _textWidth;
  62226. private _clickedCoordinate;
  62227. private _deadKey;
  62228. private _addKey;
  62229. private _currentKey;
  62230. private _isTextHighlightOn;
  62231. private _textHighlightColor;
  62232. private _highligherOpacity;
  62233. private _highlightedText;
  62234. private _startHighlightIndex;
  62235. private _endHighlightIndex;
  62236. private _cursorIndex;
  62237. private _onFocusSelectAll;
  62238. private _isPointerDown;
  62239. private _onClipboardObserver;
  62240. private _onPointerDblTapObserver;
  62241. /** @hidden */
  62242. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  62243. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  62244. promptMessage: string;
  62245. /** Force disable prompt on mobile device */
  62246. disableMobilePrompt: boolean;
  62247. /** BABYLON.Observable raised when the text changes */
  62248. onTextChangedObservable: BABYLON.Observable<InputText>;
  62249. /** BABYLON.Observable raised just before an entered character is to be added */
  62250. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  62251. /** BABYLON.Observable raised when the control gets the focus */
  62252. onFocusObservable: BABYLON.Observable<InputText>;
  62253. /** BABYLON.Observable raised when the control loses the focus */
  62254. onBlurObservable: BABYLON.Observable<InputText>;
  62255. /**Observable raised when the text is highlighted */
  62256. onTextHighlightObservable: BABYLON.Observable<InputText>;
  62257. /**Observable raised when copy event is triggered */
  62258. onTextCopyObservable: BABYLON.Observable<InputText>;
  62259. /** BABYLON.Observable raised when cut event is triggered */
  62260. onTextCutObservable: BABYLON.Observable<InputText>;
  62261. /** BABYLON.Observable raised when paste event is triggered */
  62262. onTextPasteObservable: BABYLON.Observable<InputText>;
  62263. /** BABYLON.Observable raised when a key event was processed */
  62264. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  62265. /** Gets or sets the maximum width allowed by the control */
  62266. maxWidth: string | number;
  62267. /** Gets the maximum width allowed by the control in pixels */
  62268. readonly maxWidthInPixels: number;
  62269. /** Gets or sets the text highlighter transparency; default: 0.4 */
  62270. highligherOpacity: number;
  62271. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  62272. onFocusSelectAll: boolean;
  62273. /** Gets or sets the text hightlight color */
  62274. textHighlightColor: string;
  62275. /** Gets or sets control margin */
  62276. margin: string;
  62277. /** Gets control margin in pixels */
  62278. readonly marginInPixels: number;
  62279. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  62280. autoStretchWidth: boolean;
  62281. /** Gets or sets border thickness */
  62282. thickness: number;
  62283. /** Gets or sets the background color when focused */
  62284. focusedBackground: string;
  62285. /** Gets or sets the background color when focused */
  62286. focusedColor: string;
  62287. /** Gets or sets the background color */
  62288. background: string;
  62289. /** Gets or sets the placeholder color */
  62290. placeholderColor: string;
  62291. /** Gets or sets the text displayed when the control is empty */
  62292. placeholderText: string;
  62293. /** Gets or sets the dead key flag */
  62294. deadKey: boolean;
  62295. /** Gets or sets the highlight text */
  62296. highlightedText: string;
  62297. /** Gets or sets if the current key should be added */
  62298. addKey: boolean;
  62299. /** Gets or sets the value of the current key being entered */
  62300. currentKey: string;
  62301. /** Gets or sets the text displayed in the control */
  62302. text: string;
  62303. /** Gets or sets control width */
  62304. width: string | number;
  62305. /**
  62306. * Creates a new InputText
  62307. * @param name defines the control name
  62308. * @param text defines the text of the control
  62309. */
  62310. constructor(name?: string | undefined, text?: string);
  62311. /** @hidden */
  62312. onBlur(): void;
  62313. /** @hidden */
  62314. onFocus(): void;
  62315. protected _getTypeName(): string;
  62316. /**
  62317. * Function called to get the list of controls that should not steal the focus from this control
  62318. * @returns an array of controls
  62319. */
  62320. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62321. /** @hidden */
  62322. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  62323. /** @hidden */
  62324. private _updateValueFromCursorIndex;
  62325. /** @hidden */
  62326. private _processDblClick;
  62327. /** @hidden */
  62328. private _selectAllText;
  62329. /**
  62330. * Handles the keyboard event
  62331. * @param evt Defines the KeyboardEvent
  62332. */
  62333. processKeyboard(evt: KeyboardEvent): void;
  62334. /** @hidden */
  62335. private _onCopyText;
  62336. /** @hidden */
  62337. private _onCutText;
  62338. /** @hidden */
  62339. private _onPasteText;
  62340. _draw(context: CanvasRenderingContext2D): void;
  62341. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62342. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62343. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62344. protected _beforeRenderText(text: string): string;
  62345. dispose(): void;
  62346. }
  62347. }
  62348. declare module BABYLON.GUI {
  62349. /**
  62350. * Class used to create a 2D grid container
  62351. */
  62352. export class Grid extends Container {
  62353. name?: string | undefined;
  62354. private _rowDefinitions;
  62355. private _columnDefinitions;
  62356. private _cells;
  62357. private _childControls;
  62358. /**
  62359. * Gets the number of columns
  62360. */
  62361. readonly columnCount: number;
  62362. /**
  62363. * Gets the number of rows
  62364. */
  62365. readonly rowCount: number;
  62366. /** Gets the list of children */
  62367. readonly children: Control[];
  62368. /** Gets the list of cells (e.g. the containers) */
  62369. readonly cells: {
  62370. [key: string]: Container;
  62371. };
  62372. /**
  62373. * Gets the definition of a specific row
  62374. * @param index defines the index of the row
  62375. * @returns the row definition
  62376. */
  62377. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62378. /**
  62379. * Gets the definition of a specific column
  62380. * @param index defines the index of the column
  62381. * @returns the column definition
  62382. */
  62383. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62384. /**
  62385. * Adds a new row to the grid
  62386. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62387. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  62388. * @returns the current grid
  62389. */
  62390. addRowDefinition(height: number, isPixel?: boolean): Grid;
  62391. /**
  62392. * Adds a new column to the grid
  62393. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62394. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62395. * @returns the current grid
  62396. */
  62397. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  62398. /**
  62399. * Update a row definition
  62400. * @param index defines the index of the row to update
  62401. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62402. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  62403. * @returns the current grid
  62404. */
  62405. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  62406. /**
  62407. * Update a column definition
  62408. * @param index defines the index of the column to update
  62409. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62410. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62411. * @returns the current grid
  62412. */
  62413. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  62414. /**
  62415. * Gets the list of children stored in a specific cell
  62416. * @param row defines the row to check
  62417. * @param column defines the column to check
  62418. * @returns the list of controls
  62419. */
  62420. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  62421. /**
  62422. * Gets a string representing the child cell info (row x column)
  62423. * @param child defines the control to get info from
  62424. * @returns a string containing the child cell info (row x column)
  62425. */
  62426. getChildCellInfo(child: Control): string;
  62427. private _removeCell;
  62428. private _offsetCell;
  62429. /**
  62430. * Remove a column definition at specified index
  62431. * @param index defines the index of the column to remove
  62432. * @returns the current grid
  62433. */
  62434. removeColumnDefinition(index: number): Grid;
  62435. /**
  62436. * Remove a row definition at specified index
  62437. * @param index defines the index of the row to remove
  62438. * @returns the current grid
  62439. */
  62440. removeRowDefinition(index: number): Grid;
  62441. /**
  62442. * Adds a new control to the current grid
  62443. * @param control defines the control to add
  62444. * @param row defines the row where to add the control (0 by default)
  62445. * @param column defines the column where to add the control (0 by default)
  62446. * @returns the current grid
  62447. */
  62448. addControl(control: Control, row?: number, column?: number): Grid;
  62449. /**
  62450. * Removes a control from the current container
  62451. * @param control defines the control to remove
  62452. * @returns the current container
  62453. */
  62454. removeControl(control: Control): Container;
  62455. /**
  62456. * Creates a new Grid
  62457. * @param name defines control name
  62458. */
  62459. constructor(name?: string | undefined);
  62460. protected _getTypeName(): string;
  62461. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  62462. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62463. _flagDescendantsAsMatrixDirty(): void;
  62464. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62465. /** Releases associated resources */
  62466. dispose(): void;
  62467. }
  62468. }
  62469. declare module BABYLON.GUI {
  62470. /** Class used to create color pickers */
  62471. export class ColorPicker extends Control {
  62472. name?: string | undefined;
  62473. private static _Epsilon;
  62474. private _colorWheelCanvas;
  62475. private _value;
  62476. private _tmpColor;
  62477. private _pointerStartedOnSquare;
  62478. private _pointerStartedOnWheel;
  62479. private _squareLeft;
  62480. private _squareTop;
  62481. private _squareSize;
  62482. private _h;
  62483. private _s;
  62484. private _v;
  62485. private _lastPointerDownID;
  62486. /**
  62487. * BABYLON.Observable raised when the value changes
  62488. */
  62489. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  62490. /** Gets or sets the color of the color picker */
  62491. value: BABYLON.Color3;
  62492. /**
  62493. * Gets or sets control width
  62494. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62495. */
  62496. width: string | number;
  62497. /**
  62498. * Gets or sets control height
  62499. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62500. */
  62501. /** Gets or sets control height */
  62502. height: string | number;
  62503. /** Gets or sets control size */
  62504. size: string | number;
  62505. /**
  62506. * Creates a new ColorPicker
  62507. * @param name defines the control name
  62508. */
  62509. constructor(name?: string | undefined);
  62510. protected _getTypeName(): string;
  62511. /** @hidden */
  62512. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62513. private _updateSquareProps;
  62514. private _drawGradientSquare;
  62515. private _drawCircle;
  62516. private _createColorWheelCanvas;
  62517. /** @hidden */
  62518. _draw(context: CanvasRenderingContext2D): void;
  62519. private _pointerIsDown;
  62520. private _updateValueFromPointer;
  62521. private _isPointOnSquare;
  62522. private _isPointOnWheel;
  62523. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62524. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62525. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62526. /**
  62527. * This function expands the color picker by creating a color picker dialog with manual
  62528. * color value input and the ability to save colors into an array to be used later in
  62529. * subsequent launches of the dialogue.
  62530. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  62531. * @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.
  62532. * @returns picked color as a hex string and the saved colors array as hex strings.
  62533. */
  62534. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  62535. pickerWidth?: string;
  62536. pickerHeight?: string;
  62537. headerHeight?: string;
  62538. lastColor?: string;
  62539. swatchLimit?: number;
  62540. numSwatchesPerLine?: number;
  62541. savedColors?: Array<string>;
  62542. }): Promise<{
  62543. savedColors?: string[];
  62544. pickedColor: string;
  62545. }>;
  62546. }
  62547. }
  62548. declare module BABYLON.GUI {
  62549. /** Class used to create 2D ellipse containers */
  62550. export class Ellipse extends Container {
  62551. name?: string | undefined;
  62552. private _thickness;
  62553. /** Gets or sets border thickness */
  62554. thickness: number;
  62555. /**
  62556. * Creates a new Ellipse
  62557. * @param name defines the control name
  62558. */
  62559. constructor(name?: string | undefined);
  62560. protected _getTypeName(): string;
  62561. protected _localDraw(context: CanvasRenderingContext2D): void;
  62562. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62563. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62564. }
  62565. }
  62566. declare module BABYLON.GUI {
  62567. /**
  62568. * Class used to create a password control
  62569. */
  62570. export class InputPassword extends InputText {
  62571. protected _beforeRenderText(text: string): string;
  62572. }
  62573. }
  62574. declare module BABYLON.GUI {
  62575. /** Class used to render 2D lines */
  62576. export class Line extends Control {
  62577. name?: string | undefined;
  62578. private _lineWidth;
  62579. private _x1;
  62580. private _y1;
  62581. private _x2;
  62582. private _y2;
  62583. private _dash;
  62584. private _connectedControl;
  62585. private _connectedControlDirtyObserver;
  62586. /** Gets or sets the dash pattern */
  62587. dash: Array<number>;
  62588. /** Gets or sets the control connected with the line end */
  62589. connectedControl: Control;
  62590. /** Gets or sets start coordinates on X axis */
  62591. x1: string | number;
  62592. /** Gets or sets start coordinates on Y axis */
  62593. y1: string | number;
  62594. /** Gets or sets end coordinates on X axis */
  62595. x2: string | number;
  62596. /** Gets or sets end coordinates on Y axis */
  62597. y2: string | number;
  62598. /** Gets or sets line width */
  62599. lineWidth: number;
  62600. /** Gets or sets horizontal alignment */
  62601. horizontalAlignment: number;
  62602. /** Gets or sets vertical alignment */
  62603. verticalAlignment: number;
  62604. private readonly _effectiveX2;
  62605. private readonly _effectiveY2;
  62606. /**
  62607. * Creates a new Line
  62608. * @param name defines the control name
  62609. */
  62610. constructor(name?: string | undefined);
  62611. protected _getTypeName(): string;
  62612. _draw(context: CanvasRenderingContext2D): void;
  62613. _measure(): void;
  62614. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62615. /**
  62616. * Move one end of the line given 3D cartesian coordinates.
  62617. * @param position Targeted world position
  62618. * @param scene BABYLON.Scene
  62619. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62620. */
  62621. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  62622. /**
  62623. * Move one end of the line to a position in screen absolute space.
  62624. * @param projectedPosition Position in screen absolute space (X, Y)
  62625. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62626. */
  62627. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  62628. }
  62629. }
  62630. declare module BABYLON.GUI {
  62631. /**
  62632. * Class used to store a point for a MultiLine object.
  62633. * The point can be pure 2D coordinates, a mesh or a control
  62634. */
  62635. export class MultiLinePoint {
  62636. private _multiLine;
  62637. private _x;
  62638. private _y;
  62639. private _control;
  62640. private _mesh;
  62641. private _controlObserver;
  62642. private _meshObserver;
  62643. /** @hidden */
  62644. _point: BABYLON.Vector2;
  62645. /**
  62646. * Creates a new MultiLinePoint
  62647. * @param multiLine defines the source MultiLine object
  62648. */
  62649. constructor(multiLine: MultiLine);
  62650. /** Gets or sets x coordinate */
  62651. x: string | number;
  62652. /** Gets or sets y coordinate */
  62653. y: string | number;
  62654. /** Gets or sets the control associated with this point */
  62655. control: BABYLON.Nullable<Control>;
  62656. /** Gets or sets the mesh associated with this point */
  62657. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62658. /** Resets links */
  62659. resetLinks(): void;
  62660. /**
  62661. * Gets a translation vector
  62662. * @returns the translation vector
  62663. */
  62664. translate(): BABYLON.Vector2;
  62665. private _translatePoint;
  62666. /** Release associated resources */
  62667. dispose(): void;
  62668. }
  62669. }
  62670. declare module BABYLON.GUI {
  62671. /**
  62672. * Class used to create multi line control
  62673. */
  62674. export class MultiLine extends Control {
  62675. name?: string | undefined;
  62676. private _lineWidth;
  62677. private _dash;
  62678. private _points;
  62679. private _minX;
  62680. private _minY;
  62681. private _maxX;
  62682. private _maxY;
  62683. /**
  62684. * Creates a new MultiLine
  62685. * @param name defines the control name
  62686. */
  62687. constructor(name?: string | undefined);
  62688. /** Gets or sets dash pattern */
  62689. dash: Array<number>;
  62690. /**
  62691. * Gets point stored at specified index
  62692. * @param index defines the index to look for
  62693. * @returns the requested point if found
  62694. */
  62695. getAt(index: number): MultiLinePoint;
  62696. /** Function called when a point is updated */
  62697. onPointUpdate: () => void;
  62698. /**
  62699. * Adds new points to the point collection
  62700. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  62701. * @returns the list of created MultiLinePoint
  62702. */
  62703. add(...items: (AbstractMesh | Control | {
  62704. x: string | number;
  62705. y: string | number;
  62706. })[]): MultiLinePoint[];
  62707. /**
  62708. * Adds a new point to the point collection
  62709. * @param item defines the item (mesh, control or 2d coordiantes) to add
  62710. * @returns the created MultiLinePoint
  62711. */
  62712. push(item?: (AbstractMesh | Control | {
  62713. x: string | number;
  62714. y: string | number;
  62715. })): MultiLinePoint;
  62716. /**
  62717. * Remove a specific value or point from the active point collection
  62718. * @param value defines the value or point to remove
  62719. */
  62720. remove(value: number | MultiLinePoint): void;
  62721. /**
  62722. * Resets this object to initial state (no point)
  62723. */
  62724. reset(): void;
  62725. /**
  62726. * Resets all links
  62727. */
  62728. resetLinks(): void;
  62729. /** Gets or sets line width */
  62730. lineWidth: number;
  62731. horizontalAlignment: number;
  62732. verticalAlignment: number;
  62733. protected _getTypeName(): string;
  62734. _draw(context: CanvasRenderingContext2D): void;
  62735. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62736. _measure(): void;
  62737. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62738. dispose(): void;
  62739. }
  62740. }
  62741. declare module BABYLON.GUI {
  62742. /**
  62743. * Class used to create radio button controls
  62744. */
  62745. export class RadioButton extends Control {
  62746. name?: string | undefined;
  62747. private _isChecked;
  62748. private _background;
  62749. private _checkSizeRatio;
  62750. private _thickness;
  62751. /** Gets or sets border thickness */
  62752. thickness: number;
  62753. /** Gets or sets group name */
  62754. group: string;
  62755. /** BABYLON.Observable raised when isChecked is changed */
  62756. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62757. /** Gets or sets a value indicating the ratio between overall size and check size */
  62758. checkSizeRatio: number;
  62759. /** Gets or sets background color */
  62760. background: string;
  62761. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62762. isChecked: boolean;
  62763. /**
  62764. * Creates a new RadioButton
  62765. * @param name defines the control name
  62766. */
  62767. constructor(name?: string | undefined);
  62768. protected _getTypeName(): string;
  62769. _draw(context: CanvasRenderingContext2D): void;
  62770. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62771. /**
  62772. * Utility function to easily create a radio button with a header
  62773. * @param title defines the label to use for the header
  62774. * @param group defines the group to use for the radio button
  62775. * @param isChecked defines the initial state of the radio button
  62776. * @param onValueChanged defines the callback to call when value changes
  62777. * @returns a StackPanel containing the radio button and a textBlock
  62778. */
  62779. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  62780. }
  62781. }
  62782. declare module BABYLON.GUI {
  62783. /**
  62784. * Class used to create slider controls
  62785. */
  62786. export class BaseSlider extends Control {
  62787. name?: string | undefined;
  62788. protected _thumbWidth: ValueAndUnit;
  62789. private _minimum;
  62790. private _maximum;
  62791. private _value;
  62792. private _isVertical;
  62793. protected _barOffset: ValueAndUnit;
  62794. private _isThumbClamped;
  62795. protected _displayThumb: boolean;
  62796. private _step;
  62797. private _lastPointerDownID;
  62798. protected _effectiveBarOffset: number;
  62799. protected _renderLeft: number;
  62800. protected _renderTop: number;
  62801. protected _renderWidth: number;
  62802. protected _renderHeight: number;
  62803. protected _backgroundBoxLength: number;
  62804. protected _backgroundBoxThickness: number;
  62805. protected _effectiveThumbThickness: number;
  62806. /** BABYLON.Observable raised when the sldier value changes */
  62807. onValueChangedObservable: BABYLON.Observable<number>;
  62808. /** Gets or sets a boolean indicating if the thumb must be rendered */
  62809. displayThumb: boolean;
  62810. /** Gets or sets a step to apply to values (0 by default) */
  62811. step: number;
  62812. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  62813. barOffset: string | number;
  62814. /** Gets main bar offset in pixels*/
  62815. readonly barOffsetInPixels: number;
  62816. /** Gets or sets thumb width */
  62817. thumbWidth: string | number;
  62818. /** Gets thumb width in pixels */
  62819. readonly thumbWidthInPixels: number;
  62820. /** Gets or sets minimum value */
  62821. minimum: number;
  62822. /** Gets or sets maximum value */
  62823. maximum: number;
  62824. /** Gets or sets current value */
  62825. value: number;
  62826. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  62827. isVertical: boolean;
  62828. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  62829. isThumbClamped: boolean;
  62830. /**
  62831. * Creates a new BaseSlider
  62832. * @param name defines the control name
  62833. */
  62834. constructor(name?: string | undefined);
  62835. protected _getTypeName(): string;
  62836. protected _getThumbPosition(): number;
  62837. protected _getThumbThickness(type: string): number;
  62838. protected _prepareRenderingData(type: string): void;
  62839. private _pointerIsDown;
  62840. /** @hidden */
  62841. protected _updateValueFromPointer(x: number, y: number): void;
  62842. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62843. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62844. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62845. }
  62846. }
  62847. declare module BABYLON.GUI {
  62848. /**
  62849. * Class used to create slider controls
  62850. */
  62851. export class Slider extends BaseSlider {
  62852. name?: string | undefined;
  62853. private _background;
  62854. private _borderColor;
  62855. private _isThumbCircle;
  62856. protected _displayValueBar: boolean;
  62857. /** Gets or sets a boolean indicating if the value bar must be rendered */
  62858. displayValueBar: boolean;
  62859. /** Gets or sets border color */
  62860. borderColor: string;
  62861. /** Gets or sets background color */
  62862. background: string;
  62863. /** Gets or sets a boolean indicating if the thumb should be round or square */
  62864. isThumbCircle: boolean;
  62865. /**
  62866. * Creates a new Slider
  62867. * @param name defines the control name
  62868. */
  62869. constructor(name?: string | undefined);
  62870. protected _getTypeName(): string;
  62871. _draw(context: CanvasRenderingContext2D): void;
  62872. }
  62873. }
  62874. declare module BABYLON.GUI {
  62875. /** Class used to create a RadioGroup
  62876. * which contains groups of radio buttons
  62877. */
  62878. export class SelectorGroup {
  62879. /** name of SelectorGroup */
  62880. name: string;
  62881. private _groupPanel;
  62882. private _selectors;
  62883. private _groupHeader;
  62884. /**
  62885. * Creates a new SelectorGroup
  62886. * @param name of group, used as a group heading
  62887. */
  62888. constructor(
  62889. /** name of SelectorGroup */
  62890. name: string);
  62891. /** Gets the groupPanel of the SelectorGroup */
  62892. readonly groupPanel: StackPanel;
  62893. /** Gets the selectors array */
  62894. readonly selectors: StackPanel[];
  62895. /** Gets and sets the group header */
  62896. header: string;
  62897. /** @hidden */
  62898. private _addGroupHeader;
  62899. /** @hidden*/
  62900. _getSelector(selectorNb: number): StackPanel | undefined;
  62901. /** Removes the selector at the given position
  62902. * @param selectorNb the position of the selector within the group
  62903. */
  62904. removeSelector(selectorNb: number): void;
  62905. }
  62906. /** Class used to create a CheckboxGroup
  62907. * which contains groups of checkbox buttons
  62908. */
  62909. export class CheckboxGroup extends SelectorGroup {
  62910. /** Adds a checkbox as a control
  62911. * @param text is the label for the selector
  62912. * @param func is the function called when the Selector is checked
  62913. * @param checked is true when Selector is checked
  62914. */
  62915. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  62916. /** @hidden */
  62917. _setSelectorLabel(selectorNb: number, label: string): void;
  62918. /** @hidden */
  62919. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62920. /** @hidden */
  62921. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62922. /** @hidden */
  62923. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62924. }
  62925. /** Class used to create a RadioGroup
  62926. * which contains groups of radio buttons
  62927. */
  62928. export class RadioGroup extends SelectorGroup {
  62929. private _selectNb;
  62930. /** Adds a radio button as a control
  62931. * @param label is the label for the selector
  62932. * @param func is the function called when the Selector is checked
  62933. * @param checked is true when Selector is checked
  62934. */
  62935. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  62936. /** @hidden */
  62937. _setSelectorLabel(selectorNb: number, label: string): void;
  62938. /** @hidden */
  62939. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62940. /** @hidden */
  62941. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62942. /** @hidden */
  62943. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62944. }
  62945. /** Class used to create a SliderGroup
  62946. * which contains groups of slider buttons
  62947. */
  62948. export class SliderGroup extends SelectorGroup {
  62949. /**
  62950. * Adds a slider to the SelectorGroup
  62951. * @param label is the label for the SliderBar
  62952. * @param func is the function called when the Slider moves
  62953. * @param unit is a string describing the units used, eg degrees or metres
  62954. * @param min is the minimum value for the Slider
  62955. * @param max is the maximum value for the Slider
  62956. * @param value is the start value for the Slider between min and max
  62957. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  62958. */
  62959. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  62960. /** @hidden */
  62961. _setSelectorLabel(selectorNb: number, label: string): void;
  62962. /** @hidden */
  62963. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62964. /** @hidden */
  62965. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62966. /** @hidden */
  62967. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62968. }
  62969. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  62970. * @see http://doc.babylonjs.com/how_to/selector
  62971. */
  62972. export class SelectionPanel extends Rectangle {
  62973. /** name of SelectionPanel */
  62974. name: string;
  62975. /** an array of SelectionGroups */
  62976. groups: SelectorGroup[];
  62977. private _panel;
  62978. private _buttonColor;
  62979. private _buttonBackground;
  62980. private _headerColor;
  62981. private _barColor;
  62982. private _barHeight;
  62983. private _spacerHeight;
  62984. private _labelColor;
  62985. private _groups;
  62986. private _bars;
  62987. /**
  62988. * Creates a new SelectionPanel
  62989. * @param name of SelectionPanel
  62990. * @param groups is an array of SelectionGroups
  62991. */
  62992. constructor(
  62993. /** name of SelectionPanel */
  62994. name: string,
  62995. /** an array of SelectionGroups */
  62996. groups?: SelectorGroup[]);
  62997. protected _getTypeName(): string;
  62998. /** Gets or sets the headerColor */
  62999. headerColor: string;
  63000. private _setHeaderColor;
  63001. /** Gets or sets the button color */
  63002. buttonColor: string;
  63003. private _setbuttonColor;
  63004. /** Gets or sets the label color */
  63005. labelColor: string;
  63006. private _setLabelColor;
  63007. /** Gets or sets the button background */
  63008. buttonBackground: string;
  63009. private _setButtonBackground;
  63010. /** Gets or sets the color of separator bar */
  63011. barColor: string;
  63012. private _setBarColor;
  63013. /** Gets or sets the height of separator bar */
  63014. barHeight: string;
  63015. private _setBarHeight;
  63016. /** Gets or sets the height of spacers*/
  63017. spacerHeight: string;
  63018. private _setSpacerHeight;
  63019. /** Adds a bar between groups */
  63020. private _addSpacer;
  63021. /** Add a group to the selection panel
  63022. * @param group is the selector group to add
  63023. */
  63024. addGroup(group: SelectorGroup): void;
  63025. /** Remove the group from the given position
  63026. * @param groupNb is the position of the group in the list
  63027. */
  63028. removeGroup(groupNb: number): void;
  63029. /** Change a group header label
  63030. * @param label is the new group header label
  63031. * @param groupNb is the number of the group to relabel
  63032. * */
  63033. setHeaderName(label: string, groupNb: number): void;
  63034. /** Change selector label to the one given
  63035. * @param label is the new selector label
  63036. * @param groupNb is the number of the groupcontaining the selector
  63037. * @param selectorNb is the number of the selector within a group to relabel
  63038. * */
  63039. relabel(label: string, groupNb: number, selectorNb: number): void;
  63040. /** For a given group position remove the selector at the given position
  63041. * @param groupNb is the number of the group to remove the selector from
  63042. * @param selectorNb is the number of the selector within the group
  63043. */
  63044. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  63045. /** For a given group position of correct type add a checkbox button
  63046. * @param groupNb is the number of the group to remove the selector from
  63047. * @param label is the label for the selector
  63048. * @param func is the function called when the Selector is checked
  63049. * @param checked is true when Selector is checked
  63050. */
  63051. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  63052. /** For a given group position of correct type add a radio button
  63053. * @param groupNb is the number of the group to remove the selector from
  63054. * @param label is the label for the selector
  63055. * @param func is the function called when the Selector is checked
  63056. * @param checked is true when Selector is checked
  63057. */
  63058. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  63059. /**
  63060. * For a given slider group add a slider
  63061. * @param groupNb is the number of the group to add the slider to
  63062. * @param label is the label for the Slider
  63063. * @param func is the function called when the Slider moves
  63064. * @param unit is a string describing the units used, eg degrees or metres
  63065. * @param min is the minimum value for the Slider
  63066. * @param max is the maximum value for the Slider
  63067. * @param value is the start value for the Slider between min and max
  63068. * @param onVal is the function used to format the value displayed, eg radians to degrees
  63069. */
  63070. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  63071. }
  63072. }
  63073. declare module BABYLON.GUI {
  63074. /**
  63075. * Class used to hold a the container for ScrollViewer
  63076. * @hidden
  63077. */
  63078. export class _ScrollViewerWindow extends Container {
  63079. parentClientWidth: number;
  63080. parentClientHeight: number;
  63081. /**
  63082. * Creates a new ScrollViewerWindow
  63083. * @param name of ScrollViewerWindow
  63084. */
  63085. constructor(name?: string);
  63086. protected _getTypeName(): string;
  63087. /** @hidden */
  63088. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63089. protected _postMeasure(): void;
  63090. }
  63091. }
  63092. declare module BABYLON.GUI {
  63093. /**
  63094. * Class used to create slider controls
  63095. */
  63096. export class ScrollBar extends BaseSlider {
  63097. name?: string | undefined;
  63098. private _background;
  63099. private _borderColor;
  63100. private _thumbMeasure;
  63101. /** Gets or sets border color */
  63102. borderColor: string;
  63103. /** Gets or sets background color */
  63104. background: string;
  63105. /**
  63106. * Creates a new Slider
  63107. * @param name defines the control name
  63108. */
  63109. constructor(name?: string | undefined);
  63110. protected _getTypeName(): string;
  63111. protected _getThumbThickness(): number;
  63112. _draw(context: CanvasRenderingContext2D): void;
  63113. private _first;
  63114. private _originX;
  63115. private _originY;
  63116. /** @hidden */
  63117. protected _updateValueFromPointer(x: number, y: number): void;
  63118. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63119. }
  63120. }
  63121. declare module BABYLON.GUI {
  63122. /**
  63123. * Class used to hold a viewer window and sliders in a grid
  63124. */
  63125. export class ScrollViewer extends Rectangle {
  63126. private _grid;
  63127. private _horizontalBarSpace;
  63128. private _verticalBarSpace;
  63129. private _dragSpace;
  63130. private _horizontalBar;
  63131. private _verticalBar;
  63132. private _barColor;
  63133. private _barBackground;
  63134. private _barSize;
  63135. private _endLeft;
  63136. private _endTop;
  63137. private _window;
  63138. private _pointerIsOver;
  63139. private _wheelPrecision;
  63140. private _onPointerObserver;
  63141. private _clientWidth;
  63142. private _clientHeight;
  63143. /**
  63144. * Gets the horizontal scrollbar
  63145. */
  63146. readonly horizontalBar: ScrollBar;
  63147. /**
  63148. * Gets the vertical scrollbar
  63149. */
  63150. readonly verticalBar: ScrollBar;
  63151. /**
  63152. * Adds a new control to the current container
  63153. * @param control defines the control to add
  63154. * @returns the current container
  63155. */
  63156. addControl(control: BABYLON.Nullable<Control>): Container;
  63157. /**
  63158. * Removes a control from the current container
  63159. * @param control defines the control to remove
  63160. * @returns the current container
  63161. */
  63162. removeControl(control: Control): Container;
  63163. /** Gets the list of children */
  63164. readonly children: Control[];
  63165. _flagDescendantsAsMatrixDirty(): void;
  63166. /**
  63167. * Creates a new ScrollViewer
  63168. * @param name of ScrollViewer
  63169. */
  63170. constructor(name?: string);
  63171. /** Reset the scroll viewer window to initial size */
  63172. resetWindow(): void;
  63173. protected _getTypeName(): string;
  63174. private _buildClientSizes;
  63175. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63176. protected _postMeasure(): void;
  63177. /**
  63178. * Gets or sets the mouse wheel precision
  63179. * from 0 to 1 with a default value of 0.05
  63180. * */
  63181. wheelPrecision: number;
  63182. /** Gets or sets the bar color */
  63183. barColor: string;
  63184. /** Gets or sets the size of the bar */
  63185. barSize: number;
  63186. /** Gets or sets the bar background */
  63187. barBackground: string;
  63188. /** @hidden */
  63189. private _updateScroller;
  63190. _link(host: AdvancedDynamicTexture): void;
  63191. /** @hidden */
  63192. private _attachWheel;
  63193. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63194. /** Releases associated resources */
  63195. dispose(): void;
  63196. }
  63197. }
  63198. declare module BABYLON.GUI {
  63199. /** Class used to render a grid */
  63200. export class DisplayGrid extends Control {
  63201. name?: string | undefined;
  63202. private _cellWidth;
  63203. private _cellHeight;
  63204. private _minorLineTickness;
  63205. private _minorLineColor;
  63206. private _majorLineTickness;
  63207. private _majorLineColor;
  63208. private _majorLineFrequency;
  63209. private _background;
  63210. private _displayMajorLines;
  63211. private _displayMinorLines;
  63212. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  63213. displayMinorLines: boolean;
  63214. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  63215. displayMajorLines: boolean;
  63216. /** Gets or sets background color (Black by default) */
  63217. background: string;
  63218. /** Gets or sets the width of each cell (20 by default) */
  63219. cellWidth: number;
  63220. /** Gets or sets the height of each cell (20 by default) */
  63221. cellHeight: number;
  63222. /** Gets or sets the tickness of minor lines (1 by default) */
  63223. minorLineTickness: number;
  63224. /** Gets or sets the color of minor lines (DarkGray by default) */
  63225. minorLineColor: string;
  63226. /** Gets or sets the tickness of major lines (2 by default) */
  63227. majorLineTickness: number;
  63228. /** Gets or sets the color of major lines (White by default) */
  63229. majorLineColor: string;
  63230. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  63231. majorLineFrequency: number;
  63232. /**
  63233. * Creates a new GridDisplayRectangle
  63234. * @param name defines the control name
  63235. */
  63236. constructor(name?: string | undefined);
  63237. _draw(context: CanvasRenderingContext2D): void;
  63238. protected _getTypeName(): string;
  63239. }
  63240. }
  63241. declare module BABYLON.GUI {
  63242. /**
  63243. * Class used to create slider controls based on images
  63244. */
  63245. export class ImageBasedSlider extends BaseSlider {
  63246. name?: string | undefined;
  63247. private _backgroundImage;
  63248. private _thumbImage;
  63249. private _valueBarImage;
  63250. private _tempMeasure;
  63251. displayThumb: boolean;
  63252. /**
  63253. * Gets or sets the image used to render the background
  63254. */
  63255. backgroundImage: Image;
  63256. /**
  63257. * Gets or sets the image used to render the value bar
  63258. */
  63259. valueBarImage: Image;
  63260. /**
  63261. * Gets or sets the image used to render the thumb
  63262. */
  63263. thumbImage: Image;
  63264. /**
  63265. * Creates a new ImageBasedSlider
  63266. * @param name defines the control name
  63267. */
  63268. constructor(name?: string | undefined);
  63269. protected _getTypeName(): string;
  63270. _draw(context: CanvasRenderingContext2D): void;
  63271. }
  63272. }
  63273. declare module BABYLON.GUI {
  63274. /**
  63275. * Forcing an export so that this code will execute
  63276. * @hidden
  63277. */
  63278. const name = "Statics";
  63279. }
  63280. declare module BABYLON.GUI {
  63281. /**
  63282. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  63283. */
  63284. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  63285. /**
  63286. * Define the instrumented AdvancedDynamicTexture.
  63287. */
  63288. texture: AdvancedDynamicTexture;
  63289. private _captureRenderTime;
  63290. private _renderTime;
  63291. private _captureLayoutTime;
  63292. private _layoutTime;
  63293. private _onBeginRenderObserver;
  63294. private _onEndRenderObserver;
  63295. private _onBeginLayoutObserver;
  63296. private _onEndLayoutObserver;
  63297. /**
  63298. * Gets the perf counter used to capture render time
  63299. */
  63300. readonly renderTimeCounter: BABYLON.PerfCounter;
  63301. /**
  63302. * Gets the perf counter used to capture layout time
  63303. */
  63304. readonly layoutTimeCounter: BABYLON.PerfCounter;
  63305. /**
  63306. * Enable or disable the render time capture
  63307. */
  63308. captureRenderTime: boolean;
  63309. /**
  63310. * Enable or disable the layout time capture
  63311. */
  63312. captureLayoutTime: boolean;
  63313. /**
  63314. * Instantiates a new advanced dynamic texture instrumentation.
  63315. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  63316. * @param texture Defines the AdvancedDynamicTexture to instrument
  63317. */
  63318. constructor(
  63319. /**
  63320. * Define the instrumented AdvancedDynamicTexture.
  63321. */
  63322. texture: AdvancedDynamicTexture);
  63323. /**
  63324. * Dispose and release associated resources.
  63325. */
  63326. dispose(): void;
  63327. }
  63328. }
  63329. declare module BABYLON.GUI {
  63330. /**
  63331. * Class used to create containers for controls
  63332. */
  63333. export class Container3D extends Control3D {
  63334. private _blockLayout;
  63335. /**
  63336. * Gets the list of child controls
  63337. */
  63338. protected _children: Control3D[];
  63339. /**
  63340. * Gets the list of child controls
  63341. */
  63342. readonly children: Array<Control3D>;
  63343. /**
  63344. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  63345. * This is helpful to optimize layout operation when adding multiple children in a row
  63346. */
  63347. blockLayout: boolean;
  63348. /**
  63349. * Creates a new container
  63350. * @param name defines the container name
  63351. */
  63352. constructor(name?: string);
  63353. /**
  63354. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  63355. * @returns the current container
  63356. */
  63357. updateLayout(): Container3D;
  63358. /**
  63359. * Gets a boolean indicating if the given control is in the children of this control
  63360. * @param control defines the control to check
  63361. * @returns true if the control is in the child list
  63362. */
  63363. containsControl(control: Control3D): boolean;
  63364. /**
  63365. * Adds a control to the children of this control
  63366. * @param control defines the control to add
  63367. * @returns the current container
  63368. */
  63369. addControl(control: Control3D): Container3D;
  63370. /**
  63371. * This function will be called everytime a new control is added
  63372. */
  63373. protected _arrangeChildren(): void;
  63374. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63375. /**
  63376. * Removes a control from the children of this control
  63377. * @param control defines the control to remove
  63378. * @returns the current container
  63379. */
  63380. removeControl(control: Control3D): Container3D;
  63381. protected _getTypeName(): string;
  63382. /**
  63383. * Releases all associated resources
  63384. */
  63385. dispose(): void;
  63386. /** Control rotation will remain unchanged */
  63387. static readonly UNSET_ORIENTATION: number;
  63388. /** Control will rotate to make it look at sphere central axis */
  63389. static readonly FACEORIGIN_ORIENTATION: number;
  63390. /** Control will rotate to make it look back at sphere central axis */
  63391. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  63392. /** Control will rotate to look at z axis (0, 0, 1) */
  63393. static readonly FACEFORWARD_ORIENTATION: number;
  63394. /** Control will rotate to look at negative z axis (0, 0, -1) */
  63395. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  63396. }
  63397. }
  63398. declare module BABYLON.GUI {
  63399. /**
  63400. * Class used to manage 3D user interface
  63401. * @see http://doc.babylonjs.com/how_to/gui3d
  63402. */
  63403. export class GUI3DManager implements BABYLON.IDisposable {
  63404. private _scene;
  63405. private _sceneDisposeObserver;
  63406. private _utilityLayer;
  63407. private _rootContainer;
  63408. private _pointerObserver;
  63409. private _pointerOutObserver;
  63410. /** @hidden */
  63411. _lastPickedControl: Control3D;
  63412. /** @hidden */
  63413. _lastControlOver: {
  63414. [pointerId: number]: Control3D;
  63415. };
  63416. /** @hidden */
  63417. _lastControlDown: {
  63418. [pointerId: number]: Control3D;
  63419. };
  63420. /**
  63421. * BABYLON.Observable raised when the point picked by the pointer events changed
  63422. */
  63423. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  63424. /** @hidden */
  63425. _sharedMaterials: {
  63426. [key: string]: BABYLON.Material;
  63427. };
  63428. /** Gets the hosting scene */
  63429. readonly scene: BABYLON.Scene;
  63430. /** Gets associated utility layer */
  63431. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  63432. /**
  63433. * Creates a new GUI3DManager
  63434. * @param scene
  63435. */
  63436. constructor(scene?: BABYLON.Scene);
  63437. private _handlePointerOut;
  63438. private _doPicking;
  63439. /**
  63440. * Gets the root container
  63441. */
  63442. readonly rootContainer: Container3D;
  63443. /**
  63444. * Gets a boolean indicating if the given control is in the root child list
  63445. * @param control defines the control to check
  63446. * @returns true if the control is in the root child list
  63447. */
  63448. containsControl(control: Control3D): boolean;
  63449. /**
  63450. * Adds a control to the root child list
  63451. * @param control defines the control to add
  63452. * @returns the current manager
  63453. */
  63454. addControl(control: Control3D): GUI3DManager;
  63455. /**
  63456. * Removes a control from the root child list
  63457. * @param control defines the control to remove
  63458. * @returns the current container
  63459. */
  63460. removeControl(control: Control3D): GUI3DManager;
  63461. /**
  63462. * Releases all associated resources
  63463. */
  63464. dispose(): void;
  63465. }
  63466. }
  63467. declare module BABYLON.GUI {
  63468. /**
  63469. * Class used to transport BABYLON.Vector3 information for pointer events
  63470. */
  63471. export class Vector3WithInfo extends BABYLON.Vector3 {
  63472. /** defines the current mouse button index */
  63473. buttonIndex: number;
  63474. /**
  63475. * Creates a new Vector3WithInfo
  63476. * @param source defines the vector3 data to transport
  63477. * @param buttonIndex defines the current mouse button index
  63478. */
  63479. constructor(source: BABYLON.Vector3,
  63480. /** defines the current mouse button index */
  63481. buttonIndex?: number);
  63482. }
  63483. }
  63484. declare module BABYLON.GUI {
  63485. /**
  63486. * Class used as base class for controls
  63487. */
  63488. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  63489. /** Defines the control name */
  63490. name?: string | undefined;
  63491. /** @hidden */
  63492. _host: GUI3DManager;
  63493. private _node;
  63494. private _downCount;
  63495. private _enterCount;
  63496. private _downPointerIds;
  63497. private _isVisible;
  63498. /** Gets or sets the control position in world space */
  63499. position: BABYLON.Vector3;
  63500. /** Gets or sets the control scaling in world space */
  63501. scaling: BABYLON.Vector3;
  63502. /** Callback used to start pointer enter animation */
  63503. pointerEnterAnimation: () => void;
  63504. /** Callback used to start pointer out animation */
  63505. pointerOutAnimation: () => void;
  63506. /** Callback used to start pointer down animation */
  63507. pointerDownAnimation: () => void;
  63508. /** Callback used to start pointer up animation */
  63509. pointerUpAnimation: () => void;
  63510. /**
  63511. * An event triggered when the pointer move over the control
  63512. */
  63513. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  63514. /**
  63515. * An event triggered when the pointer move out of the control
  63516. */
  63517. onPointerOutObservable: BABYLON.Observable<Control3D>;
  63518. /**
  63519. * An event triggered when the pointer taps the control
  63520. */
  63521. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  63522. /**
  63523. * An event triggered when pointer is up
  63524. */
  63525. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  63526. /**
  63527. * An event triggered when a control is clicked on (with a mouse)
  63528. */
  63529. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  63530. /**
  63531. * An event triggered when pointer enters the control
  63532. */
  63533. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  63534. /**
  63535. * Gets or sets the parent container
  63536. */
  63537. parent: BABYLON.Nullable<Container3D>;
  63538. private _behaviors;
  63539. /**
  63540. * Gets the list of attached behaviors
  63541. * @see http://doc.babylonjs.com/features/behaviour
  63542. */
  63543. readonly behaviors: BABYLON.Behavior<Control3D>[];
  63544. /**
  63545. * Attach a behavior to the control
  63546. * @see http://doc.babylonjs.com/features/behaviour
  63547. * @param behavior defines the behavior to attach
  63548. * @returns the current control
  63549. */
  63550. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  63551. /**
  63552. * Remove an attached behavior
  63553. * @see http://doc.babylonjs.com/features/behaviour
  63554. * @param behavior defines the behavior to attach
  63555. * @returns the current control
  63556. */
  63557. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  63558. /**
  63559. * Gets an attached behavior by name
  63560. * @param name defines the name of the behavior to look for
  63561. * @see http://doc.babylonjs.com/features/behaviour
  63562. * @returns null if behavior was not found else the requested behavior
  63563. */
  63564. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  63565. /** Gets or sets a boolean indicating if the control is visible */
  63566. isVisible: boolean;
  63567. /**
  63568. * Creates a new control
  63569. * @param name defines the control name
  63570. */
  63571. constructor(
  63572. /** Defines the control name */
  63573. name?: string | undefined);
  63574. /**
  63575. * Gets a string representing the class name
  63576. */
  63577. readonly typeName: string;
  63578. /**
  63579. * Get the current class name of the control.
  63580. * @returns current class name
  63581. */
  63582. getClassName(): string;
  63583. protected _getTypeName(): string;
  63584. /**
  63585. * Gets the transform node used by this control
  63586. */
  63587. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  63588. /**
  63589. * Gets the mesh used to render this control
  63590. */
  63591. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63592. /**
  63593. * Link the control as child of the given node
  63594. * @param node defines the node to link to. Use null to unlink the control
  63595. * @returns the current control
  63596. */
  63597. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  63598. /** @hidden **/
  63599. _prepareNode(scene: BABYLON.Scene): void;
  63600. /**
  63601. * Node creation.
  63602. * Can be overriden by children
  63603. * @param scene defines the scene where the node must be attached
  63604. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  63605. */
  63606. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63607. /**
  63608. * Affect a material to the given mesh
  63609. * @param mesh defines the mesh which will represent the control
  63610. */
  63611. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63612. /** @hidden */
  63613. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  63614. /** @hidden */
  63615. _onPointerEnter(target: Control3D): boolean;
  63616. /** @hidden */
  63617. _onPointerOut(target: Control3D): void;
  63618. /** @hidden */
  63619. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63620. /** @hidden */
  63621. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63622. /** @hidden */
  63623. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63624. /** @hidden */
  63625. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63626. /** @hidden */
  63627. _disposeNode(): void;
  63628. /**
  63629. * Releases all associated resources
  63630. */
  63631. dispose(): void;
  63632. }
  63633. }
  63634. declare module BABYLON.GUI {
  63635. /**
  63636. * Class used as a root to all buttons
  63637. */
  63638. export class AbstractButton3D extends Control3D {
  63639. /**
  63640. * Creates a new button
  63641. * @param name defines the control name
  63642. */
  63643. constructor(name?: string);
  63644. protected _getTypeName(): string;
  63645. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63646. }
  63647. }
  63648. declare module BABYLON.GUI {
  63649. /**
  63650. * Class used to create a button in 3D
  63651. */
  63652. export class Button3D extends AbstractButton3D {
  63653. /** @hidden */
  63654. protected _currentMaterial: BABYLON.Material;
  63655. private _facadeTexture;
  63656. private _content;
  63657. private _contentResolution;
  63658. private _contentScaleRatio;
  63659. /**
  63660. * Gets or sets the texture resolution used to render content (512 by default)
  63661. */
  63662. contentResolution: BABYLON.int;
  63663. /**
  63664. * Gets or sets the texture scale ratio used to render content (2 by default)
  63665. */
  63666. contentScaleRatio: number;
  63667. protected _disposeFacadeTexture(): void;
  63668. protected _resetContent(): void;
  63669. /**
  63670. * Creates a new button
  63671. * @param name defines the control name
  63672. */
  63673. constructor(name?: string);
  63674. /**
  63675. * Gets or sets the GUI 2D content used to display the button's facade
  63676. */
  63677. content: Control;
  63678. /**
  63679. * Apply the facade texture (created from the content property).
  63680. * This function can be overloaded by child classes
  63681. * @param facadeTexture defines the AdvancedDynamicTexture to use
  63682. */
  63683. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63684. protected _getTypeName(): string;
  63685. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63686. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63687. /**
  63688. * Releases all associated resources
  63689. */
  63690. dispose(): void;
  63691. }
  63692. }
  63693. declare module BABYLON.GUI {
  63694. /**
  63695. * Abstract class used to create a container panel deployed on the surface of a volume
  63696. */
  63697. export abstract class VolumeBasedPanel extends Container3D {
  63698. private _columns;
  63699. private _rows;
  63700. private _rowThenColum;
  63701. private _orientation;
  63702. protected _cellWidth: number;
  63703. protected _cellHeight: number;
  63704. /**
  63705. * Gets or sets the distance between elements
  63706. */
  63707. margin: number;
  63708. /**
  63709. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  63710. * | Value | Type | Description |
  63711. * | ----- | ----------------------------------- | ----------- |
  63712. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  63713. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  63714. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  63715. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  63716. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  63717. */
  63718. orientation: number;
  63719. /**
  63720. * Gets or sets the number of columns requested (10 by default).
  63721. * The panel will automatically compute the number of rows based on number of child controls.
  63722. */
  63723. columns: BABYLON.int;
  63724. /**
  63725. * Gets or sets a the number of rows requested.
  63726. * The panel will automatically compute the number of columns based on number of child controls.
  63727. */
  63728. rows: BABYLON.int;
  63729. /**
  63730. * Creates new VolumeBasedPanel
  63731. */
  63732. constructor();
  63733. protected _arrangeChildren(): void;
  63734. /** Child classes must implement this function to provide correct control positioning */
  63735. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63736. /** Child classes can implement this function to provide additional processing */
  63737. protected _finalProcessing(): void;
  63738. }
  63739. }
  63740. declare module BABYLON.GUI {
  63741. /**
  63742. * Class used to create a container panel deployed on the surface of a cylinder
  63743. */
  63744. export class CylinderPanel extends VolumeBasedPanel {
  63745. private _radius;
  63746. /**
  63747. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  63748. */
  63749. radius: BABYLON.float;
  63750. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63751. private _cylindricalMapping;
  63752. }
  63753. }
  63754. declare module BABYLON.GUI {
  63755. /** @hidden */
  63756. export var fluentVertexShader: {
  63757. name: string;
  63758. shader: string;
  63759. };
  63760. }
  63761. declare module BABYLON.GUI {
  63762. /** @hidden */
  63763. export var fluentPixelShader: {
  63764. name: string;
  63765. shader: string;
  63766. };
  63767. }
  63768. declare module BABYLON.GUI {
  63769. /** @hidden */
  63770. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  63771. INNERGLOW: boolean;
  63772. BORDER: boolean;
  63773. HOVERLIGHT: boolean;
  63774. TEXTURE: boolean;
  63775. constructor();
  63776. }
  63777. /**
  63778. * Class used to render controls with fluent desgin
  63779. */
  63780. export class FluentMaterial extends BABYLON.PushMaterial {
  63781. /**
  63782. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  63783. */
  63784. innerGlowColorIntensity: number;
  63785. /**
  63786. * Gets or sets the inner glow color (white by default)
  63787. */
  63788. innerGlowColor: BABYLON.Color3;
  63789. /**
  63790. * Gets or sets alpha value (default is 1.0)
  63791. */
  63792. alpha: number;
  63793. /**
  63794. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  63795. */
  63796. albedoColor: BABYLON.Color3;
  63797. /**
  63798. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  63799. */
  63800. renderBorders: boolean;
  63801. /**
  63802. * Gets or sets border width (default is 0.5)
  63803. */
  63804. borderWidth: number;
  63805. /**
  63806. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  63807. */
  63808. edgeSmoothingValue: number;
  63809. /**
  63810. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  63811. */
  63812. borderMinValue: number;
  63813. /**
  63814. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  63815. */
  63816. renderHoverLight: boolean;
  63817. /**
  63818. * Gets or sets the radius used to render the hover light (default is 1.0)
  63819. */
  63820. hoverRadius: number;
  63821. /**
  63822. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  63823. */
  63824. hoverColor: BABYLON.Color4;
  63825. /**
  63826. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  63827. */
  63828. hoverPosition: BABYLON.Vector3;
  63829. private _albedoTexture;
  63830. /** Gets or sets the texture to use for albedo color */
  63831. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63832. /**
  63833. * Creates a new Fluent material
  63834. * @param name defines the name of the material
  63835. * @param scene defines the hosting scene
  63836. */
  63837. constructor(name: string, scene: BABYLON.Scene);
  63838. needAlphaBlending(): boolean;
  63839. needAlphaTesting(): boolean;
  63840. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63841. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63842. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63843. getActiveTextures(): BABYLON.BaseTexture[];
  63844. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63845. dispose(forceDisposeEffect?: boolean): void;
  63846. clone(name: string): FluentMaterial;
  63847. serialize(): any;
  63848. getClassName(): string;
  63849. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  63850. }
  63851. }
  63852. declare module BABYLON.GUI {
  63853. /**
  63854. * Class used to create a holographic button in 3D
  63855. */
  63856. export class HolographicButton extends Button3D {
  63857. private _backPlate;
  63858. private _textPlate;
  63859. private _frontPlate;
  63860. private _text;
  63861. private _imageUrl;
  63862. private _shareMaterials;
  63863. private _frontMaterial;
  63864. private _backMaterial;
  63865. private _plateMaterial;
  63866. private _pickedPointObserver;
  63867. private _tooltipFade;
  63868. private _tooltipTextBlock;
  63869. private _tooltipTexture;
  63870. private _tooltipMesh;
  63871. private _tooltipHoverObserver;
  63872. private _tooltipOutObserver;
  63873. private _disposeTooltip;
  63874. /**
  63875. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  63876. */
  63877. tooltipText: BABYLON.Nullable<string>;
  63878. /**
  63879. * Gets or sets text for the button
  63880. */
  63881. text: string;
  63882. /**
  63883. * Gets or sets the image url for the button
  63884. */
  63885. imageUrl: string;
  63886. /**
  63887. * Gets the back material used by this button
  63888. */
  63889. readonly backMaterial: FluentMaterial;
  63890. /**
  63891. * Gets the front material used by this button
  63892. */
  63893. readonly frontMaterial: FluentMaterial;
  63894. /**
  63895. * Gets the plate material used by this button
  63896. */
  63897. readonly plateMaterial: BABYLON.StandardMaterial;
  63898. /**
  63899. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  63900. */
  63901. readonly shareMaterials: boolean;
  63902. /**
  63903. * Creates a new button
  63904. * @param name defines the control name
  63905. */
  63906. constructor(name?: string, shareMaterials?: boolean);
  63907. protected _getTypeName(): string;
  63908. private _rebuildContent;
  63909. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63910. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63911. private _createBackMaterial;
  63912. private _createFrontMaterial;
  63913. private _createPlateMaterial;
  63914. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  63915. /**
  63916. * Releases all associated resources
  63917. */
  63918. dispose(): void;
  63919. }
  63920. }
  63921. declare module BABYLON.GUI {
  63922. /**
  63923. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  63924. */
  63925. export class MeshButton3D extends Button3D {
  63926. /** @hidden */
  63927. protected _currentMesh: BABYLON.Mesh;
  63928. /**
  63929. * Creates a new 3D button based on a mesh
  63930. * @param mesh mesh to become a 3D button
  63931. * @param name defines the control name
  63932. */
  63933. constructor(mesh: BABYLON.Mesh, name?: string);
  63934. protected _getTypeName(): string;
  63935. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63936. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63937. }
  63938. }
  63939. declare module BABYLON.GUI {
  63940. /**
  63941. * Class used to create a container panel deployed on the surface of a plane
  63942. */
  63943. export class PlanePanel extends VolumeBasedPanel {
  63944. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63945. }
  63946. }
  63947. declare module BABYLON.GUI {
  63948. /**
  63949. * Class used to create a container panel where items get randomized planar mapping
  63950. */
  63951. export class ScatterPanel extends VolumeBasedPanel {
  63952. private _iteration;
  63953. /**
  63954. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  63955. */
  63956. iteration: BABYLON.float;
  63957. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63958. private _scatterMapping;
  63959. protected _finalProcessing(): void;
  63960. }
  63961. }
  63962. declare module BABYLON.GUI {
  63963. /**
  63964. * Class used to create a container panel deployed on the surface of a sphere
  63965. */
  63966. export class SpherePanel extends VolumeBasedPanel {
  63967. private _radius;
  63968. /**
  63969. * Gets or sets the radius of the sphere where to project controls (5 by default)
  63970. */
  63971. radius: BABYLON.float;
  63972. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63973. private _sphericalMapping;
  63974. }
  63975. }
  63976. declare module BABYLON.GUI {
  63977. /**
  63978. * Class used to create a stack panel in 3D on XY plane
  63979. */
  63980. export class StackPanel3D extends Container3D {
  63981. private _isVertical;
  63982. /**
  63983. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  63984. */
  63985. isVertical: boolean;
  63986. /**
  63987. * Gets or sets the distance between elements
  63988. */
  63989. margin: number;
  63990. /**
  63991. * Creates new StackPanel
  63992. * @param isVertical
  63993. */
  63994. constructor(isVertical?: boolean);
  63995. protected _arrangeChildren(): void;
  63996. }
  63997. }
  63998. declare module BABYLON {
  63999. /**
  64000. * Mode that determines the coordinate system to use.
  64001. */
  64002. export enum GLTFLoaderCoordinateSystemMode {
  64003. /**
  64004. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  64005. */
  64006. AUTO = 0,
  64007. /**
  64008. * Sets the useRightHandedSystem flag on the scene.
  64009. */
  64010. FORCE_RIGHT_HANDED = 1
  64011. }
  64012. /**
  64013. * Mode that determines what animations will start.
  64014. */
  64015. export enum GLTFLoaderAnimationStartMode {
  64016. /**
  64017. * No animation will start.
  64018. */
  64019. NONE = 0,
  64020. /**
  64021. * The first animation will start.
  64022. */
  64023. FIRST = 1,
  64024. /**
  64025. * All animations will start.
  64026. */
  64027. ALL = 2
  64028. }
  64029. /**
  64030. * Interface that contains the data for the glTF asset.
  64031. */
  64032. export interface IGLTFLoaderData {
  64033. /**
  64034. * Object that represents the glTF JSON.
  64035. */
  64036. json: Object;
  64037. /**
  64038. * The BIN chunk of a binary glTF.
  64039. */
  64040. bin: Nullable<ArrayBufferView>;
  64041. }
  64042. /**
  64043. * Interface for extending the loader.
  64044. */
  64045. export interface IGLTFLoaderExtension {
  64046. /**
  64047. * The name of this extension.
  64048. */
  64049. readonly name: string;
  64050. /**
  64051. * Defines whether this extension is enabled.
  64052. */
  64053. enabled: boolean;
  64054. }
  64055. /**
  64056. * Loader state.
  64057. */
  64058. export enum GLTFLoaderState {
  64059. /**
  64060. * The asset is loading.
  64061. */
  64062. LOADING = 0,
  64063. /**
  64064. * The asset is ready for rendering.
  64065. */
  64066. READY = 1,
  64067. /**
  64068. * The asset is completely loaded.
  64069. */
  64070. COMPLETE = 2
  64071. }
  64072. /** @hidden */
  64073. export interface IGLTFLoader extends IDisposable {
  64074. readonly state: Nullable<GLTFLoaderState>;
  64075. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  64076. meshes: AbstractMesh[];
  64077. particleSystems: IParticleSystem[];
  64078. skeletons: Skeleton[];
  64079. animationGroups: AnimationGroup[];
  64080. }>;
  64081. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  64082. }
  64083. /**
  64084. * File loader for loading glTF files into a scene.
  64085. */
  64086. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  64087. /** @hidden */
  64088. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  64089. /** @hidden */
  64090. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  64091. /**
  64092. * Raised when the asset has been parsed
  64093. */
  64094. onParsedObservable: Observable<IGLTFLoaderData>;
  64095. private _onParsedObserver;
  64096. /**
  64097. * Raised when the asset has been parsed
  64098. */
  64099. onParsed: (loaderData: IGLTFLoaderData) => void;
  64100. /**
  64101. * 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.
  64102. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  64103. * Defaults to true.
  64104. * @hidden
  64105. */
  64106. static IncrementalLoading: boolean;
  64107. /**
  64108. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  64109. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  64110. * @hidden
  64111. */
  64112. static HomogeneousCoordinates: boolean;
  64113. /**
  64114. * The coordinate system mode. Defaults to AUTO.
  64115. */
  64116. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  64117. /**
  64118. * The animation start mode. Defaults to FIRST.
  64119. */
  64120. animationStartMode: GLTFLoaderAnimationStartMode;
  64121. /**
  64122. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  64123. */
  64124. compileMaterials: boolean;
  64125. /**
  64126. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  64127. */
  64128. useClipPlane: boolean;
  64129. /**
  64130. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  64131. */
  64132. compileShadowGenerators: boolean;
  64133. /**
  64134. * Defines if the Alpha blended materials are only applied as coverage.
  64135. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  64136. * If true, no extra effects are applied to transparent pixels.
  64137. */
  64138. transparencyAsCoverage: boolean;
  64139. /**
  64140. * Function called before loading a url referenced by the asset.
  64141. */
  64142. preprocessUrlAsync: (url: string) => Promise<string>;
  64143. /**
  64144. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  64145. */
  64146. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  64147. private _onMeshLoadedObserver;
  64148. /**
  64149. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  64150. */
  64151. onMeshLoaded: (mesh: AbstractMesh) => void;
  64152. /**
  64153. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  64154. */
  64155. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  64156. private _onTextureLoadedObserver;
  64157. /**
  64158. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  64159. */
  64160. onTextureLoaded: (texture: BaseTexture) => void;
  64161. /**
  64162. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  64163. */
  64164. readonly onMaterialLoadedObservable: Observable<Material>;
  64165. private _onMaterialLoadedObserver;
  64166. /**
  64167. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  64168. */
  64169. onMaterialLoaded: (material: Material) => void;
  64170. /**
  64171. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  64172. */
  64173. readonly onCameraLoadedObservable: Observable<Camera>;
  64174. private _onCameraLoadedObserver;
  64175. /**
  64176. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  64177. */
  64178. onCameraLoaded: (camera: Camera) => void;
  64179. /**
  64180. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  64181. * For assets with LODs, raised when all of the LODs are complete.
  64182. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  64183. */
  64184. readonly onCompleteObservable: Observable<void>;
  64185. private _onCompleteObserver;
  64186. /**
  64187. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  64188. * For assets with LODs, raised when all of the LODs are complete.
  64189. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  64190. */
  64191. onComplete: () => void;
  64192. /**
  64193. * Observable raised when an error occurs.
  64194. */
  64195. readonly onErrorObservable: Observable<any>;
  64196. private _onErrorObserver;
  64197. /**
  64198. * Callback raised when an error occurs.
  64199. */
  64200. onError: (reason: any) => void;
  64201. /**
  64202. * Observable raised after the loader is disposed.
  64203. */
  64204. readonly onDisposeObservable: Observable<void>;
  64205. private _onDisposeObserver;
  64206. /**
  64207. * Callback raised after the loader is disposed.
  64208. */
  64209. onDispose: () => void;
  64210. /**
  64211. * Observable raised after a loader extension is created.
  64212. * Set additional options for a loader extension in this event.
  64213. */
  64214. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  64215. private _onExtensionLoadedObserver;
  64216. /**
  64217. * Callback raised after a loader extension is created.
  64218. */
  64219. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  64220. /**
  64221. * Defines if the loader logging is enabled.
  64222. */
  64223. loggingEnabled: boolean;
  64224. /**
  64225. * Defines if the loader should capture performance counters.
  64226. */
  64227. capturePerformanceCounters: boolean;
  64228. /**
  64229. * Defines if the loader should validate the asset.
  64230. */
  64231. validate: boolean;
  64232. /**
  64233. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  64234. */
  64235. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  64236. private _onValidatedObserver;
  64237. /**
  64238. * Callback raised after a loader extension is created.
  64239. */
  64240. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  64241. private _loader;
  64242. /**
  64243. * Name of the loader ("gltf")
  64244. */
  64245. name: string;
  64246. /**
  64247. * Supported file extensions of the loader (.gltf, .glb)
  64248. */
  64249. extensions: ISceneLoaderPluginExtensions;
  64250. /**
  64251. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  64252. */
  64253. dispose(): void;
  64254. /** @hidden */
  64255. _clear(): void;
  64256. /**
  64257. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  64258. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64259. * @param scene the scene the meshes should be added to
  64260. * @param data the glTF data to load
  64261. * @param rootUrl root url to load from
  64262. * @param onProgress event that fires when loading progress has occured
  64263. * @param fileName Defines the name of the file to load
  64264. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64265. */
  64266. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64267. meshes: AbstractMesh[];
  64268. particleSystems: IParticleSystem[];
  64269. skeletons: Skeleton[];
  64270. animationGroups: AnimationGroup[];
  64271. }>;
  64272. /**
  64273. * Imports all objects from the loaded glTF data and adds them to the scene
  64274. * @param scene the scene the objects should be added to
  64275. * @param data the glTF data to load
  64276. * @param rootUrl root url to load from
  64277. * @param onProgress event that fires when loading progress has occured
  64278. * @param fileName Defines the name of the file to load
  64279. * @returns a promise which completes when objects have been loaded to the scene
  64280. */
  64281. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64282. /**
  64283. * Load into an asset container.
  64284. * @param scene The scene to load into
  64285. * @param data The data to import
  64286. * @param rootUrl The root url for scene and resources
  64287. * @param onProgress The callback when the load progresses
  64288. * @param fileName Defines the name of the file to load
  64289. * @returns The loaded asset container
  64290. */
  64291. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  64292. /**
  64293. * If the data string can be loaded directly.
  64294. * @param data string contianing the file data
  64295. * @returns if the data can be loaded directly
  64296. */
  64297. canDirectLoad(data: string): boolean;
  64298. /**
  64299. * Rewrites a url by combining a root url and response url.
  64300. */
  64301. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  64302. /**
  64303. * Instantiates a glTF file loader plugin.
  64304. * @returns the created plugin
  64305. */
  64306. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  64307. /**
  64308. * The loader state or null if the loader is not active.
  64309. */
  64310. readonly loaderState: Nullable<GLTFLoaderState>;
  64311. /**
  64312. * Returns a promise that resolves when the asset is completely loaded.
  64313. * @returns a promise that resolves when the asset is completely loaded.
  64314. */
  64315. whenCompleteAsync(): Promise<void>;
  64316. private _parseAsync;
  64317. private _validateAsync;
  64318. private _getLoader;
  64319. private _unpackBinary;
  64320. private _unpackBinaryV1;
  64321. private _unpackBinaryV2;
  64322. private static _parseVersion;
  64323. private static _compareVersion;
  64324. private static _decodeBufferToText;
  64325. private static readonly _logSpaces;
  64326. private _logIndentLevel;
  64327. private _loggingEnabled;
  64328. /** @hidden */
  64329. _log: (message: string) => void;
  64330. /** @hidden */
  64331. _logOpen(message: string): void;
  64332. /** @hidden */
  64333. _logClose(): void;
  64334. private _logEnabled;
  64335. private _logDisabled;
  64336. private _capturePerformanceCounters;
  64337. /** @hidden */
  64338. _startPerformanceCounter: (counterName: string) => void;
  64339. /** @hidden */
  64340. _endPerformanceCounter: (counterName: string) => void;
  64341. private _startPerformanceCounterEnabled;
  64342. private _startPerformanceCounterDisabled;
  64343. private _endPerformanceCounterEnabled;
  64344. private _endPerformanceCounterDisabled;
  64345. }
  64346. }
  64347. declare module BABYLON.GLTF1 {
  64348. /**
  64349. * Enums
  64350. * @hidden
  64351. */
  64352. export enum EComponentType {
  64353. BYTE = 5120,
  64354. UNSIGNED_BYTE = 5121,
  64355. SHORT = 5122,
  64356. UNSIGNED_SHORT = 5123,
  64357. FLOAT = 5126
  64358. }
  64359. /** @hidden */
  64360. export enum EShaderType {
  64361. FRAGMENT = 35632,
  64362. VERTEX = 35633
  64363. }
  64364. /** @hidden */
  64365. export enum EParameterType {
  64366. BYTE = 5120,
  64367. UNSIGNED_BYTE = 5121,
  64368. SHORT = 5122,
  64369. UNSIGNED_SHORT = 5123,
  64370. INT = 5124,
  64371. UNSIGNED_INT = 5125,
  64372. FLOAT = 5126,
  64373. FLOAT_VEC2 = 35664,
  64374. FLOAT_VEC3 = 35665,
  64375. FLOAT_VEC4 = 35666,
  64376. INT_VEC2 = 35667,
  64377. INT_VEC3 = 35668,
  64378. INT_VEC4 = 35669,
  64379. BOOL = 35670,
  64380. BOOL_VEC2 = 35671,
  64381. BOOL_VEC3 = 35672,
  64382. BOOL_VEC4 = 35673,
  64383. FLOAT_MAT2 = 35674,
  64384. FLOAT_MAT3 = 35675,
  64385. FLOAT_MAT4 = 35676,
  64386. SAMPLER_2D = 35678
  64387. }
  64388. /** @hidden */
  64389. export enum ETextureWrapMode {
  64390. CLAMP_TO_EDGE = 33071,
  64391. MIRRORED_REPEAT = 33648,
  64392. REPEAT = 10497
  64393. }
  64394. /** @hidden */
  64395. export enum ETextureFilterType {
  64396. NEAREST = 9728,
  64397. LINEAR = 9728,
  64398. NEAREST_MIPMAP_NEAREST = 9984,
  64399. LINEAR_MIPMAP_NEAREST = 9985,
  64400. NEAREST_MIPMAP_LINEAR = 9986,
  64401. LINEAR_MIPMAP_LINEAR = 9987
  64402. }
  64403. /** @hidden */
  64404. export enum ETextureFormat {
  64405. ALPHA = 6406,
  64406. RGB = 6407,
  64407. RGBA = 6408,
  64408. LUMINANCE = 6409,
  64409. LUMINANCE_ALPHA = 6410
  64410. }
  64411. /** @hidden */
  64412. export enum ECullingType {
  64413. FRONT = 1028,
  64414. BACK = 1029,
  64415. FRONT_AND_BACK = 1032
  64416. }
  64417. /** @hidden */
  64418. export enum EBlendingFunction {
  64419. ZERO = 0,
  64420. ONE = 1,
  64421. SRC_COLOR = 768,
  64422. ONE_MINUS_SRC_COLOR = 769,
  64423. DST_COLOR = 774,
  64424. ONE_MINUS_DST_COLOR = 775,
  64425. SRC_ALPHA = 770,
  64426. ONE_MINUS_SRC_ALPHA = 771,
  64427. DST_ALPHA = 772,
  64428. ONE_MINUS_DST_ALPHA = 773,
  64429. CONSTANT_COLOR = 32769,
  64430. ONE_MINUS_CONSTANT_COLOR = 32770,
  64431. CONSTANT_ALPHA = 32771,
  64432. ONE_MINUS_CONSTANT_ALPHA = 32772,
  64433. SRC_ALPHA_SATURATE = 776
  64434. }
  64435. /** @hidden */
  64436. export interface IGLTFProperty {
  64437. extensions?: {
  64438. [key: string]: any;
  64439. };
  64440. extras?: Object;
  64441. }
  64442. /** @hidden */
  64443. export interface IGLTFChildRootProperty extends IGLTFProperty {
  64444. name?: string;
  64445. }
  64446. /** @hidden */
  64447. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  64448. bufferView: string;
  64449. byteOffset: number;
  64450. byteStride: number;
  64451. count: number;
  64452. type: string;
  64453. componentType: EComponentType;
  64454. max?: number[];
  64455. min?: number[];
  64456. name?: string;
  64457. }
  64458. /** @hidden */
  64459. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  64460. buffer: string;
  64461. byteOffset: number;
  64462. byteLength: number;
  64463. byteStride: number;
  64464. target?: number;
  64465. }
  64466. /** @hidden */
  64467. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  64468. uri: string;
  64469. byteLength?: number;
  64470. type?: string;
  64471. }
  64472. /** @hidden */
  64473. export interface IGLTFShader extends IGLTFChildRootProperty {
  64474. uri: string;
  64475. type: EShaderType;
  64476. }
  64477. /** @hidden */
  64478. export interface IGLTFProgram extends IGLTFChildRootProperty {
  64479. attributes: string[];
  64480. fragmentShader: string;
  64481. vertexShader: string;
  64482. }
  64483. /** @hidden */
  64484. export interface IGLTFTechniqueParameter {
  64485. type: number;
  64486. count?: number;
  64487. semantic?: string;
  64488. node?: string;
  64489. value?: number | boolean | string | Array<any>;
  64490. source?: string;
  64491. babylonValue?: any;
  64492. }
  64493. /** @hidden */
  64494. export interface IGLTFTechniqueCommonProfile {
  64495. lightingModel: string;
  64496. texcoordBindings: Object;
  64497. parameters?: Array<any>;
  64498. }
  64499. /** @hidden */
  64500. export interface IGLTFTechniqueStatesFunctions {
  64501. blendColor?: number[];
  64502. blendEquationSeparate?: number[];
  64503. blendFuncSeparate?: number[];
  64504. colorMask: boolean[];
  64505. cullFace: number[];
  64506. }
  64507. /** @hidden */
  64508. export interface IGLTFTechniqueStates {
  64509. enable: number[];
  64510. functions: IGLTFTechniqueStatesFunctions;
  64511. }
  64512. /** @hidden */
  64513. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  64514. parameters: {
  64515. [key: string]: IGLTFTechniqueParameter;
  64516. };
  64517. program: string;
  64518. attributes: {
  64519. [key: string]: string;
  64520. };
  64521. uniforms: {
  64522. [key: string]: string;
  64523. };
  64524. states: IGLTFTechniqueStates;
  64525. }
  64526. /** @hidden */
  64527. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  64528. technique?: string;
  64529. values: string[];
  64530. }
  64531. /** @hidden */
  64532. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  64533. attributes: {
  64534. [key: string]: string;
  64535. };
  64536. indices: string;
  64537. material: string;
  64538. mode?: number;
  64539. }
  64540. /** @hidden */
  64541. export interface IGLTFMesh extends IGLTFChildRootProperty {
  64542. primitives: IGLTFMeshPrimitive[];
  64543. }
  64544. /** @hidden */
  64545. export interface IGLTFImage extends IGLTFChildRootProperty {
  64546. uri: string;
  64547. }
  64548. /** @hidden */
  64549. export interface IGLTFSampler extends IGLTFChildRootProperty {
  64550. magFilter?: number;
  64551. minFilter?: number;
  64552. wrapS?: number;
  64553. wrapT?: number;
  64554. }
  64555. /** @hidden */
  64556. export interface IGLTFTexture extends IGLTFChildRootProperty {
  64557. sampler: string;
  64558. source: string;
  64559. format?: ETextureFormat;
  64560. internalFormat?: ETextureFormat;
  64561. target?: number;
  64562. type?: number;
  64563. babylonTexture?: Texture;
  64564. }
  64565. /** @hidden */
  64566. export interface IGLTFAmbienLight {
  64567. color?: number[];
  64568. }
  64569. /** @hidden */
  64570. export interface IGLTFDirectionalLight {
  64571. color?: number[];
  64572. }
  64573. /** @hidden */
  64574. export interface IGLTFPointLight {
  64575. color?: number[];
  64576. constantAttenuation?: number;
  64577. linearAttenuation?: number;
  64578. quadraticAttenuation?: number;
  64579. }
  64580. /** @hidden */
  64581. export interface IGLTFSpotLight {
  64582. color?: number[];
  64583. constantAttenuation?: number;
  64584. fallOfAngle?: number;
  64585. fallOffExponent?: number;
  64586. linearAttenuation?: number;
  64587. quadraticAttenuation?: number;
  64588. }
  64589. /** @hidden */
  64590. export interface IGLTFLight extends IGLTFChildRootProperty {
  64591. type: string;
  64592. }
  64593. /** @hidden */
  64594. export interface IGLTFCameraOrthographic {
  64595. xmag: number;
  64596. ymag: number;
  64597. zfar: number;
  64598. znear: number;
  64599. }
  64600. /** @hidden */
  64601. export interface IGLTFCameraPerspective {
  64602. aspectRatio: number;
  64603. yfov: number;
  64604. zfar: number;
  64605. znear: number;
  64606. }
  64607. /** @hidden */
  64608. export interface IGLTFCamera extends IGLTFChildRootProperty {
  64609. type: string;
  64610. }
  64611. /** @hidden */
  64612. export interface IGLTFAnimationChannelTarget {
  64613. id: string;
  64614. path: string;
  64615. }
  64616. /** @hidden */
  64617. export interface IGLTFAnimationChannel {
  64618. sampler: string;
  64619. target: IGLTFAnimationChannelTarget;
  64620. }
  64621. /** @hidden */
  64622. export interface IGLTFAnimationSampler {
  64623. input: string;
  64624. output: string;
  64625. interpolation?: string;
  64626. }
  64627. /** @hidden */
  64628. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  64629. channels?: IGLTFAnimationChannel[];
  64630. parameters?: {
  64631. [key: string]: string;
  64632. };
  64633. samplers?: {
  64634. [key: string]: IGLTFAnimationSampler;
  64635. };
  64636. }
  64637. /** @hidden */
  64638. export interface IGLTFNodeInstanceSkin {
  64639. skeletons: string[];
  64640. skin: string;
  64641. meshes: string[];
  64642. }
  64643. /** @hidden */
  64644. export interface IGLTFSkins extends IGLTFChildRootProperty {
  64645. bindShapeMatrix: number[];
  64646. inverseBindMatrices: string;
  64647. jointNames: string[];
  64648. babylonSkeleton?: Skeleton;
  64649. }
  64650. /** @hidden */
  64651. export interface IGLTFNode extends IGLTFChildRootProperty {
  64652. camera?: string;
  64653. children: string[];
  64654. skin?: string;
  64655. jointName?: string;
  64656. light?: string;
  64657. matrix: number[];
  64658. mesh?: string;
  64659. meshes?: string[];
  64660. rotation?: number[];
  64661. scale?: number[];
  64662. translation?: number[];
  64663. babylonNode?: Node;
  64664. }
  64665. /** @hidden */
  64666. export interface IGLTFScene extends IGLTFChildRootProperty {
  64667. nodes: string[];
  64668. }
  64669. /** @hidden */
  64670. export interface IGLTFRuntime {
  64671. extensions: {
  64672. [key: string]: any;
  64673. };
  64674. accessors: {
  64675. [key: string]: IGLTFAccessor;
  64676. };
  64677. buffers: {
  64678. [key: string]: IGLTFBuffer;
  64679. };
  64680. bufferViews: {
  64681. [key: string]: IGLTFBufferView;
  64682. };
  64683. meshes: {
  64684. [key: string]: IGLTFMesh;
  64685. };
  64686. lights: {
  64687. [key: string]: IGLTFLight;
  64688. };
  64689. cameras: {
  64690. [key: string]: IGLTFCamera;
  64691. };
  64692. nodes: {
  64693. [key: string]: IGLTFNode;
  64694. };
  64695. images: {
  64696. [key: string]: IGLTFImage;
  64697. };
  64698. textures: {
  64699. [key: string]: IGLTFTexture;
  64700. };
  64701. shaders: {
  64702. [key: string]: IGLTFShader;
  64703. };
  64704. programs: {
  64705. [key: string]: IGLTFProgram;
  64706. };
  64707. samplers: {
  64708. [key: string]: IGLTFSampler;
  64709. };
  64710. techniques: {
  64711. [key: string]: IGLTFTechnique;
  64712. };
  64713. materials: {
  64714. [key: string]: IGLTFMaterial;
  64715. };
  64716. animations: {
  64717. [key: string]: IGLTFAnimation;
  64718. };
  64719. skins: {
  64720. [key: string]: IGLTFSkins;
  64721. };
  64722. currentScene?: Object;
  64723. scenes: {
  64724. [key: string]: IGLTFScene;
  64725. };
  64726. extensionsUsed: string[];
  64727. extensionsRequired?: string[];
  64728. buffersCount: number;
  64729. shaderscount: number;
  64730. scene: Scene;
  64731. rootUrl: string;
  64732. loadedBufferCount: number;
  64733. loadedBufferViews: {
  64734. [name: string]: ArrayBufferView;
  64735. };
  64736. loadedShaderCount: number;
  64737. importOnlyMeshes: boolean;
  64738. importMeshesNames?: string[];
  64739. dummyNodes: Node[];
  64740. }
  64741. /** @hidden */
  64742. export interface INodeToRoot {
  64743. bone: Bone;
  64744. node: IGLTFNode;
  64745. id: string;
  64746. }
  64747. /** @hidden */
  64748. export interface IJointNode {
  64749. node: IGLTFNode;
  64750. id: string;
  64751. }
  64752. }
  64753. declare module BABYLON.GLTF1 {
  64754. /**
  64755. * Utils functions for GLTF
  64756. * @hidden
  64757. */
  64758. export class GLTFUtils {
  64759. /**
  64760. * Sets the given "parameter" matrix
  64761. * @param scene: the Scene object
  64762. * @param source: the source node where to pick the matrix
  64763. * @param parameter: the GLTF technique parameter
  64764. * @param uniformName: the name of the shader's uniform
  64765. * @param shaderMaterial: the shader material
  64766. */
  64767. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  64768. /**
  64769. * Sets the given "parameter" matrix
  64770. * @param shaderMaterial: the shader material
  64771. * @param uniform: the name of the shader's uniform
  64772. * @param value: the value of the uniform
  64773. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  64774. */
  64775. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  64776. /**
  64777. * Returns the wrap mode of the texture
  64778. * @param mode: the mode value
  64779. */
  64780. static GetWrapMode(mode: number): number;
  64781. /**
  64782. * Returns the byte stride giving an accessor
  64783. * @param accessor: the GLTF accessor objet
  64784. */
  64785. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  64786. /**
  64787. * Returns the texture filter mode giving a mode value
  64788. * @param mode: the filter mode value
  64789. */
  64790. static GetTextureFilterMode(mode: number): ETextureFilterType;
  64791. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  64792. /**
  64793. * Returns a buffer from its accessor
  64794. * @param gltfRuntime: the GLTF runtime
  64795. * @param accessor: the GLTF accessor
  64796. */
  64797. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  64798. /**
  64799. * Decodes a buffer view into a string
  64800. * @param view: the buffer view
  64801. */
  64802. static DecodeBufferToText(view: ArrayBufferView): string;
  64803. /**
  64804. * Returns the default material of gltf. Related to
  64805. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  64806. * @param scene: the Babylon.js scene
  64807. */
  64808. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  64809. private static _DefaultMaterial;
  64810. }
  64811. }
  64812. declare module BABYLON.GLTF1 {
  64813. /**
  64814. * Implementation of the base glTF spec
  64815. * @hidden
  64816. */
  64817. export class GLTFLoaderBase {
  64818. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  64819. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64820. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  64821. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64822. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  64823. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64824. }
  64825. /**
  64826. * glTF V1 Loader
  64827. * @hidden
  64828. */
  64829. export class GLTFLoader implements IGLTFLoader {
  64830. static Extensions: {
  64831. [name: string]: GLTFLoaderExtension;
  64832. };
  64833. static RegisterExtension(extension: GLTFLoaderExtension): void;
  64834. state: Nullable<GLTFLoaderState>;
  64835. dispose(): void;
  64836. private _importMeshAsync;
  64837. /**
  64838. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  64839. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64840. * @param scene the scene the meshes should be added to
  64841. * @param data gltf data containing information of the meshes in a loaded file
  64842. * @param rootUrl root url to load from
  64843. * @param onProgress event that fires when loading progress has occured
  64844. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64845. */
  64846. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  64847. meshes: AbstractMesh[];
  64848. particleSystems: IParticleSystem[];
  64849. skeletons: Skeleton[];
  64850. animationGroups: AnimationGroup[];
  64851. }>;
  64852. private _loadAsync;
  64853. /**
  64854. * Imports all objects from a loaded gltf file and adds them to the scene
  64855. * @param scene the scene the objects should be added to
  64856. * @param data gltf data containing information of the meshes in a loaded file
  64857. * @param rootUrl root url to load from
  64858. * @param onProgress event that fires when loading progress has occured
  64859. * @returns a promise which completes when objects have been loaded to the scene
  64860. */
  64861. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  64862. private _loadShadersAsync;
  64863. private _loadBuffersAsync;
  64864. private _createNodes;
  64865. }
  64866. /** @hidden */
  64867. export abstract class GLTFLoaderExtension {
  64868. private _name;
  64869. constructor(name: string);
  64870. readonly name: string;
  64871. /**
  64872. * Defines an override for loading the runtime
  64873. * Return true to stop further extensions from loading the runtime
  64874. */
  64875. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  64876. /**
  64877. * Defines an onverride for creating gltf runtime
  64878. * Return true to stop further extensions from creating the runtime
  64879. */
  64880. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  64881. /**
  64882. * Defines an override for loading buffers
  64883. * Return true to stop further extensions from loading this buffer
  64884. */
  64885. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  64886. /**
  64887. * Defines an override for loading texture buffers
  64888. * Return true to stop further extensions from loading this texture data
  64889. */
  64890. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64891. /**
  64892. * Defines an override for creating textures
  64893. * Return true to stop further extensions from loading this texture
  64894. */
  64895. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  64896. /**
  64897. * Defines an override for loading shader strings
  64898. * Return true to stop further extensions from loading this shader data
  64899. */
  64900. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64901. /**
  64902. * Defines an override for loading materials
  64903. * Return true to stop further extensions from loading this material
  64904. */
  64905. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64906. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  64907. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  64908. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64909. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64910. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  64911. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64912. private static LoadTextureBufferAsync;
  64913. private static CreateTextureAsync;
  64914. private static ApplyExtensions;
  64915. }
  64916. }
  64917. declare module BABYLON.GLTF1 {
  64918. /** @hidden */
  64919. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  64920. private _bin;
  64921. constructor();
  64922. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  64923. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64924. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64925. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64926. }
  64927. }
  64928. declare module BABYLON.GLTF1 {
  64929. /** @hidden */
  64930. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  64931. constructor();
  64932. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  64933. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64934. private _loadTexture;
  64935. }
  64936. }
  64937. declare module BABYLON.GLTF2.Loader {
  64938. /**
  64939. * Loader interface with an index field.
  64940. */
  64941. export interface IArrayItem {
  64942. /**
  64943. * The index of this item in the array.
  64944. */
  64945. index: number;
  64946. }
  64947. /**
  64948. * Loader interface with additional members.
  64949. */
  64950. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  64951. /** @hidden */
  64952. _data?: Promise<ArrayBufferView>;
  64953. /** @hidden */
  64954. _babylonVertexBuffer?: Promise<VertexBuffer>;
  64955. }
  64956. /**
  64957. * Loader interface with additional members.
  64958. */
  64959. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  64960. }
  64961. /** @hidden */
  64962. export interface _IAnimationSamplerData {
  64963. input: Float32Array;
  64964. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  64965. output: Float32Array;
  64966. }
  64967. /**
  64968. * Loader interface with additional members.
  64969. */
  64970. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  64971. /** @hidden */
  64972. _data?: Promise<_IAnimationSamplerData>;
  64973. }
  64974. /**
  64975. * Loader interface with additional members.
  64976. */
  64977. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  64978. channels: IAnimationChannel[];
  64979. samplers: IAnimationSampler[];
  64980. /** @hidden */
  64981. _babylonAnimationGroup?: AnimationGroup;
  64982. }
  64983. /**
  64984. * Loader interface with additional members.
  64985. */
  64986. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  64987. /** @hidden */
  64988. _data?: Promise<ArrayBufferView>;
  64989. }
  64990. /**
  64991. * Loader interface with additional members.
  64992. */
  64993. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  64994. /** @hidden */
  64995. _data?: Promise<ArrayBufferView>;
  64996. /** @hidden */
  64997. _babylonBuffer?: Promise<Buffer>;
  64998. }
  64999. /**
  65000. * Loader interface with additional members.
  65001. */
  65002. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  65003. }
  65004. /**
  65005. * Loader interface with additional members.
  65006. */
  65007. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  65008. /** @hidden */
  65009. _data?: Promise<ArrayBufferView>;
  65010. }
  65011. /**
  65012. * Loader interface with additional members.
  65013. */
  65014. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  65015. }
  65016. /**
  65017. * Loader interface with additional members.
  65018. */
  65019. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  65020. }
  65021. /**
  65022. * Loader interface with additional members.
  65023. */
  65024. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  65025. baseColorTexture?: ITextureInfo;
  65026. metallicRoughnessTexture?: ITextureInfo;
  65027. }
  65028. /**
  65029. * Loader interface with additional members.
  65030. */
  65031. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  65032. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  65033. normalTexture?: IMaterialNormalTextureInfo;
  65034. occlusionTexture?: IMaterialOcclusionTextureInfo;
  65035. emissiveTexture?: ITextureInfo;
  65036. /** @hidden */
  65037. _data?: {
  65038. [babylonDrawMode: number]: {
  65039. babylonMaterial: Material;
  65040. babylonMeshes: AbstractMesh[];
  65041. promise: Promise<void>;
  65042. };
  65043. };
  65044. }
  65045. /**
  65046. * Loader interface with additional members.
  65047. */
  65048. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  65049. primitives: IMeshPrimitive[];
  65050. }
  65051. /**
  65052. * Loader interface with additional members.
  65053. */
  65054. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  65055. /** @hidden */
  65056. _instanceData?: {
  65057. babylonSourceMesh: Mesh;
  65058. promise: Promise<any>;
  65059. };
  65060. }
  65061. /**
  65062. * Loader interface with additional members.
  65063. */
  65064. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  65065. /**
  65066. * The parent glTF node.
  65067. */
  65068. parent?: INode;
  65069. /** @hidden */
  65070. _babylonTransformNode?: TransformNode;
  65071. /** @hidden */
  65072. _primitiveBabylonMeshes?: AbstractMesh[];
  65073. /** @hidden */
  65074. _babylonBones?: Bone[];
  65075. /** @hidden */
  65076. _numMorphTargets?: number;
  65077. }
  65078. /** @hidden */
  65079. export interface _ISamplerData {
  65080. noMipMaps: boolean;
  65081. samplingMode: number;
  65082. wrapU: number;
  65083. wrapV: number;
  65084. }
  65085. /**
  65086. * Loader interface with additional members.
  65087. */
  65088. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  65089. /** @hidden */
  65090. _data?: _ISamplerData;
  65091. }
  65092. /**
  65093. * Loader interface with additional members.
  65094. */
  65095. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  65096. }
  65097. /**
  65098. * Loader interface with additional members.
  65099. */
  65100. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  65101. /** @hidden */
  65102. _data?: {
  65103. babylonSkeleton: Skeleton;
  65104. promise: Promise<void>;
  65105. };
  65106. }
  65107. /**
  65108. * Loader interface with additional members.
  65109. */
  65110. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  65111. }
  65112. /**
  65113. * Loader interface with additional members.
  65114. */
  65115. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  65116. }
  65117. /**
  65118. * Loader interface with additional members.
  65119. */
  65120. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  65121. accessors?: IAccessor[];
  65122. animations?: IAnimation[];
  65123. buffers?: IBuffer[];
  65124. bufferViews?: IBufferView[];
  65125. cameras?: ICamera[];
  65126. images?: IImage[];
  65127. materials?: IMaterial[];
  65128. meshes?: IMesh[];
  65129. nodes?: INode[];
  65130. samplers?: ISampler[];
  65131. scenes?: IScene[];
  65132. skins?: ISkin[];
  65133. textures?: ITexture[];
  65134. }
  65135. }
  65136. declare module BABYLON.GLTF2 {
  65137. /**
  65138. * Interface for a glTF loader extension.
  65139. */
  65140. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  65141. /**
  65142. * Called after the loader state changes to LOADING.
  65143. */
  65144. onLoading?(): void;
  65145. /**
  65146. * Called after the loader state changes to READY.
  65147. */
  65148. onReady?(): void;
  65149. /**
  65150. * Define this method to modify the default behavior when loading scenes.
  65151. * @param context The context when loading the asset
  65152. * @param scene The glTF scene property
  65153. * @returns A promise that resolves when the load is complete or null if not handled
  65154. */
  65155. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  65156. /**
  65157. * Define this method to modify the default behavior when loading nodes.
  65158. * @param context The context when loading the asset
  65159. * @param node The glTF node property
  65160. * @param assign A function called synchronously after parsing the glTF properties
  65161. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  65162. */
  65163. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65164. /**
  65165. * Define this method to modify the default behavior when loading cameras.
  65166. * @param context The context when loading the asset
  65167. * @param camera The glTF camera property
  65168. * @param assign A function called synchronously after parsing the glTF properties
  65169. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  65170. */
  65171. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  65172. /**
  65173. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  65174. * @param context The context when loading the asset
  65175. * @param primitive The glTF mesh primitive property
  65176. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  65177. */
  65178. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65179. /**
  65180. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  65181. * @param context The context when loading the asset
  65182. * @param name The mesh name when loading the asset
  65183. * @param node The glTF node when loading the asset
  65184. * @param mesh The glTF mesh when loading the asset
  65185. * @param primitive The glTF mesh primitive property
  65186. * @param assign A function called synchronously after parsing the glTF properties
  65187. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  65188. */
  65189. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  65190. /**
  65191. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  65192. * @param context The context when loading the asset
  65193. * @param material The glTF material property
  65194. * @param assign A function called synchronously after parsing the glTF properties
  65195. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  65196. */
  65197. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65198. /**
  65199. * Define this method to modify the default behavior when creating materials.
  65200. * @param context The context when loading the asset
  65201. * @param material The glTF material property
  65202. * @param babylonDrawMode The draw mode for the Babylon material
  65203. * @returns The Babylon material or null if not handled
  65204. */
  65205. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  65206. /**
  65207. * Define this method to modify the default behavior when loading material properties.
  65208. * @param context The context when loading the asset
  65209. * @param material The glTF material property
  65210. * @param babylonMaterial The Babylon material
  65211. * @returns A promise that resolves when the load is complete or null if not handled
  65212. */
  65213. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65214. /**
  65215. * Define this method to modify the default behavior when loading texture infos.
  65216. * @param context The context when loading the asset
  65217. * @param textureInfo The glTF texture info property
  65218. * @param assign A function called synchronously after parsing the glTF properties
  65219. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  65220. */
  65221. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65222. /**
  65223. * Define this method to modify the default behavior when loading animations.
  65224. * @param context The context when loading the asset
  65225. * @param animation The glTF animation property
  65226. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  65227. */
  65228. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65229. /**
  65230. * @hidden Define this method to modify the default behavior when loading skins.
  65231. * @param context The context when loading the asset
  65232. * @param node The glTF node property
  65233. * @param skin The glTF skin property
  65234. * @returns A promise that resolves when the load is complete or null if not handled
  65235. */
  65236. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  65237. /**
  65238. * @hidden Define this method to modify the default behavior when loading uris.
  65239. * @param context The context when loading the asset
  65240. * @param property The glTF property associated with the uri
  65241. * @param uri The uri to load
  65242. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  65243. */
  65244. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65245. }
  65246. }
  65247. declare module BABYLON.GLTF2 {
  65248. /**
  65249. * Helper class for working with arrays when loading the glTF asset
  65250. */
  65251. export class ArrayItem {
  65252. /**
  65253. * Gets an item from the given array.
  65254. * @param context The context when loading the asset
  65255. * @param array The array to get the item from
  65256. * @param index The index to the array
  65257. * @returns The array item
  65258. */
  65259. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  65260. /**
  65261. * Assign an `index` field to each item of the given array.
  65262. * @param array The array of items
  65263. */
  65264. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  65265. }
  65266. /**
  65267. * The glTF 2.0 loader
  65268. */
  65269. export class GLTFLoader implements IGLTFLoader {
  65270. /** @hidden */
  65271. _completePromises: Promise<any>[];
  65272. private _disposed;
  65273. private _parent;
  65274. private _state;
  65275. private _extensions;
  65276. private _rootUrl;
  65277. private _fileName;
  65278. private _uniqueRootUrl;
  65279. private _gltf;
  65280. private _babylonScene;
  65281. private _rootBabylonMesh;
  65282. private _defaultBabylonMaterialData;
  65283. private _progressCallback?;
  65284. private _requests;
  65285. private static readonly _DefaultSampler;
  65286. private static _ExtensionNames;
  65287. private static _ExtensionFactories;
  65288. /**
  65289. * Registers a loader extension.
  65290. * @param name The name of the loader extension.
  65291. * @param factory The factory function that creates the loader extension.
  65292. */
  65293. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  65294. /**
  65295. * Unregisters a loader extension.
  65296. * @param name The name of the loader extenion.
  65297. * @returns A boolean indicating whether the extension has been unregistered
  65298. */
  65299. static UnregisterExtension(name: string): boolean;
  65300. /**
  65301. * Gets the loader state.
  65302. */
  65303. readonly state: Nullable<GLTFLoaderState>;
  65304. /**
  65305. * The glTF object parsed from the JSON.
  65306. */
  65307. readonly gltf: IGLTF;
  65308. /**
  65309. * The Babylon scene when loading the asset.
  65310. */
  65311. readonly babylonScene: Scene;
  65312. /**
  65313. * The root Babylon mesh when loading the asset.
  65314. */
  65315. readonly rootBabylonMesh: Mesh;
  65316. /** @hidden */
  65317. constructor(parent: GLTFFileLoader);
  65318. /** @hidden */
  65319. dispose(): void;
  65320. /** @hidden */
  65321. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65322. meshes: AbstractMesh[];
  65323. particleSystems: IParticleSystem[];
  65324. skeletons: Skeleton[];
  65325. animationGroups: AnimationGroup[];
  65326. }>;
  65327. /** @hidden */
  65328. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65329. private _loadAsync;
  65330. private _loadData;
  65331. private _setupData;
  65332. private _loadExtensions;
  65333. private _checkExtensions;
  65334. private _setState;
  65335. private _createRootNode;
  65336. /**
  65337. * Loads a glTF scene.
  65338. * @param context The context when loading the asset
  65339. * @param scene The glTF scene property
  65340. * @returns A promise that resolves when the load is complete
  65341. */
  65342. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  65343. private _forEachPrimitive;
  65344. private _getMeshes;
  65345. private _getSkeletons;
  65346. private _getAnimationGroups;
  65347. private _startAnimations;
  65348. /**
  65349. * Loads a glTF node.
  65350. * @param context The context when loading the asset
  65351. * @param node The glTF node property
  65352. * @param assign A function called synchronously after parsing the glTF properties
  65353. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  65354. */
  65355. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  65356. private _loadMeshAsync;
  65357. /**
  65358. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  65359. * @param context The context when loading the asset
  65360. * @param name The mesh name when loading the asset
  65361. * @param node The glTF node when loading the asset
  65362. * @param mesh The glTF mesh when loading the asset
  65363. * @param primitive The glTF mesh primitive property
  65364. * @param assign A function called synchronously after parsing the glTF properties
  65365. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  65366. */
  65367. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  65368. private _loadVertexDataAsync;
  65369. private _createMorphTargets;
  65370. private _loadMorphTargetsAsync;
  65371. private _loadMorphTargetVertexDataAsync;
  65372. private static _LoadTransform;
  65373. private _loadSkinAsync;
  65374. private _loadBones;
  65375. private _loadBone;
  65376. private _loadSkinInverseBindMatricesDataAsync;
  65377. private _updateBoneMatrices;
  65378. private _getNodeMatrix;
  65379. /**
  65380. * Loads a glTF camera.
  65381. * @param context The context when loading the asset
  65382. * @param camera The glTF camera property
  65383. * @param assign A function called synchronously after parsing the glTF properties
  65384. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  65385. */
  65386. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  65387. private _loadAnimationsAsync;
  65388. /**
  65389. * Loads a glTF animation.
  65390. * @param context The context when loading the asset
  65391. * @param animation The glTF animation property
  65392. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  65393. */
  65394. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  65395. /**
  65396. * @hidden Loads a glTF animation channel.
  65397. * @param context The context when loading the asset
  65398. * @param animationContext The context of the animation when loading the asset
  65399. * @param animation The glTF animation property
  65400. * @param channel The glTF animation channel property
  65401. * @param babylonAnimationGroup The babylon animation group property
  65402. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  65403. * @returns A void promise when the channel load is complete
  65404. */
  65405. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  65406. private _loadAnimationSamplerAsync;
  65407. private _loadBufferAsync;
  65408. /**
  65409. * Loads a glTF buffer view.
  65410. * @param context The context when loading the asset
  65411. * @param bufferView The glTF buffer view property
  65412. * @returns A promise that resolves with the loaded data when the load is complete
  65413. */
  65414. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  65415. private _loadAccessorAsync;
  65416. private _loadFloatAccessorAsync;
  65417. private _loadIndicesAccessorAsync;
  65418. private _loadVertexBufferViewAsync;
  65419. private _loadVertexAccessorAsync;
  65420. private _loadMaterialMetallicRoughnessPropertiesAsync;
  65421. /** @hidden */
  65422. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  65423. private _createDefaultMaterial;
  65424. /**
  65425. * Creates a Babylon material from a glTF material.
  65426. * @param context The context when loading the asset
  65427. * @param material The glTF material property
  65428. * @param babylonDrawMode The draw mode for the Babylon material
  65429. * @returns The Babylon material
  65430. */
  65431. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  65432. /**
  65433. * Loads properties from a glTF material into a Babylon material.
  65434. * @param context The context when loading the asset
  65435. * @param material The glTF material property
  65436. * @param babylonMaterial The Babylon material
  65437. * @returns A promise that resolves when the load is complete
  65438. */
  65439. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  65440. /**
  65441. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  65442. * @param context The context when loading the asset
  65443. * @param material The glTF material property
  65444. * @param babylonMaterial The Babylon material
  65445. * @returns A promise that resolves when the load is complete
  65446. */
  65447. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  65448. /**
  65449. * Loads the alpha properties from a glTF material into a Babylon material.
  65450. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  65451. * @param context The context when loading the asset
  65452. * @param material The glTF material property
  65453. * @param babylonMaterial The Babylon material
  65454. */
  65455. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  65456. /**
  65457. * Loads a glTF texture info.
  65458. * @param context The context when loading the asset
  65459. * @param textureInfo The glTF texture info property
  65460. * @param assign A function called synchronously after parsing the glTF properties
  65461. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  65462. */
  65463. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  65464. private _loadTextureAsync;
  65465. private _loadSampler;
  65466. /**
  65467. * Loads a glTF image.
  65468. * @param context The context when loading the asset
  65469. * @param image The glTF image property
  65470. * @returns A promise that resolves with the loaded data when the load is complete
  65471. */
  65472. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  65473. /**
  65474. * Loads a glTF uri.
  65475. * @param context The context when loading the asset
  65476. * @param property The glTF property associated with the uri
  65477. * @param uri The base64 or relative uri
  65478. * @returns A promise that resolves with the loaded data when the load is complete
  65479. */
  65480. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  65481. private _onProgress;
  65482. /**
  65483. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  65484. * @param babylonObject the Babylon object with metadata
  65485. * @param pointer the JSON pointer
  65486. */
  65487. static AddPointerMetadata(babylonObject: {
  65488. metadata: any;
  65489. }, pointer: string): void;
  65490. private static _GetTextureWrapMode;
  65491. private static _GetTextureSamplingMode;
  65492. private static _GetTypedArrayConstructor;
  65493. private static _GetTypedArray;
  65494. private static _GetNumComponents;
  65495. private static _ValidateUri;
  65496. private static _GetDrawMode;
  65497. private _compileMaterialsAsync;
  65498. private _compileShadowGeneratorsAsync;
  65499. private _forEachExtensions;
  65500. private _applyExtensions;
  65501. private _extensionsOnLoading;
  65502. private _extensionsOnReady;
  65503. private _extensionsLoadSceneAsync;
  65504. private _extensionsLoadNodeAsync;
  65505. private _extensionsLoadCameraAsync;
  65506. private _extensionsLoadVertexDataAsync;
  65507. private _extensionsLoadMeshPrimitiveAsync;
  65508. private _extensionsLoadMaterialAsync;
  65509. private _extensionsCreateMaterial;
  65510. private _extensionsLoadMaterialPropertiesAsync;
  65511. private _extensionsLoadTextureInfoAsync;
  65512. private _extensionsLoadAnimationAsync;
  65513. private _extensionsLoadSkinAsync;
  65514. private _extensionsLoadUriAsync;
  65515. /**
  65516. * Helper method called by a loader extension to load an glTF extension.
  65517. * @param context The context when loading the asset
  65518. * @param property The glTF property to load the extension from
  65519. * @param extensionName The name of the extension to load
  65520. * @param actionAsync The action to run
  65521. * @returns The promise returned by actionAsync or null if the extension does not exist
  65522. */
  65523. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  65524. /**
  65525. * Helper method called by a loader extension to load a glTF extra.
  65526. * @param context The context when loading the asset
  65527. * @param property The glTF property to load the extra from
  65528. * @param extensionName The name of the extension to load
  65529. * @param actionAsync The action to run
  65530. * @returns The promise returned by actionAsync or null if the extra does not exist
  65531. */
  65532. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  65533. /**
  65534. * Increments the indentation level and logs a message.
  65535. * @param message The message to log
  65536. */
  65537. logOpen(message: string): void;
  65538. /**
  65539. * Decrements the indentation level.
  65540. */
  65541. logClose(): void;
  65542. /**
  65543. * Logs a message
  65544. * @param message The message to log
  65545. */
  65546. log(message: string): void;
  65547. /**
  65548. * Starts a performance counter.
  65549. * @param counterName The name of the performance counter
  65550. */
  65551. startPerformanceCounter(counterName: string): void;
  65552. /**
  65553. * Ends a performance counter.
  65554. * @param counterName The name of the performance counter
  65555. */
  65556. endPerformanceCounter(counterName: string): void;
  65557. }
  65558. }
  65559. declare module BABYLON.GLTF2.Loader.Extensions {
  65560. /**
  65561. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  65562. */
  65563. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  65564. /** The name of this extension. */
  65565. readonly name: string;
  65566. /** Defines whether this extension is enabled. */
  65567. enabled: boolean;
  65568. private _loader;
  65569. private _lights?;
  65570. /** @hidden */
  65571. constructor(loader: GLTFLoader);
  65572. /** @hidden */
  65573. dispose(): void;
  65574. /** @hidden */
  65575. onLoading(): void;
  65576. /** @hidden */
  65577. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65578. private _loadLightAsync;
  65579. }
  65580. }
  65581. declare module BABYLON.GLTF2.Loader.Extensions {
  65582. /**
  65583. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  65584. */
  65585. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  65586. /** The name of this extension. */
  65587. readonly name: string;
  65588. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  65589. dracoCompression?: DracoCompression;
  65590. /** Defines whether this extension is enabled. */
  65591. enabled: boolean;
  65592. private _loader;
  65593. /** @hidden */
  65594. constructor(loader: GLTFLoader);
  65595. /** @hidden */
  65596. dispose(): void;
  65597. /** @hidden */
  65598. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65599. }
  65600. }
  65601. declare module BABYLON.GLTF2.Loader.Extensions {
  65602. /**
  65603. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  65604. */
  65605. export class KHR_lights implements IGLTFLoaderExtension {
  65606. /** The name of this extension. */
  65607. readonly name: string;
  65608. /** Defines whether this extension is enabled. */
  65609. enabled: boolean;
  65610. private _loader;
  65611. private _lights?;
  65612. /** @hidden */
  65613. constructor(loader: GLTFLoader);
  65614. /** @hidden */
  65615. dispose(): void;
  65616. /** @hidden */
  65617. onLoading(): void;
  65618. /** @hidden */
  65619. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65620. }
  65621. }
  65622. declare module BABYLON.GLTF2.Loader.Extensions {
  65623. /**
  65624. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  65625. */
  65626. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  65627. /** The name of this extension. */
  65628. readonly name: string;
  65629. /** Defines whether this extension is enabled. */
  65630. enabled: boolean;
  65631. private _loader;
  65632. /** @hidden */
  65633. constructor(loader: GLTFLoader);
  65634. /** @hidden */
  65635. dispose(): void;
  65636. /** @hidden */
  65637. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65638. private _loadSpecularGlossinessPropertiesAsync;
  65639. }
  65640. }
  65641. declare module BABYLON.GLTF2.Loader.Extensions {
  65642. /**
  65643. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  65644. */
  65645. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  65646. /** The name of this extension. */
  65647. readonly name: string;
  65648. /** Defines whether this extension is enabled. */
  65649. enabled: boolean;
  65650. private _loader;
  65651. /** @hidden */
  65652. constructor(loader: GLTFLoader);
  65653. /** @hidden */
  65654. dispose(): void;
  65655. /** @hidden */
  65656. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65657. private _loadUnlitPropertiesAsync;
  65658. }
  65659. }
  65660. declare module BABYLON.GLTF2.Loader.Extensions {
  65661. /**
  65662. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  65663. */
  65664. export class KHR_texture_transform implements IGLTFLoaderExtension {
  65665. /** The name of this extension. */
  65666. readonly name: string;
  65667. /** Defines whether this extension is enabled. */
  65668. enabled: boolean;
  65669. private _loader;
  65670. /** @hidden */
  65671. constructor(loader: GLTFLoader);
  65672. /** @hidden */
  65673. dispose(): void;
  65674. /** @hidden */
  65675. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65676. }
  65677. }
  65678. declare module BABYLON.GLTF2.Loader.Extensions {
  65679. /**
  65680. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  65681. */
  65682. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  65683. /** The name of this extension. */
  65684. readonly name: string;
  65685. /** Defines whether this extension is enabled. */
  65686. enabled: boolean;
  65687. private _loader;
  65688. private _clips;
  65689. private _emitters;
  65690. /** @hidden */
  65691. constructor(loader: GLTFLoader);
  65692. /** @hidden */
  65693. dispose(): void;
  65694. /** @hidden */
  65695. onLoading(): void;
  65696. /** @hidden */
  65697. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65698. /** @hidden */
  65699. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65700. /** @hidden */
  65701. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65702. private _loadClipAsync;
  65703. private _loadEmitterAsync;
  65704. private _getEventAction;
  65705. private _loadAnimationEventAsync;
  65706. }
  65707. }
  65708. declare module BABYLON.GLTF2.Loader.Extensions {
  65709. /**
  65710. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  65711. */
  65712. export class MSFT_lod implements IGLTFLoaderExtension {
  65713. /** The name of this extension. */
  65714. readonly name: string;
  65715. /** Defines whether this extension is enabled. */
  65716. enabled: boolean;
  65717. /**
  65718. * Maximum number of LODs to load, starting from the lowest LOD.
  65719. */
  65720. maxLODsToLoad: number;
  65721. /**
  65722. * Observable raised when all node LODs of one level are loaded.
  65723. * The event data is the index of the loaded LOD starting from zero.
  65724. * Dispose the loader to cancel the loading of the next level of LODs.
  65725. */
  65726. onNodeLODsLoadedObservable: Observable<number>;
  65727. /**
  65728. * Observable raised when all material LODs of one level are loaded.
  65729. * The event data is the index of the loaded LOD starting from zero.
  65730. * Dispose the loader to cancel the loading of the next level of LODs.
  65731. */
  65732. onMaterialLODsLoadedObservable: Observable<number>;
  65733. private _loader;
  65734. private _nodeIndexLOD;
  65735. private _nodeSignalLODs;
  65736. private _nodePromiseLODs;
  65737. private _materialIndexLOD;
  65738. private _materialSignalLODs;
  65739. private _materialPromiseLODs;
  65740. /** @hidden */
  65741. constructor(loader: GLTFLoader);
  65742. /** @hidden */
  65743. dispose(): void;
  65744. /** @hidden */
  65745. onReady(): void;
  65746. /** @hidden */
  65747. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65748. /** @hidden */
  65749. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65750. /** @hidden */
  65751. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65752. /**
  65753. * Gets an array of LOD properties from lowest to highest.
  65754. */
  65755. private _getLODs;
  65756. private _disposeUnusedMaterials;
  65757. }
  65758. }
  65759. declare module BABYLON.GLTF2.Loader.Extensions {
  65760. /** @hidden */
  65761. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  65762. readonly name: string;
  65763. enabled: boolean;
  65764. private _loader;
  65765. constructor(loader: GLTFLoader);
  65766. dispose(): void;
  65767. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65768. }
  65769. }
  65770. declare module BABYLON.GLTF2.Loader.Extensions {
  65771. /** @hidden */
  65772. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  65773. readonly name: string;
  65774. enabled: boolean;
  65775. private _loader;
  65776. constructor(loader: GLTFLoader);
  65777. dispose(): void;
  65778. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65779. }
  65780. }
  65781. declare module BABYLON.GLTF2.Loader.Extensions {
  65782. /**
  65783. * Store glTF extras (if present) in BJS objects' metadata
  65784. */
  65785. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  65786. /** The name of this extension. */
  65787. readonly name: string;
  65788. /** Defines whether this extension is enabled. */
  65789. enabled: boolean;
  65790. private _loader;
  65791. private _assignExtras;
  65792. /** @hidden */
  65793. constructor(loader: GLTFLoader);
  65794. /** @hidden */
  65795. dispose(): void;
  65796. /** @hidden */
  65797. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65798. /** @hidden */
  65799. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  65800. /** @hidden */
  65801. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  65802. }
  65803. }
  65804. declare module BABYLON {
  65805. /**
  65806. * Class reading and parsing the MTL file bundled with the obj file.
  65807. */
  65808. export class MTLFileLoader {
  65809. /**
  65810. * All material loaded from the mtl will be set here
  65811. */
  65812. materials: StandardMaterial[];
  65813. /**
  65814. * This function will read the mtl file and create each material described inside
  65815. * This function could be improve by adding :
  65816. * -some component missing (Ni, Tf...)
  65817. * -including the specific options available
  65818. *
  65819. * @param scene defines the scene the material will be created in
  65820. * @param data defines the mtl data to parse
  65821. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  65822. */
  65823. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  65824. /**
  65825. * Gets the texture for the material.
  65826. *
  65827. * If the material is imported from input file,
  65828. * We sanitize the url to ensure it takes the textre from aside the material.
  65829. *
  65830. * @param rootUrl The root url to load from
  65831. * @param value The value stored in the mtl
  65832. * @return The Texture
  65833. */
  65834. private static _getTexture;
  65835. }
  65836. /**
  65837. * Options for loading OBJ/MTL files
  65838. */
  65839. type MeshLoadOptions = {
  65840. /**
  65841. * Defines if UVs are optimized by default during load.
  65842. */
  65843. OptimizeWithUV: boolean;
  65844. /**
  65845. * Defines custom scaling of UV coordinates of loaded meshes.
  65846. */
  65847. UVScaling: Vector2;
  65848. /**
  65849. * Invert model on y-axis (does a model scaling inversion)
  65850. */
  65851. InvertY: boolean;
  65852. /**
  65853. * Invert Y-Axis of referenced textures on load
  65854. */
  65855. InvertTextureY: boolean;
  65856. /**
  65857. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65858. */
  65859. ImportVertexColors: boolean;
  65860. /**
  65861. * Compute the normals for the model, even if normals are present in the file.
  65862. */
  65863. ComputeNormals: boolean;
  65864. /**
  65865. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65866. */
  65867. SkipMaterials: boolean;
  65868. /**
  65869. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65870. */
  65871. MaterialLoadingFailsSilently: boolean;
  65872. };
  65873. /**
  65874. * OBJ file type loader.
  65875. * This is a babylon scene loader plugin.
  65876. */
  65877. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65878. /**
  65879. * Defines if UVs are optimized by default during load.
  65880. */
  65881. static OPTIMIZE_WITH_UV: boolean;
  65882. /**
  65883. * Invert model on y-axis (does a model scaling inversion)
  65884. */
  65885. static INVERT_Y: boolean;
  65886. /**
  65887. * Invert Y-Axis of referenced textures on load
  65888. */
  65889. static INVERT_TEXTURE_Y: boolean;
  65890. /**
  65891. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65892. */
  65893. static IMPORT_VERTEX_COLORS: boolean;
  65894. /**
  65895. * Compute the normals for the model, even if normals are present in the file.
  65896. */
  65897. static COMPUTE_NORMALS: boolean;
  65898. /**
  65899. * Defines custom scaling of UV coordinates of loaded meshes.
  65900. */
  65901. static UV_SCALING: Vector2;
  65902. /**
  65903. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65904. */
  65905. static SKIP_MATERIALS: boolean;
  65906. /**
  65907. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65908. *
  65909. * Defaults to true for backwards compatibility.
  65910. */
  65911. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  65912. /**
  65913. * Defines the name of the plugin.
  65914. */
  65915. name: string;
  65916. /**
  65917. * Defines the extension the plugin is able to load.
  65918. */
  65919. extensions: string;
  65920. /** @hidden */
  65921. obj: RegExp;
  65922. /** @hidden */
  65923. group: RegExp;
  65924. /** @hidden */
  65925. mtllib: RegExp;
  65926. /** @hidden */
  65927. usemtl: RegExp;
  65928. /** @hidden */
  65929. smooth: RegExp;
  65930. /** @hidden */
  65931. vertexPattern: RegExp;
  65932. /** @hidden */
  65933. normalPattern: RegExp;
  65934. /** @hidden */
  65935. uvPattern: RegExp;
  65936. /** @hidden */
  65937. facePattern1: RegExp;
  65938. /** @hidden */
  65939. facePattern2: RegExp;
  65940. /** @hidden */
  65941. facePattern3: RegExp;
  65942. /** @hidden */
  65943. facePattern4: RegExp;
  65944. /** @hidden */
  65945. facePattern5: RegExp;
  65946. private _meshLoadOptions;
  65947. /**
  65948. * Creates loader for .OBJ files
  65949. *
  65950. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  65951. */
  65952. constructor(meshLoadOptions?: MeshLoadOptions);
  65953. private static readonly currentMeshLoadOptions;
  65954. /**
  65955. * Calls synchronously the MTL file attached to this obj.
  65956. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  65957. * Without this function materials are not displayed in the first frame (but displayed after).
  65958. * In consequence it is impossible to get material information in your HTML file
  65959. *
  65960. * @param url The URL of the MTL file
  65961. * @param rootUrl
  65962. * @param onSuccess Callback function to be called when the MTL file is loaded
  65963. * @private
  65964. */
  65965. private _loadMTL;
  65966. /**
  65967. * Instantiates a OBJ file loader plugin.
  65968. * @returns the created plugin
  65969. */
  65970. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  65971. /**
  65972. * If the data string can be loaded directly.
  65973. *
  65974. * @param data string containing the file data
  65975. * @returns if the data can be loaded directly
  65976. */
  65977. canDirectLoad(data: string): boolean;
  65978. /**
  65979. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  65980. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65981. * @param scene the scene the meshes should be added to
  65982. * @param data the OBJ data to load
  65983. * @param rootUrl root url to load from
  65984. * @param onProgress event that fires when loading progress has occured
  65985. * @param fileName Defines the name of the file to load
  65986. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65987. */
  65988. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65989. meshes: AbstractMesh[];
  65990. particleSystems: IParticleSystem[];
  65991. skeletons: Skeleton[];
  65992. animationGroups: AnimationGroup[];
  65993. }>;
  65994. /**
  65995. * Imports all objects from the loaded OBJ data and adds them to the scene
  65996. * @param scene the scene the objects should be added to
  65997. * @param data the OBJ data to load
  65998. * @param rootUrl root url to load from
  65999. * @param onProgress event that fires when loading progress has occured
  66000. * @param fileName Defines the name of the file to load
  66001. * @returns a promise which completes when objects have been loaded to the scene
  66002. */
  66003. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66004. /**
  66005. * Load into an asset container.
  66006. * @param scene The scene to load into
  66007. * @param data The data to import
  66008. * @param rootUrl The root url for scene and resources
  66009. * @param onProgress The callback when the load progresses
  66010. * @param fileName Defines the name of the file to load
  66011. * @returns The loaded asset container
  66012. */
  66013. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66014. /**
  66015. * Read the OBJ file and create an Array of meshes.
  66016. * Each mesh contains all information given by the OBJ and the MTL file.
  66017. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  66018. *
  66019. * @param meshesNames
  66020. * @param scene Scene The scene where are displayed the data
  66021. * @param data String The content of the obj file
  66022. * @param rootUrl String The path to the folder
  66023. * @returns Array<AbstractMesh>
  66024. * @private
  66025. */
  66026. private _parseSolid;
  66027. }
  66028. }
  66029. declare module BABYLON {
  66030. /**
  66031. * STL file type loader.
  66032. * This is a babylon scene loader plugin.
  66033. */
  66034. export class STLFileLoader implements ISceneLoaderPlugin {
  66035. /** @hidden */
  66036. solidPattern: RegExp;
  66037. /** @hidden */
  66038. facetsPattern: RegExp;
  66039. /** @hidden */
  66040. normalPattern: RegExp;
  66041. /** @hidden */
  66042. vertexPattern: RegExp;
  66043. /**
  66044. * Defines the name of the plugin.
  66045. */
  66046. name: string;
  66047. /**
  66048. * Defines the extensions the stl loader is able to load.
  66049. * force data to come in as an ArrayBuffer
  66050. * we'll convert to string if it looks like it's an ASCII .stl
  66051. */
  66052. extensions: ISceneLoaderPluginExtensions;
  66053. /**
  66054. * Import meshes into a scene.
  66055. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  66056. * @param scene The scene to import into
  66057. * @param data The data to import
  66058. * @param rootUrl The root url for scene and resources
  66059. * @param meshes The meshes array to import into
  66060. * @param particleSystems The particle systems array to import into
  66061. * @param skeletons The skeletons array to import into
  66062. * @param onError The callback when import fails
  66063. * @returns True if successful or false otherwise
  66064. */
  66065. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  66066. /**
  66067. * Load into a scene.
  66068. * @param scene The scene to load into
  66069. * @param data The data to import
  66070. * @param rootUrl The root url for scene and resources
  66071. * @param onError The callback when import fails
  66072. * @returns true if successful or false otherwise
  66073. */
  66074. load(scene: Scene, data: any, rootUrl: string): boolean;
  66075. /**
  66076. * Load into an asset container.
  66077. * @param scene The scene to load into
  66078. * @param data The data to import
  66079. * @param rootUrl The root url for scene and resources
  66080. * @param onError The callback when import fails
  66081. * @returns The loaded asset container
  66082. */
  66083. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  66084. private _isBinary;
  66085. private _parseBinary;
  66086. private _parseASCII;
  66087. }
  66088. }
  66089. declare module BABYLON {
  66090. /**
  66091. * Class for generating OBJ data from a Babylon scene.
  66092. */
  66093. export class OBJExport {
  66094. /**
  66095. * Exports the geometry of a Mesh array in .OBJ file format (text)
  66096. * @param mesh defines the list of meshes to serialize
  66097. * @param materials defines if materials should be exported
  66098. * @param matlibname defines the name of the associated mtl file
  66099. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  66100. * @returns the OBJ content
  66101. */
  66102. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  66103. /**
  66104. * Exports the material(s) of a mesh in .MTL file format (text)
  66105. * @param mesh defines the mesh to extract the material from
  66106. * @returns the mtl content
  66107. */
  66108. static MTL(mesh: Mesh): string;
  66109. }
  66110. }
  66111. declare module BABYLON {
  66112. /** @hidden */
  66113. export var __IGLTFExporterExtension: number;
  66114. /**
  66115. * Interface for extending the exporter
  66116. * @hidden
  66117. */
  66118. export interface IGLTFExporterExtension {
  66119. /**
  66120. * The name of this extension
  66121. */
  66122. readonly name: string;
  66123. /**
  66124. * Defines whether this extension is enabled
  66125. */
  66126. enabled: boolean;
  66127. /**
  66128. * Defines whether this extension is required
  66129. */
  66130. required: boolean;
  66131. }
  66132. }
  66133. declare module BABYLON.GLTF2.Exporter {
  66134. /** @hidden */
  66135. export var __IGLTFExporterExtensionV2: number;
  66136. /**
  66137. * Interface for a glTF exporter extension
  66138. * @hidden
  66139. */
  66140. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  66141. /**
  66142. * Define this method to modify the default behavior before exporting a texture
  66143. * @param context The context when loading the asset
  66144. * @param babylonTexture The glTF texture info property
  66145. * @param mimeType The mime-type of the generated image
  66146. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  66147. */
  66148. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66149. /**
  66150. * Define this method to modify the default behavior when exporting texture info
  66151. * @param context The context when loading the asset
  66152. * @param meshPrimitive glTF mesh primitive
  66153. * @param babylonSubMesh Babylon submesh
  66154. * @param binaryWriter glTF serializer binary writer instance
  66155. * @returns nullable IMeshPrimitive promise
  66156. */
  66157. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  66158. /**
  66159. * Define this method to modify the default behavior when exporting a node
  66160. * @param context The context when exporting the node
  66161. * @param node glTF node
  66162. * @param babylonNode BabylonJS node
  66163. * @returns nullable INode promise
  66164. */
  66165. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66166. /**
  66167. * Called after the exporter state changes to EXPORTING
  66168. */
  66169. onExporting?(): void;
  66170. }
  66171. }
  66172. declare module BABYLON.GLTF2.Exporter {
  66173. /**
  66174. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  66175. * @hidden
  66176. */
  66177. export class _GLTFMaterialExporter {
  66178. /**
  66179. * Represents the dielectric specular values for R, G and B
  66180. */
  66181. private static readonly _DielectricSpecular;
  66182. /**
  66183. * Allows the maximum specular power to be defined for material calculations
  66184. */
  66185. private static readonly _MaxSpecularPower;
  66186. /**
  66187. * Mapping to store textures
  66188. */
  66189. private _textureMap;
  66190. /**
  66191. * Numeric tolerance value
  66192. */
  66193. private static readonly _Epsilon;
  66194. /**
  66195. * Reference to the glTF Exporter
  66196. */
  66197. private _exporter;
  66198. constructor(exporter: _Exporter);
  66199. /**
  66200. * Specifies if two colors are approximately equal in value
  66201. * @param color1 first color to compare to
  66202. * @param color2 second color to compare to
  66203. * @param epsilon threshold value
  66204. */
  66205. private static FuzzyEquals;
  66206. /**
  66207. * Gets the materials from a Babylon scene and converts them to glTF materials
  66208. * @param scene babylonjs scene
  66209. * @param mimeType texture mime type
  66210. * @param images array of images
  66211. * @param textures array of textures
  66212. * @param materials array of materials
  66213. * @param imageData mapping of texture names to base64 textures
  66214. * @param hasTextureCoords specifies if texture coordinates are present on the material
  66215. */
  66216. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66217. /**
  66218. * Makes a copy of the glTF material without the texture parameters
  66219. * @param originalMaterial original glTF material
  66220. * @returns glTF material without texture parameters
  66221. */
  66222. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  66223. /**
  66224. * Specifies if the material has any texture parameters present
  66225. * @param material glTF Material
  66226. * @returns boolean specifying if texture parameters are present
  66227. */
  66228. _hasTexturesPresent(material: IMaterial): boolean;
  66229. /**
  66230. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  66231. * @param babylonStandardMaterial
  66232. * @returns glTF Metallic Roughness Material representation
  66233. */
  66234. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  66235. /**
  66236. * Computes the metallic factor
  66237. * @param diffuse diffused value
  66238. * @param specular specular value
  66239. * @param oneMinusSpecularStrength one minus the specular strength
  66240. * @returns metallic value
  66241. */
  66242. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  66243. /**
  66244. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  66245. * @param glTFMaterial glTF material
  66246. * @param babylonMaterial Babylon material
  66247. */
  66248. private static _SetAlphaMode;
  66249. /**
  66250. * Converts a Babylon Standard Material to a glTF Material
  66251. * @param babylonStandardMaterial BJS Standard Material
  66252. * @param mimeType mime type to use for the textures
  66253. * @param images array of glTF image interfaces
  66254. * @param textures array of glTF texture interfaces
  66255. * @param materials array of glTF material interfaces
  66256. * @param imageData map of image file name to data
  66257. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66258. */
  66259. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66260. /**
  66261. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  66262. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  66263. * @param mimeType mime type to use for the textures
  66264. * @param images array of glTF image interfaces
  66265. * @param textures array of glTF texture interfaces
  66266. * @param materials array of glTF material interfaces
  66267. * @param imageData map of image file name to data
  66268. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66269. */
  66270. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66271. /**
  66272. * Converts an image typed array buffer to a base64 image
  66273. * @param buffer typed array buffer
  66274. * @param width width of the image
  66275. * @param height height of the image
  66276. * @param mimeType mimetype of the image
  66277. * @returns base64 image string
  66278. */
  66279. private _createBase64FromCanvasAsync;
  66280. /**
  66281. * Generates a white texture based on the specified width and height
  66282. * @param width width of the texture in pixels
  66283. * @param height height of the texture in pixels
  66284. * @param scene babylonjs scene
  66285. * @returns white texture
  66286. */
  66287. private _createWhiteTexture;
  66288. /**
  66289. * 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
  66290. * @param texture1 first texture to resize
  66291. * @param texture2 second texture to resize
  66292. * @param scene babylonjs scene
  66293. * @returns resized textures or null
  66294. */
  66295. private _resizeTexturesToSameDimensions;
  66296. /**
  66297. * Converts an array of pixels to a Float32Array
  66298. * Throws an error if the pixel format is not supported
  66299. * @param pixels - array buffer containing pixel values
  66300. * @returns Float32 of pixels
  66301. */
  66302. private _convertPixelArrayToFloat32;
  66303. /**
  66304. * Convert Specular Glossiness Textures to Metallic Roughness
  66305. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  66306. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  66307. * @param diffuseTexture texture used to store diffuse information
  66308. * @param specularGlossinessTexture texture used to store specular and glossiness information
  66309. * @param factors specular glossiness material factors
  66310. * @param mimeType the mime type to use for the texture
  66311. * @returns pbr metallic roughness interface or null
  66312. */
  66313. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  66314. /**
  66315. * Converts specular glossiness material properties to metallic roughness
  66316. * @param specularGlossiness interface with specular glossiness material properties
  66317. * @returns interface with metallic roughness material properties
  66318. */
  66319. private _convertSpecularGlossinessToMetallicRoughness;
  66320. /**
  66321. * Calculates the surface reflectance, independent of lighting conditions
  66322. * @param color Color source to calculate brightness from
  66323. * @returns number representing the perceived brightness, or zero if color is undefined
  66324. */
  66325. private _getPerceivedBrightness;
  66326. /**
  66327. * Returns the maximum color component value
  66328. * @param color
  66329. * @returns maximum color component value, or zero if color is null or undefined
  66330. */
  66331. private _getMaxComponent;
  66332. /**
  66333. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  66334. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66335. * @param mimeType mime type to use for the textures
  66336. * @param images array of glTF image interfaces
  66337. * @param textures array of glTF texture interfaces
  66338. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66339. * @param imageData map of image file name to data
  66340. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66341. * @returns glTF PBR Metallic Roughness factors
  66342. */
  66343. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  66344. private _getGLTFTextureSampler;
  66345. private _getGLTFTextureWrapMode;
  66346. private _getGLTFTextureWrapModesSampler;
  66347. /**
  66348. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  66349. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66350. * @param mimeType mime type to use for the textures
  66351. * @param images array of glTF image interfaces
  66352. * @param textures array of glTF texture interfaces
  66353. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66354. * @param imageData map of image file name to data
  66355. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66356. * @returns glTF PBR Metallic Roughness factors
  66357. */
  66358. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  66359. /**
  66360. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  66361. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66362. * @param mimeType mime type to use for the textures
  66363. * @param images array of glTF image interfaces
  66364. * @param textures array of glTF texture interfaces
  66365. * @param materials array of glTF material interfaces
  66366. * @param imageData map of image file name to data
  66367. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66368. */
  66369. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66370. private setMetallicRoughnessPbrMaterial;
  66371. private getPixelsFromTexture;
  66372. /**
  66373. * Extracts a texture from a Babylon texture into file data and glTF data
  66374. * @param babylonTexture Babylon texture to extract
  66375. * @param mimeType Mime Type of the babylonTexture
  66376. * @return glTF texture info, or null if the texture format is not supported
  66377. */
  66378. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  66379. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  66380. /**
  66381. * Builds a texture from base64 string
  66382. * @param base64Texture base64 texture string
  66383. * @param baseTextureName Name to use for the texture
  66384. * @param mimeType image mime type for the texture
  66385. * @param images array of images
  66386. * @param textures array of textures
  66387. * @param imageData map of image data
  66388. * @returns glTF texture info, or null if the texture format is not supported
  66389. */
  66390. private _getTextureInfoFromBase64;
  66391. }
  66392. }
  66393. declare module BABYLON {
  66394. /**
  66395. * Class for holding and downloading glTF file data
  66396. */
  66397. export class GLTFData {
  66398. /**
  66399. * Object which contains the file name as the key and its data as the value
  66400. */
  66401. glTFFiles: {
  66402. [fileName: string]: string | Blob;
  66403. };
  66404. /**
  66405. * Initializes the glTF file object
  66406. */
  66407. constructor();
  66408. /**
  66409. * Downloads the glTF data as files based on their names and data
  66410. */
  66411. downloadFiles(): void;
  66412. }
  66413. }
  66414. declare module BABYLON {
  66415. /**
  66416. * Holds a collection of exporter options and parameters
  66417. */
  66418. export interface IExportOptions {
  66419. /**
  66420. * Function which indicates whether a babylon node should be exported or not
  66421. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  66422. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  66423. */
  66424. shouldExportNode?(node: Node): boolean;
  66425. /**
  66426. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  66427. * @param metadata source metadata to read from
  66428. * @returns the data to store to glTF node extras
  66429. */
  66430. metadataSelector?(metadata: any): any;
  66431. /**
  66432. * The sample rate to bake animation curves
  66433. */
  66434. animationSampleRate?: number;
  66435. /**
  66436. * Begin serialization without waiting for the scene to be ready
  66437. */
  66438. exportWithoutWaitingForScene?: boolean;
  66439. }
  66440. /**
  66441. * Class for generating glTF data from a Babylon scene.
  66442. */
  66443. export class GLTF2Export {
  66444. /**
  66445. * Exports the geometry of the scene to .gltf file format asynchronously
  66446. * @param scene Babylon scene with scene hierarchy information
  66447. * @param filePrefix File prefix to use when generating the glTF file
  66448. * @param options Exporter options
  66449. * @returns Returns an object with a .gltf file and associates texture names
  66450. * as keys and their data and paths as values
  66451. */
  66452. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  66453. private static _PreExportAsync;
  66454. private static _PostExportAsync;
  66455. /**
  66456. * Exports the geometry of the scene to .glb file format asychronously
  66457. * @param scene Babylon scene with scene hierarchy information
  66458. * @param filePrefix File prefix to use when generating glb file
  66459. * @param options Exporter options
  66460. * @returns Returns an object with a .glb filename as key and data as value
  66461. */
  66462. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  66463. }
  66464. }
  66465. declare module BABYLON.GLTF2.Exporter {
  66466. /**
  66467. * @hidden
  66468. */
  66469. export class _GLTFUtilities {
  66470. /**
  66471. * Creates a buffer view based on the supplied arguments
  66472. * @param bufferIndex index value of the specified buffer
  66473. * @param byteOffset byte offset value
  66474. * @param byteLength byte length of the bufferView
  66475. * @param byteStride byte distance between conequential elements
  66476. * @param name name of the buffer view
  66477. * @returns bufferView for glTF
  66478. */
  66479. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  66480. /**
  66481. * Creates an accessor based on the supplied arguments
  66482. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  66483. * @param name The name of the accessor
  66484. * @param type The type of the accessor
  66485. * @param componentType The datatype of components in the attribute
  66486. * @param count The number of attributes referenced by this accessor
  66487. * @param byteOffset The offset relative to the start of the bufferView in bytes
  66488. * @param min Minimum value of each component in this attribute
  66489. * @param max Maximum value of each component in this attribute
  66490. * @returns accessor for glTF
  66491. */
  66492. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  66493. /**
  66494. * Calculates the minimum and maximum values of an array of position floats
  66495. * @param positions Positions array of a mesh
  66496. * @param vertexStart Starting vertex offset to calculate min and max values
  66497. * @param vertexCount Number of vertices to check for min and max values
  66498. * @returns min number array and max number array
  66499. */
  66500. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  66501. min: number[];
  66502. max: number[];
  66503. };
  66504. /**
  66505. * Converts a new right-handed Vector3
  66506. * @param vector vector3 array
  66507. * @returns right-handed Vector3
  66508. */
  66509. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  66510. /**
  66511. * Converts a Vector3 to right-handed
  66512. * @param vector Vector3 to convert to right-handed
  66513. */
  66514. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  66515. /**
  66516. * Converts a three element number array to right-handed
  66517. * @param vector number array to convert to right-handed
  66518. */
  66519. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  66520. /**
  66521. * Converts a new right-handed Vector3
  66522. * @param vector vector3 array
  66523. * @returns right-handed Vector3
  66524. */
  66525. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  66526. /**
  66527. * Converts a Vector3 to right-handed
  66528. * @param vector Vector3 to convert to right-handed
  66529. */
  66530. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  66531. /**
  66532. * Converts a three element number array to right-handed
  66533. * @param vector number array to convert to right-handed
  66534. */
  66535. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  66536. /**
  66537. * Converts a Vector4 to right-handed
  66538. * @param vector Vector4 to convert to right-handed
  66539. */
  66540. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  66541. /**
  66542. * Converts a Vector4 to right-handed
  66543. * @param vector Vector4 to convert to right-handed
  66544. */
  66545. static _GetRightHandedArray4FromRef(vector: number[]): void;
  66546. /**
  66547. * Converts a Quaternion to right-handed
  66548. * @param quaternion Source quaternion to convert to right-handed
  66549. */
  66550. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  66551. /**
  66552. * Converts a Quaternion to right-handed
  66553. * @param quaternion Source quaternion to convert to right-handed
  66554. */
  66555. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  66556. static _NormalizeTangentFromRef(tangent: Vector4): void;
  66557. }
  66558. }
  66559. declare module BABYLON.GLTF2.Exporter {
  66560. /**
  66561. * Converts Babylon Scene into glTF 2.0.
  66562. * @hidden
  66563. */
  66564. export class _Exporter {
  66565. /**
  66566. * Stores the glTF to export
  66567. */
  66568. _glTF: IGLTF;
  66569. /**
  66570. * Stores all generated buffer views, which represents views into the main glTF buffer data
  66571. */
  66572. _bufferViews: IBufferView[];
  66573. /**
  66574. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  66575. */
  66576. _accessors: IAccessor[];
  66577. /**
  66578. * Stores all the generated nodes, which contains transform and/or mesh information per node
  66579. */
  66580. private _nodes;
  66581. /**
  66582. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  66583. */
  66584. private _scenes;
  66585. /**
  66586. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  66587. */
  66588. private _meshes;
  66589. /**
  66590. * Stores all the generated material information, which represents the appearance of each primitive
  66591. */
  66592. _materials: IMaterial[];
  66593. _materialMap: {
  66594. [materialID: number]: number;
  66595. };
  66596. /**
  66597. * Stores all the generated texture information, which is referenced by glTF materials
  66598. */
  66599. _textures: ITexture[];
  66600. /**
  66601. * Stores all the generated image information, which is referenced by glTF textures
  66602. */
  66603. _images: IImage[];
  66604. /**
  66605. * Stores all the texture samplers
  66606. */
  66607. _samplers: ISampler[];
  66608. /**
  66609. * Stores all the generated animation samplers, which is referenced by glTF animations
  66610. */
  66611. /**
  66612. * Stores the animations for glTF models
  66613. */
  66614. private _animations;
  66615. /**
  66616. * Stores the total amount of bytes stored in the glTF buffer
  66617. */
  66618. private _totalByteLength;
  66619. /**
  66620. * Stores a reference to the Babylon scene containing the source geometry and material information
  66621. */
  66622. _babylonScene: Scene;
  66623. /**
  66624. * Stores a map of the image data, where the key is the file name and the value
  66625. * is the image data
  66626. */
  66627. _imageData: {
  66628. [fileName: string]: {
  66629. data: Uint8Array;
  66630. mimeType: ImageMimeType;
  66631. };
  66632. };
  66633. /**
  66634. * Stores a map of the unique id of a node to its index in the node array
  66635. */
  66636. private _nodeMap;
  66637. /**
  66638. * Specifies if the Babylon scene should be converted to right-handed on export
  66639. */
  66640. _convertToRightHandedSystem: boolean;
  66641. /**
  66642. * Baked animation sample rate
  66643. */
  66644. private _animationSampleRate;
  66645. private _options;
  66646. private _localEngine;
  66647. _glTFMaterialExporter: _GLTFMaterialExporter;
  66648. private _extensions;
  66649. private static _ExtensionNames;
  66650. private static _ExtensionFactories;
  66651. private _applyExtensions;
  66652. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  66653. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  66654. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66655. private _forEachExtensions;
  66656. private _extensionsOnExporting;
  66657. /**
  66658. * Load glTF serializer extensions
  66659. */
  66660. private _loadExtensions;
  66661. /**
  66662. * Creates a glTF Exporter instance, which can accept optional exporter options
  66663. * @param babylonScene Babylon scene object
  66664. * @param options Options to modify the behavior of the exporter
  66665. */
  66666. constructor(babylonScene: Scene, options?: IExportOptions);
  66667. /**
  66668. * Registers a glTF exporter extension
  66669. * @param name Name of the extension to export
  66670. * @param factory The factory function that creates the exporter extension
  66671. */
  66672. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  66673. /**
  66674. * Un-registers an exporter extension
  66675. * @param name The name fo the exporter extension
  66676. * @returns A boolean indicating whether the extension has been un-registered
  66677. */
  66678. static UnregisterExtension(name: string): boolean;
  66679. /**
  66680. * Lazy load a local engine with premultiplied alpha set to false
  66681. */
  66682. _getLocalEngine(): Engine;
  66683. private reorderIndicesBasedOnPrimitiveMode;
  66684. /**
  66685. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  66686. * clock-wise during export to glTF
  66687. * @param submesh BabylonJS submesh
  66688. * @param primitiveMode Primitive mode of the mesh
  66689. * @param sideOrientation the winding order of the submesh
  66690. * @param vertexBufferKind The type of vertex attribute
  66691. * @param meshAttributeArray The vertex attribute data
  66692. * @param byteOffset The offset to the binary data
  66693. * @param binaryWriter The binary data for the glTF file
  66694. */
  66695. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  66696. /**
  66697. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  66698. * clock-wise during export to glTF
  66699. * @param submesh BabylonJS submesh
  66700. * @param primitiveMode Primitive mode of the mesh
  66701. * @param sideOrientation the winding order of the submesh
  66702. * @param vertexBufferKind The type of vertex attribute
  66703. * @param meshAttributeArray The vertex attribute data
  66704. * @param byteOffset The offset to the binary data
  66705. * @param binaryWriter The binary data for the glTF file
  66706. */
  66707. private reorderTriangleFillMode;
  66708. /**
  66709. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  66710. * clock-wise during export to glTF
  66711. * @param submesh BabylonJS submesh
  66712. * @param primitiveMode Primitive mode of the mesh
  66713. * @param sideOrientation the winding order of the submesh
  66714. * @param vertexBufferKind The type of vertex attribute
  66715. * @param meshAttributeArray The vertex attribute data
  66716. * @param byteOffset The offset to the binary data
  66717. * @param binaryWriter The binary data for the glTF file
  66718. */
  66719. private reorderTriangleStripDrawMode;
  66720. /**
  66721. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  66722. * clock-wise during export to glTF
  66723. * @param submesh BabylonJS submesh
  66724. * @param primitiveMode Primitive mode of the mesh
  66725. * @param sideOrientation the winding order of the submesh
  66726. * @param vertexBufferKind The type of vertex attribute
  66727. * @param meshAttributeArray The vertex attribute data
  66728. * @param byteOffset The offset to the binary data
  66729. * @param binaryWriter The binary data for the glTF file
  66730. */
  66731. private reorderTriangleFanMode;
  66732. /**
  66733. * Writes the vertex attribute data to binary
  66734. * @param vertices The vertices to write to the binary writer
  66735. * @param byteOffset The offset into the binary writer to overwrite binary data
  66736. * @param vertexAttributeKind The vertex attribute type
  66737. * @param meshAttributeArray The vertex attribute data
  66738. * @param binaryWriter The writer containing the binary data
  66739. */
  66740. private writeVertexAttributeData;
  66741. /**
  66742. * Writes mesh attribute data to a data buffer
  66743. * Returns the bytelength of the data
  66744. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  66745. * @param meshAttributeArray Array containing the attribute data
  66746. * @param binaryWriter The buffer to write the binary data to
  66747. * @param indices Used to specify the order of the vertex data
  66748. */
  66749. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  66750. /**
  66751. * Generates glTF json data
  66752. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  66753. * @param glTFPrefix Text to use when prefixing a glTF file
  66754. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  66755. * @returns json data as string
  66756. */
  66757. private generateJSON;
  66758. /**
  66759. * Generates data for .gltf and .bin files based on the glTF prefix string
  66760. * @param glTFPrefix Text to use when prefixing a glTF file
  66761. * @returns GLTFData with glTF file data
  66762. */
  66763. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  66764. /**
  66765. * Creates a binary buffer for glTF
  66766. * @returns array buffer for binary data
  66767. */
  66768. private _generateBinaryAsync;
  66769. /**
  66770. * Pads the number to a multiple of 4
  66771. * @param num number to pad
  66772. * @returns padded number
  66773. */
  66774. private _getPadding;
  66775. /**
  66776. * Generates a glb file from the json and binary data
  66777. * Returns an object with the glb file name as the key and data as the value
  66778. * @param glTFPrefix
  66779. * @returns object with glb filename as key and data as value
  66780. */
  66781. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  66782. /**
  66783. * Sets the TRS for each node
  66784. * @param node glTF Node for storing the transformation data
  66785. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  66786. */
  66787. private setNodeTransformation;
  66788. private getVertexBufferFromMesh;
  66789. /**
  66790. * Creates a bufferview based on the vertices type for the Babylon mesh
  66791. * @param kind Indicates the type of vertices data
  66792. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  66793. * @param binaryWriter The buffer to write the bufferview data to
  66794. */
  66795. private createBufferViewKind;
  66796. /**
  66797. * The primitive mode of the Babylon mesh
  66798. * @param babylonMesh The BabylonJS mesh
  66799. */
  66800. private getMeshPrimitiveMode;
  66801. /**
  66802. * Sets the primitive mode of the glTF mesh primitive
  66803. * @param meshPrimitive glTF mesh primitive
  66804. * @param primitiveMode The primitive mode
  66805. */
  66806. private setPrimitiveMode;
  66807. /**
  66808. * Sets the vertex attribute accessor based of the glTF mesh primitive
  66809. * @param meshPrimitive glTF mesh primitive
  66810. * @param attributeKind vertex attribute
  66811. * @returns boolean specifying if uv coordinates are present
  66812. */
  66813. private setAttributeKind;
  66814. /**
  66815. * Sets data for the primitive attributes of each submesh
  66816. * @param mesh glTF Mesh object to store the primitive attribute information
  66817. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  66818. * @param binaryWriter Buffer to write the attribute data to
  66819. */
  66820. private setPrimitiveAttributesAsync;
  66821. /**
  66822. * Creates a glTF scene based on the array of meshes
  66823. * Returns the the total byte offset
  66824. * @param babylonScene Babylon scene to get the mesh data from
  66825. * @param binaryWriter Buffer to write binary data to
  66826. */
  66827. private createSceneAsync;
  66828. /**
  66829. * Creates a mapping of Node unique id to node index and handles animations
  66830. * @param babylonScene Babylon Scene
  66831. * @param nodes Babylon transform nodes
  66832. * @param binaryWriter Buffer to write binary data to
  66833. * @returns Node mapping of unique id to index
  66834. */
  66835. private createNodeMapAndAnimationsAsync;
  66836. /**
  66837. * Creates a glTF node from a Babylon mesh
  66838. * @param babylonMesh Source Babylon mesh
  66839. * @param binaryWriter Buffer for storing geometry data
  66840. * @returns glTF node
  66841. */
  66842. private createNodeAsync;
  66843. }
  66844. /**
  66845. * @hidden
  66846. *
  66847. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  66848. */
  66849. export class _BinaryWriter {
  66850. /**
  66851. * Array buffer which stores all binary data
  66852. */
  66853. private _arrayBuffer;
  66854. /**
  66855. * View of the array buffer
  66856. */
  66857. private _dataView;
  66858. /**
  66859. * byte offset of data in array buffer
  66860. */
  66861. private _byteOffset;
  66862. /**
  66863. * Initialize binary writer with an initial byte length
  66864. * @param byteLength Initial byte length of the array buffer
  66865. */
  66866. constructor(byteLength: number);
  66867. /**
  66868. * Resize the array buffer to the specified byte length
  66869. * @param byteLength
  66870. */
  66871. private resizeBuffer;
  66872. /**
  66873. * Get an array buffer with the length of the byte offset
  66874. * @returns ArrayBuffer resized to the byte offset
  66875. */
  66876. getArrayBuffer(): ArrayBuffer;
  66877. /**
  66878. * Get the byte offset of the array buffer
  66879. * @returns byte offset
  66880. */
  66881. getByteOffset(): number;
  66882. /**
  66883. * Stores an UInt8 in the array buffer
  66884. * @param entry
  66885. * @param byteOffset If defined, specifies where to set the value as an offset.
  66886. */
  66887. setUInt8(entry: number, byteOffset?: number): void;
  66888. /**
  66889. * Gets an UInt32 in the array buffer
  66890. * @param entry
  66891. * @param byteOffset If defined, specifies where to set the value as an offset.
  66892. */
  66893. getUInt32(byteOffset: number): number;
  66894. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66895. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66896. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66897. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66898. /**
  66899. * Stores a Float32 in the array buffer
  66900. * @param entry
  66901. */
  66902. setFloat32(entry: number, byteOffset?: number): void;
  66903. /**
  66904. * Stores an UInt32 in the array buffer
  66905. * @param entry
  66906. * @param byteOffset If defined, specifies where to set the value as an offset.
  66907. */
  66908. setUInt32(entry: number, byteOffset?: number): void;
  66909. }
  66910. }
  66911. declare module BABYLON.GLTF2.Exporter {
  66912. /**
  66913. * @hidden
  66914. * Interface to store animation data.
  66915. */
  66916. export interface _IAnimationData {
  66917. /**
  66918. * Keyframe data.
  66919. */
  66920. inputs: number[];
  66921. /**
  66922. * Value data.
  66923. */
  66924. outputs: number[][];
  66925. /**
  66926. * Animation interpolation data.
  66927. */
  66928. samplerInterpolation: AnimationSamplerInterpolation;
  66929. /**
  66930. * Minimum keyframe value.
  66931. */
  66932. inputsMin: number;
  66933. /**
  66934. * Maximum keyframe value.
  66935. */
  66936. inputsMax: number;
  66937. }
  66938. /**
  66939. * @hidden
  66940. */
  66941. export interface _IAnimationInfo {
  66942. /**
  66943. * The target channel for the animation
  66944. */
  66945. animationChannelTargetPath: AnimationChannelTargetPath;
  66946. /**
  66947. * The glTF accessor type for the data.
  66948. */
  66949. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  66950. /**
  66951. * Specifies if quaternions should be used.
  66952. */
  66953. useQuaternion: boolean;
  66954. }
  66955. /**
  66956. * @hidden
  66957. * Utility class for generating glTF animation data from BabylonJS.
  66958. */
  66959. export class _GLTFAnimation {
  66960. /**
  66961. * @ignore
  66962. *
  66963. * Creates glTF channel animation from BabylonJS animation.
  66964. * @param babylonTransformNode - BabylonJS mesh.
  66965. * @param animation - animation.
  66966. * @param animationChannelTargetPath - The target animation channel.
  66967. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  66968. * @param useQuaternion - Specifies if quaternions are used.
  66969. * @returns nullable IAnimationData
  66970. */
  66971. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  66972. private static _DeduceAnimationInfo;
  66973. /**
  66974. * @ignore
  66975. * Create node animations from the transform node animations
  66976. * @param babylonNode
  66977. * @param runtimeGLTFAnimation
  66978. * @param idleGLTFAnimations
  66979. * @param nodeMap
  66980. * @param nodes
  66981. * @param binaryWriter
  66982. * @param bufferViews
  66983. * @param accessors
  66984. * @param convertToRightHandedSystem
  66985. */
  66986. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  66987. [key: number]: number;
  66988. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66989. /**
  66990. * @ignore
  66991. * Create node animations from the animation groups
  66992. * @param babylonScene
  66993. * @param glTFAnimations
  66994. * @param nodeMap
  66995. * @param nodes
  66996. * @param binaryWriter
  66997. * @param bufferViews
  66998. * @param accessors
  66999. * @param convertToRightHandedSystem
  67000. */
  67001. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  67002. [key: number]: number;
  67003. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  67004. private static AddAnimation;
  67005. /**
  67006. * Create a baked animation
  67007. * @param babylonTransformNode BabylonJS mesh
  67008. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  67009. * @param animationChannelTargetPath animation target channel
  67010. * @param minFrame minimum animation frame
  67011. * @param maxFrame maximum animation frame
  67012. * @param fps frames per second of the animation
  67013. * @param inputs input key frames of the animation
  67014. * @param outputs output key frame data of the animation
  67015. * @param convertToRightHandedSystem converts the values to right-handed
  67016. * @param useQuaternion specifies if quaternions should be used
  67017. */
  67018. private static _CreateBakedAnimation;
  67019. private static _ConvertFactorToVector3OrQuaternion;
  67020. private static _SetInterpolatedValue;
  67021. /**
  67022. * Creates linear animation from the animation key frames
  67023. * @param babylonTransformNode BabylonJS mesh
  67024. * @param animation BabylonJS animation
  67025. * @param animationChannelTargetPath The target animation channel
  67026. * @param frameDelta The difference between the last and first frame of the animation
  67027. * @param inputs Array to store the key frame times
  67028. * @param outputs Array to store the key frame data
  67029. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  67030. * @param useQuaternion Specifies if quaternions are used in the animation
  67031. */
  67032. private static _CreateLinearOrStepAnimation;
  67033. /**
  67034. * Creates cubic spline animation from the animation key frames
  67035. * @param babylonTransformNode BabylonJS mesh
  67036. * @param animation BabylonJS animation
  67037. * @param animationChannelTargetPath The target animation channel
  67038. * @param frameDelta The difference between the last and first frame of the animation
  67039. * @param inputs Array to store the key frame times
  67040. * @param outputs Array to store the key frame data
  67041. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  67042. * @param useQuaternion Specifies if quaternions are used in the animation
  67043. */
  67044. private static _CreateCubicSplineAnimation;
  67045. private static _GetBasePositionRotationOrScale;
  67046. /**
  67047. * Adds a key frame value
  67048. * @param keyFrame
  67049. * @param animation
  67050. * @param outputs
  67051. * @param animationChannelTargetPath
  67052. * @param basePositionRotationOrScale
  67053. * @param convertToRightHandedSystem
  67054. * @param useQuaternion
  67055. */
  67056. private static _AddKeyframeValue;
  67057. /**
  67058. * Determine the interpolation based on the key frames
  67059. * @param keyFrames
  67060. * @param animationChannelTargetPath
  67061. * @param useQuaternion
  67062. */
  67063. private static _DeduceInterpolation;
  67064. /**
  67065. * Adds an input tangent or output tangent to the output data
  67066. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  67067. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  67068. * @param outputs The animation data by keyframe
  67069. * @param animationChannelTargetPath The target animation channel
  67070. * @param interpolation The interpolation type
  67071. * @param keyFrame The key frame with the animation data
  67072. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  67073. * @param useQuaternion Specifies if quaternions are used
  67074. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  67075. */
  67076. private static AddSplineTangent;
  67077. /**
  67078. * Get the minimum and maximum key frames' frame values
  67079. * @param keyFrames animation key frames
  67080. * @returns the minimum and maximum key frame value
  67081. */
  67082. private static calculateMinMaxKeyFrames;
  67083. }
  67084. }
  67085. declare module BABYLON.GLTF2.Exporter {
  67086. /** @hidden */
  67087. export var textureTransformPixelShader: {
  67088. name: string;
  67089. shader: string;
  67090. };
  67091. }
  67092. declare module BABYLON.GLTF2.Exporter.Extensions {
  67093. /**
  67094. * @hidden
  67095. */
  67096. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  67097. /** Name of this extension */
  67098. readonly name: string;
  67099. /** Defines whether this extension is enabled */
  67100. enabled: boolean;
  67101. /** Defines whether this extension is required */
  67102. required: boolean;
  67103. /** Reference to the glTF exporter */
  67104. private _exporter;
  67105. constructor(exporter: _Exporter);
  67106. dispose(): void;
  67107. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67108. /**
  67109. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  67110. * @param babylonTexture
  67111. * @param offset
  67112. * @param rotation
  67113. * @param scale
  67114. * @param scene
  67115. */
  67116. private _textureTransformTextureAsync;
  67117. }
  67118. }
  67119. declare module BABYLON.GLTF2.Exporter.Extensions {
  67120. /**
  67121. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  67122. */
  67123. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  67124. /** The name of this extension. */
  67125. readonly name: string;
  67126. /** Defines whether this extension is enabled. */
  67127. enabled: boolean;
  67128. /** Defines whether this extension is required */
  67129. required: boolean;
  67130. /** Reference to the glTF exporter */
  67131. private _exporter;
  67132. private _lights;
  67133. /** @hidden */
  67134. constructor(exporter: _Exporter);
  67135. /** @hidden */
  67136. dispose(): void;
  67137. /** @hidden */
  67138. onExporting(): void;
  67139. /**
  67140. * Define this method to modify the default behavior when exporting a node
  67141. * @param context The context when exporting the node
  67142. * @param node glTF node
  67143. * @param babylonNode BabylonJS node
  67144. * @returns nullable INode promise
  67145. */
  67146. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67147. }
  67148. }
  67149. declare module BABYLON {
  67150. /**
  67151. * Class for generating STL data from a Babylon scene.
  67152. */
  67153. export class STLExport {
  67154. /**
  67155. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  67156. * @param meshes list defines the mesh to serialize
  67157. * @param download triggers the automatic download of the file.
  67158. * @param fileName changes the downloads fileName.
  67159. * @param binary changes the STL to a binary type.
  67160. * @param isLittleEndian toggle for binary type exporter.
  67161. * @returns the STL as UTF8 string
  67162. */
  67163. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  67164. }
  67165. }
  67166. /**
  67167. * @ignoreChildren
  67168. * @ignore
  67169. */
  67170. declare module "babylonjs-gltf2interface" {
  67171. export = BABYLON.GLTF2;
  67172. }
  67173. /**
  67174. * Module for glTF 2.0 Interface
  67175. * @ignoreChildren
  67176. * @ignore
  67177. */
  67178. declare module BABYLON.GLTF2 {
  67179. /**
  67180. * The datatype of the components in the attribute
  67181. */
  67182. const enum AccessorComponentType {
  67183. /**
  67184. * Byte
  67185. */
  67186. BYTE = 5120,
  67187. /**
  67188. * Unsigned Byte
  67189. */
  67190. UNSIGNED_BYTE = 5121,
  67191. /**
  67192. * Short
  67193. */
  67194. SHORT = 5122,
  67195. /**
  67196. * Unsigned Short
  67197. */
  67198. UNSIGNED_SHORT = 5123,
  67199. /**
  67200. * Unsigned Int
  67201. */
  67202. UNSIGNED_INT = 5125,
  67203. /**
  67204. * Float
  67205. */
  67206. FLOAT = 5126,
  67207. }
  67208. /**
  67209. * Specifies if the attirbute is a scalar, vector, or matrix
  67210. */
  67211. const enum AccessorType {
  67212. /**
  67213. * Scalar
  67214. */
  67215. SCALAR = "SCALAR",
  67216. /**
  67217. * Vector2
  67218. */
  67219. VEC2 = "VEC2",
  67220. /**
  67221. * Vector3
  67222. */
  67223. VEC3 = "VEC3",
  67224. /**
  67225. * Vector4
  67226. */
  67227. VEC4 = "VEC4",
  67228. /**
  67229. * Matrix2x2
  67230. */
  67231. MAT2 = "MAT2",
  67232. /**
  67233. * Matrix3x3
  67234. */
  67235. MAT3 = "MAT3",
  67236. /**
  67237. * Matrix4x4
  67238. */
  67239. MAT4 = "MAT4",
  67240. }
  67241. /**
  67242. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  67243. */
  67244. const enum AnimationChannelTargetPath {
  67245. /**
  67246. * Translation
  67247. */
  67248. TRANSLATION = "translation",
  67249. /**
  67250. * Rotation
  67251. */
  67252. ROTATION = "rotation",
  67253. /**
  67254. * Scale
  67255. */
  67256. SCALE = "scale",
  67257. /**
  67258. * Weights
  67259. */
  67260. WEIGHTS = "weights",
  67261. }
  67262. /**
  67263. * Interpolation algorithm
  67264. */
  67265. const enum AnimationSamplerInterpolation {
  67266. /**
  67267. * The animated values are linearly interpolated between keyframes
  67268. */
  67269. LINEAR = "LINEAR",
  67270. /**
  67271. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  67272. */
  67273. STEP = "STEP",
  67274. /**
  67275. * The animation's interpolation is computed using a cubic spline with specified tangents
  67276. */
  67277. CUBICSPLINE = "CUBICSPLINE",
  67278. }
  67279. /**
  67280. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67281. */
  67282. const enum CameraType {
  67283. /**
  67284. * A perspective camera containing properties to create a perspective projection matrix
  67285. */
  67286. PERSPECTIVE = "perspective",
  67287. /**
  67288. * An orthographic camera containing properties to create an orthographic projection matrix
  67289. */
  67290. ORTHOGRAPHIC = "orthographic",
  67291. }
  67292. /**
  67293. * The mime-type of the image
  67294. */
  67295. const enum ImageMimeType {
  67296. /**
  67297. * JPEG Mime-type
  67298. */
  67299. JPEG = "image/jpeg",
  67300. /**
  67301. * PNG Mime-type
  67302. */
  67303. PNG = "image/png",
  67304. }
  67305. /**
  67306. * The alpha rendering mode of the material
  67307. */
  67308. const enum MaterialAlphaMode {
  67309. /**
  67310. * The alpha value is ignored and the rendered output is fully opaque
  67311. */
  67312. OPAQUE = "OPAQUE",
  67313. /**
  67314. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  67315. */
  67316. MASK = "MASK",
  67317. /**
  67318. * 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)
  67319. */
  67320. BLEND = "BLEND",
  67321. }
  67322. /**
  67323. * The type of the primitives to render
  67324. */
  67325. const enum MeshPrimitiveMode {
  67326. /**
  67327. * Points
  67328. */
  67329. POINTS = 0,
  67330. /**
  67331. * Lines
  67332. */
  67333. LINES = 1,
  67334. /**
  67335. * Line Loop
  67336. */
  67337. LINE_LOOP = 2,
  67338. /**
  67339. * Line Strip
  67340. */
  67341. LINE_STRIP = 3,
  67342. /**
  67343. * Triangles
  67344. */
  67345. TRIANGLES = 4,
  67346. /**
  67347. * Triangle Strip
  67348. */
  67349. TRIANGLE_STRIP = 5,
  67350. /**
  67351. * Triangle Fan
  67352. */
  67353. TRIANGLE_FAN = 6,
  67354. }
  67355. /**
  67356. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67357. */
  67358. const enum TextureMagFilter {
  67359. /**
  67360. * Nearest
  67361. */
  67362. NEAREST = 9728,
  67363. /**
  67364. * Linear
  67365. */
  67366. LINEAR = 9729,
  67367. }
  67368. /**
  67369. * Minification filter. All valid values correspond to WebGL enums
  67370. */
  67371. const enum TextureMinFilter {
  67372. /**
  67373. * Nearest
  67374. */
  67375. NEAREST = 9728,
  67376. /**
  67377. * Linear
  67378. */
  67379. LINEAR = 9729,
  67380. /**
  67381. * Nearest Mip-Map Nearest
  67382. */
  67383. NEAREST_MIPMAP_NEAREST = 9984,
  67384. /**
  67385. * Linear Mipmap Nearest
  67386. */
  67387. LINEAR_MIPMAP_NEAREST = 9985,
  67388. /**
  67389. * Nearest Mipmap Linear
  67390. */
  67391. NEAREST_MIPMAP_LINEAR = 9986,
  67392. /**
  67393. * Linear Mipmap Linear
  67394. */
  67395. LINEAR_MIPMAP_LINEAR = 9987,
  67396. }
  67397. /**
  67398. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67399. */
  67400. const enum TextureWrapMode {
  67401. /**
  67402. * Clamp to Edge
  67403. */
  67404. CLAMP_TO_EDGE = 33071,
  67405. /**
  67406. * Mirrored Repeat
  67407. */
  67408. MIRRORED_REPEAT = 33648,
  67409. /**
  67410. * Repeat
  67411. */
  67412. REPEAT = 10497,
  67413. }
  67414. /**
  67415. * glTF Property
  67416. */
  67417. interface IProperty {
  67418. /**
  67419. * Dictionary object with extension-specific objects
  67420. */
  67421. extensions?: {
  67422. [key: string]: any;
  67423. };
  67424. /**
  67425. * Application-Specific data
  67426. */
  67427. extras?: any;
  67428. }
  67429. /**
  67430. * glTF Child of Root Property
  67431. */
  67432. interface IChildRootProperty extends IProperty {
  67433. /**
  67434. * The user-defined name of this object
  67435. */
  67436. name?: string;
  67437. }
  67438. /**
  67439. * Indices of those attributes that deviate from their initialization value
  67440. */
  67441. interface IAccessorSparseIndices extends IProperty {
  67442. /**
  67443. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  67444. */
  67445. bufferView: number;
  67446. /**
  67447. * The offset relative to the start of the bufferView in bytes. Must be aligned
  67448. */
  67449. byteOffset?: number;
  67450. /**
  67451. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  67452. */
  67453. componentType: AccessorComponentType;
  67454. }
  67455. /**
  67456. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  67457. */
  67458. interface IAccessorSparseValues extends IProperty {
  67459. /**
  67460. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  67461. */
  67462. bufferView: number;
  67463. /**
  67464. * The offset relative to the start of the bufferView in bytes. Must be aligned
  67465. */
  67466. byteOffset?: number;
  67467. }
  67468. /**
  67469. * Sparse storage of attributes that deviate from their initialization value
  67470. */
  67471. interface IAccessorSparse extends IProperty {
  67472. /**
  67473. * The number of attributes encoded in this sparse accessor
  67474. */
  67475. count: number;
  67476. /**
  67477. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  67478. */
  67479. indices: IAccessorSparseIndices;
  67480. /**
  67481. * 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
  67482. */
  67483. values: IAccessorSparseValues;
  67484. }
  67485. /**
  67486. * 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
  67487. */
  67488. interface IAccessor extends IChildRootProperty {
  67489. /**
  67490. * The index of the bufferview
  67491. */
  67492. bufferView?: number;
  67493. /**
  67494. * The offset relative to the start of the bufferView in bytes
  67495. */
  67496. byteOffset?: number;
  67497. /**
  67498. * The datatype of components in the attribute
  67499. */
  67500. componentType: AccessorComponentType;
  67501. /**
  67502. * Specifies whether integer data values should be normalized
  67503. */
  67504. normalized?: boolean;
  67505. /**
  67506. * The number of attributes referenced by this accessor
  67507. */
  67508. count: number;
  67509. /**
  67510. * Specifies if the attribute is a scalar, vector, or matrix
  67511. */
  67512. type: AccessorType;
  67513. /**
  67514. * Maximum value of each component in this attribute
  67515. */
  67516. max?: number[];
  67517. /**
  67518. * Minimum value of each component in this attribute
  67519. */
  67520. min?: number[];
  67521. /**
  67522. * Sparse storage of attributes that deviate from their initialization value
  67523. */
  67524. sparse?: IAccessorSparse;
  67525. }
  67526. /**
  67527. * Targets an animation's sampler at a node's property
  67528. */
  67529. interface IAnimationChannel extends IProperty {
  67530. /**
  67531. * The index of a sampler in this animation used to compute the value for the target
  67532. */
  67533. sampler: number;
  67534. /**
  67535. * The index of the node and TRS property to target
  67536. */
  67537. target: IAnimationChannelTarget;
  67538. }
  67539. /**
  67540. * The index of the node and TRS property that an animation channel targets
  67541. */
  67542. interface IAnimationChannelTarget extends IProperty {
  67543. /**
  67544. * The index of the node to target
  67545. */
  67546. node: number;
  67547. /**
  67548. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  67549. */
  67550. path: AnimationChannelTargetPath;
  67551. }
  67552. /**
  67553. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  67554. */
  67555. interface IAnimationSampler extends IProperty {
  67556. /**
  67557. * The index of an accessor containing keyframe input values, e.g., time
  67558. */
  67559. input: number;
  67560. /**
  67561. * Interpolation algorithm
  67562. */
  67563. interpolation?: AnimationSamplerInterpolation;
  67564. /**
  67565. * The index of an accessor, containing keyframe output values
  67566. */
  67567. output: number;
  67568. }
  67569. /**
  67570. * A keyframe animation
  67571. */
  67572. interface IAnimation extends IChildRootProperty {
  67573. /**
  67574. * An array of channels, each of which targets an animation's sampler at a node's property
  67575. */
  67576. channels: IAnimationChannel[];
  67577. /**
  67578. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  67579. */
  67580. samplers: IAnimationSampler[];
  67581. }
  67582. /**
  67583. * Metadata about the glTF asset
  67584. */
  67585. interface IAsset extends IChildRootProperty {
  67586. /**
  67587. * A copyright message suitable for display to credit the content creator
  67588. */
  67589. copyright?: string;
  67590. /**
  67591. * Tool that generated this glTF model. Useful for debugging
  67592. */
  67593. generator?: string;
  67594. /**
  67595. * The glTF version that this asset targets
  67596. */
  67597. version: string;
  67598. /**
  67599. * The minimum glTF version that this asset targets
  67600. */
  67601. minVersion?: string;
  67602. }
  67603. /**
  67604. * A buffer points to binary geometry, animation, or skins
  67605. */
  67606. interface IBuffer extends IChildRootProperty {
  67607. /**
  67608. * 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
  67609. */
  67610. uri?: string;
  67611. /**
  67612. * The length of the buffer in bytes
  67613. */
  67614. byteLength: number;
  67615. }
  67616. /**
  67617. * A view into a buffer generally representing a subset of the buffer
  67618. */
  67619. interface IBufferView extends IChildRootProperty {
  67620. /**
  67621. * The index of the buffer
  67622. */
  67623. buffer: number;
  67624. /**
  67625. * The offset into the buffer in bytes
  67626. */
  67627. byteOffset?: number;
  67628. /**
  67629. * The lenth of the bufferView in bytes
  67630. */
  67631. byteLength: number;
  67632. /**
  67633. * The stride, in bytes
  67634. */
  67635. byteStride?: number;
  67636. }
  67637. /**
  67638. * An orthographic camera containing properties to create an orthographic projection matrix
  67639. */
  67640. interface ICameraOrthographic extends IProperty {
  67641. /**
  67642. * The floating-point horizontal magnification of the view. Must not be zero
  67643. */
  67644. xmag: number;
  67645. /**
  67646. * The floating-point vertical magnification of the view. Must not be zero
  67647. */
  67648. ymag: number;
  67649. /**
  67650. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  67651. */
  67652. zfar: number;
  67653. /**
  67654. * The floating-point distance to the near clipping plane
  67655. */
  67656. znear: number;
  67657. }
  67658. /**
  67659. * A perspective camera containing properties to create a perspective projection matrix
  67660. */
  67661. interface ICameraPerspective extends IProperty {
  67662. /**
  67663. * The floating-point aspect ratio of the field of view
  67664. */
  67665. aspectRatio?: number;
  67666. /**
  67667. * The floating-point vertical field of view in radians
  67668. */
  67669. yfov: number;
  67670. /**
  67671. * The floating-point distance to the far clipping plane
  67672. */
  67673. zfar?: number;
  67674. /**
  67675. * The floating-point distance to the near clipping plane
  67676. */
  67677. znear: number;
  67678. }
  67679. /**
  67680. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67681. */
  67682. interface ICamera extends IChildRootProperty {
  67683. /**
  67684. * An orthographic camera containing properties to create an orthographic projection matrix
  67685. */
  67686. orthographic?: ICameraOrthographic;
  67687. /**
  67688. * A perspective camera containing properties to create a perspective projection matrix
  67689. */
  67690. perspective?: ICameraPerspective;
  67691. /**
  67692. * Specifies if the camera uses a perspective or orthographic projection
  67693. */
  67694. type: CameraType;
  67695. }
  67696. /**
  67697. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  67698. */
  67699. interface IImage extends IChildRootProperty {
  67700. /**
  67701. * 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
  67702. */
  67703. uri?: string;
  67704. /**
  67705. * The image's MIME type
  67706. */
  67707. mimeType?: ImageMimeType;
  67708. /**
  67709. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  67710. */
  67711. bufferView?: number;
  67712. }
  67713. /**
  67714. * Material Normal Texture Info
  67715. */
  67716. interface IMaterialNormalTextureInfo extends ITextureInfo {
  67717. /**
  67718. * The scalar multiplier applied to each normal vector of the normal texture
  67719. */
  67720. scale?: number;
  67721. }
  67722. /**
  67723. * Material Occlusion Texture Info
  67724. */
  67725. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  67726. /**
  67727. * A scalar multiplier controlling the amount of occlusion applied
  67728. */
  67729. strength?: number;
  67730. }
  67731. /**
  67732. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  67733. */
  67734. interface IMaterialPbrMetallicRoughness {
  67735. /**
  67736. * The material's base color factor
  67737. */
  67738. baseColorFactor?: number[];
  67739. /**
  67740. * The base color texture
  67741. */
  67742. baseColorTexture?: ITextureInfo;
  67743. /**
  67744. * The metalness of the material
  67745. */
  67746. metallicFactor?: number;
  67747. /**
  67748. * The roughness of the material
  67749. */
  67750. roughnessFactor?: number;
  67751. /**
  67752. * The metallic-roughness texture
  67753. */
  67754. metallicRoughnessTexture?: ITextureInfo;
  67755. }
  67756. /**
  67757. * The material appearance of a primitive
  67758. */
  67759. interface IMaterial extends IChildRootProperty {
  67760. /**
  67761. * 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
  67762. */
  67763. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67764. /**
  67765. * The normal map texture
  67766. */
  67767. normalTexture?: IMaterialNormalTextureInfo;
  67768. /**
  67769. * The occlusion map texture
  67770. */
  67771. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67772. /**
  67773. * The emissive map texture
  67774. */
  67775. emissiveTexture?: ITextureInfo;
  67776. /**
  67777. * 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
  67778. */
  67779. emissiveFactor?: number[];
  67780. /**
  67781. * The alpha rendering mode of the material
  67782. */
  67783. alphaMode?: MaterialAlphaMode;
  67784. /**
  67785. * The alpha cutoff value of the material
  67786. */
  67787. alphaCutoff?: number;
  67788. /**
  67789. * Specifies whether the material is double sided
  67790. */
  67791. doubleSided?: boolean;
  67792. }
  67793. /**
  67794. * Geometry to be rendered with the given material
  67795. */
  67796. interface IMeshPrimitive extends IProperty {
  67797. /**
  67798. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  67799. */
  67800. attributes: {
  67801. [name: string]: number;
  67802. };
  67803. /**
  67804. * The index of the accessor that contains the indices
  67805. */
  67806. indices?: number;
  67807. /**
  67808. * The index of the material to apply to this primitive when rendering
  67809. */
  67810. material?: number;
  67811. /**
  67812. * The type of primitives to render. All valid values correspond to WebGL enums
  67813. */
  67814. mode?: MeshPrimitiveMode;
  67815. /**
  67816. * 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
  67817. */
  67818. targets?: {
  67819. [name: string]: number;
  67820. }[];
  67821. }
  67822. /**
  67823. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  67824. */
  67825. interface IMesh extends IChildRootProperty {
  67826. /**
  67827. * An array of primitives, each defining geometry to be rendered with a material
  67828. */
  67829. primitives: IMeshPrimitive[];
  67830. /**
  67831. * Array of weights to be applied to the Morph Targets
  67832. */
  67833. weights?: number[];
  67834. }
  67835. /**
  67836. * A node in the node hierarchy
  67837. */
  67838. interface INode extends IChildRootProperty {
  67839. /**
  67840. * The index of the camera referenced by this node
  67841. */
  67842. camera?: number;
  67843. /**
  67844. * The indices of this node's children
  67845. */
  67846. children?: number[];
  67847. /**
  67848. * The index of the skin referenced by this node
  67849. */
  67850. skin?: number;
  67851. /**
  67852. * A floating-point 4x4 transformation matrix stored in column-major order
  67853. */
  67854. matrix?: number[];
  67855. /**
  67856. * The index of the mesh in this node
  67857. */
  67858. mesh?: number;
  67859. /**
  67860. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  67861. */
  67862. rotation?: number[];
  67863. /**
  67864. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  67865. */
  67866. scale?: number[];
  67867. /**
  67868. * The node's translation along the x, y, and z axes
  67869. */
  67870. translation?: number[];
  67871. /**
  67872. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  67873. */
  67874. weights?: number[];
  67875. }
  67876. /**
  67877. * Texture sampler properties for filtering and wrapping modes
  67878. */
  67879. interface ISampler extends IChildRootProperty {
  67880. /**
  67881. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67882. */
  67883. magFilter?: TextureMagFilter;
  67884. /**
  67885. * Minification filter. All valid values correspond to WebGL enums
  67886. */
  67887. minFilter?: TextureMinFilter;
  67888. /**
  67889. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67890. */
  67891. wrapS?: TextureWrapMode;
  67892. /**
  67893. * T (V) wrapping mode. All valid values correspond to WebGL enums
  67894. */
  67895. wrapT?: TextureWrapMode;
  67896. }
  67897. /**
  67898. * The root nodes of a scene
  67899. */
  67900. interface IScene extends IChildRootProperty {
  67901. /**
  67902. * The indices of each root node
  67903. */
  67904. nodes: number[];
  67905. }
  67906. /**
  67907. * Joints and matrices defining a skin
  67908. */
  67909. interface ISkin extends IChildRootProperty {
  67910. /**
  67911. * 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
  67912. */
  67913. inverseBindMatrices?: number;
  67914. /**
  67915. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  67916. */
  67917. skeleton?: number;
  67918. /**
  67919. * 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)
  67920. */
  67921. joints: number[];
  67922. }
  67923. /**
  67924. * A texture and its sampler
  67925. */
  67926. interface ITexture extends IChildRootProperty {
  67927. /**
  67928. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  67929. */
  67930. sampler?: number;
  67931. /**
  67932. * The index of the image used by this texture
  67933. */
  67934. source: number;
  67935. }
  67936. /**
  67937. * Reference to a texture
  67938. */
  67939. interface ITextureInfo extends IProperty {
  67940. /**
  67941. * The index of the texture
  67942. */
  67943. index: number;
  67944. /**
  67945. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  67946. */
  67947. texCoord?: number;
  67948. }
  67949. /**
  67950. * The root object for a glTF asset
  67951. */
  67952. interface IGLTF extends IProperty {
  67953. /**
  67954. * An array of accessors. An accessor is a typed view into a bufferView
  67955. */
  67956. accessors?: IAccessor[];
  67957. /**
  67958. * An array of keyframe animations
  67959. */
  67960. animations?: IAnimation[];
  67961. /**
  67962. * Metadata about the glTF asset
  67963. */
  67964. asset: IAsset;
  67965. /**
  67966. * An array of buffers. A buffer points to binary geometry, animation, or skins
  67967. */
  67968. buffers?: IBuffer[];
  67969. /**
  67970. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  67971. */
  67972. bufferViews?: IBufferView[];
  67973. /**
  67974. * An array of cameras
  67975. */
  67976. cameras?: ICamera[];
  67977. /**
  67978. * Names of glTF extensions used somewhere in this asset
  67979. */
  67980. extensionsUsed?: string[];
  67981. /**
  67982. * Names of glTF extensions required to properly load this asset
  67983. */
  67984. extensionsRequired?: string[];
  67985. /**
  67986. * An array of images. An image defines data used to create a texture
  67987. */
  67988. images?: IImage[];
  67989. /**
  67990. * An array of materials. A material defines the appearance of a primitive
  67991. */
  67992. materials?: IMaterial[];
  67993. /**
  67994. * An array of meshes. A mesh is a set of primitives to be rendered
  67995. */
  67996. meshes?: IMesh[];
  67997. /**
  67998. * An array of nodes
  67999. */
  68000. nodes?: INode[];
  68001. /**
  68002. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  68003. */
  68004. samplers?: ISampler[];
  68005. /**
  68006. * The index of the default scene
  68007. */
  68008. scene?: number;
  68009. /**
  68010. * An array of scenes
  68011. */
  68012. scenes?: IScene[];
  68013. /**
  68014. * An array of skins. A skin is defined by joints and matrices
  68015. */
  68016. skins?: ISkin[];
  68017. /**
  68018. * An array of textures
  68019. */
  68020. textures?: ITexture[];
  68021. }
  68022. /**
  68023. * The glTF validation results
  68024. */
  68025. interface IGLTFValidationResults {
  68026. info: {
  68027. generator: string;
  68028. hasAnimations: boolean;
  68029. hasDefaultScene: boolean;
  68030. hasMaterials: boolean;
  68031. hasMorphTargets: boolean;
  68032. hasSkins: boolean;
  68033. hasTextures: boolean;
  68034. maxAttributesUsed: number;
  68035. primitivesCount: number
  68036. };
  68037. issues: {
  68038. messages: Array<string>;
  68039. numErrors: number;
  68040. numHints: number;
  68041. numInfos: number;
  68042. numWarnings: number;
  68043. truncated: boolean
  68044. };
  68045. mimeType: string;
  68046. uri: string;
  68047. validatedAt: string;
  68048. validatorVersion: string;
  68049. }
  68050. /**
  68051. * The glTF validation options
  68052. */
  68053. interface IGLTFValidationOptions {
  68054. uri?: string;
  68055. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  68056. validateAccessorData?: boolean;
  68057. maxIssues?: number;
  68058. ignoredIssues?: Array<string>;
  68059. severityOverrides?: Object;
  68060. }
  68061. /**
  68062. * The glTF validator object
  68063. */
  68064. interface IGLTFValidator {
  68065. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  68066. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  68067. }
  68068. }
  68069. declare module BABYLON {
  68070. /** @hidden */
  68071. export var cellPixelShader: {
  68072. name: string;
  68073. shader: string;
  68074. };
  68075. }
  68076. declare module BABYLON {
  68077. /** @hidden */
  68078. export var cellVertexShader: {
  68079. name: string;
  68080. shader: string;
  68081. };
  68082. }
  68083. declare module BABYLON {
  68084. export class CellMaterial extends BABYLON.PushMaterial {
  68085. private _diffuseTexture;
  68086. diffuseTexture: BABYLON.BaseTexture;
  68087. diffuseColor: BABYLON.Color3;
  68088. _computeHighLevel: boolean;
  68089. computeHighLevel: boolean;
  68090. private _disableLighting;
  68091. disableLighting: boolean;
  68092. private _maxSimultaneousLights;
  68093. maxSimultaneousLights: number;
  68094. private _renderId;
  68095. constructor(name: string, scene: BABYLON.Scene);
  68096. needAlphaBlending(): boolean;
  68097. needAlphaTesting(): boolean;
  68098. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68099. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68100. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68101. getAnimatables(): BABYLON.IAnimatable[];
  68102. getActiveTextures(): BABYLON.BaseTexture[];
  68103. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68104. dispose(forceDisposeEffect?: boolean): void;
  68105. getClassName(): string;
  68106. clone(name: string): CellMaterial;
  68107. serialize(): any;
  68108. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  68109. }
  68110. }
  68111. declare module BABYLON {
  68112. export class CustomShaderStructure {
  68113. FragmentStore: string;
  68114. VertexStore: string;
  68115. constructor();
  68116. }
  68117. export class ShaderSpecialParts {
  68118. constructor();
  68119. Fragment_Begin: string;
  68120. Fragment_Definitions: string;
  68121. Fragment_MainBegin: string;
  68122. Fragment_Custom_Diffuse: string;
  68123. Fragment_Before_Lights: string;
  68124. Fragment_Before_Fog: string;
  68125. Fragment_Custom_Alpha: string;
  68126. Fragment_Before_FragColor: string;
  68127. Vertex_Begin: string;
  68128. Vertex_Definitions: string;
  68129. Vertex_MainBegin: string;
  68130. Vertex_Before_PositionUpdated: string;
  68131. Vertex_Before_NormalUpdated: string;
  68132. Vertex_MainEnd: string;
  68133. }
  68134. export class CustomMaterial extends BABYLON.StandardMaterial {
  68135. static ShaderIndexer: number;
  68136. CustomParts: ShaderSpecialParts;
  68137. _isCreatedShader: boolean;
  68138. _createdShaderName: string;
  68139. _customUniform: string[];
  68140. _newUniforms: string[];
  68141. _newUniformInstances: any[];
  68142. _newSamplerInstances: BABYLON.Texture[];
  68143. FragmentShader: string;
  68144. VertexShader: string;
  68145. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  68146. ReviewUniform(name: string, arr: string[]): string[];
  68147. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  68148. constructor(name: string, scene: BABYLON.Scene);
  68149. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  68150. Fragment_Begin(shaderPart: string): CustomMaterial;
  68151. Fragment_Definitions(shaderPart: string): CustomMaterial;
  68152. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  68153. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  68154. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  68155. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  68156. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  68157. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  68158. Vertex_Begin(shaderPart: string): CustomMaterial;
  68159. Vertex_Definitions(shaderPart: string): CustomMaterial;
  68160. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  68161. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  68162. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  68163. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  68164. }
  68165. }
  68166. declare module BABYLON {
  68167. export class ShaderAlebdoParts {
  68168. constructor();
  68169. Fragment_Begin: string;
  68170. Fragment_Definitions: string;
  68171. Fragment_MainBegin: string;
  68172. Fragment_Custom_Albedo: string;
  68173. Fragment_Before_Lights: string;
  68174. Fragment_Custom_MetallicRoughness: string;
  68175. Fragment_Custom_MicroSurface: string;
  68176. Fragment_Before_Fog: string;
  68177. Fragment_Custom_Alpha: string;
  68178. Fragment_Before_FragColor: string;
  68179. Vertex_Begin: string;
  68180. Vertex_Definitions: string;
  68181. Vertex_MainBegin: string;
  68182. Vertex_Before_PositionUpdated: string;
  68183. Vertex_Before_NormalUpdated: string;
  68184. Vertex_MainEnd: string;
  68185. }
  68186. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  68187. static ShaderIndexer: number;
  68188. CustomParts: ShaderAlebdoParts;
  68189. _isCreatedShader: boolean;
  68190. _createdShaderName: string;
  68191. _customUniform: string[];
  68192. _newUniforms: string[];
  68193. _newUniformInstances: any[];
  68194. _newSamplerInstances: BABYLON.Texture[];
  68195. FragmentShader: string;
  68196. VertexShader: string;
  68197. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  68198. ReviewUniform(name: string, arr: string[]): string[];
  68199. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  68200. constructor(name: string, scene: BABYLON.Scene);
  68201. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  68202. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  68203. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  68204. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  68205. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  68206. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  68207. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  68208. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  68209. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  68210. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  68211. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  68212. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  68213. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  68214. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  68215. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  68216. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  68217. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  68218. }
  68219. }
  68220. declare module BABYLON {
  68221. /** @hidden */
  68222. export var firePixelShader: {
  68223. name: string;
  68224. shader: string;
  68225. };
  68226. }
  68227. declare module BABYLON {
  68228. /** @hidden */
  68229. export var fireVertexShader: {
  68230. name: string;
  68231. shader: string;
  68232. };
  68233. }
  68234. declare module BABYLON {
  68235. export class FireMaterial extends BABYLON.PushMaterial {
  68236. private _diffuseTexture;
  68237. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68238. private _distortionTexture;
  68239. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68240. private _opacityTexture;
  68241. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68242. diffuseColor: BABYLON.Color3;
  68243. speed: number;
  68244. private _scaledDiffuse;
  68245. private _renderId;
  68246. private _lastTime;
  68247. constructor(name: string, scene: BABYLON.Scene);
  68248. needAlphaBlending(): boolean;
  68249. needAlphaTesting(): boolean;
  68250. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68251. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68252. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68253. getAnimatables(): BABYLON.IAnimatable[];
  68254. getActiveTextures(): BABYLON.BaseTexture[];
  68255. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68256. getClassName(): string;
  68257. dispose(forceDisposeEffect?: boolean): void;
  68258. clone(name: string): FireMaterial;
  68259. serialize(): any;
  68260. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  68261. }
  68262. }
  68263. declare module BABYLON {
  68264. /** @hidden */
  68265. export var furPixelShader: {
  68266. name: string;
  68267. shader: string;
  68268. };
  68269. }
  68270. declare module BABYLON {
  68271. /** @hidden */
  68272. export var furVertexShader: {
  68273. name: string;
  68274. shader: string;
  68275. };
  68276. }
  68277. declare module BABYLON {
  68278. export class FurMaterial extends BABYLON.PushMaterial {
  68279. private _diffuseTexture;
  68280. diffuseTexture: BABYLON.BaseTexture;
  68281. private _heightTexture;
  68282. heightTexture: BABYLON.BaseTexture;
  68283. diffuseColor: BABYLON.Color3;
  68284. furLength: number;
  68285. furAngle: number;
  68286. furColor: BABYLON.Color3;
  68287. furOffset: number;
  68288. furSpacing: number;
  68289. furGravity: BABYLON.Vector3;
  68290. furSpeed: number;
  68291. furDensity: number;
  68292. furOcclusion: number;
  68293. furTexture: BABYLON.DynamicTexture;
  68294. private _disableLighting;
  68295. disableLighting: boolean;
  68296. private _maxSimultaneousLights;
  68297. maxSimultaneousLights: number;
  68298. highLevelFur: boolean;
  68299. _meshes: BABYLON.AbstractMesh[];
  68300. private _renderId;
  68301. private _furTime;
  68302. constructor(name: string, scene: BABYLON.Scene);
  68303. furTime: number;
  68304. needAlphaBlending(): boolean;
  68305. needAlphaTesting(): boolean;
  68306. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68307. updateFur(): void;
  68308. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68309. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68310. getAnimatables(): BABYLON.IAnimatable[];
  68311. getActiveTextures(): BABYLON.BaseTexture[];
  68312. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68313. dispose(forceDisposeEffect?: boolean): void;
  68314. clone(name: string): FurMaterial;
  68315. serialize(): any;
  68316. getClassName(): string;
  68317. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  68318. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  68319. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  68320. }
  68321. }
  68322. declare module BABYLON {
  68323. /** @hidden */
  68324. export var gradientPixelShader: {
  68325. name: string;
  68326. shader: string;
  68327. };
  68328. }
  68329. declare module BABYLON {
  68330. /** @hidden */
  68331. export var gradientVertexShader: {
  68332. name: string;
  68333. shader: string;
  68334. };
  68335. }
  68336. declare module BABYLON {
  68337. export class GradientMaterial extends BABYLON.PushMaterial {
  68338. private _maxSimultaneousLights;
  68339. maxSimultaneousLights: number;
  68340. topColor: BABYLON.Color3;
  68341. topColorAlpha: number;
  68342. bottomColor: BABYLON.Color3;
  68343. bottomColorAlpha: number;
  68344. offset: number;
  68345. scale: number;
  68346. smoothness: number;
  68347. private _disableLighting;
  68348. disableLighting: boolean;
  68349. private _renderId;
  68350. constructor(name: string, scene: BABYLON.Scene);
  68351. needAlphaBlending(): boolean;
  68352. needAlphaTesting(): boolean;
  68353. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68354. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68355. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68356. getAnimatables(): BABYLON.IAnimatable[];
  68357. dispose(forceDisposeEffect?: boolean): void;
  68358. clone(name: string): GradientMaterial;
  68359. serialize(): any;
  68360. getClassName(): string;
  68361. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  68362. }
  68363. }
  68364. declare module BABYLON {
  68365. /** @hidden */
  68366. export var gridPixelShader: {
  68367. name: string;
  68368. shader: string;
  68369. };
  68370. }
  68371. declare module BABYLON {
  68372. /** @hidden */
  68373. export var gridVertexShader: {
  68374. name: string;
  68375. shader: string;
  68376. };
  68377. }
  68378. declare module BABYLON {
  68379. /**
  68380. * The grid materials allows you to wrap any shape with a grid.
  68381. * Colors are customizable.
  68382. */
  68383. export class GridMaterial extends BABYLON.PushMaterial {
  68384. /**
  68385. * Main color of the grid (e.g. between lines)
  68386. */
  68387. mainColor: BABYLON.Color3;
  68388. /**
  68389. * Color of the grid lines.
  68390. */
  68391. lineColor: BABYLON.Color3;
  68392. /**
  68393. * The scale of the grid compared to unit.
  68394. */
  68395. gridRatio: number;
  68396. /**
  68397. * Allows setting an offset for the grid lines.
  68398. */
  68399. gridOffset: BABYLON.Vector3;
  68400. /**
  68401. * The frequency of thicker lines.
  68402. */
  68403. majorUnitFrequency: number;
  68404. /**
  68405. * The visibility of minor units in the grid.
  68406. */
  68407. minorUnitVisibility: number;
  68408. /**
  68409. * The grid opacity outside of the lines.
  68410. */
  68411. opacity: number;
  68412. /**
  68413. * Determine RBG output is premultiplied by alpha value.
  68414. */
  68415. preMultiplyAlpha: boolean;
  68416. private _opacityTexture;
  68417. opacityTexture: BABYLON.BaseTexture;
  68418. private _gridControl;
  68419. private _renderId;
  68420. /**
  68421. * constructor
  68422. * @param name The name given to the material in order to identify it afterwards.
  68423. * @param scene The scene the material is used in.
  68424. */
  68425. constructor(name: string, scene: BABYLON.Scene);
  68426. /**
  68427. * Returns wehter or not the grid requires alpha blending.
  68428. */
  68429. needAlphaBlending(): boolean;
  68430. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68431. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68432. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68433. /**
  68434. * Dispose the material and its associated resources.
  68435. * @param forceDisposeEffect will also dispose the used effect when true
  68436. */
  68437. dispose(forceDisposeEffect?: boolean): void;
  68438. clone(name: string): GridMaterial;
  68439. serialize(): any;
  68440. getClassName(): string;
  68441. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  68442. }
  68443. }
  68444. declare module BABYLON {
  68445. /** @hidden */
  68446. export var lavaPixelShader: {
  68447. name: string;
  68448. shader: string;
  68449. };
  68450. }
  68451. declare module BABYLON {
  68452. /** @hidden */
  68453. export var lavaVertexShader: {
  68454. name: string;
  68455. shader: string;
  68456. };
  68457. }
  68458. declare module BABYLON {
  68459. export class LavaMaterial extends BABYLON.PushMaterial {
  68460. private _diffuseTexture;
  68461. diffuseTexture: BABYLON.BaseTexture;
  68462. noiseTexture: BABYLON.BaseTexture;
  68463. fogColor: BABYLON.Color3;
  68464. speed: number;
  68465. movingSpeed: number;
  68466. lowFrequencySpeed: number;
  68467. fogDensity: number;
  68468. private _lastTime;
  68469. diffuseColor: BABYLON.Color3;
  68470. private _disableLighting;
  68471. disableLighting: boolean;
  68472. private _unlit;
  68473. unlit: boolean;
  68474. private _maxSimultaneousLights;
  68475. maxSimultaneousLights: number;
  68476. private _scaledDiffuse;
  68477. private _renderId;
  68478. constructor(name: string, scene: BABYLON.Scene);
  68479. needAlphaBlending(): boolean;
  68480. needAlphaTesting(): boolean;
  68481. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68482. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68483. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68484. getAnimatables(): BABYLON.IAnimatable[];
  68485. getActiveTextures(): BABYLON.BaseTexture[];
  68486. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68487. dispose(forceDisposeEffect?: boolean): void;
  68488. clone(name: string): LavaMaterial;
  68489. serialize(): any;
  68490. getClassName(): string;
  68491. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  68492. }
  68493. }
  68494. declare module BABYLON {
  68495. /** @hidden */
  68496. export var mixPixelShader: {
  68497. name: string;
  68498. shader: string;
  68499. };
  68500. }
  68501. declare module BABYLON {
  68502. /** @hidden */
  68503. export var mixVertexShader: {
  68504. name: string;
  68505. shader: string;
  68506. };
  68507. }
  68508. declare module BABYLON {
  68509. export class MixMaterial extends BABYLON.PushMaterial {
  68510. /**
  68511. * Mix textures
  68512. */
  68513. private _mixTexture1;
  68514. mixTexture1: BABYLON.BaseTexture;
  68515. private _mixTexture2;
  68516. mixTexture2: BABYLON.BaseTexture;
  68517. /**
  68518. * Diffuse textures
  68519. */
  68520. private _diffuseTexture1;
  68521. diffuseTexture1: BABYLON.Texture;
  68522. private _diffuseTexture2;
  68523. diffuseTexture2: BABYLON.Texture;
  68524. private _diffuseTexture3;
  68525. diffuseTexture3: BABYLON.Texture;
  68526. private _diffuseTexture4;
  68527. diffuseTexture4: BABYLON.Texture;
  68528. private _diffuseTexture5;
  68529. diffuseTexture5: BABYLON.Texture;
  68530. private _diffuseTexture6;
  68531. diffuseTexture6: BABYLON.Texture;
  68532. private _diffuseTexture7;
  68533. diffuseTexture7: BABYLON.Texture;
  68534. private _diffuseTexture8;
  68535. diffuseTexture8: BABYLON.Texture;
  68536. /**
  68537. * Uniforms
  68538. */
  68539. diffuseColor: BABYLON.Color3;
  68540. specularColor: BABYLON.Color3;
  68541. specularPower: number;
  68542. private _disableLighting;
  68543. disableLighting: boolean;
  68544. private _maxSimultaneousLights;
  68545. maxSimultaneousLights: number;
  68546. private _renderId;
  68547. constructor(name: string, scene: BABYLON.Scene);
  68548. needAlphaBlending(): boolean;
  68549. needAlphaTesting(): boolean;
  68550. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68551. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68552. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68553. getAnimatables(): BABYLON.IAnimatable[];
  68554. getActiveTextures(): BABYLON.BaseTexture[];
  68555. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68556. dispose(forceDisposeEffect?: boolean): void;
  68557. clone(name: string): MixMaterial;
  68558. serialize(): any;
  68559. getClassName(): string;
  68560. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  68561. }
  68562. }
  68563. declare module BABYLON {
  68564. /** @hidden */
  68565. export var normalPixelShader: {
  68566. name: string;
  68567. shader: string;
  68568. };
  68569. }
  68570. declare module BABYLON {
  68571. /** @hidden */
  68572. export var normalVertexShader: {
  68573. name: string;
  68574. shader: string;
  68575. };
  68576. }
  68577. declare module BABYLON {
  68578. export class NormalMaterial extends BABYLON.PushMaterial {
  68579. private _diffuseTexture;
  68580. diffuseTexture: BABYLON.BaseTexture;
  68581. diffuseColor: BABYLON.Color3;
  68582. private _disableLighting;
  68583. disableLighting: boolean;
  68584. private _maxSimultaneousLights;
  68585. maxSimultaneousLights: number;
  68586. private _renderId;
  68587. constructor(name: string, scene: BABYLON.Scene);
  68588. needAlphaBlending(): boolean;
  68589. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68590. needAlphaTesting(): boolean;
  68591. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68592. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68593. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68594. getAnimatables(): BABYLON.IAnimatable[];
  68595. getActiveTextures(): BABYLON.BaseTexture[];
  68596. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68597. dispose(forceDisposeEffect?: boolean): void;
  68598. clone(name: string): NormalMaterial;
  68599. serialize(): any;
  68600. getClassName(): string;
  68601. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  68602. }
  68603. }
  68604. declare module BABYLON {
  68605. /** @hidden */
  68606. export var shadowOnlyPixelShader: {
  68607. name: string;
  68608. shader: string;
  68609. };
  68610. }
  68611. declare module BABYLON {
  68612. /** @hidden */
  68613. export var shadowOnlyVertexShader: {
  68614. name: string;
  68615. shader: string;
  68616. };
  68617. }
  68618. declare module BABYLON {
  68619. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  68620. private _renderId;
  68621. private _activeLight;
  68622. constructor(name: string, scene: BABYLON.Scene);
  68623. shadowColor: BABYLON.Color3;
  68624. needAlphaBlending(): boolean;
  68625. needAlphaTesting(): boolean;
  68626. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68627. activeLight: BABYLON.IShadowLight;
  68628. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68629. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68630. clone(name: string): ShadowOnlyMaterial;
  68631. serialize(): any;
  68632. getClassName(): string;
  68633. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  68634. }
  68635. }
  68636. declare module BABYLON {
  68637. /** @hidden */
  68638. export var simplePixelShader: {
  68639. name: string;
  68640. shader: string;
  68641. };
  68642. }
  68643. declare module BABYLON {
  68644. /** @hidden */
  68645. export var simpleVertexShader: {
  68646. name: string;
  68647. shader: string;
  68648. };
  68649. }
  68650. declare module BABYLON {
  68651. export class SimpleMaterial extends BABYLON.PushMaterial {
  68652. private _diffuseTexture;
  68653. diffuseTexture: BABYLON.BaseTexture;
  68654. diffuseColor: BABYLON.Color3;
  68655. private _disableLighting;
  68656. disableLighting: boolean;
  68657. private _maxSimultaneousLights;
  68658. maxSimultaneousLights: number;
  68659. private _renderId;
  68660. constructor(name: string, scene: BABYLON.Scene);
  68661. needAlphaBlending(): boolean;
  68662. needAlphaTesting(): boolean;
  68663. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68664. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68665. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68666. getAnimatables(): BABYLON.IAnimatable[];
  68667. getActiveTextures(): BABYLON.BaseTexture[];
  68668. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68669. dispose(forceDisposeEffect?: boolean): void;
  68670. clone(name: string): SimpleMaterial;
  68671. serialize(): any;
  68672. getClassName(): string;
  68673. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  68674. }
  68675. }
  68676. declare module BABYLON {
  68677. /** @hidden */
  68678. export var skyPixelShader: {
  68679. name: string;
  68680. shader: string;
  68681. };
  68682. }
  68683. declare module BABYLON {
  68684. /** @hidden */
  68685. export var skyVertexShader: {
  68686. name: string;
  68687. shader: string;
  68688. };
  68689. }
  68690. declare module BABYLON {
  68691. /**
  68692. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  68693. * @see https://doc.babylonjs.com/extensions/sky
  68694. */
  68695. export class SkyMaterial extends BABYLON.PushMaterial {
  68696. /**
  68697. * Defines the overall luminance of sky in interval ]0, 1[.
  68698. */
  68699. luminance: number;
  68700. /**
  68701. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  68702. */
  68703. turbidity: number;
  68704. /**
  68705. * Defines the sky appearance (light intensity).
  68706. */
  68707. rayleigh: number;
  68708. /**
  68709. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  68710. */
  68711. mieCoefficient: number;
  68712. /**
  68713. * Defines the amount of haze particles following the Mie scattering theory.
  68714. */
  68715. mieDirectionalG: number;
  68716. /**
  68717. * Defines the distance of the sun according to the active scene camera.
  68718. */
  68719. distance: number;
  68720. /**
  68721. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  68722. * "inclined".
  68723. */
  68724. inclination: number;
  68725. /**
  68726. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  68727. * an object direction and a reference direction.
  68728. */
  68729. azimuth: number;
  68730. /**
  68731. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  68732. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  68733. */
  68734. sunPosition: BABYLON.Vector3;
  68735. /**
  68736. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  68737. * .sunPosition property.
  68738. */
  68739. useSunPosition: boolean;
  68740. /**
  68741. * Defines an offset vector used to get a horizon offset.
  68742. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  68743. */
  68744. cameraOffset: BABYLON.Vector3;
  68745. private _cameraPosition;
  68746. private _renderId;
  68747. /**
  68748. * Instantiates a new sky material.
  68749. * This material allows to create dynamic and texture free
  68750. * effects for skyboxes by taking care of the atmosphere state.
  68751. * @see https://doc.babylonjs.com/extensions/sky
  68752. * @param name Define the name of the material in the scene
  68753. * @param scene Define the scene the material belong to
  68754. */
  68755. constructor(name: string, scene: BABYLON.Scene);
  68756. /**
  68757. * Specifies if the material will require alpha blending
  68758. * @returns a boolean specifying if alpha blending is needed
  68759. */
  68760. needAlphaBlending(): boolean;
  68761. /**
  68762. * Specifies if this material should be rendered in alpha test mode
  68763. * @returns false as the sky material doesn't need alpha testing.
  68764. */
  68765. needAlphaTesting(): boolean;
  68766. /**
  68767. * Get the texture used for alpha test purpose.
  68768. * @returns null as the sky material has no texture.
  68769. */
  68770. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68771. /**
  68772. * Get if the submesh is ready to be used and all its information available.
  68773. * Child classes can use it to update shaders
  68774. * @param mesh defines the mesh to check
  68775. * @param subMesh defines which submesh to check
  68776. * @param useInstances specifies that instances should be used
  68777. * @returns a boolean indicating that the submesh is ready or not
  68778. */
  68779. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68780. /**
  68781. * Binds the submesh to this material by preparing the effect and shader to draw
  68782. * @param world defines the world transformation matrix
  68783. * @param mesh defines the mesh containing the submesh
  68784. * @param subMesh defines the submesh to bind the material to
  68785. */
  68786. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68787. /**
  68788. * Get the list of animatables in the material.
  68789. * @returns the list of animatables object used in the material
  68790. */
  68791. getAnimatables(): BABYLON.IAnimatable[];
  68792. /**
  68793. * Disposes the material
  68794. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68795. */
  68796. dispose(forceDisposeEffect?: boolean): void;
  68797. /**
  68798. * Makes a duplicate of the material, and gives it a new name
  68799. * @param name defines the new name for the duplicated material
  68800. * @returns the cloned material
  68801. */
  68802. clone(name: string): SkyMaterial;
  68803. /**
  68804. * Serializes this material in a JSON representation
  68805. * @returns the serialized material object
  68806. */
  68807. serialize(): any;
  68808. /**
  68809. * Gets the current class name of the material e.g. "SkyMaterial"
  68810. * Mainly use in serialization.
  68811. * @returns the class name
  68812. */
  68813. getClassName(): string;
  68814. /**
  68815. * Creates a sky material from parsed material data
  68816. * @param source defines the JSON representation of the material
  68817. * @param scene defines the hosting scene
  68818. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68819. * @returns a new sky material
  68820. */
  68821. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  68822. }
  68823. }
  68824. declare module BABYLON {
  68825. /** @hidden */
  68826. export var terrainPixelShader: {
  68827. name: string;
  68828. shader: string;
  68829. };
  68830. }
  68831. declare module BABYLON {
  68832. /** @hidden */
  68833. export var terrainVertexShader: {
  68834. name: string;
  68835. shader: string;
  68836. };
  68837. }
  68838. declare module BABYLON {
  68839. export class TerrainMaterial extends BABYLON.PushMaterial {
  68840. private _mixTexture;
  68841. mixTexture: BABYLON.BaseTexture;
  68842. private _diffuseTexture1;
  68843. diffuseTexture1: BABYLON.Texture;
  68844. private _diffuseTexture2;
  68845. diffuseTexture2: BABYLON.Texture;
  68846. private _diffuseTexture3;
  68847. diffuseTexture3: BABYLON.Texture;
  68848. private _bumpTexture1;
  68849. bumpTexture1: BABYLON.Texture;
  68850. private _bumpTexture2;
  68851. bumpTexture2: BABYLON.Texture;
  68852. private _bumpTexture3;
  68853. bumpTexture3: BABYLON.Texture;
  68854. diffuseColor: BABYLON.Color3;
  68855. specularColor: BABYLON.Color3;
  68856. specularPower: number;
  68857. private _disableLighting;
  68858. disableLighting: boolean;
  68859. private _maxSimultaneousLights;
  68860. maxSimultaneousLights: number;
  68861. private _renderId;
  68862. constructor(name: string, scene: BABYLON.Scene);
  68863. needAlphaBlending(): boolean;
  68864. needAlphaTesting(): boolean;
  68865. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68866. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68867. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68868. getAnimatables(): BABYLON.IAnimatable[];
  68869. getActiveTextures(): BABYLON.BaseTexture[];
  68870. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68871. dispose(forceDisposeEffect?: boolean): void;
  68872. clone(name: string): TerrainMaterial;
  68873. serialize(): any;
  68874. getClassName(): string;
  68875. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  68876. }
  68877. }
  68878. declare module BABYLON {
  68879. /** @hidden */
  68880. export var triplanarPixelShader: {
  68881. name: string;
  68882. shader: string;
  68883. };
  68884. }
  68885. declare module BABYLON {
  68886. /** @hidden */
  68887. export var triplanarVertexShader: {
  68888. name: string;
  68889. shader: string;
  68890. };
  68891. }
  68892. declare module BABYLON {
  68893. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  68894. mixTexture: BABYLON.BaseTexture;
  68895. private _diffuseTextureX;
  68896. diffuseTextureX: BABYLON.BaseTexture;
  68897. private _diffuseTextureY;
  68898. diffuseTextureY: BABYLON.BaseTexture;
  68899. private _diffuseTextureZ;
  68900. diffuseTextureZ: BABYLON.BaseTexture;
  68901. private _normalTextureX;
  68902. normalTextureX: BABYLON.BaseTexture;
  68903. private _normalTextureY;
  68904. normalTextureY: BABYLON.BaseTexture;
  68905. private _normalTextureZ;
  68906. normalTextureZ: BABYLON.BaseTexture;
  68907. tileSize: number;
  68908. diffuseColor: BABYLON.Color3;
  68909. specularColor: BABYLON.Color3;
  68910. specularPower: number;
  68911. private _disableLighting;
  68912. disableLighting: boolean;
  68913. private _maxSimultaneousLights;
  68914. maxSimultaneousLights: number;
  68915. private _renderId;
  68916. constructor(name: string, scene: BABYLON.Scene);
  68917. needAlphaBlending(): boolean;
  68918. needAlphaTesting(): boolean;
  68919. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68920. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68921. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68922. getAnimatables(): BABYLON.IAnimatable[];
  68923. getActiveTextures(): BABYLON.BaseTexture[];
  68924. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68925. dispose(forceDisposeEffect?: boolean): void;
  68926. clone(name: string): TriPlanarMaterial;
  68927. serialize(): any;
  68928. getClassName(): string;
  68929. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  68930. }
  68931. }
  68932. declare module BABYLON {
  68933. /** @hidden */
  68934. export var waterPixelShader: {
  68935. name: string;
  68936. shader: string;
  68937. };
  68938. }
  68939. declare module BABYLON {
  68940. /** @hidden */
  68941. export var waterVertexShader: {
  68942. name: string;
  68943. shader: string;
  68944. };
  68945. }
  68946. declare module BABYLON {
  68947. export class WaterMaterial extends BABYLON.PushMaterial {
  68948. renderTargetSize: BABYLON.Vector2;
  68949. private _bumpTexture;
  68950. bumpTexture: BABYLON.BaseTexture;
  68951. diffuseColor: BABYLON.Color3;
  68952. specularColor: BABYLON.Color3;
  68953. specularPower: number;
  68954. private _disableLighting;
  68955. disableLighting: boolean;
  68956. private _maxSimultaneousLights;
  68957. maxSimultaneousLights: number;
  68958. /**
  68959. * @param {number}: Represents the wind force
  68960. */
  68961. windForce: number;
  68962. /**
  68963. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  68964. */
  68965. windDirection: BABYLON.Vector2;
  68966. /**
  68967. * @param {number}: Wave height, represents the height of the waves
  68968. */
  68969. waveHeight: number;
  68970. /**
  68971. * @param {number}: Bump height, represents the bump height related to the bump map
  68972. */
  68973. bumpHeight: number;
  68974. /**
  68975. * @param {boolean}: Add a smaller moving bump to less steady waves.
  68976. */
  68977. private _bumpSuperimpose;
  68978. bumpSuperimpose: boolean;
  68979. /**
  68980. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  68981. */
  68982. private _fresnelSeparate;
  68983. fresnelSeparate: boolean;
  68984. /**
  68985. * @param {boolean}: bump Waves modify the reflection.
  68986. */
  68987. private _bumpAffectsReflection;
  68988. bumpAffectsReflection: boolean;
  68989. /**
  68990. * @param {number}: The water color blended with the refraction (near)
  68991. */
  68992. waterColor: BABYLON.Color3;
  68993. /**
  68994. * @param {number}: The blend factor related to the water color
  68995. */
  68996. colorBlendFactor: number;
  68997. /**
  68998. * @param {number}: The water color blended with the reflection (far)
  68999. */
  69000. waterColor2: BABYLON.Color3;
  69001. /**
  69002. * @param {number}: The blend factor related to the water color (reflection, far)
  69003. */
  69004. colorBlendFactor2: number;
  69005. /**
  69006. * @param {number}: Represents the maximum length of a wave
  69007. */
  69008. waveLength: number;
  69009. /**
  69010. * @param {number}: Defines the waves speed
  69011. */
  69012. waveSpeed: number;
  69013. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  69014. private _mesh;
  69015. private _refractionRTT;
  69016. private _reflectionRTT;
  69017. private _reflectionTransform;
  69018. private _lastTime;
  69019. private _lastDeltaTime;
  69020. private _renderId;
  69021. private _useLogarithmicDepth;
  69022. private _waitingRenderList;
  69023. /**
  69024. * Gets a boolean indicating that current material needs to register RTT
  69025. */
  69026. readonly hasRenderTargetTextures: boolean;
  69027. /**
  69028. * Constructor
  69029. */
  69030. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  69031. useLogarithmicDepth: boolean;
  69032. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  69033. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  69034. addToRenderList(node: any): void;
  69035. enableRenderTargets(enable: boolean): void;
  69036. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  69037. readonly renderTargetsEnabled: boolean;
  69038. needAlphaBlending(): boolean;
  69039. needAlphaTesting(): boolean;
  69040. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69041. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69042. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69043. private _createRenderTargets;
  69044. getAnimatables(): BABYLON.IAnimatable[];
  69045. getActiveTextures(): BABYLON.BaseTexture[];
  69046. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69047. dispose(forceDisposeEffect?: boolean): void;
  69048. clone(name: string): WaterMaterial;
  69049. serialize(): any;
  69050. getClassName(): string;
  69051. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  69052. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  69053. }
  69054. }
  69055. declare module BABYLON {
  69056. /** @hidden */
  69057. export var asciiartPixelShader: {
  69058. name: string;
  69059. shader: string;
  69060. };
  69061. }
  69062. declare module BABYLON {
  69063. /**
  69064. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  69065. *
  69066. * It basically takes care rendering the font front the given font size to a texture.
  69067. * This is used later on in the postprocess.
  69068. */
  69069. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  69070. private _font;
  69071. private _text;
  69072. private _charSize;
  69073. /**
  69074. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  69075. */
  69076. readonly charSize: number;
  69077. /**
  69078. * Create a new instance of the Ascii Art FontTexture class
  69079. * @param name the name of the texture
  69080. * @param font the font to use, use the W3C CSS notation
  69081. * @param text the caracter set to use in the rendering.
  69082. * @param scene the scene that owns the texture
  69083. */
  69084. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  69085. /**
  69086. * Gets the max char width of a font.
  69087. * @param font the font to use, use the W3C CSS notation
  69088. * @return the max char width
  69089. */
  69090. private getFontWidth;
  69091. /**
  69092. * Gets the max char height of a font.
  69093. * @param font the font to use, use the W3C CSS notation
  69094. * @return the max char height
  69095. */
  69096. private getFontHeight;
  69097. /**
  69098. * Clones the current AsciiArtTexture.
  69099. * @return the clone of the texture.
  69100. */
  69101. clone(): AsciiArtFontTexture;
  69102. /**
  69103. * Parses a json object representing the texture and returns an instance of it.
  69104. * @param source the source JSON representation
  69105. * @param scene the scene to create the texture for
  69106. * @return the parsed texture
  69107. */
  69108. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  69109. }
  69110. /**
  69111. * Option available in the Ascii Art Post Process.
  69112. */
  69113. export interface IAsciiArtPostProcessOptions {
  69114. /**
  69115. * The font to use following the w3c font definition.
  69116. */
  69117. font?: string;
  69118. /**
  69119. * The character set to use in the postprocess.
  69120. */
  69121. characterSet?: string;
  69122. /**
  69123. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  69124. * This number is defined between 0 and 1;
  69125. */
  69126. mixToTile?: number;
  69127. /**
  69128. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  69129. * This number is defined between 0 and 1;
  69130. */
  69131. mixToNormal?: number;
  69132. }
  69133. /**
  69134. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  69135. *
  69136. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69137. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  69138. */
  69139. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  69140. /**
  69141. * The font texture used to render the char in the post process.
  69142. */
  69143. private _asciiArtFontTexture;
  69144. /**
  69145. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  69146. * This number is defined between 0 and 1;
  69147. */
  69148. mixToTile: number;
  69149. /**
  69150. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  69151. * This number is defined between 0 and 1;
  69152. */
  69153. mixToNormal: number;
  69154. /**
  69155. * Instantiates a new Ascii Art Post Process.
  69156. * @param name the name to give to the postprocess
  69157. * @camera the camera to apply the post process to.
  69158. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  69159. */
  69160. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  69161. }
  69162. }
  69163. declare module BABYLON {
  69164. /** @hidden */
  69165. export var digitalrainPixelShader: {
  69166. name: string;
  69167. shader: string;
  69168. };
  69169. }
  69170. declare module BABYLON {
  69171. /**
  69172. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  69173. *
  69174. * It basically takes care rendering the font front the given font size to a texture.
  69175. * This is used later on in the postprocess.
  69176. */
  69177. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  69178. private _font;
  69179. private _text;
  69180. private _charSize;
  69181. /**
  69182. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  69183. */
  69184. readonly charSize: number;
  69185. /**
  69186. * Create a new instance of the Digital Rain FontTexture class
  69187. * @param name the name of the texture
  69188. * @param font the font to use, use the W3C CSS notation
  69189. * @param text the caracter set to use in the rendering.
  69190. * @param scene the scene that owns the texture
  69191. */
  69192. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  69193. /**
  69194. * Gets the max char width of a font.
  69195. * @param font the font to use, use the W3C CSS notation
  69196. * @return the max char width
  69197. */
  69198. private getFontWidth;
  69199. /**
  69200. * Gets the max char height of a font.
  69201. * @param font the font to use, use the W3C CSS notation
  69202. * @return the max char height
  69203. */
  69204. private getFontHeight;
  69205. /**
  69206. * Clones the current DigitalRainFontTexture.
  69207. * @return the clone of the texture.
  69208. */
  69209. clone(): DigitalRainFontTexture;
  69210. /**
  69211. * Parses a json object representing the texture and returns an instance of it.
  69212. * @param source the source JSON representation
  69213. * @param scene the scene to create the texture for
  69214. * @return the parsed texture
  69215. */
  69216. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  69217. }
  69218. /**
  69219. * Option available in the Digital Rain Post Process.
  69220. */
  69221. export interface IDigitalRainPostProcessOptions {
  69222. /**
  69223. * The font to use following the w3c font definition.
  69224. */
  69225. font?: string;
  69226. /**
  69227. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  69228. * This number is defined between 0 and 1;
  69229. */
  69230. mixToTile?: number;
  69231. /**
  69232. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  69233. * This number is defined between 0 and 1;
  69234. */
  69235. mixToNormal?: number;
  69236. }
  69237. /**
  69238. * DigitalRainPostProcess helps rendering everithing in digital rain.
  69239. *
  69240. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69241. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  69242. */
  69243. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  69244. /**
  69245. * The font texture used to render the char in the post process.
  69246. */
  69247. private _digitalRainFontTexture;
  69248. /**
  69249. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  69250. * This number is defined between 0 and 1;
  69251. */
  69252. mixToTile: number;
  69253. /**
  69254. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  69255. * This number is defined between 0 and 1;
  69256. */
  69257. mixToNormal: number;
  69258. /**
  69259. * Instantiates a new Digital Rain Post Process.
  69260. * @param name the name to give to the postprocess
  69261. * @camera the camera to apply the post process to.
  69262. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  69263. */
  69264. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  69265. }
  69266. }
  69267. declare module BABYLON {
  69268. /** @hidden */
  69269. export var oceanPostProcessPixelShader: {
  69270. name: string;
  69271. shader: string;
  69272. };
  69273. }
  69274. declare module BABYLON {
  69275. /**
  69276. * Option available in the Ocean Post Process.
  69277. */
  69278. export interface IOceanPostProcessOptions {
  69279. /**
  69280. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  69281. */
  69282. reflectionSize?: number | {
  69283. width: number;
  69284. height: number;
  69285. } | {
  69286. ratio: number;
  69287. };
  69288. /**
  69289. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  69290. */
  69291. refractionSize?: number | {
  69292. width: number;
  69293. height: number;
  69294. } | {
  69295. ratio: number;
  69296. };
  69297. }
  69298. /**
  69299. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  69300. *
  69301. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69302. * Example usage:
  69303. * var pp = new OceanPostProcess("myOcean", camera);
  69304. * pp.reflectionEnabled = true;
  69305. * pp.refractionEnabled = true;
  69306. */
  69307. export class OceanPostProcess extends BABYLON.PostProcess {
  69308. /**
  69309. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  69310. */
  69311. /**
  69312. * Sets weither or not the real-time reflection is enabled on the ocean.
  69313. * Is set to true, the reflection mirror texture will be used as reflection texture.
  69314. */
  69315. reflectionEnabled: boolean;
  69316. /**
  69317. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  69318. */
  69319. /**
  69320. * Sets weither or not the real-time refraction is enabled on the ocean.
  69321. * Is set to true, the refraction render target texture will be used as refraction texture.
  69322. */
  69323. refractionEnabled: boolean;
  69324. /**
  69325. * Gets wether or not the post-processes is supported by the running hardware.
  69326. * This requires draw buffer supports.
  69327. */
  69328. readonly isSupported: boolean;
  69329. /**
  69330. * This is the reflection mirror texture used to display reflections on the ocean.
  69331. * By default, render list is empty.
  69332. */
  69333. reflectionTexture: BABYLON.MirrorTexture;
  69334. /**
  69335. * This is the refraction render target texture used to display refraction on the ocean.
  69336. * By default, render list is empty.
  69337. */
  69338. refractionTexture: BABYLON.RenderTargetTexture;
  69339. private _time;
  69340. private _cameraRotation;
  69341. private _cameraViewMatrix;
  69342. private _reflectionEnabled;
  69343. private _refractionEnabled;
  69344. private _geometryRenderer;
  69345. /**
  69346. * Instantiates a new Ocean Post Process.
  69347. * @param name the name to give to the postprocess.
  69348. * @camera the camera to apply the post process to.
  69349. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  69350. */
  69351. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  69352. /**
  69353. * Returns the appropriate defines according to the current configuration.
  69354. */
  69355. private _getDefines;
  69356. /**
  69357. * Computes the current camera rotation as the shader requires a camera rotation.
  69358. */
  69359. private _computeCameraRotation;
  69360. }
  69361. }
  69362. declare module BABYLON {
  69363. /** @hidden */
  69364. export var brickProceduralTexturePixelShader: {
  69365. name: string;
  69366. shader: string;
  69367. };
  69368. }
  69369. declare module BABYLON {
  69370. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  69371. private _numberOfBricksHeight;
  69372. private _numberOfBricksWidth;
  69373. private _jointColor;
  69374. private _brickColor;
  69375. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69376. updateShaderUniforms(): void;
  69377. numberOfBricksHeight: number;
  69378. numberOfBricksWidth: number;
  69379. jointColor: BABYLON.Color3;
  69380. brickColor: BABYLON.Color3;
  69381. /**
  69382. * Serializes this brick procedural texture
  69383. * @returns a serialized brick procedural texture object
  69384. */
  69385. serialize(): any;
  69386. /**
  69387. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  69388. * @param parsedTexture defines parsed texture data
  69389. * @param scene defines the current scene
  69390. * @param rootUrl defines the root URL containing brick procedural texture information
  69391. * @returns a parsed Brick Procedural BABYLON.Texture
  69392. */
  69393. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  69394. }
  69395. }
  69396. declare module BABYLON {
  69397. /** @hidden */
  69398. export var cloudProceduralTexturePixelShader: {
  69399. name: string;
  69400. shader: string;
  69401. };
  69402. }
  69403. declare module BABYLON {
  69404. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  69405. private _skyColor;
  69406. private _cloudColor;
  69407. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69408. updateShaderUniforms(): void;
  69409. skyColor: BABYLON.Color4;
  69410. cloudColor: BABYLON.Color4;
  69411. /**
  69412. * Serializes this cloud procedural texture
  69413. * @returns a serialized cloud procedural texture object
  69414. */
  69415. serialize(): any;
  69416. /**
  69417. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  69418. * @param parsedTexture defines parsed texture data
  69419. * @param scene defines the current scene
  69420. * @param rootUrl defines the root URL containing cloud procedural texture information
  69421. * @returns a parsed Cloud Procedural BABYLON.Texture
  69422. */
  69423. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  69424. }
  69425. }
  69426. declare module BABYLON {
  69427. /** @hidden */
  69428. export var fireProceduralTexturePixelShader: {
  69429. name: string;
  69430. shader: string;
  69431. };
  69432. }
  69433. declare module BABYLON {
  69434. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  69435. private _time;
  69436. private _speed;
  69437. private _autoGenerateTime;
  69438. private _fireColors;
  69439. private _alphaThreshold;
  69440. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69441. updateShaderUniforms(): void;
  69442. render(useCameraPostProcess?: boolean): void;
  69443. static readonly PurpleFireColors: BABYLON.Color3[];
  69444. static readonly GreenFireColors: BABYLON.Color3[];
  69445. static readonly RedFireColors: BABYLON.Color3[];
  69446. static readonly BlueFireColors: BABYLON.Color3[];
  69447. autoGenerateTime: boolean;
  69448. fireColors: BABYLON.Color3[];
  69449. time: number;
  69450. speed: BABYLON.Vector2;
  69451. alphaThreshold: number;
  69452. /**
  69453. * Serializes this fire procedural texture
  69454. * @returns a serialized fire procedural texture object
  69455. */
  69456. serialize(): any;
  69457. /**
  69458. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  69459. * @param parsedTexture defines parsed texture data
  69460. * @param scene defines the current scene
  69461. * @param rootUrl defines the root URL containing fire procedural texture information
  69462. * @returns a parsed Fire Procedural BABYLON.Texture
  69463. */
  69464. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  69465. }
  69466. }
  69467. declare module BABYLON {
  69468. /** @hidden */
  69469. export var grassProceduralTexturePixelShader: {
  69470. name: string;
  69471. shader: string;
  69472. };
  69473. }
  69474. declare module BABYLON {
  69475. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  69476. private _grassColors;
  69477. private _groundColor;
  69478. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69479. updateShaderUniforms(): void;
  69480. grassColors: BABYLON.Color3[];
  69481. groundColor: BABYLON.Color3;
  69482. /**
  69483. * Serializes this grass procedural texture
  69484. * @returns a serialized grass procedural texture object
  69485. */
  69486. serialize(): any;
  69487. /**
  69488. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  69489. * @param parsedTexture defines parsed texture data
  69490. * @param scene defines the current scene
  69491. * @param rootUrl defines the root URL containing grass procedural texture information
  69492. * @returns a parsed Grass Procedural BABYLON.Texture
  69493. */
  69494. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  69495. }
  69496. }
  69497. declare module BABYLON {
  69498. /** @hidden */
  69499. export var marbleProceduralTexturePixelShader: {
  69500. name: string;
  69501. shader: string;
  69502. };
  69503. }
  69504. declare module BABYLON {
  69505. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  69506. private _numberOfTilesHeight;
  69507. private _numberOfTilesWidth;
  69508. private _amplitude;
  69509. private _jointColor;
  69510. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69511. updateShaderUniforms(): void;
  69512. numberOfTilesHeight: number;
  69513. amplitude: number;
  69514. numberOfTilesWidth: number;
  69515. jointColor: BABYLON.Color3;
  69516. /**
  69517. * Serializes this marble procedural texture
  69518. * @returns a serialized marble procedural texture object
  69519. */
  69520. serialize(): any;
  69521. /**
  69522. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  69523. * @param parsedTexture defines parsed texture data
  69524. * @param scene defines the current scene
  69525. * @param rootUrl defines the root URL containing marble procedural texture information
  69526. * @returns a parsed Marble Procedural BABYLON.Texture
  69527. */
  69528. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  69529. }
  69530. }
  69531. declare module BABYLON {
  69532. /** @hidden */
  69533. export var normalMapProceduralTexturePixelShader: {
  69534. name: string;
  69535. shader: string;
  69536. };
  69537. }
  69538. declare module BABYLON {
  69539. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  69540. private _baseTexture;
  69541. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69542. updateShaderUniforms(): void;
  69543. render(useCameraPostProcess?: boolean): void;
  69544. resize(size: any, generateMipMaps: any): void;
  69545. baseTexture: BABYLON.Texture;
  69546. /**
  69547. * Serializes this normal map procedural texture
  69548. * @returns a serialized normal map procedural texture object
  69549. */
  69550. serialize(): any;
  69551. /**
  69552. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  69553. * @param parsedTexture defines parsed texture data
  69554. * @param scene defines the current scene
  69555. * @param rootUrl defines the root URL containing normal map procedural texture information
  69556. * @returns a parsed Normal Map Procedural BABYLON.Texture
  69557. */
  69558. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  69559. }
  69560. }
  69561. declare module BABYLON {
  69562. /** @hidden */
  69563. export var perlinNoiseProceduralTexturePixelShader: {
  69564. name: string;
  69565. shader: string;
  69566. };
  69567. }
  69568. declare module BABYLON {
  69569. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  69570. time: number;
  69571. timeScale: number;
  69572. translationSpeed: number;
  69573. private _currentTranslation;
  69574. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69575. updateShaderUniforms(): void;
  69576. render(useCameraPostProcess?: boolean): void;
  69577. resize(size: any, generateMipMaps: any): void;
  69578. /**
  69579. * Serializes this perlin noise procedural texture
  69580. * @returns a serialized perlin noise procedural texture object
  69581. */
  69582. serialize(): any;
  69583. /**
  69584. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  69585. * @param parsedTexture defines parsed texture data
  69586. * @param scene defines the current scene
  69587. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  69588. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  69589. */
  69590. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  69591. }
  69592. }
  69593. declare module BABYLON {
  69594. /** @hidden */
  69595. export var roadProceduralTexturePixelShader: {
  69596. name: string;
  69597. shader: string;
  69598. };
  69599. }
  69600. declare module BABYLON {
  69601. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  69602. private _roadColor;
  69603. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69604. updateShaderUniforms(): void;
  69605. roadColor: BABYLON.Color3;
  69606. /**
  69607. * Serializes this road procedural texture
  69608. * @returns a serialized road procedural texture object
  69609. */
  69610. serialize(): any;
  69611. /**
  69612. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  69613. * @param parsedTexture defines parsed texture data
  69614. * @param scene defines the current scene
  69615. * @param rootUrl defines the root URL containing road procedural texture information
  69616. * @returns a parsed Road Procedural BABYLON.Texture
  69617. */
  69618. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  69619. }
  69620. }
  69621. declare module BABYLON {
  69622. /** @hidden */
  69623. export var starfieldProceduralTexturePixelShader: {
  69624. name: string;
  69625. shader: string;
  69626. };
  69627. }
  69628. declare module BABYLON {
  69629. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  69630. private _time;
  69631. private _alpha;
  69632. private _beta;
  69633. private _zoom;
  69634. private _formuparam;
  69635. private _stepsize;
  69636. private _tile;
  69637. private _brightness;
  69638. private _darkmatter;
  69639. private _distfading;
  69640. private _saturation;
  69641. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69642. updateShaderUniforms(): void;
  69643. time: number;
  69644. alpha: number;
  69645. beta: number;
  69646. formuparam: number;
  69647. stepsize: number;
  69648. zoom: number;
  69649. tile: number;
  69650. brightness: number;
  69651. darkmatter: number;
  69652. distfading: number;
  69653. saturation: number;
  69654. /**
  69655. * Serializes this starfield procedural texture
  69656. * @returns a serialized starfield procedural texture object
  69657. */
  69658. serialize(): any;
  69659. /**
  69660. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  69661. * @param parsedTexture defines parsed texture data
  69662. * @param scene defines the current scene
  69663. * @param rootUrl defines the root URL containing startfield procedural texture information
  69664. * @returns a parsed Starfield Procedural BABYLON.Texture
  69665. */
  69666. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  69667. }
  69668. }
  69669. declare module BABYLON {
  69670. /** @hidden */
  69671. export var woodProceduralTexturePixelShader: {
  69672. name: string;
  69673. shader: string;
  69674. };
  69675. }
  69676. declare module BABYLON {
  69677. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  69678. private _ampScale;
  69679. private _woodColor;
  69680. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69681. updateShaderUniforms(): void;
  69682. ampScale: number;
  69683. woodColor: BABYLON.Color3;
  69684. /**
  69685. * Serializes this wood procedural texture
  69686. * @returns a serialized wood procedural texture object
  69687. */
  69688. serialize(): any;
  69689. /**
  69690. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  69691. * @param parsedTexture defines parsed texture data
  69692. * @param scene defines the current scene
  69693. * @param rootUrl defines the root URL containing wood procedural texture information
  69694. * @returns a parsed Wood Procedural BABYLON.Texture
  69695. */
  69696. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  69697. }
  69698. }